2020-09-10 08:42 AM
Hello! I have configured the RTC in cube with a frequency of 1Hz in the board STM32WB55, and I want so as to each second the RTC interruption set a task. I found out that I should use RTC_IRQHandler, but in my project I can't found this function, I don't know how to enable RTC interruption, in cube V1.5 I only see the alarm's interruptions. How should I proceed?
2020-09-10 12:07 PM
Enable the RTC Wakeup in STMCubeMx and set it to 1Hz. You can then use the callback function created by CubeMX to do whatever you want within the programm.
Good luck!
/Peter
2020-09-10 12:43 PM
thanks for the answer Peter. Could you say how it's called the callback?
I used HAL_RTCEx_WakeUpTimerEventCallback and the program seems not to achieve this function even after overloading it.
2020-09-11 02:30 AM
First: did you enable the internal wakeup within CubeMX?
Did you also enable the RTC wake-up through EXTI.22 within the NVIC settings?
Then you should put your subroutine in a user code area, e.g. USER CODE 4:
void HAL_RTCEx_WakeUpTimerEventCallback(RTC_HandleTypeDef *hrtc) {
// do something
}
You probably forgot to activate the NVIC line, right?
2020-09-12 08:12 AM
I have done all that you have mentioned. Here is my configurations
2020-09-12 05:42 PM
I tried to take out APPE_Init(); and UTIL_SEQ_Run(UTIL_SEQ_DEFAULT); and it got working. But I need BLE too
2020-10-16 01:42 AM
Use virtual timers.
// add to structure definition
uint8_t led_timer_Id;
/* USER CODE BEGIN PD */
#define LED_BLINK (1.0*1000*1000/CFG_TS_TICK_VAL) //1.0sec, 1Hz
//#define LED_BLINK (0.1*1000*1000/CFG_TS_TICK_VAL) //100ms, 10Hz
/* USER CODE END PD */
/* USER CODE BEGIN PFP */
static void Led_blink_Timer_Callback(void);
/* USER CODE END PFP */
void Custom_APP_Init(void)
{
// Virtual timer blink blue LED
HW_TS_Create(CFG_TIM_PROC_ID_ISR, &(Custom_App_Context.led_timer_Id), hw_ts_Repeated, Led_blink_Timer_Callback);
//HW_TS_Start(Custom_App_Context.led_timer_Id, LED_BLINK); // <--start with this
//HW_TS_Stop(Custom_App_Context.led_timer_Id); // <--stop with that
return;
}
static void Led_blink_Timer_Callback(void){
HAL_GPIO_WritePin(LED_BLUE_GPIO_Port, LED_BLUE_Pin, 1);
HAL_Delay(1);
HAL_GPIO_WritePin(LED_BLUE_GPIO_Port, LED_BLUE_Pin, 0);
}
Ensure you have this into your "stm32wbxx_it.c"
/* USER CODE BEGIN Includes */
#include "app_common.h"
/* USER CODE END Includes */
/* USER CODE BEGIN 1 */
void RTC_WKUP_IRQHandler(void)
{
HW_TS_RTC_Wakeup_Handler();
}
void IPCC_C1_TX_IRQHandler(void)
{
HW_IPCC_Tx_Handler();
return;
}
void IPCC_C1_RX_IRQHandler(void)
{
HW_IPCC_Rx_Handler();
return;
}
/* USER CODE END 1 */
2021-10-28 05:30 AM
For me CubeMX initialized the RTC with
static void MX_RTC_Init(void)
{
..
if (HAL_RTCEx_SetWakeUpTimer(&hrtc, 0, RTC_WAKEUPCLOCK_CK_SPRE_16BITS) != HAL_OK)
..
}
And when I checked the P2Pserver reference example, the Init code hade
(HAL_RTCEx_SetWakeUpTimer_IT(&hrtc, 0, RTC_WAKEUPCLOCK_RTCCLK_DIV16) != HAL_OK)
instead, and after chaning my code to the RTC_WAKEUPCLOCK_RTCCLK_DIV16 it worked!!
2 days worth of chasing en error other parts of the code