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.

TMS320C6748: Function library call issue

Part Number: TMS320C6748

I want to set C6748 to SPI MASTER mode and 3-pin mode,which requires me to set SPI1_ ENA bit is set to 8. I implement it through the following program:

void SPIPinMuxSetup(unsigned int instanceNum)
{
unsigned int savePinMux = 0;

if(0 == instanceNum)
{
savePinMux = HWREG(SOC_SYSCFG_0_REGS + SYSCFG0_PINMUX(3)) & \
~(SYSCFG_PINMUX3_PINMUX3_3_0 | \
SYSCFG_PINMUX3_PINMUX3_15_12 | \
SYSCFG_PINMUX3_PINMUX3_11_8 | \
SYSCFG_PINMUX3_PINMUX3_7_4);

HWREG(SOC_SYSCFG_0_REGS + SYSCFG0_PINMUX(3)) = \
(PINMUX3_SPI0_CLK_ENABLE | PINMUX3_SPI0_SIMO_ENABLE | \
PINMUX3_SPI0_SOMI_ENABLE | PINMUX3_SPI0_ENA_ENABLE | \
savePinMux);

}
else if(1 == instanceNum)
{
savePinMux = HWREG(SOC_SYSCFG_0_REGS + SYSCFG0_PINMUX(5)) & \
~(SYSCFG_PINMUX5_PINMUX5_11_8 | \
SYSCFG_PINMUX5_PINMUX5_23_20 | \
SYSCFG_PINMUX5_PINMUX5_19_16 | \
SYSCFG_PINMUX5_PINMUX5_15_12);

HWREG(SOC_SYSCFG_0_REGS + SYSCFG0_PINMUX(5)) = \
(PINMUX5_SPI1_CLK_ENABLE | PINMUX5_SPI1_SIMO_ENABLE | \
PINMUX5_SPI1_SOMI_ENABLE | PINMUX5_SPI1_ENA_ENABLE | \
savePinMux);
}

else if(2 == instanceNum)
{
savePinMux = HWREG(SOC_SYSCFG_0_REGS + SYSCFG0_PINMUX(5)) & \
~(SYSCFG_PINMUX5_PINMUX5_11_8 | \
SYSCFG_PINMUX5_PINMUX5_23_20 | \
SYSCFG_PINMUX5_PINMUX5_19_16 | \
SYSCFG_PINMUX5_PINMUX5_15_12);

HWREG(SOC_SYSCFG_0_REGS + SYSCFG0_PINMUX(5)) = \
(PINMUX5_SPI1_CLK_ENABLE | PINMUX5_SPI1_SIMO_ENABLE | \
PINMUX5_SPI1_SOMI_ENABLE | PINMUX5_SPI1_GPIO_ENABLE | \
savePinMux);
}


else
{


}

}

#define PINMUX5_SPI1_CLK_ENABLE (SYSCFG_PINMUX5_PINMUX5_11_8_SPI1_CLK << \
SYSCFG_PINMUX5_PINMUX5_11_8_SHIFT)

#define PINMUX5_SPI1_SIMO_ENABLE (SYSCFG_PINMUX5_PINMUX5_23_20_SPI1_SIMO0 << \
SYSCFG_PINMUX5_PINMUX5_23_20_SHIFT)

#define PINMUX5_SPI1_SOMI_ENABLE (SYSCFG_PINMUX5_PINMUX5_19_16_SPI1_SOMI0 << \
SYSCFG_PINMUX5_PINMUX5_19_16_SHIFT)

#define PINMUX5_SPI1_ENA_ENABLE (SYSCFG_PINMUX5_PINMUX5_15_12_NSPI1_ENA << \
SYSCFG_PINMUX5_PINMUX5_15_12_SHIFT)

#define PINMUX5_SPI1_GPIO_ENABLE (SYSCFG_PINMUX5_PINMUX5_15_12_GPIO2_12 << \
SYSCFG_PINMUX5_PINMUX5_15_12_SHIFT)

#define SYSCFG_PINMUX5_PINMUX5_11_8_SHIFT (0x00000008u)
#define SYSCFG_PINMUX5_PINMUX5_11_8_SPI1_CLK (0x00000001u)

#define SYSCFG_PINMUX5_PINMUX5_23_20_SHIFT (0x00000014u)
#define SYSCFG_PINMUX5_PINMUX5_23_20_SPI1_SIMO0 (0x00000001u)

#define SYSCFG_PINMUX5_PINMUX5_19_16_SHIFT (0x00000010u)
#define SYSCFG_PINMUX5_PINMUX5_19_16_SPI1_SOMI0 (0x00000001u)

#define SYSCFG_PINMUX5_PINMUX5_15_12_SHIFT (0x0000000Cu)
#define SYSCFG_PINMUX5_PINMUX5_15_12_NSPI1_ENA (0x00000001u)
#define SYSCFG_PINMUX5_PINMUX5_15_12_GPIO2_12 (0x00000008u)

My program was obtained by modifying SPIFLASH.I added the scenario of instanceNum=2 to meet my requirements. But the result of the program running did not change much. I set the instanceNum in the main program to 0, 1, and 2, and their results are all in the case where instanceNum=1 when I did not modify the program. I suspect that the function library I modified is not the one my main program calls, but I can only find the SPIPinMuxSetup function in this library, which is a file called SPI. c. I want to know how to find the function I need to modify next.

The following link is my previous discussion with Gary:

e2echina.ti.com/.../2915591

  • Hello,

    I can give you some advice:

    Check Function Usage in Main Program:
    Verify that your main program is indeed calling the modified `SPIPinMuxSetup` function. Use a debugger or add print statements to confirm that the function is being executed with the correct parameters (`instanceNum`).


    Check Header Files:
    - If the `SPIPinMuxSetup` function is declared in a header file (e.g., SPI.h), make sure that the header file is included in both the source file where the function is implemented and the main program file.


    Inspect Function Variants:
    Check if there are multiple implementations of the `SPIPinMuxSetup` function in different files. You might have inadvertently modified the wrong implementation.

    Regards,

    Gary

  • Hello Gary,

    I learned from the communication group that this function library is encapsulated, so perhaps my modifications will not affect it. I want to know what kind of work should I do in this situation? Perhaps I should learn how to build my own function library and call it?

  • Hello,

    In this case, you might want to consider creating your own library or modifying the existing one, and then linking it with your main program.

    Here are the steps to follow
    1. Create a New Library
    2. Copy and Modify the Function
    3. Create a Header File
    4.Include the Header File
    5.Update Function Calls
    6.Rebuild and Test

    Regards,

    Gary