Searching \ for '[PIC]: Table read troubles' 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: 'Table read troubles'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: Table read troubles'
2002\04\10@131207 by Joris van den Heuvel

flavicon
face
Hey everybody,

I'm having a slight problem reading a large table in an F876. I must be overlooking something.

There's an index, b_temp, to a table of 480 values, though future enhancement requires 960 values. Values are needed 4 at a time, so the index ranges from 0-119. It's first multiplied by 4 and then added to the base address of the table. The results are placed in 4 registers, p0buf to p3buf. What happens is this: values, even consecutive ones, are read from the wrong places, and from an adjacent table, similar in size.

The table's base address is a multiple of 4 (by compiler directive), so reading four consecutive values never causes a page wrap.

Below is a piece of the code, I hope it's readable.

I have applied small-table reads before, and with succes. This larger one puzzles me, however, although the problem doesn't seem to be related to size. Any help would mean a great deal to me, as I have very little time left to solve this problem.

Thanks!

Regards,
Joris.


gettb
       clrf   a_temp
       bcf    STATUS,C
       rlf    b_temp,F
       rlf    a_temp,F
       rlf    b_temp,F
       rlf    a_temp,F
readt1
       movlw  (high table_1)
       addwf  a_temp,W
       movwf  PCLATH
       movlw  (low table_1)
       addwf  b_temp,W
       call   table
       movwf  l0pbuf
       incf   b_temp,F
       movf   b_temp,W
       call   table
       movwf  l1pbuf
       incf   b_temp,F
       movf   b_temp,W
       call   table
       movwf  l2pbuf
       incf   b_temp,W
       call   table
       movwf  l3pbuf
       return
table
       movwf  PCL

;table_1 is located away from the code, but within the same 2K block.

table_1
       dt 1,2,3,4
       dt 5,6,7,8    etc.





_______________________________________________________________
"Bass is the basis of all that is music"

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email spam_OUTlistservTakeThisOuTspammitvma.mit.edu with SET PICList DIGEST in the body


2002\04\10@133823 by Benjamin Bromilow

flavicon
face
gettb
[cropped].... no problems here
readt1
       movlw  (high table_1)
       addwf  a_temp,W
       movwf  PCLATH
       movlw  (low table_1)
       addwf  b_temp,W

! be aware that you're putting this back into W not F so you need to re-add
it.....

       call   table
       movwf  l0pbuf

.... here
.... unless you make the above addwf b_temp,F
... otherwise subsequent calls will be wrong unless you make the table start
on a page break

       incf   b_temp,F
       movf   b_temp,W
       call   table
       movwf  l1pbuf
       incf   b_temp,F
       movf   b_temp,W
       call   table
       movwf  l2pbuf
       incf   b_temp,W
       call   table
       movwf  l3pbuf
       return
table
       movwf  PCL

;table_1 is located away from the code, but within the same 2K block.

table_1
       dt 1,2,3,4
       dt 5,6,7,8    etc.





_______________________________________________________________
"Bass is the basis of all that is music"

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email .....listservKILLspamspam@spam@mitvma.mit.edu with SET PICList DIGEST in the body

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email listservspamKILLspammitvma.mit.edu with SET PICList DIGEST in the body


2002\04\10@141623 by Andrew Warren

flavicon
face
Joris van den Heuvel <.....PICLISTKILLspamspam.....mitvma.mit.edu> wrote:

{Quote hidden}

   Joris:

   Adding a_temp to the MSB of the table address isn't enough.
   Unless your table is guaranteed to start on a page boundary, you
   need to do a full 16-bit addition (a_temp:btemp + table1) to
   determine the proper value of PCLATH.

   -Andy

=== Andrew Warren -- EraseMEaiwspam_OUTspamTakeThisOuTcypress.com
=== Principal Design Engineer
=== Cypress Semiconductor Corporation
===
=== Opinions expressed above do not
=== necessarily represent those of
=== Cypress Semiconductor Corporation

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email listservspamspam_OUTmitvma.mit.edu with SET PICList DIGEST in the body


2002\04\10@142001 by Olin Lathrop

face picon face
>>
gettb
       clrf   a_temp
       bcf    STATUS,C
       rlf    b_temp,F
       rlf    a_temp,F
       rlf    b_temp,F
       rlf    a_temp,F
readt1
       movlw  (high table_1)
       addwf  a_temp,W
       movwf  PCLATH
       movlw  (low table_1)
       addwf  b_temp,W
       call   table
       movwf  l0pbuf
       incf   b_temp,F
       movf   b_temp,W
       call   table
       movwf  l1pbuf
       incf   b_temp,F
       movf   b_temp,W
       call   table
       movwf  l2pbuf
       incf   b_temp,W
       call   table
       movwf  l3pbuf
       return
table
       movwf  PCL

;table_1 is located away from the code, but within the same 2K block.

table_1
       dt 1,2,3,4
       dt 5,6,7,8    etc.
<<

I see lots of problems here.  Please send email in PLAIN TEXT format to make
it easy to reply to.

