Problem with ADC driver - freeze

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Problem with ADC driver - freeze

632 Views
vondrus
Contributor I

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

0 Kudos
1 Reply

349 Views
c0170
Senior Contributor III

Hello vondrus,

 

this thread would fit into the kinetis section because it seems to be problem with MCU not MQX. I am running your example t to see if the conversation bit is not set in a while. I checked errata for your masket, there's only one problem with ADC and conversation abort. This example should work smoothly.

 

Waht if you test to disable hardware avarage or lower conversation samples?

 

This conditon should check CALF bit in ADCx_SC3? You are checking the bit which you have already set. This does not have any impact to a problem though.

 

  if(ADC1_SC3 & 0x4)  {    printf("Callibration ok \n");    }else  {    printf("Callibration failed \n");  }
0 Kudos