ZHCAB39E January 2022 – February 2022 TMS320F28379D , TMS320F28379D-Q1 , TMS320F28379S
说明
这是定期调用的运行时函数,用于根据应用程序的要求动态配置和更改脉冲生成要求。必须使用相应的参数(例如脉冲数、周期、持续时间等)定期调用该函数。
定义
uint16_t pto_pulsegen_runPulseGen(
uint32_t pulseLo,
uint32_t pulseHi,
uint32_t ptoActivePeriod,
uint32_t ptoFullPeriod,
uint32_t ptoInterruptTime,
uint16_t ptoDirection,
uint16_t run
);
参数
输入:
返回:
使用
在 pto_pulsegen.c 中提供了一个名为 pto_setOptions 的示例配置函数作为示例,旨在协助 pto_pulsegen_runPulseGen 函数以及执行中间计算。请参阅以下代码计算示例,其中说明了如何生成该函数的各种参数。更多详细信息,请参阅 pto_pulsegen.c 和 pto_pulsegen.h 文件。
uint32_t pto_setOptions(
uint32_t numPulses, //number of pulses needed to be generated in next period
uint32_t Period, // PTO period in clock cycles
uint32_t ptoInterruptTime, // Interrupt generation time
uint16_t ptoDirection, // Direction output
uint16_t run) //run-stop condition.
{
uint32_t pulseFreq, reminder;
uint32_t pulseLo;
uint32_t pulseHi;
uint32_t ptoActivePeriod;
uint32_t ptoFullPeriod;
pulseFreq = Period / numPulses;
reminder = Period - (pulseFreq * numPulses);
pulseLo = (pulseFreq/2 );
pulseHi = pulseFreq;
ptoActivePeriod = (pulseFreq * numPulses);
ptoFullPeriod = Period;
pto_pulsegen_runPulseGen(
pulseLo,
pulseHi,
ptoActivePeriod,
ptoFullPeriod,
ptoInterruptTime,
ptoDirection,
run);
return(reminder);
}