LCP54628 MCAN Configuration

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LCP54628 MCAN Configuration

4,609 Views
CVSta
Contributor III

Hello!

Please, someone could help me with CAN protocol configuration?

In this project I am using OM13098 development board with LPC54628 microcontroller and I'm working with MCUXpressoIDE v11.6.0 and with version 2.12 from SDK.

I saw and compiled the examples from SDK, but I think there is something weird with that examples.

I'm trying to do a loopback teste with the CAN Protocol, but following example code (lpcxpresso54628_mcan_loopback) is possible do this loopback without phisical connection beteween CAN0_RD (RX) and CAN0_TD (TX). In this way, isn't useful for one real application. It's right?

I expect to develop a example code with CAN0 working by interruptions and just works when I'll physically connect RX with TX like in serial communication.
In future, I intend to develop a master CAN with CAN1 and a slave CAN with CAN0.

Below there is the example code who I'm using and trying to unveil this mystery. If someone could help me, please could you contact me?

Labels (2)
0 Kudos
27 Replies

1,182 Views
CVSta
Contributor III

Hello @frank_m !!!
First I should say thank you for yout reply my question!
I saw the example mcan_interrupt_transfer in the same SDK like you said, but I think this is useful for 2 boards and works with callbacks functions.

In my case don't have 2 boards here and I need to develop a code with interrupt functions, this is a reason I'm trying to use mcan_loopback example for my model.
And about the transceivers, I trying to do something before read the "real" CAN Protocol. I'm just trying to send some knowed package and receive the same package, exactly like in serial communication. But the example loopback is weird, like I said before.

I'll follow your first ideia about initialize the CAN peripheral in full CAN mode.
Could you explain better your ideia? And could you show me who function are you thinking to change?

About your CANopen middleware package, if it's possible you share with me, I really be grateful for you send me. Because maybe it could be useful for my project.

Best regards.

0 Kudos

1,141 Views
frank_m
Senior Contributor III

If I remember correctly, the loopback mode is internal, i.e. the connection between Tx and Rx is on silicon.
Thus the signal never "leaves" the MCU.
It is a setting in the MCAN config register, you might need to consult the MCU user manual / datasheet.

An option interesting for you would be to turn off this loopback mode, and instead connect CAN Tx and Rx externally, i.e. on the board. This should yield the same result.

The interrupt-based example would be one example of how to configure the MCAN peripheral for normal operation.

> And about the transceivers, I trying to do something before read the "real" CAN Protocol.

Transceivers do only affect signal levels. As you might know, CAN uses a differential signal with different voltage levels.
But you can connect two CAN devices directly (without tranceivers), provided they have the same digital levels (supply voltage). Ground loops might become problematic, though.

1,112 Views
CVSta
Contributor III

Exactly, this example use the silicon internal loopback.

>An option interesting for you would be to turn off this loopback mode, and instead connect CAN Tx and Rx externally, i.e. on the board. This should yield the same result.

This is exactly what I want to do.
But when I do this, I don't receive the same buffer as I send.
I changed somethings in code and remove this internal loopback. So now, this code work if external loopback, but my received frame data isn't the same as I send. Below there is a photo from my terminal. Maybe it can be better explained.

0 Kudos

1,077 Views
frank_m
Senior Contributor III

I would definitely consult the manual, as Alice_Yang suggested.

To be honest, I don't have much experience with the LPC MCAN peripheral, though I dealt a lot CAN on other architectures.

I am not sure if the internal loopback mode requires the GPIO pins (for Tx/Rx) to be configured as alternative (CAN) functionality. You could compare this with the interrupt example.
The pin initialisation code of the project is usually found in pinmux.c / pinmux.h.

979 Views
CVSta
Contributor III

Hello Frank!
Thank you for your advice again.
I'm reading better all 35.14 chapters like Alice recommended.

About the pins, I confirmed it is being initialized with alternative (CAN) function in all example.
I think the point here is "remove" this internal connection between
tx and rx like explained in Figure 139 (section 35.14.1.7.2).
I'll publish this Figure 139 here.

0 Kudos

950 Views
frank_m
Senior Contributor III

I think the picture labelled "external loop back mode" is incorrect. The drawing contradicts the very term.

Perhaps a Copy&Paste error which requires quite a bit of work on the proofreader's side.

940 Views
CVSta
Contributor III

I don't think so, because in this case the output is readable with oscilloscope in CAN0_TX and just when I connect the tx with rx.
But in serial terminal isn't read the same package.

0 Kudos