DETAILS
To enable RTC, I enabled the flag in halconf.h and set STM32_RTCSEL to STM32_RTCSEL_LSI in mcuconf.h. Furthermore, I enabled all debug checks and assertions in chconf.h (CH_DBG_ENABLE_CHECKS and CH_DBG_ENABLE_ASSERTS).
When halInit() is called at the beginning of the main() function, it executes rtcInit(), which again calls rtc_lld_init() of the RTCv3 driver. This function eventually calls the STM32_RTC_ENABLE_ALL_EXTI() macro, which again executes extiEnableGroup1() of the EXTIv1 driver. At the very beginning of that function, there is an assertion, which fails:
Code: Select all
/* Masked out lines must not be touched by this driver.*/
osalDbgAssert((mask & STM32_EXTI_IMR1_MASK) == 0U, "fixed lines");
'mask' is the first argument of the call
Code: Select all
extiEnableGroup1(EXTI_MASK1(STM32_RTC_EVENT_RTC_EXTI) | EXTI_MASK1(STM32_RTC_EVENT_TAMP_EXTI),
EXTI_MODE_RISING_EDGE | EXTI_MODE_ACTION_INTERRUPT);
After briefly comparing the values of those defines in the code with the definitions in the reference manual (https://www.st.com/resource/en/referenc ... ronics.pdf), those seem to be correct.
BUG & FIX
The assertion itself, however, seems to be flawed in two ways:
- According to the comment it should check if any reserved bits are set in 'mask'. Unfortunately, it seems to checks all valid bits instead. This can be fixed easily by negating STM32_EXTI_IMR1_MASK.
- STM32_EXTI_IMR1_MASK is defined as 0xFFF8000U, which is the default value of the IMR1 register. The actual mask of valid bits would be 0xFEAFFFFFU. The same issue applies to STM32_EXTI_IMR2_MASK which is defined as 0xFFFFFFFFU (again the default value) instead of 0x00000003U.
When I apply those fixes, Everything seem to be fine, though I'd rather have someone double check to be sure.
Regards
Thomas