RS-232 on ice40 UP5k - Page 1
Forum section: electronics / general

author: fmahnke
author_rank: Newbie
timestamp: July 23, 2021, 07:11:10 pm
content: Hi, first time poster and a relative newcomer to FPGAs.I have an ice40 up5k breakout board and would like to do RS-232 over the USB cable. This was easy on my icestick, which dedicates one of the FTDI's interfaces to RS-232 pins. I'm stumped getting it to work on my up5k board. Does anyone have this board that's done this or could lend a hand?Looking at the UP5k board, schematic, I see interface A's TX/RX pins are connected to the SPI pins SCK and SI. So I thought if I'm not using SPI, I can use those pins for my serial communication.I shunted the programming shunts vertically and removed the J7 shunt to disable flash.Then I wrote my verilog code with SCK as the rx pin and SI as the tx pin. I synthesized and programmed the board with yosys/nextpnr, and I verified the board is transmitting data by probing the SI pin.On the computer side, I see no incoming data on the /dev/ttyUSB? device exposed from the FTDI driver. Nor do I see the board receiving data when I send it from the computer. I also tried to connect to the device with a C program using libftdi. I connect to the FTDI device successfully, but again, no data going back and forth.I connected the SCK/SI pins to another DB-9/USB cable with an internal FTDI device, and when I do that, I see data going over the line, so I think the verilog implementation is not the problem.Any ideas? Thank you.

author: iMo
author_rank: Super Contributor
timestamp: July 25, 2021, 10:12:22 am
content: The issue could be:1. wrong baudrate set (doublecheck your verilog and FTDI setting)2. the USB/serial dongle could be working with 5V I/O, your U5k is always 3.3V I/O3. Rx/Tx wires messed up - I always put 470-1k resistors in series with Rx and Tx lines - it helps in case of issue n.2 above..

author: fmahnke
author_rank: Newbie
timestamp: July 26, 2021, 01:52:28 pm
content: Hi, thanks for your suggestions. I think I have already checked all those things pretty thoroughly.I'm not sure if it was very clear from my initial message. Using the pins I mentioned works when I do the test breaking out the pins to a separate DB-9 to USB cable with FTDI chip. The failing test is when I try to use the board's _onboard_ FTDI chip through its onboard USB connector (same cable used to program the device).Using an SPI core with the FTDI in MPSSE mode does work, so that's how I'm proceeding for now. It's a bit more difficult/unnecessary to use SPI for the communication I'm doing, but that's what is working, so I'll make it work for the moment.

author: SiliconWizard
author_rank: Super Contributor
timestamp: July 26, 2021, 04:37:12 pm
content: Quote from: fmahnke on July 26, 2021, 01:52:28 pmWhat exactly is the FTDI part on this board?

author: iMo
author_rank: Super Contributor
timestamp: July 26, 2021, 05:47:10 pm
content: Provided you are using UPduino with the onboard FTDI 232H - they use the 232H's SPI signals (in order to program the on-board flash mem). It will not work as "uart", however. I wrote a post about that years back..

author: fmahnke
author_rank: Newbie
timestamp: July 27, 2021, 04:24:00 pm
content: Do you have a link to that post?I'm not using the UPduino, but the iCE40UP5K-B-EVN breakout board from Lattice. It also uses the FTDI's TX/RX pins to program the onboard flash over SPI, so I don't doubt the circuits are similar.From this post on Mastodon, it looks like someone had this problem with the UPduino and was able to solve it. I haven't figured out how I might do the same with the Lattice board, though.https://mastodon.social/@qrs/101248245735553038I've looked at the schematic in the user manual, and I don't understand why the FTDI won't work in serial mode if the flash is disabled by the J7 jumper and the device programming is already finished.https://www.latticesemi.com/view_document?document_id=51987

author: fmahnke
author_rank: Newbie
timestamp: July 27, 2021, 04:25:32 pm
content: Quote from: SiliconWizard on July 26, 2021, 04:37:12 pmThis is FT2232H.

author: iMo
author_rank: Super Contributor
timestamp: July 28, 2021, 05:57:49 pm
content: Search for Upduino posts here..The mastodon's post emulates "uart" via spi, it seems.You may use any UP5k "spi_xx" pins (used to use for the booting from the bitstream flash) from your userland after the bitstream has been loaded, provided you will wait some XX clocks after "cdone", and the "spi_cs" will be disconnected from the flash chip..PS: I've been using the bitstream flash for storing/loading the C binary into my soc's (risc-v) 128kB spram memory (UPduino)..