AnsweredAssumed Answered

LPTMR to trigger ADC

Question asked by vinod Karuvat on Mar 13, 2014
Latest reply on Jan 19, 2015 by Adrian Cano

Hello,

 

I am using the KL05-FRDM board. I want to trigger ADC conversions, via the LPTMR.

The LPTMR can be clocked by the MCRIRCLK (which is 32KH). I am toggling a pin with a value of '1' in

the CMR register. This si sdone to c the minimum clock/cycle. I saw that it is 2.5msecs, which is something

I was not expecting. WIth a prescaler of 2- the clock wld be 16KH. So a an avg of 62uSecs is what I was expecting.

The code is given -

int main(void)

{

    int count;

    uint16_t countTemp = 0;

  

  

  

                     

    SIM_SOPT1 = 0;                                           

    SIM_SCGC5 |= (SIM_SCGC5_LPTMR_MASK | SIM_SCGC5_PORTB_MASK);//PORTC_PCR1 |= PORT_PCR_MUX(1);//select RTC_CLKIN function

    PORTB_PCR8 |= 0x00000100;    // alternative pin mux selection //

    GPIOB_PDDR |= 0x00000100;    // pin direction //  

  

    SIM_SCGC5|=SIM_SCGC5_LPTMR_MASK;

      /* Reset LPTMR settings */

      SIM_SOPT1 = 0;                                           

    SIM_SCGC5 |= (SIM_SCGC5_LPTMR_MASK | SIM_SCGC5_PORTB_MASK);//PORTC_PCR1 |= PORT_PCR_MUX(1);//select RTC_CLKIN function

  

      LPTMR0_CSR=0;    

      /* Set the compare value to the number of ms to delay */    

      LPTMR0_CMR = 1;

      /* Start the timer */   

      LPTMR0_CSR |= LPTMR_CSR_TEN_MASK;

      /* Wait for counter to reach compare value */

      while(1){

          while (!(LPTMR0_CSR & LPTMR_CSR_TCF_MASK));

          /* Disable counter and Clear Timer Compare Flag */    

          LPTMR0_CSR &= ~LPTMR_CSR_TEN_MASK;

          LPTMR0_CSR |= LPTMR_CSR_TCF_MASK;

          GPIOB_PTOR |= (1<<8);

          LPTMR0_CSR |= LPTMR_CSR_TEN_MASK;

      }     

}

 

Can anyone pls advice me why this is happening.

 

 

 

Vinod.

Outcomes