LPC2148 ARM MICRONTROLLER EXTERNAL INTERRUPT PROBLEM EINT2 CODE NOT WORKING
Mon Feb 09 2009, 03:34 pm
Hello,
I am using an LPC2148 ARM microcontroller and KeiluVision development toolbox to switch an led on p0.0 on my board when i press a switch connected to p0.7.Below is the code but I don`t know what is wrong.Can you help me please because I am exhausted.
#include <LPC214x.H> // Philips Peripheral Registers
void ext (void) __irq {
IOSET0 = 0x00000001;
VICVectAddr = 0;
}
void Vic_Init()
{
VICProtection = 0; // Setup interrupt controller.
VICIntEnClr = 0xffffffff; // Disable all interrupts
PINSEL0 = 0x0000c000;
VICIntSelect=0x0; /* EINT2 selected as IRQ */
VICVectAddr0 = (unsigned long)ext;
VICVectCntl0= 0x16; /*ASSIGN PRIORITY TO INTERRUPT*/
/*VPBDIV = 0x00;*/
EXTMODE = 0x07; // Set edge trigged
/*VPBDIV = 0x07;
VPBDIV = 0x01;*/
EXTPOLAR = 0xFF; // Set rising edge
EXTINT = 0x04; // clear INT flags
VICIntEnable= 0x10000; /* EINT2 interrupt enabled */
}
int main (void){
IODIR0 = 0xFFFFFF7F;
Vic_Init();
}
}
Thanks.
Tue Feb 10 2009, 02:27 am
Looks like the classic error of not keeping the cpu occupied while
waiting for interrupts.
You should add a while() loop after Vic_Init();
(do nothing just wait)
Also you seem to have an unmatched '}'.
waiting for interrupts.
You should add a while() loop after Vic_Init();
(do nothing just wait)
Also you seem to have an unmatched '}'.
[ Edited Tue Feb 10 2009, 02:28 am ]
Tue Feb 10 2009, 03:09 am
ExperimenterUK meant this
int main (void){ IODIR0 = 0xFFFFFF7F; Vic_Init(); while(1){ } }
Tue Feb 10 2009, 02:40 pm
Hello,
I appreciate very much your feedback but still it is not working.Do you have a sample working solution concerning any LPC2148 external interrupt using KeiluVision IDE to try it on my board?
Thanks
Regards
Clive
I appreciate very much your feedback but still it is not working.Do you have a sample working solution concerning any LPC2148 external interrupt using KeiluVision IDE to try it on my board?
Thanks
Regards
Clive
Tue Feb 10 2009, 05:08 pm
Didi you take a look at this example: http://www.8051projects.net/forum-t13741.html
Fejsu like this.
Tue Feb 10 2009, 05:13 pm
Hello,
I have fixed the problem.Below is mu=y updated code and it works.Below is my KeilUvision code and want to share it with you.
#include <LPC214x.H>
/*ON PRESSING BUTTON P0.7 -ra7 each time it switches ON-OFF ra0 p0.1 and ra1 p0.2 as outputs*/
void Vic_Init()
{
PINSEL0 = 0x0000c000;
EXTINT |= 0x04;
EXTMODE = 0x04;
EXTPOLAR = 0x04;
}
unsigned int x;
void main (void){
IODIR0 = 0xFFFFFF7F;
Vic_Init();
while(1){
if (EXTINT == 0x04) {
x=IOSET0;
IOSET0 = 0x00000001 + IOSET0;
EXTINT |= 0x04; /*clear the interrupt EINT2*/
IOCLR0 = x;
}
}
} }
I have fixed the problem.Below is mu=y updated code and it works.Below is my KeilUvision code and want to share it with you.
#include <LPC214x.H>
/*ON PRESSING BUTTON P0.7 -ra7 each time it switches ON-OFF ra0 p0.1 and ra1 p0.2 as outputs*/
void Vic_Init()
{
PINSEL0 = 0x0000c000;
EXTINT |= 0x04;
EXTMODE = 0x04;
EXTPOLAR = 0x04;
}
unsigned int x;
void main (void){
IODIR0 = 0xFFFFFF7F;
Vic_Init();
while(1){
if (EXTINT == 0x04) {
x=IOSET0;
IOSET0 = 0x00000001 + IOSET0;
EXTINT |= 0x04; /*clear the interrupt EINT2*/
IOCLR0 = x;
}
}
} }
Wed Feb 11 2009, 11:22 pm
Hello,
So what was wrong in the first program ?Why did not work ?Any suggestions?
Thanks.
Regards
Clive
So what was wrong in the first program ?Why did not work ?Any suggestions?
Thanks.
Regards
Clive
Powered by e107 Forum System