The READCODE command actually looks perfect for me. Thanks for pointing that out.
The PIC will switch between different messages when external buttons are pushed.
The READCODE command actually looks perfect for me. Thanks for pointing that out.
The PIC will switch between different messages when external buttons are pushed.
Well, it was too good to be true. Whenever I compile with this in my project:
I get some nice errors:Code:Asm CODE 1400 DB 0 DB 220 DB 476 DB 384 DB 384 DB 476 DB 220 DB 0 DB 999 Endasm
Found directive in column 1. (CODE)
Directive only allowed when creating an object file
Found directive in column 1. (DB)
Argument out of range. Least significant bits used.
There are 15 errors total, but they're all just copies of those 4.
Am I missing something?
You need to indent your program like that below. However, I believe DB is used for bytes only and you must use packing to place the word (i.e., DB 476 will not do what you want)? Others with more 16 bit processor Assembly experience might be able to offer a (better) solution in ASM.
You might want to consider using PBP's WRITECODE instead of the ASM for the initial write. Look here http://www.picbasic.co.uk/forum/show...ight=writecode and also search “WRITECODE” on this forum for examples of how to write to the 18F family, which is not as straight forward as one might think.
Good LuckCode:Asm CODE 1400 DB 0 DB 220 DB 476 DB 384 DB 384 DB 476 DB 220 DB 0 DB 999 Endasm
edit: or consider LOOKUP2 tables
Last edited by paul borgmeier; - 3rd September 2006 at 08:29. Reason: added option?
Paul Borgmeier
Salt Lake City, UT
USA
__________________
Originally Posted by paul borgmeier
I also was going to suggest LOOKUP table but arrays can not be used with Lookup tables!
Say there are 90 messages.
Code:'This code is just a part of the idea to start from somewhere. Message var byte[90] MessageTemp var byte Loop var byte for loop = 0 to 89 lookup loop,[$AA,$2C,$4D,.....................], MessageTemp message[loop]=messageTEMP next loop
This way,
Originally Posted by RUBiksCUbe
can be achieved.
------------------------------------
-------
Last edited by sayzer; - 3rd September 2006 at 13:22.
"If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte
I never knew about LOOKUP, but the lookup and loop should work perfectly. The intenting fixed the "DB"s but the "CODE" line still causes a problem, so I'm going to abandon READCODE and just stick with LOOKUP.
Thanks!
There have been a number of solutions to this type of problem. If the messages you plan on displaying won't be changed once the pic is programmed, These may work:
STRINGS - How to store and retrieve strings in Code Space by Darrel Taylor.
Here is a thread which deals with the storage of strings as well.
One other possibility is use an external EEPROM. Limit all the messages to X number of characters (say 255). Then, depending on the message, go to the designated starting address for that message (0 for message A, 256 for message B, ...) Also store a "stop" character to know where the message ends. This would allow something like (This is an example, not a completed program):
HTH,Code:MessageString VAR BYTE[256] StartAddress VAR WORD cnt VAR BYTE StopChar CON 3 MessageNumber = 1 StartAddress = MessageNumber * 256 cnt = 0 ReadMessage: I2CREAD DataPin,ClockPin,Control, (StartAddress+cnt) ,[MessageString(cnt)] IF MessageString(cnt) <> StopChar THEN ReadMessage
Steve
EDIT: Added varible declaration for StartAddress
Last edited by SteveB; - 3rd September 2006 at 23:04.
I'll definetly switch to an EEPROM for storage once I get the rest of the circuit working. I thought about using an EEPROM but I wasn't sure how to interface with one. Thanks for the code.
Bookmarks