View previous topic :: View next topic |
Author |
Message |
FFT
Joined: 07 Jul 2010 Posts: 92
|
Adding jumping code by program |
Posted: Thu Jul 22, 2010 8:03 am |
|
|
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
|
|
Posted: Thu Jul 22, 2010 11:35 am |
|
|
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
|
|
Posted: Thu Jul 22, 2010 1:12 pm |
|
|
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? |
|
|
|