Log in

View Full Version : Pic16f57 + lcdout=error



pedja089
- 6th October 2010, 18:55
When I try to compile I get this:

ERROR: Macro LCDOUTCOUNT?C not found in macro file.
ERROR: Macro LCDOUTNUM?W not found in macro file.
ERROR: Macro LCDOUTDEC? not found in macro file.
All Done, PCB, soldering. Project must be finished tomorow:mad:
Does anybody know why this happens and how to solve this problem?
I'm using PBP 2.60A & MCS 4.0
Is there any hope for this project to be completed on time?

ScaleRobotics
- 6th October 2010, 19:36
Can you give any more information? I put a simple lcdout command in pbp 2.60a for a 16F57 (MCS 3.0.0.5), and just got a crossing page boundary warning. No errors.

There is always hope.....

pedja089
- 6th October 2010, 20:48
Yes of course.
All comments are in Serbian.
Programm:
'@ DEVICE XT_OSC,WDT_OFF,PROTECT_ON
'DEFINE LCD_BITS 4
'DEFINE LCD_DREG PORTB
'DEFINE LCD_DBIT 0
'DEFINE LCD_RSREG PORTB
'DEFINE LCD_RSBIT 4
'DEFINE LCD_EREG PORTB
'DEFINE LCD_EBIT 5
'DEFINE LCD_LINES 2

DEFINE LCD_BITS 4
DEFINE LCD_DREG PORTB
DEFINE LCD_DBIT 0
DEFINE LCD_RSREG PORTA
DEFINE LCD_RSBIT 2
DEFINE LCD_EREG PORTA
DEFINE LCD_EBIT 3
DEFINE LCD_LINES 2
Tz var word
Tt Var Word
Set var byte
Ton var byte
Toff var byte
Mode var byte

CR Var Byte


Sn var byte
Ss var byte

Znak1 var byte
Znak2 var byte
Znak3 var byte
Znak4 var byte

I var byte

symbol DQ = portb.4
symbol Tmode= portb.5
symbol Tp=portb.6
symbol Tm=portb.7
symbol Rele=porta.1

SYMBOL SCL = portc.4
SYMBOL SDA = portc.5

input tmode
input tp
input tm
output rele
'adcon1=7
clear
ss = tm
rele=0
set=0
i=0
pause 100
lcdout $fe,1, " ....."
Lcdout $fe, $C0," www.....hr"
pause 2000
I2Cread SDA,SCL,$A0,0,[tz.lowbyte,tz.highbyte,toff,ton]
if tz>600 then tz=200
if toff=>100 then toff=5
if ton=>100 or ton=0 then ton=5

Pocetak:
sn = tmode
if sn<ss then set= set + 1

if set>3 then
set = 0
endif

ss=sn
select case set
CASE 0
znak1=" "
znak2=" "
znak3=" "
call izmeri
i=0

CASE 1
znak1=">"
znak2=" "
znak3=" "
if tp=0 and tz<600 then
tz=tz+5
i=0
endif
if tm=0 and tz=>5 then
tz=tz-5
i=0
endif
I2CWrite SDA,SCL,$A0,0,[tz.lowbyte,tz.highbyte]

CASE 2
znak1=" "
znak2=">"
znak3=" "
if tp=0 and ton<100 then
ton=ton+5
i=0
endif
if tm=0 and ton=>5 then
ton=ton-5
if Ton=0 and toff=0 then ton=5
i=0
endif
I2CWrite SDA,SCL,$A0,3,[ton]

CASE 3
znak1=" "
znak2=" "
znak3=">"
if tp=0 and toff<100 then
toff=toff+5
i=0
endif
if tm=0 and toff=>5 then
toff=toff-5
if Ton=0 and toff=0 then toff=5
i=0
endif
I2CWrite SDA,SCL,$A0,2,[toff]

END SELECT

