Dear all,
I want to read the input status of pin PE1 and I have the following code with TivaWare:
/*
* main.c
*/
#include <stdint.h>
#include <stdbool.h>
#include "inc/hw_types.h"
#include "inc/hw_memmap.h"
#include "driverlib/sysctl.h"
#include "driverlib/gpio.h"
uint8_t ui8PinData = 2;
int32_t i32Val = 0x0;
int main(void) {
SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3);
GPIOPinTypeGPIOInput(GPIO_PORTE_BASE, GPIO_PIN_1);
SysCtlDelay(2000000);
while(1)
{
i32Val = GPIOPinRead(GPIO_PORTE_BASE,GPIO_PIN_1);
SysCtlDelay(2000000);
}
}
I have connected the pin PE1 to a pushbutton that shorts PE1 to ground when pressed. Now after running the program and putting a breakpoint at the line "i32Val = GPIOPinRead(GPIO_PORTE_BASE,GPIO_PIN_1);" , the value of i32Val doesnot become 0x00000000 even when the switch is pressed. Are there any other initializations required for reading the input?