Ask questions on STM32CubeMX. Discuss code generation and configuration challenges, among other topics.
Most recent activity
Hi All,The following is wha I met.I have a development board with STM32F429 MCU. I'd like to establish SMBus communication to a smart battery with this development board. PH4 and PH5 are used as SCL and SDA output of smbus2.I used the following APIs from stm32 hal lib.HAL_SMBUS_Init, HAL_SMBUS_ConfigDigitalFilter, HAL_SMBUS_Master_Transmit_IT, HAL_SMBUS_IsDeviceReady, and HAL_SMBUS_EV_IRQHandler.Here's the main part of my code:void SMBus_Init(tI2C_INDEX index){ assert(index < eI2C_MAX); gSMBus_Handle[index].Instance = gI2C_Base[index]; gSMBus_Handle[index].Init.ClockSpeed = 100000; // 100kHz gSMBus_Handle[index].Init.AnalogFilter = SMBUS_ANALOGFILTER_ENABLE; gSMBus_Handle[index].Init.OwnAddress1 = 2; gSMBus_Handle[index].Init.AddressingMode = SMBUS_ADDRESSINGMODE_7BIT; gSMBus_Handle[index].Init.DualAddressMode = SMBUS_DUALADDRESS_DISABLE; gSMBus_Handle[index].Init.OwnAddress2 = 0; gSMB
Hello,I'm sorry if this is the wrong sectionI'm using STM32CubeMX on custom STM32F407VG I'm using 1-Bit mode SD card with FatFS middleware (4-Bit didn't work at all)I'm writing 500-1000 bytes to a txt file every ~30msOnce the file size is > 2MB I close it and open another txt fileIt works fine for few minutes and creates multiple files as well, but sometimes the f_write fails giving a FR_DISK_ERR, when I try to close it it'll give the same errorWhen I try to write or close again after the previous error it'll give FR_INVALID_OBJECTOnce I see this error only a HW reset of the MCU will solve itI tried deinit/init of the HAL_SD or FatFS but nothing workedAttached the code I'm using, this function is currently called every ~100ms with these problems, but the goal is to call it every ~30msvoid PIR_to_SD(char myData[]){ uint8_t status = FR_OK; //mount SD if it's not already mounted if(!sd_mount){ status = f_mount(&myFATAFS, SDPath, 0); if(status != FR_OK){ printf("SD: Failed
We need some receive only UART/USART on STM32H7/STM32F7.In MX I can select Half Duplex, but that seems to only disable Rx pin.Even when I select [Data direction = Rx Only] still shows only Tx pin.Even when I select [TX and Rx pins swapping = enable] still shows only Tx pin.Is this only a bug in MX?Is there a limitation in STM32H7/STM32F7?How can I free the Uart Tx pins for other assignments?Paul
Hi,I used STM32CubeMx to config USB VCOM device on STM32F469 discovery kit and it worked well. Then I want to add another class (eg HID\Auddio), but STM32CubeMx only allows config one type of class. If I change the class, then all libraries about the last configured class will be removed. So, my question is how to config library for multi USB class by using STM32CubeMx? Good day,Young
I have two STM32H7 designsSTM32H743IIK, Clock = 480MHz/240MHzSTM32H743ZIT, Clock = Can't set 480MHz/240MHz (on Nucleo-H743ZI2)Using STM32CubeMX 6.3.0 - Clock Resolver always seems to always choose lower MHz like 120 or 64MHz- I tried a new blank project but gives same limits, so doesn't seem to be a module I'm using.- Entering 480 at "480 MHz max" or 240 at "240 MHz max" gives a popup="Frequency is out of range for this VOS range" - Starting at left and keeping everything clean ends up with 480MHz at "480MHz max" highlighted as error - why? Hovering over it says "D1CPRE clock frequency must be <=300MHz", but works OK on my first H7 project with 480MHz/240MHz. What am I doing wrong, or is there a bug in MX?Paul
In CubeMX, in the clock tree screen, you can select the prescaler that produces "Cortex System Timer (MHz)" (which is the clock feeding SysTick) starting from HCLK.However, whether you select the /1 prescaler or the /8 prescaler, identical code is generated (see the attachment).I would expect this setting to be reflected in some initialization code.The SysTick->CTRL register has a bit (bit #2, defined as SysTick_CTRL_CLKSOURCE_Msk in "core_cm*.h") to select the SysTick clock source.From the ARM documentation (https://developer.arm.com/documentation/dui0497/a/cortex-m0-peripherals/optional-system-timer--systick/systick-control-and-status-register) this bit selects either a "reference clock" (if 0) or a "processor clock" (if 1).CubeMX-generated code always sets this bit to 1.The reference manual (for L073) says, in the RCC chapter:The RCC feeds the Cortex® System Timer (SysTick) external clock with the AHB clock(HCLK) divided by 8. The SysTick can work either with this clock or with t
Hi All,I am working on my Nucleo-L4R5ZI board and facing issues with firmware sdk packages downloaded by "Stm32cubeMx" and "Stm32CubeIDE" software respectively.I am just trying to test the board using simple led toggle program but it unable to make it toggle properly and tested in other different IDE but issues remain same & present.Then I have tested it some older developed program using keil IDE it works in that environment, means in older firmware packages it works but not in new latest ones.(Note - My older firmware packages was deleted and after setting up new Stm32CubeMx it downloads new latest which is not working with my board)I request you all to please share the possible solution for the same.I am sharing my very simple and basic IOC file to re-create & perform the same for testing.Thanks & RegardsSS
I have a project configured with CubeMX that includes an RTOS. Because of RTOS, I use TIM2 as the HAL timebase. What I have observed is that STL_FullRamMarchC overwrites the htim2 structure and after interrupts are re-enabled, the HAL_TIM_IRQHandler tries to work with an invalid timer handle.I'm wondering if there is a way to configure the STL to handle this, or do I need to customize some of the STL code for my use case.
When I create a new STM32Cube IDE project with STM32CubeMX, it uses newlib.The project uses freeRTOS. Is it possible to disable this, and make it use standard libs?I can't find a flag anywhere, to do this.When I create an MDK or EWARM project, they do not use newlib.So why is the GCC / STM32Cube IDE use it?Thanks !brKaare
In embedded programming usually active low. Low menace enabled chip select or some fuse in atmega.STM shouldn't write hints which mean Enabled is 1; Disabled is "0". Am I right?
I am working on a project which use cubeMX cellular expansion package, it works fine for IPv4.Now I am enabling IPV6.I found even LwIP supports the IPv6, the expansion package has very limit support for that.For example, the IP interface of STM32_Cellular/com_sockets_addr_compat.honly support IPV4. May I know if any example or plan for STM32_Cellular to support IPv6?https://www.st.com/en/embedded-software/x-cube-cellular.html
I2C did not work, so I was looking for the cause, and found that there was a missing part in the HAL_I2C_MspInit() function of the stm32f1xx_hal_msp.c file automatically generated by CubeMX, unlike the previous version.GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;If I insert the above code, it works normally.Below is the version information.CubeMX V6.3.0MCU Package STM32F1 Series V1.8.4MCU STM32F103C6Tx
I am upgrading an STM32F429IIT6 project that uses an external SRAM and an RGB888 LCD. The product currently works as it was set up with emWin and an older version of STMCubeMX but now I need to update to use TouchGFX. However STM32CubeIDE/STM32MX pin mapping gives a conflict when attempting to set the SRAM as 32 bits wide and the LTDC to RGB888. I have stripped out most everything else with no change. I am not using an OS. What might I be missing?Thanks,Raymond
With my pin assignments ADC IN14 shows a conflict with PB0. Which is incorrect according to the datasheet. The conflict should be with PC5. IN15 also shows a conflict with PB0 which is correct.
I have an STM3210E-EVAL board that I use to gain experience with an SD card. To generate a software template, I use STM32CubeMX 6.3 and the STM32F103 package.1.8.4. Keil MDK is used to compile the project. To work with the file system, I use FatFs from STM32CubeMX. My test program (mounting the file system, writing a text file and then reading it) works correctly only in SDIO 1 bit mode. When switching the SDIO to 4 bit mod in STM32CubeMX, i get FR_DISK_ERR occurs during file opening and writing operations. I use SD cards with a capacity of 128 MB, 2 GB and 4 GB. The File_Demo project from Keil MCBSTM32E board adapted by me for STM3210E-EVAL board works successfully with all my SD cards with the SDIO 1 bit and 4 bit bus.Tell me what can be done to activate the SDIO 4 bit width mode...Problem solved! The CD card has started working at a frequency of 4 MHz!
/** Initializes the CPU, AHB and APB buses clocks */ //RCC_ClkInitStruct.ClockType = ClockTypeHCLK|ClockTypeSysClk // |ClockTypePCLK1|ClockTypePCLK2; //Has to be: RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_SYSCLK| RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2;
CubeMX allows one to enter clock frequencies and have all the registers to be set back calculated. Great! This saves much fiddling. However... is there anyway for the code to determine, for example, what the frequency if a clock going to the ADC is without doing all those calculations that CubeMX saved us from?
I will be working with some STM32F4 processors soon and so I am doing some reading ahead. What I am not clear on is if I use HAL to setup I/O or peripherals do I need to use STMCubeMX to set up the pins?Can STMCubeMX (pin editor?) be opened from IDE?MaryK
Have tried with earlier versions of CubeMX, different computer. Does the same thing. Do not see any use of the init structure (which is local). SD card is not initialized properly. Complete code generated is:tatic void MX_SDMMC1_SD_Init(void) { /* USER CODE BEGIN SDMMC1_Init 0 */ /* USER CODE END SDMMC1_Init 0 */ /* USER CODE BEGIN SDMMC1_Init 1 */ /* USER CODE END SDMMC1_Init 1 */ hsd1.Instance = SDMMC1; hsd1.Init.ClockEdge = SDMMC_CLOCK_EDGE_RISING; hsd1.Init.ClockBypass = SDMMC_CLOCK_BYPASS_DISABLE; hsd1.Init.ClockPowerSave = SDMMC_CLOCK_POWER_SAVE_DISABLE; hsd1.Init.BusWide = SDMMC_BUS_WIDE_1B; hsd1.Init.HardwareFlowControl = SDMMC_HARDWARE_FLOW_CONTROL_DISABLE; hsd1.Init.ClockDiv = 0; /* USER CODE BEGIN SDMMC1_Init 2 */ /* USER CODE END SDMMC1_Init 2 */ } This seems incomplete to me. Trying to compare this code with the BSP driver code indicates that more code is needed somewhere.If there's a setting that I'm missing, I'
I want to run the ADC using DMA and Dual mode.The sampling rate was set to 80kS / s using TIM3. The board I am using is Nucleo 64 STM32 F446.In order to confirm whether the ADC is really running at 80kS / s, I described "HAL_GPIO_TogglePin" in "DMA2_Stream0_IRQHandler (void)" and confirmed it by observing the pulse width with an oscilloscope.As a result, it was found that the ADC is running at about 660us (1.5kHz in frequency). (According to the data sheet, the STM used can have a maximum sampling rate of 2.4 MS / s.)Why doesn't my program get the sampling rate I set?My program only runs the ADC and does nothing else.Our development environmentwin10STM32CubeIDE Ver1.6.1Board used: Nucleo64 STM32F446Thank you for your reply.
This continues to be a confusing topic for me. I am slowly beginning to understand how the MCU Clock Configuration tab works in CubeMX, but I could use a little clarity before I start tweaking all these values.Here is my current clock configuration: I have an 8 MHZ external clock connected to PH0 and PH1, which I entered into the HSE block.Now, if I want my MCU to run at its max speed of 180 MHZ, which part of this clock configuration should I change?I feel like all I need to do is change the HCLK value to 180, but looking at the diagram it appears that the HCLK is being fed by the SYSCLK, which is set to 16 MHZ. So would I also need to set SYSCLK to 180 MHZ? Or is there some magic clock multiplication occurring between the SYSCLK and the HCLK?:grinning_face_with_sweat:
Hi,Can I somewhere find an example for STM32F4 + SDIOCard(Bluetooth/Wifi) ??? (It's not a SD-Card and not a MM-Card)It seems, CubeMX can only generate HAL for SDC and MMC based on Hardware Module SDIO.SDIO-Card needs different initiallization and data Exchange CMD's … e.g. starting initialization with CMD5 ...Very Best Thanks for any Help!
Because my bare metal version of a ADC1+DMA1+DMA1_CHANNEL1+DMAMUX+TIM3 System will not work,I now try to build such a system using STM32CubeMX/HAL - but with greater problems. Now writing to hdma->Instance->CCR fails, when I stepinto MX_ADC1_Init(),into HAL_ADC_Init(&hadc1),into HAL_ADC_MspInit(hadc),into HAL_DMA_Init(&hdma_adc1)to the line hdma->Instance->CCR = tmp;tmp has the value 0x5A0, hdma->Instance->CCR before an after execution of this line the value 0.Has the DMA1-Clock to be enabled for writing to DMA1->CCR?If so, the STM32CubeMX generated siftware will never work, because this Clock will be enabledinside MX_DMA_Init(), which will be called after MX_ADC1_Init()?
Hello,I tried to use SPI connectivity on STM32F769I-DISCO in order to comminucate with an ADC (LTC2440), but i can't visualize the SPI Clock on my scope. I used the SPI2, so the clock signal can be retrieved on the arduino pin (D13).Has anyone ever encountred this issue ?You 'll find attached a part of my code and the clock settingsBest regards.
..
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.