Discussion in "ARM Development" started by    Fejsu    Feb 9, 2009.
Mon Feb 09 2009, 03:34 pm
#1

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
#2
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 '}'.


[ Edited Tue Feb 10 2009, 02:28 am ]
Tue Feb 10 2009, 03:09 am
#3
ExperimenterUK meant this
int main (void){
    IODIR0 = 0xFFFFFF7F;
    Vic_Init();
    while(1){
    }
}
Tue Feb 10 2009, 02:40 pm
#4
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
Tue Feb 10 2009, 05:08 pm
#5

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
#6
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;

}
}


} }
Tue Feb 10 2009, 05:24 pm
#7

good men
Wed Feb 11 2009, 03:20 am
#8
well this is something called polling where your CPU is waiting for event to occur, whereas interrupt is when CPU doesnt wait for event and does its normal work. whenever event occurs it jumps to ISR. as you were doing in your code in first post
 Fejsu like this.
Wed Feb 11 2009, 11:22 pm
#9
Hello,

So what was wrong in the first program ?Why did not work ?Any suggestions?


Thanks.

Regards
Clive
Thu Feb 12 2009, 02:31 am
#10
have u enabled the global interrupt bit?

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

Minniemus
Sun May 19 2024, 07:39 am
Andyhet
Sat May 18 2024, 07:28 am
BrettTibre
Fri May 17 2024, 06:14 pm
Gordonfax
Fri May 17 2024, 10:28 am
Davidspils
Fri May 17 2024, 10:19 am
Patricknoind
Fri May 17 2024, 09:53 am
JeremyCycle
Fri May 17 2024, 09:46 am
FrabSeby
Thu May 16 2024, 07:31 pm