Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Problem with <reg517.h> program code

Status
Not open for further replies.

onde

Junior Member level 1
Joined
Nov 29, 2002
Messages
18
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
88
ext-int-Problem with c51

Hi,

i just tried the following programm:

#pragma INTVECTOR(0x8000)
#include <reg517.h>

void ex0_isr (void) interrupt 0
{
P4 = 255;
}

void main (void)
{
IT0 = 0;
EX0 = 1; // Enable EX0 Interrupt
EAL = 1;
P4=0;

while(1)
{
}
}

The problem is, the programm reaches never P4=255;
Before I tried different timer-interrupt programms, they are all working well, so I think uVision 2 is configured correctly.

Some Ideas ??

onde
 

Re: ext-int-Problem with c51

hi,

I don't know the 517 hw, anyway....

1) Is the timer Running?

2) Is the TCON register configured? (Gate - C/T - TR ecc. ecc.)
 

Re: ext-int-Problem with c51

hi,I think you can look for the corresponding assembly code to see if the compiler correctly compile the c source code you written.
 

Re: ext-int-Problem with c51

Ooops

Sorry, You mean external interrupt by pin, I was wrong.....

Anyway You Must set

EA = 1;

in order to enable interrupts.....
 

Re: ext-int-Problem with c51

Obvious, the problem is because the instruction

#pragma INTVECTOR(0x8000)

will put your interupt handler at location 0x8003 (instead of 0x0003, where the interupt handler for ExtInt0 would be expected)

CSEG AT 08003H
LJMP ex0_isr

ex0_isr:
MOV P4,#0xFF
RETI

So, when the external interupt is trigered, the procesor will NOT found at location 0x0003 an interupt handler (most important will not found a reti instruction to continue the normal operation) wich will make your processor to execute wathever instructions will found at this location.
The result is the crash of the system!!

To corect this use

#pragma INTVECTOR(0x0000)
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top