<?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>LPCXpresso IDE中的主题 Re: LPC11C24 can on-chip error handler</title>
    <link>https://community.nxp.com/t5/LPCXpresso-IDE/LPC11C24-can-on-chip-error-handler/m-p/531190#M2380</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by LabRat on Fri Mar 21 02:20:29 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;As described in UM:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: &lt;/STRONG&gt;&lt;BR /&gt;On-chip RAM from address 0x1000 0050 to [color=#f00]0x1000 00B8[/color] is used by the CAN API.&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;it's enough to reserve: &lt;/SPAN&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
//reserve CAN ROM-RAM 0x1000 0050 - 0x1000 00B9
__BSS(RESERVED) char CAN_driver_memory[0xC0];
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;SPAN&gt;which was described long time ago here:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.nxp.com/external-link.jspa?url=http%3A%2F%2Fwww.lpcware.com%2Fcontent%2Fforum%2Fhow-to-reserve-lpc11cxx-ram" rel="nofollow noopener noreferrer" target="_blank"&gt;http://www.lpcware.com/content/forum/how-to-reserve-lpc11cxx-ram&lt;/A&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 16 Jun 2016 00:19:01 GMT</pubDate>
    <dc:creator>lpcware</dc:creator>
    <dc:date>2016-06-16T00:19:01Z</dc:date>
    <item>
      <title>LPC11C24 can on-chip error handler</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/LPC11C24-can-on-chip-error-handler/m-p/531185#M2375</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by signumx on Mon May 14 12:13:25 MST 2012&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm using the CAN on-chip api and everything is working fine when I start my system.&amp;nbsp; I want to be able to detect and handle errors if, for instance, the communication cable to my module is cut.&amp;nbsp; When I test that, I can see that the CAN_error callback function is called the first time (by inserting a breakpoint in that function).&amp;nbsp; I plug my cable back, the communication restarts but if I remove it again, the CAN_error is never called again.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I thought of resetting the CANSTAT register but I'm apparently not allowed to&amp;nbsp; do so.&amp;nbsp; I also tried to call the initCan function inside the error handler but it does not help.&amp;nbsp; How do I either reinitialize the error flags or the whole CAN controller?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Jeff&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 00:18:58 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/LPC11C24-can-on-chip-error-handler/m-p/531185#M2375</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T00:18:58Z</dc:date>
    </item>
    <item>
      <title>Re: LPC11C24 can on-chip error handler</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/LPC11C24-can-on-chip-error-handler/m-p/531186#M2376</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by researchinnovation on Mon May 14 22:17:09 MST 2012&lt;/STRONG&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: signumx&lt;/STRONG&gt;&lt;BR /&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;I'm using the CAN on-chip api and everything is working fine when I start my system.&amp;nbsp; I want to be able to detect and handle errors if, for instance, the communication cable to my module is cut.&amp;nbsp; When I test that, I can see that the CAN_error callback function is called the first time (by inserting a breakpoint in that function).&amp;nbsp; I plug my cable back, the communication restarts but if I remove it again, the CAN_error is never called again.&lt;BR /&gt;&lt;BR /&gt;I thought of resetting the CANSTAT register but I'm apparently not allowed to&amp;nbsp; do so.&amp;nbsp; I also tried to call the initCan function inside the error handler but it does not help.&amp;nbsp; How do I either reinitialize the error flags or the whole CAN controller?&lt;BR /&gt;&lt;BR /&gt;Thank you,&lt;BR /&gt;Jeff&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;SPAN&gt;@Signumx..Hi..!!!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Can you please share the code with us.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks &amp;amp; Regards....!!!:)&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 00:18:59 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/LPC11C24-can-on-chip-error-handler/m-p/531186#M2376</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T00:18:59Z</dc:date>
    </item>
    <item>
      <title>Re: LPC11C24 can on-chip error handler</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/LPC11C24-can-on-chip-error-handler/m-p/531187#M2377</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by signumx on Tue May 15 05:18:11 MST 2012&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Here's the code.&amp;nbsp; It's basically the same as the lpcXpresso can on-chip example.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
ROM **rom = (ROM **)0x1fff1ff8;

CAN_MSG_OBJ msg_obj;

static uint32_t noAnswerErrorCount = 0;

/* Initialize CAN Controller */
uint32_t ClkInitTable[2] = {
&amp;nbsp; 0x00000005UL, // CANCLKDIV
&amp;nbsp; 0x00000501UL&amp;nbsp; // CAN_BTR 500kbps
};

/* Callback function prototypes */
void CAN_rx(uint8_t msg_obj_num);
void CAN_tx(uint8_t msg_obj_num);
void CAN_error(uint32_t error_info);

/* Publish CAN Callback Functions */
CAN_CALLBACKS callbacks = {
&amp;nbsp;&amp;nbsp; CAN_rx,
&amp;nbsp;&amp;nbsp; CAN_tx,
&amp;nbsp;&amp;nbsp; CAN_error,
&amp;nbsp;&amp;nbsp; NULL,
&amp;nbsp;&amp;nbsp; NULL,
&amp;nbsp;&amp;nbsp; NULL,
&amp;nbsp;&amp;nbsp; NULL,
&amp;nbsp;&amp;nbsp; NULL,
};

