<?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 for MCUのトピックGlobal variables and global functions in Codewarrior 5.1</title>
    <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Global-variables-and-global-functions-in-Codewarrior-5-1/m-p/124437#M68</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Hi,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I'm using Codewarrior 5.1 (special edition) to develop a simple application on MC68HC908JK1CDW (I use C language). Please can you suggest where inserting global variables and global functions whose scope is main.c (the .c file containing the main function), event.c (I need to share variables between main() function and event functions) and all the other files I need?&lt;/DIV&gt;&lt;DIV&gt;Thank you in advance for your help.&lt;BR /&gt;&lt;/DIV&gt;&lt;DIV&gt;Bye.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Simone&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 27 Feb 2007 01:00:59 GMT</pubDate>
    <dc:creator>Simone_Italy</dc:creator>
    <dc:date>2007-02-27T01:00:59Z</dc:date>
    <item>
      <title>Global variables and global functions in Codewarrior 5.1</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Global-variables-and-global-functions-in-Codewarrior-5-1/m-p/124437#M68</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Hi,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I'm using Codewarrior 5.1 (special edition) to develop a simple application on MC68HC908JK1CDW (I use C language). Please can you suggest where inserting global variables and global functions whose scope is main.c (the .c file containing the main function), event.c (I need to share variables between main() function and event functions) and all the other files I need?&lt;/DIV&gt;&lt;DIV&gt;Thank you in advance for your help.&lt;BR /&gt;&lt;/DIV&gt;&lt;DIV&gt;Bye.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Simone&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Feb 2007 01:00:59 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Global-variables-and-global-functions-in-Codewarrior-5-1/m-p/124437#M68</guid>
      <dc:creator>Simone_Italy</dc:creator>
      <dc:date>2007-02-27T01:00:59Z</dc:date>
    </item>
    <item>
      <title>Re: Global variables and global functions in Codewarrior 5.1</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Global-variables-and-global-functions-in-Codewarrior-5-1/m-p/124438#M69</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Hello&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I assume you are using ProcessorExpert to generate code. Am I right?&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I would recommend you to keep your source files separated from Processor Expert generated ones. You can do that the following way:&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; - Create a new source file where you implement your function and define the necessary global&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;variables / constants.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;For example you have a file called myfunc.c containing the following:&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN class="msg_source_code"&gt;&lt;SPAN class="text_smallest"&gt;Code:&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;PRE&gt;     unsigned char myCount;     unsigned char foo(void) {       /*Some code here*/       return myCount;     }&lt;/PRE&gt;&lt;BR /&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; - Add the file to the project (selecting Project -&amp;gt; "Add &amp;lt;...&amp;gt; to Project".&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; - Create a header file containing declaration for the global variables/constants you need and&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; prototype for the function. For the above source file the include file will be called myfunc.h and will&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; look as follow:&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN class="msg_source_code"&gt;&lt;SPAN class="text_smallest"&gt;Code:&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;PRE&gt;extern unsigned char myCount;unsigned char foo(void);&lt;/PRE&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; - In the source file containing the implementation of the main function as well as in the Events.c file add an&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; include from the new header file (myfunc.h in our example).&lt;/DIV&gt;&lt;SPAN class="msg_source_code"&gt;&lt;SPAN class="text_smallest"&gt;Code:&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;PRE&gt;#include "Cpu.h"#include "Events.h"#include "myfunc.h"&amp;lt;...&amp;gt;&lt;/PRE&gt;&lt;P&gt;Then in main or in the Events module you can just use the &amp;nbsp;function or variable the usual way.&lt;BR /&gt;in the main function make sure you write your code between the marks:&lt;/P&gt;&lt;P&gt;&amp;nbsp; /* Write your code here */&lt;BR /&gt;&amp;nbsp; /* For example: for(;&lt;IMG alt=":smileywink:" class="emoticon emoticon-smileywink" id="smileywink" src="http://freescale.i.lithium.com/i/smilies/16x16_smiley-wink.gif" title="Smiley Wink" /&gt; { } */&lt;BR /&gt;and&lt;BR /&gt;&amp;nbsp; /*** Don't write any code pass this line, or it will be deleted during code generation. ***/&lt;BR /&gt;&amp;nbsp; /*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;That should do it and keep some kind of structure in the application.&lt;BR /&gt;I hope this helps.&lt;/P&gt;&lt;DIV&gt;CrasyCat&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Feb 2007 16:23:56 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Global-variables-and-global-functions-in-Codewarrior-5-1/m-p/124438#M69</guid>
      <dc:creator>CrasyCat</dc:creator>
      <dc:date>2007-02-27T16:23:56Z</dc:date>
    </item>
    <item>
      <title>Re: Global variables and global functions in Codewarrior 5.1</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Global-variables-and-global-functions-in-Codewarrior-5-1/m-p/124439#M70</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Thank you very much for your help!&lt;/DIV&gt;&lt;DIV&gt;Bye.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Simone&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Feb 2007 17:05:02 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Global-variables-and-global-functions-in-Codewarrior-5-1/m-p/124439#M70</guid>
      <dc:creator>Simone_Italy</dc:creator>
      <dc:date>2007-02-27T17:05:02Z</dc:date>
    </item>
  </channel>
</rss>

