|
|
View previous topic :: View next topic |
Author |
Message |
jack11 Guest
|
read_program_eeprom |
Posted: Sat Mar 27, 2004 6:42 am |
|
|
I want to use the unused portion of program memory as a storage area. Much like a dynamic RAM. Board space precludes using external memory.
During normal operation does the chip ever use program ROM that is not programmed? In other words, if I have lets say 500 bytes of unused ROM and I write and read to it as if it were an external memory do I run the risk of overwriting needed info (stack,scratch variables,etc.)? Also, what version do you need to use read_program_memory. I get the compiler message "Undefined identifier"?
Thanks |
|
|
Ttelmah Guest
|
Re: read_program_eeprom |
Posted: Sat Mar 27, 2004 6:54 am |
|
|
jack11 wrote: | I want to use the unused portion of program memory as a storage area. Much like a dynamic RAM. Board space precludes using external memory.
During normal operation does the chip ever use program ROM that is not programmed? In other words, if I have lets say 500 bytes of unused ROM and I write and read to it as if it were an external memory do I run the risk of overwriting needed info (stack,scratch variables,etc.)? Also, what version do you need to use read_program_memory. I get the compiler message "Undefined identifier"?
Thanks |
You are looking at the memory in the wrong way. This is _ROM_, not RAM. So, the chip does not use this memory, but what you want to do with it will lead to problems. Writing to this memory takes time, and only a very limited number of write cycles are allowed. Typically, the internal program memory, takes up to 8mSec to write a single byte, so it cannot be used like RAM, and only about 1000 write cycles are allowed, before you run the risk of the cell starting to 'lose charge', or 'leak', and damage other data in the memory...
The 'read_program_eeprom' function, is only available on chips that support the ability (generally the 'F' chips).
I'm afraid you need to rethink significantly. Using this memory to store very occassionally changed 'near constants' is fine. Trying to use it to replace RAM, is a formula for disaster.
Best Wishes |
|
|
jack11 Guest
|
|
Posted: Sat Mar 27, 2004 11:51 am |
|
|
Thanks,
I hadn't thought of the write cycle issue. What is your opinion on storing true constants in this manner. They would be written when the chip is progammed and only read from memory. Not written.
Thanks again |
|
|
Neutone
Joined: 08 Sep 2003 Posts: 839 Location: Houston
|
|
Posted: Sat Mar 27, 2004 1:36 pm |
|
|
jack11 wrote: | Thanks,
I hadn't thought of the write cycle issue. What is your opinion on storing true constants in this manner. They would be written when the chip is progammed and only read from memory. Not written.
Thanks again |
This is part of some code I had at hand. Like this works well.
// MODBUS exception codes
#define Illegal_Function 1
#define Illegal_Data_Address 2
#define Illegal_Data_Value 3
#define Slave_Device_Failure 4
#define Acknowledge 5
#define slave_device_Busy 6
#define Negative_Acknoledge 7
#define Memory_Parity_Error 8
/* Table of CRC values for high order byte */
const char Table_CRC_Hi[256] = {
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81,
0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0,
0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01,
0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41,
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81,
0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0,
0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01,
0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40,
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81,
0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0,
0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01,
0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,
0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81,
0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0,
0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01,
0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81,
0x40
} ; |
|
|
Ttelmah Guest
|
|
Posted: Sat Mar 27, 2004 3:51 pm |
|
|
jack11 wrote: | Thanks,
I hadn't thought of the write cycle issue. What is your opinion on storing true constants in this manner. They would be written when the chip is progammed and only read from memory. Not written.
Thanks again |
This is fine.
You are doing this when you declare an initialised array as 'const'....
Best Wishes |
|
|
|
|
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
|