if tz+ton<=tt and set=0 and znak4="+" then 'ako je zadata temp manja od trenutne
rele=1 'ukljuci rele
endif
if (tz=>toff and tz-toff=>tt and znak4="+") or (tz<toff and toff-tz<=tt and znak4="-" ) or set>0 then 'ako je zadata temperatura veca od trenutne ili si usao u meni
rele=0
endif


i=i+1
if i >100 then set = 4 'izadji iz menija

call prikazi
pause 150
goto pocetak





Prikazi:
Lcdout $fe,1,znak1,"+",DEC2 (tz / 10), ".",#(tz dig 0),223, "C"
if set=0 then lcdout $fe,$89,znak4,DEC2 (tt / 10), ".",#(tt dig 0) ,223, "C" '178
Lcdout $fe, $C0, znak2,"+",DEC2 (ton / 10), ".",#(ton dig 0),223, "C",znak3,"-",DEC2 (toff / 10), ".",#(toff dig 0),223, "C"
return

Izmeri:

OWOut DQ, 1, [$CC, $44] ' Start merenja temperature
Cekaj: OWIn DQ, 4, [cr] ' Provera da li jos traje
If cr = 0 Then Cekaj

OWOut DQ, 1, [$CC, $BE] ' Procitaj izmerenu temperaturu
OWIn DQ, 0, [tt.LOWBYTE, tt.HIGHBYTE]', Skip 4, cr, cpc]

If tt.bit15=1 then
znak4="-"
tt = abs(tt)
else
znak4="+"
endif
tt=(tt>>1)*10+tt.0*5
return

It's simple thermostat with hysteresis.
I tested it on easypic5 and PIC16F877, everything works great,but when I tried to compile for the PIC16F57, I got errors...
When I remove LCDOUT comands, then I get this:

Called Adresses must Reside in Lower Half of Page
I tried to reorganize the code, remove LCDOUT, but then i get an error when using I2C commands...

'@ DEVICE XT_OSC,WDT_OFF,PROTECT_ON
'DEFINE LCD_BITS 4
'DEFINE LCD_DREG PORTB
'DEFINE LCD_DBIT 0
'DEFINE LCD_RSREG PORTB
'DEFINE LCD_RSBIT 4
'DEFINE LCD_EREG PORTB
'DEFINE LCD_EBIT 5
'DEFINE LCD_LINES 2

DEFINE LCD_BITS 4
DEFINE LCD_DREG PORTB
DEFINE LCD_DBIT 0
DEFINE LCD_RSREG PORTA
DEFINE LCD_RSBIT 2
DEFINE LCD_EREG PORTA
DEFINE LCD_EBIT 3
DEFINE LCD_LINES 2
Tz var word
Tt Var Word
Set var byte
Ton var byte
Toff var byte
Mode var byte

CR Var Byte


Sn var byte
Ss var byte

Znak1 var byte
Znak2 var byte
Znak3 var byte
Znak4 var byte

I var byte

symbol DQ = portb.4
symbol Tmode= portb.5
symbol Tp=portb.6
symbol Tm=portb.7
symbol Rele=porta.1

SYMBOL SCL = portc.4
SYMBOL SDA = portc.5

input tmode
input tp
input tm
output rele
'adcon1=7
clear
ss = tm
rele=0
set=0
i=0
pause 100
'lcdout $fe,1, "....."
'Lcdout $fe, $C0," www....r"
pause 2000
'I2Cread SDA,SCL,$A0,0,[tz.lowbyte,tz.highbyte,toff,ton]
if tz>600 then tz=200
if toff=>100 then toff=5
if ton=>100 or ton=0 then ton=5

Pocetak:
sn = tmode
if sn<ss then set= set + 1

if set>3 then
set = 0
endif

ss=sn
select case set
CASE 0
znak1=" "
znak2=" "
znak3=" "
'call izmeri
OWOut DQ, 1, [$CC, $44] ' Start merenja temperature
OWOut DQ, 1, [$CC, $44] ' Start merenja temperature
Cekaj: OWIn DQ, 4, [cr] ' Provera da li jos traje
If cr = 0 Then Cekaj

