Flash Read and Write for MCF5485

Showing results for 
Search instead for 
Did you mean: 

Flash Read and Write for MCF5485

Contributor III


I have a MCF5485 processor running project which has timer interrupts. So while reading and writing into external  flash using fucntions,I have some problems since the SW gets stuck and .Whether I have to disable the interrupt while reading and writing into flash

0 Kudos
3 Replies

Specialist I

What sort of "External Flash"? That covers a very wide range.

It could be parallel Flash on the external Address and Data Bus (Flexbus). It could be I2C or SPI Flash. It could even be NAND Flash (unlikely on this CPU). It could even be a Memory Stick on a USB bus. Or an SD Card. Or a Solid State Drive on a PCI bus.

You should give us more details so we can understand what you're doing.

What sort of Flash technology? The new stuff is "self timed", but some of the older stuff needed the CPU to guarantee timing. It is unlikely you're using anything that old, but you might.

The Read cycles shouldn't give trouble if they're interrupted. The Write cycles might, if they're timing critical.

What are the specifications for reading and writing through whatever interface you're using? Could interrupts stretching the timing cause a problem? Is the Flash Writing code using an external timer (to see if the write completes) and that timer is falsely triggering when the code is interrupted? The code can be fixed to check for that condition if you know what can happen.

Does the "Timer Interrupt" perform any operations that could interfere with the Flash Writing? Does any of the interrupt code (or any of the functions it calls) try to READ the Flash for instance?

Where is the MCF5485 running its code from? If it is running from the external Flash when you're trying to program it it causes all sorts of complications. Or is it running code from the SDRAM?


0 Kudos

Contributor III

Hi Tom,

The External flash used is IN28F256K3 Intel StrataFlash® Synchronous Memory(K3/K18).So the interrupt used is Slice timer 1 and Slice timer 0 for Watchdog. So after programming the operational code using PROGCFZ Flash programmer from PE Micro while Write_to_flash gets called in the process,the SW gets stuck ,so while I Debugged, I found that once it enters erase flash functions or write into flash functions if the interrupt is not disabled then it would not continue further and gets stuck.When I disabled ,write to flash function/eare to flash function would work fine. This is the linker lcf file I used

KEEP_SECTION {.vectortable}




boot (RWX) : ORIGIN = 0x00000000 , LENGTH = 0x00200000

text (RWX) : ORIGIN = 0x02001000 , LENGTH = 0x02000000

vector_ram (RWX) : ORIGIN = 0x20000000, LENGTH = 0x00000400 /* Vector table */

data (RWX) : ORIGIN = AFTER(text), LENGTH = 0

bss (RWX) : ORIGIN = AFTER(data), LENGTH = 0




# Heap and Stack sizes definition

___heap_size = 0x100;

___stack_size = 0x100;

.vector_ram : {} > vector_ram

___MBAR = 0x10000000;

__MBAR = ___MBAR ;

___SDRAM = 0x02000000 ;

___SDRAM_SIZE = (8 * 1024 * 1024);

# ___SDRAM_SIZE = (16 * 1024 * 1024);

___SYS_SRAM = ___MBAR + 0x00010000;

___SYS_SRAM_SIZE = (32 * 1024) ;


___MCDAPI_SIZE = (12 * 1024);

___CORE_SRAM0 = 0x20000000 ;

___CORE_SRAM0_SIZE = (4 * 1024) ;


___CORE_SRAM1 = 0x20001000 ;

___CORE_SRAM1_SIZE = (4 * 1024) ;



___CODE_FLASH = 0x00000000 ;

___CODE_FLASH_SIZE = (32 * 1024 * 1024);


___BOOT_FLASH = 0x00000000 ;

___BOOT_FLASH_SIZE = (2 * 1024 * 1024);


___VECTOR_RAM = ADDR(.vector_ram);


.boot :


. = ALIGN(0x4);








. = ALIGN(0x4);

_BOOT_END = .;

} > boot


.text : AT(0x00010000)


. = ALIGN(0x4);





. = ALIGN(0x4);

___DATA_ROM = . ;

_TEXT_END = . ;

} > text

_TEXT_PHYSICAL = 0x00010000;



.data : AT(0x00010000 + SIZEOF(.text))


. = ALIGN(0x4);

___DATA_RAM = . ;






. = ALIGN(0x4);

___DATA_END = . ;

} > data

_DATA_PHYSICAL = 0x00010000 + SIZEOF(text);



.bss :


. = ALIGN(0x4);

___BSS_START = . ;





. = ALIGN(0x4);

___BSS_END = . ;

} > bss


___HEAP_START = .;

___HEAP_END = ___HEAP_START + (512*1024);

___SP_END = ___HEAP_END;

___SP_INIT = ___SP_END + (4*1024);



0 Kudos

Specialist I

The "28F256K3 Intel StrataFlash" is ancient (2003 or earlier), but is self-timed.

Your original question contained:

> So while reading and writing into external  flash using fucntions

That implies your device is running a program stand-alone and calling functions to program the Flash.

That's not what you're doing at all. You're running PROGCFZ on a PC connected via USB to a Debug Pod connected to the BDM interface of the CPU. That program on the PC downloads "Programmer" software into (I would guess) the Static RAM of the CPU and runs it to program the external Flash. That software should be the only thing running, and should have "total control" of the CPU, but it seems you're running it in a way where there is other code and other interrupts still firing on the CPU. That can be expected to interfere with what PROGCFZ is trying to do, and you've found it does.

It is likely that the program PROGCFZ loads into the Static RAM has a small stack, and that the interrupt routines you're using are trashing that stack. Or they're doing something else to the CPU that is wrong for what the programmer is trying to do. I asked you what the interrupt routines did.

> This is the linker lcf file I used

That tells me nothing useful at all. If there's something important you think I should be looking for in that file then you should tell me what that is.

> Whether I have to disable the interrupt while reading and writing into flash

Is that meant to be a question?

> When I disabled ,write to flash function/eare to flash function would work fine.

So you don't have a problem any more. You had a problem with your setup and found a fix.

Now that we know that, thanks for letting the rest of us know.