S12DG256 - Trying to flash page 3F in program.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

S12DG256 - Trying to flash page 3F in program.

2,916 Views
hdan
Contributor III
hello,

I want to load my S12DG256 program from a external memory(sd card)and re-flash my the Page 30,,,35 and 3F.

I try to put all the code used for this in the Page 36.
But my program use the rtshc12.c function like _LCMP.

Can I move theses functions from page 3F to Page 36 and how to do it?

code :

Code:
#ifdef __cplusplusextern "C"#endif#pragma NO_FRAME#pragma NO_ENTRY#pragma NO_EXITvoid _LCMP (void) {__asm {CPD 4,SPBEQ L1PSHXXGDXSBCB 5,SPSBCA 4,SPXGDXANDCC #0xFB ; clr zPULXBRA doneL1: CPX 2,SPdone:PULY ; load return addressLEAS 4, SP ; release stack argumentsJMP 0, Y}}

 


I try to use :
#pragma CODE_SEG CODE_CPYMEM

but it does nothing.

thanks,

--
Alban Edit: FSL Part Number must figure in Message Subject line.



Message Edited by Alban on 2007-07-24 02:11 PM
Labels (1)
0 Kudos
7 Replies

650 Views
hdan
Contributor III
Thanks to all, i think with these answers i'll found the solution.

hdan.
0 Kudos

650 Views
hdan
Contributor III
hello,


Well, i've done it and i can work with string in banked page now but i have a problem:

char stH[10]=" --- ";
char stO[30];
nInd = sprintf(stO,stH); // => good result
nInd = sprintf(stO,"%s",stH); // => bad one

why ?
0 Kudos

650 Views
CrasyCat
Specialist III
Hello
 
I think you get your answer from following thread:
 
CrasyCat
0 Kudos

650 Views
mke_et
Contributor IV
Remember that when you flash, you can be affecting not only the 'page' you are trying to write to, but the 'bank' as well.

When I did my program, I purposely picked pages for all my 'options' and data so that the code running the flashing wasn't on the same bank.

Also, remember what else may be affected. ISR vectors for example... If you try to muck with flash so that they can disappear, you'd better have everything disabled that might try to use them!

As to using page 36 instead of 3F, in your case that's really a 'c' issue and I'm not a c person, I did all my stuff in assembly. But in that case, all I did was 'org' my code to be at the 'flat address' of the page. However, I did write my own page switching routines. (In one case, I did identical routines on two pages, and what I called and used depended on what my target page was.)

Mike
0 Kudos

650 Views
hdan
Contributor III
Hello,

Perhaps less difficult, i can push all my data in the others pages.(then no need to flash the page 3F)

But it create a problem function like sprintf doesn't work
with far data...

I think there is a way to make these function to deal with far data.

Someone can give me that?

thanks,
0 Kudos

650 Views
CompilerGuru
NXP Employee
NXP Employee
Using anything else than page 3F for the loader means that you have to at least temporarily erase the reset vector, therefore if the board looses power just at this time (Murphy), it does not boot anymore (and you can only rescue it via BDM).

About your question of how to use sprintf with far pointers, search in this forum, I think this came up a couple of times. Basically possible but __far pointers are not especially efficient for the HC12/S12. So check what you really need, and avoid to use __far everywhere.

Also putting _LCMP into a paged bank can cause troubles if anything outside of this page is using _LCMP. The _LCMP runtime routine is called with a JSR, so calls from another page will not reach it. If the complete application is just on a single page, say 0x36, then PPAGE is always just set right anyway. But be careful not to place any code in the same application anywhere else.
What you should think of, if you did not do it already, is to create the loader in its own completely separate ELF application. This way it gets its own copy of the runtime support and you can place it all together into its own completely separate area.

Daniel
0 Kudos

650 Views
CrasyCat
Specialist III
Hello
 
Just to close the loop on the question around storing string constants in banked memory, there is a FAQ available on that topic.
 
Just go the Freescale web page and search for "FAQ-27439".
 
CrasyCat
0 Kudos