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.

TDA4VM: SPI3 No Data received in rx register

Part Number: TDA4VM

Hi,

TDA4(J721E)  ,SDK 8.0

Issue:

       SPI3 and SPI5 are setting Tx and Rx

       SPI3 TX is OK,but  Rx register is keep 0, (CH1,CH2 and CH3 are the same)

       check SPI bus, Tx and Rx data is OK.  (use logic analyzer, waveform and data is right).

      Set the SPI3 Tx and Rx PINs as  output , pull up or down, output are  changed high or low on the logic analyzer.

      SPI5 use the similar setting, it works well.

PINMUX seting as below:

static pinmuxPerCfg_t gSpi3PinCfg[] =
{
/* MySPI3 -> SPI3_CLK -> Y25 */
{
PIN_PRG0_PRU1_GPO17, PIN_MODE(4) | \
((PIN_PULL_DIRECTION) & (~PIN_PULL_DISABLE & ~PIN_INPUT_ENABLE))
},
/* MySPI3 -> SPI3_D0 -> AA26 */
{
PIN_PRG0_PRU1_GPO18, PIN_MODE(4) | \
((0x50000) & (~PIN_PULL_DISABLE & ~PIN_PULL_DIRECTION & ~PIN_INPUT_ENABLE))
},
/* MySPI3 -> SPI3_D1 -> AA29 */
{
PIN_PRG0_PRU1_GPO19, PIN_MODE(4) | \
((PIN_INPUT_ENABLE) & (~PIN_PULL_DISABLE & ~PIN_PULL_DIRECTION))
},
/* MySPI3 -> SPI3_CS1 -> AB26 */
{
PIN_PRG0_PRU0_GPO9, PIN_MODE(4) | \
((PIN_PULL_DIRECTION) & (~PIN_PULL_DISABLE & ~PIN_INPUT_ENABLE))
},
/* MySPI3 -> SPI3_CS2 -> AB25 */
{
PIN_PRG0_PRU0_GPO10, PIN_MODE(4) | \
((PIN_PULL_DIRECTION) & (~PIN_PULL_DISABLE & ~PIN_INPUT_ENABLE))
},
/* MySPI3 -> SPI3_CS3 -> Y24 */
{
PIN_PRG0_PRU1_GPO9, PIN_MODE(4) | \
((PIN_PULL_DIRECTION) & (~PIN_PULL_DISABLE & ~PIN_INPUT_ENABLE))
},
{PINMUX_END}
};

Code for SPI:

void USS_MCU_McSPI3SetUp(void)
{
uint32_t ch_id = 0;
uint32_t reg = 0;
/* Reset the McSPI instance.*/
McSPIReset(MCU_MCSPI3_BASE_ADDRESS);

/* CLOCKACTIVITY bit - OCP and Functional clocks are maintained */
/* SIDLEMODE bit - Ignore the idle request and configure in normal mode
*/
/* AUTOIDLE bit - Disable (OCP clock is running free, no gating) */
MCSPISysConfigSetup(MCU_MCSPI3_BASE_ADDRESS, MCSPI_CLOCKS_OCP_ON_FUNC_ON,
MCSPI_SIDLEMODE_NO, MCSPI_WAKEUP_DISABLE,
MCSPI_AUTOIDLE_OFF);
McSPICSEnable(MCU_MCSPI3_BASE_ADDRESS);
/* Enable master mode of operation.*/
McSPIMasterModeEnable(MCU_MCSPI3_BASE_ADDRESS);

McSPIMultipleWordAccessConfig(MCU_MCSPI3_BASE_ADDRESS,MCSPI_MODULCTRL_MOA_MULTIACCES);
for (ch_id = 1; ch_id < (USS_SPI3_CS_NUM+1); ch_id++) //SPI3 CS1,CS2,CS3
{
/* Perform the necessary configuration for master mode. */
McSPIMasterModeConfig(MCU_MCSPI3_BASE_ADDRESS, MCSPI_SINGLE_CH,
MCSPI_TX_RX_MODE,
MCSPI_DATA_LINE_COMM_MODE_6,
ch_id);
/* Configure the McSPI bus clock depending on clock mode. */
McSPIClkConfig(MCU_MCSPI3_BASE_ADDRESS, USS_MCSPI3_IN_CLK, USS_MCSPI3_OUT_CLK, ch_id,
MCSPI_CLK_MODE_1);
/* Configure the word length.*/
McSPIWordLengthSet(MCU_MCSPI3_BASE_ADDRESS, MCSPI_WORD_LENGTH(16), ch_id);
/* Set the EPOL field with the user sent value. */
McSPICSPolarityConfig(MCU_MCSPI3_BASE_ADDRESS,
(MCSPI_CH0CONF_EPOL_ACTIVELOW <<
MCSPI_CH0CONF_EPOL_SHIFT), ch_id);

/* Enable the transmitter FIFO of McSPI peripheral.*/
McSPITxFIFOConfig(MCU_MCSPI3_BASE_ADDRESS, MCSPI_TX_FIFO_ENABLE, ch_id);

/* Enable the receiver FIFO of McSPI peripheral.*/
McSPIRxFIFOConfig(MCU_MCSPI3_BASE_ADDRESS, MCSPI_RX_FIFO_ENABLE, ch_id);
}
}

