Author Topic: RS-232 on ice40 UP5k  (Read 1263 times)

0 Members and 1 Guest are viewing this topic.

Offline fmahnkeTopic starter

  • Newbie
  • Posts: 4
  • Country: us
RS-232 on ice40 UP5k
« on: July 23, 2021, 07:11:10 pm »
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.
 

Online iMo

  • Super Contributor
  • ***
  • Posts: 4780
  • Country: pm
  • It's important to try new things..
Re: RS-232 on ice40 UP5k
« Reply #1 on: July 25, 2021, 10:12:22 am »
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/O
3. 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..
« Last Edit: July 25, 2021, 10:15:02 am by imo »
 

Offline fmahnkeTopic starter

  • Newbie
  • Posts: 4
  • Country: us
Re: RS-232 on ice40 UP5k
« Reply #2 on: July 26, 2021, 01:52:28 pm »
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.
 

Online SiliconWizard

  • Super Contributor
  • ***
  • Posts: 14465
  • Country: fr
Re: RS-232 on ice40 UP5k
« Reply #3 on: July 26, 2021, 04:37:12 pm »
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.

What exactly is the FTDI part on this board?
 

Online iMo

  • Super Contributor
  • ***
  • Posts: 4780
  • Country: pm
  • It's important to try new things..
Re: RS-232 on ice40 UP5k
« Reply #4 on: July 26, 2021, 05:47:10 pm »
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..
 

Offline fmahnkeTopic starter

  • Newbie
  • Posts: 4
  • Country: us
Re: RS-232 on ice40 UP5k
« Reply #5 on: July 27, 2021, 04:24:00 pm »
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/101248245735553038

I'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

 

Offline fmahnkeTopic starter

  • Newbie
  • Posts: 4
  • Country: us
Re: RS-232 on ice40 UP5k
« Reply #6 on: July 27, 2021, 04:25:32 pm »
What exactly is the FTDI part on this board?

This is FT2232H.
 

Online iMo

  • Super Contributor
  • ***
  • Posts: 4780
  • Country: pm
  • It's important to try new things..
Re: RS-232 on ice40 UP5k
« Reply #7 on: July 28, 2021, 05:57:49 pm »
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)..
« Last Edit: July 28, 2021, 06:08:03 pm by imo »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf