This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

I need to access two memory of xdata

Hi,
I have two memory (Flash & NVRAM). I need to access both memories.

I am writing program in C. If I want to store some variables in NVRAM and some in Flash how do I do it?

Is there any mechanism (like code if U give it will directly go to code memory) so that I will define NVRAM as my first address of the NVRAM then after that if I declare some variables under NVRAM (like code or Xdata) it will work?

Parents
  • I presume both are being mapped into the 8051's XDATA address space?

    This is a job for the Linker.

    Keep the definitions of your Flash & NVRAM variables is separate files, and use Linker directives to locate them in the appropriate address ranges.

    You will, of course, need to study the Linker Manual - probably also worth browsing through the Application Notes, and searching the knowledgebase.

    NB: you don't need to have all your Flash variables defined in a single file, nor all your NVARM variables in a single file - you just jave to ensure that no file contains both Flash and NVRAM variable definitions.

Reply
  • I presume both are being mapped into the 8051's XDATA address space?

    This is a job for the Linker.

    Keep the definitions of your Flash & NVRAM variables is separate files, and use Linker directives to locate them in the appropriate address ranges.

    You will, of course, need to study the Linker Manual - probably also worth browsing through the Application Notes, and searching the knowledgebase.

    NB: you don't need to have all your Flash variables defined in a single file, nor all your NVARM variables in a single file - you just jave to ensure that no file contains both Flash and NVRAM variable definitions.

Children