cancel
Showing results for 
Search instead for 
Did you mean: 

How assert_param macro work

SS.Sagar
Associate III
Posted on May 29, 2016 at 09:50

Hi,

I m using cubemx for stacks. In files i foundassert_param is used for parameter checking. I don't understand how it is work. Here is syntax and use of that.

#define assert_param(expr) ((void)0)
assert_param(IS_UART_WORD_LENGTH(huart->Init.WordLength));

what will happen in both cases like

IS_UART_WORD_LENGTH returns 0 and 1.

#printf #assert #!cubemx #cubemx #debug
1 REPLY 1
Walid FTITI_O
Senior II
Posted on May 30, 2016 at 13:02

Hi hobb.epy,

assert_param is used to check that a parameter that is passed to a firmware library function is in the valid range of values. Each call to assert_param uses another macro that checks the parameter is in that range. If it is in range, then assert_param does nothing. If it is a bad value, then assert_failed is called with the filename and line number.

The assert_param function is disabled by default, and can be enabled by uncommenting the correspondent macro ( for example in Hal library , in stm32fxx_hal_conf.h :

/* #define USE_FULL_ASSERT    1 */ )

-Hannibal-