cancel
Showing results for 
Search instead for 
Did you mean: 

I squeezed the error down to '' assert_param''

mehmet.karakaya
Associate III
Posted on September 01, 2010 at 19:41

I squeezed the error down to ' assert_param'

#preprocessor-output
9 REPLIES 9
trevor23
Associate III
Posted on May 17, 2011 at 14:05

asssert_param macro calls assert_failed function which you need to define in order to send error information to serial port or LCD or monitor or whatever you like (this is user specific).

e.g if you've got printf available you could do this

void assert_failed(u8* file, u32 line)

{

  printf( ''\r\nassert_failed(). file: %s, line: %ld\r\n'', file, line );

  while (1)

  {}

}

mehmet.karakaya
Associate III
Posted on May 17, 2011 at 14:05

undefined reference to `assert_param' 

hello , thank you for your answer

what I wanted to ask is

why it still gives error although I defined the ''assert param'' macro ?

Andrew Neil
Evangelist
Posted on May 17, 2011 at 14:05

''why it still gives error although I defined the assert_param macro ?''

Clearly, the compiler is not ''seeing'' your definition at the points where it is reporting this error!

For preprocessor problems like this, you need to examine the preprocessor output to see exactly what's happening.

See the Documentation for your particular compiler for how to see the preprocessor output

eg,see: 

http://www.8052.com/forum/read/149260

trevor23
Associate III
Posted on May 17, 2011 at 14:05

Can you show how you have defined assert_param? Maybe you should attach your stm3210x_conf.h as I'm not sure what you have done. As I said all you have to do is define assert_failed -- you don't do anything to assert_param macro.

In stm3210x_conf.h assert_param is defined like so

#ifdef  USE_FULL_ASSERT

  #define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__))

  void assert_failed(uint8_t* file, uint32_t line);

#else

  #define assert_param(expr) ((void)0)

#endif

mehmet.karakaya
Associate III
Posted on May 17, 2011 at 14:05

unbelievable but I compiled one project successfully

I simply included #include ''stm32f10x_conf.h'' line

in every library file like ..._usart.c or ..._gpio.c

secondly also I wrote the line #include ''stm32f10x_conf.h'' on top of other include files lines

( it means the order of include lines is also important for the compiler )

---------------------------

ok - now I have other questions

I dont have eval boards of ST

instead I have this board

http://www.futurlec.com/ET-STM32_Stamp.shtml

in gpio_toggle example of peripeheral library

it says

main.c

-----------------------------------

 /* Initialize Leds mounted on STM3210X-EVAL board */

  STM_EVAL_LEDInit(LED1);

----------------------------------------------------------

in stm3210e_eval.c

---------------------------------------------

void STM_EVAL_LEDInit(Led_TypeDef Led)

{

  GPIO_InitTypeDef  GPIO_InitStructure;

 

  /* Enable the GPIO_LED Clock */

  RCC_APB2PeriphClockCmd(GPIO_CLK[Led], ENABLE);

  /* Configure the GPIO_LED pin */

  GPIO_InitStructure.GPIO_Pin = GPIO_PIN[Led];

  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;

  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

  GPIO_Init(GPIO_PORT[Led], &GPIO_InitStructure);

}

how I must change this code to put a LED to Port PA0 for example ?
Posted on May 17, 2011 at 14:05

>>how I must change this code to put a LED to Port PA0 for example ?

Try downloading and looking at ALL the example code provided in the STM32 Firmware Library?

  GPIO_InitTypeDef  GPIO_InitStructure;

 

  RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);

  /* Configure the PA.00 pin */

  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;

  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;

  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

  GPIO_Init(GPIOA, &GPIO_InitStructure);
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Andrew Neil
Evangelist
Posted on May 17, 2011 at 14:05

''it means the order of include lines is also important for the compiler''

Note that #include and macro expansion is handled by the preprocessor -

not

the compiler!

And, of course, any symbol needs to be declared before it can be used - so, if a macro definition is made in a header file, then that header file has to be included before anything else that uses the macro!

That's what I meant about the compiler ''seeing'' your definition.

pawel_popiolek
Associate II
Posted on February 27, 2012 at 14:15

The better way (in my opinion) is uncomment the line:

#ifdef USE_STDPERIPH_DRIVER

#include ''stm32f4xx_conf.h''

#endif

in stm32f4xx.h file 

or set the  USE_STDPERIPH_DRIVER flag 

Posted on February 27, 2012 at 16:35

That, or send -DUSE_STDPERIPH_DRIVER to the compiler.

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