STM32F4 Serial Communication

조회 수: 18 (최근 30일)
Han Joon Yu
Han Joon Yu 2020년 9월 29일
답변: Asim 2024년 10월 23일
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일
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.

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by