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.
尊敬的 TI:
我尝试使用 RTI 定时器中断来测量 GIO (N2HET)寄存器的时间。 我想测量3ms、因此我在 HALCoGen 中将 RTI Compare1周期配置为0.01ms。
因此、中断每0.01ms 发生一次、在这种情况下、我检查 GIO 引脚上是否有3.3V (导通状态)、并使用0.01增大变量。
之后、我打印出每秒测量的导通时间(也可能小于或大于3ms)。
问题是、我测量的是6ms、这是它应该是的(3ms)的两倍。
我附加了代码片段。
有什么想法、会导致问题的原因是什么?
感谢您提前回复。
此致、
Zsolt Nagy
代码片段:
void rtiNotification (rtibase_t * rtiREG、uint32通知)
{
if (notification =2U){
EXPT = gioGetBit (hetPORT1、14);
if (expt){
毫秒+=0.01;
}
}
感谢您的快速回复。 我认为我测量得很好、或者至少代码是好的。 我随附其中的其他部分(与前者一起)。 你怎么看? 问题仍然存在。 如果信号在2.8 - 3.2ms 范围内、则 GIO 切换将切换绿色 LED;如果不是、则切换红色 LED。 通过调试、我能够看到、即使"毫秒"变量被错误的值填充、平均值计算也很糟糕。
提前感谢。
此致、
Zsolt Nagy
代码片段:
void rtiNotification (rtibase_t * rtiREG、uint32通知)
{
if (notification =2U){
EXPT = gioGetBit (hetPORT1、14);
if (expt){
静激= 1;
毫秒+=0.01;
否则、如果(静止){
if (milliseconds >= 2.8 && milliseconds <=3.2){
gioSetBit (gioPORTA、5、0);
gioSetBit (gioPORTA、2、1);
}
否则{
gioSetBit (gioPORTA、5、1);
gioSetBit (gioPORTA、2、0);
}
死态= 0;
msavg =(msavg +毫秒)/2;
毫秒= 0;
}
}
}