SPI4 on Colibri T20

We are currently experimenting with a “Colibri T20 512MB IT” board to improve the (graphics) performance. A standard Toradex image is installed with the most recent tdxall library.

As the board doesn’t provide a CAN-Bus interface we want to attach an external SPI to CAN-Bus adapter. So we need a working SPI interface which is routed to the base board, e.g. SPI-4.

Our problem is that the clock for SPI-4 is disabled, so the SPI-IP isn’t running. Can you provide information on how to activate the SPI-port? Maybe this is just some registry setting.

There is no activation required, the whole SPI processing is done in the library code.

On a Colibri T20, tarting with a call…

HANDLE hSpi = Spi_Init(L"SPI4"); 

…is sufficient to use SPI 4 on GPIOs D0 (CLK), D4 (MOSI), D1 (MISO) and D3 (CS).

Regards, Andy

@andy.tx unfortunately, this does not work for us. We’re getting a handle from the init function, but if we want to set a config string/int on the handle, we’re getting a negative response from the method.

For better research, I attached my code (C# with TdxAllLib v2.2).

m_hCan = spi_teg.TegSpi_Init("SPI4");

can_teg.TegCan_SetConfigString(m_hCan, "Implementation", "MCP2515", TdxCommon.ParamStorageType.StoreVolatile);
can_teg.TegCan_SetConfigString(m_hCan, "FilterFrameFormat", "extended", TdxCommon.ParamStorageType.StoreVolatile);
can_teg.TegCan_SetConfigString(m_hCan, "FilterRemote", "none", TdxCommon.ParamStorageType.StoreVolatile);
can_teg.TegCan_SetConfigString(m_hCan, "RtrFormat", "data", TdxCommon.ParamStorageType.StoreVolatile);
can_teg.TegCan_SetConfigInt(m_hCan, "FilterID", 0x00, TdxCommon.ParamStorageType.StoreVolatile);
can_teg.TegCan_SetConfigInt(m_hCan, "FilterMask", 0x00, TdxCommon.ParamStorageType.StoreVolatile);
can_teg.TegCan_SetConfigInt(m_hCan, "BitRateHz", 500000, TdxCommon.ParamStorageType.StoreVolatile);

Dear @zualri

You cannot mix CAN and SPI handles. To call any CAN function, such as TegCan_SetConfigString(), you need to get a CAN handle by calling Can_Init() or TegCan_Init().

So you probably wanted to start your code with

m_hCan = can_teg.TegCan_Init("SPI4");  // instead of spi_teg.TegSpi_Init("SPI4")

If you use the debug version of the libraries, and have debug messages enabled in the config block, you should see related error output on the serial port.

Regards, Andy

Thanks for your help. With the debug messages, we were able to figure out, that our CAN controller was the cause of error.