Truncated match.
PICList
Thread
'problems writing to EEPROM data area 16C84'
1997\11\02@060046
by
erik
|
|
1997\11\02@164628 by Mike Keitz
|
|
1997\11\02@200942 by Felix Centeno
|
|
This procedure is taken from the PIC16/17 Microcontroller
Data Book:
BSF STATUS, RP0 ; BANK 1
BCF INTCON, GIE ; DISABLE INTS
BCF EECON1, WREN ;ENABLE WRITE
MOVLW 055H ; ---
MOVWF EECON2 ; l
MOVLW 0AAH ; l -- this is obligatorie
MOVWF EECON2 ;WRITE AAH l
BSF EECON1,WR ;SET WR BIT l
; BEGIN WRITE --
BSF INTCON, GIE ; ENABLE INTS
----------
> From: erik <erik@DIGITS.DEMON.CO.UK>
> To: PICLIST@MITVMA.MIT.EDU
> Subject: problems writing to EEPROM data area 16C84
> Date: Domingo 2 de Noviembre de 1997 06:41 AM
>
> Hi,
>
> I'm not having any luck with my attempts to write to the EEPROM data area
> of my 16C84. Can anyone suggest where I'm going wrong...please.
>
> I'm using the MPASM assembler and I get the following error message
> when I try and use the Option, and EECON registers (repeats for every mention
> of these registers)
>
> Warning EEDATA.ASM 77 : Argument out of range: EECON1 (0088).
> Least significant bits used.
> Warning EEDATA.ASM 79 : Argument out of range: EECON2 (0089).
> Least significant bits used.
> Warning EEDATA.ASM 266 : Argument out of range: OPTION (0081).
> Least significant bits used.
>
>
> Heres the relevant section of my code:
>
> ; Target Chip PIC16C84
> ; DATE 27/10/1997
> ; ITERATION 1..0
> ; FILE SAVED AS eedata.asm
> ; CLOCK Xtal 32.768KHz (4x30.5uS = 120uS cycle)
> ; DESCRIPTION expt with data EEPROM
> ;****************************************************************
> List P=16C84
>
> INTCON EQU 00BH
> GIE EQU 7 ;part of intcon regr Global Interrupt Enable
> EEIE EQU 6 ;part of intcon regr
> TOIE EQU 5 ;part of intcon regr Timer0 Int Enable
> INTE EQU 4 ;part of intcon regr
> RBIE EQU 3 ;part of intcon regr
> TOIF EQU 2 ;part of intcon regr Timer0 Flag
> INTF EQU 1 ;part of intcon regr
> RBIF EQU 0 ;part of intcon regr
> STATUS EQU 003H
> RP0 EQU 5 ;part of status regr Register bank select bit
> OPTION EQU 081H
> TEMP EQU 010H ;storing a counter here
> W EQU 0 ; pointer TO W REGISTER
> tempa EQU 011H
> EECON1 EQU 088H
> EEIF EQU 004H ;4 bit of EECON1
> WRERR EQU 003H ;3 bit of EECON1
> WREN EQU 002H ;2 bit of EECON1
> WR EQU 001H ;1 bit of EECON1
> RD EQU 000H ;0 bit of EECON1
> EECON2 EQU 089H
> EEDATA EQU 008H
> EEADR EQU 009H
>
>
> ; origin vector
> ORG 00H
> GOTO INIT
> ;****** interrupt vector ****************************
> ORG 04H
> GOTO LOOP
>
> ; subroutine declarations
>
> ; write to EEPROM data section, enter with addr to write to in EEADR
> ; and data to be written in EEDATA. Interrupts must be disabled
> ; before writing
> EEWR
> BCF INTCON,GIE ;ensure interrupts disabled
> BSF STATUS,RP0 ;bank 1
> BSF EECON1,WREN ;enable a write
> MOVLW 055H ;required sequence
> MOVWF EECON2 ;required sequence
> MOVLW 0AAH ;required sequence
> MOVWF EECON2 ;required sequence
> BSF EECON1,WR ;required sequence, begin write
> WAYT NOP
> BTFSC EECON1,WR ;see if write is finished
> GOTO WAYT ;wait until it is
> BCF STATUS,RP0 ;bank0
> RETURN
>
> ; read data from EEPROM data section, enter with addr to read in EEADR
> ; exit with data that has been read in EEDATA
> EERD
> BSF STATUS,RP0 ;bank 1
> BSF EECON1,RD
> HOLT BTFSC EECON1,RD
> GOTO HOLT ;wait for read to complete
> BCF STATUS,RP0 ;bank0
> RETURN
>
> ; ********** main program starts here ******************************
> INIT
> CLRW
> MOVWF TEMP
> MOVWF EEDATA
> MOVWF EEADR
>
> BSF STATUS,RP0 ;5 bank 1
> BCF OPTION,TOCS ;5
> BCF OPTION,PSA ;3 assign prescaler to timer
> BCF OPTION,PS2 ;2
> BCF OPTION,PS1 ;1
> BCF OPTION,PS0 ;0
> BCF STATUS,RP0 ;5 bank 0 again
>
> BCF INTCON,TOIE ;5 1=enable
> BCF INTCON,EEIE ;6 0=disable
> BCF INTCON,INTE ;4 0=disable
> BCF INTCON,RBIE ;3 0=disable
> BCF INTCON,GIE ;7 1=enable unmasked interrupts
>
> LOOP
> INCF TEMP
> ; write, then read something to/from EEPROM data section
> movfw TEMP
> movwf EEDATA ;write data thats same as value in TEMP
> ANDLW 03FH ;0011 1111 clear top bits
> movwf EEADR
> call EEWR ;to addr thats same as value in TEMP
>
> clrf EEDATA ;clear it to see if its really read
>
> call EERD ;read into EEDATA
>
>
> ; display the results here...
>
> GOTO LOOP
>
> ; reset vector
> ORG 01FFH
> GOTO INIT
> END
> ; *************************************************************
>
> Really grateful for any suggestions.
>
> Cheers
> --
> erik
More... (looser matching)
- Last day of these posts
- In 1997
, 1998 only
- Today
- New search...