[En-Nut-Discussion] Here is code, "I need Help to get data"

Ole Reinhardt ole.reinhardt at kernelconcepts.de
Thu Mar 16 10:47:05 CET 2006


Hello,

> I am trying to read the Channel "0" at Analog port...i connected the
> temperature sensor with that port,,,

What's the reason you have copied the whole ADC driver into your code?
You could simply use it by including "dev/adc.h" and link with the
libnutdev.

Try to use the following code:

ADCInit();
ADCSetChannel(0);
ADCStartConversion();
while (ADCRead(&adc_value))
    NutThreadYield();
fprintf_P(uart, PSTR("Checked power 5V: %4.1f" NL), adc_value / 1023.0 *
5.0);

First you have to initialize the ADC driver. This is done by using the
first three lines. The sampling itself is done in the while loop that 
surrounds ADCRead. Youhave to poll the ADC driver as it is not interrupt 
driven and need some time to sample the value.

Hope this will help you!

Best regards,

Ole Reinhardt


-- 
kernel concepts    Tel: +49-271-771091-14
Dreisbachstr. 24   Fax: +49-271-771091-19
D-57250 Netphen    E+ : +49-177-7420433
--





More information about the En-Nut-Discussion mailing list