Serial communication only works at low speed

Learn MoreFAQsTutorials

4 posts / 0 new
Last post
jeroenLQD
Offline
Last seen:2 years 9 months ago
加入:2017-11-21 15:24
Serial communication only works at low speed

Hi,

I'm working with the DA14681 Basic dev kit and am happily uploading the examples both via serial and the JTAG. However, everything printed to the serial terminal turned out gibberish, regardless of the baud rate set in the terminal. Only after setting the baud rate to 9600 in /startup/config.c (default 115200), it works well.

Not being able print at the higher baud rate is not necessarily a problem for debugging, but it does strike me as odd. Three other boards and computers have the same issue. The board does spit out its name four times during boot at 57600, so then it does seem to communicate well at higher speed. I assume the UART is configured with the params in config.c after the bootloader has done its thing. Could it be that something did not initialise correctly or that some clock is unstable?

Cheers,
Jeroen

Device:
jeroenLQD
Offline
Last seen:2 years 9 months ago
加入:2017-11-21 15:24
We've been fiddling with it a

We've been fiddling with it a bit more, and found out that the following speeds work:

4800
9600 (4800 x 2)
19200 (4800 x 4)
38400 (4800 x 8)

Baud rates that are not doubles of 4800 don't work. 144000 (4800 x 3), 57600 (4800 x 12) and 115200 (4800 x 24) all spit out gibberish...

MT_dialog
Offline
Last seen:11 hours 37 min ago
圣aff
加入:2015-06-08 11:34
Hi jeroenLQD,

Hi jeroenLQD,

That is because the basic kit is not using an FTDI chip as a UART port but the UART of the jlink debugger, due to that the jlink doesn't set its output UART pin high unless is something transmitted from the PC to the board. Pin state is kept by level shifter low after board reset. Configuring the pin as UART_RX doesn't turn on the pull up resistor, hence RX line stays low and this state is usually detacted as break condition. Anyway the work around would be to invoke the below instruction:

hw_gpio_configure_pin(HW_GPIO_PORT_2, HW_GPIO_PIN_3, HW_GPIO_MODE_OUTPUT, HW_GPIO_FUNC_GPIO, 1);

Use that function just before setting the pin UART function in the periph_init() and you will be able to operate the UART of the basic kit, you can check the snippet below:

静态孔隙periph_init(空白)
{
hw_gpio_configure_pin(HW_GPIO_PORT_2, HW_GPIO_PIN_3, HW_GPIO_MODE_OUTPUT, HW_GPIO_FUNC_GPIO, 1);
hw_gpio_set_pin_function(HW_GPIO_PORT_1, HW_GPIO_PIN_3, HW_GPIO_MODE_OUTPUT,
HW_GPIO_FUNC_UART2_TX);
hw_gpio_set_pin_function(HW_GPIO_PORT_2, HW_GPIO_PIN_3, HW_GPIO_MODE_OUTPUT,
HW_GPIO_FUNC_UART2_RX);
}

Additionally you can also use an FTDI cable and connect the UART pins to the cable instead of the jlink's UART.

Thanks MT_dialog

jeroenLQD
Offline
Last seen:2 years 9 months ago
加入:2017-11-21 15:24
Hi MT_dialog,

Hi MT_dialog,

Thanks for the explanation! We tested it and the port now works at all baud rates. Still peculiar that it worked well with baud rates of 4k8 * 2^x before, but I'm just happy it works now.

Cheers,
Jeroen