<?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>LPC MicrocontrollersのトピックRe: Interrupt working under C but not C++</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/Interrupt-working-under-C-but-not-C/m-p/863142#M34403</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Use&lt;/P&gt;&lt;P&gt;extern “C”&lt;/P&gt;&lt;P&gt;to declare your interrupt handler. This is a common FAQ. Look it up if you don’t understand why.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 28 Mar 2019 17:22:03 GMT</pubDate>
    <dc:creator>converse</dc:creator>
    <dc:date>2019-03-28T17:22:03Z</dc:date>
    <item>
      <title>Interrupt working under C but not C++</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Interrupt-working-under-C-but-not-C/m-p/863141#M34402</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've got code extracted and modified from an LPCOpen example code for the LPC4088 evaluation board, and the interrupt in it works as C code, but not as C++, although both build and start running happily on the LPC4088. When running as C++ it ends up at the place with this code:&lt;/P&gt;&lt;P&gt;void IntDefaultHandler(void)&lt;BR /&gt;{ while(1) {}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;in&amp;nbsp;cr_startup_lpc407x_8x.cpp. (The C project has the same file called&amp;nbsp;&lt;SPAN&gt;cr_startup_lpc407x_8x.c)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The two projects were both set up with default settings with the "New C/C++ Wizard" in MCUXpresso 10.3.1_2233, and I changed the preprocessor settings to&lt;/P&gt;&lt;P&gt;DEBUG&lt;BR /&gt;__CODE_RED&lt;BR /&gt;__NEWLIB__&lt;BR /&gt;CORE_M4&lt;BR /&gt;__USE_LPCOPEN&lt;BR /&gt;NO_BOARD_LIB&lt;BR /&gt;CPP_USE_HEAP&lt;BR /&gt;__LPC407X_8X__&lt;/P&gt;&lt;P&gt;so that it should be identical for both projects. Then I put the exact same code, which is found further down in this message, into the main files, and left everything else as default settings. Why does the C project work with the interrupt, while the C++ doesn't? Do I need to set up a link to "&lt;SPAN&gt;CAN_IRQHandler" somewhere?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is the code, which is mostly taken from the "periph_can" example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#include "chip.h"&lt;/P&gt;&lt;P&gt;#define CAN_TX_MSG_STD_ID (0x200)&lt;BR /&gt;#define CAN_TX_MSG_EXT_ID (0x10000200)&lt;BR /&gt;#define CAN_RX_MSG_ID (0x100)&lt;/P&gt;&lt;P&gt;/* Reply message received */&lt;BR /&gt;static void ReplyNormalMessage(CAN_MSG_T *pRcvMsg)&lt;BR /&gt;{&lt;BR /&gt; CAN_MSG_T SendMsgBuf = *pRcvMsg;&lt;BR /&gt; CAN_BUFFER_ID_T TxBuf;&lt;BR /&gt; SendMsgBuf.ID = CAN_TX_MSG_STD_ID;&lt;BR /&gt; TxBuf = Chip_CAN_GetFreeTxBuf(LPC_CAN1);&lt;BR /&gt; Chip_CAN_Send(LPC_CAN1, TxBuf, &amp;amp;SendMsgBuf);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;/*****************************************************************************&lt;BR /&gt; * Public functions&lt;BR /&gt; ****************************************************************************/&lt;BR /&gt;void CAN_IRQHandler(void)&lt;BR /&gt;{&lt;/P&gt;&lt;P&gt;uint32_t IntStatus;&lt;BR /&gt; CAN_MSG_T RcvMsgBuf;&lt;BR /&gt; IntStatus = Chip_CAN_GetIntStatus(LPC_CAN1);&lt;/P&gt;&lt;P&gt;/* New Message came */&lt;BR /&gt; if (IntStatus &amp;amp; CAN_ICR_RI) {&lt;BR /&gt; Chip_CAN_Receive(LPC_CAN1, &amp;amp;RcvMsgBuf);&lt;/P&gt;&lt;P&gt;ReplyNormalMessage(&amp;amp;RcvMsgBuf);&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;int main(void)&lt;BR /&gt;{&lt;BR /&gt; CAN_BUFFER_ID_T TxBuf;&lt;BR /&gt; CAN_MSG_T SendMsgBuf;&lt;/P&gt;&lt;P&gt;SystemCoreClockUpdate();&lt;BR /&gt; Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 0, (IOCON_FUNC1 | 0));&lt;BR /&gt; Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 1, (IOCON_FUNC1 | 0));&lt;BR /&gt; Chip_GPIO_Init(LPC_GPIO);&lt;BR /&gt; Chip_IOCON_Init(LPC_IOCON);&lt;BR /&gt; Chip_CAN_Init(LPC_CAN1, LPC_CANAF, LPC_CANAF_RAM);&lt;BR /&gt; Chip_CAN_SetBitRate(LPC_CAN1, 500000);&lt;BR /&gt; Chip_CAN_EnableInt(LPC_CAN1, CAN_IER_BITMASK);&lt;BR /&gt; Chip_CAN_SetAFMode(LPC_CANAF, CAN_AF_BYBASS_MODE);&lt;BR /&gt; NVIC_EnableIRQ(CAN_IRQn);&lt;/P&gt;&lt;P&gt;SendMsgBuf.ID = CAN_EXTEND_ID_USAGE | CAN_TX_MSG_EXT_ID;&lt;BR /&gt; SendMsgBuf.Type = 0;&lt;BR /&gt; SendMsgBuf.Data[0] = 'E';&lt;BR /&gt; SendMsgBuf.Data[1] = 'F';&lt;BR /&gt; SendMsgBuf.Data[2] = 'G';&lt;BR /&gt; SendMsgBuf.Data[3] = 'H';&lt;BR /&gt; SendMsgBuf.Data[4] = 'I';&lt;BR /&gt; SendMsgBuf.Data[5] = 'J';&lt;BR /&gt; SendMsgBuf.Data[6] = 'K';&lt;BR /&gt; SendMsgBuf.Data[7] = 'L';&lt;BR /&gt; TxBuf = Chip_CAN_GetFreeTxBuf(LPC_CAN1);&lt;/P&gt;&lt;P&gt;Chip_CAN_Send(LPC_CAN1, TxBuf, &amp;amp;SendMsgBuf);&lt;BR /&gt; while ((Chip_CAN_GetStatus(LPC_CAN1) &amp;amp; CAN_SR_TCS(TxBuf)) == 0) {}&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Mar 2019 15:18:40 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Interrupt-working-under-C-but-not-C/m-p/863141#M34402</guid>
      <dc:creator>eriklea</dc:creator>
      <dc:date>2019-03-28T15:18:40Z</dc:date>
    </item>
    <item>
      <title>Re: Interrupt working under C but not C++</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Interrupt-working-under-C-but-not-C/m-p/863142#M34403</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Use&lt;/P&gt;&lt;P&gt;extern “C”&lt;/P&gt;&lt;P&gt;to declare your interrupt handler. This is a common FAQ. Look it up if you don’t understand why.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Mar 2019 17:22:03 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Interrupt-working-under-C-but-not-C/m-p/863142#M34403</guid>
      <dc:creator>converse</dc:creator>
      <dc:date>2019-03-28T17:22:03Z</dc:date>
    </item>
    <item>
      <title>Re: Interrupt working under C but not C++</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Interrupt-working-under-C-but-not-C/m-p/863143#M34404</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Oh, it was that simple. Worked straight away. Thank you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 Mar 2019 08:28:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Interrupt-working-under-C-but-not-C/m-p/863143#M34404</guid>
      <dc:creator>eriklea</dc:creator>
      <dc:date>2019-03-29T08:28:13Z</dc:date>
    </item>
  </channel>
</rss>

