<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: MCAN Configurations MCUXpresso IDE for LPCXpresso54628 in LPC Microcontrollers</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/MCAN-Configurations-MCUXpresso-IDE-for-LPCXpresso54628/m-p/1440430#M48436</link>
    <description>&lt;P&gt;Yes you are right.&lt;/P&gt;&lt;P&gt;But I am already using a setup with LPCXpresso54628 with CAN-Dual extension Board and a PEAK-USB connected to both CAN ports, as well as a CAN monitoring program PCAN-Explorer. As I already mentioned, sending from the PCAN-explorer to the development board is functioning, so I can read incoming CAN messages. But if I want to transmit a message it won't send it from the board to the PCAN-explorer and is halted in the function&amp;nbsp;&lt;EM&gt;MCAN_TransferSendBlocking&lt;/EM&gt; (more specific at function&amp;nbsp;&lt;EM&gt;MCAN_IsTransmitOccurred&lt;/EM&gt;).&lt;BR /&gt;But when I transmit a message using the example program "mcan_interrupt_transfer", I see incoming messages in the PCAN-explorer.&lt;/P&gt;&lt;P&gt;That's why I dont understand why transmission won't function with my own program.&lt;/P&gt;&lt;P&gt;Best regards.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here, my test code:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;/*
 * Copyright 2016-2022 NXP
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without modification,
 * are permitted provided that the following conditions are met:
 *
 * o Redistributions of source code must retain the above copyright notice, this list
 *   of conditions and the following disclaimer.
 *
 * o Redistributions in binary form must reproduce the above copyright notice, this
 *   list of conditions and the following disclaimer in the documentation and/or
 *   other materials provided with the distribution.
 *
 * o Neither the name of NXP Semiconductor, Inc. nor the names of its
 *   contributors may be used to endorse or promote products derived from this
 *   software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

/**
 * @file    test.c
 * @brief   Application entry point.
 */
#include "board.h"
#include "peripherals.h"
#include "stdlib.h"
#include "pin_mux.h"
#include "clock_config.h"
#include "fsl_debug_console.h"
#include "fsl_mcan.h"
#include "fsl_gpio.h"
#include "fsl_pint.h"
#include "fsl_inputmux.h"

#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;stdbool.h&amp;gt;

/*******************************************************************************
 * Defines
 ******************************************************************************/
#define LED2_PORT	3U
#define LED2_PIN	3U
#define LED3_PORT	2U
#define LED3_PIN	2U
#define LED_PIN_ON	0U
#define LED_PIN_OFF	1U

#define SW5_PORT_PIN	kINPUTMUX_GpioPort1Pin1ToPintsel
#define SW5_ALT_FUNC	kPINT_PinInt0

#define CAN_INPUT		CAN0
#define CAN_OUTPUT		CAN1
#define CAN_DATASIZE	(8U)
#define CAN_BITRATE		(500000U)
#define MCAN_CLK_FREQ	CLOCK_GetMCanClkFreq(0U)
#define STD_FILTER_OFS	0x0
#define STDID_OFFSET	(18U)
#define RX_FIFO0_OFS	0x10U
#define TX_BUFFER_OFS   0x20U
#define MSG_RAM_SIZE   	(TX_BUFFER_OFS + 8 + CAN_DATASIZE)

#define RX_IDENTIFIER	0x123U
#define TX_IDENTIFIER	0x124U

/*******************************************************************************
 * Variables
 ******************************************************************************/
static mcan_config_t mcanConfig;
static mcan_std_filter_element_config_t stdFilter;
//static mcan_fifo_transfer_t rxXfer;
static mcan_rx_buffer_frame_t rxFrame;
static uint8_t rx_data[CAN_DATASIZE];
static mcan_frame_filter_config_t rxFilter;
static mcan_rx_fifo_config_t rxFifo0;

static mcan_tx_buffer_frame_t txFrame;
static mcan_buffer_transfer_t txXfer;
static mcan_tx_buffer_config_t txBuffer;
static uint8_t tx_data[CAN_DATASIZE];
static uint8_t numMessage = 0;
#ifndef MSG_RAM_BASE
SDK_ALIGN(uint8_t msgRam[MSG_RAM_SIZE], 1U &amp;lt;&amp;lt; CAN_MRBA_BA_SHIFT);
#else
#define msgRam MSG_RAM_BASE
#endif

static volatile bool rxComplete = false;
static volatile bool txComplete = false;



/*******************************************************************************
 * Code
 ******************************************************************************/

/*!
 * @brief CAN0 IRQ handler (Receiver)
 */
void CAN0_IRQ0_IRQHandler(void)
{
    MCAN_ClearStatusFlag(CAN_INPUT, CAN_IR_RF0N_MASK);
    MCAN_ReadRxFifo(CAN_INPUT, 0, &amp;amp;rxFrame);
    rxComplete = true;
    SDK_ISR_EXIT_BARRIER;
}


/*!
 * @brief Initialize routine for CAN0 (receiver) and CAN1 (transeiver)
 */
static void CAN_Init(void)
{
	PRINTF("Initializing CAN ports.\r\n");

	/* Initialize board hardware. */
	/* attach 12 MHz clock to FLEXCOMM0 (debug console) */
	CLOCK_AttachClk(BOARD_DEBUG_UART_CLK_ATTACH);
	/* Set MCAN clock 220Mhz/11=20MHz. */
	CLOCK_SetClkDiv(kCLOCK_DivCan0Clk, 11U, true);
	CLOCK_SetClkDiv(kCLOCK_DivCan1Clk, 11U, true);

	/* Initialize CAN structure */
	MCAN_GetDefaultConfig(&amp;amp;mcanConfig);
	mcanConfig.baudRateA = CAN_BITRATE;
	mcanConfig.enableCanfdNormal = false;

	/* Improve timing config */
	mcan_timing_config_t timing_config;
	memset(&amp;amp;timing_config, 0, sizeof(timing_config));

    if (MCAN_CalculateImprovedTimingValues(mcanConfig.baudRateA, MCAN_CLK_FREQ, &amp;amp;timing_config))
    {
        /* Update the improved timing configuration*/
        memcpy(&amp;amp;(mcanConfig.timingConfig), &amp;amp;timing_config, sizeof(mcan_timing_config_t));
    }
    else
    {
        PRINTF("No found Improved Timing Configuration. Just used default configuration\r\n\r\n");
    }

    PRINTF("MCAN Clk-Frequency: %d Hz\r\n", MCAN_CLK_FREQ);
    PRINTF("Bitrate: %d Hz\r\n", mcanConfig.baudRateA);

    /* Initialize CAN with modified CAN structure */
	MCAN_Init(CAN_INPUT, &amp;amp;mcanConfig, MCAN_CLK_FREQ);
	MCAN_Init(CAN_OUTPUT, &amp;amp;mcanConfig, MCAN_CLK_FREQ);

	/* Create MCAN handle structure and set call back function. */
//	MCAN_TransferCreateHandle(CAN_INPUT, &amp;amp;mcanHandle_0, CAN0_IRQHandler, NULL);
//	MCAN_TransferCreateHandle(CAN_OUTPUT, &amp;amp;mcanHandle_1, CAN1_IRQHandler, NULL);

	/* Set Message RAM base address and clear to avoid BEU/BEC error. */
	MCAN_SetMsgRAMBase(CAN_INPUT, (uint32_t)msgRam);
	memset((void *)msgRam, 0, MSG_RAM_SIZE * sizeof(uint8_t));
	MCAN_SetMsgRAMBase(CAN_OUTPUT, (uint32_t)msgRam);
	memset((void *)msgRam, 0, MSG_RAM_SIZE * sizeof(uint8_t));

	/* STD filter config for rxCAN. */
	rxFilter.address  = STD_FILTER_OFS;
	rxFilter.idFormat = kMCAN_FrameIDStandard;
	rxFilter.listSize = 1U;
	rxFilter.nmFrame  = kMCAN_reject0;
	rxFilter.remFrame = kMCAN_rejectFrame;
	MCAN_SetFilterConfig(CAN_INPUT, &amp;amp;rxFilter);

	stdFilter.sfec = kMCAN_storeinFifo0;
	/* Classic filter mode, only filter matching ID. */
	stdFilter.sft   = kMCAN_classic;
	stdFilter.sfid1 = RX_IDENTIFIER;
	stdFilter.sfid2 = 0x7FFU;
	MCAN_SetSTDFilterElement(CAN_INPUT, &amp;amp;rxFilter, &amp;amp;stdFilter, 0);

	/* Enable RX fifo0 new message interrupt using interrupt line 0. */
	MCAN_EnableInterrupts(CAN_INPUT, 0, CAN_IE_RF0NE_MASK);
	EnableIRQ(CAN0_IRQ0_IRQn);

	/* RX fifo0 config. */
	rxFifo0.address       = RX_FIFO0_OFS;
	rxFifo0.elementSize   = 1U;
	rxFifo0.watermark     = 0;
	rxFifo0.opmode        = kMCAN_FifoBlocking;
	rxFifo0.datafieldSize = kMCAN_8ByteDatafield;
	MCAN_SetRxFifo0Config(CAN_INPUT, &amp;amp;rxFifo0);

	/* Enable RX fifo0 new message interrupt using interrupt line 0. */
	MCAN_EnableInterrupts(CAN_INPUT, 0, CAN_IE_RF0NE_MASK);
	EnableIRQ(CAN0_IRQ0_IRQn);

	/* TX buffer config. */
	memset(&amp;amp;txBuffer, 0, sizeof(txBuffer));
	txBuffer.address       = TX_BUFFER_OFS;
	txBuffer.dedicatedSize = 1U;
	txBuffer.fqSize        = 0;
	txBuffer.datafieldSize = kMCAN_8ByteDatafield;
	MCAN_SetTxBufferConfig(CAN_OUTPUT, &amp;amp;txBuffer);

	/* Finish software initialization and enter normal mode, synchronizes to
	 * CAN bus, ready for communication */
	MCAN_EnterNormalMode(CAN_INPUT);
	MCAN_EnterNormalMode(CAN_OUTPUT);

	PRINTF("Available for CAN communication.\r\n");
}

