Wednesday, November 14, 2007

[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.

__._,_.___
to unsubscribe, go to http://www.yahoogroups.com and follow the instructions
Recent Activity
Visit Your Group
Yahoo! News

Fashion News

What's the word on

fashion and style?

Yahoo! Finance

It's Now Personal

Guides, news,

advice & more.

Curves on Yahoo!

Share & discuss

Curves, fitness

and weight loss.

.

__,_._,___

No comments: