I am at a decision point in an application, and was wondering if anyone had experience in the options available to me?
I have a program transmitting CAN on 2 channels very reliably. However, when I change certain data in the CAN frames, I also update a 16x2 display via I2C. This is done synchronously in the same thread, and takes typically 150ms or so, suspending CAN transmission during this time. As I have frame periods of 40ms and up, this obviously plays havoc with my accuracy!
I tried moving the CAN transmission loop to a separate thread using simple threading such as “new Thread(CANSendingLoop).Start();”. But this slowed down the CAN sending thread (adding 20ms or so to all frame periods), and the display update happened at 1 character a second!
I am new to threading, but is there a large overhead with implementing threading which will cause slowdown like this in a CPU-intensive scenario?
My other option is to optimise the (seemingly-slow) display update (only update those parts of the display that I need to each time), minimising the temporary delay to the main loop…
Thanks in advance for any thoughts on the best way to head that anyone has!