Ask questions on STM32CubeMX. Discuss code generation and configuration challenges, among other topics.
Most recent activity
In a project for a STM32L4S7ZITx with LPUART1 enabled the following code is generated:/** * @brief LPUART1 Initialization Function * @param None * @retval None */ static void MX_LPUART1_UART_Init(void) { /* USER CODE BEGIN LPUART1_Init 0 */ /* USER CODE END LPUART1_Init 0 */ /* USER CODE BEGIN LPUART1_Init 1 */ /* USER CODE END LPUART1_Init 1 */ hlpuart1.Instance = LPUART1; hlpuart1.Init.BaudRate = 115200; hlpuart1.Init.WordLength = UART_WORDLENGTH_8B; hlpuart1.Init.StopBits = UART_STOPBITS_1; hlpuart1.Init.Parity = UART_PARITY_NONE; hlpuart1.Init.Mode = UART_MODE_TX_RX; hlpuart1.Init.HwFlowCtl = UART_HWCONTROL_NONE; hlpuart1.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE; hlpuart1.Init.ClockPrescaler = UART_PRESCALER_DIV1; hlpuart1.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT; hlpuart1.FifoMode = UART_FIFOMODE_DISABLE; if (HAL_UART_Init(&hlpuart1) != HAL_OK) { Error_Handler(); } if (HAL_UARTEx_SetTxFifoThreshold(&
Hello,as many before I am trying to control some SK6812 adressable LEDs with a STM32 MCU. I have successfully done so on a custom board using the STM32L433CCT and this neat guide:https://www.thevfdcollective.com/blog/stm32-and-sk6812-rgbw-ledand this gihub repository: https://github.com/hey-frnk/STM32_HAL_NeoPixelI follwed the tutorial step by step using CubeMX and SW4STM32.Now however I have to switch to a STM32F469l-DISCO board and I thought well the same code should work right? No! Looking at the signal using a scope, I saw that it was nowhere near the needed 800kHz. So after looking around in manuals and posts I figured out, that some changes to the DMA setup have to be made. See this post:https://community.st.com/s/question/0D50X00009XkeDcSAJ/stm32f4-dma-and-varying-duty-cycleSo and here is my problem I dont really understand what exactly I have to change since they are setting up their DMA manually in the post above, while I used CubeMX to set it up again without FIFO and couldnt
I am very new to the STM32 development board and am using the STM32F407VG. I wish to connect a RFID Scanner to SPI2 and looking at the Pin Description Table (pages 21->23 in the STM32F4 users manual), I cannot see if there are specific pins to be selected for SPI2 Chip-Select-Pin setup (I think I can use PB9 but am not sure). I think I'm correct to use SPI2->PC2 = MISO, SPI2->PC3 = MOSI & SPI2-> PB10 = CLK. Has anyone dealt with this issue that can help me to know if I have to select specific pin please?
Hi,I can't find the information of "the USART source clock to providethe Smartcard clock" maximum frequency in document"RM0438Reference manual-STM32L552xx and STM32L562xx advanced Arm®-based32-bit MCUs". Please advise why "STM32CubeIDE 1.5.0" limit stm32L5 "the USART source clock to providethe Smartcard clock" maximum frequency to 5MHz.Thanks,QiZhang
Dear all,I am struggling with the B-L475e-IOT board and USB. If I use the default initialisation of CubeMX and change the USB device to OTG FS Device only and add the Middleware of the Communication device class I can not get this as recognized device on Win 7 as well as Win 10. The line coding is set within usbd_cdc_if.c as in the USB mooc as follows in CDC_Control_FS and Linecoding is defined and initialized as follows: USBD_CDC_LineCodingTypeDef Linecoding = { 115200, /*baudrate*/ 0x00, /*stop bits-1*/ 0x00, /*parity none*/ 0x08, /*no of bits*/}; case CDC_SET_LINE_CODING: Linecoding.bitrate = (uint32_t)(pbuf[0] | pbuf[1] << 8 |\ pbuf[2] << 16 | pbuf[3] << 24); Linecoding.format = pbuf[4]; Linecoding.paritytype = pbuf[5]; Linecoding.datatype = pbuf[6]; break; case CDC_GET_LINE_CODING: pbuf[0] = (uint8_t)(Linecoding.bitrate); pbuf[1] = (uint8_t)(Linecoding.bitrate>>8); pbuf[2] = (uint8_t)(Linecoding.bitrate>>16
So I'm kinda out of ideas on a simple solution on this. System:The project is using a common code/binary for two slightly different hardwares. Runtime detection is used (through IO's) to detect what hardware the software is running on. On the current prosject the HSE input is different between the two. You could discuss the logic of this, but here we are, and there are some clear benefits to it as well.Issue:Clock configuration needs to be different even if working with one CubeMX file. This is easily handled with selecting "Do not generate system call" in CubeMx and simply duplicating the SystemConfig_Clock() function and keeping one the main. Its not every day clock config is changed. The issue is however that the compiler define HSE_VALUE is also updated by CubeMx. And it seems to be done so by a script replacing all instances. This value is used in the system file for returning system clock to other peripherals. Is there any clean and good way to do this?Could HSE_VALUE somehow be
Greetings.I am getting the 'arm-none-eabi-gdb.exe has stopped working' error when trying to debug my project on a Nucleo-F401RE board with STM32CubeIDE 1.5.1 on Windows 10.The problem seems to occur when I enable the I2C3 event and error interrupts in the NVIC settings of the configuration page. If I disable the interrupts, I can debug without any problem.Attached is the project folder and the gdb log file.Thank youScott Wild
Hello, I can't download none of packages in STM32CubeMX. There is error with message ".... not available...". Trying to install manually causes error message "...Problem During Unzip File....". Trying to set the path to Firmware location manually in project manager causes error message "...The selected firmware should contain at least Drivers\STM32L1xx_HAL_Driver and Driver\CMSIS Folders". The folder with firmware was downloaded from official site. What s wrong with my STM32CubeMX?
I want to use the STM32H750. I want to configure the I2S2 to use the port PI0..PI1, but the CubeMX tool will not alloud me to do it. According the data-sheet it should be posible.Br. Poul-Erik.
I have a problem with using the printf function in Keil. I used the STM32CubeMX to setup a project and generated the code for Keil. All settings in CubeMX is standard, only thing changed is the USB_DEVICE set to Communication Device Class (Virtual Port Com).If this is setup and genrate for STM32CubeIDE and then in main.c I add #include "stdio.h" and within User Code 4 I insert the following, then printf is working on the USB connection./* USER CODE BEGIN 4 */int __io_putchar(int ch) { uint8_t c[1]; c[0] = ch & 0x00FF; HAL_UART_Transmit(&huart3, &*c, 1, 10); return ch;}int _write(int file, char *ptr, int len) { int DataIdx; for (DataIdx = 0; DataIdx < len; DataIdx++) { __io_putchar(*ptr++); } return len;}/* USER CODE END 4 */If i then do the same thing for keil, its not working, anyone who can guide me how to solve this.
I use the last release of STM32CubeIDE (v1.1). When User Labels are defined for such peripherals as UARTs, TIMERs,..., defines are well created in main.hBut, when I define User Labels for simple GPIOs (inputs or outputs), nothing is generated in main.hit seems like a little oversight ...
I'm using STM32H723, and STM32F767. CubeMX allows the data cache to be enabed and leave MPU disabled. Is this a valid configuration? Yes, i do know how to configure the MPU. Am i required to enable the MPU and configure all regions to have same attributes if i simply want the whole SRAM to be cacheable?
To my current knowledge, the latest version of STMCUFinder (3.1.0, MacOS) does not include a selectable column (and/or Peripheral on the left) to select FDCAN.Also, it does not appear that FDCAN is 'implied' by the CAN peripheral. For example, the part STM32G431x6/8/B appears to have FDCAN - according to the spec, but has no "1" marked in the CAN column (and is not selectable with CAN peripheral on the left side).Is this the only peripheral that is missing, or is STMCUFinder to be considered incomplete/obsolete (for example, can't find USB-PD specifically either)?
Hello,Issue 1: assert_failed() triggeredI had observed an issue wherein the file stm32h7xx_hal_timebase_tim.c generated by STM32CubeMX for STM32H753BIT6 has HAL_InitTick() implementation different from what is provided on the GitHub repository of STM32CubeH7 (One may refer to file stm32h7xx_hal_timebase_tim_template.c to check a sample implementation).I am concerned that the STM32CubeMX generated code calls only below inside HAL_InitTick():/*Configure the TIM2 IRQ priority */ HAL_NVIC_SetPriority(TIM2_IRQn, TickPriority, 0); /* Enable the TIM2 global Interrupt */ HAL_NVIC_EnableIRQ(TIM2_IRQn); /* Enable TIM2 clock */ __HAL_RCC_TIM2_CLK_ENABLE();(where TIM2 is the timer being used by FreeRTOS).I believe the code should be modified to:/*Configure the TIM2 IRQ priority */ if (TickPriority < (1UL << __NVIC_PRIO_BITS)) { HAL_NVIC_SetPriority(TIM2_IRQn, TickPriority ,0U); /* Enable the TIM2 global Interrupt */ HAL_NVIC_EnableIRQ(TIM2_IRQn); uwTickPrio
Hi, I have custom HW with STM32L496RGTx. On board I have MicroSD card slot.I would like trying emmc from Hardkernel with microSD reader like this: I use CubeMX 6.1.1 with STM32L4 v1.16.0 package. If I set sdmmc1 to MMC 1bit in FATFS doesn`t offer SD card.Why? How to set up emmc+fatfs+freertos with STM32L496?Please helpThank you
How can I clean this computer? Do I need to get a new one? Just because it had STM32CubeMX on it previously?
STM32CubeMX allows only Full HS for STM32H7B3VIT. According to the datasheet, that 100 pin derivate do have a support for HS and external PHY (ULPI). Please, advice, if the 100 pin supports ULPI or how to setup it in the STM32CubeMX.
Hello,I am working with this board using STM32CubeIDE version 1.5.0. I would like to use the USART6 or UART7 peripheral. When I configure the UART 7 or USART6 peripherals from the .ioc file and generate the code I believe that the code generator should include a section to configure these peripherals in the MX_GPIO_Init function in main.c. I believe that there should be some code generated that would include something like:GPIO_InitStruct.Alternate = GPIO_AF8_UART7;and a few other lines of code. After configuring these peripherals in the .ioc file however, the corresponding code does not appear in the MX_GPIO_Init function in main.c. I could add the code manually but the problem would be that an .ioc changes would overwrite this code I believe. Am I doing something wrong? I've attached the project file. Thanks.
Dear ST; I can't generate PWM with CH1 for TIM2 on STM32L0 but I can generate PWM with CH3 for TIM2 on STM32L0.
I am using STM32L152R8T6-A MCU. I use 3 UARTs in my project. UART buadrates are 9600 and 115200 bps.Initially I set the clock source to HSI (16MHz) and everything worked fine. But then I decided to change the clock source to MSI (2.097 or 4.194 MHz). The program runs properly but it seems that UARTs miss some bytes, i.e. instead of getting 11 bytes, it gets the last 8 bytes.I used the STM32CubeMX configurations and didn't change anything in initializations:void SystemClock_Config(void) { RCC_OscInitTypeDef RCC_OscInitStruct = {0}; RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; RCC_PeriphCLKInitTypeDef PeriphClkInit = {0}; /** Configure the main internal regulator output voltage */ __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); /** Initializes the RCC Oscillators according to the specified parameters * in the RCC_OscInitTypeDef structure. */ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI|RCC_OSCILLATORTYPE_MSI; RCC_OscInitStruct.LSIState = RCC_L
Hello All,While building my project, I got 3 errors as shown below. I have no application level errors.Error Messages: In file included from ../STM32GENERIC-master/tools/win/src/upload-reset/upload-reset.c:29:0:c:\st\stm32cubeide_1.4.0\stm32cubeide\plugins\com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.7-2018-q2-update.win32_1.5.0.202011040924\tools\arm-none-eabi\include\termios.h:4:10: fatal error: sys/termios.h: No such file or directory #include <sys/termios.h> ^~~~~~~~~~~~~~~compilation terminated.make: *** [STM32GENERIC-master/tools/win/src/upload-reset/subdir.mk:18: STM32GENERIC-master/tools/win/src/upload-reset/upload-reset.o] Error 1make: *** Waiting for unfinished jobs...."make -j4 all" terminated with exit code 2. Build might be incomplete. For this project, I'm making use of :STM32F030R8STM CudeIDEPlease help me resolve this issue as soon as possible and thank you for your help.
Hello dear developers, here is a ridiculous bug I have found.Procedure for reproduction:1) Open STM32CUBEMX =) (preferably 6.1.1)2) Create a project. (preferably name it test)3) Generate source files.AN IMPORTANT STEP4) Copy the whole folder (If in windows 10 OS, the folder is named test - Copy, rename it to test_2)5) open the test.ioc file in test_2 folder6) Generate the code on the second folder.7) Return to test\Core folder8) Wow, something is missing, the Src folder is gone!Please, solve, this, notorious, BUG.
Hi again, I'm attempting to use the I2S peripheral on the STM32H7, and the CubeMX produces half-duplex code. Here you see that I'm using an STM32H743, selected I2S, full-duplex slave, but the only choices of mode I get are Mode Slave Transmit and Mode Slave Receive. There is no full duplex mode selectable. In addition, when I have mode slave transmit enabled, the data is spit out on the wrong pin (PA6 instead of PA7). There is literally no code change between selecting 'Full-Duplex Slave' and 'Half-Duplex Slave', but there is a change in the .ioc file. Any thoughts on how to make full duplex work? Any idea if this is a known problem in the CubeMX software?In my case, I'm lucky, an only *require* the transmit, and not so much the receive.Thanks so much!-Caleb
I'm doing my first non-trivial program using FreeRTOS, so suspect this is a newbie question. Besides the timer for FreeRTOS (using SysTick), I need a timer for the HAL (using TIM7), and another timer for some high speed audio DSP routines (using TIM6 and triggering the DAC/ADC). The audio interrupt needs to be the highest of the three. Before the RTOS that was easy, I just make sure TIM6 had a higher priority than HAL SysTick.FreeRTOS needs to use SysTick and there are lots of warnings about not sharing the HAL and FreeRTOS timer. No problem. I just told CubeMX to use TIM7 as it's timebase instead. Once I do that, however, CubeMX fixes the interrupt priority for TIM7 to be 0 and it can't be altered. I need it higher than 0 so I can have TIM6 for the audio work be the highest priority. With TIM7 fixed at 0, I can't do that.Since CubeMX is going out of its way to do this, I assume there is a reason. Is it trying to stop me from doing something bad I don't understand? I do need an interru
I have been following along with https://www.youtube.com/watch?v=-AFCcfzK9xcand I can see that each change made in CubeMX produces changes in my generated code in main.cHowever, I cannot find any generated code which links the Timer Output Channel 1 to my GPIO Pin PA5. Is it being saved somewhere else, or is it being saved in some obscure way that I've missed?
ST Community highlights – April to June 2026
Already have an account? Login
No account yet? Create an account
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.