• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Internal EEPROM of PIC

Status
Not open for further replies.

Wond3rboy

Member
Hi, can anyone tell me how do we write to the internal eeprom of a PIC microcontroller.For external we use TABLWT but what about the internal EEPROM.


Also is it possible to program an 18LF4620 with a Junebug(with out the mods of 3.3v devices).

Thanks.
 

Pommie

Well-Known Member
Most Helpful Member
People are replying less but this is because posters are asking questions with very little information. You ask how to write to EEPROM but don't state which pic or which language. If you want to know in asm then there is normally example code in the data sheet. If you want to know in C then try google. You appear to be very lazy and quick to criticize when people don't help. Posters that post an attempt to write the code tend to get more help. Posters that winge get no help whatsoever.

Try writing the code yourself. If it doesn't work then post it here and we will tell you why it doesn't.

Mike.
 

blueroomelectronics

Well-Known Member
Section 6 of the 18F1320 datasheet has everything you need to know.
EXAMPLE 6-2: ERASING A FLASH PROGRAM MEMORY ROW
Code:
MOVLW CODE_ADDR_UPPER ; load TBLPTR with the base
MOVWF TBLPTRU ; address of the memory block
MOVLW CODE_ADDR_HIGH
MOVWF TBLPTRH
MOVLW CODE_ADDR_LOW
MOVWF TBLPTRL
ERASE_ROW
BSF EECON1, EEPGD ; point to FLASH program memory
BSF EECON1, WREN ; enable write to memory
BSF EECON1, FREE ; enable Row Erase operation
BCF INTCON, GIE ; disable interrupts
MOVLW 55h
MOVWF EECON2 ; write 55H
Required MOVLW AAh
Sequence MOVWF EECON2 ; write AAH
BSF EECON1, WR ; start erase (CPU stall)
NOP
BSF INTCON, GIE ; re-enable interrupts
 

bryan

Member
Hi, can anyone tell me how do we write to the internal eeprom of a PIC microcontroller.For external we use TABLWT but what about the internal EEPROM.

Here is what I use to read/write to the EEPROM for a 18f. Not my work but courtesy of Richard.c


Code:
; ***************************************************************************
; Read EEPROM Address 0x00 and copy to counter variable
; ***************************************************************************
 
ReadEE
 movlw 0x00                ; Address in EEPROM
 movwf EEADR             ; Data Memory Address to read
 bcf  EECON1, EEPGD     ; Point to DATA memory
 bcf  EECON1, CFGS      ; Access EEPROM
 bsf  EECON1, RD          ; EEPROM Read
 movff EEDATA, counter ; EEDATA --> Counter
 retlw 0x00
 
 
; ***************************************************************************
; Write value of variable counter into EEPROM address 0x00
 ***************************************************************************
 
WriteEE      
  movlw 0x00           ; Address 
  movwf EEADR        ; Data Memory Address to write
  movf counter,W;
  movwf EEDATA           ; Data Memory Value to write
  bcf  EECON1, EEPGD    ; Point to DATA memory
  bcf  EECON1, CFGS     ; Access EEPROM
  bsf  EECON1, WREN     ; Enable writes
  bcf  INTCON, GIE        ; Disable Interrupts
  movlw 55h ;
  movwf EECON2            ; Write 55h
  movlw 0AAh 
  movwf EECON2           ; Write 0AAh
  bsf  EECON1, WR        ; Set WR bit to begin write
  bsf  INTCON, GIE        ; Enable Interrupts
Eeloop btfss PIR2,EEIF  ; Is int bit on ie WRTDONE
  bra  Eeloop              ; continue
  bcf  PIR2,EEIF          ; reset interupt
  bcf  EECON1, WREN  ; Disable writes on write complete (EEIF set)
 
Status
Not open for further replies.

EE World Online Articles

Loading
Top