I am designing password based door lock system using LPC 1769. I have build up the code of changing the state but now I am stuck to use joystick pins or switch key 3 or switch key 4 pins to use as an external interrupt. This I am using to reset the system whenever i give an external interrupt. Please help me to configured any switch key to use as an external interrupt and please tell about external interrupt service handler framework in general.
Your help will be very much appreciated.
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;
}
Hi Omkar Mugdar,
Thanks for your reply.
To utilizing the external interrupt, I'd highly recommend you to refer to the periph_pinint demo in the LPCOpen library, and you can download the library via the following link:
https://www.nxp.com/support/developer-resources/software-development-tools/lpc-developer-resources-/...
Have a great day,
TIC
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------