Skip to main content
SS.Sagar
Associate III
May 29, 2016
Question

How assert_param macro work

  • May 29, 2016
  • 1 reply
  • 3468 views
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
This topic has been closed for replies.

1 reply

Walid FTITI_O
Visitor II
May 30, 2016
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-