Al Williams 4-bit LCD driver code for SX/B
I have copied Al Williams new SX/B LCD driver code, an update·of his previous SX assembler implementation, from the new version 3 of Exploring the SX Microcontroller wiht Assembly and Basic Programming.· When I assembly it, I get an "error 44, Pass 2: Address 266 is not within lower half of memory page."· the source code of the subroutine where this is happening is:
··gosub setcursor,40·'move to line 2
··goto ploop
The assembled code is:
MOV __PARAM1,#40·············· ;··gosub setcursor, 40·'move to line 2
MOV __PARAMCNT,#1
CALL @setcursor··············
JMP @ploop···················· ;··goto ploop
The error references: CALL @setcursor
I suspect this is·some sort of dreaded page jump problem from the assembler syntax used on this line, but since I did not create the code, I'm not sure, nor am I sure how to correct this problem since I suspect it probably didn't happen when the code was tested prior to publication.· Has anyone stumbled across this before and discovered the problem.· I am beginning to believe my worst fears of intermingling basic and assembler using a non-optimizing compiler/assembler maybe coming true.
Nimbus
··gosub setcursor,40·'move to line 2
··goto ploop
The assembled code is:
MOV __PARAM1,#40·············· ;··gosub setcursor, 40·'move to line 2
MOV __PARAMCNT,#1
CALL @setcursor··············
JMP @ploop···················· ;··goto ploop
The error references: CALL @setcursor
I suspect this is·some sort of dreaded page jump problem from the assembler syntax used on this line, but since I did not create the code, I'm not sure, nor am I sure how to correct this problem since I suspect it probably didn't happen when the code was tested prior to publication.· Has anyone stumbled across this before and discovered the problem.· I am beginning to believe my worst fears of intermingling basic and assembler using a non-optimizing compiler/assembler maybe coming true.
Nimbus
Comments
Post Edited (Capt. Quirk) : 4/9/2007 2:45:11 PM GMT
It might be helpful if you posted your complete code.
Have you properly defined "setcursor" a subroutine in SX/B?
- Sparks
After you have sent the cursor to the location you desire, then follow it with RS = 1 and RW = 0 and the LCD is ready to print data at the cursors new poition.
Hexit is a small freeware program that helped me out when I made my parallel SXB program. If you need to just display data asap, a Serial LCD is the easiest LCD to work with, but I think Parallel LCD's are an excellent precursor to other chips that interface to a SX.
Thanks for the quick reply.· Sorry I'm late with this reply, but I haven't been to the forum since the posting you responded to (work always seems
to impinge).
I think I have attached the SX/B file per your suggestion (see comment below).· I orginally compiled this source file using the SX/B compiler option.· This generated the intermediate assembler where the error occurs.· It appears to be some sort of addressing (or addressing syntax) error,
but this is where I am having the problem as the error is generated out of the compile and thus I think I'm adrift without any context.· I would have thought that if the compiler were going to generate intermediate assembly code, it would take care of the page jump, but I'm not sure this is true (I may be naive here).
One question I have is: would expanding the amount of commenting text or the text of the date strings for the display possibly push this the orginal
source from Al over a page boundary?· If so, why wouldn't the compiler handle this?
I spoke to technical support late on Friday, but they couldn't help beyond suggesting I post the code and await a possible reply from one of the Parallax engineers who routinely monitor the forums.· Please·let me know if you experience the same error when you compile the code.
Also, please let me know if the file isn't attached to this message.· The way this site handles attachments is unusual for me, and I can't determine if my reply is actually going out with the attachment.
Again, thank you both for your help.· Hope hear from you soon.
Baba40
"error 44, Pass 2: Address 266 is not within lower half of memory page."·
"The error references: CALL @setcursor"
You are making a call to an address that is not in the lower half of a page (ie setcursor).
Try deleting·some of the text in the line
DW "Assembly Language I/O with the SX-Key"
The Al Williams SXB examples are way out-dated. READ THIS·, declare your subs, use the example for for Subroutines that replaces [noparse][[/noparse]GOSUB· lcdout, CURSOR_BLINK], TO: [noparse][[/noparse]lcdout CURSOR_BLINK]
To make your code more readable go to: HELP\Reference\SX/B Style guidelines. After your done your Subroutine should look like this: LCD_OUT CursorBlink and you will declare it like this: LCD_OUT····· 1 (that sub sends only 1 byte data or constant)
hope this helps, let us know if it doesn't
Bill
·PS: the help example for a serial LCD is an 8 bit parallel lcd code with Serial code to allow the SX communicate·with a BS2. Here is a striped down version that might be better to start with or at least use it to compare with.
Post Edited (Capt. Quirk) : 4/16/2007 8:07:44 AM GMT
You need to declare "SetCursor" as a SUB before you use it.
See the template in the help file.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"Educate your children to self-control, to the habit of holding passion and prejudice and evil tendencies subject to an upright and reasoning will, and you have done much to abolish misery from their future and crimes from society"
Benjamin Franklin
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
www.hittconsulting.com
·
Again, thanks for all the help and support.
BaBa40
P.S. Thanks for t he attached file
Can you tell me where to find your two help references, Style and template? Are they in the SX/B manual or Al
William's version 3 of Exploring the SX Microcontroller wiht Assembly and Basic Programming.
under: Help\ SX/B Help\Example Projects\Programming Template
and under Help\ SX/B Help \Reference\SX/B Style guidelines
I suspected it was with the compiler doc. Posted my question from work where I'm not allowed have such things as compilers.
Thanks for the help with these low brow questions.
Perry