Hi,
I wrote a short programm to light a led when I press the User 1 button, the logic "seem" right but the led isn't lighting up. What I got wrong?
#include <stdbool.h>
#include <stdint.h>
#include "inc/tm4c129xnczad.h"
#include "inc/hw_memmap.h"
#include "inc/hw_nvic.h"
#include "inc/hw_types.h"
#include "driverlib/sysctl.h"
#include "driverlib/gpio.h"
void button_press(void){
GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_1, GPIO_PIN_1);
SysCtlDelay(10000);
GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_1, 0);
SysCtlDelay(10000);
GPIOIntClear(GPIO_PORTJ_BASE,GPIO_INT_PIN_0);
}
int main(void) {
//clock init
SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), 120000000);
//button clock GPIO init
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOJ);
while(!(SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOJ)));
//led clock GPIO init
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPION);
while(!(SysCtlPeripheralReady(SYSCTL_PERIPH_GPION)));
//Led init
GPIOPinTypeGPIOOutput(GPIO_PORTN_BASE,GPIO_PIN_1);
//button init
GPIOPinTypeGPIOInput(GPIO_PORTJ_BASE,GPIO_PIN_0);
//interrupt set-up
GPIOIntTypeSet(GPIO_PORTJ_BASE,GPIO_PIN_0,GPIO_FALLING_EDGE);
GPIOIntRegister(GPIO_PORTJ_BASE,button_press);
GPIOIntEnable(GPIO_PORTJ_BASE,GPIO_INT_PIN_0);
//loop for ever waiting for the button to be pressed.
while(1){
}
}
I got questions upon the choice of Int Type. In the dev kit datasheet. the button USR 1 is connected to ground so it is logical to check for Falling_Edge right? Also I am not sure about the interrupt function(the interrupt function is correctly written in the interrup vector table), such delay aren"t too long?