??? 10/23/07 18:22 Read: times |
#146096 - I'm using simple terms Responding to: ???'s previous message |
Andy Neil said:
RAM is what I don't recommend you use as code memory. But how do you suggest that the OP achieves his goal of loading code from an external store without using RAM?? One way it can be done is to have the code run from ROM, byte for byte, and to read values, the OP would use the MOVC instruction. I agree with you that a RAM and a ROM would be better than just a ROM, but a ROM will be just enough to have the same stored code run every time the power is on. Mike Stegmaier said:
when the system is completely off, the RAM will reset, and the data at each address of the RAM will contain the same value rather than your code. The RAM doesn't actually perform a tidy reset; its content becomes undefined - that is, each and every location could contain a completely different, random value. I didn't know that. But when you do switch the unit off and then on, you can expect incorrect values coming from your ram, unless your ROM code has instructions that specifically load the ram with values. The reason why ROM (EEPROM or flash ROM recommended) is used over RAM is because it stores information alot better. It's not that the storage is "better", it's that ROM is non-volatile - ie, the stored data is not lost when power is removed. That is what I meant by better. EEPROM is far better than ROM since you can store information to it many times. Again, that may not constitute "better" in some situations: If you don't need reprogrammability, then ROM is "better"; If it's important that the memory cannot be rewritten - whether accidentally or maliciously - then ROM is "better". If I remember, a factory has to make a special ROM chip for you that contains your code. This code can never be changed. At least with an EEPROM, you can change the primary code, if you have to, just by setting proper values for some chip pins. |