gnupic: Re: [gnupic] about data tables and shared variables


Previous by date: 30 Aug 2008 21:30:15 -0000 Re: [gnupic] about data tables and shared variables, Peter Stuge
Next by date: 30 Aug 2008 21:30:15 -0000 Re: [gnupic] about data tables and shared variables, Robert Pearce
Previous in thread: 30 Aug 2008 21:30:15 -0000 Re: [gnupic] about data tables and shared variables, Peter Stuge
Next in thread: 30 Aug 2008 21:30:15 -0000 Re: [gnupic] about data tables and shared variables, Robert Pearce

Subject: Re: [gnupic] about data tables and shared variables
From: Rob Pearce ####@####.####
Date: 30 Aug 2008 21:30:15 -0000
Message-Id: <200808302229.17415.rob@bdt-home.demon.co.uk>

On Saturday 30 August 2008, Lope Vega wrote:
> One of them is about data tables. I'm trying to drive 3 7-segment displays
> which I've got multiplexed. Since I don't really yet understand table
> reads/writes, and haven't seen an example which adequates to what I'm
> doing, I thought on using `computed gotos':

I notice somebody has already pointed out the need to set PCLATH. Nobody seems 
to have mentioned the word/byte addressing thing. Suffice to say that if 
you're using an 18F family device then each entry of your retlw table 
occupies two addresses, so you probably want to shift W left before adding it 
to PCL.

Alternatively you could use table reads. It would look something like this:

read_table:
 movwf  TBLPTRL
 movlw  high(table)
 movwf  TBLPTRH
 clrf   TBLPTRU
 tblrd  *
 movf   TABLAT,w
 return


datapage code 0x200    ; Force the table to a page boundary
 db     b'01000000', b'01111001'        ; 0 and 1
 db     b'00100100', b'00110000'        ; 2 and 3
 .... etc


Note that I've put two values on each line of the data. Unfortunately it 
appears that if you define a single byte in the code space then gpasm 
allocates a whole word for it. What you want is to allocate a byte per value, 
so you need to persuade gpasm to do that by supplying two values per line.

Hope that helps,
Rob

Previous by date: 30 Aug 2008 21:30:15 -0000 Re: [gnupic] about data tables and shared variables, Peter Stuge
Next by date: 30 Aug 2008 21:30:15 -0000 Re: [gnupic] about data tables and shared variables, Robert Pearce
Previous in thread: 30 Aug 2008 21:30:15 -0000 Re: [gnupic] about data tables and shared variables, Peter Stuge
Next in thread: 30 Aug 2008 21:30:15 -0000 Re: [gnupic] about data tables and shared variables, Robert Pearce


Powered by ezmlm-browse 0.20.