with this line of code :
for 12f675
"EPWrite(DataCount, ReadAD10(AN1))"
I get the message:
"ASM: compiled.asm:48:Error [113] Symbol not previously defined (EEADRH)."
Why?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Because no one asked the question before, or some bit of code got dropped along the way? Actually noticed this when working with the a-d.h file for the 18f4431. Forgot to follow up, so here is a work around, for fixing the 12f675 ReadAD10 function. This could be obsoleted, as I do not have the lastest zip download. Let us know if it works.
Find a-d.h file in the include/lowlevel folder. In the macro LLReadAD, find the block of code described below and insert the #IFDEF Var(ADRESH).
#IFDEF Var(ANSEL)
#IFDEF Var(ANSELH)
Dim AllANSEL As Word Alias ANSELH, ANSEL
#ENDIF
'Insert 3 lines of code for the 12f675 & ???
#IFDEF Var(ADRESH)
Dim AllANSEL As Word Alias ADRESH, ADRESL
#ENDIF
#IFDEF NoVar(ANSELH)
Dim AllANSEL As Byte Alias ANSEL
#ENDIF
ADTemp = ADReadPort + 1
Set C On
Do
Rotate AllANSEL Left
decfsz ADTemp,F
Loop
#ENDIF
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
O.K. then, more extensive problem then first thought. Here is a proof example for the 12f675, and a rehash of the eeprom.h file so byte size EEProm registers can be handled on low pin count devices follows. The most effected changes are in ProgramWrite, ProgramRead, ProgramErase subs, which caused the hangup.
'This example is a proof for sending a word size variable analog input (10k Pot) to
'a low pin count device EEProm and reading it back on leds connected to GPIO/Port pins.
' (c) Kent Schafer 2008
'Chip settings
#chip 12f675,4
#config _CP_OFF & _CPD_OFF & _BODEN_OFF & _WDT_OFF & _PWRTE_ON & _INTRC_OSC_NOCLKOUT
dir GPIO.0 in 'Analog input from 10k pot connected to VDD
dir GPIO.1 out 'Set up outputs for leds
dir GPIO.2 out
dir GPIO.4 out
dir GPIO.5 out
dim Volt as word
dim readvolt as word
' EEPROM routines for Great Cow BASIC
' Copyright (C) 2006-2007 Hugh Considine
' This library is free software; you can redistribute it and/or
' modify it under the terms of the GNU Lesser General Public
' License as published by the Free Software Foundation; either
' version 2.1 of the License, or (at your option) any later version.
' This library is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
' Lesser General Public License for more details.
' You should have received a copy of the GNU Lesser General Public
' License along with this library; if not, write to the Free Software
' Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
'********************************************************************************
'IMPORTANT:
'THIS FILE IS ESSENTIAL FOR SOME OF THE COMMANDS IN GCBASIC. DO NOT ALTER THIS FILE
'UNLESS YOU KNOW WHAT YOU ARE DOING. CHANGING THIS FILE COULD RENDER SOME GCBASIC
'COMMANDS UNUSABLE!
'********************************************************************************
'Updates:
' 3/5/2006: Program EEPROM read/write added
' 16/5/2006: Write mode disabled at end of EPWrite
' 23/5/2006: EPWrite and EPRead changed to stop use of temporary vars
' 19/8/2006: Program EEPROM altered to take input as word
' 9/2/2007: Bug fix: EEPGD bit not set if not present
' 5/8/2007: Altered to use alias to access address, data vars
' 4/9/2007: Data EEPROM code altered to support AVR
'15/10/2007: Bug fix: FREE bit not set if not present, altered to use IntOn/IntOff to control interrupt
'4/12/2007: Added In/Out to parameters
'19/6/2008: Bug fix for Byte size register devices by Kent Schafer (ProgramWrite, ProgramRead, ProgramErase)
sub EPWrite(In EEAddress, In EEDataValue)
#IFDEF PIC
'Variable alias
Dim EEAddress Alias EEADR
Dim EEDataValue Alias EEDATA
'Disable interrupt
IntOff
'Select data memory
#IFDEF Bit(EEPGD)
SET EECON1.EEPGD OFF
#ENDIF
'Start write
SET EECON1.WREN ON
EECON2 = 0x55
EECON2 = 0xAA
SET EECON1.WR ON
SET EECON1.WREN OFF
'Wait for write to complete
WAIT WHILE EECON1.WR ON
SET EECON1.WREN OFF
'Restore interrupt
IntOn
#ENDIF
#IFDEF AVR
'Variable alias
Dim EEAddress As Word Alias EEARH, EEARL
Dim EEDataValue Alias EEDR
'Enable and start write
Set EECR.EEMWE On
Set EECR.EEWE On
'Wait for write to complete
Wait Until EECR.EEWE Off
Wait Until SPMCR.SPMEN Off
Set EECR.EEWE Off
#ENDIF
end sub
sub EPRead(In EEAddress, Out EEDataValue)
#IFDEF PIC
'Variable alias
Dim EEAddress Alias EEADR
Dim EEDataValue Alias EEDATA
'Disable interrupt
IntOff
'Select data memory
#IFDEF Bit(EEPGD)
SET EECON1.EEPGD OFF
#ENDIF
'Read
SET EECON1.RD ON
'Restore interrupt
IntOn
#ENDIF
#IFDEF AVR
'Variable alias
Dim EEAddress As Word Alias EEARH, EEARL
Dim EEDataValue Alias EEDR
'Start read
Set EECR.EERE On
#ENDIF
end sub
function ReadEP(EEAddress)
#IFDEF PIC
'Variable alias
Dim EEAddress Alias EEADR
Dim ReadEP Alias EEDATA
'Disable interrupt
IntOff
'Select data memory
#IFDEF Bit(EEPGD)
SET EECON1.EEPGD OFF
#ENDIF
'Read
SET EECON1.RD ON
nop
'Restore interrupt
IntOn
#ENDIF
#IFDEF AVR
'Variable alias
Dim EEAddress As Word Alias EEARH, EEARL
Dim EEDataValue Alias EEDR
'Start read
Set EECR.EERE On
#ENDIF
end sub
sub ProgramWrite(In EEAddress, In EEDataWord)
#IFDEF PIC
#IFDEF Var(EEADRH)
Dim EEAddress As Word Alias EEADRH, EEADR
Dim EEDataWord As Word Alias EEDATH, EEDATA
#Endif
#IFDEF NOVAR(EEADRH)
Dim EEAddress as Byte Alias EEADR
Dim EEDataWord as Byte Alias EData
#ENDif
IntOff
#IFDEF Bit(EEPGD)
SET EECON1.EEPGD ON
#ENDIF
SET EECON1.WREN ON
#ifdef bit(FREE)
SET EECON1.FREE OFF
#endif
EECON2 = 0x55
EECON2 = 0xAA
SET EECON1.WR ON
NOP
NOP
SET EECON1.WREN OFF
IntOn
#ENDIF
end sub
sub ProgramRead(In EEAddress, Out EEDataWord)
#IFDEF Var(EEADRH)
Dim EEAddress As Word Alias EEADRH, EEADR
Dim EEDataWord As Word Alias EEDATH, EEDATA
#Endif
#IFDEF NOVAR(EEADRH)
Dim EEAddress as Byte Alias EEADR
Dim EEDataWord as Byte Alias EData
#ENDif
IntOff
#IFDEF Bit(EEPGD)
SET EECON1.EEPGD ON
#ENDIF
SET EECON1.RD ON
NOP
NOP
IntOn
end sub
sub ProgramErase(In EEAddress)
#IFDEF Var(EEADRH)
Dim EEAddress As Word Alias EEADRH, EEADR
#Endif
#IFDEF NOVAR(EEADRH)
Dim EEAddress as Byte Alias EEADR
#ENDif
IntOff
#IFDEF Bit(EEPGD)
SET EECON1.EEPGD ON
#ENDIF
SET EECON1.WREN ON
#ifdef bit(FREE)
SET EECON1.FREE ON
#endif
EECON2 = 0x55
EECON2 = 0xAA
SET EECON1.WR ON
NOP
NOP
#ifdef bit(FREE)
SET EECON1.FREE OFF
#endif
SET EECON1.WREN OFF
IntOn
end sub
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The above eeprom.h should be used carefully, as not sure where exactly the calls to ProgramWrite, ProgramRead, ProgramErase are coming from. Thinking its the programmer?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
with this line of code :
for 12f675
"EPWrite(DataCount, ReadAD10(AN1))"
I get the message:
"ASM: compiled.asm:48:Error [113] Symbol not previously defined (EEADRH)."
Why?
Because no one asked the question before, or some bit of code got dropped along the way? Actually noticed this when working with the a-d.h file for the 18f4431. Forgot to follow up, so here is a work around, for fixing the 12f675 ReadAD10 function. This could be obsoleted, as I do not have the lastest zip download. Let us know if it works.
Find a-d.h file in the include/lowlevel folder. In the macro LLReadAD, find the block of code described below and insert the #IFDEF Var(ADRESH).
#IFDEF Var(ANSEL)
#IFDEF Var(ANSELH)
Dim AllANSEL As Word Alias ANSELH, ANSEL
#ENDIF
'Insert 3 lines of code for the 12f675 & ???
#IFDEF Var(ADRESH)
Dim AllANSEL As Word Alias ADRESH, ADRESL
#ENDIF
#IFDEF NoVar(ANSELH)
Dim AllANSEL As Byte Alias ANSEL
#ENDIF
ADTemp = ADReadPort + 1
Set C On
Do
Rotate AllANSEL Left
decfsz ADTemp,F
Loop
#ENDIF
Still happens
O.K. then, more extensive problem then first thought. Here is a proof example for the 12f675, and a rehash of the eeprom.h file so byte size EEProm registers can be handled on low pin count devices follows. The most effected changes are in ProgramWrite, ProgramRead, ProgramErase subs, which caused the hangup.
'This example is a proof for sending a word size variable analog input (10k Pot) to
'a low pin count device EEProm and reading it back on leds connected to GPIO/Port pins.
' (c) Kent Schafer 2008
'Chip settings
#chip 12f675,4
#config _CP_OFF & _CPD_OFF & _BODEN_OFF & _WDT_OFF & _PWRTE_ON & _INTRC_OSC_NOCLKOUT
dir GPIO.0 in 'Analog input from 10k pot connected to VDD
dir GPIO.1 out 'Set up outputs for leds
dir GPIO.2 out
dir GPIO.4 out
dir GPIO.5 out
dim Volt as word
dim readvolt as word
Start:
EEPromCount = 1
Volt = ReadAD10(AN0)
EPWrite(EEPromCount, Volt_H) 'low pin count devices have byte size EEProm addresses
EEPromCount += 1 'increment counter/address
EPWrite(EEPromCount, Volt)
EEPromCount = 1 'reset counter in preperation for EEProm readback
EPRead(EEPromCount, RvoltH) 'read back EEProm address values
EEPromCount += 1 'increment counter/address
EPRead(EEPromCount, RvoltL)
readvolt = (256*RvoltH) + RvoltL 'reassemble word variable
GPIO.5 = readVolt/512 'readout binary values MSB's on leds, with modulo command
GPIO.4 = (readVolt % 512)/256
GPIO.2 = (readVolt % 256)/128
GPIO.1 = (readVolt % 128)/64
wait 10 10ms
goto Start
' EEPROM routines for Great Cow BASIC
' Copyright (C) 2006-2007 Hugh Considine
' This library is free software; you can redistribute it and/or
' modify it under the terms of the GNU Lesser General Public
' License as published by the Free Software Foundation; either
' version 2.1 of the License, or (at your option) any later version.
' This library is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
' Lesser General Public License for more details.
' You should have received a copy of the GNU Lesser General Public
' License along with this library; if not, write to the Free Software
' Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
'********************************************************************************
'IMPORTANT:
'THIS FILE IS ESSENTIAL FOR SOME OF THE COMMANDS IN GCBASIC. DO NOT ALTER THIS FILE
'UNLESS YOU KNOW WHAT YOU ARE DOING. CHANGING THIS FILE COULD RENDER SOME GCBASIC
'COMMANDS UNUSABLE!
'********************************************************************************
'Updates:
' 3/5/2006: Program EEPROM read/write added
' 16/5/2006: Write mode disabled at end of EPWrite
' 23/5/2006: EPWrite and EPRead changed to stop use of temporary vars
' 19/8/2006: Program EEPROM altered to take input as word
' 9/2/2007: Bug fix: EEPGD bit not set if not present
' 5/8/2007: Altered to use alias to access address, data vars
' 4/9/2007: Data EEPROM code altered to support AVR
'15/10/2007: Bug fix: FREE bit not set if not present, altered to use IntOn/IntOff to control interrupt
'4/12/2007: Added In/Out to parameters
'19/6/2008: Bug fix for Byte size register devices by Kent Schafer (ProgramWrite, ProgramRead, ProgramErase)
sub EPWrite(In EEAddress, In EEDataValue)
#IFDEF PIC
'Variable alias
Dim EEAddress Alias EEADR
Dim EEDataValue Alias EEDATA
'Disable interrupt
IntOff
'Select data memory
#IFDEF Bit(EEPGD)
SET EECON1.EEPGD OFF
#ENDIF
'Start write
SET EECON1.WREN ON
EECON2 = 0x55
EECON2 = 0xAA
SET EECON1.WR ON
SET EECON1.WREN OFF
'Wait for write to complete
WAIT WHILE EECON1.WR ON
SET EECON1.WREN OFF
'Restore interrupt
IntOn
#ENDIF
#IFDEF AVR
'Variable alias
Dim EEAddress As Word Alias EEARH, EEARL
Dim EEDataValue Alias EEDR
'Enable and start write
Set EECR.EEMWE On
Set EECR.EEWE On
'Wait for write to complete
Wait Until EECR.EEWE Off
Wait Until SPMCR.SPMEN Off
Set EECR.EEWE Off
#ENDIF
end sub
sub EPRead(In EEAddress, Out EEDataValue)
#IFDEF PIC
'Variable alias
Dim EEAddress Alias EEADR
Dim EEDataValue Alias EEDATA
'Disable interrupt
IntOff
'Select data memory
#IFDEF Bit(EEPGD)
SET EECON1.EEPGD OFF
#ENDIF
'Read
SET EECON1.RD ON
'Restore interrupt
IntOn
#ENDIF
#IFDEF AVR
'Variable alias
Dim EEAddress As Word Alias EEARH, EEARL
Dim EEDataValue Alias EEDR
'Start read
Set EECR.EERE On
#ENDIF
end sub
function ReadEP(EEAddress)
#IFDEF PIC
'Variable alias
Dim EEAddress Alias EEADR
Dim ReadEP Alias EEDATA
'Disable interrupt
IntOff
'Select data memory
#IFDEF Bit(EEPGD)
SET EECON1.EEPGD OFF
#ENDIF
'Read
SET EECON1.RD ON
nop
'Restore interrupt
IntOn
#ENDIF
#IFDEF AVR
'Variable alias
Dim EEAddress As Word Alias EEARH, EEARL
Dim EEDataValue Alias EEDR
'Start read
Set EECR.EERE On
#ENDIF
end sub
sub ProgramWrite(In EEAddress, In EEDataWord)
#IFDEF PIC
#IFDEF Var(EEADRH)
Dim EEAddress As Word Alias EEADRH, EEADR
Dim EEDataWord As Word Alias EEDATH, EEDATA
#Endif
#IFDEF NOVAR(EEADRH)
Dim EEAddress as Byte Alias EEADR
Dim EEDataWord as Byte Alias EData
#ENDif
IntOff
#IFDEF Bit(EEPGD)
SET EECON1.EEPGD ON
#ENDIF
SET EECON1.WREN ON
#ifdef bit(FREE)
SET EECON1.FREE OFF
#endif
EECON2 = 0x55
EECON2 = 0xAA
SET EECON1.WR ON
NOP
NOP
SET EECON1.WREN OFF
IntOn
#ENDIF
end sub
sub ProgramRead(In EEAddress, Out EEDataWord)
#IFDEF Var(EEADRH)
Dim EEAddress As Word Alias EEADRH, EEADR
Dim EEDataWord As Word Alias EEDATH, EEDATA
#Endif
#IFDEF NOVAR(EEADRH)
Dim EEAddress as Byte Alias EEADR
Dim EEDataWord as Byte Alias EData
#ENDif
IntOff
#IFDEF Bit(EEPGD)
SET EECON1.EEPGD ON
#ENDIF
SET EECON1.RD ON
NOP
NOP
IntOn
end sub
sub ProgramErase(In EEAddress)
#IFDEF Var(EEADRH)
Dim EEAddress As Word Alias EEADRH, EEADR
#Endif
#IFDEF NOVAR(EEADRH)
Dim EEAddress as Byte Alias EEADR
#ENDif
IntOff
#IFDEF Bit(EEPGD)
SET EECON1.EEPGD ON
#ENDIF
SET EECON1.WREN ON
#ifdef bit(FREE)
SET EECON1.FREE ON
#endif
EECON2 = 0x55
EECON2 = 0xAA
SET EECON1.WR ON
NOP
NOP
#ifdef bit(FREE)
SET EECON1.FREE OFF
#endif
SET EECON1.WREN OFF
IntOn
end sub
Forgot already, you could also just follow what Hugh has suggeted per recent post: http://sourceforge.net/forum/message.php?msg_id=4959561
The above eeprom.h should be used carefully, as not sure where exactly the calls to ProgramWrite, ProgramRead, ProgramErase are coming from. Thinking its the programmer?