i test the results by reading the code space using my programmer software. i don't see any $1234 in memory.
-=drew
i test the results by reading the code space using my programmer software. i don't see any $1234 in memory.
-=drew
here's the code now with two LEDs. portb.0 flashes on startup and portb.1 flashes after attempted write operations.
**************
'use the following when using the MP assembler
'@ DEVICE PIC16F819, hs_osc, wdt_off, pwrt_on, mclr_on, bod_off, cpd_off, protect_off, lvp_off, WRT_3FOURTHS
'use the following when using the MPASM assembler
@ __CONFIG _HS_OSC & _WDT_ON & _CP_OFF & _CPD_OFF & _WRT_ENABLE_512 & _PWRTE_OFF & _MCLR_ON & _BODEN_OFF _LVP_OFF
DEFINE OSC 10
clear
I var byte ' Loop count
D var word ' Data
A var word ' Address
A=$04F0
d=$1234
TRISB=0 'set portb pins to all output
PORTB=0 'turn off all portb pins
portb=0
for i=0 to 3
toggle portb.0
pause 200
next i
erasecode A
For I = 0 TO 63 STEP 2
Writecode A + I, D
Next I
portb=0
for i=0 to 3
toggle portb.1
pause 200
next i
stop
end
*******************
if i read the code space after the portb.1 LED blinks i get the same results as before.
The 819 erases Flash in blocks of 32 WORDS.
Those blocks are restricted to physical boundaries, not just 32 words from where you said to erase.
With $04F0, the beginning of the block it will erase is at $04E0.
Make the lowest 5-bits 0 to find the beginning.
Then when writing, you have to write in blocks of 4 WORDS. These blocks also have physical boundaries.
After erasing from $4E0, the first write block is from $4E0 to $4E3.
Anything written to those locations will be transferred to flash memory only AFTER the 4th location is written too.
But your FOR loop is only writing every other word, so it would write to the 1st and 3rd locations, and the data will never be transferred to Flash.
Plus the loop should only go to 31 instead of 63. You're writing WORD's not BYTE's.
DT
success!
i don't have to use the ERASECODE command in order for this to work (on this PIC).
now for the one piece of information that will allow me to fish for myself: where are the pieces of information about block size, the number of bytes/words to write before they are actually written, and if a block first needs to be erased located in a typical datasheet?
thanks for the assistance! i appreciate your work, Darrel. i'm currently trying to get USART interrupts working using your instant interrupts system. just need to figure out how to grab the byte from the buffer so i can store it. the SPWM code you offer works great!
thanks again!
-=drew
Not the first time, because you'll be writing to areas that were erased when it was programmed.
If you ever want to write over then same locations again, then you have to erase it first.
Section 3.6 in the 819's datasheet.now for the one piece of information that will allow me to fish for myself: where are the pieces of information about block size, the number of bytes/words to write before they are actually written, and if a block first needs to be erased located in a typical datasheet?
Take a look at this ...i'm currently trying to get USART interrupts working using your instant interrupts system. just need to figure out how to grab the byte from the buffer so i can store it.
http://www.picbasic.co.uk/forum/show...?p=28336#28336
<br>
DT
Bookmarks