Regarding RTC inbuilt wakeup interrupt
Posted: Fri Dec 29, 2023 12:45 pm
Hi, I'm working on STM32F407 with RTC Wakeup interrupt in low power mode,
whenever I'm using the In-built RTC functions and try to use IRQ handler error is coming as "Multiple definitions of Vector 4C " tried commenting everywhere including os and hal files but not yet working, when tried with register level code the LSE is not getting ON and so interrupt not coming.
please help me resolve this as I am beginner who now only started.
I will share my RTC config with this post, request someone to help with this.
Thanks,
void rtc_init_func(void){
RCC->APB1ENR |= (1U << 28); // Enable Power interface clock
RCC->APB1LPENR |= (1U << 28); // Enable Power interface clock low power mode
// RCC->CFGR |= (1<<21); // Enabling LSE Oscillator in MCO1
PWR->CR |= (1U << 8);
RTC->WPR = 0xCA; // Unlock write protection
RTC->WPR = 0x53;
normal_clock_config();
if(!(RCC->BDCR & (1 << 15))){
RCC->BDCR |= (1<<16) ; // Reset the backup domain
RCC->BDCR = 0x00008101; // Set RTCEN, select LSE, set LSEON
while((RCC->BDCR & (1UL << 1)) == 0); // Wait for LSERDY
}
EXTI->IMR |= (1 << 22); // Set EXTI22 for wake-up timer
EXTI->RTSR |= (1 << 22); // Enable rising edge trigger
EXTI->FTSR &= ~(1 << 22); // Enable rising edge trigger
RTC->CR |= (1<<14); // Enable wake-up timer interrupt
// RTC->PRER = 0x7FFF; // Set the prescaler for 1Hz RTC clock
RTC->ISR |= (1U << 7); // Enter initialization mode, bit 7
while(RTC->ISR & (0 << 6));
RTC->CR &= ~(1U << 10); // Stop wake-up timer, to access it
while(RTC->ISR & (0 << 6)); // Wait for wake-up timer access
RTC->CR |= (3U << 0); // selecting CLK/2.
RTC->PRER = 0x007F00FF; // Set the prescaler for 1Hz RTC clock
RTC->WUTR = 0;
RTC->WUTR = 1; // Set timer period
RTC->CR |= (1U << 10); // Enable wake-up timer
RTC->ISR &= ~(1U << 7); // Exit initialization mode
RTC->WPR = 0xFF; // Lock write protect
PWR->CR &= ~(1U << 8); // Inhibit RTC access
NVIC_EnableIRQ(3);
NVIC_SetPriority(3, 15);
// nvicEnableVector(RTC_WKUP_IRQn, STM32_IRQ_EXTI22_PRIORITY);
chThdSleepMilliseconds(100);
}
whenever I'm using the In-built RTC functions and try to use IRQ handler error is coming as "Multiple definitions of Vector 4C " tried commenting everywhere including os and hal files but not yet working, when tried with register level code the LSE is not getting ON and so interrupt not coming.
please help me resolve this as I am beginner who now only started.
I will share my RTC config with this post, request someone to help with this.
Thanks,
void rtc_init_func(void){
RCC->APB1ENR |= (1U << 28); // Enable Power interface clock
RCC->APB1LPENR |= (1U << 28); // Enable Power interface clock low power mode
// RCC->CFGR |= (1<<21); // Enabling LSE Oscillator in MCO1
PWR->CR |= (1U << 8);
RTC->WPR = 0xCA; // Unlock write protection
RTC->WPR = 0x53;
normal_clock_config();
if(!(RCC->BDCR & (1 << 15))){
RCC->BDCR |= (1<<16) ; // Reset the backup domain
RCC->BDCR = 0x00008101; // Set RTCEN, select LSE, set LSEON
while((RCC->BDCR & (1UL << 1)) == 0); // Wait for LSERDY
}
EXTI->IMR |= (1 << 22); // Set EXTI22 for wake-up timer
EXTI->RTSR |= (1 << 22); // Enable rising edge trigger
EXTI->FTSR &= ~(1 << 22); // Enable rising edge trigger
RTC->CR |= (1<<14); // Enable wake-up timer interrupt
// RTC->PRER = 0x7FFF; // Set the prescaler for 1Hz RTC clock
RTC->ISR |= (1U << 7); // Enter initialization mode, bit 7
while(RTC->ISR & (0 << 6));
RTC->CR &= ~(1U << 10); // Stop wake-up timer, to access it
while(RTC->ISR & (0 << 6)); // Wait for wake-up timer access
RTC->CR |= (3U << 0); // selecting CLK/2.
RTC->PRER = 0x007F00FF; // Set the prescaler for 1Hz RTC clock
RTC->WUTR = 0;
RTC->WUTR = 1; // Set timer period
RTC->CR |= (1U << 10); // Enable wake-up timer
RTC->ISR &= ~(1U << 7); // Exit initialization mode
RTC->WPR = 0xFF; // Lock write protect
PWR->CR &= ~(1U << 8); // Inhibit RTC access
NVIC_EnableIRQ(3);
NVIC_SetPriority(3, 15);
// nvicEnableVector(RTC_WKUP_IRQn, STM32_IRQ_EXTI22_PRIORITY);
chThdSleepMilliseconds(100);
}