STM32F4 Serial Communication

8 次查看(过去 30 天)
Han Joon Yu
Han Joon Yu 2020-9-29
回答: Asim 2024-10-23,19:57
We are using STM32F446 for MCU.
And we want to make a serial communication with stm32f4 and matlab.
Is it exchanged with MATLAB?
If it is, how can i load a data from stm32?
Thank you.

回答(1 个)

Asim
Asim 2024-10-23,19:57
Hello Han,
Yes, you can establish serial communication between the STM32F446 microcontroller and MATLAB by following these steps:
  1. Configure UART with the desired settings (baud rate, data bits, stop bits, parity).
  2. Use firmware (e.g., HAL library) to send data via UART.
  3. Connect STM32 TX to adapter RX, and RX to TX.
  4. Open MATLAB and use the serialport function:
port = 'COMPort'; % Replace with your COM port
baudRate = Baudratevalue; % Baudrate
s = serialport(port, baudRate);
% Optional: Set terminator
configureTerminator(s, "LF");
% Read and display data
data = readline(s);
disp(data);
% Clean up
clear s;
  • Ensure the STM32 is sending data continuously or upon request.
  • Run the MATLAB script to read and display the data from the STM32.
I hope it helps.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by