Anthony Garrido

Problem with write/erase operation on AM29lv160DB external FLASH (coldfire 5235)

Discussion created by Anthony Garrido on Sep 14, 2006
Latest reply on Jul 22, 2008 by Francois Bouchard
hello,

In my project (based on MCF5235), I must store datas in my flash(AM29LV160DB).

My problem is that I can't access at my Flash with a write command. Every time I begin my write sequence "*((uint16 *)(EXT_FLASH_ADDRESS + 0x0555)) = 0x00AA;" an exception occurs ("Attempted write to write-protected space")

I saw in this forum that the Coldfire doesn't support a write or erase in Flash operation when the code runs in it, so, as I saw on many topics, I "copy" my write code in my RAM.

Is there a problem with protected sector?
Does someone see what is wrong?

Thanks a lot for your implication,
Regards
AgC

Here is my code:

My link file:

Code:
MEMORY {ext_nvsram (RWX) : ORIGIN = 0x10000000, LENGTH = 0x00080000vector_ram (RWX) : ORIGIN = 0x20000000, LENGTH = 0x500sram (RWX) : ORIGIN = 0x20000000, LENGTH = 0x00010000user (RWX) : ORIGIN = 0x20000500, LENGTH = 0x0000FB00ext_sram (RWX) : ORIGIN = 0x30000000, LENGTH = 0x00080000ipsbar (RWX) : ORIGIN = 0x40000000, LENGTH = 0x01ext_flash (RWX) : ORIGIN = 0xFFE00000, LENGTH = 0x00200000}SECTIONS {.vector_ram : {} > vector_ram.ipsbar : {} > ipsbar.sram : {} > sram.ext_sram : {} > ext_sram.ext_nvsram : {} > ext_nvsram.ext_flash : {} > ext_flash.user : {} > user.boot_flash :{obj-CPU_A/vectors.o (.text)*(.text)*(.rodata)*(.rodata.str1.1)} > ext_flashMy code file:enum TFlashStatus Flash_write_word(ULWORD address, UWORD data){*((uint16 *)(EXT_FLASH_ADDRESS + 0x0555)) = 0x00AA;*((uint16 *)(EXT_FLASH_ADDRESS + 0x02AA)) = 0x0055;*((uint16 *)(EXT_FLASH_ADDRESS + 0x0555)) = 0x00A0;*((uint16 *)(EXT_FLASH_ADDRESS + address)) = data;return FLASH_SUCCESS; }void runEnd(void){} // leave this immediately after runInRamenum TFlashStatus Flash_Set_Word(ULWORD address, UWORD data){enum TFlashStatus status;char buf[200];enum TFlashStatus (*ramCopy)(ULWORD, UWORD) = (enum TFlashStatus(*)(ULWORD,UWORD))buf;/* Ecriture du mot de données */memcpy(buf, (void*)Flash_write_word, (char*)runEnd - (char*)Flash_write_word);status = ramCopy(address, data);return status;}

 
(Alban formatted code)

Message Edited by Alban on 2006-09-14 10:55 AM

Outcomes