??? 03/01/07 10:10 Read: times Msg Score: +1 +1 Informative |
#134008 - "hung up"? Responding to: ???'s previous message |
What exactly do you mean by that?
Possible causes/things to check: - Watchdog reset? (erasing a Flash page takes a while) - VDD Monitor enabled? - Using the correct Flash page? (what value does "CONST1" have?) Below is a working piece of code written for the F310, which is almost identical to the F330. It erases the page (starting at 0x3A00) containing a table of parameters, then copies the new values from a table in RAM. Save_Parameters: CLR EA ; Temporarily disable all interrupts MOV PSCTL, #003H ; Set PSEE and PSWE. FLASH can now be erased MOV FLKEY, #0A5H MOV FLKEY, #0F1H ; Flash unlock sequence MOV DPTR, #3A00H ; Set the DPTR to the start of the non-volatile parameter table MOVX @DPTR, A ; Perform a memory write; this will erase the page MOV PSCTL, #001H ; Clear PSEE. FLASH can now be written MOV R0, #Parameters ; Use R0 as readpointer to the working parameter table MOV R6, #15 ; The table is 14 bytes long Write_loop: MOV FLKEY, #0A5H MOV FLKEY, #0F1H ; Flash unlock sequence MOV A,@R0 ; Get a byte from the table MOVX @DPTR,A ; Write it to FLASH INC R0 ; Increment the readpointer INC DPTR ; Increment the writepointer DJNZ R6, Write_loop ; Repeat for all bytes in the table MOV PSCTL,#000H ; Clear PSWE. FLASH can now only be read SETB EA ; Re-enable interrupts RET Rob. |
Topic | Author | Date |
Writing to flash from firmware | 01/01/70 00:00 | |
pretty sure the problem is in the erase section... | 01/01/70 00:00 | |
that's another thing ... | 01/01/70 00:00 | |
this is the case when the comment IS harmful.. :-) | 01/01/70 00:00 | |
need some sleep? | 01/01/70 00:00 | |
haha, yes | 01/01/70 00:00 | |
Key sequence | 01/01/70 00:00 | |
Thanks rob | 01/01/70 00:00 | |
"hung up"? | 01/01/70 00:00 | |
14 bytes or 15? | 01/01/70 00:00 | |
Another case where the comment is harmful :-( | 01/01/70 00:00 | |
More suggestions | 01/01/70 00:00 | |
random thought | 01/01/70 00:00 | |
RE: random thought | 01/01/70 00:00 | |
What I mean by hung up | 01/01/70 00:00 | |
since I do not use this deviate | 01/01/70 00:00 | |
the vdd monitor? | 01/01/70 00:00 | |
how you determine? | 01/01/70 00:00 | |
In response to Oleg's question | 01/01/70 00:00 | |
seen this app note? | 01/01/70 00:00 | |
problem solved... | 01/01/70 00:00 | |
are you using LARGE? | 01/01/70 00:00 | |
no large or xdata var![]() | 01/01/70 00:00 |