Searching \ for '[PIC] Program Memory Data Table' 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/microchip/memory.htm?key=data
Search entire site for: 'Program Memory Data Table'.

Exact match. Not showing close matches.
PICList Thread
'[PIC] Program Memory Data Table'
2011\09\12@214123 by Josh Koffman

face picon face
Hi all.

I'm working on a project where I'd like to store a long sequence of
"steps" in program memory. These would be set at compile time, I'm not
using the self programming features of the chip. I've done this in the
past, but I recall that things didn't work exactly as I'd expected, so
I'm looking to verify that my expectations were accurate.

For my current project, there will be 4 (or possibly 7) bytes per
step, and 255 steps. That's a minimum of 1024 bytes in memory, which
should be fine, I have plenty left over. I'd like to be able to
maximize the space, and here's where I start to need help. Last time I
did a memory table it was for converting a digit to a pattern for
display on a seven segment LED. This was pretty easy as there were
only 10 works that I wanted to store. I did it like this:

--
LEDTable code_pack
; Data table to convert BCD to 7 segment, with some additions

    db     b'00111111'          ; 0
    db     b'00000110'          ; 1
    db     b'01011011'          ; 2
    db     b'01001111'          ; 3
    db     b'01100110'          ; 4
--

I was able to read this just fine using the TBLRD* command. Not too
bad for a few entries, but for over 1000, I'd like to avoid having to
give each their own line. I remember trying this method:

--
    db     b'00111111',b'00000110', b'01011011', b'01001111',                ; 0, 1, 2, 3
--

And having it fail. This might have been before I learned about
code_pack though.

So in theory, should I be able to use the "on one line" method shown
above? I'd like to do a separate line for each step, then have the 4
(or 7 entries) on each line. Alternatively I might go for 4 separate
blocks, so that I can use the same index and add it to 4 different
bases to get the values.

Thoughts?

Thank you!

Josh
-- A common mistake that people make when trying to design something
completely foolproof is to underestimate the ingenuity of complete
fools.
        -Douglas Adams

2011\09\12@224934 by IVP

face picon face
> So in theory, should I be able to use the "on one line" method

You could use 'data', eg

  data 0x0a0d,0xF0AA

or in binary

  data b'0000101000001101',b'1111000010101010'

Jo

2011\09\12@230237 by Josh Koffman

face picon face
On Mon, Sep 12, 2011 at 10:48 PM, IVP <spam_OUTjoecolquittTakeThisOuTspamclear.net.nz> wrote:
>> So in theory, should I be able to use the "on one line" method
>
> You could use 'data', eg
>
>   data 0x0a0d,0xF0AA
>
> or in binary
>
>   data b'0000101000001101',b'1111000010101010'

Ok, I didn't know I could specify the data directly in 16 bit numbers,
but that makes sense. The TBLRD* will return 8 bit values though,
correct? And my (possibly faulty) understanding is that it will read
the least significant byte first, so I'd have to take care to swap the
high and low bytes in the table - ie:

data 0xBYTE2BYTE1, 0xBYTE4BYTE3

Uh...how far off am I?

Josh
-- A common mistake that people make when trying to design something
completely foolproof is to underestimate the ingenuity of complete
fools.
        -Douglas Adams

2011\09\12@235147 by IVP

face picon face
> The TBLRD* will return 8 bit values though, correct?

Yes. TBLRD*+ advances by 1/2 word

> And my (possibly faulty) understanding is that it will read
> the least significant byte first, so I'd have to take care to
> swap the high and low bytes in the table - ie:
>
> data 0xBYTE2BYTE1, 0xBYTE4BYTE3
>
> Uh...how far off am I?

I got into an awful pickle using 'data' and ASCII strings with
unprintable characters (eg 0a, 0d) that were inserted as 0x
values when I forgot to do that

Jo

2011\09\13@003940 by Josh Koffman

face picon face
On Mon, Sep 12, 2011 at 11:51 PM, IVP <.....joecolquittKILLspamspam@spam@clear.net.nz> wrote:
>> And my (possibly faulty) understanding is that it will read
>> the least significant byte first, so I'd have to take care to
>> swap the high and low bytes in the table - ie:
>>
>> data 0xBYTE2BYTE1, 0xBYTE4BYTE3
>>
>> Uh...how far off am I?
>
> I got into an awful pickle using 'data' and ASCII strings with
> unprintable characters (eg 0a, 0d) that were inserted as 0x
> values when I forgot to do that

Could I list them separately though?

data 0xXX, 0xXX, 0xXX, 0xXX

Josh
-- A common mistake that people make when trying to design something
completely foolproof is to underestimate the ingenuity of complete
fools.
        -Douglas Adams

2011\09\13@022940 by Jan-Erik Soderholm

face picon face
Just trying to understand your issues. :-)

