Hiya guys, need a bit of help here
I have put this code in
void noreturn (void) interrupt 1
but the target is not created when this code is in.
what could it be??
Just a guess - did you include a function prototype? The compiler does NOT want you to include a function prototype for interrupt functions.
What exactly is the error message you get?
sorry i didnt explain mysel corretly, did i ?
ok, it seems that the problem involves the code rom size in the options.
when the code rom is :
SMALL: Program 2K or less
it will not complie.
i need that seeting for my hardware, wel li think i do. cos it wont download unless in like that.
i hope this can be resolved
It sounds like when you add that piece of code, your program becomes larger than 2K bytes and the "small" code ROM size cannot work.
How big is your program without the interrupt code? If it is almost 2k, this is probably your problem.
If so, you either need to trim some fat out of your code or hopefully you can figure out how to use the compact ROM size.
Well i have found out by systmatically testing, that that is not my problem now. it complies ok now in a 64k large.
and my hardware likes it, untill i send a code down with the inturpts in it.
it frezzes up when down loading. im am currentl using a development board from my university.
ahhhhh, i found that my hardware has the interrupts at 0xBF00. how do i set this off set up in keil??
That is why it kept frezzin before when i tried to acess the wrong area.
Let me make sure I have it right. It downloads & runs the code fine w/o the interrupt routine, but then dies during downloading the code w/the interrupt?
1 - adding the interrupt routine makes the code too large for the development board and it chokes on it. As a test, try taking out a big chunk of your code somewhere else and leave the interrupt routine in. In this way, you can see if it'll take the interrupt routine when your code is still small enough to fit.
2 - I have no idea what development board you are using, but it may be that you can't use the timer0 interrupt. Perhaps writing code there kills the monitor code responsible for downloading your program.
What development board are you using?
#pragma iv (0x0000)
in your source code.
The pragma above will force interrupts to the 0x0000 block. But, that space may already be used by monitor code... Beware.
You said it's an eval board from a University - Is this something you're doing on your own or is it an assignment? It you were given an assignment to use timer0, then you must be able to use it (unless your prof isn't sharp enough to realize this). If you are winging this on your own, the problem could be that you just can't use timer0 on this eval board.
I do have acess to timer0.
that was just an example, i will be needing 3 external interrupts also.
i have chosse EX0, EX1, and CT3I/P1.5
But i now have a different problem, i can get the external interupts to work on the board, i did by changing the options, C51, int vectors options to 0xBF00. this made the interrupts work on the board, but when i went to simulate it, and clicked on a inturrpt the program jummped out and sat at the inturrupt vector ie IE0 jumped to 03h.
why is this?
I've never used the Keil simulator, but somewhere in the options there should be a way to let it know you want to relocate where the hardware goes for interrupt vectors.
Is there a place where you select what chip you are simulating? If so, maybe all you have to do is make sure the correct chip (one that has its int vectors at 0xBF00) is selected.
ahhh i found out why!!!!
Note that if you attempt to run your program with dScope, it will not run. This is because dScope jumps to the REAL interrupt vectors (0000h, 0003h, 000Bh, 0013h, and so on). You can get around this problem by using the dScope assembler to add LJMPs at the real interrupt vectors to the relocated interrupts. For example:
ASM LJMP 0x1000
ASM LJMP 0x1003
ASM LJMP 0x100B
ASM LJMP 0x1013
but how do i fit this in my code?
pls help im almost there :o)
I take it dScope is a simulator?
The problem appears to be that your chip's hardware directs interrupts to 0xBF00 while the dScope simulator directs them to 0x0000 as most 8051s do.
If you can add some assembly code in the 0x0000 block to redirect the interrupts to the 0xBF00 block the simulator will act like the chip.
In most simulators there is a way to add assembly instructions to your code already loaded into the simulator. I think the:
ASM LJMP 0x1000
stuff may have been instructions that you can issue from some kind of command line in dScope.
Dig into the dScope docs. Somewhere in there it should tell you how to edit the code that has been loaded into the simulator by "hand" adding assembly instructions.
Maybe a faster option is to use the #pragma statement to change the interrupt vector block depending on whether you are compiling your code for use in the development board or for use with the dScope simulator.
#pragma iv (0xBF00) //for use on HW
#pragma iv (0x0000) //for use w/simulator
thought i would just change the interrupt vector start address, depending on which im using.
but i would really like to to a nice program. can some one pls explain how i include assembly into C code. i have tried to read the help file, but im alittle stuck with it.
how do i get access to adress locations in c and put assembly code?
whats the best interupt to use as a 3rd external interrupt?
I'm just about positive that you can't use absolute code addresses in C.
You would have to write an assembly file and add it to your project so that it is linked with your C code.
In the assembly file, you'd have:
But, then you are still stuck adding this file to your project when compiling for the simulator and taking it out when compiling for use in HW.
If you really want something "clean" how about this?:
#define USING_SIMULATOR x
// x=1 if "using simulator"
// x=0 if using hardware
#pragma iv (0x0000)
#pragma iv (0xBF00)
You just change "x" depending on how you want it. I often write code that must be compiled differently for different situations and this is the best way to compile two different versions from the same source code.
View all questions in Keil forum