Page 1 of 1

PWM Periodic Notifications

Posted: Tue May 17, 2016 4:11 pm
by swedishhat
I'm new to ChibiOS and I'm working my way through some of the PWM-ICU demo code (specifically for the STM32F302R8) . In the example the main function calls pwmEnablePeriodicNotification() and pwmEnableChannelNotification(). I looked at the API docs but I'm still confused on what the periodic activation edge notification actually is. Since this is a HAL demo that uses the OSAL but not the RTOS, does this just enable interrupts that get fired at the end of the PWM's period and at the end of the positive PWM pulse? If this is the case, are the function pointers specified in the PWMConfig struct that determine what's being called back once the interrupts fire?

Re: PWM Periodic Notifications

Posted: Tue May 17, 2016 4:33 pm
by RoccoMarco
pwmEnablePeriodicNotification() enables interrupt on starting edge and pwmEnableChannelNotification() enables interrupt on channel commutation edge.

It is not required to produce (and hence serve) Interrupts in certain applications: as example if the only purpose is to generate a square-wave on a certain timer output: here you can keep notifications disabled.

On the other hand, sometimes we would like to generate interrupt on periodic commutation or on channel notification. This will trigger an ISR which will execute that callback functions you have declared in the PWMConfig (in demos they are usually called pwmpcb which is the periodic callback, pwmpc1cb which is the channel 1 callback). User can popolate these callbacks and perform certain simple operations like turn on or turn off a LED which is not directly connected to any TIM output.

I have a handmade draw which would explain when notifications are triggered in case of a PWM having two active high channels:
20160517_173419.jpg

I suggest this article for more
Ciao,
RM