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

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.

Related

How to send data from STM32 USB port to Raspberry PI USB port?

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.

I2C communication between LTC6804-1 and STM32 Nuclue F446RE

I am trying to build a small battery monitoring system using LTC 6804-1 IC which will send the cell voltages over I2C to my STM32 Nucleo board. I have read and understood I2C and how to use the HAL APIs for communication. However, I am not able to understand anything about the communication from the datasheet of LTC 6804-1. https://www.analog.com/media/en/technical-documentation/data-sheets/680412fc.pdf I was looking for the slave address it sends data to and also the length of data. But I can see configuring some data registers which is bit of confusing. At point I do not know where to even start? Or is it actually easy that I have to connect wires and it starts?
Any help would be highly appreciated. Thanks!
The LTC6804 is not using I2C for communication, it's using SPI. It can host I2C communication to a slave device. Reread the data sheet thoroughly. Although I must agree, the manual is not really written very well, or at least there could be a lot more info, not only on how to get started...

Regarding Raspberry Pi Zero W - USB Access from GPIO Header

I am using Raspberry Pi Zero W for my project. I want to use GPIO Pins as USB instead of the on-bard MicroUSB connector. Is it possible?
Thanks in advance.
Sorry, the GPIO connector does not include any USB signals.
There are some USB hubs that connect to the test pads on the back side of the zero, e.g this one sold by Adafruit: https://www.adafruit.com/product/3298
If you are happy with just one USB port but don't like the micro connector, you could probably solder your own connector with a short pigtail lead to the same test points.
You can't use the micro usb connector at the same time as a hub or usb connector attached to the test pads as they are the same signals as in the micro connector.
The test pads p22 and p23 can be seen in this schematic:
https://github.com/raspberrypi/documentation/blob/master/hardware/raspberrypi/schematics/Raspberry-Pi-Zero-V1.3-Schematics.pdf

Coding Raspberry Pi with an ADC - SPI

I am trying to connect an analogue to digital converter to the raspberry pi. As far as I am able to understand, the RPi doesn't support Bi-directional SPI mode. The adc I am using says it is SPI compatible but only has the inputs SCLK, CNV and outputs CLKOUT+ and CLKOUT- and SD0+ and SD0-. This leads me to understand that it will only work with bi-directional SPI as there is only the serial data out. I am thinking of using a PWM for CNV (which I think CE), GPIO clock for SCLK and then an interrupt on the falling edge of the GPIO clock to just digitally read each bit from the adc. I don't understand SPI in detail but from what I've read quite often it requires sending data in order to receive it. Do you know if the setup I mentioned (without using SPI) will work? Or am I missing something about SPI and the adc will work with that while not in bi-directional mode?
We are using the Raspberry Pi 3 b
adc - http://cds.linear.com/docs/en/datasheet/232316fa.pdf
Thanks for any help you can provide.
Read the data sheet carefully, in particular pages 8 and 9. I suggest that you tie CMOS/LVDS pin to ground to enable CMOS mode. Then use only the "+"-pins. Use the SCK for SPI clock, SD01+ for SPI data input to the Rpi. Connect a GPIO pin to CNV.
Also observe that the RPi runs at 3.3V, and the ADC's max rating is also 3v3, that is running the IC right to the edge.

CAN bus and SPI communication in Raspberry Pi

I am developing a prototype for adaptive cruise control using two raspberry pi's. I have tested SPI on pi and it works (checked it through loopback). Now i want to write this data to the cotroller. So, after referring to resources i found Socketcan should be used in order to interface can controller with the pi. So i request some one to explain how the communication happens like
1. After writing to spi how the can controller can take that data?
2. If socketcan be used to take data from spi , i need to know how?
Thanks