PDA

View Full Version : WRITE error in 18l.lib



Rogerio
- 17th March 2010, 19:56
Hi. I am trying to use WRITE to write to EEPROM on a 18F4620 using PBPL and MPASM but I get the following:

Error[113] c:\pbp\pbppi18l.lib 723 : Symbol not previously defined (WRITE)

I checked the pbpi18l library and it does include WRITE.

Any ideas why this is happening? Should I just ignore the error messages?

I'l try to write to eeprom an see what happens.

Thanks!

Rogerio

Rogerio
- 17th March 2010, 20:08
Tried to comiple and test but it won't compile while error shows up.

Any ideas?

Thanks!

Rogerio

Rogerio
- 17th March 2010, 20:52
Ok, I am trying to store LONG variables. Tried using BYTE variables and it works. It's supposed to work for LONG's also.
Found something at http://www.melabs.com/support/pbpissues.htm and tried it:

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

Add the following define at the top of the code. This define will have no effect on unaffected code, nor will it increase code space usage.

DEFINE WRITE_USED 1

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

Now it says 1 is an illegal character!

Do I have to store the LONG var into BYTE vars before Writing-Reading?

I hope not.

Please help!

Rogerio

Bruce
- 17th March 2010, 20:57
Can you post the code you're getting these errors with?

Rogerio
- 17th March 2010, 22:11
Hello Bruce,

Wrote a short test code, here are the different tests I made:


1.- LONG variables





clear

DEFINE WRITE_USED 1


Number1 var Long
Number2 var long



Start:

number1 = 70000
lcdout $FE,1
lcdout $FE,$80,dec number1
write 0,number1
pause 2000
read 0,number2
lcdout $FE,$C0,dec number2
pause 5000
goto start



LCDOUT at the second row displays 112 instead of 70000, so I guess it's not writing or reading all bytes. Would not compile without "DEFINE WRITE_USED 1".



2.- Word variables





clear

DEFINE WRITE_USED 1


Number1 var word
Number2 var word



Start:

number1 = 7000
lcdout $FE,1
lcdout $FE,$80,dec number1
write 0,number1
pause 2000
read 0,number2
lcdout $FE,$C0,dec number2
pause 5000
goto start



LCDOUT at the second row displays 88 instead of 7000, so I guess it's not writing or reading all bytes.


3.- Long variables, no define, using modifiers





clear


Number1 var long
Number2 var long



Start:

number1 = 70000
lcdout $FE,1
lcdout $FE,$80,dec number1
write 0,number1.byte0,number1.byte1,number1.byte2,number 1.byte3 'byte1,number1.byte2,number1.byte3
pause 2000
read 0,number2.byte0,number2.byte1,number2.byte2,number 2.byte3
lcdout $FE,$C0,dec number2
pause 5000
goto start



Did not work, got garbage.


4.- Long variables no define, using different modifiers





clear


Number1 var long
Number2 var long



Start:

number1 = 70000
lcdout $FE,1
lcdout $FE,$80,dec number1
write 0,number1.lowbyte,number1.highbyte,number1.byte2,n umber1.byte3 'byte1,number1.byte2,number1.byte3
pause 2000
read 0,number2.lowbyte,number2.highbyte,number2.byte2,n umber2.byte3
lcdout $FE,$C0,dec number2
pause 5000
goto start



This one worked with LowByte, HighByte, BYTE2 and BYTE3 modifiers, will not work with BYTE0, or BYTE1 modifiers. So you do have to use modifiers.

Haven't slept since yesterday so maybe I don't read and write clearly myself, maybe that's how it's supposed to be done and not just typing the variable name, that's how I thought the manual said it could be done.

At least it works, but I thought I could just write the var name and PBPL was supposed to do the rest.

Any suggestions or ideas are welcome.

Thanks Bruce!

Rogerio

Bruce
- 17th March 2010, 22:52
You do not need DEFINE WRITE_INT 1 unless you have interrupts enabled prior to issuing a WRITE statement.

What do you get with this?



Number1 var Long
Number2 var long

Start:
number1 = 70000
lcdout $FE,1,dec number1
write 0,LONG number1
pause 2000
read 0,LONG number2
lcdout $FE,$C0,dec number2
pause 5000
goto start
Works 100% on the 18F452 I just tested!

Rogerio
- 18th March 2010, 00:00
Yes, it works just fine! I definetly have to sleep, did not notice you had to use LONG before the variable name, it's right there on the manual, sorry. As always, when something is not working it most be an error on my part, not PBP!

Thanks a lot Bruce!

Rogerio