What is the problem with the actual number of lines
in the *source* ?

The end effect in the processor is the same, not ?

Yes, you need two (or any other even number of) values
on each data statement to avoid the blank filling
of the odd byte. But that didn't seemed to be your
primary concern ?

Jan-Erik.



Josh Koffman wrote 2011-09-13 03:35:
{Quote hidden}

> Jos

2011\09\13@023644 by IVP

face picon face
> Could I list them separately though?
>
> data 0xXX, 0xXX, 0xXX, 0xXX

If you do it that way they'll be in order, but in consecutive words

org 0x4000

 data 0x01,0x02,0x03,0x04

4000 0001
4002 0002
4004 0003
4006 0004

 data 0x0102,0x0304

4000 0102
4002 0304

2011\09\14@010534 by Josh Koffman

face picon face
On Tue, Sep 13, 2011 at 2:35 AM, IVP <joecolquittspamKILLspamclear.net.nz> wrote:
>> Could I list them separately though?
>>
>> data 0xXX, 0xXX, 0xXX, 0xXX
>
> If you do it that way they'll be in order, but in consecutive words
>
>  org 0x4000
>
>  data 0x01,0x02,0x03,0x04
>
> 4000 0001
> 4002 0002
> 4004 0003
> 4006 0004

Which means every second TBLRD* is 0x00. Not great. I guess I could
multiply by two, but that seems to be getting overly complicated just
to make the source look clean.

>  data 0x0102,0x0304
>
> 4000 0102
> 4002 0304

Ok, but if I read this using sequential table reads, I'd get (in
sequence): 0x02, 0x01, 0x04, 0x03, correct?

To answer Jan-Erik's questions, I'm trying to find a way to put a lot
of data in my source without it getting too visually hard to follow.
All the while trying to make sure that it's easy to read
programmatically. I find it non intuitive when looking at the data
block defined in the code to have to remember to flip every second
byte. That said, having every second byte stored as a zero in the
actual memory isn't great either.

I thought that there was some combination of db and code_pack that
made this work, but I'm just as confused about it as I was before. I'm
going to do some playing around and hopefully I'll figure it out!

Josh
-- A common mistake that people make when trying to design something
completely foolproof is to underestimate the ingenuity of complete
fools.
        -Douglas Adams

2011\09\14@024248 by IVP

face picon face
>> 4000 0102
>> 4002 0304
>
> Ok, but if I read this using sequential table reads, I'd get (in
> sequence): 0x02, 0x01, 0x04, 0x03, correct?

You could use a combination of TBLRD*- and TBLRD*+ and
modifying TBLPTR to access any byte in any order, ie skip to and
fro through flash instead of contiguouslly

> some combination of db and code_pack that made this work

There might be, never looked TBH

Another option might be a routine to read what the programmer
wrote, modify it (ie swap bytes) and then write it back in the little
endian order

Jo

2011\09\14@053233 by Bjarne Lassen

flavicon
face

----- Original Message ----- From: "Josh Koffman" <.....joshybearKILLspamspam.....gmail.com>
To: "Microcontroller discussion list - Public." <EraseMEpiclistspam_OUTspamTakeThisOuTmit.edu>
Sent: Tuesday, September 13, 2011 6:39 AM
Subject: Re: [PIC] Program Memory Data Table


On Mon, Sep 12, 2011 at 11:51 PM, IVP <joecolquittspamspam_OUTclear.net.nz> wrote:
{Quote hidden}

Could I list them separately though?

data 0xXX, 0xXX, 0xXX, 0xXX

Josh
-- A common mistake that people make when trying to design something
completely foolproof is to underestimate the ingenuity of complete
fools.
-Douglas Adams

Hi

Josh koffman wrote
>Could I list them separately though?

>data 0xXX, 0xXX, 0xXX, 0xXX


This makes sense when using Bytes and the reading sequence you've describe is correct    'data 0xBYTE2BYTE1, 0xBYTE4BYTE3'

I am in progress of making a controller to run two step motors to control my telescope. I need to ramp up gently and uses a DATA table with precalculated TMR- values. The step motors share the table and uses TMR0 and TMR1 for speed controll.  I used  Excell to make the tabel, approx 1600 words, and then copyed the values in 14 words /line, and  added 0x.... to every word, so they look like 0x23FA.. and so on, very tedious, it took an whole evening.  The TBLRD*+ and - gave me a real  headache, as I also used the table when ramping down. I am not shure if the pickup routine is working correctly yet. The routine tends to 'overshoot' at the end in either direction, because I also need be able to stop and start several times, in the middle of a ramp up or down.
I keep my Data  as 14 word/ line in order to make them readable when printing. I am using the 18F452 processor
I have not figured out how to calculate the Values 'on the fly' not given it much thoughts thoug, as i don't think there is time enough --
Bjarne Las

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