Problem with ADC (maybe RTC involved).

16 Jan 2012

Hi all,

I'm working with the ADC in BURST MODE using code based on the program 'ADC_test' published by Simon Blandford (http://mbed.org/users/simonb/programs/ADC_test/5zlnn).

I found something I can't explain why is happening.

The SAMPLE RATE is set in 150KSPS and I toggle a pin with a DSO expecting to measure a frequency of 75kHz. Well, I read another value in the DSO...

Expected: f = 75 kHz

Measured: f = 3.15 kHz

Information to add to the situation: At first, before this happened, I could make the ADC work correctly, the frequency toggled weeks ago was OK. But now is different.. Recently I start using the RTC with the Mbed library 'TimeManagement' by David Smith (http://mbed.org/users/WiredHome/libraries/TimeManagement/m003ds)

I'm not sure if that could cause the problem.

I was thinking maybe the TimeManagement library change some default settings in the initialization of my mbed that I don't have access to. Or maybe is something basic I'm missing.

Can anyone help me with this? any advice would be very appreciate

Thanks.

Hernan.

The code is the following:

const int SAMPLErATE = 150000;

void HandlerAdc (int canal,uint32_t valor);

ADC adc (SAMPLErATE,1); initialise ADC to maximum Sample Rate and cclk divide set to 1

DigitalOut toggle (p30);

int main()

{

adc.append (HandlerAdc); append an interrupt handler

adc.startmode (0,0);

adc.burst (1);

adc.setup (p20,1);

adc.interrupt_state (p20,1); enable the interrupt

while (1) {}

}

void HandlerAdc(int canal,uint32_t valor)

{

toggle=!toggle;

}