cancel
Showing results for 
Search instead for 
Did you mean: 

STR912 Mass Storage with spi driver

hjn2
Associate
Posted on February 05, 2010 at 11:55

STR912 Mass Storage with spi driver

2 REPLIES 2
nickkinchin2
Associate II
Posted on May 17, 2011 at 10:00

Hi,

If someone can solve my problem ''STR9 Timer Prescaler'' posted on this board, I will upload the full IAR project I did for Mass Storage with M25P64 (works on STR910-EVAL board).

Regards.

nickkinchin2
Associate II
Posted on May 17, 2011 at 10:00

Hi Hans,

If you are using the M25P64 (or same family) then you can use 'ssp_flash_driver.c' (from this site) to drive the IC. It has all the useful functions you need.

From a hardware point of view, the flash IC can be written 256 bytes at a time (flash 'page' size).

But to re-write, you first have to erase a flash 'sector' which is 65536 bytes in size.

One way (maybe simplest) would be to hold a 'sector' buffer (64KB) in RAM. Every time Read_Memory() or Write_Memory() is called, a 64KB sector can be read in or written out as required. For contiguous page reads/writes, this 64KB buffer can stay in RAM. Only when a 64KB boundary is reached, does an actual IC read/write have to take place.

Luckily, your MCU has enough RAM, provided you are not already using it for something else.

The logic in Read_Memory() and Write_Memory() needs to be changed to map 'Memory_Offset' onto 64KB chunks.

Although the flash IC allows you to write a page at a time (256 bytes), 'ssp_flash_driver.c' has a function that lets you write any number of bytes you want (including 64KB!). It's called 'SSP_FLASH_BufferWrite()'. This function will need to be modified slightly though, I think. It has a local variable called 'u8 NumofPage' which allows it operate over 256 pages. It might be safer to increase this to 'u16'?

So, as you can see, there is a bit of work needed to change the RAM-based example of UM0290 to work.

Regards,

Nick