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

Direct reg access

Hi again.
I have a custom 8051 processor which has defined a series of sfr, such as "sfr id_custom = 0x32" in the header reg51.h file.
When I tried to access from C, throws the error "Error 146: Invalid Base Address".
As I can do to disable this protection? or enabling the access to these registers?
Thanks.

PS: Sorry about my english. =)

Parents
  • If I remember correctly, SFR's are located in the addresses 0x80 through 0xFF. So it's not surprising that the compiler complains when it sees the address 0x32.
    If the register really is located at address 0x32, you can access it with a macro:

    #define MYREG_INDIRECT (*(unsigned char volatile data*)0x32) /* indirect addressing */
    #define MYREG_DIRECT   (*(unsigned char volatile idata*)0x32) /* direct addressing */
    

Reply
  • If I remember correctly, SFR's are located in the addresses 0x80 through 0xFF. So it's not surprising that the compiler complains when it sees the address 0x32.
    If the register really is located at address 0x32, you can access it with a macro:

    #define MYREG_INDIRECT (*(unsigned char volatile data*)0x32) /* indirect addressing */
    #define MYREG_DIRECT   (*(unsigned char volatile idata*)0x32) /* direct addressing */
    

Children