/*CAN receive callback */
/*Function is executed by the Callback handler after
a CAN message has been received */
void CAN_rx(uint8_t msg_obj_num){

noAnswerErrorCount = 0;

/* Determine which CAN message has been received */
msg_obj.msgobj = msg_obj_num;

/* Now load up the msg_obj structure with the CAN message */
(*rom)-&amp;gt;pCAND-&amp;gt;can_receive(&amp;amp;msg_obj);

return;
}

/*CAN transmit callback */
/*Function is executed by the Callback handler after
a CAN message has been transmitted */
void CAN_tx(uint8_t msg_obj_num)
{
return;
}

/*CAN error callback */
/*Function is executed by the Callback handler after
an error has occured on the CAN bus */
void CAN_error(uint32_t error_info)
{
noAnswerErrorCount++;
return;
}

/*CAN interrupt handler */
/*The CAN interrupt handler must be provided by the user application.
It's function is to call the isr() API located in the ROM */
void CAN_IRQHandler (void){
&amp;nbsp; (*rom)-&amp;gt;pCAND-&amp;gt;isr();
}

void initCan(void)
{
bool result = true;

/* Initialize the CAN controller */
(*rom)-&amp;gt;pCAND-&amp;gt;init_can(&amp;amp;ClkInitTable[0], 1);

/* Configure the CAN callback functions */
(*rom)-&amp;gt;pCAND-&amp;gt;config_calb(&amp;amp;callbacks);

/* Disable automatic repetition */
LPC_CAN-&amp;gt;CNTL |= CTRL_DAR;

/* Enable the CAN Interrupt */
NVIC_EnableIRQ(CAN_IRQn);

noAnswerErrorCount = 0;
}

void speedCanRequest(void)
{
msg_obj.msgobj&amp;nbsp; = 0;
msg_obj.mode_id = 0x7DF;
msg_obj.mask&amp;nbsp;&amp;nbsp;&amp;nbsp; = 0x0;
msg_obj.dlc&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = 8;
msg_obj.data[0] = 0x02;
msg_obj.data[1] = 0x01;
msg_obj.data[2] = 0x0D;
msg_obj.data[3] = 0x55;
msg_obj.data[4] = 0x55;
msg_obj.data[5] = 0x55;
msg_obj.data[6] = 0x55;
msg_obj.data[7] = 0x55;
(*rom)-&amp;gt;pCAND-&amp;gt;can_transmit(&amp;amp;msg_obj);

msg_obj.msgobj = 1;
msg_obj.mode_id = 0x7E8;
msg_obj.mask = 0x7E0;
(*rom)-&amp;gt;pCAND-&amp;gt;config_rxmsgobj(&amp;amp;msg_obj);
}&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So I call the function speedCanRequest once per second and the communication goes smoothly with my CAN emulator.&amp;nbsp; Unplugging the cable will increment the noAnswerErrorCounter variable once but repeating the operation won't affect it anymore.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Jeff&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 00:18:59 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/LPC11C24-can-on-chip-error-handler/m-p/531187#M2377</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T00:18:59Z</dc:date>
    </item>
    <item>
      <title>Re: LPC11C24 can on-chip error handler</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/LPC11C24-can-on-chip-error-handler/m-p/531188#M2378</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by tomicacar on Wed Mar 12 02:12:36 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hello, I have similar problem, my code never goes to CAN_error callback function.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Have you solved your problem?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Tomica.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 00:19:00 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/LPC11C24-can-on-chip-error-handler/m-p/531188#M2378</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T00:19:00Z</dc:date>
    </item>
    <item>
      <title>Re: LPC11C24 can on-chip error handler</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/LPC11C24-can-on-chip-error-handler/m-p/531189#M2379</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by npl102 on Thu Mar 20 12:53:41 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Had same problem, see:&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://http://www.lpcware.com/content/faq/lpcxpresso/reserving-ram-rom-drivers"&gt;http://www.lpcware.com/content/faq/lpcxpresso/reserving-ram-rom-drivers&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;for reserving RAM for ROM CAN driver.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 00:19:01 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/LPC11C24-can-on-chip-error-handler/m-p/531189#M2379</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T00:19:01Z</dc:date>
    </item>
    <item>
      <title>Re: LPC11C24 can on-chip error handler</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/LPC11C24-can-on-chip-error-handler/m-p/531190#M2380</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by LabRat on Fri Mar 21 02:20:29 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;As described in UM:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: &lt;/STRONG&gt;&lt;BR /&gt;On-chip RAM from address 0x1000 0050 to [color=#f00]0x1000 00B8[/color] is used by the CAN API.&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;it's enough to reserve: &lt;/SPAN&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
//reserve CAN ROM-RAM 0x1000 0050 - 0x1000 00B9
__BSS(RESERVED) char CAN_driver_memory[0xC0];
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;SPAN&gt;which was described long time ago here:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.nxp.com/external-link.jspa?url=http%3A%2F%2Fwww.lpcware.com%2Fcontent%2Fforum%2Fhow-to-reserve-lpc11cxx-ram" rel="nofollow noopener noreferrer" target="_blank"&gt;http://www.lpcware.com/content/forum/how-to-reserve-lpc11cxx-ram&lt;/A&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 00:19:01 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/LPC11C24-can-on-chip-error-handler/m-p/531190#M2380</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T00:19:01Z</dc:date>
    </item>
  </channel>
</rss>

