CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Error 51 on #ORG

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
priesty100



Joined: 16 Oct 2007
Posts: 6
Location: UK

View user's profile Send private message MSN Messenger

Error 51 on #ORG
PostPosted: Tue Oct 16, 2007 6:28 am     Reply with quote

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
Ttelmah
Guest







PostPosted: Tue Oct 16, 2007 8:49 am     Reply with quote

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
priesty100



Joined: 16 Oct 2007
Posts: 6
Location: UK

View user's profile Send private message MSN Messenger

PostPosted: Wed Oct 17, 2007 1:39 am     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group