Quote Originally Posted by ultiblade View Post
Is there anyway i can make this work Darrel or Skimask ?
I think so.

Been looking through the 12F library, and it looks like the READ and WRITE commands still do the right thing. But there's no way (in PBP) to erase a block before writing.

This might work. It's a macro that will erase 1 block at a time using a Constant for the address.

To erase the first block (bytes 0-7), you can ...
@ EraseFlash 0

To erase the second block
@ EraseFlash 8

Put it right before the WRITE command.

And put this macro somewhere near the top of the program.
Code:
ASM
EraseFlash  macro Addr
  local EraseLoop
    MOVE?CB  (Addr & 0x38), EEADR
    BSF      EECON,FREE          ; SELECT ERASE
    BSF      EECON,WREN          ; ENABLE WRITES
    BSF      EECON,WR            ; INITITATE ERASE
EraseLoop 
    btfsc    EECON, WR           ; Wait for the erase to complete
    goto     EraseLoop
  endm
ENDASM