bouffalolab / bouffalo_sdk

BouffaloSDK is the IOT and MCU software development kit provided by the Bouffalo Lab Team, supports all the series of Bouffalo chips. Also it is the combination of bl_mcu_sdk and bl_iot_sdk
Apache License 2.0
349 stars 121 forks source link

在使用freertos时使用LOG输出会出现异常,输出的数据可能被丢掉。 #192

Closed Tliang4540 closed 5 months ago

Tliang4540 commented 6 months ago

在获取时间时可能切换到其他任务执行,返回时发现已经超时就退出了。此时FIFO其实已经有空间 在返回 -ERIMEDOUT时加个判断,确定数据确实已满。

while ((getreg32(reg_base + UART_FIFO_CONFIG_1_OFFSET) & UART_TX_FIFO_CNT_MASK) == 0) {
    if ((bflb_mtimer_get_time_ms() - start_time) > 100) {
        if ((getreg32(reg_base + UART_FIFO_CONFIG_1_OFFSET) & UART_TX_FIFO_CNT_MASK) == 0) {
            return -ETIMEDOUT;
        }
    }
}
Tliang4540 commented 6 months ago

加上判断有改善,但是还是有数据异常丢失的情况 我有一个高优先级的任务输出LOG,数据只显示了一部分,后面部分没显示完整。 数据接着的是低优先级的任务输出LOG数据

显示如下,BLE_COMM这里任务优先级16,MAIN里检测按键的任务优先级2 [I][MAIN] key_down! [I][BLE_COMM] md5:afdb8897bf8352ad50369[I][MAIN] key_up!