工具/软件:
您好、
我正在使用 CC2340R5并成功实现了rfPacketTx
示例代码、到目前为止、一切都正常运行。
我为内部中断编写了 RTC 中断设置和 ISR、但不起作用。 下面是我的代码供您参考—请检查并告诉我问题可能是什么。
#define RTC_CTL_EN (1 << 0) // Enable bit volatile bool rtcWakeFlag = false; void RTC_IRQHandler(void) { // Check if Compare Channel 1 (EV1) interrupt is pending if (HWREG(RTC_BASE + RTC_O_MIS) & RTC_MIS_EV1) { // Clear the EV1 interrupt flag HWREG(RTC_BASE + RTC_O_ICLR) = RTC_ICLR_EV1_CLR; // Set your application flag rtcWakeFlag = true; } } void setupRTCWakeup(uint32_t seconds) { // Reset the RTC counter (if required) HWREG(RTC_BASE + RTC_O_CTL) = RTC_CTL_RST_CLR; // Enable RTC counter HWREG(RTC_BASE + RTC_O_CTL) |= RTC_CTL_EN; // Get current RTC time uint32_t now = HWREG(RTC_BASE + RTC_O_TIME8U); // bits [34:3] of counter uint32_t future = now + (seconds << 13); // RTC tick = 1/8192 s → seconds * 8192 ticks // Set Compare Channel 1 (CH1) to trigger at `future` time HWREG(RTC_BASE + RTC_O_CH1CC8U) = future; // Clear previous interrupt flag for EV1 (CH1) HWREG(RTC_BASE + RTC_O_ICLR) = RTC_ICLR_EV1_CLR; // Enable interrupt for EV1 HWREG(RTC_BASE + RTC_O_IMSET) = RTC_IMSET_EV1; // << Corrected // Register and enable RTC interrupt in NVIC IntRegister(INT_CPUIRQ0, RTC_IRQHandler); IntEnable(INT_CPUIRQ0); // Enable global interrupts IntEnableMaster(); }
提前感谢!