<?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: Finding period of a square wave using Input Capture in S12 / MagniV Microcontrollers</title>
    <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Finding-period-of-a-square-wave-using-Input-Capture/m-p/174528#M6060</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you very much.&lt;/P&gt;&lt;P&gt;The problem is fixed.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I will try to use the proper forum next time.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 10 Jan 2011 09:12:57 GMT</pubDate>
    <dc:creator>MO_84</dc:creator>
    <dc:date>2011-01-10T09:12:57Z</dc:date>
    <item>
      <title>Finding period of a square wave using Input Capture</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Finding-period-of-a-square-wave-using-Input-Capture/m-p/174526#M6058</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm trying to find the period of a external square wave using the input capture interrupt.&lt;/P&gt;&lt;P&gt;There is one line of code causing the below error message and its driving me mad. The error is caused by the following line:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; actual_period = period/6000000;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code works fine if I remove this line. But then I have to use a calculator to find the actual period every time.&lt;/P&gt;&lt;P&gt;Please Help. I'm not a very good programmer.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;&lt;STRONG&gt;Here is the error message:&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;C4000: Condition always TRUE&lt;BR /&gt;&lt;BR /&gt;main.c line 35&amp;nbsp; &amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Link Error&amp;nbsp;&amp;nbsp; : L1822: Symbol _FSFLOAT in file C:\Documents and Settings\Mo\Desktop\Lakehead_U\Project\Input Capture\input capture\input_capture_Data\Standard\ObjectCode\main.c.o&lt;BR /&gt;is undefined&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Link Error&amp;nbsp;&amp;nbsp; : Link failed&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;&lt;STRONG&gt;Here is the code:&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;#include &amp;lt;hidef.h&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* common defines and macros */#include "derivative.h"&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* derivative-specific definitions */volatile unsigned int rising, period;volatile unsigned int flag;#pragma CODE_SEG __NEAR_SEG NON_BANKED /* Interrupt section for this module.Placement will be in NON_BANKED area. *//* Interrupt on a rising edge of waveform connected to PT0 */interrupt void toc0_isr(void){&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; flag ++;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(flag == 1)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rising=TC0;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (flag == 2)&amp;nbsp;&amp;nbsp;&amp;nbsp; period = TC0 - rising;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (flag == 3)&amp;nbsp;&amp;nbsp;&amp;nbsp; flag = 0;&amp;nbsp;&amp;nbsp;&amp;nbsp; }#pragma CODE_SEG DEFAULTvoid input_capture_initialize(void); /* prototype to initialize input capture */void main(void) {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; float actual_period;&amp;nbsp;&amp;nbsp;&amp;nbsp; DDRT = 0xFE;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* PT0 is input, all the rest are unchanged */&amp;nbsp;&amp;nbsp;&amp;nbsp; flag = 0;&amp;nbsp;&amp;nbsp;&amp;nbsp; input_capture_initialize();&amp;nbsp;&amp;nbsp;&amp;nbsp; EnableInterrupts; /* clear I bit of CCR */&amp;nbsp;&amp;nbsp;&amp;nbsp; while(1)&amp;nbsp;&amp;nbsp;&amp;nbsp; {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; actual_period = period/6000000;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; void input_capture_initialize(void){&amp;nbsp; TSCR1=0x90; /* enable timer and fast clear, rather than writing to bit0 of TFLG1 */&amp;nbsp; TSCR2=0x02; /* prescale to 4&amp;nbsp; 6000000 pps, longest pulse width measured using*/&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; TIOS=0x00;&amp;nbsp; /* select input capture (all channels) */&amp;nbsp; TCTL3=0x00; /* capture disabled on channels 4 to 7 */&amp;nbsp; TCTL4=0x01; /*PORTT0 capture on rising edge, channels 1 to 3 disabled */&amp;nbsp; TIE=0x01;&amp;nbsp;&amp;nbsp; /* enable timer interrupt on C0 */}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 09:23:18 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Finding-period-of-a-square-wave-using-Input-Capture/m-p/174526#M6058</guid>
      <dc:creator>MO_84</dc:creator>
      <dc:date>2020-10-29T09:23:18Z</dc:date>
    </item>
    <item>
      <title>Re: Finding period of a square wave using Input Capture</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Finding-period-of-a-square-wave-using-Input-Capture/m-p/174527#M6059</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;_FSFLOAT is integer to float conversion routine. Clearly you told project wizard you don't want floating point. You probably selected 'None' for promised best code density :smileyhappy:. You should either 1) recreate project and select double is 32bits or 64bits, but not&amp;nbsp;None. Or 2) remove integer only ansixxx.lib from your project, read &amp;lt;CW root&amp;gt;\lib\hc12c\readme.txt and add appropriate library with FP support.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;volatile unsigned int&amp;nbsp;period;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; float actual_period;&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; actual_period = period/6000000;&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Clearly actual_period will be always 0.0. To make it not zero, you should typecast dividend, divisor, or both them&amp;nbsp;to float.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; actual_period = (float)period/6000000;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;P.S. Subject has&amp;nbsp;very little to do with the problem.&amp;nbsp;"undefined _FSFLOAT" would be better.&amp;nbsp;But again, it is&amp;nbsp;a&amp;nbsp;Codewarrior usage issue, not 16-bit MCU. Please use right forum next time.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 08 Jan 2011 18:23:11 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Finding-period-of-a-square-wave-using-Input-Capture/m-p/174527#M6059</guid>
      <dc:creator>kef</dc:creator>
      <dc:date>2011-01-08T18:23:11Z</dc:date>
    </item>
    <item>
      <title>Re: Finding period of a square wave using Input Capture</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Finding-period-of-a-square-wave-using-Input-Capture/m-p/174528#M6060</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you very much.&lt;/P&gt;&lt;P&gt;The problem is fixed.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I will try to use the proper forum next time.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Jan 2011 09:12:57 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Finding-period-of-a-square-wave-using-Input-Capture/m-p/174528#M6060</guid>
      <dc:creator>MO_84</dc:creator>
      <dc:date>2011-01-10T09:12:57Z</dc:date>
    </item>
  </channel>
</rss>

