Stm32 cubemx

Author: a | 2025-04-24

★★★★☆ (4.9 / 2102 reviews)

open my password manager

STM32CubeMX Essential Training : Saving time on firmware development with CubeMX. This course is an essential training on STM32 CubeMX. It is a practical cookbook for programming peripherals of all STM32 microcontrollers using the CubeMX framework. If you work with STM32 microcontrollers then you should absolutely get familiar with cubeMX.

browser memory

ADS1115 with STM32 CubeMx - Thecodeprogram

Giới thiệu về phần mềm STM32CubeMXSTM32CubeMX là một phần mềm miễn phí được cung cấp bởi STMicroelectronics (ST) để hỗ trợ việc lập trình cho các vi điều khiển (MCU) STM32. Phần mềm này cung cấp một giao diện đồ họa trực quan giúp người dùng dễ dàng cấu hình các chức năng của MCU, cũng như tự động tạo mã khởi tạo C cho dự án.Download và Cài đặt STM32 CubeMXCubeMx là 1 tools miễn phí của ST các bạn vào link Sau để download:Các Bạn download file cài đặt STM32 CubeMX tại link: và GetSoftware, đăng kí 1 tài khoản miễn phí bằng gmail và tải vềSau khi tải về chúng ta giải nén và chạy file có đuôi .exe. Nhấn nextTiếp theo, tick chọn “I accept the terms of this license agreement.” và nhấn Next:Tiếp tục nhấn Next và chờ khi cài đặt kết thúcCài đặt STM32 CubeMX PackagePackage là các gói dữ liệu của dòng chip mà chúng ta lập trình trên chúng.Lỗi thường gặp khi chưa cài package cho CubeMX đó là khi mở một project của người khác sử dụng chip bạn chưa cài đặt bao giờ sẽ không mở được hoặc báo download nhưng ko thể down từ server về.Khi download và cài đặt xong Cube, để thực hiện cấu hình trên một con MCU bạn phải cài đặt Package cho nó như sauVào Help -> Managed Embedded ….Trong cửa sổ đó, chọn dòng chip mà bạn lập trình, ví dụ STM32F4xx. Trong đó bạn nên cài version mới nhất (nằm trên cùng), tích xanh và nhấn Install NowSau đó tạo project mới bằng cách nhấn vào Access to MCU Selector Chọn dòng chip cần sử dụng và nhấn Start ProjectSau đó vào project manager Lưu 1 tên bất kì, chọn đường dẫn là Desktop (sẽ xóa sau khi cài đặt xong)Chọn tool chain là MDK- ARM V5 nhấn Generate Code How to configure and ping Ethernet on STM32This tutorial is the start of the Ethernet series in STM32. Today we will simply see how to configure the Hardware.For some of the MCUs, this will be as easy as the default setup, but for others, this part could be very complicated. Specially the Cortex M7 Series MCUs, where the cacheable region causes data coherency issues.So I will try to explain the process in the best possible way. To better understand the result of different settings, I would suggest you to watch the Video at the end of this post.CubeMX ConfigurationAfter enabling the Ethernet, you must cross check the pins configured by the cubeMX with the schematic of the board. Most of the times, the pins are configured incorrectly and it becomes one of the most popular error for the ethernet to not work.Ethernet ConfigurationThere are many types of configurations available with different MCUs. Some MCUs let you configure the memory in the CubeMX, while others don’t. Some of the Boards have the MII Hardware, while other have RMII. Below is the picture showing different configuration available in different ST Boards.The First board (Nucleo F207ZG) and second board (Disco F7508) uses the RMII pinout, while the third board (Disco H745) uses the MII pinout.On the first board we have the option to choose the PHY Address. This should be set to 0, if you are using the on board LAN Port, and it should be 1 in case of the external module.The 2nd and 3rd boards allow us to configure the memory addresses while the first one does not. If your board does not allow the memory configuration, you can simply skip those steps.The H745 discovery board is letting us configure the addresses for Tx and Rx DMA descriptors, and for the Rx Buffer as well. But the F7508 Discovery board does not let us configure the address for the Rx Buffer.Assuming that each DMA Descriptor takes 32 bits (MAXIMUM Possible), the RX Descriptor and Tx Descriptor have a maximum size of 128 Bytes (32×4) each.The Memory between them is spaced keeping this 128 bytes in mind.The Rx Buffer length is set to 1524 Bytes, but the number of RX buffers to be used can be defined later in the LWIP configuration. By default the cubeMX sets the number to 12 buffers. This would make the total length of Rx Buffer around

Using STM32 CubeMX and STM32 Cube IDE to Code

Didn’t connect that wire. If you need to send data to the microcontroller, you’ll have to connect it and configure the UART in your code so it handles data reception.STM32 Serial Data Print (For Debugging) ProjectStep #1Open CubeMX & Create New ProjectStep #2Choose The Target MCU & Double-Click Its NameStep #3Enable USART1 Module (Asynchronous Mode)Step #4Choose The Desired Settings For UART (Baud Rate, Stop Bits, Parity, etc..)Step #5Goto The RCC Options Tab & Enable External CrystalStep #6Go To The Clock Configuration & Set The System Clock To 72MHzStep #7Generate The Initialization Code & Open The Project In CubeIDEStep #8Write The Code For Your Project & Use HAL_UART_Transmit() To Print1234567891011121314151617181920212223242526#include "main.h"UART_HandleTypeDef huart1;void SystemClock_Config(void);static void MX_GPIO_Init(void);static void MX_USART1_UART_Init(void);int main(void){ uint8_t MSG[35] = {'\0'}; uint8_t X = 0; HAL_Init(); SystemClock_Config(); MX_GPIO_Init(); MX_USART1_UART_Init(); while (1) { sprintf(MSG, "Hello Dudes! Tracing X = %d\r\n", X); HAL_UART_Transmit(&huart1, MSG, sizeof(MSG), 100); HAL_Delay(500); X++; }}Step #9Build & Debug To Flash The CodeStep #10Go To The Device Manager & Check The USB-TTL COM Port Num.Step #11Open The Terminal From STM32CubeIDE MonitorWindow > Show View > ConsoleIn Console:click on the NEW icon on its menu bar > Command Shell console > Connection type: Serial port > set Baud Rate & Connection Name > Encoding: UTF-8 > And Click OK! Alternatively, You Can Use Any Terminal On Your PC (Like Tera Term, Arduino Serial Monitor, etc..)Required Parts For STM32 ExamplesAll the example Code/LABs/Projects in this STM32 Series of Tutorials are done using the Dev boards & Electronic Parts Below:QTY.Component NameAmazon.comAliExpresseBay1STM32-F103 BluePill. STM32CubeMX Essential Training : Saving time on firmware development with CubeMX. This course is an essential training on STM32 CubeMX. It is a practical cookbook for programming peripherals of all STM32 microcontrollers using the CubeMX framework. If you work with STM32 microcontrollers then you should absolutely get familiar with cubeMX. This course is an essential training on STM32 CubeMX. It is a practical cookbook for programming peripherals of all STM32 microcontrollers using the CubeMX framework. If you work with STM32 microcontrollers then you should absolutely get familiar with cubeMX. It is a massive time saver. Please see the course curriculum for more information.

Why is STM32 CubeMX not running? - STMicroelectronics

