Skip to main content
bnp979
Associate III
August 12, 2017
Question

Using internal flash for data storage with STM32L151VC

  • August 12, 2017
  • 2 replies
  • 748 views
Posted on August 12, 2017 at 20:03

Hi

We are using the L151VC part (with 256 KB flash consisting of one bank) for a sensor logger applications. We roughly log 32 bytes of data at 50 Hz. We have partitioned the flash into 96 KB of code and rest 160KB for data.

I have a couple of questions:

1) write throughput: we ran an experiment to write to 160 KB of flash using the following operation: unlock , 4-bytes write, lock 

Based on this experiment it is taking 197 sec, representing 4.8 ms/4 bytes write. Is this expected? 

Using this result, I can estimate 30 ms for writing 32 bytes, which is much higher than what I was expecting.

2) bus stall: the documentation says during write to flash, code fetches cannot be performed (since we execute out of flash and read from flash during write to the same block leads to bus stall. This means that for each 50 ms duration, the processor execution is stalled for 30ms. Did I get this right?

thanks

ben

    This topic has been closed for replies.

    2 replies

    Tesla DeLorean
    Guru
    August 12, 2017
    Posted on August 12, 2017 at 21:38

    Shouldn't have to lock/unlock for every word, shouldn't have to toggle PG either.

    The flash is not fast, degrades with age, timings should be in data sheet.

    Processor cannot read (execute) and write/erase flash at same time, basically stuffs wait states at the processor (stalls). Run code/interrupts from RAM

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    bnp979
    bnp979Author
    Associate III
    August 13, 2017
    Posted on August 13, 2017 at 19:12

    Thanks. I noticed that half word, double word, half page all have same write latency (3.5ms). I think buffering data and writing in batches of half page (128 bytes) would be the way forward for us. 

    Also guatanteed write cycles is 10k which is plenty for us.

    thanks