7 years, 3 months ago.

About ADC

Hi,everyone. I would like to do ADC when every 400kHZ. I use LPC4088. this is my code. It's possible to use Ticker or interrupt. i want to get series of analog from sin wave .

#include "SDFileSystem.h"
AnalogIn   current(p19);
Ticker Convert; 
int i ;
void ADC(){
      i= current.read_u16();
}    
int main() {
    Convert.attach(&ADC, 0.0000025);
    while(1) {
        printf("ADC Val : %d \r\n",i);
        wait(0.2);
    }
}

But it display nothing. Could someone can give me a hint? Thx!!!

1 Answer

7 years, 3 months ago.

It is permanently in its interrupt routine since you don't give it enough time.

Also i should be defined as volatile int.

Hi, Erik Thx for your answer~ but i have no idea about how to do every 1/400k (s) to read the current analog value. if i want to print 1024 datas. How could i do? interrupt or ticker~~ THx

posted by jajn HA 16 Jan 2017

See my other answer to your question, you will need to use a different library. But first if I were you I would consider what your system needs to do exactly and how. You will for example need to buffer the data, so how much data do you need? Ideally you would use DMA for this.

posted by Erik - 16 Jan 2017