2025-01-03 05:34 PM - edited 2025-01-03 05:50 PM
I am using this dev board: NUCLEO-F411RE for developing SPI communication protocol considering it as a SLAVE device. My firmware will receive data over SPI sent by Host machine and acts on it.
I have following requirement:
How to transmit data packets via host PC to MCU using SPI to test whether my firmware working correctly or not ?
Option A: To use Raspberry Pi as a Host machine device and send data over SPI to MCU :
-> This one so far seems best option for me as I can easily write test python application using open source spidev package python-spidev and easily connect Raspberry Pi and NUCLEO board as both supports SPI interface.
Option B : I have also found this USB-SPI-bridge converter to directly connect Host PC (Windows, Linux) to Nucleo-Board based on SPI interface
pdf: FTDI-MULTI-SLAVE
Also found this Adafruit-FT232H for same USB-to-SPI bridge converter
Is thee any other similar dongle available which are cost effective and easy to use ?
Can anyone suggest which one is the best options to achieve this communication setup for testing SPI communication between Host Machine and MCU ?
2025-01-03 06:06 PM
You can always connect a 2nd SPI bus on the same Nucleo board as a master to your slave SPI bus. Use the VCP to receive some data and pass that data over the master SPI. Then you can see if your slave SPI works correctly.
2025-01-03 06:44 PM
Yes, you would need a SPI Master which you can control from PC host (e.g. Windows OS, Linux OS, ....).
Yes, Raspberry would be a good option: with the Python library it should be possible.
Yes, there are also boards (and chips) for SPI, e.g. FTDI, Silicon Labs, even Aardvark (TotalPhase).
It should work (we use TotalPhase very often, sometimes also FTDI).
Just to make sure to configure properly:
Where is your problem?
Sure, you can also configure another SPI as Master on MCU and try a "loopback" test (to make sure your SPI Slave implementation works).
If you ask about how to implement a SPI Master on PC side (Windows or Linux OS) - yes, some solutions there as you have mentioned. FTDI and TotalPhase are good options (and coming with C/Python sample code).
You can also create a second MCU with FW running as "UART over USB" and acting as a SPI Master: connect both SPIs and let receive what you send.
2025-01-03 07:58 PM
Looks like you are trying to simulate spi master. Your selection depends on the maximum clock rate, voltage levels etc. Lowest possible expensive solution would be esp32 using arduino or Raspberri pico board. Both are easy to be set-up and you can make changes and update easily.
2025-01-04 01:59 AM - edited 2025-01-04 03:15 AM
@ercjethava1992 wrote:Is there any other similar dongle available which are cost effective and easy to use ?
I don't think you're going to find anything more cost effective than a simple FTDI chip!
eg, Total Phase have a great range of products, but they are orders of magnitude more expensive:
https://www.totalphase.com/protocols/spi/
As @Karl Yamashita said, you could use another SPI port on the same microcontroller.
You could also use another, separate microcontroller - it needn't be an STM32; eg, an Arduino...
@ercjethava1992 wrote:setup for testing SPI communication between Host Machine and MCU ?
The key thing you'll need is something to enable you to see what's happening on the wires - an oscilloscope and/or a logic analyser.
Without that, you're in the dark!
Low-cost (~$10) logic analysers are widely available on the likes of Amazon, ebay, et al ...
PS:
Don't make the classic mistake of trying to do both ends of the link at once!
Otherwise you're just testing your unproven slave against an unproven master:
I suggest that you start by getting your Host/Master to work with some well-known standard slaves: