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: UART_write()函数不能同时输出很多字节

Part Number: CC1312R

Hi,TI:

在使用UART串口的时候,因为使用到485模块,然后自己重新封装了UART_write函数,具体如下:

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(3600000);//300ms
        //485使能引脚设置为读
        GPIO_write(CONFIG_GPIO_DE_EN, CONFIG_GPIO_LED_OFF);
        ret = 0;
    }
    return ret;
}

此处 //485使能引脚设置为写
GPIO_write(CONFIG_GPIO_DE_EN, CONFIG_GPIO_LED_ON);将引脚拉高之后可以将数据往串口写,然后使用了UART_write(uart, data, len);函数,

写完就直接将//485使能引脚设置为读,但是实际测试发现,如果没有加延时在,根本写不出来,加了之后,这个时间太短也写不全所有的字节,

但是上位机要数据的时候很快,会出现程序卡死的现象。

请问:重写UART_write函数有没有问题,然后有么有更好的方式去解决这个问题,让写buffer里的数据都写完再进行到下一步?