Thank you BlueStax.
I was able to write the the first two bytes but instead of
writing '01' in both locations, only 'DF' was written there
as seen
using MPLAB. Please indicate the code to use to actually enable
writing '01' in EEPROM address 0x00 and 0x01.
Thanks.
Shaaks.
--- In p..., "BlueStax" wrote:
>
> If you're waiting for the write to complete (loop at SRE1) then
you don't need interupts.
>
> dB
>
> ----- Original Message -----
> From: Sasha
> To: p...
> Sent: Wednesday, November 14, 2007 9:13 PM
> Subject: [piclist] Writing to PIC16F626 EEPROM
> Dears,
> I need help on a code to write to the PIC16F628 EEPROM.
> I should write decimal '11' in the first two bytes of the EEPROM
> address.
> I have tried a sample code but I need confirmation of the
Interrupt
> controls EEIF and EEIE have and where to put them;
main program
or
> in the Interrupt Service Routine program.
>
> BSF STATUS,RP0 ;select bank1
> MOVLW 0x00 ;EEPROM address
> MOVWF EEADR
> MOVF 0x01,w ;EEPROM Data
> MOVWF EEDATA
>
> BSF EECON1,wren ;enable write
> BCF INTCON, GIE ;Disable interrupts
>
> MOVLW 0x55 ;unlock codes sequence
> MOVWF EECON2
> MOVLW 0xaa
> MOVWF EECON2
>
> BSF EECON1,WR ;write begins
>
> SRE1: BTFSC EECON1,WR ;wait for "write" to complete
> GOTO SRE1
> BCF EECON1,wren ;disable other writes
> BSF INTCON, GIE ;Enable interrupts
> ;BSF PIE1, EEIE ;Set interrupt flag in PIE1
> ;BCF PIR1, EEIF ;Clear Interrupt flag in PIR1
>
> Thanks all.
> Shaaks.
>
>
> -------------------------------
-----------
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.5.503 / Virus Database: 269.16.9/1155 - Release Date:
27/11/2007 20:30
>