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.

TMDSLCDK6748: SPI 0 communication

Part Number: TMDSLCDK6748
Other Parts Discussed in Thread: TMS320C6748, OMAP-L138

I am using a  TMDSLCDK6748  evaluation board. I want to configure the SPI communication in the board using SPI0 communication. But only the SPI0_SIMO, SPI0_SOMI and SPI0_SCLK pins are available in the J15 there is no chip select pin out from any of the output jumpers. They seem to be connected to the LAN IC, U23, LAN8710A-EZK.  SPI1 communication is available and seems to be connected to the camera header. 

Please suggest a way to use the SPI communication in the board.

 

  • Hi,

    SPI0_ENAn/EPWM0_B/MII_RXDV; SPI0_SCSn_5/UART0_RXD/MII_RXD3 and SPI0_SCSn_4/UART0_TXD/MII_RXD2 are available on the expansion headers.

    You need to correctly pinmux C17, C19 and D18 balls of the TMS320C6748 device:

    Then see page 11 of the schematic:
     

    You need to populate R214 through R219 to physically connect the device ball to expansion header. After that you can use J15.P21, J15.P23, J15.P25, J15.P27, J15.P29, J15.P31 for SPI communication. 


    Best Regards,
    Yordan

  • Is there any Pin headers available for interfacing with camera header J16 ?
  • The camera interface is J16. See the schematic. What do you mean by pin headers for interfacing with J16??

    Best Regards,
    Yordan

  • Is TI providing any connectors for the 36 pin J16 header ?
  • Do we need to remove the R177, R178, R179 and R184 in order to avoid errors ?
  • No, ti does not provide connectors, you should research and select the correct camera module.
    The resistors should NOT cause any problems. NOTE that you should populate R214 through R219 with 0 ohm resistors as stated in the schematics.

    Best Regards,
    Yordan
  • I have populated the resistors, but the output signals are getting distorted in those pins. 

  • Can you post the scope measurements? Are you sure you're doing the pinmux correctly?

    Best Regards,
    Yordan
  • SPI CLOCK

    SPI SOMI

     

  • Yes the PINMUX is done correctly
  • There can be a number of reasons for this: bad soldering, incorrect measurement (you don't have a good gnd), interfering with eth signals if you haven't disabled all ethernet drivers & pinmuxing etc..
    Is this actually affecting the spi communicaion? If not, then you should be fine.

    Best Regards,
    Yordan
  • Even when the SPI_CLK is at offset (without providing signals at that pin), I am getting a 2V signal @ 24 MHz frequency as the output in that pin. What could be the reason ?
  • Hello Yordan Kovachev,

    I am getting more errors in the SPI0 communication. The SPI0_SIMO and SPI0_SOMI was working (with a small amount of noise). Now those two pins are not providing visible output signals. Its output voltage is only a few mVolts .
  • It appears that the PHY is not completely disabled (maybe you haven't completely removed the driver from the kernel) and it is possible that it causes interference. Just to be sure, is it possible to remove R177, R178, R179 and R184 and test again?

    Best Regards,
    Yordan
  • Hello Yordan Kovachev,
    Thanks for your help,

    The coding is done using the starterware provided by TI. The code "spi_c674x_c6748_lcdkC6748" was modified for my application.
    How could I disable the PHY completely using the program ?


    #include <string.h>
    #include "soc_C6748.h"
    #include "hw_psc_C6748.h"
    #include "lcdkC6748.h"
    #include "uart.h"
    #include "spi.h"
    #include "psc.h"
    #include "interrupt.h"
    #include "uartStdio.h"
    
    /******************************************************************************
    **                      INTERNAL MACRO DEFINITIONS
    *******************************************************************************/
    /* value to configure SMIO,SOMI,CLK and CS pin as functional pin */
    #define SIMO_SOMI_CLK        0x00000E00
    #define CHAR_LENGTH             0x08
    
    /******************************************************************************
    **                      INTERNAL FUNCTION PROTOTYPES
    *******************************************************************************/
    static void SPIConfigDataFmtReg(unsigned int dataFormat);
    static void SpiTransfer(void);
    static void SetUpInt(void);
    static void SetUpSPI(void);
    static void testCommand(void);
    void SPIIsr(void);
    
    /******************************************************************************
    **                      INTERNAL VARIABLE DEFINITIONS
    *******************************************************************************/
    volatile unsigned int flag = 1;
    unsigned int tx_len;
    unsigned int rx_len;
    unsigned char vrf_data[260];
    unsigned char tx_data[260];
    volatile unsigned char rx_data[260];
    unsigned char *p_tx;
    volatile unsigned char *p_rx;
    volatile unsigned char StatusResponseMessage[16];
    
    /******************************************************************************
    **                      INTERNAL FUNCTION DEFINITIONS
    *******************************************************************************/
    int main(void)
    {
        /* Waking up the SPI0 instance. */
        PSCModuleControl(SOC_PSC_0_REGS, HW_PSC_SPI0, PSC_POWERDOMAIN_ALWAYS_ON,PSC_MDCTL_NEXT_ENABLE);
    
        /* Performing the Pin Multiplexing for SPI0. */
        SPIPinMuxSetup(0);
    
        /* Enable use of SPI0 interrupts. */
        SetUpInt();
    
        /* Configuring and enabling the SPI0 instance. */
        SetUpSPI();
    
    while(1)
    {
       testCommand();
    }
    }
    
    static void testCommand(void)
    {
    	int i;
    	for(i=0;i<7;i++)
    		tx_data[i]=0x55;
    
    	tx_len = 7;
    	rx_len = 7;
    
    	SPIDat1Config(SOC_SPI_0_REGS, (SPI_CSHOLD | SPI_DATA_FORMAT0), 0x4);
        SpiTransfer();
    }
    
    /*
    ** Configures ARM interrupt controller to generate SPI interrupt
    **
    */
    static void SetUpInt(void)
    {
    	// Setup the ARM or DSP interrupt controller
    
    #ifdef _TMS320C6X
    	// Initialize the DSP interrupt controller
    	IntDSPINTCInit();
    
    	// Register the ISR in the vector table
    	IntRegister(C674X_MASK_INT4, SPIIsr);
    
    	// Map system interrupt to the DSP maskable interrupt
    	IntEventMap(C674X_MASK_INT4, SYS_INT_SPI0_INT);
    
    	// Enable the DSP maskable interrupt
    	IntEnable(C674X_MASK_INT4);
    
    	// Enable DSP interrupts globally
    	IntGlobalEnable();
    #else
        /* Initialize the ARM Interrupt Controller.*/
        IntAINTCInit();
    
        /* Register the ISR in the Interrupt Vector Table.*/
        IntRegister(SYS_INT_SPINT1, SPIIsr);
    
        /* Set the channnel number 2 of AINTC for system interrupt 56.
         * Channel 2 is mapped to IRQ interrupt of ARM9.
        */
        IntChannelSet(SYS_INT_SPINT1, 2);
    
        /* Enable the System Interrupts for AINTC.*/
        IntSystemEnable(SYS_INT_SPINT1);
    
        /* Enable IRQ in CPSR.*/
        IntMasterIRQEnable();
    
        /* Enable the interrupts in GER of AINTC.*/
        IntGlobalEnable();
    
        /* Enable the interrupts in HIER of AINTC.*/
        IntIRQEnable();
    #endif
    }
    
    /*
    ** Configures SPI Controller
    **
    */
    static void SetUpSPI(void)
    {
        unsigned char cs  = 0x04;
        unsigned char dcs = 0x04;
        unsigned int  val = SIMO_SOMI_CLK;
        SPIReset(SOC_SPI_0_REGS);
    
        SPIOutOfReset(SOC_SPI_0_REGS);
    
        SPIModeConfigure(SOC_SPI_0_REGS, SPI_MASTER_MODE);
    
        //SPIClkConfigure(SOC_SPI_0_REGS, 150000000, 20000000, SPI_DATA_FORMAT0);
        SPIClkConfigure(SOC_SPI_0_REGS, 150000000, 1000000, SPI_DATA_FORMAT0);
    
        SPIPinControl(SOC_SPI_0_REGS, 0, 0, &val);
    
        SPIDefaultCSSet(SOC_SPI_0_REGS, dcs);
    
        /* Configures SPI Data Format Register */
        SPIConfigDataFmtReg(SPI_DATA_FORMAT0);
    
         /* Selects the SPI Data format register to used and Sets CSHOLD
          * to assert CS pin(line)
          */
        SPIDat1Config(SOC_SPI_0_REGS, (SPI_CSHOLD | SPI_DATA_FORMAT0), cs);
    
         /* map interrupts to interrupt line INT1 */
        SPIIntLevelSet(SOC_SPI_0_REGS, SPI_RECV_INTLVL | SPI_TRANSMIT_INTLVL);
    
        /* Enable SPI communication */
        SPIEnable(SOC_SPI_0_REGS);
    }
    /*
    ** Configures Data Format register of SPI
    **
    */
    static void SPIConfigDataFmtReg(unsigned int dataFormat)
    {
        /* Configures the polarity and phase of SPI clock */
        /*
    	SPIConfigClkFormat(SOC_SPI_0_REGS,
                           (SPI_CLK_POL_HIGH | SPI_CLK_INPHASE),
                           dataFormat);
        */
        SPIConfigClkFormat(SOC_SPI_0_REGS,
                           (SPI_CLK_POL_LOW | SPI_CLK_INPHASE),
                           dataFormat);
    
        /* Configures SPI to transmit MSB bit First during data transfer */
        SPIShiftMsbFirst(SOC_SPI_0_REGS, dataFormat);
    
        /* Sets the Charcter length */
        SPICharLengthSet(SOC_SPI_0_REGS, CHAR_LENGTH, dataFormat);
    }
    
    /*
    ** Enables SPI Transmit and Receive interrupt.
    ** Deasserts Chip Select line.
    */
    static void  SpiTransfer(void)
    {
        p_tx = &tx_data[0];
        p_rx = &rx_data[0];
        SPIIntEnable(SOC_SPI_0_REGS, (SPI_RECV_INT | SPI_TRANSMIT_INT));
        while(flag);
        flag = 1;
        /* Deasserts the CS pin(line) */
        SPIDat1Config(SOC_SPI_0_REGS, SPI_DATA_FORMAT0, 0x4);
    }
    
    /*
    ** Data transmission and reception SPIIsr
    **
    */
    void SPIIsr(void)
    {
        unsigned int intCode = 0;
    
    #ifdef _TMS320C6X
        IntEventClear(SYS_INT_SPI1_INT);
    #else
        IntSystemStatusClear(56);
    #endif
    
        intCode = SPIInterruptVectorGet(SOC_SPI_0_REGS);
    
        while (intCode)
        {
            if(intCode == SPI_TX_BUF_EMPTY)
            {
                tx_len--;
                SPITransmitData1(SOC_SPI_0_REGS, *p_tx);
                p_tx++;
                if (!tx_len)
                {
                    SPIIntDisable(SOC_SPI_0_REGS, SPI_TRANSMIT_INT);
                }
            }
    
            if(intCode == SPI_RECV_FULL)
            {
                rx_len--;
                *p_rx = (char)SPIDataReceive(SOC_SPI_0_REGS);
                p_rx++;
                if (!rx_len)
                {
                    flag = 0;
                    SPIIntDisable(SOC_SPI_0_REGS, SPI_RECV_INT);
                }
            }
    
            intCode = SPIInterruptVectorGet(SOC_SPI_0_REGS);
        }
    }
    
    /******************************* End of file *********************************/
    

  • Hi,

    How could I disable the PHY completely using the program ?


    Sorry, I andwered for omap-l138, where you have C6758 + arm. Ok then, can you try to remove the resistors. The SPI_CLK is connected to the RXCLK of the phy, which is outputted constantly, as I see in the datasheet:
    "RXCLK is the 25MHz output clock for the MII bus. It is recovered from the received data to clock the RXD bus. If there is no received signal, it is derived from the system reference clock (XTAL1/CLKIN)."
  • Hello Yordan Kovachev,

    Thanks for your reply,

    Is there any registers or hardware pins available for disabling the PHY chip ?  Is there any other solution other than removing the resistors ?

    What could be the reason for the errors in the SIMO and SOMI pins of SPI0. I was getting the signals correctly(with a small amount if noise). But now there is no visible output for those pins.

  • Is there any registers or hardware pins available for disabling the PHY chip ? Is there any other solution other than removing the resistors ?

    NO, this depends on your application, since you run RTOS. If you haven't enabled the phy, then it is not operational.. However as I told you, the clock is constant, so you need to dismount the series resistor.

    What could be the reason for the errors in the SIMO and SOMI pins of SPI0. I was getting the signals correctly(with a small amount if noise). But now there is no visible output for those pins.

    I can't say, I don't know what are you doing with the board.

    Best Regards,
    Yordan
  • #include "gpio.h"
    #include "psc.h"
    #include "soc_C6748.h"
    #include "lcdkC6748.h"
    #include "hw_types.h"
    #include "hw_syscfg0_C6748.h"
    
    #define PINMUX3_GPIO8_5_ENABLE    (SYSCFG_PINMUX3_PINMUX3_15_12_GPIO8_5  << \
                                        SYSCFG_PINMUX3_PINMUX3_15_12_SHIFT)
    void simopinsetup();
    
    int main(void)
    {
        somipinsetup();
        GPIODirModeSet(SOC_GPIO_0_REGS, 134, GPIO_DIR_OUTPUT);
    
        while(1)
        {
    		GPIOPinWrite(SOC_GPIO_0_REGS, 134, GPIO_PIN_HIGH);
    		Delay(100000);
    		GPIOPinWrite(SOC_GPIO_0_REGS, 134, GPIO_PIN_LOW);
    		Delay(100000);
    
        }
    }
    
    void somipinsetup()
    {
        unsigned int savePinmux = 0;
        savePinmux = (HWREG(SOC_SYSCFG_0_REGS + SYSCFG0_PINMUX(3)) &
                     ~(SYSCFG_PINMUX3_PINMUX3_11_8));
        HWREG(SOC_SYSCFG_0_REGS + SYSCFG0_PINMUX(3)) =
             (PINMUX3_GPIO8_6_ENABLE | savePinmux);
    }
    

    In this code, I am multiplexing the SIMO pin to the GPIO pin. I am getting output in a milli volt range.

  • I got the same problem wity SPI0 pins. I would like to use SPI0 and if possible the LAN chip as well. I need to use the SPI for writing to LCD only (No reading is necessary for SPI LCD).


    I was wondering if it is possible to put TX_EN to LOW when I wish to write to the LCD? THe LAN controller looks at TX_EN rising edge for sending data. If I leave it al LOW, can I send data to the LCD (SPI LCD) without messing with the data from the LAN controller?

  • Hi aronii,

    As you can see in the Schematic diagram, the SPI0_CLK is multiplexed with the RX_CLK of the PHY chip. RX_CLK is an output from the PHY chip and operates at a frequency of 25 MHz. 

    So if we populate the resistors R214 through R219 without removing the resistor R178, the 25MHz clock will be given as offset output at pin J15_25.

  • Correct. I confirmed this in my previous post:
    "However as I told you, the clock is constant, so you need to dismount the series resistor"

    Best Regards,
    Yordan