<?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 Testing CAN loopback mode on LPC11C24 in LPC Microcontrollers</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/Testing-CAN-loopback-mode-on-LPC11C24/m-p/636482#M25135</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;Hello All,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;I have a problem testing the loop back mode for CAN controller on LPC11C24. I am using the can example of LPCopen. This example uses the on-chip CAN API mentioned in UM10398.&amp;nbsp;I do not know how to configure the source code in order to work in loopback mode only as a first test. In fact, I'm not sure if the example is or not in this mode. When I debug the example, the system enters in the CAN_error callback. So, nothing is transmitted nor received. If the on-chip CAN is not in loopback mode, it's normal because I do not have connected any CAN node. But then, how can I configure the on-chip CAN registers to work in loopback mode using this on-chip CAN API?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The code is this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#include "board.h"&lt;BR /&gt;#include "cr_section_macros.h"&lt;/P&gt;&lt;P&gt;/*****************************************************************************&lt;BR /&gt; * Private types/enumerations/variables&lt;BR /&gt; ****************************************************************************/&lt;/P&gt;&lt;P&gt;#define TEST_CCAN_BAUD_RATE 500000&lt;/P&gt;&lt;P&gt;//reserve CAN ROM-RAM 0x1000 0050 - 0x1000 00B9&lt;BR /&gt;__BSS(RESERVED) char CAN_driver_memory[0xC0];&lt;/P&gt;&lt;P&gt;/*****************************************************************************&lt;BR /&gt; * Private types/enumerations/variables&lt;BR /&gt; ****************************************************************************/&lt;/P&gt;&lt;P&gt;#define TEST_CCAN_BAUD_RATE 500000&lt;/P&gt;&lt;P&gt;CCAN_MSG_OBJ_T msg_obj;&lt;BR /&gt;volatile unsigned short rx_counter=0; //receive counter&lt;BR /&gt;volatile unsigned short tx_counter=0; //transmit counter&lt;BR /&gt;/*****************************************************************************&lt;BR /&gt; * Public types/enumerations/variables&lt;BR /&gt; ****************************************************************************/&lt;/P&gt;&lt;P&gt;/*****************************************************************************&lt;BR /&gt; * Private functions&lt;BR /&gt; ****************************************************************************/&lt;BR /&gt;void baudrateCalculate(uint32_t baud_rate, uint32_t *can_api_timing_cfg)&lt;BR /&gt;{&lt;BR /&gt; uint32_t pClk, div, quanta, segs, seg1, seg2, clk_per_bit, can_sjw;&lt;BR /&gt; Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_CAN);&lt;BR /&gt; pClk = Chip_Clock_GetMainClockRate();&lt;/P&gt;&lt;P&gt;clk_per_bit = pClk / baud_rate;&lt;/P&gt;&lt;P&gt;for (div = 0; div &amp;lt;= 15; div++) {&lt;BR /&gt; for (quanta = 1; quanta &amp;lt;= 32; quanta++) {&lt;BR /&gt; for (segs = 3; segs &amp;lt;= 17; segs++) {&lt;BR /&gt; if (clk_per_bit == (segs * quanta * (div + 1))) {&lt;BR /&gt; segs -= 3;&lt;BR /&gt; seg1 = segs / 2;&lt;BR /&gt; seg2 = segs - seg1;&lt;BR /&gt; can_sjw = seg1 &amp;gt; 3 ? 3 : seg1;&lt;BR /&gt; can_api_timing_cfg[0] = div;&lt;BR /&gt; can_api_timing_cfg[1] =&lt;BR /&gt; ((quanta - 1) &amp;amp; 0x3F) | (can_sjw &amp;amp; 0x03) &amp;lt;&amp;lt; 6 | (seg1 &amp;amp; 0x0F) &amp;lt;&amp;lt; 8 | (seg2 &amp;amp; 0x07) &amp;lt;&amp;lt; 12;&lt;BR /&gt; return;&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;/* CAN receive callback */&lt;BR /&gt;/* Function is executed by the Callback handler after&lt;BR /&gt; a CAN message has been received */&lt;BR /&gt;void CAN_rx(uint8_t msg_obj_num) {&lt;BR /&gt; rx_counter++;&lt;BR /&gt; /* Determine which CAN message has been received */&lt;BR /&gt; msg_obj.msgobj = msg_obj_num;&lt;BR /&gt; /* Now load up the msg_obj structure with the CAN message */&lt;BR /&gt; LPC_CCAN_API-&amp;gt;can_receive(&amp;amp;msg_obj);&lt;BR /&gt; if (msg_obj_num == 1) {&lt;BR /&gt; /* Simply transmit CAN frame (echo) with with ID +0x100 via buffer 2 */&lt;BR /&gt; msg_obj.msgobj = 2;&lt;BR /&gt; msg_obj.mode_id += 0x100;&lt;BR /&gt; LPC_CCAN_API-&amp;gt;can_transmit(&amp;amp;msg_obj);&lt;BR /&gt; }&lt;BR /&gt; return;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;/* CAN transmit callback */&lt;BR /&gt;/* Function is executed by the Callback handler after&lt;BR /&gt; a CAN message has been transmitted */&lt;BR /&gt;void CAN_tx(uint8_t msg_obj_num) {&lt;/P&gt;&lt;P&gt;tx_counter++;&lt;BR /&gt; return;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;/* CAN error callback */&lt;BR /&gt;/* Function is executed by the Callback handler after&lt;BR /&gt; an error has occured on the CAN bus */&lt;BR /&gt;void CAN_error(uint32_t error_info) {&lt;BR /&gt; return;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;/**&lt;BR /&gt; * @brief CCAN Interrupt Handler&lt;BR /&gt; * @return Nothing&lt;BR /&gt; * @note The CCAN interrupt handler must be provided by the user application.&lt;BR /&gt; * It's function is to call the isr() API located in the ROM&lt;BR /&gt; */&lt;BR /&gt;void CAN_IRQHandler(void) {&lt;BR /&gt; LPC_CCAN_API-&amp;gt;isr();&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;/*****************************************************************************&lt;BR /&gt; * Public functions&lt;BR /&gt; ****************************************************************************/&lt;/P&gt;&lt;P&gt;/**&lt;BR /&gt; * @brief Main routine for CCAN_ROM example&lt;BR /&gt; * @return Nothing&lt;BR /&gt; */&lt;BR /&gt;int main(void)&lt;BR /&gt;{&lt;BR /&gt; volatile unsigned int i,counter=0;&lt;BR /&gt; uint32_t CanApiClkInitTable[2];&lt;BR /&gt; /* Publish CAN Callback Functions */&lt;BR /&gt; CCAN_CALLBACKS_T callbacks = {&lt;BR /&gt; CAN_rx,&lt;BR /&gt; CAN_tx,&lt;BR /&gt; CAN_error,&lt;BR /&gt; NULL,&lt;BR /&gt; NULL,&lt;BR /&gt; NULL,&lt;BR /&gt; NULL,&lt;BR /&gt; NULL,&lt;BR /&gt; };&lt;BR /&gt; SystemCoreClockUpdate();&lt;BR /&gt; Board_Init();&lt;BR /&gt; baudrateCalculate(TEST_CCAN_BAUD_RATE, CanApiClkInitTable);&lt;/P&gt;&lt;P&gt;LPC_CCAN_API-&amp;gt;init_can(&amp;amp;CanApiClkInitTable[0], TRUE);&lt;BR /&gt; /* Configure the CAN callback functions */&lt;BR /&gt; LPC_CCAN_API-&amp;gt;config_calb(&amp;amp;callbacks);&lt;BR /&gt; //set loop back mode&lt;BR /&gt; //LPC_CAN-&amp;gt;CNTL |= (1&amp;lt;&amp;lt;7);&lt;BR /&gt; //LPC_CCAN-&amp;gt;TEST |= (1&amp;lt;&amp;lt;4);&lt;/P&gt;&lt;P&gt;/* Enable the CAN Interrupt */&lt;BR /&gt; NVIC_EnableIRQ(CAN_IRQn);&lt;/P&gt;&lt;P&gt;/* Send a simple one time CAN message */&lt;BR /&gt; msg_obj.msgobj = 0;&lt;BR /&gt; msg_obj.mode_id = 0x345;&amp;nbsp;&lt;BR /&gt; msg_obj.mask = 0x7F0;&lt;BR /&gt; msg_obj.dlc = 4;&lt;BR /&gt; msg_obj.data[0] = 'T'; // 0x54&lt;BR /&gt; msg_obj.data[1] = 'E'; // 0x45&lt;BR /&gt; msg_obj.data[2] = 'S'; // 0x53&lt;BR /&gt; msg_obj.data[3] = 'T'; // 0x54&lt;BR /&gt; LPC_CCAN_API-&amp;gt;can_transmit(&amp;amp;msg_obj);&lt;/P&gt;&lt;P&gt;/* Configure message object 1 to receive all 11-bit messages 0x400-0x4FF */&lt;BR /&gt; msg_obj.msgobj = 1;&lt;BR /&gt; msg_obj.mode_id = 0x300;&lt;BR /&gt; msg_obj.mask = 0x7F0;&lt;BR /&gt; LPC_CCAN_API-&amp;gt;config_rxmsgobj(&amp;amp;msg_obj);&lt;/P&gt;&lt;P&gt;while (1) {&lt;BR /&gt; __WFI(); /* Go to Sleep */&lt;BR /&gt; }&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I do not find any helpful information. I have found another kind of problems related to on-chip CAN but it seems that people achieve working&amp;nbsp;in loopback mode but not using on-chip CAN API.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could anybody help me with this issue?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;Thanks.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 30 Mar 2017 13:36:06 GMT</pubDate>
    <dc:creator>ainhoacortes</dc:creator>
    <dc:date>2017-03-30T13:36:06Z</dc:date>
    <item>
      <title>Testing CAN loopback mode on LPC11C24</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Testing-CAN-loopback-mode-on-LPC11C24/m-p/636482#M25135</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;Hello All,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;I have a problem testing the loop back mode for CAN controller on LPC11C24. I am using the can example of LPCopen. This example uses the on-chip CAN API mentioned in UM10398.&amp;nbsp;I do not know how to configure the source code in order to work in loopback mode only as a first test. In fact, I'm not sure if the example is or not in this mode. When I debug the example, the system enters in the CAN_error callback. So, nothing is transmitted nor received. If the on-chip CAN is not in loopback mode, it's normal because I do not have connected any CAN node. But then, how can I configure the on-chip CAN registers to work in loopback mode using this on-chip CAN API?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The code is this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#include "board.h"&lt;BR /&gt;#include "cr_section_macros.h"&lt;/P&gt;&lt;P&gt;/*****************************************************************************&lt;BR /&gt; * Private types/enumerations/variables&lt;BR /&gt; ****************************************************************************/&lt;/P&gt;&lt;P&gt;#define TEST_CCAN_BAUD_RATE 500000&lt;/P&gt;&lt;P&gt;//reserve CAN ROM-RAM 0x1000 0050 - 0x1000 00B9&lt;BR /&gt;__BSS(RESERVED) char CAN_driver_memory[0xC0];&lt;/P&gt;&lt;P&gt;/*****************************************************************************&lt;BR /&gt; * Private types/enumerations/variables&lt;BR /&gt; ****************************************************************************/&lt;/P&gt;&lt;P&gt;#define TEST_CCAN_BAUD_RATE 500000&lt;/P&gt;&lt;P&gt;CCAN_MSG_OBJ_T msg_obj;&lt;BR /&gt;volatile unsigned short rx_counter=0; //receive counter&lt;BR /&gt;volatile unsigned short tx_counter=0; //transmit counter&lt;BR /&gt;/*****************************************************************************&lt;BR /&gt; * Public types/enumerations/variables&lt;BR /&gt; ****************************************************************************/&lt;/P&gt;&lt;P&gt;/*****************************************************************************&lt;BR /&gt; * Private functions&lt;BR /&gt; ****************************************************************************/&lt;BR /&gt;void baudrateCalculate(uint32_t baud_rate, uint32_t *can_api_timing_cfg)&lt;BR /&gt;{&lt;BR /&gt; uint32_t pClk, div, quanta, segs, seg1, seg2, clk_per_bit, can_sjw;&lt;BR /&gt; Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_CAN);&lt;BR /&gt; pClk = Chip_Clock_GetMainClockRate();&lt;/P&gt;&lt;P&gt;clk_per_bit = pClk / baud_rate;&lt;/P&gt;&lt;P&gt;for (div = 0; div &amp;lt;= 15; div++) {&lt;BR /&gt; for (quanta = 1; quanta &amp;lt;= 32; quanta++) {&lt;BR /&gt; for (segs = 3; segs &amp;lt;= 17; segs++) {&lt;BR /&gt; if (clk_per_bit == (segs * quanta * (div + 1))) {&lt;BR /&gt; segs -= 3;&lt;BR /&gt; seg1 = segs / 2;&lt;BR /&gt; seg2 = segs - seg1;&lt;BR /&gt; can_sjw = seg1 &amp;gt; 3 ? 3 : seg1;&lt;BR /&gt; can_api_timing_cfg[0] = div;&lt;BR /&gt; can_api_timing_cfg[1] =&lt;BR /&gt; ((quanta - 1) &amp;amp; 0x3F) | (can_sjw &amp;amp; 0x03) &amp;lt;&amp;lt; 6 | (seg1 &amp;amp; 0x0F) &amp;lt;&amp;lt; 8 | (seg2 &amp;amp; 0x07) &amp;lt;&amp;lt; 12;&lt;BR /&gt; return;&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;/* CAN receive callback */&lt;BR /&gt;/* Function is executed by the Callback handler after&lt;BR /&gt; a CAN message has been received */&lt;BR /&gt;void CAN_rx(uint8_t msg_obj_num) {&lt;BR /&gt; rx_counter++;&lt;BR /&gt; /* Determine which CAN message has been received */&lt;BR /&gt; msg_obj.msgobj = msg_obj_num;&lt;BR /&gt; /* Now load up the msg_obj structure with the CAN message */&lt;BR /&gt; LPC_CCAN_API-&amp;gt;can_receive(&amp;amp;msg_obj);&lt;BR /&gt; if (msg_obj_num == 1) {&lt;BR /&gt; /* Simply transmit CAN frame (echo) with with ID +0x100 via buffer 2 */&lt;BR /&gt; msg_obj.msgobj = 2;&lt;BR /&gt; msg_obj.mode_id += 0x100;&lt;BR /&gt; LPC_CCAN_API-&amp;gt;can_transmit(&amp;amp;msg_obj);&lt;BR /&gt; }&lt;BR /&gt; return;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;/* CAN transmit callback */&lt;BR /&gt;/* Function is executed by the Callback handler after&lt;BR /&gt; a CAN message has been transmitted */&lt;BR /&gt;void CAN_tx(uint8_t msg_obj_num) {&lt;/P&gt;&lt;P&gt;tx_counter++;&lt;BR /&gt; return;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;/* CAN error callback */&lt;BR /&gt;/* Function is executed by the Callback handler after&lt;BR /&gt; an error has occured on the CAN bus */&lt;BR /&gt;void CAN_error(uint32_t error_info) {&lt;BR /&gt; return;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;/**&lt;BR /&gt; * @brief CCAN Interrupt Handler&lt;BR /&gt; * @return Nothing&lt;BR /&gt; * @note The CCAN interrupt handler must be provided by the user application.&lt;BR /&gt; * It's function is to call the isr() API located in the ROM&lt;BR /&gt; */&lt;BR /&gt;void CAN_IRQHandler(void) {&lt;BR /&gt; LPC_CCAN_API-&amp;gt;isr();&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;/*****************************************************************************&lt;BR /&gt; * Public functions&lt;BR /&gt; ****************************************************************************/&lt;/P&gt;&lt;P&gt;/**&lt;BR /&gt; * @brief Main routine for CCAN_ROM example&lt;BR /&gt; * @return Nothing&lt;BR /&gt; */&lt;BR /&gt;int main(void)&lt;BR /&gt;{&lt;BR /&gt; volatile unsigned int i,counter=0;&lt;BR /&gt; uint32_t CanApiClkInitTable[2];&lt;BR /&gt; /* Publish CAN Callback Functions */&lt;BR /&gt; CCAN_CALLBACKS_T callbacks = {&lt;BR /&gt; CAN_rx,&lt;BR /&gt; CAN_tx,&lt;BR /&gt; CAN_error,&lt;BR /&gt; NULL,&lt;BR /&gt; NULL,&lt;BR /&gt; NULL,&lt;BR /&gt; NULL,&lt;BR /&gt; NULL,&lt;BR /&gt; };&lt;BR /&gt; SystemCoreClockUpdate();&lt;BR /&gt; Board_Init();&lt;BR /&gt; baudrateCalculate(TEST_CCAN_BAUD_RATE, CanApiClkInitTable);&lt;/P&gt;&lt;P&gt;LPC_CCAN_API-&amp;gt;init_can(&amp;amp;CanApiClkInitTable[0], TRUE);&lt;BR /&gt; /* Configure the CAN callback functions */&lt;BR /&gt; LPC_CCAN_API-&amp;gt;config_calb(&amp;amp;callbacks);&lt;BR /&gt; //set loop back mode&lt;BR /&gt; //LPC_CAN-&amp;gt;CNTL |= (1&amp;lt;&amp;lt;7);&lt;BR /&gt; //LPC_CCAN-&amp;gt;TEST |= (1&amp;lt;&amp;lt;4);&lt;/P&gt;&lt;P&gt;/* Enable the CAN Interrupt */&lt;BR /&gt; NVIC_EnableIRQ(CAN_IRQn);&lt;/P&gt;&lt;P&gt;/* Send a simple one time CAN message */&lt;BR /&gt; msg_obj.msgobj = 0;&lt;BR /&gt; msg_obj.mode_id = 0x345;&amp;nbsp;&lt;BR /&gt; msg_obj.mask = 0x7F0;&lt;BR /&gt; msg_obj.dlc = 4;&lt;BR /&gt; msg_obj.data[0] = 'T'; // 0x54&lt;BR /&gt; msg_obj.data[1] = 'E'; // 0x45&lt;BR /&gt; msg_obj.data[2] = 'S'; // 0x53&lt;BR /&gt; msg_obj.data[3] = 'T'; // 0x54&lt;BR /&gt; LPC_CCAN_API-&amp;gt;can_transmit(&amp;amp;msg_obj);&lt;/P&gt;&lt;P&gt;/* Configure message object 1 to receive all 11-bit messages 0x400-0x4FF */&lt;BR /&gt; msg_obj.msgobj = 1;&lt;BR /&gt; msg_obj.mode_id = 0x300;&lt;BR /&gt; msg_obj.mask = 0x7F0;&lt;BR /&gt; LPC_CCAN_API-&amp;gt;config_rxmsgobj(&amp;amp;msg_obj);&lt;/P&gt;&lt;P&gt;while (1) {&lt;BR /&gt; __WFI(); /* Go to Sleep */&lt;BR /&gt; }&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I do not find any helpful information. I have found another kind of problems related to on-chip CAN but it seems that people achieve working&amp;nbsp;in loopback mode but not using on-chip CAN API.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could anybody help me with this issue?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;Thanks.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Mar 2017 13:36:06 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Testing-CAN-loopback-mode-on-LPC11C24/m-p/636482#M25135</guid>
      <dc:creator>ainhoacortes</dc:creator>
      <dc:date>2017-03-30T13:36:06Z</dc:date>
    </item>
    <item>
      <title>Re: Testing CAN loopback mode on LPC11C24</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Testing-CAN-loopback-mode-on-LPC11C24/m-p/636483#M25136</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi AINHOA CORTES,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Thank you for your interest in NXP LPC product, I would like to provide service for you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; The CAN on chip drives have limitation, it doesn't support all the CAN functions..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; I have check the on chip can drives, the can initialization don't have the TEST mode configuration.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; But don't worry, you can combine with the CAN register control.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; If you want to enter loopback mode, you just need to control two registers:&lt;/P&gt;&lt;P&gt;1. CANCNTL[TEST] = 1, enable the test mode.&lt;/P&gt;&lt;P&gt;2. CANTEST[LBACK] =1, enable the loop back mode.&lt;/P&gt;&lt;P&gt;Now, let's based on the lpc11c24 lpcopen code periph_ccan_rom, add the loopback mode enable code.&lt;/P&gt;&lt;P&gt;1. include io_macros.h&lt;/P&gt;&lt;P&gt;#include "io_macros.h"&lt;/P&gt;&lt;P&gt;2. add CAN register define code.&lt;/P&gt;&lt;P&gt;typedef struct{&lt;BR /&gt;__REG32 INIT&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : 1;&lt;BR /&gt;__REG32 IE&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : 1;&lt;BR /&gt;__REG32 SIE&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : 1;&lt;BR /&gt;__REG32 EIE&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : 1;&lt;BR /&gt;__REG32&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : 1;&lt;BR /&gt;__REG32 DAR&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : 1;&lt;BR /&gt;__REG32 CCE&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : 1;&lt;BR /&gt;__REG32 TEST&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : 1;&lt;BR /&gt;__REG32&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; :24;&lt;BR /&gt;} __cancntl_bits;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* CAN test register */&lt;BR /&gt;typedef struct{&lt;BR /&gt;__REG32&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : 2;&lt;BR /&gt;__REG32 BASIC&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : 1;&lt;BR /&gt;__REG32 SILENT&amp;nbsp;&amp;nbsp;&amp;nbsp; : 1;&lt;BR /&gt;__REG32 LBACK&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : 1;&lt;BR /&gt;__REG32 TX&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : 2;&lt;BR /&gt;__REG32 RX&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : 1;&lt;BR /&gt;__REG32&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; :24;&lt;BR /&gt;} __cantest_bits;&lt;BR /&gt;__IO_REG32_BIT(CANCNTL,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0x40050000,__READ_WRITE ,__cancntl_bits);&lt;BR /&gt;__IO_REG32_BIT(CANTEST,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0x40050014,__READ_WRITE ,__cantest_bits);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3. in main() enable the loopback mode.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CANCNTL |= 1&amp;lt;&amp;lt;7; // enable the test mode&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CANTEST |= 1&amp;lt;&amp;lt;4; // enable the loop back mode.&lt;/P&gt;&lt;P&gt;4. send the data ID in the range of 0x400-0x4ff.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; msg_obj.msgobj&amp;nbsp; = 0;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;msg_obj.mode_id = 0x400;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;msg_obj.mask&amp;nbsp;&amp;nbsp;&amp;nbsp; = 0x0;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;msg_obj.dlc&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = 4;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;msg_obj.data[0] = 'T';&amp;nbsp;&amp;nbsp; &amp;nbsp;// 0x54&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;msg_obj.data[1] = 'E';&amp;nbsp;&amp;nbsp; &amp;nbsp;// 0x45&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;msg_obj.data[2] = 'S';&amp;nbsp;&amp;nbsp; &amp;nbsp;// 0x53&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;msg_obj.data[3] = 'T';&amp;nbsp;&amp;nbsp; &amp;nbsp;// 0x54&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;LPC_CCAN_API-&amp;gt;can_transmit(&amp;amp;msg_obj);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have attached my test ccam_rom.c for your reference.&lt;/P&gt;&lt;P&gt;After you download the code to your ccan_rom.c, and debug it, you will find even you don't add the CAN node, you also can receive the data. this is my test result on lpcxpresso lpc11c24 board.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_1.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/17813i959EAE2025010E60/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_1.png" alt="pastedImage_1.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can receive the correct data.&lt;/P&gt;&lt;P&gt;Please try my code on your side.&lt;/P&gt;&lt;P&gt;If you still have question, just let me know.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Have a great day,&lt;BR /&gt;Kerry&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Apr 2017 06:29:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Testing-CAN-loopback-mode-on-LPC11C24/m-p/636483#M25136</guid>
      <dc:creator>kerryzhou</dc:creator>
      <dc:date>2017-04-07T06:29:10Z</dc:date>
    </item>
    <item>
      <title>Re: Testing CAN loopback mode on LPC11C24</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Testing-CAN-loopback-mode-on-LPC11C24/m-p/636484#M25137</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Kerry,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you very much for your response. I think it's very clear and this confirms my thoughts.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Only one easy question. I don't find the io_macros.h file anywhere. Could you send me the file? I do not know why I don't have it in my project, but in the structure I downloaded this file doesn't exist. In fact, I don't find anywhere in the web. In the following figure, you can see the files I have related to LPC chip:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_1.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/17681iB74F1EA01B56671E/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_1.png" alt="pastedImage_1.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Ainhoa&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Apr 2017 12:53:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Testing-CAN-loopback-mode-on-LPC11C24/m-p/636484#M25137</guid>
      <dc:creator>ainhoacortes</dc:creator>
      <dc:date>2017-04-07T12:53:13Z</dc:date>
    </item>
    <item>
      <title>Re: Testing CAN loopback mode on LPC11C24</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Testing-CAN-loopback-mode-on-LPC11C24/m-p/636485#M25138</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Ainhoa,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Sorry for my later reply.&lt;/P&gt;&lt;P&gt;io_macros.h is the file in the IAR install attachment.&lt;/P&gt;&lt;P&gt;&amp;nbsp; If you are using the lPCXpresso IDE,&amp;nbsp; you can refer to my attached header file: LPC11xx.h.&lt;/P&gt;&lt;P&gt;&amp;nbsp;Line 483:&lt;/P&gt;&lt;P&gt;typedef struct&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp; __IO uint32_t CNTL;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;/* 0x000 */&lt;BR /&gt;&amp;nbsp; __IO uint32_t STAT;&lt;BR /&gt;&amp;nbsp; __IO uint32_t EC;&lt;BR /&gt;&amp;nbsp; __IO uint32_t BT;&lt;BR /&gt;&amp;nbsp; __IO uint32_t INT;&lt;BR /&gt;&amp;nbsp; __IO uint32_t TEST;&lt;BR /&gt;&amp;nbsp; __IO uint32_t BRPE;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; uint32_t RESERVED0;&lt;BR /&gt;&amp;nbsp; __IO uint32_t IF1_CMDREQ;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;/* 0x020 */&lt;BR /&gt;&amp;nbsp; __IO uint32_t IF1_CMDMSK;&lt;BR /&gt;&amp;nbsp; __IO uint32_t IF1_MSK1;&lt;BR /&gt;&amp;nbsp; __IO uint32_t IF1_MSK2;&lt;BR /&gt;&amp;nbsp; __IO uint32_t IF1_ARB1;&lt;BR /&gt;&amp;nbsp; __IO uint32_t IF1_ARB2;&lt;BR /&gt;&amp;nbsp; __IO uint32_t IF1_MCTRL;&lt;BR /&gt;&amp;nbsp; __IO uint32_t IF1_DA1;&lt;BR /&gt;&amp;nbsp; __IO uint32_t IF1_DA2;&lt;BR /&gt;&amp;nbsp; __IO uint32_t IF1_DB1;&lt;BR /&gt;&amp;nbsp; __IO uint32_t IF1_DB2;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; uint32_t RESERVED1[13];&lt;BR /&gt;&amp;nbsp; __IO uint32_t IF2_CMDREQ;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;/* 0x080 */&lt;BR /&gt;&amp;nbsp; __IO uint32_t IF2_CMDMSK;&lt;BR /&gt;&amp;nbsp; __IO uint32_t IF2_MSK1;&lt;BR /&gt;&amp;nbsp; __IO uint32_t IF2_MSK2;&lt;BR /&gt;&amp;nbsp; __IO uint32_t IF2_ARB1;&lt;BR /&gt;&amp;nbsp; __IO uint32_t IF2_ARB2;&lt;BR /&gt;&amp;nbsp; __IO uint32_t IF2_MCTRL;&lt;BR /&gt;&amp;nbsp; __IO uint32_t IF2_DA1;&lt;BR /&gt;&amp;nbsp; __IO uint32_t IF2_DA2;&lt;BR /&gt;&amp;nbsp; __IO uint32_t IF2_DB1;&lt;BR /&gt;&amp;nbsp; __IO uint32_t IF2_DB2;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; uint32_t RESERVED2[21];&lt;BR /&gt;&amp;nbsp; __I&amp;nbsp; uint32_t TXREQ1;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;/* 0x100 */&lt;BR /&gt;&amp;nbsp; __I&amp;nbsp; uint32_t TXREQ2;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; uint32_t RESERVED3[6];&lt;BR /&gt;&amp;nbsp; __I&amp;nbsp; uint32_t ND1;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;/* 0x120 */&lt;BR /&gt;&amp;nbsp; __I&amp;nbsp; uint32_t ND2;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; uint32_t RESERVED4[6];&lt;BR /&gt;&amp;nbsp; __I&amp;nbsp; uint32_t IR1;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;/* 0x140 */&lt;BR /&gt;&amp;nbsp; __I&amp;nbsp; uint32_t IR2;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; uint32_t RESERVED5[6];&lt;BR /&gt;&amp;nbsp; __I&amp;nbsp; uint32_t MSGV1;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;/* 0x160 */&lt;BR /&gt;&amp;nbsp; __I&amp;nbsp; uint32_t MSGV2;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; uint32_t RESERVED6[6];&lt;BR /&gt;&amp;nbsp; __IO uint32_t CLKDIV;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;/* 0x180 */&lt;BR /&gt;} LPC_CAN_TypeDef;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Line 560:&lt;/P&gt;&lt;P&gt;#define LPC_CAN_BASE&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (LPC_APB0_BASE + 0x50000)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#define LPC_CAN&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ((LPC_CAN_TypeDef&amp;nbsp;&amp;nbsp;&amp;nbsp; *) LPC_CAN_BASE&amp;nbsp;&amp;nbsp; )&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#define CTRL_TEST&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;(1 &amp;lt;&amp;lt; 7)&lt;/P&gt;&lt;P&gt;#define TEST_LOOPBACK &amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (1 &amp;lt;&amp;lt; 4)&lt;/P&gt;&lt;P&gt;Then you can call CAN register like this:&lt;/P&gt;&lt;P&gt;LPC_CAN-&amp;gt;CNTL |= CTRL_TEST&amp;nbsp;;&lt;/P&gt;&lt;P&gt;LPC_CAN-&amp;gt;TEST |= TEST_LOOPBACK &amp;nbsp; ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Wish it helps you!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Have a great day,&lt;BR /&gt;Kerry&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 31 May 2017 09:06:24 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Testing-CAN-loopback-mode-on-LPC11C24/m-p/636485#M25138</guid>
      <dc:creator>kerryzhou</dc:creator>
      <dc:date>2017-05-31T09:06:24Z</dc:date>
    </item>
  </channel>
</rss>

