Converting a CAN0 Example to use CAN1 Instead

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

Converting a CAN0 Example to use CAN1 Instead

1,096 Views
brian_ungar
Contributor III

I have a two LPCXpresso54S018 cards. Each card has a Dual CAN-FD Shield Board attached. I have run the mcan_interrupt_transfer code that comes with the SDK. The code works to demonstrate communications on CAN0 for both boards.

I have now made some minor changes to try the code using CAN1 instead. The code appears to not be getting any interrupts when communicating on CAN1. What am I doing wrong? The interface cable between the two cards was moved to the CAN1 channel on both cards.

I have attached the code that works using CAN0 along with my modified file that I thought would work for CAN1. Are there any other changes somewhere else that should be made?

Labels (1)
0 Kudos
4 Replies

1,091 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

I suppose that you do not configure the CAN1 bus pins, on the LPCXpressoo54S018 card, this is the pins assignment.

J10 connector

PIO3_19: CAN0_RD

PIO3_18: CAN0_TD

 

J9 connector:

PIO1_18: CAN0_RD

PIO1_17: CAN0_TD

If you want to use the CAN1 bus which is connected to pin2 and 4 of J9, you have to configure the PIO1_18 and PIO1_17 pins with the code in pin_mux.c

#define IOCON_PIO_FUNC5 5

void BOARD_InitPins(void)
{
/* Enables the clock for the IOCON block. 0 = Disable; 1 = Enable.: 0x01u */
CLOCK_EnableClock(kCLOCK_Iocon);

const uint32_t port1_pin18_config = (/* Pin is configured as CAN1_RD*/
IOCON_PIO_FUNC5 |
/* No addition pin function */
IOCON_PIO_MODE_INACT |
/* Input function is not inverted */
IOCON_PIO_INV_DI |
/* Enables digital function */
IOCON_PIO_DIGITAL_EN |
/* Input filter disabled */
IOCON_PIO_INPFILT_OFF |
/* Standard mode, output slew rate control is enabled */
IOCON_PIO_SLEW_STANDARD |
/* Open drain is disabled */
IOCON_PIO_OPENDRAIN_DI);

IOCON_PinMuxSet(IOCON, 1U, 18U, port1_pin18_config);

 

const uint32_t port1_pin17_config = (/* Pin is configured as CAN1_TD*/
IOCON_PIO_FUNC5 |
/* No addition pin function */
IOCON_PIO_MODE_INACT |
/* Input function is not inverted */
IOCON_PIO_INV_DI |
/* Enables digital function */
IOCON_PIO_DIGITAL_EN |
/* Input filter disabled */
IOCON_PIO_INPFILT_OFF |
/* Standard mode, output slew rate control is enabled */
IOCON_PIO_SLEW_STANDARD |
/* Open drain is disabled */
IOCON_PIO_OPENDRAIN_DI);

IOCON_PinMuxSet(IOCON, 1U, 17U, port1_pin17_config);

..........

}

Pls have a try.

This is only my guess, if you still have issue, pls update the ticket.

BR

XiangJun Rong

 

 

0 Kudos

1,086 Views
brian_ungar
Contributor III

I changed the pin_mux.c and pin_mux.h files as you suggested. I now see my interrupt callback being called with the correct expected status when I transmit a CAN packet. However, there appears to be no interrupt on the receiving card. I tried reversing which card was receiving vs transmitting and got the same result. Is there a jumper or something on the OM13099 shield board or the LPCXpresso54S018 board that has to be changed?

I also noticed that in the code that you gave me, that you set the IOCON_PIO_MODE_INACT bit for CAN1 while the original pin_mux.c code sets the IOCON_PIO_MODE_PULLUP bit instead for CAN0. I tried changing the bit for CAN1 to IOCON_PIO_MODE_PULLUP, this did not make a difference.

0 Kudos

1,080 Views
brian_ungar
Contributor III

As an additional note to my previous post, I tried talking between CAN0 and CAN1. The board running CAN0 was able to receive what was being output on the CAN1 connector from the board running CAN1. The CAN1 board, however, could still not receive anything from the board running CAN0.

0 Kudos

1,076 Views
brian_ungar
Contributor III

I finally found the source of my receive problem. I was mixing things up between RX FIFO 0 and RX FIFO 1. This occurred because I changed too many functions with a zero in their name to have a one in their name when I changed the code from CAN0 to CAN1.

The code now transmits and receives both on CAN0 and CAN1. I can also transmit between CAN0 and CAN1.

This thread (issue) can now be closed. Thank you for your help.

0 Kudos