Looking for sample ADC code for only AN7 as ADC output and rest AN0-4 as GPIO inputs

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Looking for sample ADC code for only AN7 as ADC output and rest AN0-4 as GPIO inputs

Jump to solution
1,204 Views
TVNAIDU
Contributor III

I am Looking for sample ADC code to read only AN7 continuosly for 12 times as ADC output and rest AN0-4 as GPIO inputs, select chip using AN0-4 and its output on AN7.

 

AN4   AN3  AN2   AN1 AN0             AN7

0        0       0         0        1                 ADC output

0        0       0         1        0                ADC output

0        0       0         1        1                 ADC output

0        0       1         0        0                 ADC output

 

 

my program able to read only once for first one, after that not getting correct readings, appreciated.

Labels (1)
0 Kudos
1 Solution
344 Views
RichTestardi
Senior Contributor II

Hi,

 

You can find a bunch of ADC sample code in the skeleton project at the bottom of:

 

http://www.cpustick.com/downloads.htm

 

Look in sources/adc.[ch] and follow the MCF52233 (I believe) #if's.  You can see how pins are configured in sources.pin.[ch], and you can configure AN7 for analog input while configuring the other AN pins for digital output or whatever.

 

If you're having trouble verifying your hardware is working, you can even load up StickOS and probe the hardware interactively -- it's pretty simple to set output pins or read input pins (even analog input).

 

-- Rich

 

View solution in original post

0 Kudos
1 Reply
345 Views
RichTestardi
Senior Contributor II

Hi,

 

You can find a bunch of ADC sample code in the skeleton project at the bottom of:

 

http://www.cpustick.com/downloads.htm

 

Look in sources/adc.[ch] and follow the MCF52233 (I believe) #if's.  You can see how pins are configured in sources.pin.[ch], and you can configure AN7 for analog input while configuring the other AN pins for digital output or whatever.

 

If you're having trouble verifying your hardware is working, you can even load up StickOS and probe the hardware interactively -- it's pretty simple to set output pins or read input pins (even analog input).

 

-- Rich

 

0 Kudos