Part Number:CC1310
我在使用SCS中的Uart Emulator時,為了省電,我將uart在結束工作後進行關閉(透過scifUartStopEmulator();和scifUartSetBaudRate(0);),並在下次的while中,重新啟動,但是每次重新啟動後(透過scifResetTaskStructs和scifExecuteTasksOnceNbl),就會觸發scTaskAlertCallback,但是我並沒有接收到Uart的RX
程式碼如下
void scCtrlReadyCallback(void) {printf("scCtrlReadyCallback\n"); } // scCtrlReadyCallback void scTaskAlertCallback(void) {printf("scTaskAlertCallback\n"); } // scTaskAlertCallback void scUartTask(UArg a0, UArg a1) {printf("scUartTask start\n");// Initialize the Sensor ControllerscifOsalInit();scifOsalRegisterCtrlReadyCallback(scCtrlReadyCallback);scifOsalRegisterTaskAlertCallback(scTaskAlertCallback);scifInit(&scifDriverSetup);scifStartRtcTicksNow(0x00010000 / 8);// Start the UART emulatorscifResetTaskStructs((1 << SCIF_UART_EMULATOR_TASK_ID), (1 << SCIF_STRUCT_CFG) | (1 << SCIF_STRUCT_INPUT) | (1 << SCIF_STRUCT_OUTPUT));scifExecuteTasksOnceNbl(1 << SCIF_UART_EMULATOR_TASK_ID);// Enable baud rate generationscifUartSetBaudRate(9600);// Enable RX (10 idle bit periods required before enabling start bit detection)scifUartSetRxFifoThr(SCIF_UART_RX_FIFO_MAX_COUNT / 2);scifUartSetRxTimeout(10 * 2);scifUartSetRxEnableReqIdleCount(10 * 2);scifUartRxEnable(1);// Enable events (half full RX FIFO or 10 bit period timeoutscifUartSetEventMask(BV_SCIF_UART_ALERT_RX_FIFO_ABOVE_THR | BV_SCIF_UART_ALERT_RX_BYTE_TIMEOUT);while(1){// Start the UART emulatorscifResetTaskStructs((1 << SCIF_UART_EMULATOR_TASK_ID), (1 << SCIF_STRUCT_CFG) | (1 << SCIF_STRUCT_INPUT) | (1 << SCIF_STRUCT_OUTPUT));scifExecuteTasksOnceNbl(1 << SCIF_UART_EMULATOR_TASK_ID);// Enable baud rate generationscifUartSetBaudRate(9600);// Enable events (half full RX FIFO or 10 bit period timeoutscifUartSetEventMask(BV_SCIF_UART_ALERT_RX_FIFO_ABOVE_THR | BV_SCIF_UART_ALERT_RX_BYTE_TIMEOUT);printf("scUartTask wait for semaphore post\n");// Wait for an ALERT callbackSemaphore_pend(uartTaskSemHandle, BIOS_WAIT_FOREVER);// Clear the ALERT interrupt sourcescifClearAlertIntSource();// Echo all characters currently in the RX FIFOint rxFifoCount = scifUartGetRxFifoCount();uartRxCount = rxFifoCount;i = 0;while (rxFifoCount--){UartRxBuf[i] = (char)scifUartRxGetChar();i++;}// Clear the events that triggered thisscifUartClearEvents();// Acknowledge the alert eventscifAckAlertEvents();scifWaitOnNbl(500000);printf("wait 0.5s\n");scifUartStopEmulator();scifUartSetBaudRate(0);printf("wait 5s\n");scifWaitOnNbl(5000000);} } // taskFxn
Alex Zhang:
您好,已经跟进您的问题,谢谢。
,
Alex Zhang:
uart在开启接收时是不会进入低功耗的,电流损耗会增加。目前采用常规做 IO + 外部中断,有数据时,切换为UART rx.当然对应的从机也要做调整。