??? 06/14/12 18:13 Read: times |
#187705 - C code sample from Silab website Responding to: ???'s previous message |
Hi Rob,
Thanks for your comments. Below is the C code example to write to flash from firmware that Silabs suggests. I have converted the C code below to assembly and it also causes the micro to reset. Silabs seems to contradict itself in a number of places when looking at the C8051F504 datasheet their Application Notes (AN201) and code examples. I'm going to try some other things such as lowering the system clock frequency when writing to flash. I'm trying to make a bootloader to update the main code via the serial port because I can't use the C2 lines (too long a cable for C2 to work). Cheers, Bert void FLASH_ByteWrite (FLADDR addr, char byte) { bit EA_SAVE = EA; // Preserve EA char xdata * data pwrite; // FLASH write pointer EA = 0; // Disable interrupts VDM0CN = 0xA0; // Enable VDD monitor and high threshold RSTSRC = 0x02; // Enable VDD monitor as a reset source pwrite = (char xdata *) addr; FLKEY = 0xA5; // Key Sequence 1 FLKEY = 0xF1; // Key Sequence 2 PSCTL |= 0x01; // PSWE = 1 which enables writes VDM0CN = 0xA0; // Enable VDD monitor and high threshold RSTSRC = 0x02; // Enable VDD monitor as a reset source *pwrite = byte; // Write the byte PSCTL &= ~0x01; // PSWE = 0 which disable writes EA = EA_SAVE; // Restore interrupts } |
Topic | Author | Date |
Problem writing to C8051F504 flash from firmware | 01/01/70 00:00 | |
Some comments | 01/01/70 00:00 | |
C code sample from Silab website | 01/01/70 00:00 | |
the dog bites | 01/01/70 00:00 | |
Responding to Bert's and Rob's prior messages | 01/01/70 00:00 | |
Wow | 01/01/70 00:00 | |
Wow to you! | 01/01/70 00:00 | |
Problem solved | 01/01/70 00:00 |