Searching \ for '[PIC] PIC18F1320 and jump tables' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/memory.htm?key=table
Search entire site for: 'PIC18F1320 and jump tables'.

Exact match. Not showing close matches.
PICList Thread
'[PIC] PIC18F1320 and jump tables'
2005\05\31@171451 by Dave W Turner

picon face
Hey all,

I am trying to make a program that uses an LCD display.  I know the
LCD works fine, but I want to send a long string of text.  Instead of
doing each letter individually, I tryed to construct a jump table with
dt.  However, debugging shows that W always contains 8 after the jump
table, instead of the ascii code for the correct letter.

Heres a <snip> of my code:

getstring
       addwf        PCL,f   ; A subroutine to fetch a letter
       dt        "olleH"    ; (hello backwards

<snip>

; meanwhile, in the main program......

                movlw 04h                   ; number of characters
                movwf number              ; character counter

loop:          movf number,w             ; put in in W
                call getstring               ; put character number W into W
                IOExpLCDSendData    ; macro which sends the data in W

                decfsz number,f
                goto loop

<snip>

BTW, I know there are ways of sending a string the right way around,
but I find it easier to just reverse the string in the dt, and run the
loop decrementing.

Thanks in advance,

--

Dave
All us base are belong to you.

2005\05\31@174557 by Harold Hallikainen

face picon face
Here's some stuff I did to send strings to an LCD.


MsgToLcd macro msg
; Set up table pointers and send a messag to LCD
       movlw        upper(msg)
       movwf        tblptru
       movlw        high(msg)
       movwf        tblptrh
       movlw        low(msg)
       movwf        tblptrl
       call        LcdMsg
       endm

LcdMsg
; Put up a message pointed to by tblprt (u:h:l)
       tblrd        *+                ; Read the table character to tablat, then increment tblptr
       movfw        tablat                ; Get the character from the table
       addlw        0                ; Test w (above may not set condition codes correctly)
       skpnz
       return                        ; if we just got a zero byte, exit
       call        LcdPutChar        ; Go put it on the LCD
       goto        LcdMsg                ; Go do next


Here's a string definition:
SignOnMessageL1
       db        "     IQ512",0 ; Line 1 - Message with terminator


And here's a call of the whole mess:

       msgToLcd(signOnMessageL1)


Harold


--
FCC Rules Updated Daily at http://www.hallikainen.com

2005\05\31@175201 by Jan-Erik Soderholm

face picon face
dave.w.turner@gmail.com wrote :

> Hey all,
>
> I am trying to make a program that uses an LCD display.  I know the
> LCD works fine, but I want to send a long string of text.  Instead of
> doing each letter individually, I tryed to construct a jump table...

Hi.
Since the PIC18-line has good table-read capability through the
TBLxxx instructions, jump-tables isn't used that much on them.

In my copy of the 18F1220/1320 data sheet, the rellevant
parts are in chap 6 on page 59. Check that.

Jan-Erik.




'[PIC] PIC18F1320 and jump tables'
2005\06\01@053202 by Dave W Turner
picon face
After replacing the skpnz with btfsc STATUS,Z and changing movfw to
movf X,w,, I tried to assembler the code.  I got an error, Symbol not
previously defined (tablat).

Am I missing something obvious, or doesn't the 18F1320 support tables?
Or do I need to setup anything else?


On 5/31/05, Harold Hallikainen <spam_OUTharoldTakeThisOuTspamhallikainen.com> wrote:
{Quote hidden}

> -

2005\06\01@054320 by Jan-Erik Soderholm

face picon face
dave.w.turner@gmail.com wrote :

> I got an error, Symbol not previously defined (tablat).


You *do* include the p18f1320.inc file, right ?

TABLAT is at least defined in *my* copy of the INC file...

Jan-Erik.




2005\06\01@054550 by Dave W Turner

picon face
Oh, now I also get lots more errors along the lines of:

Error[113]   MAIN.ASM 47 : Symbol not previously defined (tablat)
Error[113]   MAIN.ASM 16 : Symbol not previously defined (tblptru)
Error[113]   MAIN.ASM 18 : Symbol not previously defined (tblptrh)
Error[113]   MAIN.ASM 20 : Symbol not previously defined (tblptrl)

On 6/1/05, .....dave.w.turnerKILLspamspam@spam@gmail.com <dave.w.turnerspamKILLspamgmail.com> wrote:
{Quote hidden}

2005\06\01@070439 by Dave W Turner

picon face
Aha - I just remembered that unlike most people, I always have my
assembler set to case sensitive.  After changing all the registers to
upper case it compiled fine.

Runs fine too.  Thank-you very much

On 6/1/05, Jan-Erik Soderholm <EraseMEjan-erik.soderholmspam_OUTspamTakeThisOuTtelia.com> wrote:
{Quote hidden}

> -

2005\06\01@072054 by Jan-Erik Soderholm

face picon face
dave.w.turner@gmail.com wrote :

> Aha - I just remembered that unlike most people,
> I always have my assembler set to case sensitive.

Well then, this might be a good time to get rid
of at least one bad habit then... :-)

Jan-Erik.



2005\06\01@081347 by olin_piclist

face picon face
dave.w.turner@gmail.com wrote:
> Error[113]   MAIN.ASM 47 : Symbol not previously defined (tablat)
> Error[113]   MAIN.ASM 16 : Symbol not previously defined (tblptru)
> Error[113]   MAIN.ASM 18 : Symbol not previously defined (tblptrh)
> Error[113]   MAIN.ASM 20 : Symbol not previously defined (tblptrl)

