How to send data from STM32 USB port to Raspberry PI USB port? - raspberry-pi

I want to send data through USB between STM32 and Raspberry Pi. I don't want to use USB to Serial convertor, but instead have a actual USB Connection (maybe CDC class). I have to send data at high rate (Full speed). Please guide on how to achieve this?

A USB-serial connector is simply a microcontroller implementing a USB CDC/ACM virtual COM port and bridging to a UART which you would connect to a microcontroller's UART interface.
In your case you can simply implement the CDC/ACM directly on the STM32 using either of its USB device controller peripherals (USB support varies depending on the specific device https://www.st.com/resource/en/application_note/dm00296349-usb-hardware-and-pcb-guidelines-using-stm32-mcus-stmicroelectronics.pdf).
How you actually implement that will depend on what specific part, and what library or framework ecosystem you are using (e.g. SPL, CubeMX, Mbed). There are reference implementations, examples, drivers and libraries for all of these.
Your milage may vary, but I have measured ST's own USB library and example CDC/ACM virtual COM for STM32F1xx on a 72MHz MCU achieving 700kbits/s. Note that the performance is independent of the baud rate you might set on the host when you open the he VCP. Setting the baud rate simply sends a control packet to the device that can be used to set the baud rate of a UART in bridging applications. In your case such control packets can be ignored. There are similar packets for modem control signals such as DTR, RTS, CTS and RI, which you might choose to us for flow control or other signalling.

Related

Do I need a level converter for Raspberry Pi and STM32 to communicate via GPIO(UART) port?

I want to connect an STM32F407 Discovery board with a Raspberry Pi 4 Model B.
And I want to use UART as communication so I plan to use PD5&6 on STM32 and Pin8&10 on RPi. But after looking up online it says that the voltage of a STM32 port is 5V and RPi is 3.3V, so it seems that I need a level converter between them?
And there are also some articles says that not all the STM32 port are 5V, some are 3.3V. But I cannot find any of that information in the datasheet. Can anyone tell me where can I find these information?
Thank you very much ~ ~
The STM32 uses 3.3V as well. But it's 5V tolerant.
Just go ahead and connect them. There is no voltage difference.
You should have a look at the reference manual for that discovery board. It is here: STM32F407 Reference Manual.
There should be no issue connecting UARTs between those boards. Just remember to connect the TX from one to the RX of the other and vice versa. You can also use the CTS/RTS for flow control, but that isn't necessary as long as you are using baud rates of 115200 or slower.
Something else that I would recommended is to power the Raspberry Pi from the Discovery board. There should be pins for suitable power on the discovery. This is important because it gets both boards using the same power and ground so that the UART logic levels are consistent between the two. This may not be necessary, but I have had issues trying to connect two Nucleo boards SPI busses together if I didn't power one board from the other.

Communication Between ESP8266-01 and NUCLEO-F030R8

I've been tasked with figuring out how to get a mobile app to communicate with an MCU then in turn control a stepper motor. Right now I'm trying to get the WiFi module (ESP8266-01) and MCU (NUCLEO-F030R8) to play nice with each other. The catch is I have little to no experience and no education in this field. The closest experience I have is simple Arduino sketches from years ago (IE photo-resistor values driving a stepper motor) and making desktop applications with C#. I am using STM32CubeIDE but if there's a better option I can switch to that.
What I would very much like help on is send and receive simple data between a smartphone and the MCU via the WiFi module. I've read through documentation and other questions but still don't exactly know where to start.
I understand this is probably a large topic in its own right and a short blurb on the internet won't do it (and undoubtedly its multiple subcategories) justice. But I might as well ask.
Sorry if this is too much and thank you in advance.
This project would involve making the following connections.
The UART connection between STM32 and ESP8266.
The WiFi connection between ESP8266 and the mobile.
The application layer protocol between ESP8266 and the application running on the mobile.
For 1, you can actually program the ESP8266 using Arduino IDE and simply connect the UART TX/RX pins of ESP8266 with RX/TX pins of STM32 respectively. You can create a test project in which ESP8266 sends data to STM32 over UART to verify this connection.
For 2, you need to consider the wifi network mode i.e identify whether the wifi connection is going to be ad-hoc (mobile connects to ESP8266 directly) or in infrastructure mode (mobile and ESP8266 connected via a shared access point). You can configure the ESP8266 in both modes. You just have to program the SSID and password of the Wifi network in the ESP8266 (in case of ad-hoc, it is the SSID of the network advertised by ESP8266 and in the infrastructure mode, it is the SSID of the common AP). This wifi functionality is also easily programmable in Arduino IDE for ESP8266.
Finally, once the physical connection has been established between the ESP8266 and mobile device, you need an application-level protocol to connect the application running on the mobile with the ESP8266. You can either use socket connection between ESP8266 and mobile application or use a higher-level communication protocol for IoT devices like MQTT, which is also available in the Arduino IDE.
Final connection diagram could be something like this:
application -> mqtt msgs -> wifi packets -> esp8266 recv pkts -> parse mqtt msgs -> forward data to STM32 over UART

Linux I2C driver porting issue

I am porting an I2C driver to Linux-4. This device provides multiple I2C addresses for different function simultaneously.
For example:
address 0xAA is for access of SPI flash.
address 0xA0 is for access of EEPROM.
address 0x60 is for normal access (control purpose).
Is it possible to support access of different I2C address in single-one I2C device driver?
Any help appreciated,
Thanks
I think it is possible. Using i2c_transfer() you are giving particular address in i2c_msg structure of the device you want to communicate with. So your driver will be able to communicate with all of the functions of your i2c device.
Depends on what type of I2C driver you are talking about, bus(adapter) or chip(client) driver?
i2c-dev.c is a kind of bus driver with character device interface which exports kernel low level I2C API to userspace.
For each registered I2C adapter Kernel will add i2c-N device node in /devuserspace interface.
But you can't read/write EEPROM chip attached to /dev/i2c-N like simple character device or file. You need to write some utility program regarding chip protocol.
But in Linux there is are special EEPROM chip drivers like eeprom.c or at24.c for registering I2C EEPROM devices with addresses of 0x50..0x57(if I'm not wrong) to Kernel and creating files in /sys userspace interface.
You can access them as a file in:/sys/bus/i2c/devices/0-005x/eeprom
Thanks for Dražen Grašovec and user2699113 's help.
I am porting a I2C device driver (chip, client) to Linux-4.9.
This chip accepts different I2C device address for different purpose.
My goal is to create only one I2C device on Linux device tree file (.dts)
I resolved my issue by using i2c_new_dummy().
In driver probe function,
I made two i2c_new_dummy() to create two additional i2c clients.
One(client#1) is for accessing of I2C address 0xAA, another(client#2) is for I2C address 0xA0.
So I can use client#1 to communicate with its SPI flash and use client#2 to access it EEPROM.

rs232 to ethernet converter connection issue with Atmel board

we are doing a project for receiving data from a device using a RS232 to ethernet converter (gridconnect net 232+) onto to a Atmel board. When we connect the converter to the PC, we are getting the output but not when connected to the microcontroller board. We need to know if there has to be some network confirguration to be done on the converter in order to receive it on the microcontroller.
Thanks !
I haven't worked with that board or device, but with any RS-232 communication channel you should check that all RS-232 parameters are set up correctly on both sides. Databits, stopbits, parity settings, etc. Even one setting being off will completely stop RS-232 communications.
Once that is done, I'd hook up a terminal emulator of your choice to simulate the microcontroller side and make sure that you're getting the right traffic from the Ethernet side. You might get lucky at that point and everything might start working. ;)

Why does ModBus require the RTS line?

i cannot figure this out by myself. What is the point of the RTS (direction) line in the RS485 ModBus communication?
There is no description about it on the internet, all the images in google only show the RX & TX lines but i know that RTS is also used.
Thanks
The only use of RTS in the context of RS485 based communications is so-called RS485 Transceiver Control (see for example the related Docklight RS485 setting). In Microsoft Windows API for serial communications, this mode is called RTS_CONTROL_TOGGLE:
Specifies that the RTS line will be high if bytes are available for transmission. After all buffered bytes have been sent, the RTS line will be low.
It has nothing to do with the 2-wire RS485 bus and the MODBUS application protocol used on such a bus. But some older RS232-to-RS485 (or USB-to-RS485) converters require the RTS signal to be set to high before transmitting any data, and reset it to low for receiving data.
Most standard RS485 interfaces and converters for PC can handle this switch between transmit and receive automatically, so they don't need the RTS at all. Just for example - For the popular MOXA brand this is called ADDC (Automatic Data Direction Control).