Skip to main content
aalmax
Associate
January 27, 2012
Question

questions about flash programming

  • January 27, 2012
  • 3 replies
  • 920 views
Posted on January 27, 2012 at 12:23

Hi,

I have some questions about flash programming

1. how many writes to flash can i made beetwen

FLASH->CR |= CR_PG_Set;

 and

FLASH->CR &= CR_PG_Reset;

is it possible to write here more data than 2 words ? (only 2 words are written in stm32 peripherial library).Are such writes limited ?

2. Is it possible to write to flash from procedure executed from flash ? or this procedure should be executet from RAM ?

3. when page is erased and flash is busy, the main program is running or executions is stopped until flash is ready ?

thanks in advance

    This topic has been closed for replies.

    3 replies

    Tesla DeLorean
    Guru
    January 27, 2012
    Posted on January 27, 2012 at 14:31

    1) Yes, you can program the entire array. Doing it every word/half-word is inefficient.

    2) Yes, don't erase the page/area you are running from, or vectors with interrupts running. Works much better running from RAM.

    3) It stalls the CPU out with wait-states during erase/write, this can cause USART, etc, to over/underrun as you can't service them in a timely manner. Run from RAM if this is a problem.

    Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
    aalmax
    aalmaxAuthor
    Associate
    January 27, 2012
    Posted on January 27, 2012 at 16:14

    Thanks.

    Oh, shade that CPU stills during erasing of different flash page. It complicates my program very much. Runing erase procedure from RAM will not help much because UART and etc. interrupts handlers also should be in RAM, so in my project almost entire program should be executed from RAM.

    And one more question: when device have 2 flash banks (i.e. STM32F101), and program erases page from different bank, main program also stalls CPU ?

    > 3) It stalls the CPU out with wait-states during erase/write, this can cause USART, etc, to over/underrun as you can't service them in a timely manner. Run from RAM if this is a problem.

    Tesla DeLorean
    Guru
    January 27, 2012
    Posted on January 27, 2012 at 16:37

    Well most flash device do not even permit write and read/execute. So as tedious as the limitation is of the STM32, it is still better than many of the alternatives. Copying to RAM is not that problematic, but I'd would definitely break the firmware into at least two pieces, a boot loader and application.

    The CPU will stall if you try to perform a read on a bank that is busy (ie writing or erasing).

    I do not have any 1MB STM32F101 devices, but as I recall they have two separate flash controllers. I would imagine, but have not verified, that you should be able to read/execute from the other bank without delay. If you read the one that is busy it will stall.

    Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..