Second UART for debugging VS1005 projects

Discussion about writing software for VS1005 and the VSOS Operating System. Also posts about VS1005-related hardware design and device drivers should be posted here.
Post Reply
User avatar
Panu
VSDSP Expert
Posts: 2828
Joined: Tue 2010-06-22 13:43

Second UART for debugging VS1005 projects

Post by Panu »

Hi all!

Here's a neat hack to make a second UART using timer and gpio interrupts and use it as a debugging console for the VS1005 when you need the hardware UART for communicating with external equipment. Simply load this driver instead of UARTIN driver. It creates another UART to pins D2 (TX) and D3 (RX) and sets stdin and stdout to use those pins. stderr still points to the hardware UART so you can use both (it's really easy to change this in the source code).

The UART works at 115200 speed, and at that speed it's not 100% error free in receiving characters when there are other interrupts running - there's the occasional bit error now and then, but it's more than good enough for giving commands on the shell. You can change it to 38400 bps by modifying TIMER_CYCLES from 52 to 160 in the source code.

Below you can see an image of the VS1005 booting. The left terminal is the hardware UART and the right terminal shows the softare UART and a DIR command being run on the software UART.
vs1005_gpio_software_uart.jpg
vs1005_gpio_software_uart.jpg (159.08 KiB) Viewed 2473 times
There's no buffering in the code for the software uart, but that would be easy to add. As is, the code is OK for debugging-as-needed and for further development.

Have fun!
-Panu
Attachments
uartdual.dl3
Driver for implementing two uarts; the traditional hardware UART and another software UART in pins D2, D3 for debugging. VSOS/VS1005 DL3 driver, load from config.txt instead of UARTIN
(4.57 KiB) Downloaded 148 times
arch-uartdual-2021-03-05-09-59-RC1.zip
Source code, VSIDE Solution
(11.3 KiB) Downloaded 155 times
Post Reply