<?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>LPC MicrocontrollersのトピックRe: LPC4367 Timer Capture issue</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC4367-Timer-Capture-issue/m-p/1321018#M46121</link>
    <description>Hi,
I suggest you initialize a GPIO output pin, in the void TIMER2_IRQHandler(void), toggle the GPIO, you can compare the capturing signal and GPIO output pin with an oscilloscope.
Pls have a try
BR
XiangJun Rong</description>
    <pubDate>Tue, 10 Aug 2021 10:13:24 GMT</pubDate>
    <dc:creator>xiangjun_rong</dc:creator>
    <dc:date>2021-08-10T10:13:24Z</dc:date>
    <item>
      <title>LPC4367 Timer Capture issue</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC4367-Timer-Capture-issue/m-p/1320825#M46114</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am using LPC4637 based Evaluation board OEM13088 for development. I am trying to explore the Timer capture functionality since it is the requirement in our product to measure the frequency .&lt;/P&gt;&lt;P&gt;I have implemented the code where I am using Timer 2 and T2_CAP0 line (P6_1) to measure the frequency. I am getting the interrupt of the timer but the Frequency which i have measured is exceeding the expected one, rather it is not stable at all. I verified the input to the capture line, It is one of the input from out development board Circuit,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I checked with LPC546xx board and it is working properly. So the input the capture line is proper. Not I am not able to get the same result with LPC4367 controller.&lt;/P&gt;&lt;P&gt;Following is the initialization code for the same.&lt;/P&gt;&lt;LI-SPOILER&gt;&lt;P&gt;#define CAP_NUMB 0&lt;BR /&gt;#define TIMER2_PRESCALER 10&lt;BR /&gt;&lt;BR /&gt;ui32_timerFreq = Chip_Clock_GetRate(CLK_MX_TIMER2);//Chip_Clock_GetSystemClockRate();//(PRESCALE_COUNT+1);&lt;/P&gt;&lt;P&gt;Chip_GPIO_Init(LPC_GPIO_PORT);&lt;/P&gt;&lt;P&gt;Chip_SCU_PinMux(0x6,1, MD_PLN_FAST, SCU_MODE_FUNC5);&lt;BR /&gt;LPC_GIMA-&amp;gt;CAP0_IN[2][0]|= (2 &amp;lt;&amp;lt; 4) | (1 &amp;lt;&amp;lt; 1);//0x20&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Chip_TIMER_Init(LPC_TIMER2);&lt;BR /&gt;Chip_RGU_TriggerReset(RGU_TIMER2_RST);&lt;BR /&gt;while (Chip_RGU_InReset(RGU_TIMER2_RST)) {}&lt;/P&gt;&lt;P&gt;// Chip_TIMER_Init(LPC_TIMER2);&lt;/P&gt;&lt;P&gt;Chip_TIMER_Reset(LPC_TIMER2);&lt;/P&gt;&lt;P&gt;// Chip_TIMER_TIMER_SetCountClockSrc(LPC_TIMER2, TIMER_CAPSRC_RISING_CAPN, CAP_NUMB);&lt;/P&gt;&lt;P&gt;Chip_TIMER_PrescaleSet(LPC_TIMER2, TIMER2_PRESCALER);&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Chip_TIMER_ClearCapture(LPC_TIMER2, CAP_NUMB );//&lt;BR /&gt;Chip_TIMER_CaptureRisingEdgeEnable(LPC_TIMER2, CAP_NUMB);//&lt;BR /&gt;// Chip_TIMER_CaptureFallingEdgeEnable (LPC_TIMER2, CAP_NUMB );//&lt;BR /&gt;Chip_TIMER_CaptureEnableInt(LPC_TIMER2,CAP_NUMB);//&lt;/P&gt;&lt;P&gt;NVIC_EnableIRQ(TIMER2_IRQn);&lt;BR /&gt;NVIC_ClearPendingIRQ(TIMER2_IRQn);&lt;/P&gt;&lt;P&gt;Chip_TIMER_Enable(LPC_TIMER2);&lt;/P&gt;&lt;/LI-SPOILER&gt;&lt;P&gt;After this I am able to get the capture evet but the value is exceeding the frequency value. Also find the attached code which I am working on.&lt;/P&gt;&lt;P&gt;Similar issue was there in the Forum but there no reply for the same.&lt;/P&gt;&lt;P&gt;Please check for the issue and solution for the same. Also let me know if required any more information.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Gaurav More&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Aug 2021 06:23:30 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC4367-Timer-Capture-issue/m-p/1320825#M46114</guid>
      <dc:creator>gauravmore</dc:creator>
      <dc:date>2021-08-10T06:23:30Z</dc:date>
    </item>
    <item>
      <title>Re: LPC4367 Timer Capture issue</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC4367-Timer-Capture-issue/m-p/1320920#M46117</link>
      <description>&lt;P&gt;Hi, Gaurav,&lt;/P&gt;
