Hi,
First please be note that in the case of the ColdFire V1, the code must be executed from RAM in order to perform this operation.
Flash routines are physically stored in ROM. At software startup, "__copy_rom_sections_to_ram" function will copy them to RAM, as defined by __S_romp table in the linker definition file.
It’s important to mention that all the flash writes and erase must be performed with longword aligned addresses. If you try to write to a non-aligned location (i.e. 0x10001) the device will return an address error.
This is the reason why you’ll see that for the ColdFire all the pointers and addresses are declared as long and the addresses are longword aligned.
Now that the code is in RAM, you can use the routines to write and erase flash.
It is very important to set FCDIV correctly depending on the bus frequency (to get flash programming clock frequency between 150 kHz and 200 kHz).
The functions in the example are:
Flash_SectorErase(Address);
This definition erases a flash sector (1024 bytes); the parameter sent is a 32-bit address within that sector.
Flash_Program(Address, Data);
This one is used to program a longword for the ColdFire into the Flash; you have to sent the 32-bit address and a variable containing the data to be programmed.
Flash_BurstProgram(Address, Pointer, Size); The last definition is used to program an array into flash; the parameters needed are the address, the pointer to the buffer where the data that will be programmed is and the amount of longwords to be programmed.
I would like to mention, that internal flash is very nicely described in the MCF51JM128 Reference Manual in the section 4.4. It shows state diagrams of a flow of all flash commands.
Yes, that is normal, and catches a lot of people out. Here's the last one:
Flash Logical Block in MCF52235
Why don\t they make FLASH chips where you can read them while they're programming? It would take a lot more silicon to do that and would make the chips cost a lot more. So they don't.
Tom
It appears that the entire flash memory is unavailable. Not just the sector your are writing.
Thanks.