[En-Nut-Discussion] Reading Program Memory Arrays

peter.scandrett at transport.alstom.com peter.scandrett at transport.alstom.com
Fri Sep 27 03:07:19 CEST 2002


Hi Harald,

I'm new to the AVR product, so an experienced person may know a simple 
solution.

I'm having trouble with reading a 256 element 'u_short' array resident in 
program memory.

After some investigation I successfully created the data type I required, 
as follows. (I used the example in 'progmem.h' for inspiration.)
        #include    <progmem.h>

        #ifdef __cplusplus
        extern "C" {
        #endif

        typedef unsigned short int prog_ushort PROGMEM;

        #ifdef __cplusplus
        }
        #endif

I then was able to define my array in program memory, as follows.
        const   prog_ushort   ccitt_16_table[ ]     =
        {
                0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 
0x70e7,
                0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 
0xf1ef,
                0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 
0x62d6,
                :
                :
                0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 
0x1ef0
        };

However, when I came to read the values, I only found routines in the 
libraries and include files to read 'u_char' arrays, and no routines for 
reading 'u_short' arrays. Thus when I try to read 'ccitt_16_table[ 3 ]', I 
end up with '0x0063', not '0x3063' as expected.

Are there any efficient routines to read 'u_short', as there is for the 
'u_char' functionality in 'ina90.h'? Any help would be appreciated. So 
far, I find the inline assembler format very confusing, so I'm not yet 
able to create the necessary routines by myself.

With thanks,
Peter S

Peter Scandrett
Engineering Systems Department
ALSTOM Australia Limited
3 Bridge Street, Pymble, 2073, Australia
Phone (+612) 94 88 49 11      Fax (+612) 94 88 49 00
peter.scandrett at transport.alstom.com


CONFIDENTIALITY: This e-mail and any attachments are confidential and may 
be privileged. If you are not a named recipient, please notify the sender 
immediately and do not disclose the contents to another person, use it for 
any purpose or store or copy the information in any medium.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.egnite.de/pipermail/en-nut-discussion/attachments/20020927/cb39cb99/attachment.html>


More information about the En-Nut-Discussion mailing list