AnsweredAssumed Answered

MCUXpresso combine mcan and ethernet

Question asked by Simon Hilt on Apr 28, 2020
Latest reply on May 14, 2020 by Simon Hilt

Hello,

 

I use the CAN-FD Kit LPCXpresso54618 and its IDE MCUXpresso IDE V11.1.0 This is the first time I use an NXP board.

 

In my project I want to evaluate the messages of a CAN bus and send them via Ethernet to a measuring laptop.

I can compile and successfully run both communication interfaces in separate projects, but no matter how I merge the configurations of the projects, there will always be some errors or one of the two interfaces will not work.

 

First I started with the example mcan_interrupt_transfer and changed it a bit so that it communicates with the CAN case from Vector. In CANoe (Vector-Tool) I can send messages, which the NXP board reads and outputs to the console of the IDE.

 

Next, I took the example project lwip_udpecho_bm and modified it so that when a message arrives, it is sent back with a modified payload. using a packet sender (Packet Sender - Free utility to for sending / receiving of network packets. TCP, UDP, SSL. ) I can now send different packets which are output in the console of the NXP.

 

Ultimately I need to combine the two interfaces and create a project with a configuration that contains all the required packages and libraries. For this I have tried several steps:


1:    Add the missing packages to the project using the component manager:

The settings of the two projects are attached in the appendix.

I have to make this correction so that the program can be compiled and executed:

      opt.h:  #define LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT 1 (0 leads to error:

      "Bare metal requires LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT=1 because

      pbuf_free() is being called from an ISR")

        From  <https://community.nxp.com/message/1280097> lwIP - MCUXpresso SDK v2.7.0, IDE v11.1

 

If I now add the CAN packets to the Ethernet project, the program can be executed and the Ethernet interface works, but the CAN port is not active. I get the error message NACK (not acknowledged) in CANoe, so the bus device (the NXP board) is not active.

If I add the Ethernet packets to the CAN project the other way round, the Ethernet cannot be initialized, even if the program is executable. The console then says "Cannot initialize PHY...".

 

2: So in the next step I tried to create a completely new configuration using the Quickstart panel. But that doesn't work either and leads to the same mistake.

 

I have tried various additions of packages or variations of the libraries (Redlib, Newlib etc.), but never succeeded.

 

Do I have to pay attention to anything during configuration or do the two interfaces interfere with each other somehow?

If necessary, I can also upload the projects, but it already fails because of the default settings. I have only combined the two slightly modified examples from the SDK.

 

Another question: The previous projects are all written in C, but I would like to program in C++ and have tried to implement the example mcan_interrupt_transfer in C++. The NACK error occurred here as well.

 

A further question is whether I can combine MQTT with CAN, because the example lwip_mqtt_freertos uses the real time operating system Amazon FreeRTOS kernel.  I have only tested this example and did not try to implement it further.

 

I am very grateful for any help and advice!

Simon

Outcomes