<?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>CodeWarrior Development ToolsのトピックRe: Pass struct to function</title>
    <link>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Pass-struct-to-function/m-p/664754#M5941</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;Not sure which memory model you are using, but perhaps this issue is related to the fact your struct is located in a paged RAM and the function call doesn't pass the page number.&lt;/P&gt;&lt;P&gt;I'd suggest you to declare sciDATA pointer as a far pointer so it passes global address pointer instead:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;void SendSerialData3(struct sciData &amp;nbsp;&lt;STRONG&gt;*far&lt;/STRONG&gt; sd3)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope it helps.&lt;/P&gt;&lt;P&gt;Stan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 02 Mar 2017 14:20:39 GMT</pubDate>
    <dc:creator>stanish</dc:creator>
    <dc:date>2017-03-02T14:20:39Z</dc:date>
    <item>
      <title>Pass struct to function</title>
      <link>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Pass-struct-to-function/m-p/664748#M5935</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I seem to be having some difficulty in passing a struct to a function. No errors generated by the make process but upon inspection the values inside the function are not equal to the values outside.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;THE STRUCT:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;struct sciData{ &lt;BR /&gt;&amp;nbsp; uint8_t rxBuf[RSBuffSIZE]; // Receive buffer&lt;BR /&gt;&amp;nbsp; uint16_t RSindex; // receive buffer counter&lt;BR /&gt;&amp;nbsp; uint16_t RSread; // receive buffer counter&lt;/P&gt;&lt;P&gt;&amp;nbsp; uint32_t tempVal; //scratchpad calc storage space&lt;BR /&gt;&amp;nbsp; uint8_t tempChars[TBUFF_SIZE]; //temporary scratchpad for received chars&lt;BR /&gt;&amp;nbsp; //Data Transmit Parameters&lt;BR /&gt;&amp;nbsp; uint8_t txBuf[SendBuffSIZE]; /* Send buffer */&lt;BR /&gt;&amp;nbsp; uint16_t numTXBytes;&lt;BR /&gt;&amp;nbsp; uint16_t OutBytes; /* Number of bytes to send */&lt;BR /&gt;&amp;nbsp; uint16_t SentBytes; /* Number of bytes sent */&lt;BR /&gt;&amp;nbsp; uint16_t TRANSMIT; // transmit flag to let prog know interrupt&lt;BR /&gt;&amp;nbsp; // driven transmission in progress&lt;BR /&gt;&amp;nbsp; uint8_t tPtr; //pointer to current buffer item&lt;BR /&gt;&amp;nbsp; uint8_t dataReady; //flag to indicate return data ready&lt;BR /&gt;&amp;nbsp; uint8_t charCount; //number of chars received&lt;BR /&gt;&amp;nbsp; uint8_t commChar;&lt;BR /&gt;&amp;nbsp; uint16_t charsExpected;&lt;BR /&gt;};&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;STRUCT DEFINE IN MAIN:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;struct sciData sci3Dat;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;CALL FROM MAIN&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;//Send Mode change to Top Controller&lt;BR /&gt; sci3Dat.txBuf[0] = 'p';&lt;BR /&gt; sci3Dat.txBuf[1] = 'G';&lt;BR /&gt; sci3Dat.txBuf[2] = TC_START;&lt;BR /&gt; sci3Dat.numTXBytes = 3;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; &lt;EM&gt;(NOTE: At this point&amp;nbsp;sci3Dat.numTXBytes = 3)&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;#ifdef SCI3&lt;BR /&gt;&amp;nbsp; SendSerialData3(&amp;amp;sci3Dat); //past end of data&lt;BR /&gt;&amp;nbsp; while(sci3Dat.TRANSMIT);&lt;BR /&gt; #endif&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;INSIDE THE FUNCTION:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;/* routine called to start string transmission */&lt;BR /&gt;void SendSerialData3(struct sciData *sd3){&lt;BR /&gt;&amp;nbsp; &amp;nbsp;&lt;EM&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(NOTE: At this point sd3-&amp;gt;numTXBytes =&amp;nbsp;0)&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;sd3-&amp;gt;OutBytes = sd3-&amp;gt;numTXBytes - 1;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;sd3-&amp;gt;SentBytes = 0;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;sd3-&amp;gt;TRANSMIT = 1; // We're transmitting data&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;/* Set transmit buffer empty * transmit complete interrupts */&lt;BR /&gt;&amp;nbsp; &amp;nbsp;INTR_OFF();&lt;BR /&gt;&amp;nbsp; &amp;nbsp;SCI3CR2 = 0xEc;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;INTR_ON();&lt;BR /&gt;}&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Other values are incorrect also, just included the numTXBytes as an example. Pointer to a function should be fairly simple right, but I am not sure where I have gone wrong here.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any Ideas?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Feb 2017 22:00:21 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Pass-struct-to-function/m-p/664748#M5935</guid>
      <dc:creator>tnriley</dc:creator>
      <dc:date>2017-02-23T22:00:21Z</dc:date>
    </item>
    <item>
      <title>Re: Pass struct to function</title>
      <link>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Pass-struct-to-function/m-p/664749#M5936</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN&gt;I was looking at this some more and found the following&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The value of sd3 inside the function&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="background-color: #ffffff; color: #51626f;"&gt;void SendSerialData3(struct sciData *sd3) is reported as sd3=NULL by the Codewarrior IDE.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Whereas the value of sd3 in the function&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;void out_serial3(struct sciData *sd3) &lt;STRONG&gt;(Shown Below)&lt;/STRONG&gt; points to the correct struct&amp;nbsp;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;sci3Dat defined back in main().&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;STRONG style="color: #51626f; background-color: #ffffff; border: 0px; font-weight: bold;"&gt;INSIDE THE FUNCTION CALLED BY THE ISR:&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;/* Send data routine. Called by sci interrupt handler */&lt;BR /&gt;void out_serial3(struct sciData *sd3){&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;if(sd3-&amp;gt;SentBytes &amp;gt; sd3-&amp;gt;OutBytes){ // if last character transmitted&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;INTR_OFF(); // turn off transmitter interrupts&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;SCI3CR2 = 0x24; // Also turns off transmitter when last char is sent&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;sd3-&amp;gt;TRANSMIT = 0; // notify main program that tranmission is complete&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;INTR_ON();&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;else&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;SCI3DRL = sd3-&amp;gt;txBuf[sd3-&amp;gt;SentBytes++]; // stuff character in sci transmit buffer&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ISR SHOWING CALL TO&amp;nbsp;out_serial3&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;/* interrupt handler for all SCI3 communications interrupts */&lt;BR /&gt;void interrupt com3(void){&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;uint8_t scitest = SCI3SR1;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;if(scitest&amp;amp;BM_RDRF){ // if receive buffer full interrupt, call data receive routine&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;in_serial3(&amp;amp;sci3Dat);&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;else{&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if(scitest&amp;amp;(BM_TDRE|BM_TC)){ // if transmit buffer empty or transmit complete interrupt, &lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;out_serial3(&amp;amp;sci3Dat); // call transmit data routine&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR /&gt;}&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The code for all three modules &lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;SendSerialData3,&amp;nbsp;&lt;SPAN style="color: #3d3d3d;"&gt;out_serial3, and&amp;nbsp;com3 reside in the same file.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="background-color: #ffffff; : ; color: #3d3d3d;"&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;SPAN style="background-color: #ffffff; color: #3d3d3d;"&gt;Parameters to both modules are defined in the same manner &lt;SPAN&gt;&lt;STRONG&gt;(struct sciData *sd3)&lt;/STRONG&gt;&amp;nbsp;&lt;/SPAN&gt;and calls are made in same fashion&amp;nbsp;&lt;STRONG&gt;(&amp;amp;sci3Dat).&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff; color: #3d3d3d;"&gt;&lt;STRONG&gt;So the question is: &amp;nbsp;Why does sd3=NULL inside&amp;nbsp;SendSerialData3, but contain the correct values inside&amp;nbsp;&lt;SPAN style="background-color: #ffffff;"&gt;out_serial3?&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Feb 2017 15:28:38 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Pass-struct-to-function/m-p/664749#M5936</guid>
      <dc:creator>tnriley</dc:creator>
      <dc:date>2017-02-24T15:28:38Z</dc:date>
    </item>
    <item>
      <title>Re: Pass struct to function</title>
      <link>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Pass-struct-to-function/m-p/664750#M5937</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Tim,&lt;/P&gt;&lt;P&gt;Please tell me the chip part number and the version of CodeWarrior.&lt;/P&gt;&lt;P&gt;Also in order to check the problem , please share your project t me , thanks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BR&lt;/P&gt;&lt;P&gt;Alice&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Feb 2017 07:03:59 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Pass-struct-to-function/m-p/664750#M5937</guid>
      <dc:creator>Alice_Yang</dc:creator>
      <dc:date>2017-02-28T07:03:59Z</dc:date>
    </item>
    <item>
      <title>Re: Pass struct to function</title>
      <link>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Pass-struct-to-function/m-p/664751#M5938</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Alice,&lt;/P&gt;&lt;P&gt;The chip is a Freescale MC9S12XDP512CAL. The CodeWarrior IDE version is 5.9.0 build 5294.&lt;/P&gt;&lt;P&gt;Sorry, I can't send the complete project.&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Tim&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Feb 2017 14:11:25 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Pass-struct-to-function/m-p/664751#M5938</guid>
      <dc:creator>tnriley</dc:creator>
      <dc:date>2017-02-28T14:11:25Z</dc:date>
    </item>
    <item>
      <title>Re: Pass struct to function</title>
      <link>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Pass-struct-to-function/m-p/664752#M5939</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Tim,&lt;/P&gt;&lt;P&gt;OK, it doesn't matter.&lt;/P&gt;&lt;P&gt;I create a new project about it , and copy these code into it , while when build there some error,&lt;/P&gt;&lt;P&gt;as to lack of some definition , for example INTR_OFF()...&lt;/P&gt;&lt;P&gt;So could you please also create a new project , then only copy these code related your question,&lt;/P&gt;&lt;P&gt;build with no error, check whether it can work well . If no, please share it to me this project .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BR&lt;/P&gt;&lt;P&gt;Alice&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Mar 2017 07:50:18 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Pass-struct-to-function/m-p/664752#M5939</guid>
      <dc:creator>Alice_Yang</dc:creator>
      <dc:date>2017-03-01T07:50:18Z</dc:date>
    </item>
    <item>
      <title>Re: Pass struct to function</title>
      <link>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Pass-struct-to-function/m-p/664753#M5940</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Alice,&lt;/P&gt;&lt;P&gt;How is best to post files here?&lt;/P&gt;&lt;P&gt;Tim&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Mar 2017 17:07:33 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Pass-struct-to-function/m-p/664753#M5940</guid>
      <dc:creator>tnriley</dc:creator>
      <dc:date>2017-03-01T17:07:33Z</dc:date>
    </item>
    <item>
      <title>Re: Pass struct to function</title>
      <link>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Pass-struct-to-function/m-p/664754#M5941</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;Not sure which memory model you are using, but perhaps this issue is related to the fact your struct is located in a paged RAM and the function call doesn't pass the page number.&lt;/P&gt;&lt;P&gt;I'd suggest you to declare sciDATA pointer as a far pointer so it passes global address pointer instead:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;void SendSerialData3(struct sciData &amp;nbsp;&lt;STRONG&gt;*far&lt;/STRONG&gt; sd3)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope it helps.&lt;/P&gt;&lt;P&gt;Stan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Mar 2017 14:20:39 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Pass-struct-to-function/m-p/664754#M5941</guid>
      <dc:creator>stanish</dc:creator>
      <dc:date>2017-03-02T14:20:39Z</dc:date>
    </item>
    <item>
      <title>Re: Pass struct to function</title>
      <link>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Pass-struct-to-function/m-p/664755#M5942</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Stan,&lt;/P&gt;&lt;P&gt;Thanks, I will try that. I am new to the Codewarrior tools.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I set the project up with the small memory model option. Which I thought meant that it was a non paged contiguous space. What is the best source for documentation on learning and using the different memory models for CodeWarrior and the MC9S12?&lt;/P&gt;&lt;P&gt;Tim&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Mar 2017 15:04:47 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Pass-struct-to-function/m-p/664755#M5942</guid>
      <dc:creator>tnriley</dc:creator>
      <dc:date>2017-03-02T15:04:47Z</dc:date>
    </item>
  </channel>
</rss>

