dustie
Newbie level 6
- Joined
- Oct 2, 2009
- Messages
- 11
- Helped
- 1
- Reputation
- 2
- Reaction score
- 1
- Trophy points
- 1,283
- Location
- Macedonia
- Activity points
- 1,354
Hi guys,
I have problem with writing to the internal EEPROM on PIC16F887.
As you can see in the code below, I am using LEDs on PORTB so I can watch where the code stucks.
So, the problem is: EECON1,WR bit doesn't set at all (and the PORTB,2 indicator LED doesn't go "1").
And I really can't figure out what causes this problem.
Please help me if you have any idea.
Below is the procedure for writing to EEPROM (as a part of a program), and the _CONFIG sentence:
I have problem with writing to the internal EEPROM on PIC16F887.
As you can see in the code below, I am using LEDs on PORTB so I can watch where the code stucks.
So, the problem is: EECON1,WR bit doesn't set at all (and the PORTB,2 indicator LED doesn't go "1").
And I really can't figure out what causes this problem.
Please help me if you have any idea.
Below is the procedure for writing to EEPROM (as a part of a program), and the _CONFIG sentence:
Code:
;----------------------------------------------------------------------------------
__CONFIG _CONFIG1, _LVP_OFF & _FCMEN_ON & _IESO_ON & _BOR_ON & _CPD_OFF & _CP_OFF & _MCLRE_ON & _PWRTE_OFF & _WDT_OFF & _HS_OSC & _DEBUG_OFF
__CONFIG _CONFIG2, _WRT_OFF & _BOR40V
;---------------------------------------------------------------------------------
; EEPROM WRITE
eeprom_write
nop
banksel EEADR
movlw 0x00
movwf EEADR
banksel EEDAT
movlw H'26'
movwf EEDAT
banksel EECON1
bcf EECON1,EEPGD
bsf EECON1,WREN
banksel INTCON
bcf INTCON,GIE
btfsc INTCON,GIE
goto $-2
banksel PORTB
bsf PORTB,0 ; Indication LED
banksel EECON2
movlw H'55'
movwf EECON2
movlw H'AA'
movwf EECON2
banksel PORTB
bsf PORTB,1 ; Indication LED
banksel EECON1
bsf EECON1,WR
btfss EECON1,WR
goto $-2
banksel PORTB
bsf PORTB,2 ; Indication LED
banksel INTCON
bsf INTCON,GIE
banksel EECON1
btfsc EECON1,WR
goto $-1
banksel PORTB
bsf PORTB,3 ; Indication LED
banksel EECON1
bcf EECON1,WREN
;
banksel STATUS
bcf STATUS,RP0
bcf STATUS,RP1
return
;---------------------------------------------------------------------------
Last edited by a moderator: