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.

CC1312R: 延时函数等问题

Part Number: CC1312R


Dear TI:

int32_t uart_write(uint8_t* data, int32_t len)
{
    int32_t ret = 0;

    if((NULL == data) || (len < 0))
    {
        ret = -1;
    }
    else
    {
        //485使能引脚设置为写
        GPIO_write(CONFIG_GPIO_DE_EN, CONFIG_GPIO_LED_ON);
        UART_write(uart, data, len);
        CPUdelay(360000);//1.5ms
        //485使能引脚设置为读
        GPIO_write(CONFIG_GPIO_DE_EN, CONFIG_GPIO_LED_OFF);
        ret = 0;
    }
    return ret;
}

我在使用串口,通过485模块进行信息输出的时候,当我的数据处理完上面代码的UART_write时直接将DE_EN引脚拉低,此时在上位机那边无法输出打印信息。但是我在

GPIO_write(CONFIG_GPIO_DE_EN, CONFIG_GPIO_LED_OFF);前打上断点的时候,就可以输出信息,所以我考虑是不是时间不够他输出的。

方案一:我使用了usleep和sleep函数做延时,发现1秒2秒都不会输出信息。

方案二:使用CPUdelay函数做延时,发现180000时数据输出不完全,后增大一倍,到CPUdelay(360000);可以输出我的数据,但是当我增加输出的字节数时,又不能输出全部。我想知道,一个UART_write函数,输出信息需要那么长时间吗?

我在CPUdelay函数的说明处看到如下:

//! The delay depends on where code resides and the path for code fetching:
//! - Code in flash, cache enabled, prefetch enabled : 4 cycles per loop (Default)
//! - Code in flash, cache enabled, prefetch disabled : 5 cycles per loop
//! - Code in flash, cache disabled : 7 cycles per loop
//! - Code in SRAM : 6 cycles per loop
//! - Code in GPRAM : 3 cycles per loop
//!
//! \note If using an RTOS, consider using RTOS provided delay functions because these will not block task scheduling and will potentially save power.

加粗部分说的RTOS的延时函数指的是什么函数?以上怎么看我的代码是处于以上情形的哪一种?