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