This is the 4th Tutorial in the Modbus Series, and today we will start the STM32 as a slave Device. This tutorial will cover how the STM32 as a slave device will send a response to the queries regarding reading holding registers and input registers.We will cover the function codes FC03 and FC04 in this tutorial, but from the slave prospective.I have already mentioned in the previous modbus tutorials that RS485 is not a requirement by the modbus, rather the mosbus protocol can be used with any communication standard.Today I am going to use the UART with the modbus protocol. I am using the STM32F446 nucleo board and it’s easier to communicate with the computer using the UART.CubeMX SetupBelow is the image of the cubeMX setupHere I am using the UART2 with the Baudrate of 115200. The configuration is 8-N-1. I have also enabled the interrupt. The pins PA2 and PA3 are configured as the TX and RX pins respectively.The Master SotwareI am using the simply modbus master software, which can be downloaded from software is shown belowHere in the RED BOX we have the serial configuration. It is same as what we configured in the cubeMX.The 115200-8-N-1 configurationThe GREEN BOX contains the slave ID, The start Register, the number of Registers master wants to Read, the function code and the Register size.The BLACK BOX contains the query to be sent by the master. It is based on the setup we did in the Green box.The BLUE box contains the response received by the master. It will update once the slave send some response.The YELLOW BOX contains the resisters master has requested the values for. These will update once the slave send the data.Some insight into the CODEDefines// in the main.c uint8_t RxData[256];uint8_t TxData[256];// in the modbusslave.cextern uint8_t RxData[256];extern uint8_t TxData[256];extern UART_HandleTypeDef huart2;// in the modbusslave.h#define SLAVE_ID 7#define ILLEGAL_FUNCTION 0x01#define ILLEGAL_DATA_ADDRESS 0x02#define ILLEGAL_DATA_VALUE 0x03static uint16_t Holding_Registers_Database[50]={ 0000, 1111, 2222, 3333, 4444, 5555, 6666, 7777, 8888, 9999, // 0-9 40001-40010 12345, 15432, 15535, 10234, 19876, 13579, 10293, 19827, 13456, 14567, // 10-19 40011-40020 21345, 22345, 24567, 25678, 26789, 24680, 20394, 29384, 26937, 27654, // 20-29 40021-40030 31245, 31456, 34567, 35678, 36789, 37890, 30948, 34958, 35867, 36092, // 30-39 40031-40040 45678, 46789, 47890, 41235, 42356, 43567, 40596, 49586, 48765, 41029, // 40-49 40041-40050};I have defined the RxData and TxData buffers in the main file. The same buffers are defined in the modbusslave.c file but as extern variables. The modbusslave.h file contains the slave ID, along with some exception codes. We will see the exception codes in a while.I have also defines the database for the holding registers, which the master will request the data from.SendData functionvoid sendData (uint8_t *data, int size){ // 18KB.The memories are allocated in the SRAM region, whose properties can be modified later in the MPU.LWIP ConfigurationThe LightWeight IP can be enabled in the middleware section. If the MCU does not let you enable it, make sure the cache (DCache and ICache) are enabled.The most of the Configuration in the LWIP remains same. Except, some MCUs let us choose the address for the Heap.Here we are going to disable the DHCP, and configure a static IP for our ethernet module. I have set the IP 192.168.0.123 for the board.In the Key Option tab, I am using 5KB memory for the Heap. The location for this heap is defined as 0x30004000.In the Platform Settings tab, set the PHY as LAN8742.MPU ConfigurationWe have the DMA Descriptors in the SRAM Region. This is why we need to configure the MPU.If your MCU didn’t let you choose the memory region, then probably you don’t need to do it. But for the cortex M7 devices, this is a must, or else you will get hardfault.Remember that during the configuration, we set up everything in the SRAM (0x30000000). The complete memory structure is shown in the image below.Below is the image showing the MPU configuration for the above Region.Here I have selected the 32 KB region so that it will cover our total RAM region, which is around 24KB.The rest of the configuration is to set the region as non-cacheable region.This would prevent the cache coherency issue between the CPU and the DMA.This is explained in the cortex M7 playlist, so do check that out.Other ConfigurationIf you are connecting the STM32 board to the Router, there is nothing you need to do at the computer end. But if you are connecting the ethernet cable directly to the computer, you need to configure your computer’s ethernet as per the images shown below.Below is the configuration for a Windows computer.Below is the configuration for Mac.The CODEOnce the project is generated, open the LWIP -> Target -> ethernetif.c file. Here you will some memory locations that needs to be defined in the flash script file.We need to define these memory locations in the flash script file, as per the configuration done in the cubeMX.Below is the code is for the H745 Discovery board according to the configuration done in the cubeMX. .lwip_sec (NOLOAD) : { . = ABSOLUTE(0x30000000); *(.RxDecripSection) . = ABSOLUTE(0x30000080); *(.TxDecripSection) . = ABSOLUTE(0x30000100); *(.Rx_PoolSection) }

