Dear TI,
I need to store a byte in data flash. Since the byte can be modified on runtime the first step is erasing the data flash. As the manual says, it should be easy:
- write key to FLASHILOCK register,
- set page to be erased in DFLASHCTRL register,
- wait until BUSY flag in the same register deasserts.
I have also found this thread:
https://e2e.ti.com/support/power_management/digital_power/f/184/t/469002
about using the RONLY bit, and I've copied the line to remove the read-only protection.
However, this doesn't work for me.
I have written this code:
static void erase_dflash(void)
{
const union DFLASHCTRL_REG dctrl = {.bit.PAGE_SEL = 0, .bit.PAGE_ERASE = 1};
send_str("zz\n");
while( DecRegs.DFLASHCTRL.bit.BUSY );
send_str("uu\n");
DecRegs.MFBALR2.all = 0x8820;
send_str("vv\n");
DecRegs.FLASHILOCK.all = DATA_FLASH_INTERLOCK_KEY;
send_str("yy\n");
DecRegs.DFLASHCTRL.all = dctrl.all;
send_str("xx\n");
while( DecRegs.DFLASHCTRL.bit.BUSY );
send_str("ww\n");
}
'send_str' is a function which sends a string over UART and it's working fine.
After calling this function I can see "zz" and "uu" printed in the terminal, but nothing more, and without a reset the device cannot be accesed by the PMBUS probe (HPA172). So this looks like the device was hanging on the write to MFBALR2. I've tried to swap the order of writes to MFBALR2 and FLASHILOCK, with the same result.
Can you, please, help me with that? Is there something that the documentation doesn't mention? Maybe there is a working piece of code that I could use for that?
EDIT:
I have realized that there are ready "software interrupt" routines for this purpose, but these don't work for me either.
The code snippet is now:
send_str("\nnew addr\n");
erase_data_flash_segment(0);
send_str("\nerased\n");
write_data_flash_word(DFLASH_START_ADDRESS, dfs.addr);
send_str("\nall done\n");
dfs.addr is uint8_t.
I can see only "new addr" and "erased" displayed, the write operation causes a reset (I can find the device in ROM mode and make it run the program again). I did try to replace in the routine bitwise assignment to MFBALR2 with assignment to "all", as suggested in the post cited.
Best regards,
Adam