2014-05-26 06:55 AM
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?2014-05-26 12:16 PM
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¤tviews=67]Related thread