AnalogIn in 8-bit mode

09 Jan 2011

Hello everyone,

My application needs 8-bit AnalogIn data. But the existing lib has 16-bit conversion and no 8-bit conversion(I guess). Can anyone help me on this issue?

 

Thanks

Nitin

09 Jan 2011

Hi Nitin,

Does the following give you what you need?

#include "mbed.h"

AnalogIn x(p20);

int main() {
    uint8_t byte = x.read_u16() >> 8; // take most significant 8-bits of sample
}

Thanks, Simon

09 Jan 2011

Hi Simon,

Ya ultimately I have to try your suggestion. But is there a way to get 8-bit ADC without consuming extra CPU clocks? I am trying to build a oscillscope using mbed and a color lcd. So I cant consume more CPU clocks and do plotting of waveform at the earliest! What might be the maximum ADC speed? 200kHz?

 

Thanks

Nitin

09 Jan 2011

Even at maximum ADC speed you don't have to worry about comsuming some extra CPU clocks.