How to protect Flash with FLBPR??? (MC68HC908)

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

How to protect Flash with FLBPR??? (MC68HC908)

4,115 次查看
Soror
Contributor I
Hi,

I would like to protect my flash with the FLBPR register. The datasheet says: "The range of the protected area starts from a location defined by FLBPR and ends to the bottom of the FLASH memory ($FFFF)."
So I can only protect an area at the end of the flash-addressspace. Unfortunately my program-code is stored at the beginning of the flash-addressspace. The free pages I could use for my data are at the end. How can I then protected the program-code from being over-written by mistake? As far as I know it's not possible to de- and reactivate the protection. So I need to place the program-code at the end of the flash-addressspace and use the beginning for my data. But how can I configure this with CodeWarrior?

Thanks a lot.

Regards,

Soror
标签 (1)
0 项奖励
5 回复数

629 次查看
Alban
Senior Contributor II

Hi Soror,

The spaces where Data and Code will be placed in the MCU are in the linker paramter file or PRM file.

In the prm file of your project, just change the addresses to the wished location.

Code:

SEGMENTS /* here all RAM/ROM areas of the device are listed. Used in PLACEMENT below. */  Z_RAM     = READ_WRITE 0x0040 TO 0x00EF;  RAM1      = READ_WRITE 0x0100 TO 0x043F;  RAM2      = READ_WRITE 0x0580 TO 0x097F;  ROM1      = READ_ONLY  0x0462 TO 0x04FF;  ROM2      = READ_ONLY  0x0980 TO 0x1B7F;  ROM3      = READ_ONLY  0x1E20 TO 0xFDFF;//OSVECTORS = READ_ONLY  0xFFCC TO 0xFFFF;  /* OSEK interrupt vectors (use your vector.o) */  ENDPLACEMENT /* here all predefined and user segments are placed into the SEGMENTS defined above. *///.ostext,                                      /* OSEK */  DEFAULT_ROM                   INTO /*ROM1, ROM2,*/ ROM3;  /* in case you want to use ROM1/ROM2 here as well, add option -OnB=b to the compiler. */  DEFAULT_RAM                   INTO RAM1, RAM2;  _DATA_ZEROPAGE, MY_ZEROPAGE   INTO Z_RAM;//VECTORS_DATA                  INTO OSVECTORS; /* OSEK */END


 
Declare a Zone DATA you can map to another ROM area you don't protect.


To reset the FLBPR value to 0xFF, you need to do a MASS ERASE.

Cheers,
Alban.

0 项奖励

629 次查看
Soror
Contributor I
Hi Alban,

thanks a lot :-)! That's exactly what I am looking for!

Regards,

Soror
0 项奖励

629 次查看
Soror
Contributor I
Hi Alban,

I still have some problems. I tried to change my prm to this:

SECTIONS
ROM = READ_ONLY 0xF840 TO 0xFDFF;
Z_RAM = READ_WRITE 0x0080 TO 0x00FF;
InterruptVectors_ROM = READ_ONLY 0xFFDE TO 0xFFFF;
MyROM = READ_ONLY 0xF800 TO 0xF83F;
END

PLACEMENT
DEFAULT_RAM INTO Z_RAM;
DEFAULT_ROM, ROM_VAR, STRINGS INTO ROM;
_DATA_ZEROPAGE, MY_ZEROPAGE INTO Z_RAM;
DATAFLASH INTO MyROM;
END

I couldn't name the zone DATA. With DATA I got a linker-error a sectionname would be expected. So I called the zone DATAFLASH.

But I receive an error during runtime:

Error: At location F83F -
Error: Attempt to use invalid or uninitialized memory

The code is:

unsigned char flashByte[64] @ 0xF800;

if ( flashByte[i] == 0xFF ) /* i=63 */

=> Translated in "LDX 63488,X", which produces the error.

If I point the array flashByte to the "ROM" area 0xF83F it works fine.( unsigned char flashByte[64] @ 0xF83F; ) But it doesnt work with my DATAFLASH address-space.

Thanks a lot.


Regrads,

Soror

Message Edited by Soror on 2006-08-10 03:08 AM

Message Edited by Soror on 2006-08-10 03:09 AM

Message Edited by Soror on 2006-08-10 03:10 AM

Message Edited by Soror on 2006-08-10 03:18 AM

0 项奖励

629 次查看
Alban
Senior Contributor II

Yo,

You've declared your area MyROM, OK.... But you need to tell the compiler which variable/constant you want to put there !

In the C code, I want for instance to declare a global variable, I would do like this:

Code: main.c

#pragma DATA_SEG MyROMtU08 ResetCounter;#pragma DATA_SEG DEFAULT

 

Only ResetCounter will go to MyROM and then I switch back to default Data space.

Alban.
 

0 项奖励

629 次查看
Soror
Contributor I
THANKS! now it's working.

regards,

Soror
0 项奖励