Integrate STM32 CubeMX into Atollic TrueSTUDIO

STM32CubeIDE/CLT 1.12.1 was released on st.com as well as an in-tool update patch. Aligned with STM32CubeMX v6.8.1 that is available for download .Caution: The in-tool update does not allow updating drivers and ST-LINK server tool. Full installer is required for this.Main issues fixed in this patch:This patch release fixes the issues related to the following cases:STM32CubeIDEIncorrect permission of lib jspawnhelper in jre packaged in STM3CubeIDE.STM32CubeIDE does not launch with Linux FedoraSTM32CubeCLT Variable path is removed when CubeCLT is installed.STM32CubeMXCubeMX project Cube IDE complication error on ETHUpdate to CubeMX 6.8 adds non-working VOSRDY flag check to SystemClock_Config() on STM32F7 using LL drivers.[X-CUBE-FREERTOS][v1.0.1] Can't select previous version with secure context[STM32CubeMX][MDMA] MDMA GUI crash causing issue with toolWhere do I obtain CubeIDE ,CLT 1.12.1 and CubeMX 6.8.1 ?For IDE 1.12.1 : CLT 1.12.1 : update your current installation of STM32CubeIDE using: Help > Check for updatesupdating STM32CubeIDE, the post-update restart fails. STM32CubeIDE must be restarted manually For MX 6.8.1: STM32CubeMX - STM32Cube initialization code generator - STMicroelectronicsRelated threadsUpdate to CubeMX 6.8 adds non-working VOSRDY flag check to SystemClock_Config() on STM32F7 using LL driversClick on cubeIDE 1.12 MDMA section sometime causes MX tab an undefined behaviour

devcontainer-stm32-cubemx-utility.ioc - GitHub

Main navigation contains tabs, main links and MediaWiki sidebar This message will disappear after all relevant tasks have been resolved.Semantic MediaWikiThere are 1 incomplete or pending task to finish installation of Semantic MediaWiki. An administrator or user with sufficient rights can complete it. This should be done before adding new data to avoid inconsistencies.The Getting started with STM32 step-by-step guide is designed for anyone interested in getting started on building projects with the STM32 microcontroller and its powerful ecosystem of development boards and software programming tools.Whether you are an experienced embedded programmer or an enthusiastic beginner, learn in five tutorials from the basics of the STM32 ecosystem installation to advanced software development with sensors, UART messages, and Bluetooth communication.If you want to extend your knowledge, try advanced steps on various topics such as, motor control and analog.Start now and quickly become a professional STM32 developer!1. STM32 basic2. STM32 step-by-step3. Go further with STM323.1. AnalogGetting started with analogIn this tutorial, learn how to capture, filter, and record sound with a STM32F769I-DISCO board. Go further and apply the cross correlation algorithm in order to estimate the direction of the sound.3.2. Motor Control3.3. USB-Power Delivery3.4. Security3.5. External memory tools3.6. Connectivity3.6.1. Bluetooth® Low Energy3.7. Power and low power. STM32CubeMX Essential Training : Saving time on firmware development with CubeMX. This course is an essential training on STM32 CubeMX. It is a practical cookbook for programming peripherals of all STM32 microcontrollers using the CubeMX framework. If you work with STM32 microcontrollers then you should absolutely get familiar with cubeMX.

Using STM32 CubeMX and STM32 Cube IDE to Code Drivers

