I'm working on a distributed real-time application, where 4 MCUs (PIC18F45k22) are connected to a network. The real-time kernel FreeRTOS is running on each of the four PICs, and all MCUs exchange data in real-time through the network (bus), in order to accomplish their functions (sensing, regulation, control, display etc...).
The PICs that I use do not include a CAN module, and I cannot get an external one (or any other real-time communication protocol module). The only solution is to use I2C bus, which is not designed for real-time communication.
In order to improve my communication protocol, I'm trying to implement (in software) some algorithms that can manage message scheduling through the bus using I2C arbitration, and also implement error detection using CRC, and I really don't know where to start. I'm not even sure if this solution is valid for a real-time application.
Does anyone have an idea or advice? Is this solution valid? If so, how can I implement CRC (how to choose the appropriate polynomial)?