dean_winchester
Advanced Member level 4
- Joined
- Oct 19, 2010
- Messages
- 108
- Helped
- 22
- Reputation
- 44
- Reaction score
- 21
- Trophy points
- 1,298
- Location
- India
- Activity points
- 1,813
int main(void)
{
while(1) // loop forever
if(...) main1();
else main2();
}
void main1()
{
..
}
void main2()
{
...
}
easy way merge the two project files as a single project and do like #3.
otherwise change the starting address of the second application, ensure it is not overlapping with the first code then write some boot from assembly code to select which part to execute first.
Or you can use the function pointer to do the job instead of assembly...
Also It it is not at all going to possible if you got any ISR s to work with..
does the linker map give you the entery point of the two programs - you can then jump to the appropriate address? what do you do about the stack pointer etc?
I will burn both the hex files to my 8051..
0x0000 ~ 0x0FFF == APP1.hex
0x1000 ~ 0x1FFFF == APP2.hex
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 main() { void (*FuncPtr)(void); FuncPtr = (void *)Starting address of main of APP2; . . . if( you want switch to APP2 ?) { (*FuncPtr)(); } . . . }
Make sure no part of the code in both programs are not overlapped !!!
from APP1
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 main() { void (*FuncPtr)(void); FuncPtr = (void *)Starting address of main of APP2; . . . if( you want switch to APP2 ?) { (*FuncPtr)(); } . . . }
I never tried this before, If you try this your code will work fine for some time for sure.
Stack overflow can occur any time, If you switch often and also I am not sure about the init values of functions ..
In this case, you'll simply jump to the reset vector (begin of startup code) of APP2 which is probably not identical to main(). It's necessary to perform the regular initialization of APP2, otherwise it won't run properly.YES, i want to achieve the boot code and APP code in the controller. If BOOT is OK then i need to jump from BOOT CODE to the APPlication code to run interfaced devices and all.
In boot code i am not at all using ISR, it just checks for a particular condition.. and Jumps to aPP.
@FvM: YES, i want to achieve the boot code and APP code in the controller. If BOOT is OK then i need to jump from BOOT CODE to the APPlication code to run interfaced devices and all.
In boot code i am not at all using ISR, it just checks for a particular condition.. and Jumps to aPP.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?