On the 8051 MCUs, which have 256 bytes of RAM, how can I locate my variables and data in the upper 128 bytes, so that I can reserve the lower 128 bytes for another purpose?
On the 8051 MCUs, the lower 128 bytes bytes of RAM is the "data" space and is accessible by direct and indirect addressing, while the upper 128 bytes of RAM, or "idata," is available only by indirect addressing. To place a variable in idata, you can use the following type of declaration for the variable or array:
idata char myvariable;
idata unsigned char array;
Processor access times for idata are slower than for data. In general, it is recommended to let the compiler automatically place variables in memory where it sees fit, as it can perform certain performance and space optimizations, but if you have a specific use case that warrants manual placement of variables in the RAM space, then you can use the "idata" keyword in your variable declaration.