Is it possible to flash EEPROM only?
Is it possible to flash EEPROM memory only?
"stcgal" command is designed to have CODE and EEPROM file as parameters at command line, CODE file is the first parameter. I would like to have posibility to flash EEPROM data only.
BTW, I tried to flash STC15W201S with this tool and it worked.
I think that isn't possible (by design of STC's boot loader protocol), but I have to check.
any update on this
Read and write EEPROM only
You have to write your code and that should be part of your application in STC. stcgal or STC-ISP cannot read CODE or EEPROM and they cannot write only EEPROM part. Some explanation why EEPROM has to be written after CODE could be found in #58.
Other important detail is that "EEPROM" on STC51 MCUs has to be erased before data can be changed; check #59 for details. Page size of EEPROM is 512 bytes, that is a lot of data because many MCU have only 128, 256 or 512 bytes of SRAM, so you cannot temporary copy data from EEPROM page to RAM. EEPROM on other MCUs (like AVR) or serial EEPROM, like 24C02 or 93L56, can change one byte after other, there is no need to erase page before data can be modified. From my point of view, EEPROM on STC51 is more FLASH than true EEPROM... It is possible that data can be modified in the way, that bits with value 1 can be cleared to 0 and the only way to change bit from 0 to 1 is to erase the whole page. I have not verified this...
UPDATE: I verified it on STC15F104W and it is not so easy. Only the first write to EEPROM guarantees that value stored is the same as value written. When I start with EEPROM cell with value 0xff and write to that cell values from 255 to 0 (decrement by 1), I end with result 0x28; I expected to get 0x00 but I read 0x28. I cannot explain it. My guess is that there is some correction system in the background and each cell of EEPROM has more than just 8 bits. In detail, this is a history of EEPROM cell, this is a black magic:
FF, write FE, result is FE
FE, write FD, result is FC
FC, write FB, result is F8
F8, write EF, result is E8
E8, write BF, result is A8
A8, write 7F, result is 28
Other test, write numbers from 0 to 255, increment by 1. Result is 0x28!
FF, write 00, result is 00
00, write 08, result is 08
08, write 20, result is 28
Other test, I write 0x28 first and than I can write whatever I want, I cannot change that value:
FF, write 28, result is 28