View previous topic :: View next topic |
Author |
Message |
priesty100
Joined: 16 Oct 2007 Posts: 6 Location: UK
|
Error 51 on #ORG |
Posted: Tue Oct 16, 2007 6:28 am |
|
|
Compiler Version - 4.025
Target PIC - PIC18F8722
Oscillator Speed (10MHz) (clocking at 40MHz)
Hi,
I am trying to specify the location of some code using #org however the compiler is throwing up an error51 (a numeric expression must appear here). I cant see anything wrong with the code and have even copied the example from the help and this doesn’t work either.
Here's the code:
Code: |
while(1)
{
output_high(pin_B2);
output_low(pin_B2);
#org 0x100,0x1FF
#asm
RLNCF LoopDelay,F
MOVF LoopDelay,W
ADDWF 0xFF9,F //0xFF9 = PCL
nop
nop
.
.
.
nop
#endasm
output_high(pin_B0);
output_low(pin_B0);
delay_ms(100);
StrobeDelay++;
if(StrobeDelay==102)
StrobeDelay=100;
LoopDelay=StrobeDelay;
}
|
Any help on the #ORG problem would be most appreciated.
(The code is for a variable delay loop however this seems to work with small numbers and no #org, the code location needs to be specified so that it is within page boundaries).
Thank you for your help _________________ Sam |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah Guest
|
|
Posted: Tue Oct 16, 2007 8:49 am |
|
|
You cannot just set an org 'inline'. It places the subsequent _function_, at the desired address. What you post, would require the addresses of everything else to be retroactively altered to reposition the bit of code at the required location...
You need to declare your routine as a separate function, and then set it's origin.
Why not just use the 'delay_cycles function....
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
priesty100
Joined: 16 Oct 2007 Posts: 6 Location: UK
|
|
Posted: Wed Oct 17, 2007 1:39 am |
|
|
Thank you for your help, the problem is now sorted.
And yes, the delay_cycles function would be a much better implimentation.
Thanks again _________________ Sam |
|
![](templates/subSilver/images/spacer.gif) |
|