Skip to main content
mehmet.karakaya
Associate III
September 1, 2010
Question

I squeezed the error down to '' assert_param''

  • September 1, 2010
  • 9 replies
  • 1945 views
Posted on September 01, 2010 at 19:41

I squeezed the error down to ' assert_param'

#preprocessor-output
    This topic has been closed for replies.

    9 replies

    mehmet.karakaya
    Associate III
    May 17, 2011
    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 ?

    trevor23
    Associate III
    May 17, 2011
    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)

      {}

    }

    trevor23
    Associate III
    May 17, 2011
    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

    Andrew Neil
    Super User
    May 17, 2011
    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

    A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
    Andrew Neil
    Super User
    May 17, 2011
    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.

    A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
    Tesla DeLorean
    Guru
    May 17, 2011
    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 (See Profile) Up vote any posts that you find helpful, it shows what's working..
    mehmet.karakaya
    Associate III
    May 17, 2011
    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 ?
    pawel_popiolek
    Associate
    February 27, 2012
    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 

    Tesla DeLorean
    Guru
    February 27, 2012
    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 (See Profile) Up vote any posts that you find helpful, it shows what's working..