u8g2 SPI and CAN conflict

I have a display configured with SPI, and another with I2C (for test purposes), and a MCP2515 CAN module, also on SPI.

The two SPI items have different SS ports.

After I initialise CANBUS, the u8g2 calls no longer result in messages being displayed.

I get the “BLUE” and “GREEN” messages displayed, but I am not getting “RED”.

Any guidance would be greatly appreciated.

Code is attached.

snippet.txt (1.04 KB)

It turned out to be a conflict between the display and the CAN card. I simply put the display on its own SPI pins and it worked.

You must never mix software emulated SPI (display) with hardware SPI (see U8g2 FAQ). Assigning other GPIO is one solution, another option could be to use the HW SPI constructor for the display.

Oliver