Ravi
Ravi

Reputation: 29

Writing .hex file to Internal FlashROM of 8051 microcontroller using SPI bus

I am doing a firmware upgrade using SPI bus on EEPROM as well as Internal ROM of 8051, basically writing a .hex file on both these memory devices.I am able to see .hex file written there.I am able to see slave and master are communicating properly, but not able to write anything on my memory devices.

If you have suggestions and if you have faced similar problems, please let me know where is the actual problem.

Any inputs would be welcomed.

Regards, Ravi

Upvotes: 0

Views: 1395

Answers (1)

Sam Cristall
Sam Cristall

Reputation: 4387

I think more information will likely be required. In any case, here a few pitfalls I could see:

  • Hex Files are not necessarily memory images. The 8051s I've worked with usually use Intel Hex which is an ASCII format that describes the memory. The format is well documented here.

  • If you're having trouble writing to the EEPROM, you may not be writing the proper instructions. Typically, SPI EEPROM will be Byte addressed, but still has paging internally. You should start your writes on a Page boundary and write the whole page, then issue another write command, etc. By convention if you overrun a page, or start in the middle of a page it will loop around. So if your page is 8 bytes long, and you start writing 0-7 starting at index 4, you'll get:

    Page Start: Index 0 = 4
                Index 1 = 5
                Index 2 = 6
                Index 3 = 7
                Index 4 = 0
                Index 5 = 1
                Index 6 = 2
                Index 7 = 3
    
    • Most EEPROMs have locking mechanisms to prevent accidental writes once they are finalized. If the lock has been set, you will need to write an unlocking method (this will be detailed in the data sheet if it has it)

To further help you, please reference part numbers and better yet Data Sheets if you can.

Upvotes: 1

Related Questions