heyo fellow forumers.. been trying to set up a button to turn on and off an led... and can't... don't know why.
the board I'm using is the tm4c1294xl. I'm using CCS v.6.1
here is the code I've written;
#include <stdbool.h>
#include <stdint.h>
#include "inc/hw_types.h"
#include "inc/hw_gpio.h"
#include "inc/hw_memmap.h"
#include "driverlib/gpio.h"
#include "driverlib/pin_map.h"
#include "driverlib/pwm.h"
#include "driverlib/sysctl.h"
#include "drivers/pinout.h"
int main(void){
//enable the first LED (PN1)
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPION);
GPIOPinTypeGPIOOutput(GPIO_PORTN_BASE, GPIO_PIN_0);
//Enable The first push button (PJ0)
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOJ);
GPIOPinTypeGPIOInput(GPIO_PORTJ_BASE, GPIO_PIN_0);
GPIOPadConfigSet(GPIO_PORTJ_BASE, GPIO_PIN_0, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
while(1)
{
int buttonpressed = GPIOPinRead(GPIO_PORTJ_BASE, GPIO_PIN_0);
if(buttonpressed != 0)
{
GPIOPinWrite(CLP_D1_PORT, CLP_D1_PIN, CLP_D1_PIN);
}
else
{
GPIOPinWrite(CLP_D1_PORT, CLP_D1_PIN, 0);
}
GPIOIntClear(GPIO_PORTJ_BASE, GPIO_PIN_0);
}
}
thanks much.