&lt;P&gt;I have checked your code briefly, I think the code is correct. The TImer2 counts internal clock, when the T2_CAP0 signal is coming, the Counter0f T2 is latched to capture register and interrupt is triggered..&lt;/P&gt;
&lt;P&gt;But I think you have to add the line to reset the counter explicitly when the T2 counter reaches to match register for example match0&lt;/P&gt;
&lt;P&gt;//STATIC INLINE void Chip_TIMER_SetMatch(LPC_TIMER_T *pTMR, int8_t matchnum, uint32_t //matchval)&lt;/P&gt;
&lt;P&gt;Chip_TIMER_SetMatch(LPC_TIMER2,0,0xFFFFFFFF);&lt;/P&gt;
&lt;P&gt;Chip_TIMER_ResetOnMatchEnable((LPC_TIMER2, 0);&lt;/P&gt;
&lt;P&gt;pls have a try.&lt;/P&gt;
&lt;P&gt;BR&lt;/P&gt;
&lt;P&gt;XiangJun Rong&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Aug 2021 08:17:38 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC4367-Timer-Capture-issue/m-p/1320920#M46117</guid>
      <dc:creator>xiangjun_rong</dc:creator>
      <dc:date>2021-08-10T08:17:38Z</dc:date>
    </item>
    <item>
      <title>Re: LPC4367 Timer Capture issue</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC4367-Timer-Capture-issue/m-p/1320938#M46118</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;BTW, I think you'd better set up the #define TIMER2_PRESCALER 1&lt;/P&gt;
&lt;P&gt;At the time being, what is your problem?&lt;/P&gt;
&lt;P&gt;BR&lt;/P&gt;
&lt;P&gt;XiangJun Rong&lt;/P&gt;</description>
      <pubDate>Tue, 10 Aug 2021 08:35:29 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC4367-Timer-Capture-issue/m-p/1320938#M46118</guid>
      <dc:creator>xiangjun_rong</dc:creator>
      <dc:date>2021-08-10T08:35:29Z</dc:date>
    </item>
    <item>
      <title>Re: LPC4367 Timer Capture issue</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC4367-Timer-Capture-issue/m-p/1320948#M46119</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;SPAN&gt;XiangJun Rong,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks for the reply,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I check the modification suggested by you both the match set and the Timer prescaler, but still no success,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I also shifted from internal&amp;nbsp;clock to external clock but still the same result.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I also check whether the problem is with the waveform input, but that is also proper&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Any other input please suggest, mean while I will check other possible ways, w.r.t&amp;nbsp; logic implemented&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Gaurav More&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Aug 2021 08:54:59 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC4367-Timer-Capture-issue/m-p/1320948#M46119</guid>
      <dc:creator>gauravmore</dc:creator>
      <dc:date>2021-08-10T08:54:59Z</dc:date>
    </item>
    <item>
      <title>Re: LPC4367 Timer Capture issue</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC4367-Timer-Capture-issue/m-p/1321018#M46121</link>
      <description>Hi,
I suggest you initialize a GPIO output pin, in the void TIMER2_IRQHandler(void), toggle the GPIO, you can compare the capturing signal and GPIO output pin with an oscilloscope.
Pls have a try
BR
XiangJun Rong</description>
      <pubDate>Tue, 10 Aug 2021 10:13:24 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC4367-Timer-Capture-issue/m-p/1321018#M46121</guid>
      <dc:creator>xiangjun_rong</dc:creator>
      <dc:date>2021-08-10T10:13:24Z</dc:date>
    </item>
    <item>
      <title>Re: LPC4367 Timer Capture issue</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC4367-Timer-Capture-issue/m-p/1321035#M46123</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes checking the same at my end, Will update you once it is done with screen shots.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Gaurav More&lt;/P&gt;</description>
      <pubDate>Tue, 10 Aug 2021 10:31:49 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC4367-Timer-Capture-issue/m-p/1321035#M46123</guid>
      <dc:creator>gauravmore</dc:creator>
      <dc:date>2021-08-10T10:31:49Z</dc:date>
    </item>
    <item>
      <title>Re: LPC4367 Timer Capture issue</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC4367-Timer-Capture-issue/m-p/1321679#M46137</link>
      <description>&lt;P&gt;Hi&amp;nbsp;XiangJun Rong,&lt;/P&gt;&lt;P&gt;Thanks for the reply,&lt;/P&gt;&lt;P&gt;I checked the line and got the issue, I had not configured the falling edge trigger option,&lt;/P&gt;&lt;P&gt;I enabled it and now both the line toggling and the input to the capture is matching.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="gauravmore_2-1628668946004.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/152595i85F3B070BD9FF7A0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="gauravmore_2-1628668946004.png" alt="gauravmore_2-1628668946004.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Yellow line is the line toggled and the blue one is the ZCD input from the development board.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;#define CAP_NUMB  0
#define TIMER2_PRESCALER   1
#define UPPER_LIMIT_32	0xFFFFFFFF   

ui32_timerFreq = Chip_Clock_GetRate(CLK_MX_TIMER2);//Chip_Clock_GetSystemClockRate();//(PRESCALE_COUNT+1);

    Chip_GPIO_Init(LPC_GPIO_PORT);

    Chip_SCU_PinMux(0x6,1, MD_PLN_FAST, SCU_MODE_FUNC5);
    LPC_GIMA-&amp;gt;CAP0_IN[2][0]|=  (2 &amp;lt;&amp;lt; 4) ;//| (1 &amp;lt;&amp;lt; 1);//0x20

    Chip_SCU_PinMuxSet(0x02, 12,(SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS |SCU_MODE_FUNC0));
    Chip_GPIO_SetPinState(LPC_GPIO_PORT,1,12,true);
    Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT,1,12);


	Chip_TIMER_Init(LPC_TIMER2);
	Chip_RGU_TriggerReset(RGU_TIMER2_RST);
	while (Chip_RGU_InReset(RGU_TIMER2_RST)) {}

	Chip_TIMER_Reset(LPC_TIMER2);

