11 years ago.

Program my own CAN functions by using the CAN controller registers of LPC1768

Hi,

Actualy i develop a CAN gateway, thanks to CAN functions on Mbed(can.read() and can.write()). It works correctly when messages are slow (1 message each 500ms). But when i receive messages each 100ms, the CAN gateway misses some messages and it's dangerous on my entire system. So, i want to programm my own CAN functions for resolve this problem. Can I programm CAN Controller registers of LPC1768 directly ? How ?

Thanks for your help. Anisse

1 Answer

11 years ago.

Hi Anisse,

I have not built a gateway app, but I can imagine a couple of things - 1) With those APIs, you are "polling", which I think should be able to keep up easily - depending on where else CPU cycles are going. What else is happening in your polling loop? And when you read a message, aside from pushing it to the other side, what else is happening. For instance, printing might be much slower than the CAN traffic, causing messages to be lost. 2) There are "attach" functions in CAN, so you can bypass polling and get a callback when a message is received. In these callbacks, you should not do anything time-consuming, like a printf.

I have been trying to use the attach function with CAN. I have tried on both P9 P10 and P29 P30 pins, but have been unsuccessful. The attach function is never called.

There was a reference to this problem here: http://mbed.org/forum/bugs-suggestions/topic/1039/

According to that link, the attach function has a bug which doesn't allow it to work as designed. Has this bug been fixed? Have you used the attach function with CAN? I would be grateful if anyone could offer any insight to this problem, as I don't think that there's a fault with my hardware.

posted by Arpan Das 14 May 2013