AnsweredAssumed Answered

Problem with ADC driver - freeze

Question asked by Ondrej Dvorak on Aug 13, 2012
Latest reply on Aug 14, 2012 by Martin Kojtal

Hello,

 

I'm having a problem with ADC driver for K60 uP that is used by touch screen resistive driver in MQX 3.8.

The ADC driver stops sending the events to touch screen driver after some time (from minutes to days).

 

I've written small test program that directly uses the ADC peripheral and I'm able to induce the situation when ADC does not signalize the conversion complete.

 

I shall note that I'm using PK version of uP (silicon 2N30D).

 

Here is the code I'm using for the test:

 

void adc_task(uint_32 ini_data){  uint_16 set_gain;  //set calibration config adc:  SIM_SCGC3 |= 1 <<27; // on adc1 clock  ADC1_CFG1 = 0x64 ; // adc clock config  and resolution  ADC1_SC2 = 0x0; // select software trigger and power down compare function  ...  ADC1_SC3 = 0x07; // set max avereage  and continuos conversion    //run calibration:  ADC1_SC3 |= 1 << 7;  //wait for callibration complete:  while(!(ADC1_SC1A & 0x80));  if(ADC1_SC3 & 0x4)  {    printf("Callibration ok \n");    }else  {    printf("Callibration failed \n");  }    //set plus /minus gain,   set_gain = ADC1_CLP0;  set_gain +=ADC1_CLP1;  set_gain +=ADC1_CLP2;  set_gain +=ADC1_CLP3;  set_gain +=ADC1_CLP4;    set_gain = set_gain / 2;  set_gain |= 1 << 15;  ADC1_PG = set_gain;       set_gain = ADC1_CLM0;  set_gain +=ADC1_CLM1;  set_gain +=ADC1_CLM2;  set_gain +=ADC1_CLM3;  set_gain +=ADC1_CLM4;  set_gain = set_gain / 2;  set_gain |= 1 << 15;  ADC1_MG = set_gain;    ADC1_SC1A = 0x1A; // select channel  - temperature sensor  while(1)  {    //conversion: - software trigger start conversion when write to sc1a register    ADC1_SC1A = 0x1A; // select channel  - temperature sensor    _time_delay(2);    while(!(ADC1_SC1A & 0x80)) //wait for complete    {    }    _time_delay(2);  }    }

Thank you,

Ondra

Outcomes