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.

TMS320F280039C: enabling the SPI pin on the eval board

Part Number: TMS320F280039C
Other Parts Discussed in Thread: C2000WARE, SYSCONFIG

Hello,

I'm trying to enable the SPI module on the TMS320F280039C eval board.
The pins I'm configuring are GPIO22, GPIO23, GPIO24, GPIO25 as CLK, CS, MOSI & MISO respectively. I'm using the SPIB on the board.

I'm currently not getting the clock on the CLK (GPIO22) pin. it either stay continuous high or low.
Can you share the configuration to enable SPIB or Can you please share some example code.

Let me know if anything else is required from my side.

  • Also, Can you please tel me
    - how to check the clock set for SPI w.r.t. system clock.
    - how to check if the system clock is set properly and SPI clocked w.r.t to system clock. 
    - how to check the counter for sys clock and spi clock (peripheral clock)

  • Are you sure you are checking the right pins for GPIO22? Did you try toggling GPIO22 as output pin and make sure you are probing right pins on eval board.

    C2000Ware example mentioned below

    Path:<C2000Ware>\driverlib\f28003x\examples\spi\

    Examples:

    spi_ex3_external_loopback

    spi_ex4_external_loopback_fifo_interrupts

  • Relationship between SYSCLK / LSPCLK and SPICLK shown here.

    SPI Baud rate is determined by SPIBRR register. So, essentially LOSPCP, PCLKCRx registers, SPIBRR register will affect SPICLK (SPI baud rate)

    To observe SYSCLK, you need to use XCLKOUTSEL, XCLKOUTDIVSEL register and configure GPIO16 (or) 18 to probe for SYSCLK in XCLKOUT pin. SPI baud rate can be observed by probing SPICLK pin.

  • afa I know I'm looking the correct GPIO and probing the correct Pin.

    I also configured other GPIOs and below is the code for gpio12 and related pins.

    ie.   GPIO12, GPIO11, GPIO16, GPIO17 as CLK, CS, MOSI & MISO respectively.
    and I'm probing pin51 and pin52 for CLK & CS respectively.

    Here is the configuration for SPI:

    // SPICCR - Configuration Control Register
    // Set reset low before configuration changes
    SpiaRegs.SPICCR.bit.SPISWRESET = BIT_RESET;
    // Clock polarity (0 == rising, 1 == falling)
    SpiaRegs.SPICCR.bit.CLKPOLARITY = BIT_RESET;
    // High speed mode disabled
    SpiaRegs.SPICCR.bit.HS_MODE = BIT_RESET;
    // Enable loop-back
    SpiaRegs.SPICCR.bit.SPILBK = BIT_RESET;
    // 16-bit character
    SpiaRegs.SPICCR.bit.SPICHAR = (16 - 1);


    // SPICCR - Operation Control Register
    // Overrun Interrupt Enable = 0
    SpiaRegs.SPICTL.bit.OVERRUNINTENA = BIT_RESET;
    // Clock phase (0 == normal, 1 == delayed)
    SpiaRegs.SPICTL.bit.CLK_PHASE = BIT_RESET;
    // Enable master (0 == slave, 1 == master)
    SpiaRegs.SPICTL.bit.MASTER_SLAVE = BIT_SET;
    // Enable transmission (Talk)
    SpiaRegs.SPICTL.bit.TALK = BIT_SET;
    // SPI interrupts are disabled
    SpiaRegs.SPICTL.bit.SPIINTENA = BIT_RESET;


    // SPIBRR - Baud rate Register
    SpiaRegs.SPIBRR.all = ((60000000 / 15000000) - 1);


    Here is the GPIO configuration for SPI

    // Configuring the GPIO Pins for SPI-A
    // SPI_CS_GPIO confi
    GPIO_setPinConfig(GPIO_11_GPIO11); // SPIA -CS
    GPIO_setDirectionMode(SPI_CS_GPIO, GPIO_DIR_MODE_OUT);
    GPIO_setPadConfig(SPI_CS_GPIO, GPIO_PIN_TYPE_STD);
    GPIO_setMasterCore(SPI_CS_GPIO, GPIO_CORE_CPU1);
    GPIO_setQualificationMode(SPI_CS_GPIO, GPIO_QUAL_SYNC);

    // SPI_CLK_GPIO Config
    GPIO_setPadConfig(GPIO_PIN_SPIA_CLK, GPIO_PIN_TYPE_PULLUP);
    GPIO_setQualificationMode(GPIO_PIN_SPIA_CLK, GPIO_QUAL_ASYNC);
    GPIO_setPinConfig(GPIO_12_SPIA_CLK); // SPIA -CLK

    GPIO_setPadConfig(GPIO_PIN_SPIA_SIMO, GPIO_PIN_TYPE_PULLUP);
    GPIO_setQualificationMode(GPIO_PIN_SPIA_SIMO, GPIO_QUAL_ASYNC);
    GPIO_setPinConfig(GPIO_16_SPIA_SIMO); // SPIA-SIMO

    GPIO_setPadConfig(GPIO_PIN_SPIA_SOMI, GPIO_PIN_TYPE_PULLUP);
    GPIO_setQualificationMode(GPIO_PIN_SPIA_SOMI, GPIO_QUAL_ASYNC);
    GPIO_setPinConfig(GPIO_17_SPIA_SOMI); // SPIB-SOMI

    I'm using the same library as you referenced and referred same example of SPI.

    Can you please check and let me know if I'm missing something and I went wrong somewhere. 
    because i referred the almost all the examples provided in C2000ware.

  • Vikas,

    You're not using C2000Ware driverlib example code I suggested. You're using bit-field approach. I would encourage you to use driverlib approach as it has support of sysconfig which allows you to graphically configure both GPIO and SPI module and the tool automatically generates code. 

    Also, are you probing the signals in TMDSHSECDOCK board? If not, please provide schematics. You have configured SPI_CS_GPIO (GPIO11) as output pin but you also seem to use GPIO_QUAL_SYNC. This option is used only when GPIO is used as input pin and it doesn't make sense as output pin.

    Check whether SPISWRESET is set to 1 at the end of SPI configuration. Only then, SPI will be ready to transmit / receive next character. Using sysconfig will help to avoid incorrect SPI / GPIO configuration.

    Regards,

    Manoj

  • Thanks for your reply,

    Actually i initially used driverlib api approach but that didn't work then i switched to bit field approach. I can retry and check again.

    I have custom board and ti control card where i checking this gpio pins. Also, for gpio 11 i initially configured it as spi_ste but that didnot work so i changed to normal gpio output pin. 

    I'm setting the SPISWRESET bit. May be i didnot share in the code.

    Can you let me know if there is any extra configuration/settings i need to do on board or in code which I'm missing.

  • Try toggling all the GPIO used as SPI pins as output pin and make sure you are toggling as expected. It is much easier to work with sysconfig and driverlib approach. So, I wouldn't try using bit-field approach.

  • Hello,

    I received the custom board and we tried configuring the SPI on the TI MCU.
    we could able to get SPI_CLK, SPI_CS and SPI_MOSI. We check on CRO and we are getting the waveform on these pins as per our configuration.
    But we are not getting anything on SPI_MISO (checked on CRO).

    Also,
    1) we are reading the data from SPI_O_RXBUF register its giving nothing (just "0x0000" value)
    and when we are setting SPI_O_RXEMU register to read, its giving some output in watch window (but nothing on CRO ie. on SPI_MISO pin)

    2) we are sending the data from SPI_O_TXBUF then nothing is received on either register (SPI_O_RXBUF/SPI_O_RXEMU) and 
    when we use SPI_O_DAT then we start receiving the data but nothing is transmitted (i.e nothing on SPI_O_TXBUF).

    can you check about this and let us know.

  • Vikas,

    I don't know what you want to check. I know for a fact the SPIA / SPIB works on the device as master (transmitter / receiver) (or) slave (transmitter / receiver) as each individual devices are exhaustively tested before it being shipped to customers.

    Is your C2000 SPI master / slave? what are you trying to interface to? What modifications have you made to C2000Ware example code?

    Did you try running the example code to understand how they work?

    Regards,

    Manoj