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.

CC1310: SCS Uart Emulator 如何實現低工耗

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 Controller
    scifOsalInit();
    scifOsalRegisterCtrlReadyCallback(scCtrlReadyCallback);
    scifOsalRegisterTaskAlertCallback(scTaskAlertCallback);
    scifInit(&scifDriverSetup);

    scifStartRtcTicksNow(0x00010000 / 8);

    // Start the UART emulator
    scifResetTaskStructs((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 generation
    scifUartSetBaudRate(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 timeout
    scifUartSetEventMask(BV_SCIF_UART_ALERT_RX_FIFO_ABOVE_THR | BV_SCIF_UART_ALERT_RX_BYTE_TIMEOUT);

    while(1)
    {
        // Start the UART emulator
        scifResetTaskStructs((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 generation
        scifUartSetBaudRate(9600);

        // Enable events (half full RX FIFO or 10 bit period timeout
        scifUartSetEventMask(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 callback
        Semaphore_pend(uartTaskSemHandle, BIOS_WAIT_FOREVER);

        // Clear the ALERT interrupt source
        scifClearAlertIntSource();

        // Echo all characters currently in the RX FIFO
        int rxFifoCount = scifUartGetRxFifoCount();

        uartRxCount = rxFifoCount;

        i = 0;

        while (rxFifoCount--)
        {
            UartRxBuf[i] = (char)scifUartRxGetChar();
            i++;
        }

        // Clear the events that triggered this
        scifUartClearEvents();

        // Acknowledge the alert event
        scifAckAlertEvents();

        scifWaitOnNbl(500000);
        printf("wait 0.5s\n");

        scifUartStopEmulator();

        scifUartSetBaudRate(0);

        printf("wait 5s\n");
        scifWaitOnNbl(5000000);
    }

} // taskFxn