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

How to reserve a memory zone

I'm using an 8051 like controller.

In the past I worked with an other micro and his compiler and I was able to reserve a memory zone to place my "not to be initiated" variables.

With the old compiler I could use the following lines in my code:

#pragma memory=dataseg( NOINIT )
unsigned char dummy;
#pragma memory=default

to place the variable dummy into the segment NOINIT.
Then in the linker control file I could define the segment NOINIT in a chosen memory zone and then in the cstartup I could not initiate that memory zone.
In this way I could choose to place variables in two different memory zone and have them zeroed at every reset or not.

Searching in the manual I found the keyword _at_, but it's slight different because in my example I didn't have to care about placing my NOINIT varibles, it was the linker who did it, while with the _at_ keyword I have to care for every variable and be careful not to overlap to an existing one.
Is there a way to do what I need with C51 V7.50 and BL51 V5.12?
Thanks in advance.

Parents
  • dead easy in assembler
    have your XDATA in an assembler module and make a .h that has them as extern for your C

    Erik

    example assembler for 8k RAM. You also need to modify startup.a51 to exclude the clearing

               PUBLIC .....
    
    ?XD?mcxdata SEGMENT XDATA
    
               RSEG ?XD?mcxdata
    firstone:  ds    0
    ....: ds ...
    lastone:   ds    0
    ;; these 16 bytes are not cleared by startup @@@@@@@@@@@@@@@
               ds (01ff0h -(lastone - firstone))
    ......:  ds    1
    
               end
    

Reply
  • dead easy in assembler
    have your XDATA in an assembler module and make a .h that has them as extern for your C

    Erik

    example assembler for 8k RAM. You also need to modify startup.a51 to exclude the clearing

               PUBLIC .....
    
    ?XD?mcxdata SEGMENT XDATA
    
               RSEG ?XD?mcxdata
    firstone:  ds    0
    ....: ds ...
    lastone:   ds    0
    ;; these 16 bytes are not cleared by startup @@@@@@@@@@@@@@@
               ds (01ff0h -(lastone - firstone))
    ......:  ds    1
    
               end
    

Children
No data