/*!
 * @brief Interrupt handler for Switch 5 =&amp;gt; transfer CAN message
 */
static void SW_Interrupt_Handler(pint_pin_int_t pintr, uint32_t pmatch_status)
{
	GPIO_PortToggle(GPIO, LED3_PORT, 1u &amp;lt;&amp;lt; LED3_PIN);

	PRINTF("Press any key to trigger one-shot transmission\r\n\r\n");
	GETCHAR();

	PRINTF("Transmitting CAN message...\r\n");

	/* Config TX frame data. */
	uint8_t cnt = 0;
	for (cnt = 0; cnt &amp;lt; CAN_DATASIZE; cnt++)
	{
		tx_data[cnt] = cnt;
	}

	tx_data[0] += numMessage++;
	txFrame.xtd  = kMCAN_FrameIDStandard;
	txFrame.rtr  = kMCAN_FrameTypeData;
	txFrame.fdf  = 0;
	txFrame.brs  = 0;
	txFrame.dlc  = 8U;
	txFrame.id   = TX_IDENTIFIER &amp;lt;&amp;lt; STDID_OFFSET;
	txFrame.data = tx_data;
	txFrame.size = CAN_DATASIZE;
	txXfer.frame     = &amp;amp;txFrame;
	txXfer.bufferIdx = 0;

	//status_t status = MCAN_WriteTxBuffer(CAN_OUTPUT, 0, &amp;amp;txFrame);
	//status_t status = MCAN_TransferSendNonBlocking(CAN_OUTPUT, &amp;amp;mcanHandle_1, &amp;amp;txXfer);
	status_t status = MCAN_TransferSendBlocking(CAN_OUTPUT, 0, &amp;amp;txFrame);
	if(status == kStatus_Success)
	{
		PRINTF("Transmited CAN message!\r\n");
	}
	else
	{
		PRINTF("*Error: Failed to transmit CAN message*\r\n");
	}

	txComplete = false;

}

/*!
 * @brief Initialize routine for LED2 and SW5
 */
void GPIO_Init(void)
{
	PRINTF("Initializing LED2 and SW5.\r\n");

	/* Define the init structure for the LED and SW pin*/
	gpio_pin_config_t led_config = {
		kGPIO_DigitalOutput,
		0,
	};

	/* Init output LED2 and 3 GPIO. */
	GPIO_PortInit(GPIO, LED2_PORT);
	GPIO_PinInit(GPIO, LED2_PORT, LED2_PIN, &amp;amp;led_config);
	GPIO_PinWrite(GPIO, LED2_PORT, LED2_PIN, LED_PIN_OFF);

	GPIO_PortInit(GPIO, LED3_PORT);
	GPIO_PinInit(GPIO, LED3_PORT, LED3_PIN, &amp;amp;led_config);
	GPIO_PinWrite(GPIO, LED3_PORT, LED3_PIN, LED_PIN_OFF);

	/* Init input switch 5 GPIO. */
	INPUTMUX_Init(INPUTMUX);
	INPUTMUX_AttachSignal(INPUTMUX, SW5_ALT_FUNC, SW5_PORT_PIN);
	/* Turnoff clock to inputmux to save power. Clock is only needed to make changes */
	INPUTMUX_Deinit(INPUTMUX);

	/* Initialize the PINT module */
	PINT_Init(PINT);
	/* Make PINT channel 0 react to falling edges */
	PINT_PinInterruptConfig(PINT, SW5_ALT_FUNC, kPINT_PinIntEnableFallEdge, SW_Interrupt_Handler);

	/* Enable callbacks for PINT0 by Index */
	PINT_EnableCallbackByIndex(PINT, SW5_ALT_FUNC);
}

/*
 * @brief   Application entry point.
 */
int main(void)
{
	/* Init board hardware. */
 	BOARD_InitBootPins();
	BOARD_InitBootClocks();
	BOARD_InitBootPeripherals();

	/* Init FSL debug console */
	BOARD_InitDebugConsole();

	/* Init LED and SW */
	GPIO_Init();

	/* Init CAN TX and RX */
	CAN_Init();

	uint8_t cnt = 0;
	rxFrame.size = CAN_DATASIZE;

    /* Enter an infinite loop, print received CAN messages. */
    while(1)
    {
		if(rxComplete)
		{
			/* After call the API of rMCAN_TransferReceiveFifoNonBlocking success, we can
			 * only get a point (rxFrame.data) to the fifo reading entrance.
			 * Copy the received frame data from the FIFO by the pointer(rxFrame.data). */
			memcpy(rx_data, rxFrame.data, rxFrame.size);

			PRINTF("Received Frame ID: 0x%x\r\n", rxFrame.id &amp;gt;&amp;gt; STDID_OFFSET);
			PRINTF("Received Frame DATA: ");

			cnt = 0;
			while (cnt &amp;lt; rxFrame.size)
			{
				PRINTF("0x%x ", rx_data[cnt++]);
			}
			PRINTF("\r\n");
			rxComplete = false;
		}
    }

    return 0;
}&lt;/LI-CODE&gt;</description>
    <pubDate>Thu, 07 Apr 2022 09:19:56 GMT</pubDate>
    <dc:creator>SimonSchnee</dc:creator>
    <dc:date>2022-04-07T09:19:56Z</dc:date>
    <item>
      <title>MCAN Configurations MCUXpresso IDE for LPCXpresso54628</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/MCAN-Configurations-MCUXpresso-IDE-for-LPCXpresso54628/m-p/1439597#M48420</link>
      <description>&lt;P&gt;Hello!&lt;BR /&gt;&lt;BR /&gt;I am writing a MCAN module which I will use for a project. I used for implementation the &lt;EM&gt;mcan_interrupt_transfer&lt;/EM&gt; example.&lt;/P&gt;&lt;P&gt;But when I implement it in almost the same way, I can't transmit or receive any CAN message (see my implementation below). I wonder if I need to do specific settings in the peripheral or pin section of the MCUXpresso IDE.&lt;/P&gt;&lt;P&gt;Here are some settings I did for now:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Pins CAN0_RD and CAN0_TD =&amp;gt; enabled&lt;/LI&gt;&lt;LI&gt;Pins CAN1_RD and CAN1_TD =&amp;gt; enabled&lt;/LI&gt;&lt;LI&gt;Clocks for CAN0 and CAN1 enabled&lt;/LI&gt;&lt;LI&gt;CAN0 =&amp;gt; Mode: Interrupts&lt;/LI&gt;&lt;LI&gt;CAN1 =&amp;gt; Mode: Transfer&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Another question would be, if it is possible to transmit message without having to use the interrupt transmit function&amp;nbsp;&lt;EM&gt;MCAN_TransferSendNonBlocking.&amp;nbsp;&lt;/EM&gt;I would rather use the function&amp;nbsp;&lt;EM&gt;MCAN_WriteTxBuffer.&amp;nbsp;&lt;/EM&gt;Is this possible or transmitting data in the "same" way?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Source code:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;/**
 * @file    test.c
 * @brief   Application entry point.
 */
#include "board.h"
#include "peripherals.h"
#include "stdlib.h"
#include "pin_mux.h"
#include "clock_config.h"
#include "fsl_debug_console.h"
#include "LPC54628.h"
#include "fsl_mcan.h"
#include "fsl_gpio.h"
#include "fsl_pint.h"
#include "fsl_inputmux.h"

#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;stdbool.h&amp;gt;

/*******************************************************************************
 * Defines
 ******************************************************************************/
#define LED2_PORT	3U
#define LED2_PIN	3U
#define LED3_PORT	2U
#define LED3_PIN	2U
#define LED_PIN_ON	0U
#define LED_PIN_OFF	1U

#define SW5_PORT_PIN	kINPUTMUX_GpioPort1Pin1ToPintsel
#define SW5_ALT_FUNC	kPINT_PinInt0

#define CAN_INPUT		CAN0
#define CAN_OUTPUT		CAN1
#define CAN_DATASIZE	(8U)
#define MCAN_CLK_FREQ	CLOCK_GetMCanClkFreq(0U)
#define STD_FILTER_OFS	0x0
#define STDID_OFFSET	(18U)
#define RX_FIFO0_OFS	0x10U
#define TX_BUFFER_OFS   0x20U
#define MSG_RAM_SIZE   	(TX_BUFFER_OFS + 8 + CAN_DATASIZE)

#define RX_IDENTIFIER	0x123U
#define TX_IDENTIFIER	0x124U

/*******************************************************************************
 * Variables
 ******************************************************************************/
static mcan_handle_t mcanHandle_0;
static mcan_handle_t mcanHandle_1;
static mcan_config_t mcanConfig;

static mcan_std_filter_element_config_t stdFilter;
static mcan_fifo_transfer_t rxXfer;
static mcan_rx_buffer_frame_t rxFrame;
static uint8_t rx_data[CAN_DATASIZE];
static mcan_frame_filter_config_t rxFilter;
static mcan_rx_fifo_config_t rxFifo0;

static mcan_tx_buffer_frame_t txFrame;
static mcan_buffer_transfer_t txXfer;
static mcan_tx_buffer_config_t txBuffer;
static uint8_t tx_data[CAN_DATASIZE];
static uint8_t numMessage = 0;
#ifndef MSG_RAM_BASE
SDK_ALIGN(uint8_t msgRam[MSG_RAM_SIZE], 1U &amp;lt;&amp;lt; CAN_MRBA_BA_SHIFT);
#else
#define msgRam MSG_RAM_BASE
#endif

