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

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

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

跳至解决方案
1,712 次查看
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.

标签 (1)
0 项奖励
回复
1 解答
852 次查看
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 项奖励
回复
1 回复
853 次查看
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 项奖励
回复