Hello,
Xarion wrote:
I've recenlty had to move to a S08QE device beacuse the 8051 core I am using is becomming obsoleted. I would like update firmware over the air, I have 64KB of eeprom that i can use to temporarily store my new code.
I am not exactly sure what you wish to achieve? The expression "over the air" to me means something different than using an external SPI type EEPROM to provide new application code.
The usual method is to use a flash resident, bootloader program to communicate with the MCU via SCI module. The bootloader is capable of erasing and re-programming the application flash area, usually situated immediately below the bootloader code. There are many references to this type of bootloader within this forum. The bootloader code needs to be programmed using a Multilink Interface, or similar, or a demo board that has inbuilt programming capability.
If you wish to use an external serial EEPROM this should also be feasible. A couple of possibilities come to mind.
You might adapt the "standard" serial bootloader to directly read from the EEPROM device, rather than use the SCI. If the presence of an EEPROM could not be detected, the bootloader would initiate the application, othwise it would re-program the application code.
Another possibility might be to have the majority of the bootloader code also located on the EEPROM, and to then temporarily load this code to RAM, and run the bootloader code from there. This is what you seemed to be alluding? Of course, this method would require some flash-based, rudimentary loader code that would be the destination of the reset vector, and would also provide redirection to the application program of all the other interrupt vectors (as does the serial bootloader).
During the erase process for a flash sector, or the programming of a flash byte, flash memory becomes inaccessible. The code that executes under this circumstance needs to execute from RAM. This function (or routine) is kept to minimal size, and would normally be placed on the stack, and executed from there (i.e. doonstack), or alternatively could occupy a fixed position in RAM, maybe at the very bottom of the stack. My personal preference is the second method because it has simpler, more understandable code.
However, should the bootloader operate from RAM based code, as for the second scenario above, the flash routines would become simpler without the need to tranfer execution from flash to RAM, and you would certainly not need the complex doonstack code.
When using the SPI module as a master, as you would with SPI type EEPROM, it is quite unnecessary to use interrupts under most circumstances. The only justification would be with a very slow SPI clock rate, which would not apply for your application. The interrupt capability is more useful for a SPI slave application.
Regards,
Mac