Sign in

username:

password:



Not a member?

Search adsp



Search tips

Subscribe to adsp



adsp by Keywords

AD1819 | AD7332 | ADSP-2106 | ADSP-21060 | ADSP-21065L | ADSP-2116 | ADSP-21160M | ADSP-2181 | ADSP-218x | ADSP-219 | ADSP-2199 | ADSP219 | BF531 | BF532 | BF533 | BF535 | Blackfin | FFT | JTAG | LDF | SDRAM | SHARC | SPORT | UART | VDSP++ | VisualDSP

Sponsor

NEW! TMS320C6474: 3x the performance. 1/3 the cost. Three 1 GHz cores on 1 chip.

Discussion Groups

Discussion Groups | Analog Devices DSPs | Writing data to flash memory

Technical discussions related to Analog Devices DSPs (including Blackfin, TigerSHARC, SHARC and ADSP-21xx DSPs).

  

Post a new Thread

Writing data to flash memory - isni...@gmail.com - Jul 8 8:38:56 2008



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

------------------------------------



(You need to be a member of adsp -- send a blank email to adsp-subscribe@yahoogroups.com )

Re: Writing data to flash memory - Mike Rosing - Jul 8 9:12:55 2008

Howdy Nithin,

Check the timing of your write sequence.  You may need to wait several
microseconds between each write.  Look at the data sheet for the flash
and monitor your writes by o'scope to make sure all the timing is correct.

Some flash devices allow you to read back status by watching the D0 or D7
bit.  You may be able to write, then read until a bit is set (or clear)
and then do the next step.

In any case, watch the write strobe, chip select and other control lines
to make sure you are hitting the flash the way it wants.

Patience, persistence, truth,
Dr. mike

 On Tue, 8 Jul 2008 i...@gmail.com wrote:

> 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
>

------------------------------------



(You need to be a member of adsp -- send a blank email to adsp-subscribe@yahoogroups.com )