STM32F070F6 PWM problem

General discussion on mikroPascal PRO for ARM.
Post Reply
Author
Message
ZbynekSkvor
Posts: 28
Joined: 18 Nov 2016 09:09

STM32F070F6 PWM problem

#1 Post by ZbynekSkvor » 29 Apr 2024 19:05

Hi,
can anybody suggest where the mistake is? The code compiles OK.

Code: Select all

procedure half(mag:real);
var vel,pwm_period:word;
 i:integer;
begin
 lbridgeOn;
 if mag>1 then mag:=1;
 for i:=0 to ndel do begin
   pwm_period := PWM_TIM3_Init(2000);
   vel:=mag*pwm_period*sin(i*pi/ndel);
   PWM_TIM3_Set_Duty(vel, _PWM_NON_INVERTED, _PWM_CHANNEL2);
   PWM_TIM3_Start(_PWM_CHANNEL2, @_GPIO_MODULE_TIM3_CH2_PA7);
   delay_ms(100);
   PWM_TIM3_Stop(_PWM_CHANNEL2) ;
 end;
end;
The code does nothing (I can trace variable values, these are OK, but there is no output at PA7). Using STM32F070F6. Tim 3 as well as PA7 tested by

Code: Select all

procedure Timer3_interrupt(); iv IVT_INT_TIM3;
begin
 TIM3_SR.UIF := 0;
 if tam then rbridge:=cast<mezt
 else lbridge:=cast<mezt;
 cast:=cast+1;
 if cast>999 then cast:=0;
end;


procedure starttim3(v:word);
begin
 //TIM6_CR1.CEN := 0;
 lbridge:=0;
 RCC_APB1ENR.TIM3EN := 1; // Enable clock gating for timer module 3
 TIM3_CR1.CEN := 0; // Disable timer
 TIM3_PSC := 4; // Set timer prescaler.
 TIM3_ARR := 5;
 NVIC_IntEnable(IVT_INT_TIM3); // Enable timer interrupt
 TIM3_DIER.UIE := 1; // Update interrupt enable
 cast:=0;
 mezt:=v;
 TIM3_CR1.CEN := 1; // Enable timer
end;
This produces a PWM signal at PA7... so it is not a hardware problem.

Any suggestion?

Post Reply

Return to “mikroPascal PRO for ARM General”