Searching \ for 'How to execute table reading ?' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: techref.massmind.org/techref/mems.htm?key=table
Search entire site for: 'How to execute table reading ?'.

Truncated match.
PICList Thread
'How to execute table reading ?'
1996\10\22@131703 by Dmitry Kiryashov

flavicon
face
Hi All.

Before I start using PIC I wrote programs for i8051 processors.
i8051 command set allow me to read from tables , allocated in program
memory.
For example:
---cut---
MOV DPTR, #ADDR ;Load start addr to DPTR register
MOV A, #DISPOSE ;Load offset to accumulator
MOVC A, @A+DPTR ;Load data from array with offset
....
ADDR: .DB 01h, 04h, 49h, 38h, 86h, 57h, 86h, 7Fh ;the are
     .DB 1Eh, AAh, A4h, B3h, E9h, 99h, 88h, 77h ;some data
---cut---
dispose=0 result A=01h; dispose=4 result A=86h; dispose=5 result A=57h
...

Are the same technique in the PIC proccesor's case ?
The are no_pins_available/no_time to read from external ROM
parallel/serial interfaced with PIC ?

WBW Dmitry.

1996\10\25@001029 by Barry Bine

picon face
Dmitry,

       I am not sure which PIC you are using.  Here's an exaple of how I do
tables on the PIC16C74:

;-----------------------------------------------------------------------
; BIT_MASK_
;       Returns a bit mask for the number in ix.  For example,
;       a 0 returns 00000001B and a 7 returns 10000000B.
;
; Input:
;       ix - 0-7
;
; Output:
;       W - mask
;
; Notes:
;       This routine must be located to avoid wrap-around of PCL.
;-----------------------------------------------------------------------

bit_mask_:
               movlw   $ >> 8          ; Set hi bits to that of
               movwf   PCLATH          ; current address.
               movf    ix,W
               addwf   PCL,F           ; Add offset to program counter.
               retlw   B'00000001'
               retlw   B'00000010'
               retlw   B'00000100'
               retlw   B'00001000'
               retlw   B'00010000'
               retlw   B'00100000'
               retlw   B'01000000'
               retlw   B'10000000'

;-----------------------------------------------------------------------


       As far as I know, using the RETLW instruction is the best way to
treat the PROGRAM ROM as DATA in tabular form.  This is probably the biggest
drawback of the chip's architecture.  I am sure others on the PIClist have
nifty ways of accessing data in ROM.  If you continue to use the PIC, you
will find other paradigm shifts that you will have to make.  All told
though, it isn't bad... the minor software hurdles you go through buy you a
cheap chip that is really fast.  Let macros be your friend.

       On this subject though, I still feel as though I must be missing
something.  Should we really have to jump through these hoops?  If anybody
out in PIClist land has something to say on this subject... I'd like to hear
it.  Or is this subject just old news on the PIClist?  We'll see.  In the
mean time, have fun PICking...

                                               - Barry

1996\10\25@122759 by Eric Rossello

flavicon
face
part 0 2395 bytes
----------
From:   Barry Bine[SMTP:spam_OUTbbineTakeThisOuTspamPRIMENET.COM]
Sent:   Friday, October 25, 1996 8:10 AM
To:     Multiple recipients of list PICLIST
Subject:        Re: How to execute table reading ?

Dmitry,

       I am not sure which PIC you are using.  Here's an exaple of how I do
tables on the PIC16C74:

;-----------------------------------------------------------------------
; BIT_MASK_
;       Returns a bit mask for the number in ix.  For example,
;       a 0 returns 00000001B and a 7 returns 10000000B.
;
; Input:
;       ix - 0-7
;
; Output:
;       W - mask
;
; Notes:
;       This routine must be located to avoid wrap-around of PCL.
;-----------------------------------------------------------------------

bit_mask_:
               movlw   $ >> 8          ; Set hi bits to that of
               movwf   PCLATH          ; current address.
               movf    ix,W
               addwf   PCL,F           ; Add offset to program counter.
               retlw   B'00000001'
               retlw   B'00000010'
               retlw   B'00000100'
               retlw   B'00001000'
               retlw   B'00010000'
               retlw   B'00100000'
               retlw   B'01000000'
               retlw   B'10000000'

;-----------------------------------------------------------------------


       As far as I know, using the RETLW instruction is the best way to
treat the PROGRAM ROM as DATA in tabular form.  This is probably the biggest
drawback of the chip's architecture.  I am sure others on the PIClist have
nifty ways of accessing data in ROM.  If you continue to use the PIC, you
will find other paradigm shifts that you will have to make.  All told
though, it isn't bad... the minor software hurdles you go through buy you a
cheap chip that is really fast.  Let macros be your friend.

       On this subject though, I still feel as though I must be missing
something.  Should we really have to jump through these hoops?  If anybody
out in PIClist land has something to say on this subject... I'd like to hear
it.  Or is this subject just old news on the PIClist?  We'll see.  In the
mean time, have fun PICking...

                                               - Barry

I think you need to be careful with interrupts during table read using the pcl register, the interrupts should be disable,  have look to MicroChip Application Note AN556.

Eric

1996\10\28@003822 by tjaart

flavicon
face
If you have more than one table, you can you can make use of MPASM's
addressing scheme as follows :

1) Use one look-up table for the offset of the look-up tables with
the     data
2) Use one lookup table with the page of the table (the value in PCLATH)
3) Define your different look-up tables

Al you have to make sure of, is that one table doesn't cross a page
boundary.

Before calling "Get_A_Character", load your desired table number into
"Table_Number", and the desired character offset into "Character_Index"

Here's the code :

Get_A_Character
       movf    Table_Number,w  ;Choose the table
       call    Table_Page
       movwf   PCLATH          ;Set up the page

       movf    Table_Number,w  ;Choose the table
       call    Table_Offset
       movwf   PCL             ;Set up the offset


ORG Anywhere

Table_Offset
       addwf   PCL,f
       dt (Table1&&0xff),(Table2&&0xff),(Table3&&0xff)

Table_Page
       addwf   PCL,f
       dt ((Table1>>8)&&0xff),((Table1>>8)&&0xff),((Table1>>8)&&0xff)

Table_1
       movf    Character_Index,w
       addf    PCL,f
       dt "This is table 1"
Table_2
       movf    Character_Index,w
       addf    PCL,f
       dt "This is table 2"
Table_3
       movf    Character_Index,w
       addf    PCL,f
       dt "This is table 3"

What do you guys (and gal's?) think?
--
Friendly Regards

Tjaart van der Walt
______________________________________________________________
|  Another sun-deprived R&D Engineer slaving away in a dungeon |
|WASP International GSM vehicle tracking and datacomm solutions|
|           +27-(0)11-622-8686 | http://wasp.co.za             |
|______________________________________________________________|

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