My usecase for the timer was to do some profiling of the code.As suggested i have made the modifications as below.
void LPTMR0_init(void)
{
PCC->PCCn[PCC_LPTMR0_INDEX] = PCC_PCCn_CGC_MASK;
// PCC->PCCn[PCC_LPTMR0_INDEX] = 0x0;
// LPTMR0->PSR = 0; /* Enable LPTMR Clock */
// LPTMR0->PSR |= LPTMR_PSR_PCS(0b01) /* LPTMR clk src: 1KHz LPO */
// | LPTMR_PSR_PBYP_MASK;
LPTMR0->PSR |= 0x4 ; /* Bypass Prescaler */
LPTMR0->CMR = 0x7;
/* 500 ms interrupt */
LPTMR0->CSR |= LPTMR_CSR_TCF_MASK; /* Clear TCF flag by writting a logic one */
LPTMR0->CSR |= LPTMR_CSR_TIE_MASK; /* Timer interrupt enabled */
LPTMR0->CSR |= LPTMR_CSR_TEN_MASK; /* Enable Timer */
NVIC_init_LPTMR0_IRQs();
}
void LPTMR0_IRQHandler (void)
{
if (0 != (LPTMR0->CSR & LPTMR_CSR_TCF_MASK)) //0x80u 1000 0000
{
/* Check if TCF flag is set */
LPTMR0->CSR |= LPTMR_CSR_TCF_MASK; /* Clear TCF flag by writting a logic one */
// 0x80u 1000 0000
counter_time++;
}
}
I have done the profiling but for some reason the timer does not start on power cycle.But if I connect the Jlink and give the command "rnh" to reset MCU the timer behave as expected.Any thought as to why?