copy page 3D to page 3F

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

copy page 3D to page 3F

ソリューションへジャンプ
2,805件の閲覧回数
hdan
Contributor III
hello, I'm working with a 9S12DG256 and code warrior 3.1. I want to copy the page 3D (i can change) to the page 3F. I try to do that with code of AN2720. but this code use function like _LCMP from rtshc12.c who are located in 3F. what s the best way to do that? (in C, i haven't work in ASM) thx.
ラベル(1)
タグ(1)
0 件の賞賛
返信
1 解決策
1,515件の閲覧回数
hdan
Contributor III
Well, it's done. I've move code to page 3E and rewrite all function to avoid far access. thx

元の投稿で解決策を見る

0 件の賞賛
返信
4 返答(返信)
1,515件の閲覧回数
J2MEJediMaster
Specialist I
Try taking a look at AN3275, which describes a bootloader for HCS12 parts. You'd be interested in the Flash programming code in this document, of course. It's written mostly in C. Both the Acrobat file and its software archive can be found on this page.

Things to remember are: it sounds like you're doing a copy from one flash sector to another. If those sectors are part of the same Flash bank, then that won't work. You're trying to read something from the same bank you're trying to program. You have to copy your data and code to do the programming into RAM, and then write your changes back to Flash. Tech Note 228 (TN228) explains how to do this, and its Acrobat file should be located in the CodeWarrior documentation directory.

---Tom
0 件の賞賛
返信
1,515件の閲覧回数
Lundin
Senior Contributor IV
They are in the same bank: pages 3C, 3D, 3E and 3F are in bank 0. So you can't copy directly from one page to another, you'll have to copy one 512 bytes large section from 3E to RAM, then burn them to 3F.
0 件の賞賛
返信
1,515件の閲覧回数
hdan
Contributor III
hello,


Thanks for your help.

I have moved the page to copy at page 38.
The function needed to do the copy is at page 37.
and the destination is 3F.
(three differents blocks)

I do that:

int TransPrg (void)
{
unsigned char TToTrans[Flash_Sector_Size];
unsigned int ind,data;
long adr,adrFlash;
char valRet;

for (adr =0x3F8000;adr0x3F9FFF;adr=adr+Flash_Sector_Size)
{
valRet=Flash_Erase_Sector((unsigned int *far)adr);
}

for (adr =0x388000;adr0x389FFF;adr=adr+Flash_Sector_Size)
{ for (ind=0;ind
{
data= *(( unsigned int *far) (adr+ind));
TToTrans[ind]=data>>8;
TToTrans[ind+1]=data&0x00ff;
}
adrFlash= adr + 70000;
valRet = Flash_Write_Block (( unsigned int *far) TToTrans,( unsigned int *far)adrFlash,(Flash_Sector_Size/2));
}

}

with Flash_Sector_Size = 0x200
but when I do a step by step execution, in the function
Flash_Erase_Sector there is a line :

if ((unsigned long)far_address >= 0x10000)
{ ...

who call the function :

void _LCMP (void) {
__asm {
#ifdef __HCS12X__
CPD 4,SP
CPEX 2,SP
#else
CPD 4,SP
...
LEAS 4, SP ; release stack arguments
JMP 0, Y
}
}

This function making a long compare, this function is in the file rtshc12.c, and it's at the address 0xC6E2 (0x3F86E2) in the page that i want to erase!

what can i do to do ?
0 件の賞賛
返信
1,516件の閲覧回数
hdan
Contributor III
Well, it's done. I've move code to page 3E and rewrite all function to avoid far access. thx
0 件の賞賛
返信