我用利用HAL Code Generatr配置rti 的counter0的campare0 产生10ms中断,
配置rti compare0中断
设置rti中断间隔
然后根据中断计数实现一个占空比50%的周期200ms的脉冲
把NHET3配置成输入捕捉
在NHET13脚输出到NHET3脚作为输入信号,
用rti.c的capGetSignal(cap0);
但是我发现我的程序好像什么都没捕捉到
串口数据全部为零
至少占空比不应为零 我做的是50%的脉冲啊
下边是主程序的代码:
/* USER CODE BEGIN (0) */
#include \"rti.h\"
#include \"gio.h\"
#include \"het.h\"
#include \"sci.h\"
/* USER CODE END */
/* Include Files */
#include \"sys_common.h\"
#include \"system.h\"
/* USER CODE BEGIN (1) */
/* USER CODE END */
/** @fn void main(void)
* @brief Application main function
* @note This function is empty by default.
*
* This function is called after startup.
* The user can use this function to implement the application.
*/
/* USER CODE BEGIN (2) */
/* USER CODE END */
void main(void)
{
/* USER CODE BEGIN (3) */
hetSIGNAL_t CAP;
unsigned char a,b,c;
gioInit();
rtiInit();
hetInit();
sciInit();
rtiEnableNotification(rtiNOTIFICATION_COMPARE0);
rtiEnableNotification(rtiNOTIFICATION_COMPARE1);
rtiEnableNotification(rtiNOTIFICATION_COMPARE2);
rtiEnableNotification(rtiNOTIFICATION_COMPARE3);
rtiStartCounter(rtiCOUNTER_BLOCK0);
_enable_IRQ();//开启中断
sciSendByte(sciREG2, 0);
CAP=capGetSignal(cap0);
a=(unsigned char)(CAP.duty);
sciSendByte(sciREG2, a);
sciSendByte(sciREG2, 0);
b=(unsigned char)(CAP.period/256);
c=(unsigned char)(CAP.period);
sciSendByte(sciREG2, b);
sciSendByte(sciREG2, c);
sciSendByte(sciREG2, 0);
while(1){
//capGetSignal(cap0);
}
/* USER CODE END */
}
附件是整个程序代码本文含有来自论坛的附件或图片点击查看原帖附件。