This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

TCAN4550 chip select, EasyDMA, 8 vs 32 bit SPI words and nRF52832

Hello! I have a custom board with two TCAN4550 over SPI to an nRF52832. One is for vehicle communication, the other for our proprietary bus communicating with external units. I've ported the official Texas TCAN library to Zephyr and would be more than happy to share it once it's been cleaned up.

The official driver uses three functions (start / burst / end). Start flips chip select low and transmits the header (first 8 bits are either a read or write cmd, next 16 bits are reg address and last 8 bits are number of words for the following read/write). Burst transmits/receives the number of words specified in the header. End just flips chip select high. Each word needs to be 32 bits, and each transaction can contain up to 256 words plus the header.

For a long time, I struggled to achieve communication, then discovered Zephyr pulls the chip select high after each individual spi_write / spi_read / spi_transceive. This reset the shift register in TCAN between start and burst functions. The TCAN requires chip select to be held low during the whole transaction. I disabled the zephyr chip select (basically sat it to an unused pin at the moment), and explicitly set the chip select before and after each complete spi transaction. Now everything is working.

My question is, what is the most appropriate way of controlling the chip select for the TCAN in Zephyr, when having two instances of the same driver and knowing it shall keep low until transaction is complete? And for safety, nothing else shall control the chip select except the driver. I could of course re-write the driver to concatenate the whole message, before sending it in a dynamically sized array. But I suspect unpredictable behaviour. They will be running in two individual threads.

Second question is, what is the most effective way of communicating? Four 8 bit words at a time or one 32 bit word (I didn't find any documentation if 32 is even supported)?

The nRF52832 will also have quite a lot of BT traffic simultaneous with TCAN. Would using EasyDMA be offloading the nRF significantly, and are there any drawbacks?

Related