2009-02-20 08:28 PM
Error in flash.c ?
2011-05-17 04:03 AM
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 ]2011-05-17 04:03 AM
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 ]2011-05-17 04:03 AM
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