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;
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;
Any suggestion?