static volatile bool rxComplete = false;
static volatile bool txComplete = false;



/*******************************************************************************
 * Code
 ******************************************************************************/

/*!
 * @brief CAN0 IRQ handler (Receiver)
 */
static void CAN0_IRQHandler(CAN_Type *base, mcan_handle_t *handle, status_t status, uint32_t result, void *userData)
{
	if(status == kStatus_MCAN_RxFifo0Idle)
	{
		GPIO_PortToggle(GPIO, LED2_PORT, 1u &amp;lt;&amp;lt; LED2_PIN);
		PRINTF("Received CAN 0 message.\r\n");
		rxComplete = true;
	}
	else if(status == kStatus_MCAN_TxIdle)
	{
		PRINTF("Transfered CAN 0 message.\r\n");
	}
}

/*!
 * @brief CAN1 IRQ handler (Receiver)
 */
static void CAN1_IRQHandler(CAN_Type *base, mcan_handle_t *handle, status_t status, uint32_t result, void *userData)
{
	if(status == kStatus_MCAN_RxFifo0Idle)
	{
		GPIO_PortToggle(GPIO, LED3_PORT, 1u &amp;lt;&amp;lt; LED3_PIN);
		PRINTF("Received CAN 1 message.\r\n");
	}
	else if(status == kStatus_MCAN_TxIdle)
	{
		txComplete = true;
		PRINTF("Transfered CAN 1 message.\r\n");
	}
}

/*!
 * @brief Initialize routine for CAN0 (receiver) and CAN1 (transeiver)
 */
static void CAN_Init(void)
{
	PRINTF("Initializing CAN ports.\r\n");

	/* Initialize board hardware. */
	/* attach 12 MHz clock to FLEXCOMM0 (debug console) */
	CLOCK_AttachClk(BOARD_DEBUG_UART_CLK_ATTACH);
	/* Set MCAN clock 220Mhz/11=20MHz. */
	CLOCK_SetClkDiv(kCLOCK_DivCan0Clk, 11U, true);
	CLOCK_SetClkDiv(kCLOCK_DivCan1Clk, 11U, true);

	/* Initialize CAN structure */
	MCAN_GetDefaultConfig(&amp;amp;mcanConfig);

	/* Improve timing config */
	mcan_timing_config_t timing_config;
	memset(&amp;amp;timing_config, 0, sizeof(timing_config));

    if (MCAN_CalculateImprovedTimingValues(mcanConfig.baudRateA, MCAN_CLK_FREQ, &amp;amp;timing_config))
    {
        /* Update the improved timing configuration*/
        memcpy(&amp;amp;(mcanConfig.timingConfig), &amp;amp;timing_config, sizeof(mcan_timing_config_t));
    }
    else
    {
        PRINTF("No found Improved Timing Configuration. Just used default configuration\r\n\r\n");
    }

    PRINTF("MCAN Clk-Frequency: %d Hz\r\n", MCAN_CLK_FREQ);

    /* Initialize CAN with modified CAN structure */
	MCAN_Init(CAN_INPUT, &amp;amp;mcanConfig, MCAN_CLK_FREQ);
	MCAN_Init(CAN_OUTPUT, &amp;amp;mcanConfig, MCAN_CLK_FREQ);

	/* Create MCAN handle structure and set call back function. */
	MCAN_TransferCreateHandle(CAN_INPUT, &amp;amp;mcanHandle_0, CAN0_IRQHandler, NULL);
	MCAN_TransferCreateHandle(CAN_OUTPUT, &amp;amp;mcanHandle_1, CAN1_IRQHandler, NULL);

	/* Set Message RAM base address and clear to avoid BEU/BEC error. */
	MCAN_SetMsgRAMBase(CAN_INPUT, (uint32_t)msgRam);
	memset((void *)msgRam, 0, MSG_RAM_SIZE * sizeof(uint8_t));
	MCAN_SetMsgRAMBase(CAN_OUTPUT, (uint32_t)msgRam);
	memset((void *)msgRam, 0, MSG_RAM_SIZE * sizeof(uint8_t));

	/* STD filter config for rxCAN. */
	rxFilter.address  = STD_FILTER_OFS;
	rxFilter.idFormat = kMCAN_FrameIDStandard;
	rxFilter.listSize = 1U;
	rxFilter.nmFrame  = kMCAN_reject0;
	rxFilter.remFrame = kMCAN_rejectFrame;
	MCAN_SetFilterConfig(CAN_INPUT, &amp;amp;rxFilter);

	stdFilter.sfec = kMCAN_storeinFifo0;
	/* Classic filter mode, only filter matching ID. */
	stdFilter.sft   = kMCAN_classic;
	stdFilter.sfid1 = RX_IDENTIFIER;
	stdFilter.sfid2 = 0x7FFU;
	MCAN_SetSTDFilterElement(CAN_INPUT, &amp;amp;rxFilter, &amp;amp;stdFilter, 0);

	/* RX fifo0 config. */
	rxFifo0.address       = RX_FIFO0_OFS;
	rxFifo0.elementSize   = 1U;
	rxFifo0.watermark     = 0;
	rxFifo0.opmode        = kMCAN_FifoBlocking;
	rxFifo0.datafieldSize = kMCAN_8ByteDatafield;
	MCAN_SetRxFifo0Config(CAN_INPUT, &amp;amp;rxFifo0);

	/* TX buffer config. */
	memset(&amp;amp;txBuffer, 0, sizeof(txBuffer));
	txBuffer.address       = TX_BUFFER_OFS;
	txBuffer.dedicatedSize = 1U;
	txBuffer.fqSize        = 0;
	txBuffer.datafieldSize = kMCAN_8ByteDatafield;
	MCAN_SetTxBufferConfig(CAN_OUTPUT, &amp;amp;txBuffer);

	/* Finish software initialization and enter normal mode, synchronizes to
	 * CAN bus, ready for communication */
	MCAN_EnterNormalMode(CAN_INPUT);
	MCAN_EnterNormalMode(CAN_OUTPUT);

	PRINTF("Available for CAN communication.\r\n");
}

/*!
 * @brief Interrupt handler for Switch 5 =&amp;gt; transfer CAN message
 */
static void SW_Interrupt_Handler(pint_pin_int_t pintr, uint32_t pmatch_status)
{
	GPIO_PortToggle(GPIO, LED3_PORT, 1u &amp;lt;&amp;lt; LED3_PIN);

	PRINTF("Press any key to trigger one-shot transmission\r\n\r\n");
	GETCHAR();

	PRINTF("Transfering CAN message...\r\n");

	/* Config TX frame data. */
	uint8_t cnt = 0;
	for (cnt = 0; cnt &amp;lt; CAN_DATASIZE; cnt++)
	{
		tx_data[cnt] = cnt;
	}

	tx_data[0] += numMessage++;
	txFrame.xtd  = kMCAN_FrameIDStandard;
	txFrame.rtr  = kMCAN_FrameTypeData;
	txFrame.fdf  = 0;
	txFrame.brs  = 0;
	txFrame.dlc  = 8U;
	txFrame.id   = TX_IDENTIFIER &amp;lt;&amp;lt; STDID_OFFSET;
	txFrame.data = tx_data;
	txFrame.size = CAN_DATASIZE;
	txXfer.frame     = &amp;amp;txFrame;
	txXfer.bufferIdx = 0;

	//status_t status = MCAN_WriteTxBuffer(CAN_OUTPUT, 0, &amp;amp;txFrame);
	status_t status = MCAN_TransferSendNonBlocking(CAN_OUTPUT, &amp;amp;mcanHandle_1, &amp;amp;txXfer);
	if(status == kStatus_Success)
	{
		PRINTF("Transfered CAN message!\r\n");
	}
	else
	{
		PRINTF("*Error: Failed to transfered CAN message*\r\n");
	}

	txComplete = false;

}

/*!
 * @brief Initialize routine for LED2 and SW5
 */
void GPIO_Init(void)
{
	PRINTF("Initializing LED2 and SW5.\r\n");

	/* Define the init structure for the LED and SW pin*/
	gpio_pin_config_t led_config = {
		kGPIO_DigitalOutput,
		0,
	};

	/* Init output LED2 and 3 GPIO. */
	GPIO_PortInit(GPIO, LED2_PORT);
	GPIO_PinInit(GPIO, LED2_PORT, LED2_PIN, &amp;amp;led_config);
	GPIO_PinWrite(GPIO, LED2_PORT, LED2_PIN, LED_PIN_OFF);

	GPIO_PortInit(GPIO, LED3_PORT);
	GPIO_PinInit(GPIO, LED3_PORT, LED3_PIN, &amp;amp;led_config);
	GPIO_PinWrite(GPIO, LED3_PORT, LED3_PIN, LED_PIN_OFF);

	/* Init input switch 5 GPIO. */
	INPUTMUX_Init(INPUTMUX);
	INPUTMUX_AttachSignal(INPUTMUX, SW5_ALT_FUNC, SW5_PORT_PIN);
	/* Turnoff clock to inputmux to save power. Clock is only needed to make changes */
	INPUTMUX_Deinit(INPUTMUX);

	/* Initialize the PINT module */
	PINT_Init(PINT);
	/* Make PINT channel 0 react to falling edges */
	PINT_PinInterruptConfig(PINT, SW5_ALT_FUNC, kPINT_PinIntEnableFallEdge, SW_Interrupt_Handler);

	/* Enable callbacks for PINT0 by Index */
	PINT_EnableCallbackByIndex(PINT, SW5_ALT_FUNC);
}

/*
 * @brief   Application entry point.
 */
