Skip to main content
lil-vince
Associate III
February 21, 2009
Question

Error in flash.c ?

  • February 21, 2009
  • 3 replies
  • 885 views
Posted on February 21, 2009 at 05:28

Error in flash.c ?

    This topic has been closed for replies.

    3 replies

    lil-vince
    lil-vinceAuthor
    Associate III
    May 17, 2011
    Posted on May 17, 2011 at 13:03

    Hi all,

    I think there is an error in function:

    void FLASH_ClearFlag(u16 FLASH_FLAG)

    This function clear the BSY Flag in the Flash Status Register whereas this Flag is readonly...

    And in Flash program example:

    Code:

    /* Clear All pending flags */ <BR> FLASH_ClearFlag(FLASH_FLAG_BSY | FLASH_FLAG_EOP | FLASH_FLAG_PGERR | FLASH_FLAG_WRPRTERR);

    [ This message was edited by: lil-vince on 18-02-2009 12:07 ]

    lil-vince
    lil-vinceAuthor
    Associate III
    May 17, 2011
    Posted on May 17, 2011 at 13:03

    Up :)

    I would like especially an answer about the timeout: It is necessary (is there a real risk of ''no-end'' flash operation)?

    Thanks,

    Vince

    lil-vince
    lil-vinceAuthor
    Associate III
    May 17, 2011
    Posted on May 17, 2011 at 13:03

    Hi again,

    Another thing:

    In a lot of functions like FLASH_ProgramWord there is:

    Code:

    /* Wait for last operation to be completed */ <BR><BR> status = FLASH_WaitForLastOperation(TimeoutValue); <BR><BR> <BR><BR> if(status != FLASH_BUSY) <BR><BR> { <BR><BR> /* Change a bit in the Flash control register */ <BR><BR> }

    and as this is the FLASH_WaitForLastOperation function:

    Code:

    FLASH_Status FLASH_WaitForLastOperation(u32 Timeout) <BR><BR>{ <BR><BR> FLASH_Status status = FLASH_COMPLETE; <BR><BR> <BR><BR> /* Check for the Flash Status */ <BR><BR> status = FLASH_GetStatus(); <BR><BR> <BR><BR> /* Wait for a Flash operation to complete or a TIMEOUT to occur */ <BR><BR> while((status == FLASH_BUSY) && (Timeout != 0x00)) <BR><BR> { <BR><BR> delay(); <BR><BR> status = FLASH_GetStatus(); <BR><BR> Timeout--; <BR><BR> } <BR><BR> <BR><BR> if(Timeout == 0x00 ) <BR><BR> { <BR><BR> status = FLASH_TIMEOUT; <BR><BR> } <BR><BR> <BR><BR> /* Return the operation status */ <BR><BR> return status; <BR><BR>}

    For me it´s impossible that status = FLASH_BUSY when returning from FLASH_WaitForLastOperation function (I don´t say that the busy bit can´t be set, but status can´t be equal to FLASH_BUSY)...

    Am I wrong or is it a test ''to make this beautiful''? ;)

    And after this remarks,I have 2 simple questions:

    -Can the busy bit (from the Flash status Register) be set for another reason than a programming or erasing operation? so, once it´s no more set, it can´t be set again without a programming or erasing operation?

    -Is it possible that the erase or programming operation fail?

    I ask that as there is a ''Timeout control'' in the FLASH_WaitForLastOperation function and how I write my program without ST librairies, I ask me if I will make this control or not...

    Thanks

    [ This message was edited by: lil-vince on 18-02-2009 16:24 ]

    :)

    [ This message was edited by: lil-vince on 18-02-2009 16:34 ]