UART2 Transmit Holding Register is always full

⚠️
Hi there.. thanks for coming to the forums. Exciting news! we’re now in the process of moving to our new forum platform that will offer better functionality and is contained within the main Dialog website. All posts and accounts have been migrated. We’re now accepting traffic on the new forum only - please POST any new threads at//www.wsdof.com/support. We’ll be fixing bugs / optimising the searching and tagging over the coming days.
4 posts / 0 new
Last post
guxiang
Offline
Last seen:3 weeks 4 days ago
加入:2017-05-12 04:18
UART2 Transmit Holding Register is always full

hi , dialog
We use SDK V1.06 pxp_reporter demo. After each end of the BLE advertisement , we used UART2 to printf string . At first , it can print the string normally. But we found it will stuck in " while (hw_uart_write_buf_full(uart)); " later. It seems that there is something wrong with uart after the system waking up from extended sleep mode. Our code is as follow :

静态孔隙periph_init(空白)
{
hw_gpio_set_pin_function(HW_GPIO_PORT_1, HW_GPIO_PIN_0, HW_GPIO_MODE_OUTPUT,
HW_GPIO_FUNC_UART2_TX);
hw_gpio_set_pin_function(HW_GPIO_PORT_1, HW_GPIO_PIN_2, HW_GPIO_MODE_INPUT,
HW_GPIO_FUNC_UART2_RX);
}

void retarget_init(void)
{
uart_config uart_init = {
.baud_rate = HW_UART_BAUDRATE_115200,
.data = HW_UART_DATABITS_8,
.stop = HW_UART_STOPBITS_1,
.parity = HW_UART_PARITY_NONE,
.use_dma = 0,
.use_fifo = 1,
.rx_dma_channel = HW_DMA_CHANNEL_INVALID,
.tx_dma_channel = HW_DMA_CHANNEL_2,
};

hw_uart_init(HW_UART2, &uart_init);
}

{
...
hw_uart_send(HW_UART2 , “\r\n123412341234\r\n”);
...
}

void hw_uart_write(HW_UART_ID uart, uint8_t data)
{
// Wait if Transmit Holding Register is full
while (hw_uart_write_buf_full(uart)); // stuck here

// Write data to the transmit FIFO
UBA(uart)->UART2_RBR_THR_DLL_REG = data;
}

Is something wrong with my code?

Device:
MT_dialog
Offline
Last seen:3 months 4 hours ago
Staff
加入:2015-06-08 11:34
Hi guxiang,

Hi guxiang,

Using directly the low level hw functions (hw_ prefix functions) in order to interact with the peripherals of the 68x is not recommended in general for any peripheral, thats why the adapters are created. For debugging or for general printing since you would like to use the UART2 you can use the CONFIG_RETARGET flag, this will redirect the printf functionallity to the UART2 (or to the UART, depends on the configuration). You can have a look at the ble_multi_link in the custom_config_qspi.h file and check how the CONFIG_RETARGET is configured its one of the examples that use the CONFIG_RETARGET flag. If you dont want to use the the RETARGET flag then you should use the adapters instead of the Low Level drivers.

Thanks MT_dialog

guxiang
Offline
Last seen:3 weeks 4 days ago
加入:2017-05-12 04:18
Hi , dialog

Hi , dialog
We want to use both uart1 and uart2. Now uart1 is configured as retarget port and it work well , and I also found it used low level hw functions but not the adapters . So I configured uart2 acoording to the retarget_init() code . About using the uart adapters , how can I learn to use it?

MT_dialog
Offline
Last seen:3 months 4 hours ago
Staff
加入:2015-06-08 11:34
Hi guxiang,

Hi guxiang,

You can check how to use the adapters in the UM-B-044 User Manual: DA1468x Software Platform Reference, also you will be able to find info regarding the adapters and the available functions in doxygen (in the SDK go to the doc folder and search for the index html), there you will find all the available function on how to work with the adapters and also there are examples in the SDK demo's. If you would like to use both uarts i would suggest to use the adapters for the usage in your application.

Thanks MT_dialog