# CAN bus and UART interfering

I have a PIC18F4680, and I want to interface with an Ecan module and UART at the same time. I am sending the UART message correctly and reading the CAN bus properly, but when trying to do both things at the same time the microcontroller stops working. Is the PIC18F4680 able to manage both communications without crashing?

If it is not possible to work with both communications at the same time, which microcontroller should I use? The programming code is done for MicroC so I would prefer a microcontroller that is supported by MicroC.

I have tried to simplify the firmware architecture, but still it doesn't work. Here is the code:

Msg_Rcvd = CANRead(&CAN_RxID, data_rx, &rx_DLC, CAN_Rcv_Flags);
id = CAN_RxID;
dato = data_rx;
UART1_Write('\$');
UART1_Write(dato[0]);
UART1_Write(dato[1]);
UART1_Write(dato[2]);
UART1_Write(dato[3]);
UART1_Write(dato[4]);
UART1_Write(dato[5]);
UART1_Write(dato[6]);
UART1_Write(dato[7]);


I have saved the values read from the CAN bus in different variables to avoid using both communications at the same time, but it is not working. I am not familiar with interrupts, and I do not know exactly how to use them. Has someone done something similar with interrupts?

• Is the pic18F4680 able to manage both comunications without crushing? - The MCU is able. Your code might not. May 25 '17 at 15:51
• @Eugene: Exactly. I've done this with no problems. Then again, I think about the firmware architecture before writing any code, and then write it carefully keeping the hardware characteristics in mind. May 25 '17 at 16:01
• Would be helpful if you provided a little more code. Like, how are variables defined, how is the shown routine called, etc. In particular, what does dato point to? May 26 '17 at 13:39