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.
王工您好:μ A
我想问一下:μ A
uint32 pwmPeriod =(hetRAM->指令[(cap << 1U)+ 26U].Data)>> 7U;
和 μ A
uint32 pwmPeriod =(hetRAM->指令[(PWM << 1U)+ 42U].Data + 128U)>>7U;
1)有什么区别?μ A
2)为什么第二行代码中要+128?
您好、Mingxi、
在 HALCoGen 生成的 HET 代码中、
[引用 userid="507609" URL"~μ C/support/microcontrollers/arm-based microcontrollers-group/arm-based microcontrollers/f/arm-based microcontrollers-forum/1104796/tms570lc4357-n2het-pwm"] uint32 pwmPeriod =(hetRAM->指令[(cap)[+26U]数据引用)<[+26U]第26条指令为: PCNT、用于捕捉输入信号0的周期
[引用 userid="507609" URL"~μ C/support/microcontrollers/arm-based microcontrollers-group/arm-based microcontrollers/f/arm-based microcontrollers-forum/1104796/tms570lc4357-n2het-pwm"] uint32 pwmPeriod =(hetRAM->Instruction [(PWM)+128u]+数据[[[+42U]+报价[[[+42U]第42条指令为: MOV64、用于更新指令#2 DJZ (远程地址)使用的 PWM0周期。
现在考虑 MOV64指令的数据字段:
该数据字段由7位高分辨率数据字段和25位环路分辨率数据字段组成。 此 HALCoGen 示例不使用高分辨率功能、因此不使用"HR 数据"字段。 这就是更新后的数据值被7移位、然后添加128的偏移(2^7 = 128)的原因。
王工:μ A
1)如果我想捕获PWM脉冲的周期period ,应该使用PCNT 还是MOV64 指令?μ A
2)为什么代码2需要先加128再shifted x 7?而不是直接
uint32 pwmPeriod =(hetRAM->指令[(PWM << 1U)+ 42U].Data)>> 7U;
PCNT
[?而不是直接 userid="507609" URL"~μ C/support/microcontrollers/arm-based microcontrollers-group/arm-based microcontrollers/f/arm based microcontrollers-forume/1104796/tms570lc4357-n2het-PWM/4093721#4093721"] 2 μ m x 7 μ)为什么代码2需要先加128再shiftedDJZ 指令用于生成 PWM 周期、每次 执行 DJZ 指令时、DJZ 中的25位数据都会递减、直到 计数器计数到0。 周期是数据+1。
DJZ 数据字段由指令42 (MOV64)更新。