Searching \ for '[PIC] 18F4680 table reads' 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: '18F4680 table reads'.

Exact match. Not showing close matches.
PICList Thread
'[PIC] 18F4680 table reads'
2008\04\20@200606 by alan smith

picon face
>From what I can tell...you can only read on even address boundaries for table reads?  So if I have a counter that I am incrementing for a table read, I am forced to do a 2x on the counter value in order to index into the table?
     
---------------------------------
Be a better friend, newshound, and know-it-all with Yahoo! Mobile.  Try it now.

2008\04\20@212903 by Jinx

face picon face
> From what I can tell...you can only read on even address boundaries
> for table reads?  So if I have a counter that I am incrementing for a
> table read, I am forced to do a 2x on the counter value in order to
> index into the table?

tblrd*+ might be one option

        clrf     tblptru       ;user names table address
        mov      high(user),tblptrh
        clrf     tblptrl

usr_srch tblrd*+                ;get table character
        movfw    tablat
        xorwf    postinc0,w    ;compare with string character
        bnz      nxt_usr       ;no match, try new string
        decfsz   cnt1          ;field count
        bra      usr_srch

But, yes, otherwise all byte addressing on the 18F is 16-bit, say
for RETLW strings

        movlw   d_text+.01   ;send CMEE=1, report << ERROR >>
        movwf   pclath
        clrf    cnt1         ;character address
getcmee  movf    cnt1,w
        call    cmee         ;get character
        xorlw   0xff         ;test for e-o-s
        bz      cmee_r       ;yes
        xorlw   0xff         ;no
        outw                 ;transmit
        call    write_d      ;display
        incf    cnt1         ;<<<<<<<<<<<
        incf    cnt1         ;<<<<<<<<<<<
        bra     getcmee

cmee     addwf  pcl           ;CMEE=

        retlw  "C"
        retlw  "M"
        retlw  "E"
        retlw  "E"
        retlw  "="
        retlw  "1"
        retlw  .13
        retlw  0xff

2008\04\21@030706 by Picbits Sales

flavicon
face
Just do a table read twice under the same counter/loop and store the odd
value in a seperate variable.

Dom
{Original Message removed}

2008\04\21@130504 by alan smith

picon face
I'll have to try that and see if it works.  Presently I am just doubling the pointer address, and it works fine but seems like there ought to be a better way.  Besides, then I could use half the memory that I am now.

Picbits Sales <spam_OUTsalesTakeThisOuTspampicbits.co.uk> wrote:  Just do a table read twice under the same counter/loop and store the odd
value in a seperate variable.

Dom
{Original Message removed}

2008\04\21@154749 by Jan-Erik Soderholm

face picon face
alan smith wrote:

> I'll have to try that and see if it works.
> Presently I am just doubling the pointer address,
> and it works fine but seems like there ought to be
> a better way.  Besides, then I could use half
> the memory that I am now.

I don't understand. Are you saying that the table-
instructions does not work "as documented" ?
You should be able to read any *byte* in Flash.

>>> From what I can tell...

How do you tell ?

>>> you can only read on even address boundaries for
>>> table reads?

That is not as it's documented in the data sheet.

Regards,
Jan-Erik.


>
> Picbits Sales <.....salesKILLspamspam@spam@picbits.co.uk> wrote:  Just do a table read twice under the same counter/loop and store the odd
> value in a seperate variable.
>
> Dom
> {Original Message removed}

2008\04\21@183009 by Jinx

face picon face
> > Presently I am just doubling the pointer address, and it works
> > fine but seems like there ought to be a better way.  Besides,
> > then I could use half the memory that I am now

I'm not sure what you're calling a table, but "half the memory" seems
to imply that you're using DT / RETLW and the type of routine below

Note that you must increment the pointer twice because the call to
"text" affects PCL. 'RETLW value' is a two-byte,16-bit, entity on the
18F (instruction and value), unlike 12F/16F which have the whole
thing in one 14-bit byte. This routine does not check for PCL rollover
BTW

        movlw   text_add   ;text address
        movwf   pclath
        clrf    pointer    ;character pointer
gettext  movfw   pointer
        call    text
        xorlw   0xff       ;find terminator
        bz      done       ;yes, finished
        xorlw   0xff       ;no, restore character

;do here what you will with retrieved character

        incf    pointer    ;pointer + 1
        incf    pointer    ;pointer + 1
        bra     gettext    ;get next character

done     more code

 org text_add

text     addwf   pcl

dt "text string",0xff       ;string + terminator

==================

> I don't understand. Are you saying that the table instructions
> does not work "as documented" ? You should be able to read
> any *byte* in Flash

And, of course, you can. DATA storage is half that of DT, as
what is stored is pure data, without an attached RETLW, eg

org sim_data

  data  "AN01 S 15000 3",0x0d30,0x0000

Note a quirk that data inside the "" will store in flash in the order
written, but that outside of the "" you must reverse bytes. In the
above example, 0x30 will preceed 0x0d in memory. Example
above needed to be done this way as 0x0d is unprintable

Read data with something like

        mov     upper(sim_data),tblptru  ;table base address ****
        mov     high(sim_data),tblptrh
        mov     low(sim_data),tblptrl

read     tblrd*+               ;get entry, post-increment pointer
        movf    tablat,w      ;or movff tablat,register

;do here what you will with retrieved character
;test for number of characters, end-of-string, whatever

        bra     read          ;loop

**** mov macro

mov      macro   litval,file
        movlw   litval
        movwf   file
        endm


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