This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

How to configure the GPIO pin of tm4c123gh6pm as input and to monitor it

Other Parts Discussed in Thread: TM4C123GH6PM

i tried doing it with this code.

but it doesnt work on the board

/*
* main.c
*/

#include "tm4c123gh6pm.h"
#include "xdc/std.h"
#include "hw_gpio.h"
#include "hw_memmap.h"
#include "hw_sysctl.h"
#include "hw_types.h"
#include "gpio.h"
#include "rom.h"
#include "sysctl.h"
#include "stdint.h"
#include "stdbool.h"
#include "pin_map.h"

int
main(void)
{
volatile unsigned long ulLoop;
//volatile unsigned long status;
//
// Enable the GPIO port that is used for the on-board LED.
//
SYSCTL_RCGC2_R = SYSCTL_RCGC2_GPIOE;

//
// Do a dummy read to insert a few cycles after enabling the peripheral.
//
ulLoop = SYSCTL_RCGC2_R;

//
// Enable the GPIO pin for the LED (PF3). Set the direction as output, and
// enable the GPIO pin for digital function.
//
GPIO_PORTE_DIR_R = 0x08;
GPIO_PORTE_DEN_R = 0x08;

//SYSCTL_RCGC2_R = SYSCTL_RCGC2_GPIOF;

GPIO_PORTF_DIR_R = 0x00;
GPIO_PORTF_DEN_R = 0x08;

//status=GPIOPinRead(GPIO_PORTF_BASE,GPIO_PIN_3);
//
// Loop forever.
//
while(1)
{

if ((GPIO_PORTF_DATA_R & 0x08) == 0x08)
{
//
// Turn on the LED.
//
GPIO_PORTE_DATA_R |= 0x08;

//
// Delay for a bit.
//
for(ulLoop = 0; ulLoop < 200000; ulLoop++);

//
// Turn off the LED.
//
GPIO_PORTE_DATA_R &= ~(0x08);

//
// Delay for a bit.
//
for(ulLoop = 0; ulLoop < 200000; ulLoop++);
}
else
GPIO_PORTE_DATA_R &= ~(0x08);
}
}

  • What exacly doesn't work?

    It seems you forgot to enable the internal pull up. Or did you use a external resistor?

    If you never used the Tiva maybe you should start with TivaWare istead of direct register access? Here is some code on how to use it https://sites.google.com/site/luiselectronicprojects/tutorials/tiva-gpio