<?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>topic Re: evaluate macro in a .h file in CodeWarrior for MCU</title>
    <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/evaluate-macro-in-a-h-file/m-p/281322#M10451</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Pascal, I meant calculate the final value of the macro in your case &lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt; ( 20971520 / 32 )&lt;/SPAN&gt;=655360.&lt;/P&gt;&lt;P&gt;Is it possible?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 07 Feb 2014 07:40:55 GMT</pubDate>
    <dc:creator>stefanomanca</dc:creator>
    <dc:date>2014-02-07T07:40:55Z</dc:date>
    <item>
      <title>evaluate macro in a .h file</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/evaluate-macro-in-a-h-file/m-p/281320#M10449</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, Anybody knows how evaluate (calculate) a macro in a .h file by codewarrior?&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;define BUSCLOCK 20971520&lt;/P&gt;&lt;P&gt;#define TPM_PRESCALER 32//assicurarsi che il registro TPM_SC sia configurato con prescaler a 32&lt;/P&gt;&lt;P&gt;#define TPM_CLOCK (BUSCLOCK/TPM_PRESCALER)&lt;/P&gt;&lt;P&gt;#define TPM_OVERFLOW_MS 64//massima durata impulso e quindi overflow del timer in millisecondi &lt;/P&gt;&lt;P&gt;#define NUM_SLICE 30&lt;/P&gt;&lt;P&gt;#define TPM_OVERFLOW ((TPM_OVERFLOW_MS*TPM_CLOCK)/1000)&lt;/P&gt;&lt;P&gt;#define TPM_OVERFLOW_SLICE (TPM_OVERFLOW/NUM_SLICE)&lt;/P&gt;&lt;P&gt;#define GUARD_TIME_COUNTER_MS 2//periodo di guardia dopo l'arrivo del primo impulso valido in millisecondi&lt;/P&gt;&lt;P&gt;#define GUARD_TIME_COUNTER ((GUARD_TIME_COUNTER_MS*TPM_CLOCK)/1000)&lt;/P&gt;&lt;P&gt;#define PULSE_PERIOD_OK_US 256 //durata impulso valido in microsecondi&lt;/P&gt;&lt;P&gt;#define PULSE_PERIOD_OK ((PULSE_PERIOD_OK_US*TPM_CLOCK)/1000000)&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Feb 2014 07:53:09 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/evaluate-macro-in-a-h-file/m-p/281320#M10449</guid>
      <dc:creator>stefanomanca</dc:creator>
      <dc:date>2014-02-06T07:53:09Z</dc:date>
    </item>
    <item>
      <title>Re: evaluate macro in a .h file</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/evaluate-macro-in-a-h-file/m-p/281321#M10450</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Stefano,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the macros are evaluated / calculated at preprocess step.&lt;/P&gt;&lt;P&gt;To generate this file you must select the .c file and with the pop-up menu click on Preprocess.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've created an example based on your code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;test.h&lt;/P&gt;&lt;P&gt;#define BUSCLOCK 20971520&lt;/P&gt;&lt;P&gt;#define TPM_PRESCALER 32&amp;nbsp;&amp;nbsp;&amp;nbsp; //assicurarsi che il registro TPM_SC sia configurato con prescaler a 32&lt;/P&gt;&lt;P&gt;#define TPM_CLOCK (BUSCLOCK/TPM_PRESCALER)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;**********************&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;main.c&lt;/P&gt;&lt;P&gt;#include &amp;lt;hidef.h&amp;gt; /* for EnableInterrupts macro */&lt;/P&gt;&lt;P&gt;#include "derivative.h" /* include peripheral declarations */&lt;/P&gt;&lt;P&gt;#include "test.h"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;long test_long;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;void main(void) {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp; EnableInterrupts;&lt;/P&gt;&lt;P&gt;&amp;nbsp; /* include your code here */&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; test_long=TPM_CLOCK;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; for(;;) {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; __RESET_WATCHDOG();&amp;nbsp;&amp;nbsp;&amp;nbsp; /* feeds the dog */&lt;/P&gt;&lt;P&gt;&amp;nbsp; } /* loop forever */&lt;/P&gt;&lt;P&gt;&amp;nbsp; /* please make sure that you never leave main */&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*********************&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;preprocess extract:&lt;/P&gt;&lt;P&gt;long test_long ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;void main ( void ) {&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;__asm CLI ; ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;test_long = ( 20971520 / 32 ) ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for ( ; ; ) {&lt;/P&gt;&lt;P&gt;{ __asm sta _SRS . Byte ; } ;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Attached the example I used -&amp;gt; For S08QE128.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Pascal&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Feb 2014 14:53:24 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/evaluate-macro-in-a-h-file/m-p/281321#M10450</guid>
      <dc:creator>trytohelp</dc:creator>
      <dc:date>2014-02-06T14:53:24Z</dc:date>
    </item>
    <item>
      <title>Re: evaluate macro in a .h file</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/evaluate-macro-in-a-h-file/m-p/281322#M10451</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Pascal, I meant calculate the final value of the macro in your case &lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt; ( 20971520 / 32 )&lt;/SPAN&gt;=655360.&lt;/P&gt;&lt;P&gt;Is it possible?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Feb 2014 07:40:55 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/evaluate-macro-in-a-h-file/m-p/281322#M10451</guid>
      <dc:creator>stefanomanca</dc:creator>
      <dc:date>2014-02-07T07:40:55Z</dc:date>
    </item>
    <item>
      <title>Re: evaluate macro in a .h file</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/evaluate-macro-in-a-h-file/m-p/281323#M10452</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Stefano,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I performed several tests but the macro is not evaluated.&lt;/P&gt;&lt;P&gt;The macro is replaced by the definition.&lt;/P&gt;&lt;P&gt;In the example, TPM_CLOCK is replaced by (BUSCLOCK/TPM_PRESCALER) where BUSCLOCK is 20971520 and TPM_PRESCALER 32.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Pascal&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Feb 2014 13:13:56 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/evaluate-macro-in-a-h-file/m-p/281323#M10452</guid>
      <dc:creator>trytohelp</dc:creator>
      <dc:date>2014-02-07T13:13:56Z</dc:date>
    </item>
  </channel>
</rss>

