Timing Issues When Writing to Disconnected CAN channel

Programmable 6-channel router and data logger for CAN and CAN FD with I/O and optional Ethernet interface
Post Reply
dominic_v
Posts: 4
Joined: Wed 19. Jul 2023, 19:06

Timing Issues When Writing to Disconnected CAN channel

Post by dominic_v » Tue 17. Oct 2023, 22:18

Hello,

I am running an application based on the 31_SIMPLE_TCP_SERVER example.

My modification involves sending a test CAN message out of a port periodically from a RTX thread.

If I have a CAN device connected, I can transmit as fast as I like (say every one millisecond)

However, if I disconnect the CAN port, it seems to create an additional load on the RTOS and causing error. Specifically, I'm receiving the osRtxErrorTimerQueueOverflow error.

I expect the CAN_Write function to return the CAN_ERR_TX_FULL, but I didn't expect it to cause any additional timing issues with my system.
I checked the delta time to the call to CAN_Write, and it is consistent regardless of if another CAN device is connected or not. This makes sense as there are no while loops in the function.

Is there any added interrupt load that the FPGA introduces when sending to a disconnected CAN network?

Thanks,
Dominic

User avatar
PEAK-Support
Sales & Support
Sales & Support
Posts: 1646
Joined: Fri 10. Sep 2010, 19:34

Re: Timing Issues When Writing to Disconnected CAN channel

Post by PEAK-Support » Wed 18. Oct 2023, 14:10

If you disconnect the CAN cable without leaving a termination resistor on the Router the CAN Controller might see a Bus-OFF event due to improper signaling
(valid signal levels need a term-resistor). Here the CAN Controller generates a status frame showing Bus-OFF ( see can_user.c) .
There the CAN Controller is re-initialized, Firmware will continue transmission but again ending in a Bus-OFF situation. So you may get an endless loop here.

Try either to keep a termination on the Router's DSUB ( max. two status frames seen until error-passive), or modify your can_user.c to use a different handling in case of a Bus-OFF event.
--------------------------------
PEAK-System Technik
Technical Support Team
support[at]peak-system.com
-------------------------------

dominic_v
Posts: 4
Joined: Wed 19. Jul 2023, 19:06

Re: Timing Issues When Writing to Disconnected CAN channel

Post by dominic_v » Wed 18. Oct 2023, 14:51

I tried adding an external termination, and both an external and the internal, but it didn't make any difference.

Looking an my can_user.c (see attached), I only see what looks like re-initialization in the CAN_UserRead() function.
However, I'm not even doing any reads at all and I don't see any other calls to CAN_UnInitialize() or CAN_Initialize() other than at start up.

Any other ideas?
Attachments
can_user.c
(3.86 KiB) Downloaded 4817 times

User avatar
P.Steil
Hardware Development
Hardware Development
Posts: 32
Joined: Fri 14. Jan 2011, 10:27

Re: Timing Issues When Writing to Disconnected CAN channel

Post by P.Steil » Thu 19. Oct 2023, 08:55

the FPGA do not have any IRQ support yet. All data must be polled. You can check the following:

> Check if you have FPGA version 10 ( macro HW_FPGA_VERSION can be used for reading)
> If you read CAN data, do this from just a single point e.g. single thread
> Check your CAN_Write() and other functions. Typical examples the basic code is not thread save.
E.g. CAN_Write() from two threads may destroy data integrity

For deeper inspection we need your code via email ...
--------------------------------------------
PEAK-System HW development Team
support@peak-system.com
phone: +49-6151-8173-20
fax: +49-6151-8173-29
--------------------------------------------

Post Reply