Center Aligned PWM
Posted: Fri May 15, 2020 12:46 pm
Hello,
I am a bit of a Newbie here. Last year I made a 3 phase bldc controller using the stm32f103, for that I implemented a centre aligned (symmetric) PWM with the help of this forum. Unfortunately I lost my code during a PC reset and worst yet all the links on this forum that helped me achieve it are now down. I desperately need to get it working again since I have made significant investements in hardware with the hope of writing the same code again.
I need help to get the PWMs in timer 1 and timer 4 to work in center aligned mode, as for now they work in edge aligned. Help would be much appreciated in how to manipuilate the timers to achieve this. As mentioned I got all the answer initially on this forum but those links are now dead.
outputs on timer1 (PA8 PA10 and PA9) look like so
I believe the answer was in one of these links but they are down;
viewtopic.php?t=1318
viewtopic.php?t=2561
viewtopic.php?t=3957
Looking forward to your suggestions, could really use some help here,
Thank you
I am a bit of a Newbie here. Last year I made a 3 phase bldc controller using the stm32f103, for that I implemented a centre aligned (symmetric) PWM with the help of this forum. Unfortunately I lost my code during a PC reset and worst yet all the links on this forum that helped me achieve it are now down. I desperately need to get it working again since I have made significant investements in hardware with the hope of writing the same code again.
I need help to get the PWMs in timer 1 and timer 4 to work in center aligned mode, as for now they work in edge aligned. Help would be much appreciated in how to manipuilate the timers to achieve this. As mentioned I got all the answer initially on this forum but those links are now dead.
Code: Select all
void setup(){
Timer1.pause();
Timer4.pause();
Timer1.setPrescaleFactor(1);
Timer1.setOverflow(1500);
Timer4.setPrescaleFactor(1);
Timer4.setOverflow(1500);
Timer1.refresh();
Timer4.refresh();
Timer1.resume();
Timer4.resume();
pinMode (PA8, PWM);
pinMode (PA9, PWM);
pinMode (PA10, PWM);
pinMode (PB6, PWM);
pinMode (PB7, PWM);
pinMode (PB8, PWM);
}
void loop()
{
pwmWrite(PA8, 1000);
pwmWrite(PA9, 200);
pwmWrite(PA10, 500);
pwmWrite(PB6, 200);
pwmWrite(PB7, 300);
pwmWrite(PB8, 400);
}
viewtopic.php?t=1318
viewtopic.php?t=2561
viewtopic.php?t=3957
Looking forward to your suggestions, could really use some help here,
Thank you