Edit source]Prerequisites: STM32CubeProgrammer installation completed and STM32 board connected to the host PC.First, activate the USB driver on Ubuntu on VMware Workstation Player (use VM Player menu "removable devices" to connect to STMicroelectronics DFU in HS mode), then execute the following command and check the result: STM32_Programmer_CLI -l usbIf the DFU is functional, the result is similar to the following ------------------------------------------------------------------- STM32CubeProgrammer -------------------------------------------------------------------Total number of available STM32 device in DFU mode: 1 Device Index : USB1 USB Bus Number : 002 USB Address Number : 008 Product ID : USB download gadget@Device ID /0x500, @Revision ID /0x0000 Serial number : 0000000000 Firmware version : 0x0110 Device ID : 0x0500Otherwise, the DFU is not functional and the result is the following: ------------------------------------------------------------------ STM32CubeProgrammer ------------------------------------------------------------------ Warning: No STM32 device in DFU mode connected5.3. How to proceed when the DFU driver installation fails on Windows host PC[edit | edit source]Prerequisites: STM32CubeProgrammer installation completed.The STM32 Bootloader.bat allows to install the DFU driver on a Windows PC (see Preparing the USB serial link for flashing).In case of failure, here is a typical error log:c:\demo\MPU\stm32_programmer_package_v1.0.3_MPU\Drivers\DFU_Driver>"STM32 Bootloader.bat"c:\demo\MPU\stm32_programmer_package_v1.0.3_MPU\Drivers\DFU_Driver>echo off Microsoft PnP UtilityProcessing inf : DFU_in_HS_Mode.infFailed to install the driver on any of the devices on the system : No more data is available.Total attempted: 1Number successfully imported: 0This error occurs either because the STM32CubeProgrammer DFU driver is already installed or because the DFUSE driver is installed.To verify if the STM32CubeProgrammer DFU driver is correctly installed on your Windows host PC, proceed as follow:Connect the board to the Windows host PC.Launch the Device Manager utility and execute the below action depending on your use case:The STM32CubeProgrammer DFU driver is not installed:Execute the STM32 Bootloader.bat script to install it (see Preparing the USB serial link for flashing).Figure 1: STM32CubeProgrammer’s DFU driver is not installedThe DfuSe driver is installed and you must uninstall it.Right click STM Device in DFU Mode and select Uninstall.Figure 1: STM32 DFU Device with DfuSe DriverThe STM32CubeProgrammer DFU driver is installed and ready to be used.Figure 2: STM32 DFU Device with STM32_Programmer Driver5.4. How to find the DEVICE_PORT_LOCATION parameter value for the USB link[edit | edit source]Prerequisites: STM32CubeProgrammer installation completed and STM32 board connected to the host PC.To find the value of the DEVICE_PORT_LOCATION corresponding to the USB link, use the following command:STM32_Programmer_CLI -l usb ------------------------------------------------------------------- STM32CubeProgrammer -------------------------------------------------------------------Total number of available STM32 device in DFU mode: 1 Device Index : USB1 USB Bus Number : 002 USB Address Number : 008 Product ID : USB download gadget@Device ID /0x500, @Revision ID /0x0000 Serial number : 0000000000 Firmware version : 0x0110 Device ID : 0x0500You can then report the value returned by the command line as explained in the How to flash with STM32CubeProgrammer chapter.Pay attention that the

Comments

User9124

