<?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>Model-Based Design Toolbox (MBDT)のトピックMPC5744P does not work properly for PWM input capture based on MBD</title>
    <link>https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/MPC5744P-does-not-work-properly-for-PWM-input-capture-based-on/m-p/1391907#M6828</link>
    <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I configured input capture based on MBD to measure the frequency and duty cycle of PWM, I encountered a problem:&lt;BR /&gt;First of all, I configured one input capture according to the official example, as follows:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="1010183396_0-1640431580335.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/166216iDE6583CB89E5015F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="1010183396_0-1640431580335.png" alt="1010183396_0-1640431580335.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The code generated by this model is working properly，Then I continued to configure a few others, but found that they did not work properly, the configuration is as follows：&lt;/P&gt;&lt;P&gt;Through debug, it was found that this inoperable code did not generate a configured interrupt, that is, Input Capture 2 Flag Interrupt, and the corresponding interrupt function is as follows:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="1010183396_1-1640431723584.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/166217i6014B9DB8C28EFAB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="1010183396_1-1640431723584.png" alt="1010183396_1-1640431723584.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Of course, I have set the corresponding interrupt in the model and made sure that the PWM signal is input to the chip, as follows：&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="1010183396_2-1640431830563.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/166218i6EFB6A6C527726B3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="1010183396_2-1640431830563.png" alt="1010183396_2-1640431830563.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Later, normal operation can be realized through the register, and the corresponding configuration is as follows:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;void ETimer_EtcInit(u8 ucETimerNo, u8 ucChNo)
{
	pETIMER[ucETimerNo]-&amp;gt;ENBL.R &amp;amp;= (~((1&amp;lt;&amp;lt;ucChNo)));// disable Timer channels
	/* CTRL1---0x3F00
	 * bit15-13:	CNTMODE = 1	count rising edge of primary source
	 * bit12-8:	PRIsrc=0x1F	ip bus clock divide by 128
	 * bit12-8:	PRIsrc=0x1C	ip bus clock divide by 16
	 * bit7:	ONCE	= 0	count repeatedly
	 * bit6:	LENGTH	= 0	continue counting to roll over
	 * bit5:	DIR	= 0	count up
	 * bit4-0:	SECsrc=n	counter #n input pin
	 */
#if (PWM_FRE_RANGE == RANGE_HIGH)
	pETIMER[ucETimerNo]-&amp;gt;CH[ucChNo].CTRL1.R = 0x3C00 | (ucChNo);
#else
	pETIMER[ucETimerNo]-&amp;gt;CH[ucChNo].CTRL1.R = 0x3F00 | (ucChNo);
#endif
	pETIMER[ucETimerNo]-&amp;gt;CH[ucChNo].COMP1.R = 0xFFFF;
	/* CCCTRL---0x0264
	 * bit15-13:	CLC2	= 0	never preload
	 * bit12-10:	CLC1	= 0	never preload
	 * bit9-8:	CMPMODE	= 2	comp1 for counting up;	comp2 for counting down
	 * bit7-6:	CPT2MODE= 1	CAPT2	capture falling edge
	 * bit5-4:	CPT1MODE= 2	CAPT1	capture rising edge
	 * bit3-2:	CFWM	= 1	capture FIFO water mark
	 * bit1:	ONESHOT	= 0	free running(not one shot mode)
	 * bit0:	ARM	= 0	input capture disable
	 */
	pETIMER[ucETimerNo]-&amp;gt;CH[ucChNo].CCCTRL.R = 0x0264;
	/* INTDMA---0x0080
	 * bit15:	ICF2DE	= 0	Input Capture 2 Flag DMA disable
	 * bit14:	ICF1DE	= 0	Input Capture 1 Flag DMA disable
	 * bit13:	CMPLD2DE= 0	Comparator Load Register 2 Flag DMA disable
	 * bit12:	CMPLD1DE= 0	Comparator Load Register 1 Flag DMA disable
	 * bit9:	WDFIE	= 0	Watchdog Flag Interrupt disable
	 * bit8:	RDFIE	= 0	Redundant Channel Flag Interrupt disable
	 * bit7:	ICF2IE	= 1	Input Capture 2 Flag Interrupt enable
	 * bit6:	ICF1IE	= 0	Input Capture 1 Flag Interrupt  disable
	 * bit5:	IEHFIE	= 0	Input Edge High Flag Interrupt  disable
	 * bit4:	IELFIE	= 0	Input Edge Low Flag Interrupt  disable
	 * bit3:	TOFIE	= 0	Timer Overflow Flag Interrupt  enable
	 * bit2:	TCF2IE	= 0	Timer Compare 2 Flag Interrupt  disable
	 * bit1:	TCF1IE	= 0	Timer Compare 1 Flag Interrupt  disable
	 * bit0:	TCFIE	= 0	Timer Compare Flag Interrupt  disable
	 */
	pETIMER[ucETimerNo]-&amp;gt;CH[ucChNo].INTDMA.R = 0x0080;		//Input Capture 2
	pETIMER[ucETimerNo]-&amp;gt;CH[ucChNo].CTRL3.R	= 1;

	pETIMER[ucETimerNo]-&amp;gt;ENBL.R |= (1&amp;lt;&amp;lt;ucChNo);				// enable Timer channels

	pETIMER[ucETimerNo]-&amp;gt;CH[ucChNo].CCCTRL.B.ARM = 1;// input capture enable
}&lt;/LI-CODE&gt;&lt;P&gt;Finally, after configuring the model according to the corresponding register, the code generated by the model still does not work properly。&lt;/P&gt;&lt;P&gt;I put all the models in the attachment:&lt;BR /&gt;The first model is a model that can work normally, and the second is a model that does not work properly。&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;&lt;P&gt;zhang.&lt;/P&gt;</description>
    <pubDate>Sat, 25 Dec 2021 11:44:02 GMT</pubDate>
    <dc:creator>Yunhe</dc:creator>
    <dc:date>2021-12-25T11:44:02Z</dc:date>
    <item>
      <title>MPC5744P does not work properly for PWM input capture based on MBD</title>
      <link>https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/MPC5744P-does-not-work-properly-for-PWM-input-capture-based-on/m-p/1391907#M6828</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I configured input capture based on MBD to measure the frequency and duty cycle of PWM, I encountered a problem:&lt;BR /&gt;First of all, I configured one input capture according to the official example, as follows:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="1010183396_0-1640431580335.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/166216iDE6583CB89E5015F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="1010183396_0-1640431580335.png" alt="1010183396_0-1640431580335.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The code generated by this model is working properly，Then I continued to configure a few others, but found that they did not work properly, the configuration is as follows：&lt;/P&gt;&lt;P&gt;Through debug, it was found that this inoperable code did not generate a configured interrupt, that is, Input Capture 2 Flag Interrupt, and the corresponding interrupt function is as follows:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="1010183396_1-1640431723584.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/166217i6014B9DB8C28EFAB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="1010183396_1-1640431723584.png" alt="1010183396_1-1640431723584.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Of course, I have set the corresponding interrupt in the model and made sure that the PWM signal is input to the chip, as follows：&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="1010183396_2-1640431830563.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/166218i6EFB6A6C527726B3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="1010183396_2-1640431830563.png" alt="1010183396_2-1640431830563.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Later, normal operation can be realized through the register, and the corresponding configuration is as follows:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;void ETimer_EtcInit(u8 ucETimerNo, u8 ucChNo)
{
	pETIMER[ucETimerNo]-&amp;gt;ENBL.R &amp;amp;= (~((1&amp;lt;&amp;lt;ucChNo)));// disable Timer channels
	/* CTRL1---0x3F00
	 * bit15-13:	CNTMODE = 1	count rising edge of primary source
	 * bit12-8:	PRIsrc=0x1F	ip bus clock divide by 128
	 * bit12-8:	PRIsrc=0x1C	ip bus clock divide by 16
	 * bit7:	ONCE	= 0	count repeatedly
	 * bit6:	LENGTH	= 0	continue counting to roll over
	 * bit5:	DIR	= 0	count up
	 * bit4-0:	SECsrc=n	counter #n input pin
	 */
#if (PWM_FRE_RANGE == RANGE_HIGH)
	pETIMER[ucETimerNo]-&amp;gt;CH[ucChNo].CTRL1.R = 0x3C00 | (ucChNo);
#else
	pETIMER[ucETimerNo]-&amp;gt;CH[ucChNo].CTRL1.R = 0x3F00 | (ucChNo);
#endif
	pETIMER[ucETimerNo]-&amp;gt;CH[ucChNo].COMP1.R = 0xFFFF;
	/* CCCTRL---0x0264
	 * bit15-13:	CLC2	= 0	never preload
	 * bit12-10:	CLC1	= 0	never preload
	 * bit9-8:	CMPMODE	= 2	comp1 for counting up;	comp2 for counting down
	 * bit7-6:	CPT2MODE= 1	CAPT2	capture falling edge
	 * bit5-4:	CPT1MODE= 2	CAPT1	capture rising edge
	 * bit3-2:	CFWM	= 1	capture FIFO water mark
	 * bit1:	ONESHOT	= 0	free running(not one shot mode)
	 * bit0:	ARM	= 0	input capture disable
	 */
	pETIMER[ucETimerNo]-&amp;gt;CH[ucChNo].CCCTRL.R = 0x0264;
	/* INTDMA---0x0080
	 * bit15:	ICF2DE	= 0	Input Capture 2 Flag DMA disable
	 * bit14:	ICF1DE	= 0	Input Capture 1 Flag DMA disable
	 * bit13:	CMPLD2DE= 0	Comparator Load Register 2 Flag DMA disable
	 * bit12:	CMPLD1DE= 0	Comparator Load Register 1 Flag DMA disable
	 * bit9:	WDFIE	= 0	Watchdog Flag Interrupt disable
	 * bit8:	RDFIE	= 0	Redundant Channel Flag Interrupt disable
	 * bit7:	ICF2IE	= 1	Input Capture 2 Flag Interrupt enable
	 * bit6:	ICF1IE	= 0	Input Capture 1 Flag Interrupt  disable
	 * bit5:	IEHFIE	= 0	Input Edge High Flag Interrupt  disable
	 * bit4:	IELFIE	= 0	Input Edge Low Flag Interrupt  disable
	 * bit3:	TOFIE	= 0	Timer Overflow Flag Interrupt  enable
	 * bit2:	TCF2IE	= 0	Timer Compare 2 Flag Interrupt  disable
	 * bit1:	TCF1IE	= 0	Timer Compare 1 Flag Interrupt  disable
	 * bit0:	TCFIE	= 0	Timer Compare Flag Interrupt  disable
	 */
	pETIMER[ucETimerNo]-&amp;gt;CH[ucChNo].INTDMA.R = 0x0080;		//Input Capture 2
	pETIMER[ucETimerNo]-&amp;gt;CH[ucChNo].CTRL3.R	= 1;

	pETIMER[ucETimerNo]-&amp;gt;ENBL.R |= (1&amp;lt;&amp;lt;ucChNo);				// enable Timer channels

	pETIMER[ucETimerNo]-&amp;gt;CH[ucChNo].CCCTRL.B.ARM = 1;// input capture enable
}&lt;/LI-CODE&gt;&lt;P&gt;Finally, after configuring the model according to the corresponding register, the code generated by the model still does not work properly。&lt;/P&gt;&lt;P&gt;I put all the models in the attachment:&lt;BR /&gt;The first model is a model that can work normally, and the second is a model that does not work properly。&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;&lt;P&gt;zhang.&lt;/P&gt;</description>
      <pubDate>Sat, 25 Dec 2021 11:44:02 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/MPC5744P-does-not-work-properly-for-PWM-input-capture-based-on/m-p/1391907#M6828</guid>
      <dc:creator>Yunhe</dc:creator>
      <dc:date>2021-12-25T11:44:02Z</dc:date>
    </item>
  </channel>
</rss>

