Skip to main content
martinstingl
Associate
May 26, 2014
Question

USE_FULL_ASSERT macro does not give warning

  • May 26, 2014
  • 1 reply
  • 647 views
Posted on May 26, 2014 at 15:55

Hi,

I have had an error in my program and was wondering why the assertion macro did not give a warning for the second line, the first line is correct:

RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE);

RCC_APB2PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE);

The reason seems to be that the value of RCC_APB1Periph_TIM2 is 0x00000001 which is also the valid value of RCC_APB2Periph_TIM1 which would be OK for APB2, so no error is reported.

What is the sense of assert_failed if such easy detectable error aren't recognized?

Could the macro be extended to detect errors like these?

    This topic has been closed for replies.

    1 reply

    Tesla DeLorean
    Guru
    May 26, 2014
    Posted on May 26, 2014 at 21:16

    The assert's aren't idiot proof.

    There are only 32-bits in the vectors, and nothing other than the name ties the peripheral enable to APB1 or APB2.

    People will mix up the Reset and Clock functions, and mix up AHB, APB1 and APB2, be more attentive, the compiler isn't going to catch them. In another world people might use enum instead of defines.

    [DEAD LINK /public/STe2ecommunities/mcu/Lists/STM32Java/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/STM32Java/SM32L1xx%20Standard%20Peripherals%20Library%20Drivers%2c%20IS_RCC_APB1_PERIPH%28PERIPH%29&FolderCTID=0x01200200770978C69A1141439FE559EB459D758000F9A0E3A95BA69146A17C2E80209ADC21&currentviews=67]Related thread
    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..