Are you including the standard include file for your processor?  Do you have
case sensitivity disabled?


*****************************************************************
Embed Inc, embedded system specialists in Littleton Massachusetts
(978) 742-9014, http://www.embedinc.com

2005\06\01@085622 by Dave W Turner

picon face
Yes I did include the include file.

Yes, as I explained above, I do have case sensitivity enabled.  I have
just changed it.

On 6/1/05, Olin Lathrop <@spam@olin_piclistKILLspamspamembedinc.com> wrote:
{Quote hidden}

> -

2005\06\01@092732 by Scott Dattalo

face
flavicon
face
On Tue, 2005-05-31 at 14:45 -0700, Harold Hallikainen wrote:

> Here's some stuff I did to send strings to an LCD.

<snip>

This is pretty much what I do too. However, in addition I use the
assembler to control the creation of an array of strings.

m1      db     (m1e-m1-1),"Message1
m1e

 if VERSION < 10
#define _VERSION VERSION + '0'
 else
#define _VERSION  '1',VERSION - 10 + '0'
 endif


m2      db      (m2e-m2-1),"Version: ",' ',_VERSION,"\r\n"
m2e

m3      db      (m3e-m3-1),"Message3"
m3e

m4      db      (m4e-m4-1),"Message4 is a long message that can\r\n"
       db                 " wrap around to the next line\r\n"
m4e

Messages
       data        m1,m2,m3,m4
LastMessage

M_STARTUP       EQU     0
M_VERSION       EQU     1
M_INFO          EQU     2
M_LONG_MESSAGE  EQU        3


I use Pascal's string encoding method by making the first byte be the
length of the string. Notice how the assembler can figure this out for
you. Next, I create an array of pointers to the strings and store that in
program memory at the label Messages. In C, one would write something like
this for that array:

 const char *Messages[] = {m1,m2,m3,m4};

(It's a little harder to get C to automatically figure out the length of a
string and encode it in the Pascal style.)

Finally, the constants M_* are created as symbolic indices. I could have
even used the assembler to create these too by writing something like
(untested):

Messages
Lm1   data m1
Lm2   data m2
Lm3   data m3
Lm4   data m4
LastMessage

M_STARTUP  EQU Lm1-Messages
M_VERSION  EQU Lm2-Messages
etc.



To use this assembler generated array, I write:

        MOVLW   M_STARTUP              ;Send the Startup message to
        RCALL   SendMessage            ;the console or lcd or whatever

And for completeness, here's the SendMessage routine that is very similar
to Harold's


SendMessage:
       movwf   temp0                   ;Save the message number

       CLRF    TBLPTRU                 ;Get a pointer to the
       MOVLW   LOW(Messages)           ;start of the messages
       MOVWF   TBLPTRL                 ;
       MOVLW   HIGH(Messages)          ;
       MOVWF   TBLPTRH                 ;
                                       ;
       RLNCF   temp0,W                 ;Select a particular message
       ADDWF   TBLPTRL,F               ;
       CLRW                            ;
       ADDWFC  TBLPTRH,F               ;

       TBLRD   *+                      ;Get the message ptr
       MOVFF   TABLAT,temp0            ;Low byte of message ptr
       TBLRD   *+                      ;
       MOVFF   TABLAT,TBLPTRH          ;High byte
       MOVFF   temp0,TBLPTRL           ;

       TBLRD   *+                      ;Get the message Length
       MOVFF   TABLAT,temp1            ;(could reuse temp0...)
                                       ;
smGetArray
       TBLRD   *+                      ;Get a byte of the message
       MOVF    TABLAT,W
       RCALL   DoSomethingWithTheNextByte
       DECFSZ  temp1,f
        bra    smGetArray

       RETURN

Scott

PS, I turned the sarcastic tone down a notch or two from the last reply to
one of Dave T's questions...

2005\06\01@093333 by Scott Dattalo

face
flavicon
face
On Wed, 2005-06-01 at 06:25 -0700, Scott Dattalo wrote:


> m1      db     (m1e-m1-1),"Message1
> m1e

There's a typo there - I forgot to add the closed quote while editing out
the actual message that I have in my source code.

Scott

2005\06\01@100133 by Alan B. Pearce

face picon face
>I use Pascal's string encoding method by making the first
>byte be the length of the string.
...
>
>  const char *Messages[] = {m1,m2,m3,m4};
>
>(It's a little harder to get C to automatically figure out
>the length of a string and encode it in the Pascal style.)

I done something similar, but used C style strings with a null byte at the
end, then scanned the string until I reached the null.

2005\06\01@164836 by Scott Dattalo

face
flavicon
face
Alan B. Pearce wrote:
>>I use Pascal's string encoding method by making the first
>>byte be the length of the string.
>
> ...
>
>> const char *Messages[] = {m1,m2,m3,m4};
>>
>>(It's a little harder to get C to automatically figure out
>>the length of a string and encode it in the Pascal style.)
>
>
> I done something similar, but used C style strings with a null byte at the
> end, then scanned the string until I reached the null.

That works too as long as you know your strings don't have intentional
0's. In my case, this same routine sends arbitrary binary data.

Scott

2005\06\02@033902 by Alan B. Pearce

face picon face
>> I done something similar, but used C style strings with a null byte at
the
>> end, then scanned the string until I reached the null.
>
>That works too as long as you know your strings don't have intentional
>0's. In my case, this same routine sends arbitrary binary data.

fair enough, in my case it was only printable characters.

More... (looser matching)
- Last day of these posts
- In 2005 , 2006 only
- Today
- New search...