PDA

View Full Version : PIC16F677 and READ/WRITE



LinkMTech
- 26th August 2010, 02:46
Hi all,
I've been using both 16F677 and 16f685 chips as availability allowed with same program without any problems until I introduced the READ and WRITE functions on the 16F677.
I get the error: Error[113]: Symbol not previously defined (EEPGD)
The data sheet shows:

10.1.1 EECON1 AND EECON2 REGISTERS EECON1 is the control register for EE memory accesses. Control bit EEPGD (PIC16F685/PIC16F689/PIC16F690) determines if the access will be a program or data memory access.

And also when referring to EECON1.7:

Note 1: PIC16F685/PIC16F689/PIC16F690 only.

I stripped the code down to a minimum to compile with READ and WRITE commented out or not to see if it compiles without error using PICBasic Pro 2.47 and MPASM.

This is only a sample routine to demo the compilation error. I hope that someone can shed some light on this.


'************************************************* ************************
@ __config _INTRC_OSC_NOCLKOUT & _WDT_OFF & _MCLRE_OFF & _CP_ON & _BOR_OFF

OSCCON = %01001000 ' Oscillator set to 1MHz
PORTA = %00000000 ' Turn off all PORTA
ANSEL = 0 ' Sets all PORTA inputs to digital inputs
TRISA = %00011111 ' Sets all PORTA pins as inputs except RA5
PORTB = %00000000 ' Turn off all PORTB
ANSELH = 0 ' Sets analog inputs 8 ~ 11 to digital inputs
TRISB = %10000000 ' Sets RB4~6 as outputs and RB7 as input
PORTC = %00000000 ' Turn off all PORTC
TRISC = %00000000 ' Sets all PORTC pins as outputs
CM1CON0.7 = 0 ' Analog comparator #1 off
CM1CON0.5 = 0 ' Comparator #1 output disabled
CM2CON0.7 = 0 ' Analog comparator #2 off
CM2CON0.5 = 0 ' Comparator #0 output disabled
ADCON0 = 0 ' A/D OFF
OPTION_REG.7 = 1 ' Global weak pull-up enable bit enabled
WPUA = %00010111 ' Weak pull-ups enable on PORTA inputs
WPUB = %00000000 ' Weak pull-ups disabled on PORTB inputs

'================================================= ========================
' Variables
'================================================= ========================
x VAR BYTE

'================================================= ========================
' Set EEPROM default value at location 2 for 2 Modes at initial program
' then this value is user selectable via Mode button.
'================================================= ========================
EEPROM 2, [2]
PAUSE 10

'================================================= ========================
' Test loop
'================================================= ========================
x = 7
loop:
READ 2, x
PAUSE 10
' WRITE 2, x
PAUSE 10
GOTO loop

END


Thank you all for your input...

LinkMTech
- 28th August 2010, 18:41
I guess this was a tough one and don't feel so bad now. After researching and more searching it became obvious.
Even though the PIC16F677 has 256 bytes of EEPROM availble but I can't use it because it seems the compiler is trying to use EEPGD that is only used in the rest of the series... Don't use it!
The PIC16F685, 687, 689 & 690 are only around $0.25 more. Problem solved. :rolleyes:

LinkMTech
- 8th November 2010, 19:21
Well as it turns out, just avoiding the problem did not solve it.:rolleyes:
The PIC16F685 does not provide the SSP hardware I'll be needing now so more searching found Darrel's guidance (thanks again Darrel!) http://www.picbasic.co.uk/forum/showthread.php?t=12424
So comparing both INC files shows that the PIC16F677 was missing the EEPGD in the BANK 3 Register:

portion of PIC16F685 INC file:


;----- BANK 3 REGISTER DEFINITIONS ----------------------------------------
;----- EECON1 -------------------------------------------------------------

EEPGD EQU H'0007'
WRERR EQU H'0003'
WREN EQU H'0002'
WR EQU H'0001'
RD EQU H'0000'


same section of PIC16F677 INC file:


;----- BANK 3 REGISTER DEFINITIONS ----------------------------------------
;----- EECON1 -------------------------------------------------------------

WRERR EQU H'0003'
WREN EQU H'0002'
WR EQU H'0001'
RD EQU H'0000'


Updated to:



;----- BANK 3 REGISTER DEFINITIONS ----------------------------------------
;----- EECON1 -------------------------------------------------------------

EEPGD EQU H'0007' ; Added 11/8/2010
WRERR EQU H'0003'
WREN EQU H'0002'
WR EQU H'0001'
RD EQU H'0000'


Compiled without errors and I can now use the EEPROM in the PIC16F677!

A big Thank You! to all who contribute their expertise and time to help others along.

Darrel Taylor
- 8th November 2010, 23:03
Hi Louie,

I'm glad you got it working, although I'm not sure how my other post helped. :o

Would it help if I mentioned that 2.47 was the first time that family was included in PBP.
And the 677 EEPROM issue was fixed in PBP version 2.50?

OK, probably not ... :)
________________
DT
http://www.pbpgroup.com/files/SIGIMG/Upgrade.gif

LinkMTech
- 9th November 2010, 14:35
Would it help if I mentioned that 2.47 was the first time that family was included in PBP.
And the 677 EEPROM issue was fixed in PBP version 2.50?

Actually it does...
It confirms I need to stop dragging my feet and dig out my receipt for Bruce so I can update!