Giới thiệu về phần mềm STM32CubeMXSTM32CubeMX là một phần mềm miễn phí được cung cấp bởi STMicroelectronics (ST) để hỗ trợ việc lập trình cho các vi điều khiển (MCU) STM32. Phần mềm này cung cấp một giao diện đồ họa trực quan giúp người dùng dễ dàng cấu hình các chức năng của MCU, cũng như tự động tạo mã khởi tạo C cho dự án.Download và Cài đặt STM32 CubeMXCubeMx là 1 tools miễn phí của ST các bạn vào link Sau để download:Các Bạn download file cài đặt STM32 CubeMX tại link: và GetSoftware, đăng kí 1 tài khoản miễn phí bằng gmail và tải vềSau khi tải về chúng ta giải nén và chạy file có đuôi .exe. Nhấn nextTiếp theo, tick chọn “I accept the terms of this license agreement.” và nhấn Next:Tiếp tục nhấn Next và chờ khi cài đặt kết thúcCài đặt STM32 CubeMX PackagePackage là các gói dữ liệu của dòng chip mà chúng ta lập trình trên chúng.Lỗi thường gặp khi chưa cài package cho CubeMX đó là khi mở một project của người khác sử dụng chip bạn chưa cài đặt bao giờ sẽ không mở được hoặc báo download nhưng ko thể down từ server về.Khi download và cài đặt xong Cube, để thực hiện cấu hình trên một con MCU bạn phải cài đặt Package cho nó như sauVào Help -> Managed Embedded ….Trong cửa sổ đó, chọn dòng chip mà bạn lập trình, ví dụ STM32F4xx. Trong đó bạn nên cài version mới nhất (nằm trên cùng), tích xanh và nhấn Install NowSau đó tạo project mới bằng cách nhấn vào Access to MCU Selector Chọn dòng chip cần sử dụng và nhấn Start ProjectSau đó vào project manager Lưu 1 tên bất kì, chọn đường dẫn là Desktop (sẽ xóa sau khi cài đặt xong)Chọn tool chain là MDK- ARM V5 nhấn Generate Code

2025-04-17
User4990

How to configure and ping Ethernet on STM32This tutorial is the start of the Ethernet series in STM32. Today we will simply see how to configure the Hardware.For some of the MCUs, this will be as easy as the default setup, but for others, this part could be very complicated. Specially the Cortex M7 Series MCUs, where the cacheable region causes data coherency issues.So I will try to explain the process in the best possible way. To better understand the result of different settings, I would suggest you to watch the Video at the end of this post.CubeMX ConfigurationAfter enabling the Ethernet, you must cross check the pins configured by the cubeMX with the schematic of the board. Most of the times, the pins are configured incorrectly and it becomes one of the most popular error for the ethernet to not work.Ethernet ConfigurationThere are many types of configurations available with different MCUs. Some MCUs let you configure the memory in the CubeMX, while others don’t. Some of the Boards have the MII Hardware, while other have RMII. Below is the picture showing different configuration available in different ST Boards.The First board (Nucleo F207ZG) and second board (Disco F7508) uses the RMII pinout, while the third board (Disco H745) uses the MII pinout.On the first board we have the option to choose the PHY Address. This should be set to 0, if you are using the on board LAN Port, and it should be 1 in case of the external module.The 2nd and 3rd boards allow us to configure the memory addresses while the first one does not. If your board does not allow the memory configuration, you can simply skip those steps.The H745 discovery board is letting us configure the addresses for Tx and Rx DMA descriptors, and for the Rx Buffer as well. But the F7508 Discovery board does not let us configure the address for the Rx Buffer.Assuming that each DMA Descriptor takes 32 bits (MAXIMUM Possible), the RX Descriptor and Tx Descriptor have a maximum size of 128 Bytes (32×4) each.The Memory between them is spaced keeping this 128 bytes in mind.The Rx Buffer length is set to 1524 Bytes, but the number of RX buffers to be used can be defined later in the LWIP configuration. By default the cubeMX sets the number to 12 buffers. This would make the total length of Rx Buffer around

2025-04-23
User5557

