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.

TM4C123GH6PM: KSZ8795CLX SPI Reading Problem

Part Number: TM4C123GH6PM

Tool/software:

Hi Community Members,

We would like to read the 0x00 register of the KSZ8795CLX ethernet switch using tm4c123gh6pm with SPI.

We expect to get the value of 0x87 from 0x00 register of the KSZ8795CLX.

We send 0x03 (SPI read data command), 0x00 (register address), and 4 dummy bytes while receving 4 bytes.

However, we have not yet managed to get any meaningful data from the register. System clock, initialization, and reading functions with the logic analyzer screenshot can be seen in the followings:

How can we solve this problem?

System Clock:

SysCtlClockSet(SYSCTL_SYSDIV_10 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);

Initialization Function:

// Enable SSI0 peripheral
SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI0);

// Enable GPIO port A
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);

// Configure the pin muxing for SSI0 functions on port A2, A3, A4, and A5

GPIOPinConfigure(GPIO_PA2_SSI0CLK);

GPIOPinConfigure(GPIO_PA3_SSI0FSS);

GPIOPinConfigure(GPIO_PA4_SSI0RX);

GPIOPinConfigure(GPIO_PA5_SSI0TX);

// Configure the GPIO settings for the SSI pins
GPIOPinTypeSSI(GPIO_PORTA_BASE, GPIO_PIN_5 | GPIO_PIN_4 | GPIO_PIN_3 |GPIO_PIN_2);

// Configure and enable the SSI port for SPI master mode
SSIConfigSetExpClk(SSI0_BASE, SysCtlClockGet(), SSI_FRF_MOTO_MODE_1, SSI_MODE_MASTER, 1000000, 8);

// Enable the SSI0 module
SSIEnable(SSI0_BASE);

Reading Function:

while(SSIDataGetNonBlocking(SSI0_BASE, &pui32DataRx[0]))
{
}

SSIDataPut(SSI0_BASE, 0x03);
SSIDataPut(SSI0_BASE, 0x00);

for(ui32Index = 0; ui32Index < 4; ui32Index++)
{
SSIDataPut(SSI0_BASE, 0x00);
SSIDataGet(SSI0_BASE, &pui32DataRx[ui32Index]);
}

Thank you very much.

Best Regards.

  • We send 0x03 (SPI read data command), 0x00 (register address), and 4 dummy bytes while receving 4 bytes.

    T

    The waveform is doing exactly what you are intending to do by putting out 0x3 followed by five 0x0. However, the slave (your KSZ) is not returning data. You will need to investigate why the KSZ is not returning data. As far as I can tell, the master is working correctly as shown on MOSI. The MISO on the other hand is just flat. 

    What I notice is that the KSZ outputs its data on the falling edge. If that is the case, why do you use SSI_FRF_MOTO_MODE_1 and not SSI_FRF_MOTO_MODE_0?  In SSI_FRF_MOTO_MODE_1, the MOSI is clocked out at the rise edge but the slave is also using the rise edge to sample data which would not have enough setup time. In any case, you need to check the KSZ datasheet for the required timing as I'm not an expert in this third party IC. 

  • Thank you for your answer. 

    The reason we use SSI_FRF_MOTO_MODE_1 is that in modes 0 and 2 the clock is not continuous. However, in mode 1 and mode 3 the clock is continuous.

    In addition, we also tried the mode0, mode2, and mode3. However, we have not yet been able to obtain any meaningful data. You can see the log files below.

    Mode0:

    Mode2:

    Mode3:

  • Hi,

      Can you consult with KSZ8795CLX vendor and have them suggest things to look at? You have tried all different modes and they all return 0 from the slave. It is not something I can help. From the master point of view, it is behaving as intended. I think KSZ8795CLX vendor will be able to help you better. 

  • Hi,

    I will do it. I just wrote to anwer your question about the modes.

    Thank you very much.

    Best regards.