This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS/TMS320F28027: Driver code for peripherals SCI, SPI etc on C2000 microcontrollers

Part Number: TMS320F28027
Other Parts Discussed in Thread: CONTROLSUITE

Tool/software: Code Composer Studio

To program peripherals SCI, SPI, I2c on Microprocessors (like f2806x and  f2802x), each peripheral TI has two sets of registers definition. For example SCI, Ti has struct _SCI_Obj_ in sci.h/sci.c and struct SCI_REGS in F2806x_Sci.h (union based from controlSUITE). They are actually same size and in same order of each member in the structure. 

So, after we use the SCI base address to do the initialization (with SCI_init()) to get SCI_Handle object. Then if we want to use SCI_REGS structure object, just cast and pass the SCI_Handle object to a pointer of SCI_REGS.

 Like the following:

 SCI_Handle  scia_handle = SCI_init((void*)SCIA_BASE_ADDR, sizeof(SCI_Obj));

SCI_REGS     *scia_regs_p = (SCI_REGS     *)scia_handle;

Just want to make sure it is the right way to do it.

Thanks.

  • Hui,

    the first method you described is for our "driver" style , the second method is our "struct" style. Users usually pick one style and stick to it, switching back and forth can be confusing.

    Anyways, this should work! I would suggest that you use the “Volatile” keyword when defining SCI_REGS, because some of the values in this struct may be changed by things outside of the application code.

    Regards,
    Cody