This is the mail archive of the ecos-bugs@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug 1001897] lpc2xxx CAN driver improvements / enhancements


Please do not reply to this email, use the link below.

http://bugs.ecos.sourceware.org/show_bug.cgi?id=1001897

--- Comment #26 from Bernard Fouchà <bernard.fouche@kuantic.com> ---
(In reply to comment #13)
> > I can't test on the LPC1765 before next week at the earliest and the driver
> > I use is different because of the LPC1765 "pending interrupt problem", but
> > what you describe should appear here also if we have the same CAN cell.
> > 
> > Can you describe what you do on the CAN bus to reach bus off? I could try to
> > reproduce here and see if I also see RM staying at zero.
> > 
> > Did you check the value of EWL? If is 0 or 255 I wonder what happens...
> 
> Create a thread that prints a debug message in a loop via diag_printf (i.e.
> one message per second). Create a second thread that simply sends CAN
> messages (i.e. one message per second). When this application is running,
> simply unplug the CAN bus cable from the CAN connector.
> 
> If your debug message from the thread stops, then you know you are spinning
> in the CAN ISR. You can activate the debug output in the driver to see
> register contents and ISR reason (ICR_BUS_OFF) - it will be printed again
> and again ...

Sorry, it took me ages to be able to go back to that topic.

On the LPC1765, I just did something a bit different than what you wrote, I
unplugged the resistor on the CAN wires. Then I got BEI (Bus Error Interrupt)
in CAN1ICR.

When I look at the error counter, I have 0x00 (Tx) and 0x87 (Rx) while the
warning level is at the default 0x60.

Once I reach this point, the ISR is triggered again and again (and I'm not even
in a bus off condition since the test code didn't have time yet to try to send
a message: it is just floating signals on the wires that shows impossible CAN
frames).

Once the wires aren't floating any more, I have no more such interrupts. It
seems that the only way to stop having these repeated ISR is to reset the CAN
hardware driver or to disable the interrupt that reacts on a bus error or to
have the external condition (in this case bad wiring) to disappear. I did not
find in the documentation how to correctly process that case.

Then I re-installed the resistor but I had only my test node on the CAN bus.
Since no one could acknowledge frames, I had a bus off condition, that worked
as described: TxREC was at 0x7F , and CAN1MOD changed from 0x0 to 0x01 (reset
mode).

Hence in my opinion your patch is not needed on LPC1765 BUT the issue with
floating wires needs some attention and the documentation does not describe
exactly what's going on anyway whatever the version of this CAN cell.

All in all I think it is better to have this kind of processing (taking the
decision to reset the CAN controller) to be handled by higher level code
instead of having the ISR or DSR to magically do things.

I did not encountered problems when I was developing my app since the app
powers off the CAN cell as soon as a bus error or bus off condition occurs.
This is detected by a CAN event call back function that takes immediate action
and also reports this to higher level code. The app re-initialize the CAN a few
seconds later and then tries again to use the CAN bus. So I was immune to the
repeated ISR illness, whatever the reason. And my high level code is always
kept aware about what's going on on the wires.

If the CAN hardware driver is reset without having the app to know about it,
other weird things may  happen, especially if the higher level code assumes
than the CAN controller can recover from bus off by itself, or than a
previously queued message was correctly sent on the bus, etc.

Maybe the feature you added should send a new event reporting that the CAN
controller was reset? So high level code knows that it should be reconfigured
or messages resent? Anyway I don't use LPC22xx parts so for me this is not a
problem!

-- 
You are receiving this mail because:
You are the assignee for the bug.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]