Discussion in "ARM Development" started by    Fejsu    Feb 9, 2009.
Mon Feb 09 2009, 05:04 AM
#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.
Mon Feb 09 2009, 03:57 PM
#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 Mon Feb 09 2009, 03:58 PM ]
Mon Feb 09 2009, 04:39 PM
#3
ExperimenterUK meant this
int main (void){
    IODIR0 = 0xFFFFFF7F;
    Vic_Init();
    while(1){
    }
}
Tue Feb 10 2009, 04:10 AM
#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, 06:38 AM
#5

Didi you take a look at this example: http://www.8051projects.net/forum-t13741.html
 Fejsu like this.
Tue Feb 10 2009, 06:43 AM
#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, 06:54 AM
#7

good men
Tue Feb 10 2009, 04:50 PM
#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, 12:52 PM
#9
Hello,

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


Thanks.

Regards
Clive
Wed Feb 11 2009, 04:01 PM
#10
have u enabled the global interrupt bit?

Get Social

Information

Powered by e107 Forum System

Conversation

Wed Mar 25 2020, 09:39 AM
Tajammul
Sir kindly send the code file i2c for 8051
ExperimenterUK
Fri Mar 13 2020, 06:36 PM
@ Rohitnani,ABEBE..which project ?
Fri Mar 13 2020, 08:55 AM
ABEBE
how can get hadwere of this project
Rohitnani
Sat Mar 07 2020, 12:11 PM
Sir, Could you please send me the zip file input password....
Wed Feb 26 2020, 11:58 AM
Peter Parker
Is it possible to send multiple messages using only 1 GSM module?
Sat Feb 01 2020, 05:12 AM
Pearl Olin
Hello,
Wed Jan 22 2020, 01:16 PM
MINU CHAUDHARY
I m getting errors while simulation process during interfacing socket output and lcd... Can i get the report of ur project which is same as us.
Tue Jan 14 2020, 02:08 AM
shubham kharade
when i am trying to simulate the program in Proteus 8 professional, I am getting some errors as cannot find module file dhtxx.md can u help me
Tue Dec 17 2019, 08:44 AM
Devangi
hello..i am programming industrial timer using 8051 with 24lc64 eeprom. i have query in storing the 3 diff value in eeprom with enter button. can anyone share c code ?
Tue Dec 17 2019, 05:30 AM
Andrius
Hello. Can anyone share the code in Bascon and scheme in Proteus?

Downloads

Comments

ukkorikerist
Thu Apr 09 2020, 12:05 AM
Oswaldrib
Wed Apr 08 2020, 11:08 PM
Rachelsig
Wed Apr 08 2020, 04:57 PM
Franksig
Wed Apr 08 2020, 03:38 AM
OliverKiz
Mon Apr 06 2020, 07:54 PM
Nikolaynom
Mon Apr 06 2020, 09:13 AM
Paulinewop
Sun Apr 05 2020, 10:33 PM
NormanJeops
Sun Apr 05 2020, 03:26 AM

Online

Guests: 42, Members: 0 ...

most ever online: 182184
(Members: , Guests: 182184) on 06 Aug 2010: 01:37 AM

Members: 38149
Newest member: ukkorikerist
Forum Activity
PHANTOM28 Avatar
Posted By PHANTOM28
Fri Feb 28 2020, 10:25 AM
Hi.I hope you all can help me. I am relatively ne...
ExperimenterUK Avatar
Posted By ExperimenterUK
Fri Feb 21 2020, 05:05 PM
ajay_bhargav Avatar
Posted By ajay_bhargav
Fri Feb 21 2020, 04:45 AM
Yes you can do that.1. Create a channel @Thingspea...
ananyagupta Avatar
Posted By ananyagupta
Thu Feb 20 2020, 03:58 AM
With regards to the particular characters sent to ...
sarrahjuzar Avatar
Posted By sarrahjuzar
Wed Feb 19 2020, 04:24 AM
I have a gsm module sim900a and dht22 connected to...
ExperimenterUK Avatar
Posted By ExperimenterUK
Tue Feb 18 2020, 04:52 PM
figureyang Avatar
Posted By figureyang
Tue Feb 18 2020, 04:59 AM
figureyang Avatar
Posted By figureyang
Tue Feb 18 2020, 04:50 AM
wounder Avatar
Posted By wounder
Mon Feb 10 2020, 03:32 AM
From below sample code for nuvoton 8051 timer0 mod...
Just4Fun Avatar
Posted By Just4Fun
Sat Feb 01 2020, 09:20 AM
If you want to use a CH55x MCU there isn't any adv...