cancel
Showing results for 
Search instead for 
Did you mean: 

How to use the RTC tamper level detetion function ?

Denson Li
Associate
Posted on June 24, 2018 at 05:40

The tamper level detection configuration shown below

void init_BspTamper()

{

RTC_TamperTypeDef  stamperstructure;

  RtcHandle.Instance            = RTC;

  RtcHandle.Init.HourFormat     = RTC_HOURFORMAT_24;

  RtcHandle.Init.AsynchPrediv   = RTC_ASYNCH_PREDIV;

  RtcHandle.Init.SynchPrediv    = RTC_SYNCH_PREDIV;

  RtcHandle.Init.OutPut         = RTC_OUTPUT_DISABLE;

  RtcHandle.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH;

  RtcHandle.Init.OutPutType     = RTC_OUTPUT_TYPE_OPENDRAIN;

 

  if (HAL_RTC_Init(&RtcHandle) != HAL_OK)

  {

    /* Initialization Error */

    //Error_Handler();

  }

  //Configure RTC Tamper

  stamperstructure.Tamper                       = RTC_TAMPER_1;

  stamperstructure.Trigger                      = RTC_TAMPERTRIGGER_LOWLEVEL;

  stamperstructure.Filter                       = RTC_TAMPERFILTER_2SAMPLE;//定义采样次数

  stamperstructure.SamplingFrequency            = RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV256;

  stamperstructure.PrechargeDuration            = RTC_TAMPERPRECHARGEDURATION_1RTCCLK;1RTCCLK=30us

  stamperstructure.TamperPullUp                 = RTC_TAMPER_PULLUP_ENABLE;

  stamperstructure.TimeStampOnTamperDetection   = RTC_TIMESTAMPONTAMPERDETECTION_DISABLE;

  stamperstructure.NoErase                      = RTC_TAMPER_ERASE_BACKUP_ENABLE;

  stamperstructure.MaskFlag                     = RTC_TAMPERMASK_FLAG_DISABLE;

  stamperstructure.Interrupt                    = RTC_TAMPER1_INTERRUPT;

 

  //HAL_StatusTypeDef HAL_RTCEx_SetTamper_IT(RTC_HandleTypeDef *hrtc, RTC_TamperTypeDef* sTamper)

  //

//  if (HAL_RTCEx_SetTamper_IT(&RtcHandle, &stamperstructure) != HAL_OK)

//  {

//    /* Initialization Error */

//    //Error_Handler();

//  }

}

see from the code in HAL_RTCEx_SetTamper_IT(RTC_HandleTypeDef *hrtc, RTC_TamperTypeDef* sTamper) function,it seems that the level detetion can't use the tamper interrupt , because in the function it enabled the exti rising edge(__HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_RISING_EDGE();).

so ,if tamper level detection doesn't use the interrupt, how to get the event  occured information.

should i use tamper event polling function  (HAL_RTCEx_PollForTamper1Event) to check if the tamper has occured. but i don't know if i use the polling function ,do i need to configure the EXTI?

0 REPLIES 0