Didn’t connect that wire. If you need to send data to the microcontroller, you’ll have to connect it and configure the UART in your code so it handles data reception.STM32 Serial Data Print (For Debugging) ProjectStep #1Open CubeMX & Create New ProjectStep #2Choose The Target MCU & Double-Click Its NameStep #3Enable USART1 Module (Asynchronous Mode)Step #4Choose The Desired Settings For UART (Baud Rate, Stop Bits, Parity, etc..)Step #5Goto The RCC Options Tab & Enable External CrystalStep #6Go To The Clock Configuration & Set The System Clock To 72MHzStep #7Generate The Initialization Code & Open The Project In CubeIDEStep #8Write The Code For Your Project & Use HAL_UART_Transmit() To Print1234567891011121314151617181920212223242526#include "main.h"UART_HandleTypeDef huart1;void SystemClock_Config(void);static void MX_GPIO_Init(void);static void MX_USART1_UART_Init(void);int main(void){ uint8_t MSG[35] = {'\0'}; uint8_t X = 0; HAL_Init(); SystemClock_Config(); MX_GPIO_Init(); MX_USART1_UART_Init(); while (1) { sprintf(MSG, "Hello Dudes! Tracing X = %d\r\n", X); HAL_UART_Transmit(&huart1, MSG, sizeof(MSG), 100); HAL_Delay(500); X++; }}Step #9Build & Debug To Flash The CodeStep #10Go To The Device Manager & Check The USB-TTL COM Port Num.Step #11Open The Terminal From STM32CubeIDE MonitorWindow > Show View > ConsoleIn Console:click on the NEW icon on its menu bar > Command Shell console > Connection type: Serial port > set Baud Rate & Connection Name > Encoding: UTF-8 > And Click OK! Alternatively, You Can Use Any Terminal On Your PC (Like Tera Term, Arduino Serial Monitor, etc..)Required Parts For STM32 ExamplesAll the example Code/LABs/Projects in this STM32 Series of Tutorials are done using the Dev boards & Electronic Parts Below:QTY.Component NameAmazon.comAliExpresseBay1STM32-F103 BluePill

2025-04-03
User8054

This is the 4th Tutorial in the Modbus Series, and today we will start the STM32 as a slave Device. This tutorial will cover how the STM32 as a slave device will send a response to the queries regarding reading holding registers and input registers.We will cover the function codes FC03 and FC04 in this tutorial, but from the slave prospective.I have already mentioned in the previous modbus tutorials that RS485 is not a requirement by the modbus, rather the mosbus protocol can be used with any communication standard.Today I am going to use the UART with the modbus protocol. I am using the STM32F446 nucleo board and it’s easier to communicate with the computer using the UART.CubeMX SetupBelow is the image of the cubeMX setupHere I am using the UART2 with the Baudrate of 115200. The configuration is 8-N-1. I have also enabled the interrupt. The pins PA2 and PA3 are configured as the TX and RX pins respectively.The Master SotwareI am using the simply modbus master software, which can be downloaded from software is shown belowHere in the RED BOX we have the serial configuration. It is same as what we configured in the cubeMX.The 115200-8-N-1 configurationThe GREEN BOX contains the slave ID, The start Register, the number of Registers master wants to Read, the function code and the Register size.The BLACK BOX contains the query to be sent by the master. It is based on the setup we did in the Green box.The BLUE box contains the response received by the master. It will update once the slave send some response.The YELLOW BOX contains the resisters master has requested the values for. These will update once the slave send the data.Some insight into the CODEDefines// in the main.c uint8_t RxData[256];uint8_t TxData[256];// in the modbusslave.cextern uint8_t RxData[256];extern uint8_t TxData[256];extern UART_HandleTypeDef huart2;// in the modbusslave.h#define SLAVE_ID 7#define ILLEGAL_FUNCTION 0x01#define ILLEGAL_DATA_ADDRESS 0x02#define ILLEGAL_DATA_VALUE 0x03static uint16_t Holding_Registers_Database[50]={ 0000, 1111, 2222, 3333, 4444, 5555, 6666, 7777, 8888, 9999, // 0-9 40001-40010 12345, 15432, 15535, 10234, 19876, 13579, 10293, 19827, 13456, 14567, // 10-19 40011-40020 21345, 22345, 24567, 25678, 26789, 24680, 20394, 29384, 26937, 27654, // 20-29 40021-40030 31245, 31456, 34567, 35678, 36789, 37890, 30948, 34958, 35867, 36092, // 30-39 40031-40040 45678, 46789, 47890, 41235, 42356, 43567, 40596, 49586, 48765, 41029, // 40-49 40041-40050};I have defined the RxData and TxData buffers in the main file. The same buffers are defined in the modbusslave.c file but as extern variables. The modbusslave.h file contains the slave ID, along with some exception codes. We will see the exception codes in a while.I have also defines the database for the holding registers, which the master will request the data from.SendData functionvoid sendData (uint8_t *data, int size){ //

