This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS570LC4357: PWM

Part Number: TMS570LC4357

王工您好:

       咨询一下。

      1)下图中Table 23-7和Table 23-8什么区别啊(23.2.5.8 Edge Detection Input Timing)。

      2)如何判断是否使用了 High Resolution Instructions?

           比如下列函数使用ECNT指令,此指令是不是就没有High Resolution?

uint32 edgeGetCounter(hetRAMBASE_t * hetRAM, uint32 edge)
{
return hetRAM->Instruction[edge + 17U].Data >> 7U;
}

       

         3)我们捕获pwm时,pwm会产生杂波,我们是否可以通过调节参数,> (hr) (lr) t c(VCLK2)或者> 2 (hr) t c(VCLK2)来过滤掉杂波?

        

  • Hi Mingxi,

    There are three clocks when executing N2HET instructions in N2HET RAM:

    • VCLK2: The N2HET instructions execute at this clock rate. Each instruction may take 1~3 VLCK2 cycles. Please find more information in table 23-73 "Instruction Summary" in TRM.

    • High Resolution Clock (HRP): It is the smallest time increment with which a pin can change it’s state or can be measured in the case of input signals. HRP= tCLK2 * hr

    • Loop Resolution Clock (LRP):  The first N2HET instruction at 0x00 is fetched and executed at the occurrences of the loop resolution clock. After the last instruction is executed, the first instruction 0x location 0x00 is prefetched, but will not execute until the occurrence of the loop resolution clock. LRP = HRP * lr = tCLK2 * hr * lr

    1. HR resolution is not enabled: if compare values match (for example, data in CMP instruction, and data of CNT instruction or value of a specified register), the pin action is performed at the rising edge of next Loop Clock 

    2. HR is enabled: the pin action won't performed at the rising edge of loop clock, but add a delay of hr_data VCLK2 cycles.

    The 2nd table is for HR instructions, but the 1st table is not.

  •   2)如何判断是否使用了 High Resolution Instructions?

    Five H2NET instructions (PCNT, WCAP, ECMP, MCMP, and PWCNT) have a dedicated hr_lr bit (high resolution/low resolution) allowing operation either in HR mode or in standard resolution mode by ignoring the HR field.

    By default, the hr_lr bit value is 0 which implies HR operation mode. If hr_lr =1, HR mode is disabled.

    For Exmaple:

    PCNT Instruction:

    If hr_lr is 0 then PCNT captures the HR delay. if hr_lr is 1 then PCNT only captures at loop resolution.

    Please be aware of that only one instruction per high resolution pin is allowed to operate in HR mode (bit cleared to 0), but the other instructions can be used in standard resolution mode (bit set to 1).

    函数使用ECNT指令,此指令是不是就没有High Resolution?

    ECNT is used to count the edges of pulses of the input signal. It doesn't measure the pulse width or period, so It doesn't have hr_lr field. 

  •  3)我们捕获pwm时,pwm会产生杂波,我们是否可以通过调节参数,> (hr) (lr) t c(VCLK2)或者> 2 (hr) t c(VCLK2)来过滤掉杂波?

    No. Where did you probe this PWM signal? If there any circuitry for filtering this PWM signal. Does your code output a PWM whose frequency is out of the valid range?

  • 王工:

            我们通过N2HET1[18]引脚来捕获外部PWM,但是通过示波器观察的外部波形如下,存在以下杂波,会导致采集脉冲的个数多于pwm设计发出的脉冲个数。

           

        1)我们采用ECNT这个命令来计算PWM上升沿个数的,因为ECNT没有使用HR mode ,所以是不是可以将 (hr) (lr) t c(VCLK2)调大,大于杂波的高电平时间(100us),这样就采集不到杂波了,计算PWM个数就正确了,您看我这个思路可行吗?

        2)如果我想使用PCNT指令来计算PWM周期,是不是就要 2 (hr) t c(VCLK2)>杂波高电平时间,就能过滤掉杂波,你看我这个思路可行吗?

  • 王工

         1)为何TRM中和Datasheet中关于捕获时序计算不一样啊,一个是>(hr) (lr) t c(VCLK2),一个是(HRP) (LRP) tc (VCLK2) + 2 ,我们以哪个为准?

         2)t c(VCLK2)就是VCLK2的周期吗?如果VCLK2是20MHZ,那么t c(VCLK2)就是50ns?

  • Please use the formulas in datasheet. 

    The HRP and LRP in the table 7-24 should be HR and LR.

    2)t c(VCLK2)就是VCLK2的周期吗?如果VCLK2是20MHZ,那么t c(VCLK2)就是50ns?

    Yes, the Tc(vclk2) is the period of VCLK2