Skip to main content
Visitor II
September 24, 2024
Question

Can not set tamper trigger LOWLEVEL in stm32g4xx_hal_rtc_ex.c

  • September 24, 2024
  • 1 reply
  • 792 views

In the file "stm32g4xx_hal_rtc_ex.c" in the function "HAL_RTCEx_SetTamper_IT(...)" there is an if-statement:

 

 if (sTamper->Trigger != RTC_TAMPERTRIGGER_RISINGEDGE)
 {
 tmpreg |= (sTamper->Tamper << TAMP_CR2_TAMP1TRG_Pos);
 }

 

And the corresponding .h file has:

 

#define RTC_TAMPERTRIGGER_RISINGEDGE 0x00U /*!< Warning : Filter must be RTC_TAMPERFILTER_DISABLE */
#define RTC_TAMPERTRIGGER_FALLINGEDGE 0x01U /*!< Warning : Filter must be RTC_TAMPERFILTER_DISABLE */
#define RTC_TAMPERTRIGGER_LOWLEVEL 0x02U /*!< Warning : Filter must not be RTC_TAMPERFILTER_DISABLE */
#define RTC_TAMPERTRIGGER_HIGHLEVEL 0x03U /*!< Warning : Filter must not be RTC_TAMPERFILTER_DISABLE */

 

This becomes an issue if configuring for RTC_TAMPERTRIGGER_LOWLEVEL.

The issue seems to be that the code inside the if-statement sets the TAMP1TRG bit to 1 if true. Since the defines for the different triggers are numbered from 0 to 3, TAMP1TRG will always be 1 so long as we are not using RISINGEDGE. However, to use LOWLEVEL, we want TAMP1TRG to be set to 0.

    This topic has been closed for replies.

    1 reply

    ST Employee
    September 26, 2024

    Hi All,

     

    This post has been escalated to the ST Online Support Team for additional assistance. We'll contact you directly.

     

    Regards,
    Jake

    ST Support