uint8_t erase_flash (void), exit with a timeout, but the program still manages to program the chip.
The erase_flash return status is ignored, thus the error is 'not visible.
I changed the function to log the error on the serial terminal. I always get timeout 2, even if the timeout is 1 sec.
/** ---------------------------------------------------------------------------
-
@brief erase_flash
-
@return uint8_t
*/
uint8_t erase_flash (void)
{
gprintf ("\r\n Erasing flash.. please wait ..");
write_register(0x4001e504, 2);
long timeout = millis();
while (read_register(0x4001e400) != 1)
{
if (millis()-timeout > TIMEOUT)
{
gprintf ( "\r\n Erasing timeout 1 ..");
return 1;
}
}
write_register(0x4001e50c, 1);
timeout = millis();
while (read_register(0x4001e400) != 1)
{
if(millis()-timeout > TIMEOUT)
{
gprintf ( "\r\n Erasing timeout 2...");
return 1;
}
}
write_register(0x4001e504, 0);
timeout = millis();
while (read_register(0x4001e400) != 1)
{
if(millis()-timeout > TIMEOUT)
{
gprintf ("\r\n Erasing timeout 3...");
return 1;
}
}
gprintf ( "\r\n Erasing done ..");
return 0;
}
uint8_t erase_flash (void), exit with a timeout, but the program still manages to program the chip.
The erase_flash return status is ignored, thus the error is 'not
visible.I changed the function to log the error on the serial terminal. I always get timeout 2, even if the timeout is 1 sec.
/** ---------------------------------------------------------------------------
@brief erase_flash
@return uint8_t
*/
uint8_t erase_flash (void)
{
gprintf ("\r\n Erasing flash.. please wait ..");
write_register(0x4001e504, 2);
long timeout = millis();
while (read_register(0x4001e400) != 1)
{
if (millis()-timeout > TIMEOUT)
{
gprintf ( "\r\n Erasing timeout 1 ..");
return 1;
}
}
write_register(0x4001e50c, 1);
timeout = millis();
while (read_register(0x4001e400) != 1)
{
if(millis()-timeout > TIMEOUT)
{
gprintf ( "\r\n Erasing timeout 2...");
return 1;
}
}
write_register(0x4001e504, 0);
timeout = millis();
while (read_register(0x4001e400) != 1)
{
if(millis()-timeout > TIMEOUT)
{
gprintf ("\r\n Erasing timeout 3...");
return 1;
}
}
gprintf ( "\r\n Erasing done ..");
return 0;
}