Re: Problems reading data EEprom on Pic 16F88
From: Sergio Masci (sergio_at_NO.SPAM.xcprod.com)
Date: 11/13/04
- Previous message: Allan R. Batteiger: "Re: MPC8241 and Wiggler - any hints?"
- Next in thread: Gary Kato: "Re: Problems reading data EEprom on Pic 16F88"
- Maybe reply: Gary Kato: "Re: Problems reading data EEprom on Pic 16F88"
- Maybe reply: Gary Kato: "Re: Problems reading data EEprom on Pic 16F88"
- Maybe reply: Gary Kato: "Re: Problems reading data EEprom on Pic 16F88"
- Maybe reply: Gary Kato: "Re: Problems reading data EEprom on Pic 16F88"
- Maybe reply: Lady Chatterly: "Re: Problems reading data EEprom on Pic 16F88"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 13 Nov 2004 18:31:14 -0000
Simon <si767676@hotmail.com> wrote in message
news:6c289e8a.0411130940.75fe5ac4@posting.google.com...
> I have been trying to use the read data EEPROM feature of the 16F88,
> but can't get it to work.
>
> I have used the sample code from Microchip's data***. Attached is
> the (entire) ASM file that I am using. It should (I had hoped) store
> the value h'BB' in the register count1. Then read it from the data
> EEPROM location (h'20') and store it into the register count2.
>
> When I step through it in the simulator, the EEDATA register gets the
> value h'FF' instead of h'BB'. I can't figure this out and have spent
> many hours on it so would be very grateful if someone could help.
>
> Code follows...
>
>
> LIST N=90,ST=OFF,p=16F88
> INCLUDE P16f88.INC ;Register definitions
> errorlevel 0,-302
> __config _config1, _hs_osc & _wdt_off & _pwrte_on & _cp_off &
> _boden_off & _CCP1_RB0 & _WRT_PROTECT_OFF & _CPD_OFF & _LVP_OFF
> __config _config2, _IESO_ON & _FCMEN_ON
>
>
> cblock h'20' ;
> count1
> count2
> ADDR
> endc
>
>
> GOTO INITIALISE
> NOP
> NOP
> NOP
>
> INITIALISE
>
> banksel eedata ; Clearing these registers first to make it easier
> ; to see what's going on in Watch Window
> clrf eedata
> clrf eeadr
>
> banksel count1
> clrf count1
> clrf count2
> movlw h'BB'
> movwf count1
>
> read_eeprom ; This section of code taken from 16F88 data***
> BANKSEL EEADR ; Select Bank of EEADR
>
> ; MOVF ADDR,W ; I replaced this line with the literal value
> h'20'
> movlw h'20' ; (which is the address of count1) for the
> purposes of
> ; troubleshooting
>
> MOVWF EEADR ; Data Memory Address to read
> BANKSEL EECON1 ; Select Bank of EECON1
> BCF EECON1,EEPGD ; Point to Data memory
> BSF EECON1,RD ; EE Read
> BANKSEL EEDATA ; Select Bank of EEDATA
> MOVF EEDATA,W ; W = EEDATA
>
> ; check to see if data read successful
> banksel count2
> movwf count2 ; move the data value to count2
>
> goto $
> end
Hi Simon,
The data EEPROM is protected from accidental corruption by use of a
protocol. You need to write 0x55 and 0xAA to special function register
before writing to the EEPROM. I cannot remember the details off the top of
my head. Look at the 16f88 data ***, there are flowcharts and code samples
that show you exactly what you should be doing. Read the explanation
carefully.
Regards
Sergio Masci
http://www.xcprod.com/titan/XCSB - optimising PIC compiler
FREE for personal non-commercial use
- Previous message: Allan R. Batteiger: "Re: MPC8241 and Wiggler - any hints?"
- Next in thread: Gary Kato: "Re: Problems reading data EEprom on Pic 16F88"
- Maybe reply: Gary Kato: "Re: Problems reading data EEprom on Pic 16F88"
- Maybe reply: Gary Kato: "Re: Problems reading data EEprom on Pic 16F88"
- Maybe reply: Gary Kato: "Re: Problems reading data EEprom on Pic 16F88"
- Maybe reply: Gary Kato: "Re: Problems reading data EEprom on Pic 16F88"
- Maybe reply: Lady Chatterly: "Re: Problems reading data EEprom on Pic 16F88"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]