cancel
Showing results for 
Search instead for 
Did you mean: 

PWM/ADC HAL callback referall

hesam moshiri
Associate III
Posted on July 08, 2018 at 12:14

Hi,

As we know peripherals can have callback functions such as the below one for the PWM:

void HAL_TIM_PWM_PulseFinishedCallback(TIM_HandleTypeDef *htim) {

}

This is something like a general callback, But if we have several enabled PWMs or ADCs or similar, then how these could be differentiated by the callback functions to be fired just by the one we like, or for the time we like to have several callbacks, one for each. is that possible?

1 ACCEPTED SOLUTION

Accepted Solutions
Posted on July 08, 2018 at 15:04

The mechanics of the HAL is to pass an object/handle to the callbacks, this is unique for each peripheral, and from it you can determine the source.

Here you'd build an if/then/else tree via htim->Instance == TIMx

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

View solution in original post

4 REPLIES 4
Posted on July 08, 2018 at 15:04

The mechanics of the HAL is to pass an object/handle to the callbacks, this is unique for each peripheral, and from it you can determine the source.

Here you'd build an if/then/else tree via htim->Instance == TIMx

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on July 08, 2018 at 16:38

Thank you.

is there any resource to study these more in depth?

Also I'm looking for a source that explains timer trigger, compare and all sort of staff.

Posted on July 08, 2018 at 16:53

The HAL is provided with complete source code, and the code trees contain dozens of examples and demo applications, for dozens of boards.

Use a file manager, or static analysis tool of your own preference to navigates the available resources, find examples that closely match your goals and port to the target platform.

0690X00000604lAQAQ.jpg
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on July 08, 2018 at 17:08

Do these sources get installed in accompany with the CubeMX? I can not find them in the installation path.