2025-04-16
User9557

18KB.The memories are allocated in the SRAM region, whose properties can be modified later in the MPU.LWIP ConfigurationThe LightWeight IP can be enabled in the middleware section. If the MCU does not let you enable it, make sure the cache (DCache and ICache) are enabled.The most of the Configuration in the LWIP remains same. Except, some MCUs let us choose the address for the Heap.Here we are going to disable the DHCP, and configure a static IP for our ethernet module. I have set the IP 192.168.0.123 for the board.In the Key Option tab, I am using 5KB memory for the Heap. The location for this heap is defined as 0x30004000.In the Platform Settings tab, set the PHY as LAN8742.MPU ConfigurationWe have the DMA Descriptors in the SRAM Region. This is why we need to configure the MPU.If your MCU didn’t let you choose the memory region, then probably you don’t need to do it. But for the cortex M7 devices, this is a must, or else you will get hardfault.Remember that during the configuration, we set up everything in the SRAM (0x30000000). The complete memory structure is shown in the image below.Below is the image showing the MPU configuration for the above Region.Here I have selected the 32 KB region so that it will cover our total RAM region, which is around 24KB.The rest of the configuration is to set the region as non-cacheable region.This would prevent the cache coherency issue between the CPU and the DMA.This is explained in the cortex M7 playlist, so do check that out.Other ConfigurationIf you are connecting the STM32 board to the Router, there is nothing you need to do at the computer end. But if you are connecting the ethernet cable directly to the computer, you need to configure your computer’s ethernet as per the images shown below.Below is the configuration for a Windows computer.Below is the configuration for Mac.The CODEOnce the project is generated, open the LWIP -> Target -> ethernetif.c file. Here you will some memory locations that needs to be defined in the flash script file.We need to define these memory locations in the flash script file, as per the configuration done in the cubeMX.Below is the code is for the H745 Discovery board according to the configuration done in the cubeMX. .lwip_sec (NOLOAD) : { . = ABSOLUTE(0x30000000); *(.RxDecripSection) . = ABSOLUTE(0x30000080); *(.TxDecripSection) . = ABSOLUTE(0x30000100); *(.Rx_PoolSection) }

2025-04-07
User4890

STM32CubeIDE/CLT 1.12.1 was released on st.com as well as an in-tool update patch. Aligned with STM32CubeMX v6.8.1 that is available for download .Caution: The in-tool update does not allow updating drivers and ST-LINK server tool. Full installer is required for this.Main issues fixed in this patch:This patch release fixes the issues related to the following cases:STM32CubeIDEIncorrect permission of lib jspawnhelper in jre packaged in STM3CubeIDE.STM32CubeIDE does not launch with Linux FedoraSTM32CubeCLT Variable path is removed when CubeCLT is installed.STM32CubeMXCubeMX project Cube IDE complication error on ETHUpdate to CubeMX 6.8 adds non-working VOSRDY flag check to SystemClock_Config() on STM32F7 using LL drivers.[X-CUBE-FREERTOS][v1.0.1] Can't select previous version with secure context[STM32CubeMX][MDMA] MDMA GUI crash causing issue with toolWhere do I obtain CubeIDE ,CLT 1.12.1 and CubeMX 6.8.1 ?For IDE 1.12.1 : CLT 1.12.1 : update your current installation of STM32CubeIDE using: Help > Check for updatesupdating STM32CubeIDE, the post-update restart fails. STM32CubeIDE must be restarted manually For MX 6.8.1: STM32CubeMX - STM32Cube initialization code generator - STMicroelectronicsRelated threadsUpdate to CubeMX 6.8 adds non-working VOSRDY flag check to SystemClock_Config() on STM32F7 using LL driversClick on cubeIDE 1.12 MDMA section sometime causes MX tab an undefined behaviour

2025-04-13

Add Comment