No transitions on the SPI CS signal

Hi,

I am testing SPI on the Colibri iMX7 SoM plugged into an Aster Carrier Board running a Win Embedded 7 image.

I am able to see the SPI_CLK signal being generated when I initiate the transfer on the Aster X20 (23 #pin) when I initiate a transfer, but the CS signal is always sitting low, X20 (pin# 26).

Initially I assumed that when I call the Imx7Spi_Open() it would use the default pin numbers that are specified in the Aster’s manual and the Toradex’s spi library documentation. When this did not work, I used the Imx7Spi_SetConfigInt(hSpi, L"ioCS" .... to set the ioCS to COLIBRIPIN(86), but that also didn’t do the job.

Below is the code that I am using to initialize and transfer 16 bit frames over the SPI Bus. Surprisingly the ioCS configuration doesn’t seem to change because when I print the ioCS values read back it is set to 16.107, I am not sure how to translate that to SODIMM pin number…

Do you find anything amiss?

int _tmain(int argc, _TCHAR* argv[])
{
    HANDLE      hSpi    = NULL;
    BOOL        bReturn = FALSE;
    tVersion    ver     = {0, 0, 0};
    DWORD       value   = 0;

    Spi_GetVersion(&ver);
    printf("\nDemo Application for the SPI Library V%d.%d.%d", ver.Major, ver.Minor, ver.Build);

    hSpi = Imx7Spi_Init( L"SPI1" );
    if( hSpi == NULL )
        printf("\nERROR, (%s, %d), Failed to initialize SPI1", __FUNCTION__, __LINE__ );
    else
        printf("\nOK, (%s, %d), Spi handle created", __FUNCTION__, __LINE__ );


    /// Configuring the SPI Port

    /// Set Mode
    bReturn = Imx7Spi_SetConfigInt(hSpi, L"SpiMode", SpiMode0, StoreVolatile );
    if( bReturn == FALSE )
        printf("\nERROR, (%s, %d), Failed to set mode SPI", __FUNCTION__, __LINE__ );

    /// Set frequency of operation, 1 MHz
    bReturn = Imx7Spi_SetConfigInt(hSpi, L"BitRateHz", 1000000, StoreVolatile );
    if( bReturn == FALSE )
        printf("\nERROR, (%s, %d), Failed to set mode SPI", __FUNCTION__, __LINE__ );

    /*************************************************************************
                    Trying to get the SPI CS to work
    **************************************************************************/

    /// Checking the current CS configuration
    uIo ioCS_pin;
    bReturn = Imx7Spi_GetConfigInt( hSpi, L"ioCS", (DWORD *)&ioCS_pin );
    if( bReturn == FALSE )
        printf("\nERROR, (%s, %d), Failed to get ioCS setting", __FUNCTION__, __LINE__ );
    else
    {
        printf("\nOK, (%s, %d), ioCS ....%d.%d  %d", __FUNCTION__, __LINE__, ioCS_pin.ColibriPin.Tp, ioCS_pin.ColibriPin.Nr, ioCS_pin.GenericDefinition  );
    }
    
    /// Setting the new CS configuration, requesting the SPI library to use
    /// COLIBRI SODIMM Pin #86 (Available on Aster's X20 pin # 26)
    uIo newCS_Pin = COLIBRI_PIN(86);
    bReturn = Imx7Spi_SetConfigInt(hSpi, L"ioCS", (DWORD)newCS_Pin.GenericDefinition, StoreVolatile);
    if( bReturn == FALSE )
        printf("\nERROR, (%s, %d), Failed to set ioCS setting", __FUNCTION__, __LINE__ );

    /// Reading back to check whether the ioCS has been updated
    bReturn = Imx7Spi_GetConfigInt( hSpi, L"ioCS", (DWORD *)&ioCS_pin );
    if( bReturn == FALSE )
        printf("\nERROR, (%s, %d), Failed to get ioCS setting", __FUNCTION__, __LINE__ );
    else
    {
        printf("\nOK, (%s, %d), ioCS ....%d.%d  %d", __FUNCTION__, __LINE__, ioCS_pin.ColibriPin.Tp, ioCS_pin.ColibriPin.Nr, ioCS_pin.GenericDefinition  );
    }

    /*************************************************************************
                    Trying to get the SPI CS to work
    **************************************************************************/

    bReturn = Imx7Spi_GetConfigInt( hSpi, L"BitsPerWord", &value );
    if( bReturn == FALSE )
        printf("\nERROR, (%s, %d), Failed to get bits per word setting", __FUNCTION__, __LINE__ );
    else
    {
        printf("\nOK, (%s, %d), Bits per word setting ....%d", __FUNCTION__, __LINE__, value );
        if( value != 16 )
        {
            bReturn = Imx7Spi_SetConfigInt( hSpi, L"BitsPerWord", (DWORD)16, StoreVolatile );
            if( bReturn == FALSE )
                printf("\nERROR, (%s, %d), Failed to get bits per word setting", __FUNCTION__, __LINE__ );
        }
    }

    bReturn = Imx7Spi_Open( hSpi );
    if( bReturn == FALSE )
        printf("\nERROR, (%s, %d), Failed to open the spi port", __FUNCTION__, __LINE__ );

    while( 1 )
    {
        DWORD dataCount     = 0;
        DWORD rxBuffer[2]   = { 0xFFFFFFFF, 0xFFFFFFFF };
        DWORD spiData[2]    = { 0 };

        dataCount = Spi_ReadWrite( hSpi, rxBuffer, spiData, 1 );
        
        printf("\nAmount of data received  is %d, data (0x%08X)", dataCount, rxBuffer[0] );

        Sleep(100);
    }

	return 0;
}

In the schematics, the pin X20(26), GPIO07/SPI_CE1_N, is also connected to the CIF section as CIF_D_8, do I need to set this pin as a GPIO through the pin muxing?

Moreover, in the schematic the SPI_CE1_N is connected to Colibri SODIMM pin number 85 whereas in the toradex libraries help documentation says it is on the SODIMM pin 86. There is a mismatch …
Infact even the SoM manual says that the SODIMM pin 86 is supposed to be SPI_CS but the schematic and the SoM + Aster board physical connections have the SPI_CS connected to pin 85 …

The SPI_CS signal is working. I was going wrong in checking it over the X20(Pin 26), CIF_D_8 signal (this goes to the SODIMM_85).

The labelling on the X20 connector caused the confusion, since Pin 26 is labelled as SPI_CE1_N but the SSP_CS signal is not terminated at any of the X20 points.

I checked all SPI signals at the X18 connector eventually.

Dear @kapeed
Thank you for getting back. I’m glad to hear that you could solve the problem yourself :slight_smile:
Regards, Andy