//	Chip_TIMER_TIMER_SetCountClockSrc(LPC_TIMER2, TIMER_CAPSRC_BOTH_CAPN, CAP_NUMB);

	Chip_TIMER_PrescaleSet(LPC_TIMER2, TIMER2_PRESCALER);

	Chip_TIMER_ClearCapture(LPC_TIMER2, CAP_NUMB );
	Chip_TIMER_CaptureRisingEdgeEnable(LPC_TIMER2, CAP_NUMB);
	Chip_TIMER_CaptureFallingEdgeEnable (LPC_TIMER2, CAP_NUMB );
	Chip_TIMER_CaptureEnableInt(LPC_TIMER2,CAP_NUMB);

	Chip_TIMER_SetMatch(LPC_TIMER2,0,0xFFFFFFFF);
	Chip_TIMER_ResetOnMatchEnable(LPC_TIMER2,0);


	NVIC_EnableIRQ(TIMER2_IRQn);
	NVIC_ClearPendingIRQ(TIMER2_IRQn);

	Chip_TIMER_Enable(LPC_TIMER2);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also need to change the Prescaler to 1 and now I am running the at 100Mhz both controller and timer as well.&lt;/P&gt;&lt;P&gt;But there is one observation,&amp;nbsp; if we consider the clock freq 100Mhz , then expected difference for complete cycle is around 200 counts but the difference observed is not as per the expectation.&amp;nbsp;&lt;/P&gt;&lt;P&gt;see the below screen shot&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="gauravmore_0-1628668224357.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/152592i59DAC7A54DF5369A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="gauravmore_0-1628668224357.png" alt="gauravmore_0-1628668224357.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="gauravmore_1-1628668249661.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/152593i42F5B7BB1A6F52E6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="gauravmore_1-1628668249661.png" alt="gauravmore_1-1628668249661.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;It is not stable to 50Hz it is fluctuating between 49Hz to 50Hz. Here the variable "ui32_current_half_cycle_time" is just a difference between the current and previous capture value of timer 2. And as per the formula the value come around 20Mhz&amp;nbsp;&lt;/P&gt;&lt;P&gt;channels[0].ui32_frequency = (uint32_t)(((uint64_t)ui32_timerFreq*(uint64_t)1000)/(uint64_t)channels[0].ui32_current_half_cycle_time);&lt;/P&gt;&lt;P&gt;Got the reason, changed the Prescaler to 0 from 1 and kept only Rising edge trigger. Now it is coming closer to the expected value.&lt;/P&gt;&lt;P&gt;Also attached the code which w.r.t Capture functionality for LPC4367 over OEM13088.&lt;/P&gt;&lt;P&gt;Please check w.r.t the configuration and the if there is any thing you find that need to be modified pls suggest.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Gaurav More&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Aug 2021 09:16:15 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC4367-Timer-Capture-issue/m-p/1321679#M46137</guid>
      <dc:creator>gauravmore</dc:creator>
      <dc:date>2021-08-11T09:16:15Z</dc:date>
    </item>
  </channel>
</rss>

