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.

How to use define register variables in C6748?

Other Parts Discussed in Thread: TMS320C6748

The chip I used is TMS320C6748. I plan to define some register variables(about ~50 count) to replace the some normal global variables. I read the datasheet especial on the part of  memory mapping. I define the register as follow format:

#define REG32(x)            (*(volatile unsigned int *)(x))// reference to a 32 bit register (unsigned int)

#define Register_Var1      REG32(0x60000000u)         //clocks of burst width

I'm not sure which memery block I used is OK? Is there someone could give me a confirmation? Thank you very much!


  • I plan to define some register variables(about ~50 count) to replace the some normal global variables.

    Which register need to read or write ?

    You can see here some HW register access from starterware package.
    C:\ti\C6748_StarterWare_1_20_04_01\include\hw\hw_types.h
    C:\ti\C6748_StarterWare_1_20_04_01\platform\lcdkC6748\gpio.c
  • Hello Titus,

          Thank you very much for your reply. I read gpio.c and hw_types.h follow your suggestion. And now I have a more clear understand for the GPIO. But also have some new confuse.

          1.-->Which register need to read or write ?

          This is also my question. I want to define some register variables. As we know, we could define global variable or local variable and register variables in C. I want to define some register variables to speed up my code. I don't know which register space I could use. I mean is there some register space we could define personally in the TMS 320C6748?

          2.-->new question about the GPIO(Pin Multiplexing)

    Demo Example(Define the GPIO6_13 as normal GPIO input as follow)

    void GPIOBank6Pin13PinMuxSetup(void)

    {

       unsigned int savePinmux = 0;

       savePinmux = (HWREG(SOC_SYSCFG_0_REGS + SYSCFG0_PINMUX(13)) &

                    ~(SYSCFG_PINMUX13_PINMUX13_11_8));

       HWREG(SOC_SYSCFG_0_REGS + SYSCFG0_PINMUX(13)) =

            (PINMUX13_GPIO6_13_ENABLE | savePinmux);

    }

    #define SYSCFG_PINMUX13_PINMUX13_11_8 (0x00000F00u)

    #define SYSCFG_PINMUX13_PINMUX13_11_8_SHIFT (0x00000008u)

    /*----PINMUX13_11_8 Tokens----*/

    #define SYSCFG_PINMUX13_PINMUX13_11_8_DEFAULT (0x00000000u)

    #define SYSCFG_PINMUX13_PINMUX13_11_8_PRU0_R30_31 (0x00000001u)

    #define SYSCFG_PINMUX13_PINMUX13_11_8_NUHPI_HRDY (0x00000002u)

    #define SYSCFG_PINMUX13_PINMUX13_11_8_PRU1_R30_12 (0x00000004u)

    #define SYSCFG_PINMUX13_PINMUX13_11_8_GPIO6_13 (0x00000008u)

           But if I want to use this pin as other function. How could I modify above code?

           Thank you very much!

    BRs,

    Shuanghong

  • Dear Shuanghong,


    2.-->new question about the GPIO(Pin Multiplexing)

    Demo Example(Define the GPIO6_13 as normal GPIO input as follow)
    But if I want to use this pin as other function. How could I modify above code?


    You can modify like below if you wish to use that pin as UHPI INT (HPI peripheral interrupt pin)

    /* Pin Multiplexing bit mask to select UHPI INT pin. */
    #define PINMUX13_UHPI_INT_ENABLE (SYSCFG_PINMUX13_PINMUX13_15_12_NUHPI_HINT << \
    SYSCFG_PINMUX13_PINMUX13_15_12_SHIFT)

    void UHPI_INT_PinMuxSetup(void)
    {
    unsigned int savePinmux = 0;

    /*
    ** Clearing the bit in context and retaining the other bit values
    ** in PINMUX13 register.
    */
    savePinmux = (HWREG(SOC_SYSCFG_0_REGS + SYSCFG0_PINMUX(13)) &
    ~(SYSCFG_PINMUX13_PINMUX13_15_12));

    /* Setting the pins corresponding to UHPI_INT in PINMUX13 register.*/
    HWREG(SOC_SYSCFG_0_REGS + SYSCFG0_PINMUX(13)) =
    (PINMUX13_UHPI_INT_ENABLE | savePinmux);

    }

    I hope this helps.


    This is also my question. I want to define some register variables. As we know, we could define global variable or local variable and register variables in C. I want to define some register variables to speed up my code. I don't know which register space I could use. I mean is there some register space we could define personally in the TMS 320C6748?

    I am not sure about this, I thought that you want to read some memory mapped register to access the DSP peripherals.

    You can refer to this e2e post.

    I've tried to use the "register" keyword but compiler allocated the memory from RAM rather than CPU register.

    register int a=100;

    printf("A value %d and Address is %p\n",a,&a);

    OUTPUT:
    [C674X_0] A value 0 and Address is c0016c1c

    I think, you can check with compiler folks who knows better than us.

    Actually this forum is device specific and the following is the TI E2E Compiler forum link; here you can post your compiler related questions.
    e2e.ti.com/.../

    Thanks for your understanding.
  • Hello Titus,

    Thank you very much for your quickly and kindly reply. Very good explanation. I got it. Thanks!

    BRs,
    Shuanghong
  • Dear Shuanghong,
    Sounds good.
    Thanks for your update.