|
|
View previous topic :: View next topic |
Author |
Message |
Guest
|
write 2000 bytes in ROM and read it |
Posted: Sat Jan 05, 2008 10:12 am |
|
|
How can I write data in ROM with #ROM and get it ?
thanks a lot |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Jan 06, 2008 5:35 pm |
|
|
Here is a short program that shows how to do it. This example only
stores 20 bytes in ROM, but you can add more bytes in the #rom
declaration. Here's the output of this program on a terminal window:
Quote: | 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
Code: | #include <18F452.h>
#fuses XT,NOWDT,PUT,BROWNOUT,NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
#define DATA_ADDRESS 0x1000 // Start address for data
#define DATA_SIZE 20 // in bytes
#rom int8 DATA_ADDRESS =
{
0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19
}
//--------------------------------------
void display_data(int32 rom_address)
{
int i;
int8 buffer[100];
read_program_memory(rom_address, buffer, DATA_SIZE);
for(i = 0; i < DATA_SIZE; i++)
printf("%u ", buffer[i]);
}
//====================================
void main()
{
display_data(DATA_ADDRESS);
while(1);
} |
|
|
|
Ttelmah Guest
|
|
Posted: Mon Jan 07, 2008 3:00 am |
|
|
However, 'caveat', this only applies to chips that support reading of their program memory (most of the 'newer' chips). You can't do this on some older chips, because the support is not there in the processor instructions. On these, it is actually basically 'impossible'.
Best Wishes |
|
|
John P
Joined: 17 Sep 2003 Posts: 331
|
|
Posted: Mon Jan 07, 2008 9:27 am |
|
|
But is there a limit on how much data can be saved using a single #ROM directive, or the total amount of data which can be saved with multiple #ROM directives in the same program? I encountered a situation where I thought the compiler was refusing to accept more than a certain amount of data, but I solved the problem another way before I really reached an understanding of what was happening. I'd be curious to hear what limits exist, if any. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|