OWOut DQ, 1, [$CC, $BE] ' Procitaj izmerenu temperaturu
OWIn DQ, 0, [tt.LOWBYTE, tt.HIGHBYTE]', Skip 4, cr, cpc]

If tt.bit15=1 then
znak4="-"
tt = abs(tt)
else
znak4="+"
endif
tt=(tt>>1)*10+tt.0*5
i=0

CASE 1
znak1=">"
znak2=" "
znak3=" "
if tp=0 and tz<600 then
tz=tz+5
i=0
endif
if tm=0 and tz=>5 then
tz=tz-5
i=0
endif
'I2CWrite SDA,SCL,$A0,0,[tz.lowbyte,tz.highbyte]

CASE 2
znak1=" "
znak2=">"
znak3=" "
if tp=0 and ton<100 then
ton=ton+5
i=0
endif
if tm=0 and ton=>5 then
ton=ton-5
if Ton=0 and toff=0 then ton=5
i=0
endif
'I2CWrite SDA,SCL,$A0,3,[ton]

CASE 3
znak1=" "
znak2=" "
znak3=">"
if tp=0 and toff<100 then
toff=toff+5
i=0
endif
if tm=0 and toff=>5 then
toff=toff-5
if Ton=0 and toff=0 then toff=5
i=0
endif
'I2CWrite SDA,SCL,$A0,2,[toff]

END SELECT

if tz+ton<=tt and set=0 and znak4="+" then 'ako je zadata temp manja od trenutne
rele=1 'ukljuci rele
endif
if (tz=>toff and tz-toff=>tt and znak4="+") or (tz<toff and toff-tz<=tt and znak4="-" ) or set>0 then 'ako je zadata temperatura veca od trenutne ili si usao u meni
rele=0
endif


i=i+1
if i >100 then set = 4 'izadji iz menija

'call prikazi
'Lcdout $fe,1,znak1,"+",DEC2 (tz / 10), ".",#(tz dig 0),223, "C"
'if set=0 then lcdout $fe,$89,znak4,DEC2 (tt / 10), ".",#(tt dig 0) ,223, "C" '178
'Lcdout $fe, $C0, znak2,"+",DEC2 (ton / 10), ".",#(ton dig 0),223, "C",znak3,"-",DEC2 (toff / 10), ".",#(toff dig 0),223, "C"

pause 150
goto pocetak
If uncomment I2C or LCDOU, I get an error...
Sorry for bad English...

Darrel Taylor
- 7th October 2010, 00:48
The 16F57 is a 12-bit core, which only has 2 stack levels.
This puts restraints on what PBP can do.

Therefore you cannot use modifiers like DEC HEX STR etc. in your LCDOUT statements.
And I2C commands can only use fixed pins that are declared with DEFINE's.

DEFINE I2C_SCL PORTA,1
DEFINE I2C_SDA PORTA,0

You can do it by tomorrow ... maybe :)

pedja089
- 7th October 2010, 01:06
Thanks Darrel.
I read a datasheet, and again I have not paid attention to the MCU ... :confused:
I made a new PCB, the 16LF76, and works great ... now that I know what the problem is, I try to write a program that runs on 16F57. Now it should not be a problem.
Thanks again.

mackrackit
- 7th October 2010, 01:21
Maybe...
You can use SHIFTIN/OUT in place of I2C
http://www.picbasic.co.uk/forum/content.php?r=165-Serial-EEPROM-Part-1

Darrel Taylor
- 7th October 2010, 01:28
You can use the I2C statements with 12-bit cores.
You just need to DEFINE the SCL and SDA pins.

They still need to be specified in the I2C statements, but can't be changed at run-time.

pedja089
- 7th October 2010, 01:36
mackrackit,very nice explanation. I did not know exactly how I2C works, now I know.;) It is easier to use and I2CREAD I2CWRITE, but this is also useful.