cancel
Showing results for 
Search instead for 
Did you mean: 

HAL Bug Report - F4xx, Timer Complimentary Outputs

mwp
Senior
Posted on September 22, 2016 at 16:11

Using latest CubeMX and HAL libs.

As far as i can see, HAL doesn't support a method for enabling the TIMx complimentary CHxN outputs.

In this case i want to use TIM1 CH1N and CH2N for PWM output.

Thanks.
7 REPLIES 7
Walid FTITI_O
Senior II
Posted on September 22, 2016 at 16:37

Hi MWP,

Did you configured that in CubeMx and the generated code does not output signal or the configuration does not exist on the CubeMx tool ? please share further your .ioc file.

-Hannibal-

mwp
Senior
Posted on September 22, 2016 at 18:41

The configuration exists in the CubeMX tool, but the HAL libraries don't support it.

The HAL library enables CH1 & CH2 not CH1N & CH2N as configured in CubeMX.

I can share the IOC, but not publicly (can i email it somewhere?).

BTW.... can you pleeeeease fix the login process for this forum.

Its so incredibly broken.

mwp
Senior
Posted on September 22, 2016 at 18:55

To be more specific...

This should work:

HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_1); //enable CH1N

HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_2); //enable CH2N

... but instead of enabling CH1N and CH2N, it enables CH1 and CH2 instead.

Ive looked thorough the HAL library source, and it appears there is no method available to enable CH1N and CH2N.

To work around the problem i have to do this:

__HAL_TIM_DISABLE(&htim1);

TIM1->CCER = 0; //all off

TIM1->CCER |= 0x44; //=CC2NE | CC1NE

//normal enable

__HAL_TIM_MOE_ENABLE(&htim1);

__HAL_TIM_ENABLE(&htim1);

Walid FTITI_O
Senior II
Posted on September 23, 2016 at 13:52

Hi MWP,

You are not implementing the right function to start the complimentary output. You should enable the CH1 and then enable CH1N (not the same function indeed) like below:

/* Start CH1 */
HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_1); 
/* Start CH2N */
HAL_TIM_PWMN_Start(&htim1, TIM_CHANNEL_1);

-Hannibal-

mwp
Senior
Posted on September 26, 2016 at 12:06

HAL_TIM_PWMN_Start() ... no such function exists.

I gather you mean 

HAL_TIMex_PWMN_Start()?

Why is it in the TIMex library section?

Did the dev's forget that the N channels exist, so had to add it in a separate library later?

The more i use HAL, the more i dislike it.

For a library that's meant to simplify use across stm32's it's doing a pretty bad job of it.

mwp
Senior
Posted on September 26, 2016 at 13:33

So this brings up the question... what is the ''correct'' way to find these functions?

Is there a big index with peripheral name vs function calls somewhere?
Walid FTITI_O
Senior II
Posted on September 30, 2016 at 17:57

HI MWP, 

You should check the user manual

http://www.st.com/content/ccc/resource/technical/document/user_manual/2f/71/ba/b8/75/54/47/cf/DM00105879.pdf/files/DM00105879.pdf/jcr:content/translations/en.DM00105879.pdf

''Description of STM32F4xx HAL driver''.

This user manual is structured as follows:

- Overview of the HAL drivers

- Detailed description of each peripheral driver: configuration structures, functions, and how to usethe given API to build your application.

To see all the Timer driver APIs , go to part ''63.2 TIMEx Firmware driver API description ''.

-Hannibal-