Jump to content
43oh

Configuring GPIO as an ADC at TM4C123GXL


Recommended Posts

I am using the current sensor HO 10-P with my TM4C123 launchpad board.

 

Essentially I have to connect the Vout pin to a GPIO, configure the GPIO as an ADC pin and then configure the ADC controller to read the Vout from the sensor. I will connect the Vout to PE2 (which is AIN2 and also a GPIO).

 

Wondering how to configure this GPIO as an ADC and then read it? Can you show a sample code snippet?

Link to post
Share on other sites

// stuff here like global variables and constants

const int analogInputPin = 28;

// PE2 on the chip, A1 in Energia, Pin 28 on the headers

// defined here to make it easier to re-assign the pin if

// needed later

 

int a = 0;

 

void setup()

{

// more stuff here

}

 

void loop()

{

// do things

a = analogRead(analogInputPin);

// do other things

}

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...