Please note: We are aware of an issue affecting replies on the Arm Community forums, which may not be loading as expected.

We apologize for any inconvenience and appreciate your patience while we investigate and work to resolve the issue.

Thank you for your understanding.


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

Addressing 8255

Hi,

I have a Philips RD2 board with a memory mapped 8255 with ports A at 8000H, B at 8001H, C at 8002H and a control port at 8003H.

How do I set up my defines so that I can just refer to these memory mapped ports as PORTA, CTRLPRT etc. in a C program?

Muz

Parents
  • If you wanted to use a #define, it would look something like:

    8255.h
    --
    #define 8255_BASE_ADDR   0x8000
    #define 8255_CTRL_ADDR   (8255_BASE_ADDR + 3)
    #define 8255_CTRL        (*(xdata volatile*)8255_CTRL_ADDR)
    
    ...
       // usage
       val = 8255_CTRL;
       8255_CTRL |= 0x01;
    


    The only virtue of this method would be portability. (And that not so much of the code, but of your skills; you don't have to figure out the current platform's idiosyncratic method of locating variables for each project.) _at_ should work just fine.

Reply
  • If you wanted to use a #define, it would look something like:

    8255.h
    --
    #define 8255_BASE_ADDR   0x8000
    #define 8255_CTRL_ADDR   (8255_BASE_ADDR + 3)
    #define 8255_CTRL        (*(xdata volatile*)8255_CTRL_ADDR)
    
    ...
       // usage
       val = 8255_CTRL;
       8255_CTRL |= 0x01;
    


    The only virtue of this method would be portability. (And that not so much of the code, but of your skills; you don't have to figure out the current platform's idiosyncratic method of locating variables for each project.) _at_ should work just fine.

Children