Products & Services Solutions Academia Support User Community Company

Learn more about xPC Target   

Accessing Registers

I/O Space

For registers in I/O space, use the xPC Target I/O read and write functions:

uint32_T xpcInpDW(uint16_T port );  // read a 32 bit word
uint16_T xpcInpW(uint16_T port );  // read a 16 bit word
uint8_T  xpcInpB(uint16_T port );  // read an 8 bit byte

void xpcOutpDW(uint16_T port, uint32_T value );  // write 32 bits
void xpcOutpW(uint16_T port, uint16_T value );  // write 16 bits
void xpcOutpB(uint8_T port,  uint8_T value );  // write a byte

The port address is the value returned in the BaseAddress array.

Memory-Mapped Space

For registers in memory-mapped space, access them by dereferencing through a pointer that contains the virtual address returned by the xpcReserveMemoryRegion function. Because modern compilers have aggressive optimizers, you must declare the pointer to be volatile. Doing so ensures that the compiler does not optimize out reads and writes using that pointer. The following pseudocode illustrates this using two methods: structure and array.

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS