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

Adding jumping code by program

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



Joined: 07 Jul 2010
Posts: 92

View user's profile Send private message

Adding jumping code by program
PostPosted: Thu Jul 22, 2010 8:03 am     Reply with quote

Hi,

I have an interesting question.

For example I have a function A.
When the program enters the function A I want to write a jump code at the program start address to function B.
In other words:
PIC after reset, goes to 0x0000(I hope) address and I want to write there goto (a function B's address)
after the function A write that jump code, if PIC reseted, pic will start from the function B everytime.

Code:

main{
inits
code
code

if something
    function A;
}

function A{
write jump code at the start address to jump to function B
}

function B{
inits
code
}


How to do this?
I use 18F4520 and I have code protect.

Thanks in advance
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Jul 22, 2010 11:35 am     Reply with quote

Use the internal data eeprom in the PIC to control the behavior of
the program upon startup. Initialize an eeprom location with the #rom
statement. Compile your program. The eeprom will be programmed by
your programmer with that value. Then, when your program is running,
it can change the value in the eeprom to affect future operation of the
program. This is done by the program reading the eeprom location
upon power-up. You can use a switch-case statement, or an if()
statement, or if-else, to make the program call whatever function you
want it to call, upon power-up.

Examples:
http://www.ccsinfo.com/forum/viewtopic.php?t=41564&start=6
http://www.ccsinfo.com/forum/viewtopic.php?t=22109&start=17
FFT



Joined: 07 Jul 2010
Posts: 92

View user's profile Send private message

PostPosted: Thu Jul 22, 2010 1:12 pm     Reply with quote

Thanks, this is good idea if I can't do what I want.

Is not possible to add just a goto/bra instruction to the start vector of pic by program?
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