Search This Blog

Monday, July 30, 2018

STM8 breakout board with USB Serial

 Projects / Misc 8-bit uC projects  Original post date: 03/03/2017

I put together a quick and dirty breakout board for the STM8F003 with PL2303 USB serial chip. Normally not a big fan of doing serial I/O, but V-USB for the STM8 not working. My big tube of fake PL2302 isn't going anywhere.

It might be useful for playing with external SPI or I2C chips. The nice thing about the STM8 is that the memory space is unified, so I could download small firmware to RAM and run native code there for time sensitive I/O.

As usual, I like to procrastinate a bit before sending it out. With snail mail delivery, the extra weekend won't make a difference.

Did some changes.

General clean up, RefDes, and Values etc
added I2C EEPOM for USB Serial # which would help the PC use the same COM port - not sure if it works for the fake chip.
added pull up for PB4, PB5 (I2C true open drain) with solder blob selected to 3.3 (default) or 5V.



PCB working now.

Order from OSH Park

Github: https://github.com/FPGA-Computer/STM8F003-Development-board



The EEPROM for the PL2303 clone also works. I programmed in a serial number for it using their EEPROm Writer util.

Top: EEPROM not programmed. Bottom: EEPROM programmed with serial number.

Windows associates the COM port assignment with the serial number and would recognize the card even if I plug it into a different USB port. Too bad the tool doesn't allow for text string as serial number.

I made a 3-pin version of my press fit programming header.  There are 4 pins on it just because I want to reuse my SWD cable for ARM chips.


It is working. It is a consolidation of what I have.


The STM8S UART1 has an upper limit of 1Mbps. I tried to find out where such a limitation exists besides the obvious 16X oversampling/synchronization and what was said in the feature list.


The smallest divider that is allowed is 0x0010 which will result in BRR1 = 0x01. 16MHz/16 = 1Mbps.

I played around with the PL2303 clone and it can send data at 1/2/4 Mbps. Tera Term is more than happy to accept typed in rates.

Xmodem was a popular serial protocol back in the days of BBS. It is a very attractive protocol for embedded system when you need to move/stream a lot of binary data. It is a built-in file transfer protocol for terminal programs, so no need to roll your own which is the whole point of text interface. (If I have to roll my own, I would be using a GUI with USB Custom Vendor class packets and not serial.)

Some of its inefficiency actually helps make life easier:

  • It transfer a small block of data: 128 byte. This reduces the amount of buffer memory. This also easily fits in the buffer inside the PL2303 (256 byte Rx buffer), so no handshaking is required.
  • It transfer a single packet at a time until an ACK/NACK is sent from the receiver and this gives lot of time for the embedded system for processing.
  • Simple checksum. Communication error is not an issue on this PCB as the traces are very short ~0.28" (7mm). The USB packets has 16-bit CRC to give additional protection.

At 16MHz and 1Mbps, there are 160 cycles between incoming data. There are plenty of cycles left over even after interrupt driven serial code.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.