It would also help if you commented your code.  I can see what the code
does, but I'd like to know what you intended it to do.  Often the exercise
of describing what each line is supposed to do will cause you to see the
bugs yourself.


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

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email @spam@listservKILLspamspammitvma.mit.edu with SET PICList DIGEST in the body


2002\04\10@151421 by Joris van den Heuvel

flavicon
face
Phew, that was quick!

You're right, I forgot to actually store the addition in b_temp. How could I
not have seen that?

I had looked for more obvious mistakes, like improper handling of PCLATH,
which often causes erratic program execution (in MY code that is...)

Thanx Benjamin!



Andrew : I'll definitely check the suggestions, but I think I'll try
Benjamin's one first. Thanks, anyway!

Olin: sorry about the unreadability. I tried to send plain text but
obviously wasn't doing so. To be honest I haven't got a clue about email
formats.

Regards,
Joris.




{Original Message removed}

2002\04\10@154315 by Olin Lathrop

face picon face
> Olin: sorry about the unreadability. I tried to send plain text but
> obviously wasn't doing so. To be honest I haven't got a clue about email
> formats.

Might be a good thing to learn before sending more messages to 2000 people.
By the way, I had no problem replying to this message and having Outlook
Express automatically put the "> " in front of each of your lines.  Perhaps
you did fix something.


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

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email KILLspamlistservKILLspamspammitvma.mit.edu with SET PICList DIGEST in the body


2002\04\10@163107 by Joris van den Heuvel

flavicon
face
> Might be a good thing to learn before sending more messages to 2000
people.

Of course you're right. But this is a somwhat controversial topic.

> By the way, I had no problem replying to this message and having Outlook
> Express automatically put the "> " in front of each of your lines.
Perhaps
> you did fix something.

I guess so. I wouldn't know ;-)

Maybe I did screw up the format of the initial post myself, and when
replying to Benjamin's I just used the standard plain-text format.


Regards,
Joris.

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email RemoveMElistservTakeThisOuTspammitvma.mit.edu with SET PICList DIGEST in the body


2002\04\10@205541 by Bob Ammerman

picon face
*** UNTESTED CODE ***

; compute a_temp:b_temp = 4 * b_temp

   clrf    a_temp
   bcf    STATUS,C
   rlf      b_temp,F
   rlf      a_temp,F
   rlf      b_temp,F
   rlf      a_temp

; compute PCLATH:b_temp = addr(table_1) - 1 + a_temp:b_temp

   movlw    low(table_1-1)
   addwf    b_temp,F
   movf      a_temp,W
   skpnc
   incf        a_temp,W
   addlw    high(table_1-1)
   movwf   PCLATH

; fetch the four bytes

   call        fetch
   movwf    byte_1
   call        fetch
   movwf    byte_2
   call        fetch
   movwf    byte_3
   call        fetch
   movwf    byte_4
   return

fetch:

; increment PCLATH:b_temp

   incf        PCLATH,f
   incfsz    b_temp,f
   decf      PCLATH,f

; index into the table

   movf     b_temp,W
   movwf   PCL

; And then the table

table_1:
   .....


Bob Ammerman
RAm Systems

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email spamBeGonelistservspamBeGonespammitvma.mit.edu with SET PICList DIGEST in the body


2002\04\10@210403 by Bob Ammerman

picon face
Oops... I missed the statement that the table is certain to be on a four
byte boundary. That certainly simplifies thing a little bit:

*** UNTESTED CODE ***

; compute W:b_temp = 4 * b_temp

   clrf    a_temp
   bcf    STATUS,C
   rlf      b_temp,F
   rlf      a_temp,F
   rlf      b_temp,F
   rlf      a_temp,W        ; msbits to W

; compute PCLATH:b_temp = addr(table_1)  + W:b_temp

   addlw    high(table_1)
   movwf    PCLATH
   movlw    low(table_1)
   addwf    b_temp,F
   skpnc
   incf        PCLATH

; fetch the four bytes

   decf      b_temp,F
   call        fetch
   movwf    byte_1
   call        fetch
   movwf    byte_2
   call        fetch
   movwf    byte_3
   call        fetch
   movwf    byte_4
   return

fetch:
  incf        b_temp,F
  movf     b_temp,W
  movwf   PCL

; And then the table

table_1:
   .....


Bob Ammerman
RAm Systems

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email TakeThisOuTlistservEraseMEspamspam_OUTmitvma.mit.edu with SET PICList DIGEST in the body


2002\04\11@162359 by Joris van den Heuvel

flavicon
face
Bob, you're wonderful!

I just tested the program with the modifications you suggested and it worked
right away. I didn't copy and paste, but read it, understood it, and rewrote
it myself.

These were the problems: I didn't account for page wraps when calculating
the table address, and I forgot to store my b_temp for consecutive reads.
That's the story.

Probably next week or so, I'll post pictures. The project I've been working
on is a revised version of my Scandisplay (see http://go.to/joris.bass).
It's a moving info sign at my company's Intertraffic exhibition stand this
Monday.

Thanks everyone!

Regards,
Joris.




{Original Message removed}

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