AnsweredAssumed Answered

TWR-K60F120M ADC 16 Bit resolution Single and differential Input

Question asked by dinesh vaghela on Jun 26, 2013

I have used Demo code in TWR-k60F120M.  code of Potentiometer Reading on LED and UART.

 

I am Running Demo code  of Reading potentiometer through UART.

but i am not getting 16 bit resolution

there is around 10mv  variation in ADC Readinreading

 

void ADC_Init (void) {

 

 

  /* Setup potentiometer pin ADC1_DM1 and A/D converter ADC1 */

  SIM->SCGC3  |=  SIM_SCGC3_ADC1_MASK;  /* Enable ADC 1 gate clocking         */

 

 

  ADC1->CFG1   = ( 3 << 5) |            /* ADC clock is (Input clock)/8       */

                 ( 1 << 4) |            /* Select Long sample time            */

                 ( 3 << 2) |            /* Select 16-bit conversion           */

                 ( 1 << 0) ;            /* Input clock is (Bus clock)/2       */

 

 

  ADC1->CFG2   = ( 0 << 4) |            /* ADxxa channels are selected        */

                 ( 0 << 3) |            /* Async clock output disabled        */

                 ( 0 << 2) |            /* Normal conversion sequence         */

                 ( 0 << 0) ;            /* 20 extra ADCK cycles               */

 

 

  ADC1->SC1[0] = ( 1 << 6) |            /* Conversion complete interrupt enabled */

                 (20 << 0) ;            /* Select AD20 as a input             */

 

 

  ADC1->SC2    = ( 0 << 6) |            /* Software trigger selected          */

                 ( 0 << 5) |            /* Compare function disabled          */

                 ( 0 << 4) |            /* Compare configures less than threshold */

                 ( 0 << 3) |            /* Range function disabled            */

                 ( 0 << 2) |            /* DMA is disabled                    */

                 ( 0 << 0) ;            /* Default voltage reference          */

 

  ADC1->SC3   |= ( 0<< 2) |            /* Hardware average function Disabled  */

                 ( 3 << 0) ;               

 

 

  ADC_Calib ();                         /* Perform calibration of the ADC     */

#if __ADC_IRQ

  NVIC_EnableIRQ(ADC1_IRQn);            /* Enable ADC Interrupt               */

#endif

}

Please Help me to get 16 bit Resolution

 

I also need Code to interface Differential input apply to tower kit AD1_DM0 and AD1_DP0.

 

 

Outcomes