I can't configure CAN on an LPC54608

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

I can't configure CAN on an LPC54608

793 Views
diegoperea
Contributor II

Hi, I have a CAN network with an MPC5634 and an MCF51JM128 assembled and now I want to add an LPC54608 to that network and I cannot find the correct configuration.

The MPC5634 has the following configuration:

/*-----------------------------------------------------------*/

/*          CAN_A.MCR Module Control Register       */

/*-----------------------------------------------------------*/

  CAN_A.MCR.R = 0x5980000F;

    /* Enabling the CAN module : Enabled */

    /* Freeze Enable :Enabled*/

    /* FIFO Enable :Disabled */

    /* Halt : Enabled*/

    /* Wake Up Interrupt Mask : Disabled */

    /* Soft Reset : Disabled */

    /* Supervisor Mode : Enabled */

    /* Self Wake Up : Disabled */

    /* Warning Interrupt : Disabled */

    /* Wake Up Source : Disabled */

    /* Doze Mode : Disabled */

    /* Self Reception : Disabled */

    /* Backwards Compatibility Configuration : Disabled */

    /* Local Priority Enable : Disabled */

    /* Abort Enable : Disabled */

    /* ID Acceptance Mode : A*/

    /* Maximum Number of Message Buffers : 15*/

/*------------------------------------------------------------*/

/*      CAN_A.CRControl Register            */

/*------------------------------------------------------------*/

  CAN_A.CR.R = 0x09DB2006;

    /* Bus -Off Interrupt Mask: Disabled */

    /* CAN bit Sampling Mode: 1 Sample */

    /* CAN Error Interrupt Mask: Disabled */

    /* Clock Source: System */

    /* Listen Only Mode: Disabled */

    /* Loop Back Mode: Disabled */

    /* Bus off Recovery: Enabled */

    /* Lowest Buffer Transfer First: Disabled*/

    /* Phase Segment1: 4 */

    /* Phase Segment2: 4 */

    /* Prescalar Division Factor: 10 */

    /* Propagation Segment: 7 */

    /* Resynchronization Jump Width: 4 */

    /* Timer Synch Mode: Disabled */

And the Coldfire has the following configuration:

XP - CodeWarrior-2020-05-12-20-28-27

For the LPC54608 I am using the MCUXpresso IDE SDK with the following configuration:

  MCAN_GetDefaultConfig(&mcanConfig);

  MCAN_Init(EXAMPLE_MCAN, &mcanConfig, MCAN_CLK_FREQ);

  /* Create MCAN handle structure and set call back function. */

  MCAN_TransferCreateHandle(EXAMPLE_MCAN, &mcanHandle, mcan_callback, NULL);

  /* Set Message RAM base address and clear to avoid BEU/BEC error. */

  MCAN_SetMsgRAMBase(EXAMPLE_MCAN, MSG_RAM_BASE);

  uint32_t *p=(uint32_t *)(MSG_RAM_BASE);

  memset(p, 0, TX_BUFFER_OFS + 0x10U);

  /* TX buffer config. */

  txBuffer.address = TX_BUFFER_OFS;

  txBuffer.dedicatedSize = 1U;

  txBuffer.fqSize = 0;

  txBuffer.datafieldSize = kMCAN_8ByteDatafield;

  MCAN_SetTxBufferConfig(EXAMPLE_MCAN, &txBuffer);

  /* Finish software initialization and enter normal mode, synchronizes to

    CAN bus, ready for communication */

  MCAN_EnterNormalMode(EXAMPLE_MCAN);

  txIdentifier = 0x321U;

  uint8_t tx_data[8]={0x0,0x1U,0x2U,0x3U,0x4U,0x5U,0x6U,0x7U};

  tx_data[0] += count++;

  txFrame.xtd = kMCAN_FrameIDStandard;

  txFrame.rtr = kMCAN_FrameTypeData;

  txFrame.fdf = 0;

  txFrame.brs = 0;

  txFrame.dlc = 8U;

  txFrame.id = txIdentifier << STDID_OFFSET;

  txFrame.data = tx_data;

  txFrame.size = 8U;

  txXfer.frame = &txFrame;

  txXfer.bufferIdx = 0;

  MCAN_TransferSendNonBlocking(EXAMPLE_MCAN, &mcanHandle, &txXfer);

After this the signal is seen on the oscilloscope but none of the devices on the network detect it.

I tried several options that the SDK allows me without results.

I need help.

Best Regards

Diego Perea

Labels (4)
Tags (3)
0 Kudos
1 Reply

690 Views
simon_hilt
Contributor II

Hello Diego,

I use the board LPC54618 and had similar problems with CAN. Unfortunately I am not familiar with the other devices.

The code you posted is certainly from one of those reference examples from the SDK, isn't it?
But it seems to me that it is not complete. I also took a reference example and modified it, but it contains more lines of code. Could you possibly attach the whole code? It will help me enormously with the debugging and I could try out your code on my board.

An error source could be the identifier. That was also my first mistake. Do the other boards also react to the ID 0x321? This is the ID from the example, but the boards in the network may expect a different ID.

This seems to me to be the most likely case, because you can see the signals on the oscilloscope, but the other participants do not react to them.


For debugging, I had the messages sent via PRINTF output to the console. Furthermore I used the callback function to display the status registers, which told me that my CAN is not initialized at all:

static void mcan_callback(CAN_Type *base, mcan_handle_t *handle, status_t status, uint32_t result, void *userData)
{
    PRINTF("Callback   status: 0x%x", status);
    PRINTF("     IR: 0x%x \r\n", base->IR);
    switch (status)...

About this output I could find out the error. You can find more information about this in my case at MCUXpresso combine mcan and ethernet  in the later comments.

Hope I could help. If it doesn't solve your problem, I would try your code on my board.

Best Regards

Simon

0 Kudos