int main(void)
{
	/* Init board hardware. */
 	BOARD_InitBootPins();
	BOARD_InitBootClocks();
	BOARD_InitBootPeripherals();

	/* Init FSL debug console */
	BOARD_InitDebugConsole();

	/* Init LED and SW */
	GPIO_Init();

	/* Init CAN TX and RX */
	CAN_Init();

	uint8_t cnt = 0;

    /* Enter an infinite loop, print received CAN messages. */
    while(1)
    {
    	PRINTF("Press any key to trigger one-shot transmission\r\n\r\n");
		GETCHAR();

		PRINTF("Transfering CAN message...\r\n");

		/* Config TX frame data. */
		cnt = 0;
		for (cnt = 0; cnt &amp;lt; CAN_DATASIZE; cnt++)
		{
			tx_data[cnt] = cnt;
		}

		tx_data[0] += numMessage++;
		txFrame.xtd  = kMCAN_FrameIDStandard;
		txFrame.rtr  = kMCAN_FrameTypeData;
		txFrame.fdf  = 0;
		txFrame.brs  = 0;
		txFrame.dlc  = 8U;
		txFrame.id   = TX_IDENTIFIER &amp;lt;&amp;lt; STDID_OFFSET;
		txFrame.data = tx_data;
		txFrame.size = CAN_DATASIZE;
		txXfer.frame     = &amp;amp;txFrame;
		txXfer.bufferIdx = 0;

		//status_t status = MCAN_WriteTxBuffer(CAN_OUTPUT, 0, &amp;amp;txFrame);
		status_t status = MCAN_TransferSendNonBlocking(CAN_OUTPUT, &amp;amp;mcanHandle_1, &amp;amp;txXfer);
		if(status == kStatus_Success)
		{
			PRINTF("Transfered CAN message!\r\n");
		}
		else
		{
			PRINTF("*Error: Failed to transfered CAN message*\r\n");
		}

		while (!txComplete)
		{
		}
		txComplete = false;

		/* Start receive data through Rx FIFO 0. */
		memset(rx_data, 0, sizeof(uint8_t) * CAN_DATASIZE);

		/* the MCAN engine can't auto to get rx payload size, we need set it. */
		rxFrame.size = CAN_DATASIZE;
		rxXfer.frame = &amp;amp;rxFrame;
		MCAN_TransferReceiveFifoNonBlocking(CAN_INPUT, 0, &amp;amp;mcanHandle_0, &amp;amp;rxXfer);

		while (!rxComplete)
		{
		}
		rxComplete = false;

		/* After call the API of rMCAN_TransferReceiveFifoNonBlocking success, we can
		 * only get a point (rxFrame.data) to the fifo reading entrance.
		 * Copy the received frame data from the FIFO by the pointer(rxFrame.data). */
		memcpy(rx_data, rxFrame.data, rxFrame.size);

		PRINTF("Received Frame ID: 0x%x\r\n", rxFrame.id &amp;gt;&amp;gt; STDID_OFFSET);
		PRINTF("Received Frame DATA: ");

		cnt = 0;
		while (cnt &amp;lt; rxFrame.size)
		{
			PRINTF("0x%x ", rx_data[cnt++]);
		}
		PRINTF("\r\n");
    }

    return 0 ;
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Apr 2022 09:23:26 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/MCAN-Configurations-MCUXpresso-IDE-for-LPCXpresso54628/m-p/1439597#M48420</guid>
      <dc:creator>SimonSchnee</dc:creator>
      <dc:date>2022-04-06T09:23:26Z</dc:date>
    </item>
    <item>
      <title>Re: MCAN Configurations MCUXpresso IDE for LPCXpresso54628</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/MCAN-Configurations-MCUXpresso-IDE-for-LPCXpresso54628/m-p/1440223#M48425</link>
      <description>&lt;P&gt;I have not worked with the CAN peripheral of the LPC546xx yet, but with both this MCU and with CAN (on other MCUs).&lt;/P&gt;&lt;P&gt;And I am not sure why you picked &lt;EM&gt;&lt;STRONG&gt;this&lt;/STRONG&gt; &lt;/EM&gt;example. CAN is multi-user bus, which supports a multitude of nodes on one bus.&lt;/P&gt;&lt;P&gt;The example you picked is basically a CAN gateway, which translates messages from one bus to another. My company uses such gateway functionality in one of it's devices, and it is everything but trouble-free.I am not sure if you need this complexity for your application.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Apr 2022 05:35:30 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/MCAN-Configurations-MCUXpresso-IDE-for-LPCXpresso54628/m-p/1440223#M48425</guid>
      <dc:creator>frank_m</dc:creator>
      <dc:date>2022-04-07T05:35:30Z</dc:date>
    </item>
    <item>
      <title>Re: MCAN Configurations MCUXpresso IDE for LPCXpresso54628</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/MCAN-Configurations-MCUXpresso-IDE-for-LPCXpresso54628/m-p/1440249#M48426</link>
      <description>&lt;P&gt;There are two examples for the CAN module. One for testing CAN internally in a loopback and the other one uses interrupts to detect receiving and transmitting of CAN messages.&lt;/P&gt;&lt;P&gt;I just wanna use the CAN module for receiving and transmitting of CAN messages. Receiving should use interrupts to correspond fast to a incoming message. Thats why I used this example.&lt;/P&gt;&lt;P&gt;Do you have a better example for my purpose or any sugestion how to get it to work?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Apr 2022 06:08:55 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/MCAN-Configurations-MCUXpresso-IDE-for-LPCXpresso54628/m-p/1440249#M48426</guid>
      <dc:creator>SimonSchnee</dc:creator>
      <dc:date>2022-04-07T06:08:55Z</dc:date>
    </item>
    <item>
      <title>Re: MCAN Configurations MCUXpresso IDE for LPCXpresso54628</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/MCAN-Configurations-MCUXpresso-IDE-for-LPCXpresso54628/m-p/1440338#M48430</link>
      <description>&lt;P&gt;As said, I have not used the LPC546xx CAN peripheral yet, and thus did not check the related SDK examples.&lt;/P&gt;&lt;P&gt;But AFAIK, the loopback is based on an internal loopback mode of the peripheral, and you would have to change the configuration. Other MCUs do not have such a mode, and one needs to connect Tx and Rx manually.&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;gt; ... and the other one uses interrupts to detect receiving and transmitting of CAN messages.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;If this is not the mentioned gateway example, I would rather choose that.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;By the way, you usually can't transmit CAN messages from an interrupt directly. CAN is a message-arbitrated bus, and another node might block you. Therefore most CAN peripherals have "message boxes" with either private memory or a chunk reserved from GPRAM. Upon a TxE interrupt, one only needs to refill such a message buffer (with the message usually taken from a SW queue) and mark it for transmission.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Your mileage might vary. I had been working similar issues/implementations on Fujitsu/Cypress MCUs lately, whith different CAN peripheral implementations.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Apr 2022 07:42:54 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/MCAN-Configurations-MCUXpresso-IDE-for-LPCXpresso54628/m-p/1440338#M48430</guid>
      <dc:creator>frank_m</dc:creator>
      <dc:date>2022-04-07T07:42:54Z</dc:date>
    </item>
    <item>
      <title>Re: MCAN Configurations MCUXpresso IDE for LPCXpresso54628</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/MCAN-Configurations-MCUXpresso-IDE-for-LPCXpresso54628/m-p/1440343#M48431</link>
      <description>&lt;P&gt;Thanks for the input.&lt;/P&gt;&lt;P&gt;I got receiving of CAN messages working now, with the loopback example (I just did not enable loopback, therefore I can receive messages from connected CAN simulation).&lt;BR /&gt;But I got the problem, that when I want to transmit something over CAN it just does not send a message on the CAN bus. For example it is stuck in the&amp;nbsp; MCAN_TransferSendBlocking() function at the point of&amp;nbsp;MCAN_IsTransmitOccurred() =&amp;gt; that means it is waiting until the transmission is done, which is not the case ...&lt;/P&gt;&lt;P&gt;I also wanted to only use the&amp;nbsp;MCAN_WriteTxBuffer() function to write the CAN data into the transmit buffer. Inserting data into the tansmit buffer works, but it also does not send the data on the CAN bus.&lt;/P&gt;&lt;P&gt;Am I doing something wrong here?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Apr 2022 07:52:19 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/MCAN-Configurations-MCUXpresso-IDE-for-LPCXpresso54628/m-p/1440343#M48431</guid>
      <dc:creator>SimonSchnee</dc:creator>
      <dc:date>2022-04-07T07:52:19Z</dc:date>
    </item>
    <item>
      <title>Re: MCAN Configurations MCUXpresso IDE for LPCXpresso54628</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/MCAN-Configurations-MCUXpresso-IDE-for-LPCXpresso54628/m-p/1440426#M48435</link>
      <description>&lt;P&gt;&lt;EM&gt;&amp;gt; But I got the problem, that when I want to transmit something over CAN it just does not send a message on the CAN bus. For example it is stuck in the&amp;nbsp; MCAN_TransferSendBlocking() function at the point of&amp;nbsp;MCAN_IsTransmitOccurred() =&amp;gt; that means it is waiting until the transmission is done, which is not the case ...&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I am not sure about your level of experience with CAN, but it seems you are more of a beginner in this regard.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;For proper transmission, you need at least one second node (CAN bus device). Otherwise, a transmit will not succeed. You can connect a scope to the bus lines, and compare it to the specs.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;To forgo the physical bus configuration (with transceivers, cabling and termination resistor), you can&amp;nbsp; connect two boards directly (i.e. cross the Rx and Tx on digital level) with not too long lines.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Another essential tool is a CAN adapter for the PC, and some CAN monitoring software. My company uses the PEAK PCAN-USB, and alternatively the (more expensive) Vektor adapters and software.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Alternatively, you might manage with a scope that includes a CAN protocol interpretation package (scope firmware).&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Apr 2022 09:09:09 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/MCAN-Configurations-MCUXpresso-IDE-for-LPCXpresso54628/m-p/1440426#M48435</guid>
      <dc:creator>frank_m</dc:creator>
      <dc:date>2022-04-07T09:09:09Z</dc:date>
    </item>
    <item>
      <title>Re: MCAN Configurations MCUXpresso IDE for LPCXpresso54628</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/MCAN-Configurations-MCUXpresso-IDE-for-LPCXpresso54628/m-p/1440430#M48436</link>
      <description>&lt;P&gt;Yes you are right.&lt;/P&gt;&lt;P&gt;But I am already using a setup with LPCXpresso54628 with CAN-Dual extension Board and a PEAK-USB connected to both CAN ports, as well as a CAN monitoring program PCAN-Explorer. As I already mentioned, sending from the PCAN-explorer to the development board is functioning, so I can read incoming CAN messages. But if I want to transmit a message it won't send it from the board to the PCAN-explorer and is halted in the function&amp;nbsp;&lt;EM&gt;MCAN_TransferSendBlocking&lt;/EM&gt; (more specific at function&amp;nbsp;&lt;EM&gt;MCAN_IsTransmitOccurred&lt;/EM&gt;).&lt;BR /&gt;But when I transmit a message using the example program "mcan_interrupt_transfer", I see incoming messages in the PCAN-explorer.&lt;/P&gt;&lt;P&gt;That's why I dont understand why transmission won't function with my own program.&lt;/P&gt;&lt;P&gt;Best regards.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here, my test code:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;/*
 * Copyright 2016-2022 NXP
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without modification,
 * are permitted provided that the following conditions are met:
 *
 * o Redistributions of source code must retain the above copyright notice, this list
 *   of conditions and the following disclaimer.
 *
 * o Redistributions in binary form must reproduce the above copyright notice, this
 *   list of conditions and the following disclaimer in the documentation and/or
 *   other materials provided with the distribution.
 *
 * o Neither the name of NXP Semiconductor, Inc. nor the names of its
 *   contributors may be used to endorse or promote products derived from this
 *   software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

/**
 * @file    test.c
 * @brief   Application entry point.
 */
#include "board.h"
#include "peripherals.h"
#include "stdlib.h"
#include "pin_mux.h"
#include "clock_config.h"
#include "fsl_debug_console.h"
#include "fsl_mcan.h"
#include "fsl_gpio.h"
#include "fsl_pint.h"
#include "fsl_inputmux.h"

#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;stdbool.h&amp;gt;

/*******************************************************************************
 * Defines
 ******************************************************************************/
#define LED2_PORT	3U
#define LED2_PIN	3U
#define LED3_PORT	2U
#define LED3_PIN	2U
#define LED_PIN_ON	0U
#define LED_PIN_OFF	1U

#define SW5_PORT_PIN	kINPUTMUX_GpioPort1Pin1ToPintsel
#define SW5_ALT_FUNC	kPINT_PinInt0

#define CAN_INPUT		CAN0
#define CAN_OUTPUT		CAN1
#define CAN_DATASIZE	(8U)
#define CAN_BITRATE		(500000U)
#define MCAN_CLK_FREQ	CLOCK_GetMCanClkFreq(0U)
#define STD_FILTER_OFS	0x0
#define STDID_OFFSET	(18U)
#define RX_FIFO0_OFS	0x10U
#define TX_BUFFER_OFS   0x20U
#define MSG_RAM_SIZE   	(TX_BUFFER_OFS + 8 + CAN_DATASIZE)

#define RX_IDENTIFIER	0x123U
#define TX_IDENTIFIER	0x124U

/*******************************************************************************
 * Variables
 ******************************************************************************/
static mcan_config_t mcanConfig;
static mcan_std_filter_element_config_t stdFilter;
//static mcan_fifo_transfer_t rxXfer;
static mcan_rx_buffer_frame_t rxFrame;
static uint8_t rx_data[CAN_DATASIZE];
static mcan_frame_filter_config_t rxFilter;
static mcan_rx_fifo_config_t rxFifo0;

static mcan_tx_buffer_frame_t txFrame;
static mcan_buffer_transfer_t txXfer;
static mcan_tx_buffer_config_t txBuffer;
static uint8_t tx_data[CAN_DATASIZE];
static uint8_t numMessage = 0;
#ifndef MSG_RAM_BASE
SDK_ALIGN(uint8_t msgRam[MSG_RAM_SIZE], 1U &amp;lt;&amp;lt; CAN_MRBA_BA_SHIFT);
#else
#define msgRam MSG_RAM_BASE
#endif

static volatile bool rxComplete = false;
static volatile bool txComplete = false;



/*******************************************************************************
 * Code
 ******************************************************************************/

/*!
 * @brief CAN0 IRQ handler (Receiver)
 */
void CAN0_IRQ0_IRQHandler(void)
{
    MCAN_ClearStatusFlag(CAN_INPUT, CAN_IR_RF0N_MASK);
    MCAN_ReadRxFifo(CAN_INPUT, 0, &amp;amp;rxFrame);
    rxComplete = true;
    SDK_ISR_EXIT_BARRIER;
}


/*!
 * @brief Initialize routine for CAN0 (receiver) and CAN1 (transeiver)
 */
static void CAN_Init(void)
{
	PRINTF("Initializing CAN ports.\r\n");

	/* Initialize board hardware. */
	/* attach 12 MHz clock to FLEXCOMM0 (debug console) */
	CLOCK_AttachClk(BOARD_DEBUG_UART_CLK_ATTACH);
	/* Set MCAN clock 220Mhz/11=20MHz. */
	CLOCK_SetClkDiv(kCLOCK_DivCan0Clk, 11U, true);
	CLOCK_SetClkDiv(kCLOCK_DivCan1Clk, 11U, true);

	/* Initialize CAN structure */
	MCAN_GetDefaultConfig(&amp;amp;mcanConfig);
	mcanConfig.baudRateA = CAN_BITRATE;
	mcanConfig.enableCanfdNormal = false;

	/* Improve timing config */
	mcan_timing_config_t timing_config;
	memset(&amp;amp;timing_config, 0, sizeof(timing_config));

    if (MCAN_CalculateImprovedTimingValues(mcanConfig.baudRateA, MCAN_CLK_FREQ, &amp;amp;timing_config))
    {
        /* Update the improved timing configuration*/
        memcpy(&amp;amp;(mcanConfig.timingConfig), &amp;amp;timing_config, sizeof(mcan_timing_config_t));
    }
    else
    {
        PRINTF("No found Improved Timing Configuration. Just used default configuration\r\n\r\n");
    }

    PRINTF("MCAN Clk-Frequency: %d Hz\r\n", MCAN_CLK_FREQ);
    PRINTF("Bitrate: %d Hz\r\n", mcanConfig.baudRateA);

    /* Initialize CAN with modified CAN structure */
	MCAN_Init(CAN_INPUT, &amp;amp;mcanConfig, MCAN_CLK_FREQ);
	MCAN_Init(CAN_OUTPUT, &amp;amp;mcanConfig, MCAN_CLK_FREQ);

	/* Create MCAN handle structure and set call back function. */
//	MCAN_TransferCreateHandle(CAN_INPUT, &amp;amp;mcanHandle_0, CAN0_IRQHandler, NULL);
//	MCAN_TransferCreateHandle(CAN_OUTPUT, &amp;amp;mcanHandle_1, CAN1_IRQHandler, NULL);

	/* Set Message RAM base address and clear to avoid BEU/BEC error. */
	MCAN_SetMsgRAMBase(CAN_INPUT, (uint32_t)msgRam);
	memset((void *)msgRam, 0, MSG_RAM_SIZE * sizeof(uint8_t));
	MCAN_SetMsgRAMBase(CAN_OUTPUT, (uint32_t)msgRam);
	memset((void *)msgRam, 0, MSG_RAM_SIZE * sizeof(uint8_t));

	/* STD filter config for rxCAN. */
	rxFilter.address  = STD_FILTER_OFS;
	rxFilter.idFormat = kMCAN_FrameIDStandard;
	rxFilter.listSize = 1U;
	rxFilter.nmFrame  = kMCAN_reject0;
	rxFilter.remFrame = kMCAN_rejectFrame;
	MCAN_SetFilterConfig(CAN_INPUT, &amp;amp;rxFilter);

	stdFilter.sfec = kMCAN_storeinFifo0;
	/* Classic filter mode, only filter matching ID. */
	stdFilter.sft   = kMCAN_classic;
	stdFilter.sfid1 = RX_IDENTIFIER;
	stdFilter.sfid2 = 0x7FFU;
	MCAN_SetSTDFilterElement(CAN_INPUT, &amp;amp;rxFilter, &amp;amp;stdFilter, 0);

	/* Enable RX fifo0 new message interrupt using interrupt line 0. */
	MCAN_EnableInterrupts(CAN_INPUT, 0, CAN_IE_RF0NE_MASK);
	EnableIRQ(CAN0_IRQ0_IRQn);

	/* RX fifo0 config. */
	rxFifo0.address       = RX_FIFO0_OFS;
	rxFifo0.elementSize   = 1U;
	rxFifo0.watermark     = 0;
	rxFifo0.opmode        = kMCAN_FifoBlocking;
	rxFifo0.datafieldSize = kMCAN_8ByteDatafield;
	MCAN_SetRxFifo0Config(CAN_INPUT, &amp;amp;rxFifo0);

	/* Enable RX fifo0 new message interrupt using interrupt line 0. */
	MCAN_EnableInterrupts(CAN_INPUT, 0, CAN_IE_RF0NE_MASK);
	EnableIRQ(CAN0_IRQ0_IRQn);

	/* TX buffer config. */
	memset(&amp;amp;txBuffer, 0, sizeof(txBuffer));
	txBuffer.address       = TX_BUFFER_OFS;
	txBuffer.dedicatedSize = 1U;
	txBuffer.fqSize        = 0;
	txBuffer.datafieldSize = kMCAN_8ByteDatafield;
	MCAN_SetTxBufferConfig(CAN_OUTPUT, &amp;amp;txBuffer);

	/* Finish software initialization and enter normal mode, synchronizes to
	 * CAN bus, ready for communication */
	MCAN_EnterNormalMode(CAN_INPUT);
	MCAN_EnterNormalMode(CAN_OUTPUT);

	PRINTF("Available for CAN communication.\r\n");
}

/*!
 * @brief Interrupt handler for Switch 5 =&amp;gt; transfer CAN message
 */
static void SW_Interrupt_Handler(pint_pin_int_t pintr, uint32_t pmatch_status)
{
	GPIO_PortToggle(GPIO, LED3_PORT, 1u &amp;lt;&amp;lt; LED3_PIN);

	PRINTF("Press any key to trigger one-shot transmission\r\n\r\n");
	GETCHAR();

	PRINTF("Transmitting CAN message...\r\n");

	/* Config TX frame data. */
	uint8_t cnt = 0;
	for (cnt = 0; cnt &amp;lt; CAN_DATASIZE; cnt++)
	{
		tx_data[cnt] = cnt;
	}

	tx_data[0] += numMessage++;
	txFrame.xtd  = kMCAN_FrameIDStandard;
	txFrame.rtr  = kMCAN_FrameTypeData;
	txFrame.fdf  = 0;
	txFrame.brs  = 0;
	txFrame.dlc  = 8U;
	txFrame.id   = TX_IDENTIFIER &amp;lt;&amp;lt; STDID_OFFSET;
	txFrame.data = tx_data;
	txFrame.size = CAN_DATASIZE;
	txXfer.frame     = &amp;amp;txFrame;
	txXfer.bufferIdx = 0;

	//status_t status = MCAN_WriteTxBuffer(CAN_OUTPUT, 0, &amp;amp;txFrame);
	//status_t status = MCAN_TransferSendNonBlocking(CAN_OUTPUT, &amp;amp;mcanHandle_1, &amp;amp;txXfer);
	status_t status = MCAN_TransferSendBlocking(CAN_OUTPUT, 0, &amp;amp;txFrame);
	if(status == kStatus_Success)
	{
		PRINTF("Transmited CAN message!\r\n");
	}
	else
	{
		PRINTF("*Error: Failed to transmit CAN message*\r\n");
	}

	txComplete = false;

}

/*!
 * @brief Initialize routine for LED2 and SW5
 */
void GPIO_Init(void)
{
	PRINTF("Initializing LED2 and SW5.\r\n");

	/* Define the init structure for the LED and SW pin*/
	gpio_pin_config_t led_config = {
		kGPIO_DigitalOutput,
		0,
	};

	/* Init output LED2 and 3 GPIO. */
	GPIO_PortInit(GPIO, LED2_PORT);
	GPIO_PinInit(GPIO, LED2_PORT, LED2_PIN, &amp;amp;led_config);
	GPIO_PinWrite(GPIO, LED2_PORT, LED2_PIN, LED_PIN_OFF);

	GPIO_PortInit(GPIO, LED3_PORT);
	GPIO_PinInit(GPIO, LED3_PORT, LED3_PIN, &amp;amp;led_config);
	GPIO_PinWrite(GPIO, LED3_PORT, LED3_PIN, LED_PIN_OFF);

	/* Init input switch 5 GPIO. */
	INPUTMUX_Init(INPUTMUX);
	INPUTMUX_AttachSignal(INPUTMUX, SW5_ALT_FUNC, SW5_PORT_PIN);
	/* Turnoff clock to inputmux to save power. Clock is only needed to make changes */
	INPUTMUX_Deinit(INPUTMUX);

	/* Initialize the PINT module */
	PINT_Init(PINT);
	/* Make PINT channel 0 react to falling edges */
	PINT_PinInterruptConfig(PINT, SW5_ALT_FUNC, kPINT_PinIntEnableFallEdge, SW_Interrupt_Handler);

	/* Enable callbacks for PINT0 by Index */
	PINT_EnableCallbackByIndex(PINT, SW5_ALT_FUNC);
}

/*
 * @brief   Application entry point.
 */
int main(void)
{
	/* Init board hardware. */
 	BOARD_InitBootPins();
	BOARD_InitBootClocks();
	BOARD_InitBootPeripherals();

	/* Init FSL debug console */
	BOARD_InitDebugConsole();

	/* Init LED and SW */
	GPIO_Init();

	/* Init CAN TX and RX */
	CAN_Init();

	uint8_t cnt = 0;
	rxFrame.size = CAN_DATASIZE;

    /* Enter an infinite loop, print received CAN messages. */
    while(1)
    {
		if(rxComplete)
		{
			/* After call the API of rMCAN_TransferReceiveFifoNonBlocking success, we can
			 * only get a point (rxFrame.data) to the fifo reading entrance.
			 * Copy the received frame data from the FIFO by the pointer(rxFrame.data). */
			memcpy(rx_data, rxFrame.data, rxFrame.size);

			PRINTF("Received Frame ID: 0x%x\r\n", rxFrame.id &amp;gt;&amp;gt; STDID_OFFSET);
			PRINTF("Received Frame DATA: ");

			cnt = 0;
			while (cnt &amp;lt; rxFrame.size)
			{
				PRINTF("0x%x ", rx_data[cnt++]);
			}
			PRINTF("\r\n");
			rxComplete = false;
		}
    }

    return 0;
}&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 07 Apr 2022 09:19:56 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/MCAN-Configurations-MCUXpresso-IDE-for-LPCXpresso54628/m-p/1440430#M48436</guid>
      <dc:creator>SimonSchnee</dc:creator>
      <dc:date>2022-04-07T09:19:56Z</dc:date>
    </item>
    <item>
      <title>Re: MCAN Configurations MCUXpresso IDE for LPCXpresso54628</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/MCAN-Configurations-MCUXpresso-IDE-for-LPCXpresso54628/m-p/1440443#M48437</link>
      <description>&lt;P&gt;I do not know what changed now, but both transmitting and receiving is now working.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Nevertheless thank you for your input.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Current implementation:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;/*
 * Copyright 2016-2022 NXP
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without modification,
 * are permitted provided that the following conditions are met:
 *
 * o Redistributions of source code must retain the above copyright notice, this list
 *   of conditions and the following disclaimer.
 *
 * o Redistributions in binary form must reproduce the above copyright notice, this
 *   list of conditions and the following disclaimer in the documentation and/or
 *   other materials provided with the distribution.
 *
 * o Neither the name of NXP Semiconductor, Inc. nor the names of its
 *   contributors may be used to endorse or promote products derived from this
 *   software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

/**
 * @file    test.c
 * @brief   Application entry point.
 */
#include "board.h"
#include "peripherals.h"
#include "stdlib.h"
#include "pin_mux.h"
#include "clock_config.h"
#include "fsl_debug_console.h"
#include "fsl_mcan.h"
#include "fsl_gpio.h"
#include "fsl_pint.h"
#include "fsl_inputmux.h"

#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;stdbool.h&amp;gt;

/*******************************************************************************
 * Defines
 ******************************************************************************/
#define LED2_PORT	3U
#define LED2_PIN	3U
#define LED3_PORT	2U
#define LED3_PIN	2U
#define LED_PIN_ON	0U
#define LED_PIN_OFF	1U

#define SW5_PORT_PIN	kINPUTMUX_GpioPort1Pin1ToPintsel
#define SW5_ALT_FUNC	kPINT_PinInt0

#define CAN_INPUT		CAN0
#define CAN_OUTPUT		CAN0
#define CAN_DATASIZE	(8U)
#define CAN_BITRATE		(500000U)
#define MCAN_CLK_FREQ	CLOCK_GetMCanClkFreq(0U)
#define STD_FILTER_OFS	0x0
#define STDID_OFFSET	(18U)
#define RX_FIFO0_OFS	0x10U
#define TX_BUFFER_OFS   0x20U
#define MSG_RAM_SIZE   	(TX_BUFFER_OFS + 8 + CAN_DATASIZE)

#define RX_IDENTIFIER	0x123U
#define TX_IDENTIFIER	0x124U

/*******************************************************************************
 * Variables
 ******************************************************************************/
static mcan_config_t mcanConfig;
static mcan_std_filter_element_config_t stdFilter;
//static mcan_fifo_transfer_t rxXfer;
static mcan_rx_buffer_frame_t rxFrame;
static uint8_t rx_data[CAN_DATASIZE];
static mcan_frame_filter_config_t rxFilter;
static mcan_rx_fifo_config_t rxFifo0;

static mcan_tx_buffer_frame_t txFrame;
static mcan_buffer_transfer_t txXfer;
static mcan_tx_buffer_config_t txBuffer;
static uint8_t tx_data[CAN_DATASIZE];
static uint8_t numMessage = 0;
#ifndef MSG_RAM_BASE
SDK_ALIGN(uint8_t msgRam[MSG_RAM_SIZE], 1U &amp;lt;&amp;lt; CAN_MRBA_BA_SHIFT);
#else
#define msgRam MSG_RAM_BASE
#endif

static volatile bool rxComplete = false;
static volatile bool txComplete = false;



/*******************************************************************************
 * Code
 ******************************************************************************/

/*!
 * @brief CAN0 IRQ handler (Receiver)
 */
void CAN0_IRQ0_IRQHandler(void)
{
    MCAN_ClearStatusFlag(CAN_INPUT, CAN_IR_RF0N_MASK);
    MCAN_ReadRxFifo(CAN_INPUT, 0, &amp;amp;rxFrame);
    rxComplete = true;
    SDK_ISR_EXIT_BARRIER;
}


/*!
 * @brief Initialize routine for CAN0 (receiver) and CAN1 (transeiver)
 */
static void CAN_Init(void)
{
	PRINTF("Initializing CAN ports.\r\n");

	/* Initialize board hardware. */
	/* attach 12 MHz clock to FLEXCOMM0 (debug console) */
	CLOCK_AttachClk(BOARD_DEBUG_UART_CLK_ATTACH);
	/* Set MCAN clock 220Mhz/11=20MHz. */
	CLOCK_SetClkDiv(kCLOCK_DivCan0Clk, 11U, true);
	CLOCK_SetClkDiv(kCLOCK_DivCan1Clk, 11U, true);

	/* Initialize CAN structure */
	MCAN_GetDefaultConfig(&amp;amp;mcanConfig);
	mcanConfig.baudRateA = CAN_BITRATE;
	mcanConfig.enableCanfdNormal = false;

	/* Improve timing config */
	mcan_timing_config_t timing_config;
	memset(&amp;amp;timing_config, 0, sizeof(timing_config));

    if (MCAN_CalculateImprovedTimingValues(mcanConfig.baudRateA, MCAN_CLK_FREQ, &amp;amp;timing_config))
    {
        /* Update the improved timing configuration*/
        memcpy(&amp;amp;(mcanConfig.timingConfig), &amp;amp;timing_config, sizeof(mcan_timing_config_t));
    }
    else
    {
        PRINTF("No found Improved Timing Configuration. Just used default configuration\r\n\r\n");
    }

    PRINTF("MCAN Clk-Frequency: %d Hz\r\n", MCAN_CLK_FREQ);
    PRINTF("Bitrate: %d Hz\r\n", mcanConfig.baudRateA);

    /* Initialize CAN with modified CAN structure */
	MCAN_Init(CAN_INPUT, &amp;amp;mcanConfig, MCAN_CLK_FREQ);
	MCAN_Init(CAN_OUTPUT, &amp;amp;mcanConfig, MCAN_CLK_FREQ);

	/* Create MCAN handle structure and set call back function. */
//	MCAN_TransferCreateHandle(CAN_INPUT, &amp;amp;mcanHandle_0, CAN0_IRQHandler, NULL);
//	MCAN_TransferCreateHandle(CAN_OUTPUT, &amp;amp;mcanHandle_1, CAN1_IRQHandler, NULL);

	/* Set Message RAM base address and clear to avoid BEU/BEC error. */
	MCAN_SetMsgRAMBase(CAN_INPUT, (uint32_t)msgRam);
	memset((void *)msgRam, 0, MSG_RAM_SIZE * sizeof(uint8_t));
	MCAN_SetMsgRAMBase(CAN_OUTPUT, (uint32_t)msgRam);
	memset((void *)msgRam, 0, MSG_RAM_SIZE * sizeof(uint8_t));

	/* STD filter config for rxCAN. */
	rxFilter.address  = STD_FILTER_OFS;
	rxFilter.idFormat = kMCAN_FrameIDStandard;
	rxFilter.listSize = 1U;
	rxFilter.nmFrame  = kMCAN_reject0;
	rxFilter.remFrame = kMCAN_rejectFrame;
	MCAN_SetFilterConfig(CAN_INPUT, &amp;amp;rxFilter);

	stdFilter.sfec = kMCAN_storeinFifo0;
	/* Classic filter mode, only filter matching ID. */
	stdFilter.sft   = kMCAN_classic;
	stdFilter.sfid1 = RX_IDENTIFIER;
	stdFilter.sfid2 = 0x7FFU;
	MCAN_SetSTDFilterElement(CAN_INPUT, &amp;amp;rxFilter, &amp;amp;stdFilter, 0);

	/* Enable RX fifo0 new message interrupt using interrupt line 0. */
	MCAN_EnableInterrupts(CAN_INPUT, 0, CAN_IE_RF0NE_MASK);
	EnableIRQ(CAN0_IRQ0_IRQn);

	/* RX fifo0 config. */
	rxFifo0.address       = RX_FIFO0_OFS;
	rxFifo0.elementSize   = 1U;
	rxFifo0.watermark     = 0;
	rxFifo0.opmode        = kMCAN_FifoBlocking;
	rxFifo0.datafieldSize = kMCAN_8ByteDatafield;
	MCAN_SetRxFifo0Config(CAN_INPUT, &amp;amp;rxFifo0);

	/* Enable RX fifo0 new message interrupt using interrupt line 0. */
	MCAN_EnableInterrupts(CAN_INPUT, 0, CAN_IE_RF0NE_MASK);
	EnableIRQ(CAN0_IRQ0_IRQn);

	/* TX buffer config. */
	memset(&amp;amp;txBuffer, 0, sizeof(txBuffer));
	txBuffer.address       = TX_BUFFER_OFS;
	txBuffer.dedicatedSize = 1U;
	txBuffer.fqSize        = 0;
	txBuffer.datafieldSize = kMCAN_8ByteDatafield;
	MCAN_SetTxBufferConfig(CAN_OUTPUT, &amp;amp;txBuffer);

	/* Finish software initialization and enter normal mode, synchronizes to
	 * CAN bus, ready for communication */
	MCAN_EnterNormalMode(CAN_INPUT);
	MCAN_EnterNormalMode(CAN_OUTPUT);

	PRINTF("Available for CAN communication.\r\n");
}

/*!
 * @brief Interrupt handler for Switch 5 =&amp;gt; transfer CAN message
 */
static void SW_Interrupt_Handler(pint_pin_int_t pintr, uint32_t pmatch_status)
{
	GPIO_PortToggle(GPIO, LED3_PORT, 1u &amp;lt;&amp;lt; LED3_PIN);

	PRINTF("Press any key to trigger one-shot transmission\r\n\r\n");
	GETCHAR();

	PRINTF("Transmitting CAN message...\r\n");

	/* Config TX frame data. */
	uint8_t cnt = 0;
	for (cnt = 0; cnt &amp;lt; CAN_DATASIZE; cnt++)
	{
		tx_data[cnt] = cnt;
	}

	tx_data[0] += numMessage++;
	txFrame.xtd  = kMCAN_FrameIDStandard;
	txFrame.rtr  = kMCAN_FrameTypeData;
	txFrame.fdf  = 0;
	txFrame.brs  = 0;
	txFrame.dlc  = 8U;
	txFrame.id   = TX_IDENTIFIER &amp;lt;&amp;lt; STDID_OFFSET;
	txFrame.data = tx_data;
	txFrame.size = CAN_DATASIZE;
	txXfer.frame     = &amp;amp;txFrame;
	txXfer.bufferIdx = 0;

	status_t status = MCAN_WriteTxBuffer(CAN_OUTPUT, 0, &amp;amp;txFrame);
	MCAN_TransmitAddRequest(CAN_OUTPUT, 0);
	//status_t status = MCAN_TransferSendNonBlocking(CAN_OUTPUT, &amp;amp;mcanHandle_1, &amp;amp;txXfer);
	//status_t status = MCAN_TransferSendBlocking(CAN_OUTPUT, 0, &amp;amp;txFrame);
	if(status == kStatus_Success)
	{
		PRINTF("Transmited CAN message!\r\n");
	}
	else
	{
		PRINTF("*Error: Failed to transmit CAN message*\r\n");
	}

	txComplete = false;

}

/*!
 * @brief Initialize routine for LED2 and SW5
 */
void GPIO_Init(void)
{
	PRINTF("Initializing LED2 and SW5.\r\n");

	/* Define the init structure for the LED and SW pin*/
	gpio_pin_config_t led_config = {
		kGPIO_DigitalOutput,
		0,
	};

	/* Init output LED2 and 3 GPIO. */
	GPIO_PortInit(GPIO, LED2_PORT);
	GPIO_PinInit(GPIO, LED2_PORT, LED2_PIN, &amp;amp;led_config);
	GPIO_PinWrite(GPIO, LED2_PORT, LED2_PIN, LED_PIN_OFF);

	GPIO_PortInit(GPIO, LED3_PORT);
	GPIO_PinInit(GPIO, LED3_PORT, LED3_PIN, &amp;amp;led_config);
	GPIO_PinWrite(GPIO, LED3_PORT, LED3_PIN, LED_PIN_OFF);

	/* Init input switch 5 GPIO. */
	INPUTMUX_Init(INPUTMUX);
	INPUTMUX_AttachSignal(INPUTMUX, SW5_ALT_FUNC, SW5_PORT_PIN);
	/* Turnoff clock to inputmux to save power. Clock is only needed to make changes */
	INPUTMUX_Deinit(INPUTMUX);

	/* Initialize the PINT module */
	PINT_Init(PINT);
	/* Make PINT channel 0 react to falling edges */
	PINT_PinInterruptConfig(PINT, SW5_ALT_FUNC, kPINT_PinIntEnableFallEdge, SW_Interrupt_Handler);

	/* Enable callbacks for PINT0 by Index */
	PINT_EnableCallbackByIndex(PINT, SW5_ALT_FUNC);
}

/*
 * @brief   Application entry point.
 */
int main(void)
{
	/* Init board hardware. */
 	BOARD_InitBootPins();
	BOARD_InitBootClocks();
	BOARD_InitBootPeripherals();

	/* Init FSL debug console */
	BOARD_InitDebugConsole();

	/* Init LED and SW */
	GPIO_Init();

	/* Init CAN TX and RX */
	CAN_Init();

	uint8_t cnt = 0;
	rxFrame.size = CAN_DATASIZE;

    /* Enter an infinite loop, print received CAN messages. */
    while(1)
    {
		if(rxComplete)
		{
			/* After call the API of rMCAN_TransferReceiveFifoNonBlocking success, we can
			 * only get a point (rxFrame.data) to the fifo reading entrance.
			 * Copy the received frame data from the FIFO by the pointer(rxFrame.data). */
			memcpy(rx_data, rxFrame.data, rxFrame.size);

			PRINTF("Received Frame ID: 0x%x\r\n", rxFrame.id &amp;gt;&amp;gt; STDID_OFFSET);
			PRINTF("Received Frame DATA: ");

			cnt = 0;
			while (cnt &amp;lt; rxFrame.size)
			{
				PRINTF("0x%x ", rx_data[cnt++]);
			}
			PRINTF("\r\n");
			rxComplete = false;
		}
    }

    return 0;
}&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 07 Apr 2022 09:33:45 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/MCAN-Configurations-MCUXpresso-IDE-for-LPCXpresso54628/m-p/1440443#M48437</guid>
      <dc:creator>SimonSchnee</dc:creator>
      <dc:date>2022-04-07T09:33:45Z</dc:date>
    </item>
    <item>
      <title>Re: MCAN Configurations MCUXpresso IDE for LPCXpresso54628</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/MCAN-Configurations-MCUXpresso-IDE-for-LPCXpresso54628/m-p/1440446#M48438</link>
      <description>&lt;P&gt;&lt;EM&gt;&amp;gt;I do not know what changed now, but both transmitting and receiving is now working.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I am using the PCAN Explorer as well.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;For environments like yours, check that the setting "Listen Only" is enabled. Otherwise, the adapter might interfere with the CAN bus in strange ways, I had similar problems in the past.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Apr 2022 09:36:52 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/MCAN-Configurations-MCUXpresso-IDE-for-LPCXpresso54628/m-p/1440446#M48438</guid>
      <dc:creator>frank_m</dc:creator>
      <dc:date>2022-04-07T09:36:52Z</dc:date>
    </item>
    <item>
      <title>Re: MCAN Configurations MCUXpresso IDE for LPCXpresso54628</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/MCAN-Configurations-MCUXpresso-IDE-for-LPCXpresso54628/m-p/1440507#M48440</link>
      <description>&lt;P&gt;Ok, I will try that out.&lt;/P&gt;&lt;P&gt;Interestingly when I want to use CAN0 as receiver and CAN1 as transmitter, receiving works just fine, but the transmission won't work on CAN1.&lt;/P&gt;&lt;P&gt;Do you have an idea if a setting is missing?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Apr 2022 10:27:04 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/MCAN-Configurations-MCUXpresso-IDE-for-LPCXpresso54628/m-p/1440507#M48440</guid>
      <dc:creator>SimonSchnee</dc:creator>
      <dc:date>2022-04-07T10:27:04Z</dc:date>
    </item>
    <item>
      <title>Re: MCAN Configurations MCUXpresso IDE for LPCXpresso54628</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/MCAN-Configurations-MCUXpresso-IDE-for-LPCXpresso54628/m-p/1440525#M48441</link>
      <description>&lt;P&gt;I am not sure about the example, and your setup. Are CAN0 and CAN1 working as two nodes on the same bus ? That would be fine as a standalone demonstration, but I can't see a use case for an actual device.&lt;/P&gt;&lt;P&gt;If that is true, the reason transmissions doesn't work there is most probably hidden in the configuration of CAN1.&lt;/P&gt;&lt;P&gt;But as said, (albeit having an OM13098 with the same MCU) I have never looked at the SDK CAN examples.&lt;/P&gt;&lt;P&gt;Adapting such examples for your applications usually involved intensive study of the CAN documentation in the MCU user manual.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Apr 2022 11:03:45 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/MCAN-Configurations-MCUXpresso-IDE-for-LPCXpresso54628/m-p/1440525#M48441</guid>
      <dc:creator>frank_m</dc:creator>
      <dc:date>2022-04-07T11:03:45Z</dc:date>
    </item>
    <item>
      <title>Re: MCAN Configurations MCUXpresso IDE for LPCXpresso54628</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/MCAN-Configurations-MCUXpresso-IDE-for-LPCXpresso54628/m-p/1440530#M48442</link>
      <description>&lt;P&gt;I am using the CAN0 as receiving node and CAN1 as transmitting node, both are seperated, so read and write on different CAN lines/busses.&lt;/P&gt;&lt;P&gt;For example CAN0 of the board is connected to PCAN-USB Pro CAN1 and CAN1 of the board is connected to&amp;nbsp;PCAN-USB Pro on CAN2.&lt;/P&gt;&lt;P&gt;I just would like to seperate does two CAN ports (transmitting and receiving).&lt;/P&gt;</description>
      <pubDate>Thu, 07 Apr 2022 11:12:59 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/MCAN-Configurations-MCUXpresso-IDE-for-LPCXpresso54628/m-p/1440530#M48442</guid>
      <dc:creator>SimonSchnee</dc:creator>
      <dc:date>2022-04-07T11:12:59Z</dc:date>
    </item>
    <item>
      <title>Re: MCAN Configurations MCUXpresso IDE for LPCXpresso54628</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/MCAN-Configurations-MCUXpresso-IDE-for-LPCXpresso54628/m-p/1441981#M48461</link>
      <description>&lt;P&gt;Does someone know, why CAN0 is fully functioning on&amp;nbsp;LPCXpresso54628 with CAN extension Board and CAN1 with same settings won't work?&lt;/P&gt;&lt;P&gt;I used the same setting for both CAN ports, but only CAN0 is functioning for transmitting and receiving.&amp;nbsp;&lt;BR /&gt;(for reference see included implementation in previous post)&lt;/P&gt;</description>
      <pubDate>Mon, 11 Apr 2022 09:16:44 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/MCAN-Configurations-MCUXpresso-IDE-for-LPCXpresso54628/m-p/1441981#M48461</guid>
      <dc:creator>SimonSchnee</dc:creator>
      <dc:date>2022-04-11T09:16:44Z</dc:date>
    </item>
    <item>
      <title>Re: MCAN Configurations MCUXpresso IDE for LPCXpresso54628</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/MCAN-Configurations-MCUXpresso-IDE-for-LPCXpresso54628/m-p/1442680#M48471</link>
      <description>&lt;P&gt;Besides of the MCAN configuration, the GPIO configuration must be approriate as well. Which means, both pins must be enabled and set up as CAN "alternate function".&lt;/P&gt;&lt;P&gt;With NXP's SDK this is usually done in pinmux.c / pinmux.h.&lt;/P&gt;&lt;P&gt;Perhaps the CAN1 Tx is not initialized/enabled ?&lt;/P&gt;</description>
      <pubDate>Tue, 12 Apr 2022 11:33:16 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/MCAN-Configurations-MCUXpresso-IDE-for-LPCXpresso54628/m-p/1442680#M48471</guid>
      <dc:creator>frank_m</dc:creator>
      <dc:date>2022-04-12T11:33:16Z</dc:date>
    </item>
    <item>
      <title>Re: MCAN Configurations MCUXpresso IDE for LPCXpresso54628</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/MCAN-Configurations-MCUXpresso-IDE-for-LPCXpresso54628/m-p/1443127#M48474</link>
      <description>&lt;P&gt;I initialized the CAN1 in the same way as CAN0.&lt;BR /&gt;Also selected the CAN1 pins in the pin configurator.&lt;/P&gt;&lt;P&gt;Everything should therefore be enabled &lt;LI-EMOJI id="lia_confused-face" title=":confused_face:"&gt;&lt;/LI-EMOJI&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Apr 2022 06:14:51 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/MCAN-Configurations-MCUXpresso-IDE-for-LPCXpresso54628/m-p/1443127#M48474</guid>
      <dc:creator>SimonSchnee</dc:creator>
      <dc:date>2022-04-13T06:14:51Z</dc:date>
    </item>
    <item>
      <title>Re: MCAN Configurations MCUXpresso IDE for LPCXpresso54628</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/MCAN-Configurations-MCUXpresso-IDE-for-LPCXpresso54628/m-p/1443206#M48476</link>
      <description>&lt;P&gt;&lt;EM&gt;&amp;gt; Also selected the CAN1 pins in the pin configurator.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;If I get that right - have you checked the generated source code ?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;And have you manually checked the configuration and initialisation code for the respective GPIO pin(s) ?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Just speaking from experience with other projects.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Apr 2022 07:33:45 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/MCAN-Configurations-MCUXpresso-IDE-for-LPCXpresso54628/m-p/1443206#M48476</guid>
      <dc:creator>frank_m</dc:creator>
      <dc:date>2022-04-13T07:33:45Z</dc:date>
    </item>
    <item>
      <title>Re: MCAN Configurations MCUXpresso IDE for LPCXpresso54628</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/MCAN-Configurations-MCUXpresso-IDE-for-LPCXpresso54628/m-p/1452533#M48640</link>
      <description>&lt;P&gt;I checked the configurations for both CAN clocks. But first I thought if I activate them manually in the main function it should work. But I realized that you need to enable them in the Clock configurations and set the dividers accordingly.&lt;BR /&gt;&lt;BR /&gt;Thank you for your help &lt;LI-EMOJI id="lia_slightly-smiling-face" title=":slightly_smiling_face:"&gt;&lt;/LI-EMOJI&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 04 May 2022 06:26:57 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/MCAN-Configurations-MCUXpresso-IDE-for-LPCXpresso54628/m-p/1452533#M48640</guid>
      <dc:creator>SimonSchnee</dc:creator>
      <dc:date>2022-05-04T06:26:57Z</dc:date>
    </item>
  </channel>
</rss>

