[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-gcc-list] program memory
From: |
Gary Douglas |
Subject: |
[avr-gcc-list] program memory |
Date: |
Thu, 29 Dec 2005 10:39:26 -0700 |
I'm having issues with gcc and strings in progmem space. And Studio,
but
that's another issue
This...
const prog_char Display_Test_String[] PROGMEM = "jhakjldf";
... in theory, produce a null terminated string in program memory space.
If I
do this:
char * pointer;
strcpy_P(Display_Buffer,Display_Test_String);
pointer = Display_Test_String;
then Display_Buffer gets the proper contents of Display_Narrow and
everything
is happy happy. If, you've got bags of ram.
This doesn't work:
PGM_P pointer_P;
pointer_P = Display_Test_String;
You look at the contents of it with AVR Studio, it says that all the
values
are in SRAM (which it should not be) and pumps garbage out on the SPI
port
(where all this stuff is going).
But its says, of course, that the type of the variable is const
prog_char[]....
And I was blaming the display for being stupid.
This, however, works.
PGM_P pointer_P;
char *pointer;
char Display_Buffer[16];
strcpy_P(Display_Buffer,Display_Test_String);
pointer = &Display_Buffer;
pointer_P = Display_Test_String;
while (pgm_read_byte( pointer_P )) { // have we hit NULL yet?
while(CS_VFD_BUSY); // wait for display
temp = pgm_read_byte( pointer_P++ );
pointer++;
SPI_BUFFER = temp; // load up the SPI
while (!(SPSR & (1<<SPIF))); // wait for SPI to
finish
}
(I think I'm missing a '&' somewhere... but its late).
This is the only way you can see what is going on with the debugger.
Apparently, Studio insists that everything on the watch has to be in the
SRAM
- or am I wrong?
So, is there any way to see what the correct values for pointer_P are in
the
debugger without loading up a bunch of temp variables in SRAM?
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [avr-gcc-list] program memory,
Gary Douglas <=