ADC read at 0

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

ADC read at 0

231 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by blasiis on Mon Jun 21 08:34:59 MST 2010
LPC1758
I have this simple code for read the AD from 2 to 7, I read this value in different time. This routine run every 1 ms .
Normally all is OK, it  happens sometimes that a single value read is = 0 (only one among others), may  depend on what?
I have checked with oscilloscope the analog in put and it is ok.

Thanks

void ReadADC ()
{
  uint32_t ADCR, ADGR;
  ADGR = LPC_ADC->ADGDR;
  ADCR = LPC_ADC->ADCR;

     switch (ADCR & 0x00ff)
       {
       case 0x04:
         mem_In_2 = ADC_ChannelGetData(LPC_ADC,ADC_CHANNEL_2);
      ADC_ChannelCmd(LPC_ADC,ADC_CHANNEL_2,DISABLE);
        ADC_ChannelCmd(LPC_ADC,ADC_CHANNEL_3,ENABLE);
         break;

      case 0x08:
        mem_In_3 = ADC_ChannelGetData(LPC_ADC,ADC_CHANNEL_3);
        ADC_ChannelCmd(LPC_ADC,ADC_CHANNEL_3,DISABLE);
        ADC_ChannelCmd(LPC_ADC,ADC_CHANNEL_4,ENABLE);
        break;

      case 0x10:
     mem_In_4 = ADC_ChannelGetData(LPC_ADC,ADC_CHANNEL_4);
     In_Corr_Chair = ((mem_In_Corr_Chair [0] + mem_In_Corr_Chair [1] + mem_In_Corr_Chair [2]) / 3) >> 4;
        ADC_ChannelCmd(LPC_ADC,ADC_CHANNEL_4,DISABLE);
        ADC_ChannelCmd(LPC_ADC,ADC_CHANNEL_5,ENABLE);
        break;

      case 0x20:
     mem_In_5 = ADC_ChannelGetData(LPC_ADC,ADC_CHANNEL_5);
        ADC_ChannelCmd(LPC_ADC,ADC_CHANNEL_5,DISABLE);
     ADC_ChannelCmd(LPC_ADC,ADC_CHANNEL_6,ENABLE);
        break;

      case 0x40:
     mem_In_6 = ADC_ChannelGetData(LPC_ADC,ADC_CHANNEL_6);
        ADC_ChannelCmd(LPC_ADC,ADC_CHANNEL_6,DISABLE);
        ADC_ChannelCmd(LPC_ADC,ADC_CHANNEL_7,ENABLE);
        break;

      case 0x80:
     mem_In_7  = ADC_ChannelGetData(LPC_ADC,ADC_CHANNEL_7);
        ADC_ChannelCmd(LPC_ADC,ADC_CHANNEL_7,DISABLE);
        ADC_ChannelCmd(LPC_ADC,ADC_CHANNEL_2,ENABLE);
        break;

      }
   ADC_StartCmd(LPC_ADC,ADC_START_NOW);
}
0 Kudos
0 Replies