AnsweredAssumed Answered

LPTMR0 always shows 0?

Question asked by Yasuhiko Koumoto on Feb 28, 2015
Latest reply on Nov 30, 2015 by Oleksandr Pylypenko

Hello all,

 

I found a strange behavior.

LPTMR0_CNR always shows 0.

My scenario below is to occur the compare interrupt of LPTMR.

As the interrupt caused normally and I had not cared the LPTMR0_CNR value.

That is, LPTMR0_CSR varied from 0x41 to 0xC1 but LPTR0_CNR kept 0.

I would like to see changing the LPTMR0_CNR value.

What should I do to do it?

 

    SIM_SCGC5 |= SIM_SCGC5_LPTMR_MASK;

    LPTMR0_PSR = ( LPTMR_PSR_PRESCALE(0) // 0000 is div 2
                 | LPTMR_PSR_PBYP_MASK   // LPO feeds directly to LPT
                 | LPTMR_PSR_PCS(LPTMR_USE_LPOCLK)) ; // use the choice of clock

    LPTMR0_CMR = LPTMR_CMR_COMPARE(1000);  //Set compare value (100ms)

    LPTMR0_CSR =(  LPTMR_CSR_TCF_MASK   // Clear any pending interrupt
                 | LPTMR_CSR_TIE_MASK   // LPT interrupt enabled
                 | LPTMR_CSR_TPS(0)     //TMR pin select
                 |!LPTMR_CSR_TPP_MASK   //TMR Pin polarity
                 |!LPTMR_CSR_TFC_MASK   // Timer Free running counter is reset 
                                        //  whenever TMR counter equals compare
                 |!LPTMR_CSR_TMS_MASK   //LPTMR0 as Timer
                );
    LPTMR0_CSR |= LPTMR_CSR_TEN_MASK;   //Turn on LPT and start counting

    while(1){
      printf("%x %x\n",LPTMR0_CNR, LPTMR0_CSR);
      printf("%x %x\n",LPTMR0_CNR, LPTMR0_CSR);
      printf("%x %x\n",LPTMR0_CNR, LPTMR0_CSR);
      printf("%x %x\n",LPTMR0_CNR, LPTMR0_CSR);
      printf("%x %x\n",LPTMR0_CNR, LPTMR0_CSR);
      printf("%x %x\n",LPTMR0_CNR, LPTMR0_CSR);
      printf("%x %x\n",LPTMR0_CNR, LPTMR0_CSR);
      printf("%x %x\n",LPTMR0_CNR, LPTMR0_CSR);
   }

 

Best regards.

Yasuhiko Koumoto.

Outcomes