Flash Winbond with ATXMEGA256A3BU

Go To Last Post
8 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi All,

 

I am using a Flash Winbond w25q32bv with my ATXMEGA256A3BU. The flash memory is working fine, I can write and read data without any issue. So my question is not code related, it's a about the memory usage of my XMEGA.

 

Some background: The flash memory is divided in 16384 pages of 256 bytes each. The thing is that these pages can be written only if they were previously erased. Quote from the datasheet: "The page program instruction allow from one byte to 256 bytes (a page) of data to be programmed at previously erased (FFh) memory locations"

But I can only erased pages in groups of 16, it's not possible to erased pages one by one.

 

So, what I am actually doing every time I need to write a single page that is already written is doing a backup on my XMEGA of 16 pages. Erasing those 16 pages on the flash memory, putting the 15 pages I want to keep again in the flash and finally write the new data in the page I wanted to write. It was a bit hard to code this, but I did it and it's working. The thing is that to do this I use 256 bytes * 16 = 4 KB of memory of my XMEGA. This is not a problem when the rest of my program is simple and small, but I facing some issues of memory usage on  more complex programs.

 

Do you have any idea on how can I reduce the memory usage? Maybe there is another way to implement the flash memory.

 

I know that my question is a bit tricky and confusing, so please if you need more information or further clarification please let me know.

 

Many thanks!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

This is a common problem! You need to avoid writing over existing data. Or you copy the data to a erased sector. Unfortunately there is no magic solution - it is like shuffling boxes around or rubik's cube.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Unfortunately I cant avoid writing over existing data since I am expecting to store more than 16384 measures of my sensors. I implemented  FIFO in the flash memory so the old data is always overwrite by the new data.

Thanks for your help anyway!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The w25q32bv has the same endurance as the AVR's EEPROM: 100,000 cycles.  You could push the 15 pages-to-keep to EEPROM instead of SRAM.  Mind you, with only 4K of EEPROM, the overall wear on the EEPROM will exceed that on the w25q32bv which has a thousand times as much storage.  Writes to EEPROM will also be slower, although page access will help.  With 32-byte pages, the whole 4K EEPROM will take about a second.  This may make the whole approach unsuitable for your app.  You could use flash in the same way.  Although write endurance is lower (10,000 cycles), page size is 512 bytes so 4K will take only 64 ms.

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"Read a lot.  Write a lot."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Unfortunately I cant avoid writing over existing data since I am expecting to store more than 16384 measures of my sensors. I implemented  FIFO in the flash memory so the old data is always overwrite by the new data.

Of course you can!

When you start out fresh, there is no problem as all sectors are erased. The fun begins when you have filled up and need to kill off the oldest sector of data.  If you can't compromise with that, then maybe a sdcard is a better solution.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

@cventu  Hi  This side Soumya I am also working with the same flash what you had already used .can you give me your avr code so that I can get some reference from it.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

@soumyalm Note that the last post in this thread (before you woke it up) was over a year ago - the OP no longer appears to be active here

 

Datasheet: http://www.winbond.com/hq/produc...

 

Note that they classify it as:

 

HOME Product Code Storage Flash Memory Serial NOR Flash

 

So it's not actually designed for data storage.

 

Last Edited: Tue. May 30, 2017 - 12:58 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Have you Googled for code examples? There's probably some for the Arduino which happens to have an AVR.