Hello,
Hello
I took screenshots from a logic analyzer of the following code
delay(100);
Serial.println(GD.rd(REG_FLASH_STATUS));
GD.cmd_flashdetach();
Serial.println(GD.rd(REG_FLASH_STATUS));
In the attachments, GD.rd(REG_FLASH_STATUS).JPG shows the logic when I send Serial.println(GD.rd(REG_FLASH_STATUS));
and GD.cmd_flashdetach().JPG shows the logic when I send GD.cmd_flashdetach() and Serial.println(GD.rd(REG_FLASH_STATUS)) after that.
I noticed there is some random logic after I send Serial.println(GD.rd(REG_FLASH_STATUS))
The logic analyzer reads B0 81 CC after reading the REG_FLASH_STATUS and I don't know why that is.
Here is the layout of my GD.rd() function
byte GDClass::rd(uint32_t addr) {
return GDTR.rd(addr);
}
byte rd(uint32_t addr)
{
__end(); // stop streaming
__start(addr);
SPI.transfer(0); // dummy
byte r = SPI.transfer(0);
stream();
return r;
}
Thanks for the screenshots, it looks as if the registers is being read correctly.
And the CMD_FLASHDETACH command does also seem to being written correctly.
The B0 81 CC is the RAM_CMD address that the CMD_FLASHDETACH command is being written to (0x3081CC, with the write bit enabled). This would indicate you have sent several other co-processor commands before issuing the CMD_FLASH command. It also appears if you are writing some display list commands into RAM_CMD immediately after reading REG_FLASH_STATUS for the second time.
Would it be possible for you to minimise the number of co-processor calls before attempting to send the CMD_FLASHDETACH command? And if possible could you implement a method similar to below to await the command FIFO executing the command before attempting to read REG_FLASH_STATUS again?
uint8_t HAL_WaitCmdFifoEmpty(void)
{
uint32_t readCmdPointer;
// Wait until the two registers match
do
{
// Read the graphics processor read pointer
readCmdPointer = HAL_MemRead32(EVE_REG_CMD_READ);
} while ((writeCmdPointer != readCmdPointer) && (readCmdPointer != 0xFFF));
if(readCmdPointer == 0xFFF)
{
// Return 0xFF if an error occurred
return 0xFF;
}
else
{
// Return 0 if pointers became equal successfully
return 0;
}
}
This should ensure the command has executed in the co-processor before you attempt to read what hopefully should be an updated register.
Also thank you Rudolph for giving that a try, his suggestion of calling CMD_FLASHSPIDESEL may also be useful in your scenario.
Best Regards,
BRT Community