<?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>S12 / MagniV MicrocontrollersのトピックUsing Xgate lead to the program collapse</title>
    <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Using-Xgate-lead-to-the-program-collapse/m-p/773655#M15403</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now I use Xgate to process the CAN interrupts. I encounter the following issues:&lt;/P&gt;&lt;P&gt;1、CAN port can send the frame but the content is error, Can port can reveive frame but the&amp;nbsp;&lt;SPAN&gt;content is error.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2、Even worse, the program go to&amp;nbsp;collapse after about 40 seconds running.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;My&amp;nbsp;SetupXGATE functin is this:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;void SetupXGATE(void) &lt;BR /&gt;{&lt;BR /&gt; /* initialize the XGATE vector block and&lt;BR /&gt; set the XGVBR register to its start address */&lt;BR /&gt; XGVBR= (unsigned int)(void*__far)(XGATE_VectorTable - XGATE_VECTOR_OFFSET);&lt;BR /&gt; ROUTE_INTERRUPT(CAN2_RECV_VEC, 0x81);&lt;BR /&gt; ROUTE_INTERRUPT(CAN2_SEND_VEC, 0x81);&lt;BR /&gt; /* when changing your derivative to non-core3 one please remove next five lines */&lt;BR /&gt; XGISPSEL= 1;&lt;BR /&gt; XGISP31= (unsigned int)(void*__far)(XGATE_STACK_L + 1);&lt;BR /&gt; XGISPSEL= 2;&lt;BR /&gt; XGISP74= (unsigned int)(void*__far)(XGATE_STACK_H + 1);&lt;BR /&gt; XGISPSEL= 0;&lt;/P&gt;&lt;P&gt;/* enable XGATE mode and interrupts */&lt;BR /&gt; XGMCTL= 0xFBC1; /* XGE | XGFRZ | XGIE */&lt;/P&gt;&lt;P&gt;/* force execution of software trigger 0 handler */&lt;BR /&gt; //XGSWT= 0x0101;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The xgate vector table is like this, about CAN interrupt vector:&lt;/P&gt;&lt;P&gt;const XGATE_TableEntry XGATE_VectorTable[] = {&lt;/P&gt;&lt;P&gt;{(XGATE_Function)ISR_CAN2_Send, (int)&amp;amp;MyData}, // Channel 50 - CAN2 transmit&lt;BR /&gt; {(XGATE_Function)ISR_CAN2_Recv, (int)&amp;amp;MyData}, // Channel 51 - CAN2 receive&lt;/P&gt;&lt;P&gt;};&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And the interrupt functions define are like this:&lt;/P&gt;&lt;P&gt;interrupt void ISR_CAN2_Recv(MyDataType* __restrict pData)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;if(_ssem(CANSEMXG)) /* semaphore locked */&lt;BR /&gt; {&lt;BR /&gt;// do something&lt;BR /&gt; /* unlock semaphore */&lt;BR /&gt; _csem(CANSEMXG);&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;interrupt void ISR_CAN2_Send(MyDataType* __restrict pData)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;if(_ssem(CANSEMXG)) /* semaphore locked */&lt;BR /&gt; {&lt;BR /&gt;&lt;SPAN&gt;// do something&lt;/SPAN&gt;&lt;BR /&gt; /* unlock semaphore */&lt;BR /&gt; _csem(CANSEMXG);&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In my&amp;nbsp;S12X_CPU codes like this:&lt;/P&gt;&lt;P&gt;UINT16 CAN_Send(void)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;do &lt;BR /&gt; { /* lock semaphore */&lt;BR /&gt; XGSEM = SETCANSEM;&lt;BR /&gt; } &lt;BR /&gt; while(!(XGSEM_XGSEM &amp;amp; CANSEM));&lt;/P&gt;&lt;P&gt;//do&amp;nbsp;&lt;SPAN&gt;something&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;/* unlock semaphore */&lt;BR /&gt; XGSEM = CLRCANSEM;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;UINT16 CAN_Recv(void)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;do &lt;BR /&gt;{ /* lock semaphore */&lt;BR /&gt;XGSEM = SETCANSEM;&lt;BR /&gt;} &lt;BR /&gt;while(!(XGSEM_XGSEM &amp;amp; CANSEM));&lt;/P&gt;&lt;P&gt;//do&amp;nbsp;&lt;SPAN&gt;something&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;/* unlock semaphore */&lt;BR /&gt;XGSEM = CLRCANSEM;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And I define the var shared between&amp;nbsp;&lt;SPAN&gt;S12X_CPU and &amp;nbsp;Xgates like this:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;#pragma DATA_SEG SHARED_DATA&lt;BR /&gt;const ST_CAN_DIVIDE_MSG *pstCanDivideMsg[CAN_MAX_NUM];&lt;BR /&gt;volatile ST_CAN_PROPERTY g_astCanProp[CAN_MAX_NUM];&lt;BR /&gt;#pragma DATA_SEG DEFAULT&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;#pragma DATA_SEG SHARED_DATA&lt;BR /&gt;volatile ST_CAN_FRAME astRxCan2Mailbox0Buf[RX_CAN2_MAILBOX0_SIZE];&lt;BR /&gt;volatile ST_CAN_FRAME astRxCan2Mailbox1Buf[RX_CAN2_MAILBOX1_SIZE];&lt;/P&gt;&lt;P&gt;volatile ST_CAN_FRAME astTxCan2Mailbox0Buf[TX_CAN2_MAILBOX0_SIZE];&lt;BR /&gt;#pragma DATA_SEG DEFAULT&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hopes somebody can solve my confusion.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 25 Feb 2018 05:41:38 GMT</pubDate>
    <dc:creator>赵子成</dc:creator>
    <dc:date>2018-02-25T05:41:38Z</dc:date>
    <item>
      <title>Using Xgate lead to the program collapse</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Using-Xgate-lead-to-the-program-collapse/m-p/773655#M15403</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now I use Xgate to process the CAN interrupts. I encounter the following issues:&lt;/P&gt;&lt;P&gt;1、CAN port can send the frame but the content is error, Can port can reveive frame but the&amp;nbsp;&lt;SPAN&gt;content is error.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2、Even worse, the program go to&amp;nbsp;collapse after about 40 seconds running.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;My&amp;nbsp;SetupXGATE functin is this:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;void SetupXGATE(void) &lt;BR /&gt;{&lt;BR /&gt; /* initialize the XGATE vector block and&lt;BR /&gt; set the XGVBR register to its start address */&lt;BR /&gt; XGVBR= (unsigned int)(void*__far)(XGATE_VectorTable - XGATE_VECTOR_OFFSET);&lt;BR /&gt; ROUTE_INTERRUPT(CAN2_RECV_VEC, 0x81);&lt;BR /&gt; ROUTE_INTERRUPT(CAN2_SEND_VEC, 0x81);&lt;BR /&gt; /* when changing your derivative to non-core3 one please remove next five lines */&lt;BR /&gt; XGISPSEL= 1;&lt;BR /&gt; XGISP31= (unsigned int)(void*__far)(XGATE_STACK_L + 1);&lt;BR /&gt; XGISPSEL= 2;&lt;BR /&gt; XGISP74= (unsigned int)(void*__far)(XGATE_STACK_H + 1);&lt;BR /&gt; XGISPSEL= 0;&lt;/P&gt;&lt;P&gt;/* enable XGATE mode and interrupts */&lt;BR /&gt; XGMCTL= 0xFBC1; /* XGE | XGFRZ | XGIE */&lt;/P&gt;&lt;P&gt;/* force execution of software trigger 0 handler */&lt;BR /&gt; //XGSWT= 0x0101;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The xgate vector table is like this, about CAN interrupt vector:&lt;/P&gt;&lt;P&gt;const XGATE_TableEntry XGATE_VectorTable[] = {&lt;/P&gt;&lt;P&gt;{(XGATE_Function)ISR_CAN2_Send, (int)&amp;amp;MyData}, // Channel 50 - CAN2 transmit&lt;BR /&gt; {(XGATE_Function)ISR_CAN2_Recv, (int)&amp;amp;MyData}, // Channel 51 - CAN2 receive&lt;/P&gt;&lt;P&gt;};&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And the interrupt functions define are like this:&lt;/P&gt;&lt;P&gt;interrupt void ISR_CAN2_Recv(MyDataType* __restrict pData)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;if(_ssem(CANSEMXG)) /* semaphore locked */&lt;BR /&gt; {&lt;BR /&gt;// do something&lt;BR /&gt; /* unlock semaphore */&lt;BR /&gt; _csem(CANSEMXG);&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;interrupt void ISR_CAN2_Send(MyDataType* __restrict pData)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;if(_ssem(CANSEMXG)) /* semaphore locked */&lt;BR /&gt; {&lt;BR /&gt;&lt;SPAN&gt;// do something&lt;/SPAN&gt;&lt;BR /&gt; /* unlock semaphore */&lt;BR /&gt; _csem(CANSEMXG);&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In my&amp;nbsp;S12X_CPU codes like this:&lt;/P&gt;&lt;P&gt;UINT16 CAN_Send(void)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;do &lt;BR /&gt; { /* lock semaphore */&lt;BR /&gt; XGSEM = SETCANSEM;&lt;BR /&gt; } &lt;BR /&gt; while(!(XGSEM_XGSEM &amp;amp; CANSEM));&lt;/P&gt;&lt;P&gt;//do&amp;nbsp;&lt;SPAN&gt;something&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;/* unlock semaphore */&lt;BR /&gt; XGSEM = CLRCANSEM;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;UINT16 CAN_Recv(void)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;do &lt;BR /&gt;{ /* lock semaphore */&lt;BR /&gt;XGSEM = SETCANSEM;&lt;BR /&gt;} &lt;BR /&gt;while(!(XGSEM_XGSEM &amp;amp; CANSEM));&lt;/P&gt;&lt;P&gt;//do&amp;nbsp;&lt;SPAN&gt;something&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;/* unlock semaphore */&lt;BR /&gt;XGSEM = CLRCANSEM;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And I define the var shared between&amp;nbsp;&lt;SPAN&gt;S12X_CPU and &amp;nbsp;Xgates like this:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;#pragma DATA_SEG SHARED_DATA&lt;BR /&gt;const ST_CAN_DIVIDE_MSG *pstCanDivideMsg[CAN_MAX_NUM];&lt;BR /&gt;volatile ST_CAN_PROPERTY g_astCanProp[CAN_MAX_NUM];&lt;BR /&gt;#pragma DATA_SEG DEFAULT&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;#pragma DATA_SEG SHARED_DATA&lt;BR /&gt;volatile ST_CAN_FRAME astRxCan2Mailbox0Buf[RX_CAN2_MAILBOX0_SIZE];&lt;BR /&gt;volatile ST_CAN_FRAME astRxCan2Mailbox1Buf[RX_CAN2_MAILBOX1_SIZE];&lt;/P&gt;&lt;P&gt;volatile ST_CAN_FRAME astTxCan2Mailbox0Buf[TX_CAN2_MAILBOX0_SIZE];&lt;BR /&gt;#pragma DATA_SEG DEFAULT&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hopes somebody can solve my confusion.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 25 Feb 2018 05:41:38 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Using-Xgate-lead-to-the-program-collapse/m-p/773655#M15403</guid>
      <dc:creator>赵子成</dc:creator>
      <dc:date>2018-02-25T05:41:38Z</dc:date>
    </item>
    <item>
      <title>Re: Using Xgate lead to the program collapse</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Using-Xgate-lead-to-the-program-collapse/m-p/773656#M15404</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;One evident problem is shared pointer. You can't easily share pointers between S12X and XGATE. It's possible, but you need to have deep knowledge of how to trick them.&amp;nbsp;16bit XGATE pointer can point to RAM/registers/part of flash pages 0xE0,E1. Nonpaged S12 0x2000 is what XGATE sees at 0xE000. It may be easier to share array index instead. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Edward&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Feb 2018 11:57:00 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Using-Xgate-lead-to-the-program-collapse/m-p/773656#M15404</guid>
      <dc:creator>kef2</dc:creator>
      <dc:date>2018-02-26T11:57:00Z</dc:date>
    </item>
  </channel>
</rss>

