Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
void WriteEeprom( unsigned int badd,unsigned char bdata )
{
EEADR = (badd & 0x0ff);
EEDATA = bdata;
EECON1bits.EEPGD = 0;
EECON1bits.CFGS = 0;
EECON1bits.WREN = 1;
INTCONbits.GIE = 0;
EECON2 = 0x55;
EECON2 = 0xAA;
EECON1bits.WR = 1;
while(EECON1bits.WR);
INTCONbits.GIE = 1;
EECON1bits.WREN = 0;
}
How is your knowledge of C coming along!! If you ever need anything translated!!!Almost everything for those modules (eBay, ugh) is in C and most of that is for the Arduino.
If I write
loop : goto loop
It's the same as
goto $-1
Unless I'm missing something
Thanks, John. I've done little PIC programming and never used the $ designator. It shows!Thus, "$" is the PC for the current instruction, and "$-1" counts back to the just previous instruction.
Write_EEPROM_Addr_w ;load w with address, load EEWriteData with data, then call here
TryDisableInts
bcf INTCON,GIE ;disable ints
btfsc INTCON,GIE
goto TryDisableInts
bsf STATUS,5 ;bank 1 (all EEPROM regs are in bank 1)
movwf EEADR ;set addr
clrf EEADRH ;set high addr to 0 (16F688)
movf EEWriteData,w ;get data (shared memory)
movwf EEDATA ;place data
bcf EECON1,EEPGD ;enable EEPROM writes
bsf EECON1,WREN ;enable eeprom writes (rem for testing and unrem when ready)
movlw 0x55 ;start of required sequence
movwf EECON2
movlw 0xAA
movwf EECON2
bsf EECON1,WR ;start of write, end of sequence
WaitForEEPROMWriteComplete
btfsc EECON1,WR
goto WaitForEEPROMWriteComplete
bcf EECON1,WREN ;disable any more EEPROM writes
bcf STATUS,5 ;back to bank 0 before return
;bsf INTCON,GIE ;enable ints
return