Hi!
I'm not going to create a new question, I will write here.
I've created code that should respond to an external interrupt, but nothing happens. In the main cycle, the led flashes (using the open 1788 Board). What is the error, why the interrupt does not work?
#include <LPC177x_8x.H>
#include "lpc177x_8x_gpio.h"
#include "lpc177x_8x_clkpwr.h"
#include "bsp.h"
/* SysTick Counter */
volatile unsigned long SysTickCnt;
void Delay (unsigned long tick)
{
/*unsigned long systickcnt;
systickcnt = SysTickCnt;
while ((SysTickCnt - systickcnt) < tick);*/
unsigned int i;
unsigned int i2;
for(i2=0;i2<tick;i2++)
for(i=0;i<0x100000;i++){}
}
void EINT0_IRQHandler(void){
if(GPIO_GetIntStatus(2,22,1)){
GPIO_ClearInt(2, (1<<22));
GPIO_SetValue(1, (1<<14));
Delay(500);
}
}
void SysTick_Handler (void)
{
SysTickCnt++;
}
void gpio_config(){
GPIO_SetDir(1, (1<<14), GPIO_DIRECTION_OUTPUT); // LED
GPIO_SetDir(2, (1<<22), GPIO_DIRECTION_INPUT); // Key 2
}
void setupExtI(){
NVIC_SetPriority(EINT0_IRQn, 1);
GPIO_IntCmd(2, (1<<22), 1);
NVIC_ClearPendingIRQ(EINT0_IRQn);
NVIC_EnableIRQ(EINT0_IRQn);
}
int main(void)
{
uint32_t cclk = CLKPWR_GetCLK(CLKPWR_CLKTYPE_CPU);
/* Generate interrupt each 1 ms */
//SysTick_Config(cclk/1000 - 1);
gpio_config();
setupExtI();
//__enable_irq(); // Enable global interrupt
while(1){
GPIO_SetValue(1, (1<<14));
Delay(10);
GPIO_ClearValue(1, (1<<14));
Delay(10);
}
return 0;
}