2022-08-29 05:26 AM - last edited on 2023-07-11 09:42 AM by Kevin HUBER
Hello,
I am trying to manage some interrupts in the M4, specifically the Tamper Interrupt.
Using the STM32CubeIDE (CubeMX) I am unable to select the Tamper interrupt that shows in the NVIC peripheral, when I select it, it gets deselected automatically. What could be the cause of this behaviour?
I am allocating the tamper peripheral to the non-secure world (A7) in SP-Min (Manually changed in source code) and enabling the external tampers. In M4 I try to enable the interrupt and set an IRQHandler with the following code:
void tamp_init (void)
{
HAL_NVIC_SetPriority (TAMP_IRQn, 1, 0);
HAL_NVIC_EnableIRQ (TAMP_IRQn);
}
void TAMP_IRQHandler (void)
{
// Do something (turn led on)
}
I have a button connected to the tamper input signal, when I press this button I expect to see the led light up but it does not. I know the tamper is triggered because the backup registers are cleared.
What is missing in my configuration or how should I set up the interrupts? Should I configure something in the A7 GIC or EXTI?
Best regards,
Andrés
2022-09-09 07:48 AM
Hello,
not sure at this point regarding the CubeMx behaviour.
However in your code have you the below items ?
in the main.c
1)
configuration of the Tamper (example from other product but should be very similar)
stamperstructure.Tamper = RTC_TAMPER_2;
stamperstructure.Trigger = RTC_TAMPERTRIGGER_FALLINGEDGE;
stamperstructure.Filter = RTC_TAMPERFILTER_DISABLE;
stamperstructure.SamplingFrequency = RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV32768;
stamperstructure.PrechargeDuration = RTC_TAMPERPRECHARGEDURATION_1RTCCLK;
stamperstructure.TamperPullUp = RTC_TAMPER_PULLUP_ENABLE;
stamperstructure.TimeStampOnTamperDetection = RTC_TIMESTAMPONTAMPERDETECTION_DISABLE;
if (HAL_RTCEx_SetTamper_IT(&RtcHandle, &stamperstructure) != HAL_OK)
{
/* Initialization Error */
Error_Handler();
}
2) define call back function
void HAL_RTCEx_Tamper2EventCallback(RTC_HandleTypeDef *hrtc)
{
TamperStatus = SET;
}
/*##- Wait for the tamper button is pressed ##############################*/
while (TamperStatus != SET)
{
/* Delay */
HAL_Delay(1000);
}
/* Do something */
….
in the stm32mp15xx_it.c
1) define the IRQHandler
void TAMP_IRQHandler(void)
{
HAL_RTCEx_TamperIRQHandler(&RtcHandle);
}
JM