Wednesday, November 28, 2007

Re: [piclist] Writing to PIC16F626 EEPROM

If you're waiting for the write to complete (loop at SRE1) then you don't need interupts.
 
dB
 
----- Original Message -----
From: Sasha
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

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

Odd News

You won't believe

it, but it's true

Yahoo! Finance

It's Now Personal

Guides, news,

advice & more.

Moderator Central

Yahoo! Groups

Join and receive

produce updates.

.

__,_._,___

No comments: