This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Flash_Program error

Hi All,

I've got boot from SPI EEPROM working - yay. 

Our application is a group of distributed sensors, on an RS485 bus, talking Modbus.  The main app resides in Flash, and we want to be able field reprogram these units via modbus, so we're using a modbus capable reprogrammer that gets loaded from SPI EEPROM on boot, with the appropriate SPI boot mode selected.

I've written the reprogrammer, and can reprogram the EEPROM as well as the Flash.  The EEPROM repprogramming works fine.  I can reprogram the reprogrammer insitue ;-)

 

The Flash programming is where I've come unstuck. I've followed the Flash_API Example code as much as possible, but come up against a wierdness.  Say I want to program 64x 16 bit words from the bottom of Flash, address 0x3D8000.  Modbus packets I use send 32x 16 bit words at a time, so the first write triggers an erase of the sector, which is successful, then writes the first 32 words, which is also successful.  The next write fails on the first word, because it is (for some strange reason) not 0xFFFF.

I have tried writing just one block of 32 words, then reading back two blocks of 32 words.  Always, the first word of the second block is corrupted (not erase).

Programming with the ICE with verify is successful.

I've written debug code to spew out the flash addr, buffer length, and error info from the failed Flash_Program() function call.  It is always returning error code 0x1F, failed address is 0x3D8020, expected 0x000C, actual 0x7FDB.

Does anyone have a clue what I'm doing wrong?

 

Regards,

James.