Previous in Forum: MRP II SOFTWARE FOR FOOTWARE INDUSTRY   Next in Forum: Which kind of keyboard do you use?
Close
Close
Close
Rate Comments: Nested
Participant

Join Date: Mar 2008
Posts: 2

Problem with writing to Flash using Analog devices blackfin processor

07/08/2008 3:49 AM

Hi,
I have written a small piece of code to write data to flash. I am using a BF534 processor. The flash is connected to the bank 0 of the BF534 Here is the piece of code :
----------------------------start of code ----------------------------
#define START_ADDR 0x20000000
#define FLASH_555 0x0AAA //these 2 values were obtained from #define FLASH_2AA 0x0554 //flash driver program provided by AD

int write_flash(unsigned long offset,const short *buffer,int num){
for(int i=0;i<num;i++){
//flash write sequence
wr_flash((START_ADDR+FLASH_555),0xAA);
wr_flash((START_ADDR+FLASH_2AA ),0x55);
wr_flash((START_ADDR+FLASH_555),0xA0);
//end of flash write squence

//writing the actual data
wr_flash((START_ADDR+offset+i*2),*(buffer+i));

for(int j=0;j<0x200;j++){
asm("nop;");
}
}
}


static inline ERROR_CODE wr_flash(unsigned long wr_addr,short data){

unsigned int uiSaveInts = cli();
short *flash_addr=(short *) wr_addr;
*flash_addr=data;
sti(uiSaveInts);
return NO_ERR;

}
---------------------end of code --------------------------------------
But when I use this code.. After writing to the flash if i check the memory location i am writing, it is filled with junk data. Not only that when I write a single location, the other locations are also getting written by junk data. Has anybody encountered such a problem before.?
Regards,
Nithin

Register to Reply
Interested in this topic? By joining CR4 you can "subscribe" to
this discussion and receive notification when new comments are added.
Guru
Canada - Member - Specialized in power electronics

Join Date: Feb 2008
Location: Montreal, Canada.
Posts: 1372
Good Answers: 80
#1

Re: Problem with writing to Flash using Analog devices blackfin processor

07/09/2008 9:53 AM

1- You might need to unlock the flash for writing.

2- You should test the Write done bit instead of waiting for a fix time. depending on the type. If you access the flash while it is writing, you might get wrong data.

3- Are you certain that is it wired properly? Check the wiring and applications notes. You might not be connected to the proper section of the data bus.

4- Did you check the access time for the flash and DSP? I had to add wait states to get mi flash to work on the slower ADSP-2181. Make sure that you include your address decoding logic in the timings.

__________________
Experienced is earned, common sense is taught, both are rare essentials of life.
Register to Reply
Register to Reply

Previous in Forum: MRP II SOFTWARE FOR FOOTWARE INDUSTRY   Next in Forum: Which kind of keyboard do you use?

Advertisement