LPTIM1 ISR never cleared STM32L031G6
Hello, I would like to know if anyone has already encountered this problem.
I have an LPTIMER configured with an ARR Match interrupt at 100ms
I also want to enter my interrupt every 10ms so I added an interrupt in compare mode at 10ms.
I have 2 questions:
- When I enter my interrupt I test the interrupt that was called but both are permanently TRUE, is it possible to use the COMPARE mode interrupt with the ARR Match interrupt?
- The register allowing to clear the interrupts does not seem to work in my case, because before exiting I clear all possible interruptions through the LPTIM1->ICR register but the ISR register is still equals to 1 for all of my interrupts... Do we have to wait several instructions before I check it ?
**INIT LPTimer
//--- Demarrage LSI (oscillateur interne RC 37kHz)---
RCC->CSR |= RCC_CSR_LSION;
//--- Selection LSI pour LPTIM ---
RCC->CCIPR |= RCC_CCIPR_LPTIM1SEL_0;
//--- Validation clock LPTIM ---
RCC->APB1ENR |= RCC_APB1ENR_LPTIM1EN;
//--- Conf LPTIM
LPTIM1->CFGR |= LPTIM_CFGR_PRESC_2; //-- Prescaler = 100b = /16 => 37000/16 = 2312,5Hz
LPTIM1->IER |= LPTIM_IER_ARRMIE;
LPTIM1->IER |= LPTIM_IER_CMPMIE;
LPTIM1->CR |= LPTIM_CR_ENABLE; //-- Enable LPTimer
LPTIM1->ARR = 232; // T = (1 / 2312,5Hz) x 232 = 100ms
LPTIM1->CMP = 22;
LPTIM1->CR |= LPTIM_CR_CNTSTRT;
//--- All interrupt configured to ON
NVIC_EnableIRQ(LPTIM1_IRQn);
*INTERRUPT
//-----------------------------------------------------------------------------
void LPTIM1_IRQHandler(void)
//-----------------------------------------------------------------------------
{
if((LPTIM1->ISR & LPTIM_ISR_CMPM))
{
lpTim.uptime_cmp++;
}
if (LPTIM1->ISR & LPTIM_ISR_ARRM)
{
//DEBUG
LED_ORANGE_ON;
Delay10usASM();
LED_ORANGE_OFF;
//--DEBUG
lpTim.flag = TRUE;
lpTim.uptime++;
}
LPTIM1->ICR = 0x0000007F; //--- Clear all Flag
}
Thanks.
