<?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>Kinetis Software Development KitのトピックRe: RTC vs FTM measurement</title>
    <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/RTC-vs-FTM-measurement/m-p/459634#M3363</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Alice,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I thought I'd chime in on this old issue with my questions about FTM timer functions.&amp;nbsp;&amp;nbsp;&amp;nbsp; Even though my issue &amp;amp; question is not exactly the same as the poster's problem I hope you will take notice &amp;amp; give me the answer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have taken over this FW on a product made by another SW vendor for the company I work for.&amp;nbsp;&amp;nbsp;&amp;nbsp; The FTM timer is used for timing the motor movement from one position to the next based on MIN &amp;amp; MAX ranges in order for it to know what particular cycle it is on.&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This MCU is capable of 64-bit and all KSDK FTM function parameters allow 32-bit time.&amp;nbsp;&amp;nbsp;&amp;nbsp; However, whenever we increase the MAX value of a timer range to be &amp;gt;65536 milliseconds, e.g. 75000 msec,&amp;nbsp; in order to accommodate slower motor movements, it times out.&amp;nbsp;&amp;nbsp;&amp;nbsp; The motor power supply is operating at 60 MHz.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I do not yet understand all of FTM's function calls &amp;amp; computations so I can't figure out in this interrupt service routine quoted here below,&amp;nbsp;where I should check &amp;amp; change&amp;nbsp;in order to prevent the timer timeout.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please let me know if you need any more info than this &amp;amp; what I have provided in order to be able to help me out.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's where it is failing; where it seems that it is returning a cut-off 16-bit timer captured_ms value instead the full 64-bit 70000 msec value.&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Questions:&lt;/P&gt;&lt;P&gt;1.&amp;nbsp;&amp;nbsp; Why add 16-bit value of 65536 to capturecounts?&lt;/P&gt;&lt;P&gt;2.&amp;nbsp; Why is the capture_ms value compared to 200 at the end?&amp;nbsp; How is that value determined to be the limit?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your help.&lt;/P&gt;&lt;P&gt;MI&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #7f0055; font-size: small;"&gt;&lt;STRONG&gt;void&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: small;"&gt; &lt;STRONG&gt;capture_isr&lt;/STRONG&gt;(&lt;/SPAN&gt;&lt;STRONG style=": ; color: #7f0055; font-size: small;"&gt;void&lt;/STRONG&gt;&lt;SPAN style="font-size: small;"&gt; *data)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #005032; font-size: small;"&gt;gcc_msg2&lt;/SPAN&gt;&lt;SPAN style="font-size: small;"&gt; msg; &lt;/SPAN&gt;&lt;SPAN style="color: #3f7f5f; font-size: small;"&gt;// 12/26/17 &lt;SPAN style="text-decoration: underline;"&gt;mi&lt;/SPAN&gt; new message structure has 32-bit &lt;SPAN style="text-decoration: underline;"&gt;arg&lt;/SPAN&gt; parameter&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #3f7f5f; font-size: small;"&gt;//gcc_msg &lt;SPAN style="text-decoration: underline;"&gt;msg&lt;/SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #005032; font-size: small;"&gt;uint16_t&lt;/SPAN&gt;&lt;SPAN style="font-size: small;"&gt; i;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #005032; font-size: small;"&gt;uint32_t&lt;/SPAN&gt;&lt;SPAN style="font-size: small;"&gt; CaptureTime_ms;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;　&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; &lt;/SPAN&gt;&lt;STRONG style=": ; color: #7f0055; font-size: small;"&gt;if&lt;/STRONG&gt;&lt;SPAN style="font-size: small;"&gt;(FTM_HAL_HasTimerOverflowed(g_ftmBase[VALVE_FTM_UNIT]))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;FTM_HAL_ClearTimerOverflow(g_ftmBase[VALVE_FTM_UNIT]);&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #3f7f5f; font-size: small;"&gt;// Timer OverFlow add overflow count to captured time&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;CaptureCounts += 65536;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #3f7f5f; font-size: small;"&gt;//&lt;SPAN style="text-decoration: underline;"&gt;printf&lt;/SPAN&gt;("... Timer overflowed, CaptureCounts = %7lu\n",CaptureCounts);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; &lt;/SPAN&gt;&lt;STRONG style=": ; color: #7f0055; font-size: small;"&gt;else&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; &lt;/SPAN&gt;&lt;STRONG style=": ; color: #7f0055; font-size: small;"&gt;for&lt;/STRONG&gt;&lt;SPAN style="font-size: small;"&gt; (i = 0; i &amp;lt; &lt;/SPAN&gt;&lt;EM style=": ; color: #0000c0; font-size: small;"&gt;Valve_num_valves&lt;/EM&gt;&lt;SPAN style="font-size: small;"&gt;; i++)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; &lt;/SPAN&gt;&lt;STRONG style=": ; color: #7f0055; font-size: small;"&gt;if&lt;/STRONG&gt;&lt;SPAN style="font-size: small;"&gt; (FTM_HAL_HasChnEventOccurred(g_ftmBase[VALVE_FTM_UNIT], _valve_params[i].&lt;/SPAN&gt;&lt;SPAN style="color: #0000c0; font-size: small;"&gt;ftm_channel&lt;/SPAN&gt;&lt;SPAN style="font-size: small;"&gt;))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; FTM_HAL_ClearChnEventStatus(g_ftmBase[VALVE_FTM_UNIT], _valve_params[i].&lt;/SPAN&gt;&lt;SPAN style="color: #0000c0; font-size: small;"&gt;ftm_channel&lt;/SPAN&gt;&lt;SPAN style="font-size: small;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; CaptureCounts += FTM_HAL_GetChnCountVal(g_ftmBase[VALVE_FTM_UNIT], _valve_params[i].&lt;/SPAN&gt;&lt;SPAN style="color: #0000c0; font-size: small;"&gt;ftm_channel&lt;/SPAN&gt;&lt;SPAN style="font-size: small;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #3f7f5f; font-size: small;"&gt;// &lt;SPAN style="text-decoration: underline;"&gt;Init&lt;/SPAN&gt; FTM counter&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;FTM_HAL_SetCounter(g_ftmBase[VALVE_FTM_UNIT], 0);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #3f7f5f; font-size: small;"&gt;//CaptureTime_ms = (CaptureCounts * 1000) / FTM_DRV_GetClock(VALVE_FTM_UNIT);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;CaptureTime_ms = (CaptureCounts * 100) / FTM_DRV_GetClock(VALVE_FTM_UNIT);&lt;/P&gt;&lt;P&gt;CaptureTime_ms*= 10;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #3f7f5f; font-size: small;"&gt;// 100ms &lt;SPAN style="text-decoration: underline;"&gt;debounce&lt;/SPAN&gt; time&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; &lt;/SPAN&gt;&lt;STRONG style=": ; color: #7f0055; font-size: small;"&gt;if&lt;/STRONG&gt;&lt;SPAN style="font-size: small;"&gt;(CaptureTime_ms &amp;gt; 200)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;CaptureCounts = 0;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #3f7f5f; font-size: small;"&gt;// send message to valve task&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;msg_prepare2(valve_get_task_id(), valve_get_task_id(), MSG_VALVE_INTERRUPT, CaptureTime_ms, &amp;amp;msg);&lt;/P&gt;&lt;P&gt;// msg_prepare(valve_get_task_id(), valve_get_task_id(), MSG_VALVE_INTERRUPT, (uint16_t)CaptureTime_ms, &lt;SPAN style="text-decoration: underline;"&gt;&amp;amp;msg&lt;/SPAN&gt;);&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; _lwmsgq_send(valve_get_msg_queue(), (&lt;/SPAN&gt;&lt;SPAN style="color: #005032; font-size: small;"&gt;_mqx_uint&lt;/SPAN&gt;&lt;SPAN style="font-size: small;"&gt; *)&amp;amp;msg, 0);&lt;/SPAN&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;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 02 Jan 2018 18:37:06 GMT</pubDate>
    <dc:creator>mci</dc:creator>
    <dc:date>2018-01-02T18:37:06Z</dc:date>
    <item>
      <title>RTC vs FTM measurement</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/RTC-vs-FTM-measurement/m-p/459624#M3353</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have the RTC set up to give an interrupt every second, in the interrupt I reset the FTM counter and my software FTM overflow counter and then wait for an input capture. When I get the input capture I print (over USB-CDC) the time in hours, minutes, seconds and then the time to the input capture event in nano-seconds. The FTM is set up to be clocked at 50MHz so the tick is 20nS.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thus the highest value I would expect to see in my "software" overflow counter before the "seconds" interrupt cleared it, would be 1/(65334 x 20nS) = 762&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However I regularly see values over this, can anyone say why this would happen?&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here&amp;nbsp; is the main code created with KSDK 1.3&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3f7f5f; font-family: Consolas; font-size: 10pt;"&gt;//turns on seconds interrupt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: black; font-family: Consolas; font-size: 10pt;"&gt; RTC_DRV_SetSecsIntCmd(rtcTimer1_IDX, true);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&lt;SPAN style="font-family: Consolas; font-size: 10pt;"&gt; &lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3f7f5f; font-size: 10pt; font-family: Consolas;"&gt;//Turn on the FTM counter in free running mode and enable overflow &lt;SPAN style="text-decoration: underline;"&gt;int&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: black; font-family: Consolas; font-size: 10pt;"&gt; FTM_DRV_CounterStart(flexTimer1_IDX, &lt;/SPAN&gt;&lt;EM style="color: #0000c0; font-size: 10pt; font-family: Consolas;"&gt;kCounting_FTM_UP&lt;/EM&gt;&lt;SPAN style="color: black; font-family: Consolas; font-size: 10pt;"&gt;, 0x00, 0xFFFF, true);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3f7f5f; font-size: 10pt; font-family: Consolas;"&gt;//Turn on the FTM0 input capture&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: black; font-family: Consolas; font-size: 10pt;"&gt;FTM_DRV_SetupChnInputCapture(flexTimer1_IDX, &lt;/SPAN&gt;&lt;EM style="color: #0000c0; font-size: 10pt; font-family: Consolas;"&gt;kFtmFallingEdge&lt;/EM&gt;&lt;SPAN style="color: black; font-family: Consolas; font-size: 10pt;"&gt;, FTM0_channel_1, input_filter_off);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&lt;SPAN style="font-family: Consolas; font-size: 10pt;"&gt; &lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&lt;SPAN style="font-family: Consolas; font-size: 10pt;"&gt; &lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: black; font-family: Consolas; font-size: 10pt;"&gt; &lt;STRONG style="color: #7f0055; font-size: 10pt; font-family: Consolas;"&gt;for&lt;/STRONG&gt;&lt;SPAN style="color: black; font-family: Consolas; font-size: 10pt;"&gt;(;;){&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Consolas; font-size: 10pt;"&gt; &lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG style="color: #7f0055; font-size: 10pt; font-family: Consolas;"&gt;if&lt;/STRONG&gt;&lt;SPAN style="color: black; font-family: Consolas; font-size: 10pt;"&gt; (FTM0_Ch1_ICflag == 1 )&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: black; font-family: Consolas; font-size: 10pt;"&gt;&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; {&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: black; font-family: Consolas; font-size: 10pt;"&gt;&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; FTM0_Ch1_ICflag = 0;&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; &lt;/SPAN&gt;&lt;SPAN style="color: #3f7f5f; font-family: Consolas; font-size: 10pt;"&gt;// clears "input capture" flag set in FTM interrupt routine&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: black; font-family: Consolas; font-size: 10pt;"&gt;&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; cmd_get_datetime();&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; &lt;/SPAN&gt;&lt;SPAN style="color: #3f7f5f; font-family: Consolas; font-size: 10pt;"&gt;// prints the current date time&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: black; font-family: Consolas; font-size: 10pt;"&gt;&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; Ch1_nanoseconds_value =(((FTM0_Ch1_timer_overflow_count_store &amp;lt;&amp;lt;16) + FTM0_Ch1_capture_value)*20);&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #3f7f5f; font-family: Consolas; font-size: 10pt;"&gt;// calculates the &lt;SPAN style="text-decoration: underline;"&gt;ns&lt;/SPAN&gt; position of pulse this second&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: black; font-family: Consolas; font-size: 10pt;"&gt;&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; PRINTF(&lt;/SPAN&gt;&lt;SPAN style="color: #2a00ff; font-family: Consolas; font-size: 10pt;"&gt;"capture value%d\r\n"&lt;/SPAN&gt;&lt;SPAN style="color: black; font-family: Consolas; font-size: 10pt;"&gt;, FTM0_Ch1_capture_value);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: black; font-family: Consolas; font-size: 10pt;"&gt;&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; PRINTF(&lt;/SPAN&gt;&lt;SPAN style="color: #2a00ff; font-family: Consolas; font-size: 10pt;"&gt;"overflowcount %d\r\n"&lt;/SPAN&gt;&lt;SPAN style="color: black; font-family: Consolas; font-size: 10pt;"&gt;, FTM0_Ch1_timer_overflow_count_store);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: black; font-family: Consolas; font-size: 10pt;"&gt;&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; PRINTF(&lt;/SPAN&gt;&lt;SPAN style="color: #2a00ff; font-family: Consolas; font-size: 10pt;"&gt;"overflowcount x 65536 = %d\r\n"&lt;/SPAN&gt;&lt;SPAN style="color: black; font-family: Consolas; font-size: 10pt;"&gt;, (FTM0_Ch1_timer_overflow_count_store&amp;lt;&amp;lt;16));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: black; font-family: Consolas; font-size: 10pt;"&gt;&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; PRINTF(&lt;/SPAN&gt;&lt;SPAN style="color: #2a00ff; font-family: Consolas; font-size: 10pt;"&gt;"and %&lt;SPAN style="text-decoration: underline;"&gt;dns&lt;/SPAN&gt;\r\n\n"&lt;/SPAN&gt;&lt;SPAN style="color: black; font-family: Consolas; font-size: 10pt;"&gt;,Ch1_nanoseconds_value);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: black; font-family: Consolas; font-size: 10pt;"&gt;&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; }&lt;/SPAN&gt;&lt;SPAN style="color: black; font-family: Consolas; font-size: 10pt;"&gt;&lt;BR /&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;.....and here is the terminal view, with a couple of examples (second and last) with the overflow count significantly above 762, any thoughts?&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="140987_140987.jpg"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/121077i0A16B7BB79802BF7/image-size/large?v=v2&amp;amp;px=999" role="button" title="140987_140987.jpg" alt="140987_140987.jpg" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="terminal.jpg"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/53061iA3F249E6D809F661/image-size/large?v=v2&amp;amp;px=999" role="button" title="terminal.jpg" alt="terminal.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here are the two interrupt routines.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #7f0055; font-size: 10pt; font-family: Consolas;"&gt;void&lt;/STRONG&gt;&lt;SPAN style="color: black; font-family: Consolas; font-size: 10pt;"&gt; &lt;STRONG&gt;RTC_Seconds_IRQHandler&lt;/STRONG&gt;(&lt;/SPAN&gt;&lt;STRONG style="color: #7f0055; font-size: 10pt; font-family: Consolas;"&gt;void&lt;/STRONG&gt;&lt;SPAN style="color: black; font-family: Consolas; font-size: 10pt;"&gt;)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: black; font-family: Consolas; font-size: 10pt;"&gt;{&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: black; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FTM0_timer_overflow_count= 0;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #3f7f5f; font-family: Consolas; font-size: 10pt;"&gt;//Resets my timer overflow counter back to zero&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: black; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FTM_HAL_SetCounter(g_ftmBase[flexTimer1_IDX],0);&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #3f7f5f; font-family: Consolas; font-size: 10pt;"&gt;//Resets the FTM counter back to zero&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: black; font-family: Consolas; font-size: 10pt;"&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #7f0055; font-size: 10pt; font-family: Consolas;"&gt;void&lt;/STRONG&gt;&lt;SPAN style="color: black; font-family: Consolas; font-size: 10pt;"&gt; &lt;STRONG&gt;FTM0_IRQHandler&lt;/STRONG&gt;(&lt;/SPAN&gt;&lt;STRONG style="color: #7f0055; font-size: 10pt; font-family: Consolas;"&gt;void&lt;/STRONG&gt;&lt;SPAN style="color: black; font-family: Consolas; font-size: 10pt;"&gt;)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: black; font-family: Consolas; font-size: 10pt;"&gt;{&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: black; font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #3f7f5f; font-family: Consolas; font-size: 10pt;"&gt;//checking the interrupt flag source and clearing&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG style="color: #7f0055; font-size: 10pt; font-family: Consolas;"&gt;if&lt;/STRONG&gt;&lt;SPAN style="color: black; font-family: Consolas; font-size: 10pt;"&gt;(FTM_HAL_HasTimerOverflowed(g_ftmBase[flexTimer1_IDX]))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: black; font-family: Consolas; font-size: 10pt;"&gt;&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; {&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: black; font-family: Consolas; font-size: 10pt;"&gt;&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; FTM_HAL_ClearTimerOverflow(g_ftmBase[flexTimer1_IDX]);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: black; font-family: Consolas; font-size: 10pt;"&gt;&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; FTM0_timer_overflow_count++;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: black; font-family: Consolas; font-size: 10pt;"&gt;&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; }&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Consolas; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt; &lt;STRONG style="color: #7f0055; font-size: 10pt; font-family: Consolas;"&gt;if&lt;/STRONG&gt;&lt;SPAN style="color: black; font-family: Consolas; font-size: 10pt;"&gt;(FTM_HAL_HasChnEventOccurred(g_ftmBase[flexTimer1_IDX],CHAN1_IDX))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: black; font-family: Consolas; font-size: 10pt;"&gt;&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; {&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: black; font-family: Consolas; font-size: 10pt;"&gt;&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; FTM_HAL_ClearChnEventFlag(g_ftmBase[flexTimer1_IDX],CHAN1_IDX);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: black; font-family: Consolas; font-size: 10pt;"&gt;&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; FTM0_Ch1_timer_overflow_count_store = FTM0_timer_overflow_count;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: black; font-family: Consolas; font-size: 10pt;"&gt;&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; FTM0_Ch1_capture_value=FTM_HAL_GetChnCountVal(g_ftmBase[flexTimer1_IDX],CHAN1_IDX);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: black; font-family: Consolas; font-size: 10pt;"&gt;&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; FTM0_Ch1_ICflag = true;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: black; font-family: Consolas; font-size: 10pt;"&gt;&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; }&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: black; font-family: Consolas; font-size: 10pt;"&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: black; font-family: Consolas; font-size: 10pt;"&gt;Thanks!&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 14 Feb 2016 12:43:17 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/RTC-vs-FTM-measurement/m-p/459624#M3353</guid>
      <dc:creator>therealfreegeek</dc:creator>
      <dc:date>2016-02-14T12:43:17Z</dc:date>
    </item>
    <item>
      <title>Re: RTC vs FTM measurement</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/RTC-vs-FTM-measurement/m-p/459625#M3354</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Ernest,&lt;/P&gt;&lt;P&gt;What about the chip number of your chip ?&lt;/P&gt;&lt;P&gt;And could you please show the code of how to configure the clock of the FTM0.&lt;/P&gt;&lt;P&gt;And please check whether it run to the interrupt function of &lt;SPAN style="color: black; font-family: Consolas; font-size: 10pt;"&gt;&lt;STRONG&gt;RTC_Seconds_IRQHandler()&amp;nbsp; &lt;/STRONG&gt;and reset the counter&lt;STRONG&gt; ?&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: black; font-family: Consolas; font-size: 10pt;"&gt;Hope it helps&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: black; font-family: Consolas; font-size: 10pt;"&gt;Alice&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Feb 2016 07:19:49 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/RTC-vs-FTM-measurement/m-p/459625#M3354</guid>
      <dc:creator>Alice_Yang</dc:creator>
      <dc:date>2016-02-16T07:19:49Z</dc:date>
    </item>
    <item>
      <title>Re: RTC vs FTM measurement</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/RTC-vs-FTM-measurement/m-p/459626#M3355</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, oops, it is running on the FRDM-K64F board, with SW3 configured as the input capture and the CDC on the second usb port and I used PE for the configuration set up of all the peripherals. I have attached the project which is mainly part of the RTC demo then a loop waiting for the input capture.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Feb 2016 09:21:22 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/RTC-vs-FTM-measurement/m-p/459626#M3355</guid>
      <dc:creator>therealfreegeek</dc:creator>
      <dc:date>2016-02-16T09:21:22Z</dc:date>
    </item>
    <item>
      <title>Re: RTC vs FTM measurement</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/RTC-vs-FTM-measurement/m-p/459627#M3356</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Ernest,&lt;/P&gt;&lt;P&gt;I have checked your code and test it , from the PE configuration , we can see you configure the&lt;/P&gt;&lt;P&gt;clock source of FTM0 60MHZ,&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_1.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/53339i35FA6621831AB70B/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_1.png" alt="pastedImage_1.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;so&amp;nbsp; we should change&amp;nbsp; this 1/(65334 x 20nS) = 762&amp;nbsp; to&amp;nbsp; 60MHZ/65334 = 918 .&lt;/P&gt;&lt;P&gt;And from your result , this is no "overflow count" more than 918 , and also in my test , there is neither .&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_0.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/53304iBDF793CC7135842B/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_0.png" alt="pastedImage_0.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Hope it helps&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Have a great day,&lt;BR /&gt;Alice Yang&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Feb 2016 10:17:51 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/RTC-vs-FTM-measurement/m-p/459627#M3356</guid>
      <dc:creator>Alice_Yang</dc:creator>
      <dc:date>2016-02-16T10:17:51Z</dc:date>
    </item>
    <item>
      <title>Re: RTC vs FTM measurement</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/RTC-vs-FTM-measurement/m-p/459628#M3357</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Alice, thanks for the insight, that would make sense, but please have a look at my MCG settings, they are set to have the system clock at 50MHz, but for some reason the FTM is saying that the system clock is 60MHz.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is the FTM overwriting the settings from the clockMAN? Also, I can not seem to be able to change the FTM component inspector to 50MHz.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="mcg.jpg"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/53544i5C66BB103B5EE889/image-size/large?v=v2&amp;amp;px=999" role="button" title="mcg.jpg" alt="mcg.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Feb 2016 11:24:52 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/RTC-vs-FTM-measurement/m-p/459628#M3357</guid>
      <dc:creator>therealfreegeek</dc:creator>
      <dc:date>2016-02-16T11:24:52Z</dc:date>
    </item>
    <item>
      <title>Re: RTC vs FTM measurement</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/RTC-vs-FTM-measurement/m-p/459629#M3358</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Ernest,&lt;/P&gt;&lt;P&gt;Please pay attention that , there are five clock configuration you can choose:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_0.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/53373i5C7EF9158D3A4ECB/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_0.png" alt="pastedImage_0.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;if you want use the mode 0, please configure it at here :&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_1.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/53418iCD8DCFFF89E6CE86/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_1.png" alt="pastedImage_1.png" /&gt;&lt;/span&gt;,&lt;/P&gt;&lt;P&gt;then in the FTM component , the clock source you can choose 50MHZ.&lt;/P&gt;&lt;P&gt;In your project , for you chose the mode 4:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_2.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/53437iF30701D8F7D7F12F/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_2.png" alt="pastedImage_2.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;we can see in the mode 4, the system clock is 60MHZ, so ....&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_3.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/53495i30F72098B9323C40/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_3.png" alt="pastedImage_3.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope it helps&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Have a great day,&lt;BR /&gt;Alice Yang&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Feb 2016 03:07:01 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/RTC-vs-FTM-measurement/m-p/459629#M3358</guid>
      <dc:creator>Alice_Yang</dc:creator>
      <dc:date>2016-02-17T03:07:01Z</dc:date>
    </item>
    <item>
      <title>Re: RTC vs FTM measurement</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/RTC-vs-FTM-measurement/m-p/459630#M3359</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Alice,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ahh, I had missed that, thank you very much for your help. I tried to change clockman_initconfig 4 to have a bus clock of 50MHz and a USB clock of 48MHz but this seemed not to be possible, is this correct?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would prefer to operate at 50MHz bus rather than 60MHz bus as this makes the maths much faster as I can use a shift rather than a multiply.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards&lt;/P&gt;&lt;P&gt;Jim&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Feb 2016 14:47:51 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/RTC-vs-FTM-measurement/m-p/459630#M3359</guid>
      <dc:creator>therealfreegeek</dc:creator>
      <dc:date>2016-02-17T14:47:51Z</dc:date>
    </item>
    <item>
      <title>Re: RTC vs FTM measurement</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/RTC-vs-FTM-measurement/m-p/459631#M3360</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Jim,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Yes, if you configure the bus clock to 50M, the best value to 48M of USB is configure to 50M.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_0.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/53736i7EA28782072E5004/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_0.png" alt="pastedImage_0.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope it helps&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Have a great day,&lt;BR /&gt;Alice Yang&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Feb 2016 07:42:40 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/RTC-vs-FTM-measurement/m-p/459631#M3360</guid>
      <dc:creator>Alice_Yang</dc:creator>
      <dc:date>2016-02-18T07:42:40Z</dc:date>
    </item>
    <item>
      <title>Re: RTC vs FTM measurement</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/RTC-vs-FTM-measurement/m-p/459632#M3361</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Alice, yes that is what I tried, however the closest frequency that could be generated for the USB was 50MHz with a 50MHz bus which caused an error.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For the time being it is not too big a problem for me to stay with 60MHz bus frequency which does allow a 48MHz clock for the USB.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again for your patience and support.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Feb 2016 09:27:18 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/RTC-vs-FTM-measurement/m-p/459632#M3361</guid>
      <dc:creator>therealfreegeek</dc:creator>
      <dc:date>2016-02-19T09:27:18Z</dc:date>
    </item>
    <item>
      <title>Re: RTC vs FTM measurement</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/RTC-vs-FTM-measurement/m-p/459633#M3362</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Ernest,&lt;/P&gt;&lt;P&gt;OK, welcome !&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>Fri, 19 Feb 2016 09:41:22 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/RTC-vs-FTM-measurement/m-p/459633#M3362</guid>
      <dc:creator>Alice_Yang</dc:creator>
      <dc:date>2016-02-19T09:41:22Z</dc:date>
    </item>
    <item>
      <title>Re: RTC vs FTM measurement</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/RTC-vs-FTM-measurement/m-p/459634#M3363</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Alice,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I thought I'd chime in on this old issue with my questions about FTM timer functions.&amp;nbsp;&amp;nbsp;&amp;nbsp; Even though my issue &amp;amp; question is not exactly the same as the poster's problem I hope you will take notice &amp;amp; give me the answer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have taken over this FW on a product made by another SW vendor for the company I work for.&amp;nbsp;&amp;nbsp;&amp;nbsp; The FTM timer is used for timing the motor movement from one position to the next based on MIN &amp;amp; MAX ranges in order for it to know what particular cycle it is on.&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This MCU is capable of 64-bit and all KSDK FTM function parameters allow 32-bit time.&amp;nbsp;&amp;nbsp;&amp;nbsp; However, whenever we increase the MAX value of a timer range to be &amp;gt;65536 milliseconds, e.g. 75000 msec,&amp;nbsp; in order to accommodate slower motor movements, it times out.&amp;nbsp;&amp;nbsp;&amp;nbsp; The motor power supply is operating at 60 MHz.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I do not yet understand all of FTM's function calls &amp;amp; computations so I can't figure out in this interrupt service routine quoted here below,&amp;nbsp;where I should check &amp;amp; change&amp;nbsp;in order to prevent the timer timeout.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please let me know if you need any more info than this &amp;amp; what I have provided in order to be able to help me out.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's where it is failing; where it seems that it is returning a cut-off 16-bit timer captured_ms value instead the full 64-bit 70000 msec value.&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Questions:&lt;/P&gt;&lt;P&gt;1.&amp;nbsp;&amp;nbsp; Why add 16-bit value of 65536 to capturecounts?&lt;/P&gt;&lt;P&gt;2.&amp;nbsp; Why is the capture_ms value compared to 200 at the end?&amp;nbsp; How is that value determined to be the limit?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your help.&lt;/P&gt;&lt;P&gt;MI&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #7f0055; font-size: small;"&gt;&lt;STRONG&gt;void&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: small;"&gt; &lt;STRONG&gt;capture_isr&lt;/STRONG&gt;(&lt;/SPAN&gt;&lt;STRONG style=": ; color: #7f0055; font-size: small;"&gt;void&lt;/STRONG&gt;&lt;SPAN style="font-size: small;"&gt; *data)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #005032; font-size: small;"&gt;gcc_msg2&lt;/SPAN&gt;&lt;SPAN style="font-size: small;"&gt; msg; &lt;/SPAN&gt;&lt;SPAN style="color: #3f7f5f; font-size: small;"&gt;// 12/26/17 &lt;SPAN style="text-decoration: underline;"&gt;mi&lt;/SPAN&gt; new message structure has 32-bit &lt;SPAN style="text-decoration: underline;"&gt;arg&lt;/SPAN&gt; parameter&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #3f7f5f; font-size: small;"&gt;//gcc_msg &lt;SPAN style="text-decoration: underline;"&gt;msg&lt;/SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #005032; font-size: small;"&gt;uint16_t&lt;/SPAN&gt;&lt;SPAN style="font-size: small;"&gt; i;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #005032; font-size: small;"&gt;uint32_t&lt;/SPAN&gt;&lt;SPAN style="font-size: small;"&gt; CaptureTime_ms;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;　&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; &lt;/SPAN&gt;&lt;STRONG style=": ; color: #7f0055; font-size: small;"&gt;if&lt;/STRONG&gt;&lt;SPAN style="font-size: small;"&gt;(FTM_HAL_HasTimerOverflowed(g_ftmBase[VALVE_FTM_UNIT]))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;FTM_HAL_ClearTimerOverflow(g_ftmBase[VALVE_FTM_UNIT]);&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #3f7f5f; font-size: small;"&gt;// Timer OverFlow add overflow count to captured time&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;CaptureCounts += 65536;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #3f7f5f; font-size: small;"&gt;//&lt;SPAN style="text-decoration: underline;"&gt;printf&lt;/SPAN&gt;("... Timer overflowed, CaptureCounts = %7lu\n",CaptureCounts);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; &lt;/SPAN&gt;&lt;STRONG style=": ; color: #7f0055; font-size: small;"&gt;else&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; &lt;/SPAN&gt;&lt;STRONG style=": ; color: #7f0055; font-size: small;"&gt;for&lt;/STRONG&gt;&lt;SPAN style="font-size: small;"&gt; (i = 0; i &amp;lt; &lt;/SPAN&gt;&lt;EM style=": ; color: #0000c0; font-size: small;"&gt;Valve_num_valves&lt;/EM&gt;&lt;SPAN style="font-size: small;"&gt;; i++)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; &lt;/SPAN&gt;&lt;STRONG style=": ; color: #7f0055; font-size: small;"&gt;if&lt;/STRONG&gt;&lt;SPAN style="font-size: small;"&gt; (FTM_HAL_HasChnEventOccurred(g_ftmBase[VALVE_FTM_UNIT], _valve_params[i].&lt;/SPAN&gt;&lt;SPAN style="color: #0000c0; font-size: small;"&gt;ftm_channel&lt;/SPAN&gt;&lt;SPAN style="font-size: small;"&gt;))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; FTM_HAL_ClearChnEventStatus(g_ftmBase[VALVE_FTM_UNIT], _valve_params[i].&lt;/SPAN&gt;&lt;SPAN style="color: #0000c0; font-size: small;"&gt;ftm_channel&lt;/SPAN&gt;&lt;SPAN style="font-size: small;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; CaptureCounts += FTM_HAL_GetChnCountVal(g_ftmBase[VALVE_FTM_UNIT], _valve_params[i].&lt;/SPAN&gt;&lt;SPAN style="color: #0000c0; font-size: small;"&gt;ftm_channel&lt;/SPAN&gt;&lt;SPAN style="font-size: small;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #3f7f5f; font-size: small;"&gt;// &lt;SPAN style="text-decoration: underline;"&gt;Init&lt;/SPAN&gt; FTM counter&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;FTM_HAL_SetCounter(g_ftmBase[VALVE_FTM_UNIT], 0);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #3f7f5f; font-size: small;"&gt;//CaptureTime_ms = (CaptureCounts * 1000) / FTM_DRV_GetClock(VALVE_FTM_UNIT);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;CaptureTime_ms = (CaptureCounts * 100) / FTM_DRV_GetClock(VALVE_FTM_UNIT);&lt;/P&gt;&lt;P&gt;CaptureTime_ms*= 10;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #3f7f5f; font-size: small;"&gt;// 100ms &lt;SPAN style="text-decoration: underline;"&gt;debounce&lt;/SPAN&gt; time&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; &lt;/SPAN&gt;&lt;STRONG style=": ; color: #7f0055; font-size: small;"&gt;if&lt;/STRONG&gt;&lt;SPAN style="font-size: small;"&gt;(CaptureTime_ms &amp;gt; 200)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;CaptureCounts = 0;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #3f7f5f; font-size: small;"&gt;// send message to valve task&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;msg_prepare2(valve_get_task_id(), valve_get_task_id(), MSG_VALVE_INTERRUPT, CaptureTime_ms, &amp;amp;msg);&lt;/P&gt;&lt;P&gt;// msg_prepare(valve_get_task_id(), valve_get_task_id(), MSG_VALVE_INTERRUPT, (uint16_t)CaptureTime_ms, &lt;SPAN style="text-decoration: underline;"&gt;&amp;amp;msg&lt;/SPAN&gt;);&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; _lwmsgq_send(valve_get_msg_queue(), (&lt;/SPAN&gt;&lt;SPAN style="color: #005032; font-size: small;"&gt;_mqx_uint&lt;/SPAN&gt;&lt;SPAN style="font-size: small;"&gt; *)&amp;amp;msg, 0);&lt;/SPAN&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;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Jan 2018 18:37:06 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/RTC-vs-FTM-measurement/m-p/459634#M3363</guid>
      <dc:creator>mci</dc:creator>
      <dc:date>2018-01-02T18:37:06Z</dc:date>
    </item>
  </channel>
</rss>

