Reading Analog Input from FRDM-K22F

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

Reading Analog Input from FRDM-K22F

跳至解决方案
775 次查看
xhr1s
Contributor II
Hello, I'm trying to read the value of the A0 pin from the FRDM-K22F development board as an analog input. I have defined it as a input GPIO pin using the pin configuration tool in MCUXpresso. Is this the way to do it? GPIO_ReadPinInput(BOARD_A0_GPIO, BOARD_A0_PORT, BOARD_A0_PIN);
0 项奖励
1 解答
772 次查看
ErichStyger
Senior Contributor V

GPIO_ReadPinInput() reads the pin as digital (high, low) input pin, not as analog pin. I suggest you have a look at the analog examples in the SDK how to configure and read the pin as analog pin?

在原帖中查看解决方案

0 项奖励
4 回复数
731 次查看
xhr1s
Contributor II

So, I still am not able to figure out how to read analog data from an input pin. Which example should I look at?

xhr1s_0-1670514306740.png

Any help is appreciated.

0 项奖励
721 次查看
_Leo_
NXP TechSupport
NXP TechSupport

The SDK examples that you can use as a reference are the following:

nxf86756_0-1670969361116.png

 

0 项奖励
773 次查看
ErichStyger
Senior Contributor V

GPIO_ReadPinInput() reads the pin as digital (high, low) input pin, not as analog pin. I suggest you have a look at the analog examples in the SDK how to configure and read the pin as analog pin?

0 项奖励
766 次查看
xhr1s
Contributor II

Yup. You're right. After reading the documentation at https://mcuxpresso.nxp.com/api_doc/dev/329/group__lpc__gpio.html it is obvious, sorry. It's a bit difficult making sense of the ADC sdk examples, I only need to read one value at a time. The API calls are also not very friendly. Perhaps there is an easier way to do it? I can't seem to figure out any other analog pin read examples.

0 项奖励