| View previous topic :: View next topic |
| Author |
Message |
Ttelmah Guest
|
|
Posted: Thu May 29, 2008 2:51 pm |
|
|
Not opcodes (they are no longer instructions when stored this way). Look at the ROM data list, at the end of the .lst file.
This does work.
I have just finished a program, with over 5KB of arrays stored this way, and they are all working fine. You have to be doing something in the code you use to access the arrays that is causing problems.
Best Wishes |
|
 |
picerno Guest
|
|
Posted: Fri May 30, 2008 11:02 am |
|
|
ok I have found data in .lst file.
Today I have noticed that when I put more of 200 elements the program works
this works
| Code: |
char ROM test[2][100] = {"abcde","fghil"};
char ROM *ptr;
void main()
{
int8 i;
int8 data;
ptr = &test[1];
for(i=0; i<6; i++)
{
data = *ptr++;
delay_ms(1);
}
}
|
this works
| Code: |
char ROM test[2][5000] = {"abcde","fghil"};
char ROM *ptr;
void main()
{
int8 i;
int8 data;
ptr = &test[1];
for(i=0; i<6; i++)
{
data = *ptr++;
delay_ms(1);
}
}
|
In conclusion it doesn't work with arrays between 16 and 200 elements
The code is always the same I cannot do anything to cause a problem |
|
 |
future_ Guest
|
|
Posted: Thu Dec 31, 2009 4:53 pm |
|
|
Following this thread, I am trying to use pointer to structs.
| Code: | typedef struct _rom_ {
char aa;
char bb;
};
struct _rom_ ROM teste = { 100, 200 }; // correctly placed in flash
ROM struct _rom_ *ptr;
char p;
void main (void) {
ptr = teste;
p = ptr->aa; // always point to ram!
while(1);
} |
I tried a few combinations but the pointer always point to ram and the compiler generates code for FSR0.
The OP code also does not work with printf because of the same reason. |
|
 |
Gavin Pinto
Joined: 18 Oct 2009 Posts: 27 Location: Australia
|
|
Posted: Wed Feb 03, 2010 9:52 pm |
|
|
| Ttelmah wrote: | The 'key' perhaps, is to understand the history.
Originally, none of the PIC's had code to allow the ROM to be directly accessed. Best Wishes |
can you let us know examples of which PIC devices which have had the code changes?Can you give some dates when changes occured?
When did ccs implement compiler changes? _________________ Clear Logic |
|
 |
Ttelmah Guest
|
|
Posted: Thu Feb 04, 2010 3:29 am |
|
|
It is not really a 'date' thing.
Chips that allow you to directly reprogram/verify the program memory from code, (support a bootloader), generally allow you to also read the memory.
Look in the data sheet for the chip. Look for a section entitled 'Reading flash program memory'. If this section is present, then the chip has this feature.
A few older chips, though 'flash' based, require an external supply to develop the programming voltage needed, so can't reprogram themselves. Then there are some other 'intermediate' versions, that can develop the voltage, but don't support reading from inside the code.
Best Wishes |
|
 |
Gavin Pinto
Joined: 18 Oct 2009 Posts: 27 Location: Australia
|
|
Posted: Thu Feb 04, 2010 11:15 pm |
|
|
| Ttelmah wrote: | It is not really a 'date' thing.
Chips that allow you to directly reprogram/verify the program memory from code, (support a bootloader), generally allow you to also read the memory.
Look in the data sheet for the chip. Look for a section entitled 'Reading flash program memory'. If this section is present, then the chip has this feature.
A few older chips, though 'flash' based, require an external supply to develop the programming voltage needed, so can't reprogram themselves. Then there are some other 'intermediate' versions, that can develop the voltage, but don't support reading from inside the code.
Best Wishes
|
What are the differences with string manipulation when reading from RAM and ROM. After storing data in program memory space what string manipulation reading fuctions can you use?
How do you read a string or string array in user memory space with the ccs functions ? Can you give simple working examples that I can cut and paste to compile. Please show all the differences with keyword 'rom' or 'ROM' and keyword 'const'. Can you list all advantages with each method ?
.sym output file only shows rom keyword data in the heading of "user memory space". const keyword data is not under that heading.
Compiler version I use is latest the PCH version. No #device statements related to ROM settings are entered. _________________ Clear Logic |
|
 |
bkamen
Joined: 07 Jan 2004 Posts: 1619 Location: Central Illinois, USA
|
|
Posted: Fri Feb 05, 2010 1:17 am |
|
|
In the well known world of microprocessors, RAM holds programs and data.
So jumping or reading around in memory is addressing the same space whether be it data or program instructions.
(thus one of the problems with buffer overflows. You can jump to a spot in memory that's data and crash -- Or you can gather too much data that extends into program instructions and crash.)
With PIC (or any harvard architecture) the program (what executes) and the data it operates on are in different memory spaces.
So the problem is, how do you look back at constants in program space with pointers that point into RAM. You don't --- without some trickery and rules that have limitations.
Eventually, the flash parts that allow self-programming came along that have a window in RAM Space (SFR) that allow for a window back into flash.
NOW you can read program space (at a cost) almost like reading ram. (just more busy) _________________ Dazed and confused? I don't think so. Just "plain lost" will do. :D |
|
 |
Gavin Pinto
Joined: 18 Oct 2009 Posts: 27 Location: Australia
|
|
Posted: Fri Feb 05, 2010 2:01 am |
|
|
| bkamen wrote: |
With PIC (or any harvard architecture) the program (what executes) and the data it operates on are in different memory spaces.
NOW you can read program space (at a cost) almost like reading ram. (just more busy) |
Most of us understand that PC is harvard architecture with separate data and program memory spaces.
We just need some clarity on what CCS compiler is actually doing and how the keywords and new features are working with rom program space.
In other words good examples showing subtle details of using the new features. _________________ Clear Logic |
|
 |
bkamen
Joined: 07 Jan 2004 Posts: 1619 Location: Central Illinois, USA
|
|
Posted: Fri Feb 05, 2010 8:10 am |
|
|
| Gavin Pinto wrote: | | bkamen wrote: |
With PIC (or any harvard architecture) the program (what executes) and the data it operates on are in different memory spaces.
NOW you can read program space (at a cost) almost like reading ram. (just more busy) |
Most of us understand that PC is harvard architecture with separate data and program memory spaces.
We just need some clarity on what CCS compiler is actually doing and how the keywords and new features are working with rom program space.
|
I don't mean to be argumentative, but with all the inquiries as to this very topic (and that Ttelmah said almost what I said on the previous page of this thread and still the question is "when and where") shows a lack of understanding by the newer PIC user community.
Programming Microcontrollers is just like writing a driver for windows or linux in the sense that you are interfacing with the hardware typically on a very intimate level. Which is why most programmers hate writing drivers (I've heard anyway - I'm a hardware guy though, so I love it).
because this is a microcontroller, the environment for developing code requires a deeper understanding of what is going on. that can only come from study and experimentation.
I can tell a LOT of users come here with the "I need answers. Someone give it to me" kind of attitude without having looked at the LST file first. It's ASM, it's scary... I know.
But it has to be done. Write a program, compile it and then look at the LST file. THEN you will truly get an idea for what's going on under the hood in a way better than most could explain it.
The LST files are great as they show step by step; THIS C generates THIS ASM. Line by line.
These are microcontrollers. It's not the same as writing for windows in visual basic as some might think.
--Ben _________________ Dazed and confused? I don't think so. Just "plain lost" will do. :D |
|
 |
|