Keil Logo

C51: Accessing Specific Memory Bytes


Information in this knowledgebase article applies to:

  • C51 All Versions

QUESTION

How can I access any byte of internal memory without reserving it? At some time, I want to download all memory contents, including all variables and registers. It is no problem working in Assembly, but can I do this from a C program?

ANSWER

Yes. You may use the DBYTE macro in the C51 library. Refer to the ABSACC.H include file. The definition for DBYTE is...

#define DBYTE ((unsigned char volatile data  *) 0)

You may then access any byte in internal memory as shown in the following C code:

for (i = 0; i < 0x80; i++)
  {
  unsigned char my_data;

  my_data = DBYTE[i];  // Read DATA byte
  SBUF = my_data;  // Write DATA byte to serial port

  // Delay for TI here
  }

MORE INFORMATION


Last Reviewed: Thursday, February 25, 2021


Did this article provide the answer you needed?
 
Yes
No
Not Sure
 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.