I have a problem with ADC conversion.
ADC is setup to single sequencer with 5 conversions.
Every 62.5 us ADC starts new conversion.
The internal reference is used and ADCREFP, ADCREFM are connected to ceramic cap 10uF.
The input is now connected to AGND.
The sampled value is around 55.
(It seems that this is offset, but if I decrease AdcRegs.ADCTRL3.bit.ADCCLKPS this value will increase!!!)
When I check now min a max values I find many sampled values with 0 and many with 110, which seems to be double of offset.
This log file shows only values sampled as 0 or more than 100.
Start System log :27.02.2017 16:09:19
Timestamp sampling value 1,001s : 0x0000 dez:00000 1,001s : 0x0000 dez:00000 1,117s : 0x0000 dez:00000 1,422s : 0x0070 dez:00112 1,422s : 0x0070 dez:00112 1,450s : 0x0000 dez:00000 1,450s : 0x0000 dez:00000 2,144s : 0x006D dez:00109 3,153s : 0x0000 dez:00000 3,153s : 0x0000 dez:00000 3,176s : 0x0000 dez:00000 3,550s : 0x0072 dez:00114 3,550s : 0x0072 dez:00114 3,600s : 0x0000 dez:00000 4,258s : 0x0000 dez:00000 4,258s : 0x0000 dez:00000 4,632s : 0x0000 dez:00000 4,710s : 0x0000 dez:00000 4,783s : 0x0000 dez:00000 4,783s : 0x0000 dez:00000 4,898s : 0x0000 dez:00000 4,898s : 0x0000 dez:00000 4,919s : 0x006B dez:00107 4,919s : 0x006B dez:00107 4,927s : 0x0000 dez:00000 4,927s : 0x0000 dez:00000 5,245s : 0x0000 dez:00000 5,246s : 0x0000 dez:00000 5,697s : 0x0000 dez:00000 5,697s : 0x0000 dez:00000 5,833s : 0x0000 dez:00000 5,850s : 0x0069 dez:00105 5,851s : 0x0069 dez:00105 6,019s : 0x0000 dez:00000 6,189s : 0x0000 dez:00000 6,189s : 0x0000 dez:00000 6,198s : 0x0069 dez:00105 6,198s : 0x0069 dez:00105 6,297s : 0x0000 dez:00000 6,368s : 0x0000 dez:00000 6,369s : 0x0000 dez:00000 6,656s : 0x0000 dez:00000 6,657s : 0x0000 dez:00000 6,838s : 0x0000 dez:00000 6,838s : 0x0000 dez:00000
Code:
void InitAdc(void) { // Init ADC AdcRegs.ADCTRL3.bit.ADCBGRFDN = 0x3; // Power up bandgap/reference circuitry DELAY_US(ADC_usDELAY); // Delay before powering up rest of ADC AdcRegs.ADCTRL3.bit.ADCPWDN = 1; // Power up rest of ADC DELAY_US(ADC_usDELAY2); // Delay after powering up ADC // End Init ADC // Specific ADC setup : AdcRegs.ADCTRL1.bit.ACQ_PS = 0xf; // S/H width in ADC module periods = 16 ADC clocks AdcRegs.ADCTRL1.bit.CPS=0; AdcRegs.ADCTRL3.bit.ADCCLKPS = 15; // ADC module clock = HSPCLK/2*ADC_CKPS = 60MHz/(2*2) = 15MHz AdcRegs.ADCTRL1.bit.SEQ_CASC = 0; AdcRegs.ADCTRL1.bit.CONT_RUN = 0; // Setup continuous run AdcRegs.ADCMAXCONV.bit.MAX_CONV1=4; AdcRegs.ADCCHSELSEQ1.bit.CONV00 = 0; AdcRegs.ADCCHSELSEQ1.bit.CONV01 = 1; AdcRegs.ADCCHSELSEQ1.bit.CONV02 = 4; AdcRegs.ADCCHSELSEQ1.bit.CONV03 = 6; AdcRegs.ADCCHSELSEQ2.bit.CONV04 = 7; // Start SEQ1 by EVA AdcRegs.ADCTRL2.bit.EVA_SOC_SEQ1 = 1; } void GetADC(void) { while (AdcRegs.ADCST.bit.INT_SEQ1== 0) { DELAY_US(1); } // Wait for interrupt I1=AdcRegs.ADCRESULT0>>4; I2=AdcRegs.ADCRESULT1>>4; U1=AdcRegs.ADCRESULT2>>4; U2=AdcRegs.ADCRESULT3>>4; U3=AdcRegs.ADCRESULT4>>4; AdcRegs.ADCST.bit.INT_SEQ1_CLR = 1; }
Do I have a software problem or a hardware problem?