avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [avr-gcc-list] why the pointer get a error address?


From: Phillip Vogel
Subject: RE: [avr-gcc-list] why the pointer get a error address?
Date: Sun, 15 Feb 2004 21:02:48 -0500

Actually, I made a mistake in the last posting, the read function should
look like ( note the "+I" added:

char readpattern(int i)  // read a byte from flash 
{
        return (char)pgm_read_byte(pattern + i);
}

I don't see any reason why this wouldn't work with as many arrays as you
want.

Phillip


> -----Original Message-----
> From: address@hidden 
> [mailto:address@hidden On Behalf Of whiteman
> Sent: Monday, February 16, 2004 12:00 AM
> To: address@hidden
> Subject: RE: [avr-gcc-list] why the pointer get a error address?
> 
> 
> Hi,Phillip Vogel!
> 
>                 My project have many independents array in 
> program space,they will be read in defferece subroutine,so I 
> can't combine them together.I would try the function you mentioned.
> 
> 
> ======= 2004-02-15 17:48:00:=======
> 
> >I can't believe I can actually answer this:
> >
> >First, define you array like this:
> >
> >const char pattern[]  PROGMEM = {
> >  1,2,3,a,b,c
> >};
> >
> >The data can go on for several lines (mine goes on for a couple of 
> >thousand lines).
> >
> >Then to access the data, us a function like this:
> >
> >char readpattern(int i)       // read a byte out of the 
> pattern array in
> >flash
> >{
> >     return (char)pgm_read_byte(pattern);
> >}
> >
> >I forget where I found this, probably in the FAQ, but it DOES work.
> >
> >Phillip Vogel
> >Bartal Design Group, Inc.
> >318 Marlboro Road Englewood, NJ 07631-1416
> >Phone: 201-567-1343   Fax: 201-568-2891
> >Cell: 201-232-5208
> >mailto:address@hidden  http://www.VisualConductor.com
> >Ask me about the Visual Conductor
> >
> >> -----Original Message-----
> >> From: address@hidden 
> >> [mailto:address@hidden On Behalf Of whiteman
> >> Sent: Friday, February 13, 2004 8:28 PM
> >> To: avr-gcc-list
> >> Subject: [avr-gcc-list] why the pointer get a error address?
> >> 
> >> 
> >> hi,all!
> >>    I defined a array in program space and a pointer to this array.
> >> eg:
> >> 
> >> 
> >> uint8_t test_array[] PROGMEM = {
> >>    1,2,3,4,5,6,7
> >> };
> >> const prog_char *character_pnt;
> >> 
> >> void main(void)
> >> {
> >>    charcter_pnt = test_array;
> >>    ;
> >>    ;
> >> }
> >> 
> >> but when I simulated with avr_studio, I found the 
> "character_pnt" get 
> >> a error address,The "*character_pnt" isn't equal to 1.why?
> >> 
> >>    
> Regards                                
>         whiteman
> address@hidden
>           2004-02-16
> 
> 
> 
> 
> 
> _______________________________________________
> avr-gcc-list mailing list
> address@hidden 
> http://www.avr1.org/mailman/listinfo/avr-gcc-> list
> 
> 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]