void USS_SPI3_CHX_Tx_Rx(uint8_t Datalength, uint16_t *pTxData, uint16_t *pRxData,uint8_t ch_id)
{
uint8_t BufferCounter =0;
uint32_t SPIINTStatus =0;
uint32_t Timerout ;
uint32_t SPI_CH_Rx_Mask ;
uint32_t SPI_CH_Tx_Mask ;
switch(ch_id)
{
case 1:
SPI_CH_Rx_Mask = MCSPI_CH1STAT_RXS_MASK;
SPI_CH_Tx_Mask = MCSPI_CH1STAT_TXS_MASK;
break;
case 2:
SPI_CH_Rx_Mask = MCSPI_CH2STAT_RXS_MASK;
SPI_CH_Tx_Mask = MCSPI_CH2STAT_TXS_MASK;
break;
case 3:
SPI_CH_Rx_Mask = MCSPI_CH3STAT_RXS_MASK;
SPI_CH_Tx_Mask = MCSPI_CH3STAT_TXS_MASK;
break;
default:
SPI_CH_Rx_Mask = MCSPI_CH1STAT_RXS_MASK;
SPI_CH_Tx_Mask = MCSPI_CH1STAT_TXS_MASK;
break;
}
USS_SPI3_ENABLE(ch_id);

while( BufferCounter<Datalength)
{
Timerout =0xffff;
SPIINTStatus = McSPIChannelStatusGet(USS_PDMA_MISC_SPI3_BASE_ADDR,ch_id);
while(0 == (SPIINTStatus&SPI_CH_Tx_Mask))
{
SPIINTStatus = McSPIChannelStatusGet(USS_PDMA_MISC_SPI3_BASE_ADDR,ch_id);
Timerout--;
if(0 == Timerout)
{
//USS_MCU_McSPI5SetUp();
appLogPrintf("\nSPI3 SPITx break error ");
break;
}
}
McSPITransmitData(USS_PDMA_MISC_SPI3_BASE_ADDR,(uint32_t) (*pTxData),ch_id);
pTxData++;

Timerout =0xffff;
SPIINTStatus = McSPIChannelStatusGet(USS_PDMA_MISC_SPI3_BASE_ADDR,ch_id);
while(0 == (SPIINTStatus&SPI_CH_Rx_Mask))
{
SPIINTStatus = McSPIChannelStatusGet(USS_PDMA_MISC_SPI3_BASE_ADDR,ch_id);
Timerout--;
if(0 == Timerout)
{
//USS_MCU_McSPI5SetUp();
appLogPrintf("\nSPI3 SPITx break error ");
break;
}
}
*pRxData= (uint16_t)McSPIReceiveData(USS_PDMA_MISC_SPI3_BASE_ADDR,ch_id);

uint32_t wTemp ;

wTemp= (uint16_t)McSPIReceiveData(USS_PDMA_MISC_SPI3_BASE_ADDR,ch_id);

appLogPrintf("\nSPI3 Rx Data CH   %d    DATA   %x ",ch_id,wTemp);


pRxData++;
BufferCounter++;

}
USS_SPI3_DISABLE(ch_id);
}

  • Hi,

    First thing is to check pinmux while usecase is running and make sure all pins are configured for SPI input/output. Can you please use some Linux utility to get the value of the pinmux registers and confirm it is correct?

    Regards,

    Brijesh

  • Hi, 

    Yes, i wrote test code print out Tx and Rx PIN registers  value, it seems right

  • Hi,

    Are you sure you are seeing data output from SPI3? This is because of SPI3 is by default connected to internally mcu_spi1 at power up.. 

    In order to use SPI3 for the external input/output, you need to change  CTRLMMR_SPI3_CLKSEL[16].MSTR_LB_CLKSEL bit. Could you please try changing it? 

    Regards,

    Brijesh

  • Hi, 

     I add the code as below, after appInit(), before SPI initialization,

    #define CTRLMMR_SPI3_CLKSEL (0x0010819C)

    reg = 0x10000;
    HW_WR_REG32(CTRLMMR_SPI3_CLKSEL,reg);

    The issue is still there, SPI3 Rx registers keep 0, SPI5 work well.

    The screenshot is SPI3 channel3 work, and read out channel 1~3 RX register , the values are 0.

  • Hi,

    I check the different of MCSPI Registers value between SPI3 and SPI5, log as below,

    Please help me check there is any issue of the value?

    Is there any other Registers should be check?

    28.636904 s:
    [MCU2_0] Config Addr 110 SPI3 value 308 SPI5 value 308
    [MCU2_0] 28.736874 s:
    [MCU2_0] Config Addr 114 SPI3 value 1 SPI5 value 1
    [MCU2_0] 28.836877 s:
    [MCU2_0] Config Addr 118 SPI3 value 5550 SPI5 value 555 ------Interrupt enable register :SPI3 channel 1~3, SPI 5 channel 0~2
    [MCU2_0] 28.936876 s:
    [MCU2_0] Config Addr 11c SPI3 value 0 SPI5 value 0
    [MCU2_0] 29.036876 s:
    [MCU2_0] Config Addr 120 SPI3 value 0 SPI5 value 0
    [MCU2_0] 29.136876 s:
    [MCU2_0] Config Addr 124 SPI3 value 0 SPI5 value 0
    [MCU2_0] 29.236874 s:
    [MCU2_0] Config Addr 128 SPI3 value 1 SPI5 value 1

    /*******************************************************************channel 0**************************/
    [MCU2_0] 29.336878 s:
    [MCU2_0] Config Addr 12c SPI3 value 60000 SPI5 value 380607cd ------SPI3 Channel 0 is not use
    [MCU2_0] 29.436875 s:
    [MCU2_0] Config Addr 130 SPI3 value 0         SPI5 value 6
    [MCU2_0] 29.536874 s:
    [MCU2_0] Config Addr 134 SPI3 value 0         SPI5 value 200
    [MCU2_0] 29.636876 s:
    [MCU2_0] Config Addr 138 SPI3 value 0         SPI5 value 0 ----------TX register
    [MCU2_0] 29.736876 s:
    [MCU2_0] Config Addr 13c SPI3 value 0         SPI5 value bb194b7b ----------RX register
    /*******************************************************************channel 1**************************/
    [MCU2_0] 29.836874 s:
    [MCU2_0] Config Addr 140 SPI3 value 380607cd SPI5 value 380607cd
    [MCU2_0] 29.936876 s:
    [MCU2_0] Config Addr 144 SPI3 value 6               SPI5 value 6
    [MCU2_0] 30.036876 s:
    [MCU2_0] Config Addr 148 SPI3 value 200           SPI5 value 200
    [MCU2_0] 30.136874 s:
    [MCU2_0] Config Addr 14c SPI3 value ffff              SPI5 value 0 ----------TX register
    [MCU2_0] 30.236878 s:
    [MCU2_0] Config Addr 150 SPI3 value 0                SPI5 value 5eacfa ----------RX register
    /*******************************************************************channel 2**************************/
    [MCU2_0] 30.336875 s:
    [MCU2_0] Config Addr 154 SPI3 value 380607cd SPI5 value 380607cd
    [MCU2_0] 30.436873 s:
    [MCU2_0] Config Addr 158 SPI3 value 6               SPI5 value 6
    [MCU2_0] 30.536878 s:
    [MCU2_0] Config Addr 15c SPI3 value 200           SPI5 value 200
    [MCU2_0] 30.636876 s:
    [MCU2_0] Config Addr 160 SPI3 value ffff             SPI5 value 0 ----------TX register
    [MCU2_0] 30.736876 s:
    [MCU2_0] Config Addr 164 SPI3 value 0               SPI5 value 9618dde7 ----------RX register
    /*******************************************************************channel 3**************************/
    [MCU2_0] 30.836876 s:
    [MCU2_0] Config Addr 168 SPI3 value 380607cd SPI5 value 60000    ---------SPI5 Channel 3 is not use
    [MCU2_0] 30.936876 s:
    [MCU2_0] Config Addr 16c SPI3 value 6               SPI5 value 0
    [MCU2_0] 31.036878 s:
    [MCU2_0] Config Addr 170 SPI3 value 200           SPI5 value 0
    [MCU2_0] 31.136874 s:
    [MCU2_0] Config Addr 174 SPI3 value ffff             SPI5 value 0 ----------TX register
    [MCU2_0] 31.236878 s:
    [MCU2_0] Config Addr 178 SPI3 value 0               SPI5 value 0 ----------RX register

    /***********************************************CTRLMMR_SPI3_CLKSEL*********************************/
    [MCU2_0] 31.336876 s:
    [MCU2_0] SPI3 Config Addr 10819c value 10000 ----------CTRLMMR_SPI3_CLKSEL

  • Issue has been fixed, thanks!

  • Thanks Jafar, closing this ticket.