Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
April 19, 2024, 09:22:05 21:22


Login with username, password and session length


Pages: [1]
Print
Author Topic: 8051 "two codes in flash"  (Read 4684 times)
0 Members and 1 Guest are viewing this topic.
ktasdelen
Newbie
*
Offline Offline

Posts: 23

Thank You
-Given: 16
-Receive: 5


« on: November 10, 2009, 09:45:39 09:45 »

Hi Everybody

I have 2 codes:
for example, First code :0x0000-0x1fff
second code : 0x3000 - 0x7fff

I want to learn " how can I run these codes together"

can anybody help me or suggest any source?
Logged
sam_des
Senior Member
****
Offline Offline

Posts: 253

Thank You
-Given: 124
-Receive: 146


« Reply #1 on: November 10, 2009, 10:09:04 10:09 »

Hi,

Can you be more informative ? Huh

I wonder why people never think that whatever they say or write may seem completely nonsense even if it makes perfect sense to themselves ?  Roll Eyes

reagrds,
sam_des
Logged

Never be afraid to do something new. Remember Amateurs built the Ark, Professionals built the Titanic !
pickit2
Moderator
Hero Member
*****
Offline Offline

Posts: 4647

Thank You
-Given: 826
-Receive: 4207


There is no evidence that I muted SoNsIvRi


« Reply #2 on: November 10, 2009, 11:46:52 11:46 »

Problem maybe in the translation, if the native is say english and is translated to spanish, how do you know, it was translated correctley. even if you translate back to english it may look ok.
granted the question is not easy to work out.

he has two code samples (and we know that he can't run both at the same time.(unles we missed something like the 8051 can multitask Smiley ) so does he want a way to select order they are run or what?
Logged

Note: I stoped Muteing bad members OK I now put thier account in sleep mode
Ichan
Hero Member
*****
Offline Offline

Posts: 833

Thank You
-Given: 312
-Receive: 392



WWW
« Reply #3 on: November 10, 2009, 11:52:12 11:52 »

Hi,

I'm interested to know what kind of application you aim for with that two code in one.

A bootloader usually is a small code that run another code if some condition satisfied, perhaps you could learn from it.

-ichan
Logged

There is Gray, not only Black or White.
aplank
Active Member
***
Offline Offline

Posts: 111

Thank You
-Given: 137
-Receive: 193


« Reply #4 on: November 10, 2009, 02:40:51 14:40 »

Well,

I noticed this was posted on the Keil forum earlier and the guys there were equally baffled.

http://www.keil.com/forum/docs/thread15913.asp


Logged
ktasdelen
Newbie
*
Offline Offline

Posts: 23

Thank You
-Given: 16
-Receive: 5


« Reply #5 on: November 10, 2009, 06:14:01 18:14 »

hi;
my question is "how two applications can cooperate?"
I have two programs.
0000-7fff user space - user program can be change and program ISP(In System Programming)
f800-ffff boot space - main program can be program by parallel programmers.
main program will never change.
I can program mcu, no problem.
I wonder that can main program control user program?
for example
when I give an order, main program can do this (run or stop the user program).

Logged
oldvan
Senior Member
****
Offline Offline

Posts: 372

Thank You
-Given: 154
-Receive: 107


If the van is a Rockin'...


WWW
« Reply #6 on: November 10, 2009, 06:29:27 18:29 »

Perhaps a timer interrupt can alternately flag one then the other as active,
and code can check this flag, co-operative time sharing?
Logged

Give a man a fish and you feed him for a day.
Teach a man to fish and he will sit around in a boat drinking beer all day.
sphinx
Hero Member
*****
Online Online

Posts: 913

Thank You
-Given: 606
-Receive: 265



« Reply #7 on: November 10, 2009, 06:54:45 18:54 »

why cant you just use a simple pin change check to which programpart to run. doesnt sound too strange to me to use different program to tell which to use. maybe a bit like a 110/220 switch or 2 in one chip for different languages, or just as simple as to use same chip in 2 different hardwares that are a bit modified.

regards
Logged

laws of physics are not laws at all, just assumptions and formulas that work as long as we don't figure something new that wrecks the calculations. the infinite onion try to peel that one
metal
Global Moderator
Hero Member
*****
Offline Offline

Posts: 2420

Thank You
-Given: 862
-Receive: 678


Top Topic Starter


« Reply #8 on: November 10, 2009, 08:31:30 20:31 »

hi;
my question is "how two applications can cooperate?"
I have two programs.
0000-7fff user space - user program can be change and program ISP(In System Programming)
f800-ffff boot space - main program can be program by parallel programmers.
main program will never change.
I can program mcu, no problem.
I wonder that can main program control user program?
for example
when I give an order, main program can do this (run or stop the user program).



Wait Wait Wait.. You have to reprogram ISP code (f800-ffff boot space) because this area is protected against flash write instructions and what you want in this case is to modify the original ISP code in order to make it respond to your commands or events, and be aware to change the value of N which identifies how many blocks you will use for ISP space when you use a parallel programmer. In your case N = 4, 512 bytes/Block.

I meant you have to modify the ISP code in order to run or stop the user code (0000-7fff user space). You can use serial communication or a pin in your processor to loop in main so as to send it to ISP code when you want to stop and loop forever in the ISP code waiting for another command to run the user code again. If you tell us what exactly you want to do and mention the microcontroller type/number as well as the codes I might be able to help you more because I modified an RS-232 ISP code to run on RS-485 instead and was able to send user code to ISP code and vice versa, but it was a bit of work and experiments a month ago because I am new to 8051 assembler.

For example you can go to ISP code as follows:
Code:
// =========== Goto ISP definition ===========
#define GotoISP() ((void (code *) (void)) 0xF800) ();
Now You can use GotoISP() to jump to ISP using a pin on the controller, in this case P3.2:
Code:
// =========== Main Function ===========
void main(void){
for(;;){
if ((P3 & (0x01<<2)) == 0){
GotoISP();
}
// User code
}
}

This is what I use to manually go to ISP after I reset the controller. BTW, not all 8051 microcontrollers automatically go to ISP program, so I need to know which microcontroller you are using. Some of them will automatically go to ISP provided that the first location in user code is 0xFF. But the problem with that is you have to ensure that you insert 0xFF at the first location in you assembler or C languages in the ISP code.
« Last Edit: November 10, 2009, 08:50:12 20:50 by metal » Logged
Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright © 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC