<?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 Problem with major  or minor compare??? in S12 / MagniV Microcontrollers</title>
    <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Problem-with-major-or-minor-compare/m-p/125033#M234</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN style="color: #ff0000;"&gt;This message contains an entire topic ported from a separate forum. The original message and all replies are in this single message. We have seeded this new forum with selected information that we expect will be of value to you as you search for answers to your questions.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN class="postdetails"&gt;&lt;STRONG&gt;Posted: Fri Sep 02, 2005 4:29 am&lt;SPAN class="gen"&gt;&amp;nbsp;&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN class="postdetails"&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN class="postdetails"&gt;&lt;SPAN class="postbody"&gt;Hello!&lt;BR /&gt;&lt;BR /&gt; I have the following rummy problem.&lt;BR /&gt; I measure voltage with the ATD-Module. In a ISR, I write the Value of&lt;BR /&gt; ATD0DR0 in a struct.&lt;BR /&gt;&lt;BR /&gt; It looks like this:&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&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;struct value { volatile short volt; volatile float volt_calc; }var; // (void)init_value(void) { var.volt=0; var.volt_calc=0; } #pragma interrupt_handler isratd void isratd(void) { var.volt=ATD0DR0; } // (void)calc(void) { asm ("sei"); var.volt_calc=var.volt*3.967 asm("cli"); }&lt;/PRE&gt;&lt;DIV&gt;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;Okay, that works perfectly.&lt;BR /&gt;I can display the value of var.volt_calc over a printf-command on the&lt;BR /&gt;screen.&lt;BR /&gt;But now, I have problems with the following command.&lt;BR /&gt;An example:&lt;BR /&gt;if (var.volt_calc&amp;lt;20.5){;}&lt;BR /&gt;This query is only true, when the value of var.volt_calc is equal 0.&lt;BR /&gt;It´s false, when i.e. the value is 1 or 4 or 7.4 etc.&lt;BR /&gt;I don´t know, what´s wrong.&lt;BR /&gt;&lt;BR /&gt;I use the ICC compiler with a S12DJ64 controller.&lt;BR /&gt;Please, help me, if you have an idea?!?!&lt;BR /&gt;&lt;BR /&gt;Cheers&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN class="postdetails"&gt;&lt;STRONG&gt;Posted: Fri Sep 02, 2005 11:36 am&lt;SPAN class="gen"&gt;&amp;nbsp;&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN class="postdetails"&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN class="postdetails"&gt;&lt;SPAN class="postbody"&gt;Hello,&lt;BR /&gt;&lt;BR /&gt; I tried your code (slightly modified) in CodeWarrior, it worked for me... You could maybe try a workaround, something like:&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&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;float dummy; ... dummy = (var.volt_calc) /20.5; if (dummy &amp;lt; 1.0){&amp;nbsp;&amp;nbsp; // smaller } &lt;/PRE&gt;&lt;DIV&gt;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;or&lt;BR /&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;float dummy; ... dummy = ((var.volt_calc) /20.5)-1.0; if (dummy &amp;lt; 0.0){&amp;nbsp;&amp;nbsp; // smaller } &lt;/PRE&gt;&lt;DIV&gt;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;maybe also do printf's of the dummy variable to see what's the value of it.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Then I have a question to you, if I may:&lt;BR /&gt;I'm trying to use the HW I2C on my S12DP256B, but it doesn't work. Have you gotten your code to work? Could you tell me your configuration words?&lt;BR /&gt;&lt;BR /&gt;MfG,&lt;/DIV&gt;&lt;DIV&gt;&lt;BR /&gt;&lt;SPAN class="postdetails"&gt;&lt;STRONG&gt;Posted: Fri Sep 02, 2005 11:46 am&lt;SPAN class="gen"&gt;&amp;nbsp;&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;SPAN class="postdetails"&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;P&gt;&lt;SPAN class="postdetails"&gt;&lt;SPAN class="postbody"&gt;&lt;SPAN class="postdetails"&gt;&lt;SPAN class="postbody"&gt;&lt;SPAN class="postdetails"&gt;&lt;SPAN class="postbody"&gt;Hello&lt;BR /&gt;&lt;BR /&gt; Thank you for the comment. It is rummy, that your code is working. But I will test your example soon. Now I am not at work.&lt;BR /&gt; I use a monitor program and interrupts. It is possible, that this monitor program is the cause of my problem?!?!&lt;BR /&gt;&lt;BR /&gt; Okay, now to your problem "I2C":&lt;BR /&gt; Yes it´s working. But I don´t use interrupts in my I2C routine and it is probably not very professional, but it works.&lt;BR /&gt; I can send you the code perhaps per Mail?!?!&lt;BR /&gt;&lt;BR /&gt; Cheers&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="postdetails"&gt;&lt;SPAN class="postbody"&gt;&lt;SPAN class="postdetails"&gt;&lt;SPAN class="postbody"&gt;&lt;SPAN class="postdetails"&gt;&lt;SPAN class="postbody"&gt;&lt;SPAN class="postdetails"&gt;&lt;STRONG&gt;Posted: Fri Sep 02, 2005 12:31 pm&lt;SPAN class="gen"&gt;&amp;nbsp;&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="postdetails"&gt;&lt;SPAN class="postbody"&gt;&lt;SPAN class="postdetails"&gt;&lt;SPAN class="postbody"&gt;&lt;SPAN class="postdetails"&gt;&lt;SPAN class="postbody"&gt;&lt;SPAN class="postdetails"&gt;&lt;SPAN class="postbody"&gt;Servus,&lt;BR /&gt;&lt;BR /&gt; I would not really expect the monitor to be the problem, but I'd have to see where the code-parts are placed to be sure.&lt;BR /&gt; I would more expect the problem to be with missing type-casting or parantheses, but that also seemed okay.&lt;BR /&gt;&lt;BR /&gt; Turning off the interrupts while doing the calculation (as you do) is btw. a good idea &lt;A href="http://www.freegeeks.net/modules/Forums/images/smiles/icon_smile.gif" rel="nofollow noopener noreferrer" target="_blank"&gt;&lt;IMG alt="Smile" border="0" src="http://www.freegeeks.net/modules/Forums/images/smiles/icon_smile.gif" /&gt;&lt;/A&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV&gt;&lt;BR /&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 28 Jan 2006 10:13:44 GMT</pubDate>
    <dc:creator>RChapman</dc:creator>
    <dc:date>2006-01-28T10:13:44Z</dc:date>
    <item>
      <title>Problem with major  or minor compare???</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Problem-with-major-or-minor-compare/m-p/125033#M234</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN style="color: #ff0000;"&gt;This message contains an entire topic ported from a separate forum. The original message and all replies are in this single message. We have seeded this new forum with selected information that we expect will be of value to you as you search for answers to your questions.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN class="postdetails"&gt;&lt;STRONG&gt;Posted: Fri Sep 02, 2005 4:29 am&lt;SPAN class="gen"&gt;&amp;nbsp;&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN class="postdetails"&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN class="postdetails"&gt;&lt;SPAN class="postbody"&gt;Hello!&lt;BR /&gt;&lt;BR /&gt; I have the following rummy problem.&lt;BR /&gt; I measure voltage with the ATD-Module. In a ISR, I write the Value of&lt;BR /&gt; ATD0DR0 in a struct.&lt;BR /&gt;&lt;BR /&gt; It looks like this:&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&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;struct value { volatile short volt; volatile float volt_calc; }var; // (void)init_value(void) { var.volt=0; var.volt_calc=0; } #pragma interrupt_handler isratd void isratd(void) { var.volt=ATD0DR0; } // (void)calc(void) { asm ("sei"); var.volt_calc=var.volt*3.967 asm("cli"); }&lt;/PRE&gt;&lt;DIV&gt;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;Okay, that works perfectly.&lt;BR /&gt;I can display the value of var.volt_calc over a printf-command on the&lt;BR /&gt;screen.&lt;BR /&gt;But now, I have problems with the following command.&lt;BR /&gt;An example:&lt;BR /&gt;if (var.volt_calc&amp;lt;20.5){;}&lt;BR /&gt;This query is only true, when the value of var.volt_calc is equal 0.&lt;BR /&gt;It´s false, when i.e. the value is 1 or 4 or 7.4 etc.&lt;BR /&gt;I don´t know, what´s wrong.&lt;BR /&gt;&lt;BR /&gt;I use the ICC compiler with a S12DJ64 controller.&lt;BR /&gt;Please, help me, if you have an idea?!?!&lt;BR /&gt;&lt;BR /&gt;Cheers&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN class="postdetails"&gt;&lt;STRONG&gt;Posted: Fri Sep 02, 2005 11:36 am&lt;SPAN class="gen"&gt;&amp;nbsp;&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN class="postdetails"&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN class="postdetails"&gt;&lt;SPAN class="postbody"&gt;Hello,&lt;BR /&gt;&lt;BR /&gt; I tried your code (slightly modified) in CodeWarrior, it worked for me... You could maybe try a workaround, something like:&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&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;float dummy; ... dummy = (var.volt_calc) /20.5; if (dummy &amp;lt; 1.0){&amp;nbsp;&amp;nbsp; // smaller } &lt;/PRE&gt;&lt;DIV&gt;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;or&lt;BR /&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;float dummy; ... dummy = ((var.volt_calc) /20.5)-1.0; if (dummy &amp;lt; 0.0){&amp;nbsp;&amp;nbsp; // smaller } &lt;/PRE&gt;&lt;DIV&gt;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;maybe also do printf's of the dummy variable to see what's the value of it.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Then I have a question to you, if I may:&lt;BR /&gt;I'm trying to use the HW I2C on my S12DP256B, but it doesn't work. Have you gotten your code to work? Could you tell me your configuration words?&lt;BR /&gt;&lt;BR /&gt;MfG,&lt;/DIV&gt;&lt;DIV&gt;&lt;BR /&gt;&lt;SPAN class="postdetails"&gt;&lt;STRONG&gt;Posted: Fri Sep 02, 2005 11:46 am&lt;SPAN class="gen"&gt;&amp;nbsp;&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;SPAN class="postdetails"&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;P&gt;&lt;SPAN class="postdetails"&gt;&lt;SPAN class="postbody"&gt;&lt;SPAN class="postdetails"&gt;&lt;SPAN class="postbody"&gt;&lt;SPAN class="postdetails"&gt;&lt;SPAN class="postbody"&gt;Hello&lt;BR /&gt;&lt;BR /&gt; Thank you for the comment. It is rummy, that your code is working. But I will test your example soon. Now I am not at work.&lt;BR /&gt; I use a monitor program and interrupts. It is possible, that this monitor program is the cause of my problem?!?!&lt;BR /&gt;&lt;BR /&gt; Okay, now to your problem "I2C":&lt;BR /&gt; Yes it´s working. But I don´t use interrupts in my I2C routine and it is probably not very professional, but it works.&lt;BR /&gt; I can send you the code perhaps per Mail?!?!&lt;BR /&gt;&lt;BR /&gt; Cheers&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="postdetails"&gt;&lt;SPAN class="postbody"&gt;&lt;SPAN class="postdetails"&gt;&lt;SPAN class="postbody"&gt;&lt;SPAN class="postdetails"&gt;&lt;SPAN class="postbody"&gt;&lt;SPAN class="postdetails"&gt;&lt;STRONG&gt;Posted: Fri Sep 02, 2005 12:31 pm&lt;SPAN class="gen"&gt;&amp;nbsp;&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="postdetails"&gt;&lt;SPAN class="postbody"&gt;&lt;SPAN class="postdetails"&gt;&lt;SPAN class="postbody"&gt;&lt;SPAN class="postdetails"&gt;&lt;SPAN class="postbody"&gt;&lt;SPAN class="postdetails"&gt;&lt;SPAN class="postbody"&gt;Servus,&lt;BR /&gt;&lt;BR /&gt; I would not really expect the monitor to be the problem, but I'd have to see where the code-parts are placed to be sure.&lt;BR /&gt; I would more expect the problem to be with missing type-casting or parantheses, but that also seemed okay.&lt;BR /&gt;&lt;BR /&gt; Turning off the interrupts while doing the calculation (as you do) is btw. a good idea &lt;A href="http://www.freegeeks.net/modules/Forums/images/smiles/icon_smile.gif" rel="nofollow noopener noreferrer" target="_blank"&gt;&lt;IMG alt="Smile" border="0" src="http://www.freegeeks.net/modules/Forums/images/smiles/icon_smile.gif" /&gt;&lt;/A&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV&gt;&lt;BR /&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 28 Jan 2006 10:13:44 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Problem-with-major-or-minor-compare/m-p/125033#M234</guid>
      <dc:creator>RChapman</dc:creator>
      <dc:date>2006-01-28T10:13:44Z</dc:date>
    </item>
  </channel>
</rss>

