cancel
Showing results for 
Search instead for 
Did you mean: 

TIM2, assert_failed and MX

hbarta2
Associate III
Posted on September 14, 2015 at 15:16

Monday mornings don;t usually bother me but today seems different. I have commented out some code in gpio.c (for an input that is not presently used) and now I get run time assertions in timer configuration. The line that asserts is:

assert_param(IS_TIM_CLOCKPOLARITY(sClockSourceConfig->ClockPolarity));

And sure enough, the value of that field looks like garbage and the MX generated code that callsHAL_TIM_ConfigClockSource() does not set this field. I have two questions about this. Why is this assert failing now? I not generated code using MX since late August. How can I figure out what a timer is used for int the first place? This is TIM2 on an STM32F429I and was not explicitly configured in the first place. I suppose it is used for some other chip peripheral but I cannot see a way to determine what. I tried commenting out the call toMX_TIM2_Init() in main.c to see what no longer works and I find that the next timer init (MX_TIM8_Init()) now fails on the same assertion. Looking at the timer configuration dialogs it is not even obvious what the polarity be. I'm baffled about how to resolve this so I can get back to work. Thanks! #tim2-assert
7 REPLIES 7
hbarta2
Associate III
Posted on September 14, 2015 at 16:00

The followingcode:

static FLASH_OBProgramInitTypeDef OBInit;
HAL_FLASHEx_OBGetConfig(&OBInit);
OBInit.BORLevel = OB_BOR_LEVEL1;
HAL_StatusTypeDef st = HAL_FLASHEx_OBProgram(&OBInit);

Is also generating an assert at:

static HAL_StatusTypeDef FLASH_OB_DisableWRP(uint32_t WRPSector, uint32_t Banks)
{
HAL_StatusTypeDef status = HAL_OK;
/* Check the parameters */
assert_param(IS_OB_WRP_SECTOR(WRPSector));
assert_param(IS_FLASH_BANK(Banks));

(Last line above fails assert line 723 instm32f4xx_hal_flash_ex.c) Not new code!
hbarta2
Associate III
Posted on September 14, 2015 at 16:17

I guess what changed is that a breakpoint got set in assert_failed(() in main.c. This happens with IAR if I make changes to code earlier in the file as it sets breakpoints by line number.

I guess that still raises the question why these asserts failed. MX buglets? (Checking for parameters that are not set and apparently do not matter?)

And I still wonder what those timers are used for.

Thanks!

Posted on September 14, 2015 at 19:15

Hi HankB,

1-Concerning the timer issue, it has been reported to our developer team. Also, other forum users reported it (

https://my.st.com/public/STe2ecommunities/mcu/Lists/STM32Java/Flat.aspx?RootFolder=https://my.st.com/public/STe2ecommunities/mcu/Lists/STM32Java/Bug%20Report%20CubeMX%8.0%20with%20STM32F4%6.0%20asserts%20from%20missing%20parameters%20in%20generated%20code%20%2b%20unused%20variable&FolderCTID=0x01200...

), and Maylahas intervened.

You can comment the assert line as a workaround.

2-Concerning the flash issue, Could you precise which version of CubeMx and HAL package are you using? And if it is possible, explain to us the testcase, so we can help.

-Shahrzad-

hbarta2
Associate III
Posted on September 18, 2015 at 14:47

Hi 

shahrzad,

MX -> 4.9.0 (.IOC file shows ''MxCube.Version=4.7.0'')

HAL -> 1.5.0 (No hint that I could see in .IOC file)

thanks,

hank

hbarta2
Associate III
Posted on September 18, 2015 at 14:48

Hi 

shahrzad,

MX -> 4.9.0 (.IOC file shows ''MxCube.Version=4.7.0'')

HAL -> 1.5.0 (No hint that I could see in .IOC file)

thanks,

hank

hbarta2
Associate III
Posted on September 18, 2015 at 14:48

Hi 

shahrzad,

MX -> 4.9.0 (.IOC file shows ''MxCube.Version=4.7.0'')

HAL -> 1.5.0 (No hint that I could see in .IOC file)

thanks,

hank

hbarta2
Associate III
Posted on September 18, 2015 at 14:50

Triple post!

On the first two tries the forum S/W threw up error messages.

Maybe some day this will be fixed.