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 do more efficiency ?

Hi,All
I try to define the start_address type,
//-------------------------------------
unsigned char xdata Start_Address _at_ 0x2000;
//-------------------------------------
and also need to access 0x2001,0x2002,......
my solution is repeat define the address, but it is poor efficiency.
Is there are any function like (Start_Address+1),(Start_Address+2)......
can implementation ? or any suggestion.

Thanks.

Parents
  • If you have mapped some peripheral (with a set of registers) to XRAM area, it's a good practice to declare a structure that describes your peripheral and then locate that structure to the absolute address of your peripheral...

    for example:

    struct
    {
    unsigned char status_reg;
    unsigned char command_reg;
    unsigned char address_reg;
    }MY_HARDWARE _at_ 0xF000;

    Later you can access the registers like:

    MY_HARDWARE.command_reg=0x55;
    if (MY_HARDWARE.status_reg&0x80)
    {
    ...
    }


    regards

    Dejan

Reply
  • If you have mapped some peripheral (with a set of registers) to XRAM area, it's a good practice to declare a structure that describes your peripheral and then locate that structure to the absolute address of your peripheral...

    for example:

    struct
    {
    unsigned char status_reg;
    unsigned char command_reg;
    unsigned char address_reg;
    }MY_HARDWARE _at_ 0xF000;

    Later you can access the registers like:

    MY_HARDWARE.command_reg=0x55;
    if (MY_HARDWARE.status_reg&0x80)
    {
    ...
    }


    regards

    Dejan

Children