Continue to Site

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.

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

Accessing EEPROM in PIC16F877

Status
Not open for further replies.

hunzaboy

New Member
Hello

I have been studying and implementing EEPROM tutorials and forums from last 5 hours and no one had solved my problem.

I hope i'll fine the answer here.

PROBLEM:
The problem is " I am trying to store data and retrieve data from EEPROM of PIC16F877". But i can't find the simplest way. I have studied the DataSheet and tried the given thing many times but i haven't got the results.

Please tell me the simplest way to PUT DATA at a specific address and RETRIEVE DATA from a specific Address.

I'll be thankful to you.

Regards,
Aslam
 
From my PIC tutorials, an example:

Code:
EE_Read		bsf 	STATUS,	RP0 		; Bank 1
		movlw 	EEPROM_Addr
		movwf 	EEADR			; Address to read
		bsf 	EECON1,	RD 		; EE Read
		movf 	EEDATA,	W 		; W = EEDATA
		bcf 	STATUS,	RP0 		; Bank 0
		movwf	LED_PORT		; restore previous value
		retlw	0x00

EE_Write	movf	LED_PORT,	w	; read current value
		bsf 	STATUS,	RP0 		; Bank 1
		bsf	EECON1,	WREN 		; Enable write
		movwf	EEDATA			; set EEPROM data
		movlw	EEPROM_Addr
		movwf	EEADR			; set EEPROM address
		movlw	0x55
		movwf	EECON2 			; Write 55h
		movlw	0xAA
		movwf	EECON2 			; Write AAh
		bsf	EECON1,	WR 		; Set WR bit
						; begin write
		bcf 	STATUS,	RP0 		; Bank 0
		
		btfss	PIR1,	EEIF		; wait for write to complete.
		goto	$-1
		bcf	PIR1,	EEIF		; and clear the 'write complete' flag
		bsf 	STATUS,	RP0 		; Bank 1
		bcf	EECON1,	WREN 		; Disable write
		bcf 	STATUS,	RP0 		; Bank 0
		retlw	0x00

Basically you follow what the datasheet says.
 
Thank you for the reply!! I will run this code and update with the issues..

What Address can i use for EEPROM? As per my knowledge i can use the EMPTY MEMORY IN EACH BANK..
 
Last edited:
**broken link removed**

THE SAME PROBLEM .. the code doesn't go beyond this point
btfss PIR1, EEIF ; wait for write to complete.
goto $-1
and no changes in the EECON1 and EECON2 as shown in the attached image.

Please helpp me ..
 
I've no idea if it works in the simulator, as I never use it - but the EEPROM data memory is a specific size, and entirely separate to the rest of the memory.
 
Hi hunzaboy,
download oshonsoft pic simulator, it is a basic lang. and it takes most of the guess work out of the equation. if you like ASM you can use that 2. I have recently used the demo version to implement i2c interface from a 16f84 - 24lc256 (search the post) and with the help of eric we sorted that out in no time. I too have some ASM exp. but i prefer the basic lang. especially when you have a limited time to complete. I will def. be purchasing the oshonsoft ide.
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top