Shop OBEX P1 Docs P2 Docs Learn Events
Al Williams 4-bit LCD driver code for SX/B — Parallax Forums

Al Williams 4-bit LCD driver code for SX/B

baba40baba40 Posts: 13
edited 2007-04-18 13:53 in General Discussion
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

Comments

  • Capt. QuirkCapt. Quirk Posts: 872
    edited 2007-04-09 04:58
    This doesn't answer your question, but I didn't have much luck with that program. The SASM examples both 4 bit and 8 bit work great and are commented very well.




    Post Edited (Capt. Quirk) : 4/9/2007 2:45:11 PM GMT
  • Capt. QuirkCapt. Quirk Posts: 872
    edited 2007-04-09 14:43
    (note)I didn't notice the SX/B portion of the title, but your showing sasm in your example? which language do you need?
  • Sparks-R-FunSparks-R-Fun Posts: 388
    edited 2007-04-09 18:50
    baba40,

    It might be helpful if you posted your complete code.

    Have you properly defined "setcursor" a subroutine in SX/B?


    - Sparks
  • Capt. QuirkCapt. Quirk Posts: 872
    edited 2007-04-09 20:03
    Lcd's don't normally take decimal #s. If you want it to go there and since you are talking about an Instruction. First you convert your decimal to a binary. 40 converts to %0010_1000. But in order for the LCD to take it as an instruction to goto row #2 first space, you need to add a 1 to the beginning of that binary number (like this %1010_1000). When you are sending instructions be sure RS = 0 and RW = 0 (or RW is grounded)

    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.
  • baba40baba40 Posts: 13
    edited 2007-04-15 22:20
    Capt. Quirk, Sparks-R- fun,

    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
  • NateNate Posts: 154
    edited 2007-04-15 23:57
    Your answer is in your first post.·

    "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"
  • Capt. QuirkCapt. Quirk Posts: 872
    edited 2007-04-16 07:53
    You need to start by organizing your code with the "code template" under: Help\Example Projects\Programming Template. That will help your subroutine problem. All subs need to be declared before the start of the main loop.

    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
  • BeanBean Posts: 8,129
    edited 2007-04-16 12:59
    nimbus,
    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
    ·
  • baba40baba40 Posts: 13
    edited 2007-04-17 03:53
    Thanks guys. You've given me a lot to ponder. Since there seems to be a common thread in your responses, I'm sure you've given me what I need to solve my problem, but perhaps more importantly the RIGHT approach and discipline. Will follow your advice and let you know how I fair (though maybe not until the weekend... work impinges again).

    Again, thanks for all the help and support.

    BaBa40

    P.S. Thanks for t he attached file
  • baba40baba40 Posts: 13
    edited 2007-04-17 22:51
    Capt. Quirk and Bean,

    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.
  • Capt. QuirkCapt. Quirk Posts: 872
    edited 2007-04-17 22:59
    You have downloaded the SX/B software from parallax? it's in there. In·the help section of SX/B compiler·

    under: Help\ SX/B Help\Example Projects\Programming Template

    and under Help\ SX/B Help \Reference\SX/B Style guidelines

  • baba40baba40 Posts: 13
    edited 2007-04-18 13:53
    Thank,

    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
Sign In or Register to comment.