UartSpeed for VS1005 / VSOS

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
Henrik
VLSI Staff
Posts: 1238
Joined: Tue 2010-06-22 14:10

UartSpeed for VS1005 / VSOS

Post by Henrik »

Hello!

Attached to this message is UartSpeed v1.00, a program that automatically sets the UART speed. This is particularly useful for startup scripts where the chrystal speed may not be known beforehand, or where it is something non-standard.

Note that this is not a port of the similarly named program that Hannu released yesterday on the VS1010 forum. The function, intent, and inner workings of these programs are slightly different.

In the future, this will be part of the VSOS Root Images and Libraries with Source Code and Documentation package.

Instructions from the README.TXT file are below:

Code: Select all

              UartSpeed 1.00
              --------------
          for VSOS 3.62 or higher
         2021-05-26  VLSI Solution




UartSpeed is a VSOS Shell program that automatically adjusts the UART
speed accurding to 7-bit characters that the user sends to it through
UART. Running it in config.txt is very useful if the system clock can
not be determined beforehand or if it is up to change.

 UartSpeed requests for the user to push 'U'. However, any 7-bit
 character will do, as the bit pattern of the character will
 then obey the rule of:

             S01234567T
'U' = ...11110101010101111...  // Recommended character 'U'
      ...11110xxxxxxx01111...  // Any 7-bit character, x = don't care

S = Start bit
T = sTop bit

Note, however, that UartSpeed will still always echo back a 'U'.
If verbose mode is selected, a longer message will be displayed.

UartSpeed is interested in:
1) the hi-low transition of Empty Bus vs Start Bit
2) the last lo-high transition within 10 ms of the transition in (1),
   which should be the transition between Bit 7 and the Stop Bit.

There are several cases where bit speed calculation may fail:
1) If there is a character transmission already going on when the
   program starts.
2) If two characters are sent within 10 ms.
3) If the character has bit 7 set, i.e. it is not within the 7-bit
   ASCII character set.
4) If the baud rate is above 115200 bps.
5) If the baud rate is between 300-1200 bps and a character is
   transmitted that doesn't have enough transitions. For example,
   300 bps and 'U' may work while 'u', 'z', '}', and '~' don't.


Note that the value set with UartSpeed is an estimation based on
the length of one character. It may not be accurate enough for
completely error free transmission. After this, it is recommended
you confirm your current parameters using SetClock. In this example,
XTALI is 12.000 MHz instead of the default 12.288 MHz, and we set the
internal clock to 72 MHz.

S:>SetClock -x12.000 72




Running UARTSPEED.DL3 in config.txt, in verbose mode:
RUN UARTSPEED -v




Running UartSpeed from the VSOS Shell, in verbose mode:
S:>uartspeed -v

For more options:
S:>uartspeed -h
Example run (text in brackets are instructions to the user, not part of the screen dump):

Code: Select all

S:>uartspeed -v
Change UART speed to 1200-115200, then push 'U' until you get proper echo.
Wait at least 10 ms between each 'U'. Then type "end"
[Push 'U']
U: Nominal speed 115682 bps, clocksPerBit 106 -> register 0x006a
[Change speed to 9600 bps on your terminal emulation program, then push 'U']
U: Nominal speed 9566 bps, clocksPerBit 1284 -> register 0x05d6
[Change speed to 1200 bps on your terminal emulation program, then push 'U']
U: Nominal speed 1201 bps, clocksPerBit 10226 -> register 0x2fd5
[Change speed to 115200 bps on your terminal emulation program, then push 'U']
U: Nominal speed 115440 bps, clocksPerBit 106 -> register 0x006a
[Type "end"]
U: Nominal speed 115924 bps, clocksPerBit 106 -> register 0x006a
U: Nominal speed 113544 bps, clocksPerBit 108 -> register 0x006c
S:>
Kind regards,
- Henrik
Attachments
UartSpeed_v100.zip
(9.56 KiB) Downloaded 39 times
Good signatures never die. They just fade away.
Post Reply