Macro |
|
Write one byte to a specified location in RAM |
Purpose |
|
Indirect access to RAM registers |
Syntax |
|
void writeToRAM(uns16 address, uns8 value) |
Parameters |
|
• address: traditional or linear memory location address • value: value to be written |
Return value |
|
– |
Output values |
|
– |
Preconditions |
|
Avoid writing to RAM areas dedicated to OS and to PIC special function registers otherwise OS can collapse. See IQRF OS User’s guide, RAM map. |
Remarks |
|
RAM can be accessed either directly (using common C commands like X = Y;) or indirectly. But indirect writing to the INDFx registers is not allowed. Due to security reasons, all instructions writing to INDFx are removed during Upload. To avoid unintended behavior, all constructions writing to INDFx (either by the user or by the compiler) should be omitted. Instead of this IQRF OS provides complete support for indirect RAM addressing using extra system functions readFromRAM, writeToRAM, and copyMemoryBlock. See Example E06–RAM. |
Side effects |
|
FSR0 register is modified. |
See also |
|
|
Example 1 |
|
// Not allowed. The compiler uses INDFx in such cases. for (i=0; i<5; i++) bufferRF[i] = i; |
Example 2 |
|
// Correct for (i=0; i<5; i++) writeToRAM(bufferRF + i, i); |