Ask questions on STM32CubeMX. Discuss code generation and configuration challenges, among other topics.
Most recent activity
The function LL_PLL_ConfigSystemClock_HSI() in stm32g4xx_ll_utils.c temporarily divides the AHB clock by 2 if the SYSCLK divider is 1. According to the comments, this is to "Prevent undershoot at highest frequency by applying intermediate AHB prescaler 2". The issue is that during this temporary AHB clock rate, the SystemCoreClock is updated to also be 1/2 the expected clock.Although LL_PLL_ConfigSystemClock_HSI() resets the AHB clock properly, it does not reset the global variable SystemCoreClock. This incorrect value is exposed when trying to set the UART baud rate later on in stm32g4xx_hal_uart.c.Note that I'm using the latest from https://github.com/STMicroelectronics/STM32CubeG4 (0f8a4fd) with this recent pull-request integrated.The following patch fixes the issue. Is this the correct solution? If so, I'm happy to issue a PR.. but do not know where to do it as there is conflicting info across the web.diff --git a/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_ll_utils.c b/Drivers/STM3
I updated the software package for the STM32F1 MCU from the 1.6.0 version to 1.8.0 and I then felt in trouble with the ADC acquisition with the DMA in continuous mode : the data sound to be shifting in the buffer.I read 3 signals (actually RGB LED). While the signals are constant, I observed the values moving from one channel to another.Here is the code :some definitions#define ADC_SAMPLE_COUNT 10u #define ADC_CHANNEL_COUNT 3u #define ADC_DATA_COUNT (ADC_SAMPLE_COUNT * ADC_CHANNEL_COUNT)the initialization (generated by STM32CubeMX)void MX_ADC1_Init(void) { ADC_ChannelConfTypeDef sConfig = {0}; /** Common config */ hadc1.Instance = ADC1; hadc1.Init.ScanConvMode = ADC_SCAN_ENABLE; hadc1.Init.ContinuousConvMode = ENABLE; hadc1.Init.DiscontinuousConvMode = DISABLE; hadc1.Init.ExternalTrigConv = ADC_SOFTWARE_START; hadc1.Init.DataAlign = ADC_DATAALIGN_RIGHT; hadc1.Init.NbrOfConversion = 3; if (HAL_ADC_Init(&hadc1) != HAL_OK) { Error_Handler(); } /** Configure Regu
In the latest version of CubeMX for F4 1.24.2, the parameters on Error_Handler have disappeared. I can't find a control in the code generator page to enable it again. What gives?A few years ago, I wrote:"In the latest version of Cube (4.17.0), when main.c is generated, you get a function called Error_Handler() that is called by the HAL functions anytime the return code is not HAL_OK. Error_Handler just goes into a tight loop, leaving you scratching your head as to why your program isn't working.This is somewhat better than the previous construct, but in my small program, this function is called in 51 places. It would be useful if Error_Handler had some parameters so you could print out __FILE__ and __LINE__ so you could at least print out some sort of message that could lead you to a solution. That would mean using some sort of a macro along the lines of assert_param.As it is now, the only thing that Error_Handler can be used for is some sort of printf(''blammo I blew up\n''); or as a
..
The scope is showing the following code takes 602ms (I'm using the external crystal, so no jitter) this 2ms can be seen on top of any delay I set. while (1) { HAL_GPIO_WritePin(GPIOB, profilingPin_Pin, GPIO_PIN_SET); HAL_Delay(300); HAL_GPIO_WritePin(GPIOB, profilingPin_Pin, GPIO_PIN_RESET); HAL_Delay(300); }The toggle of a pin takes 70-80ns so that isn't the issue. I have used the 16MHz clockwhich still has the +2ms, and some jitter as expected.Any insights on this will be greatly appreciated!
I am Samet, an electrical and electronics engineering first-year student. I and my team are designing a hydrogen car and taking part in the races. We make the electronic cards of our vehicle and the design of these cards. I am writing to you because we had a problem while coding. There are many sensors in our vehicle and we have to get data from these sensors with ADC. We use STM32F407VGT6 as the processor. In software, we write our code in the Keil compiler using the STMCUBEMX HAL Library. We need to read ADC value from 13 channels but we cannot read fluent and accurate data. If you think that the problem is caused by hardware, our cards have the necessary filters and Op-Amp circuits. Can you help us with suggestions and sample coding about this subject?
I use stm32F407ZG, when I update mxcube to 5.3 version and stm32f4 package to 1.24.2 fatfs version updated to R0.12c while previous fatfs version was R0.11 and work perfectly. after code generate and compile I realized f_mount function returns FR_NO_FILESYSTEM.(f_mount(&SDFatFs,"1:/", 1))I attach cube setting.please help me.if (INSERT_SD ==0) { res=disk_initialize (0); if (res==0) { res=f_mount(&SDFatFs,"1:/", 1); if (res!=FR_OK && res!=FR_EXIST) {// printf("<ERR*SD NOT Ready:%d*>\r\n",res); sprintf(str,"<ERR*SD NOT Ready:%d*>\r\n",res); if (start_debug==1) print(DEBUG_PORT,str);else if (start_debug==2) print(LAN_PORT,str); return 0; }res = f_findfirst(&SD_dir,&fno,"1:/LOG","*.LOG"); /* Start to search for log files */}}
Hello,Under linux (project generated by STM32CubeMX), the compiler reports illegal implicit casts from void * to PCD_HandleTypeDef in the HAL libraries.The problems are in two files: usbd_conf.c and usbd_cdc.cI solved this by following the example in other HAL sources, by adding explicit type casts for all reported problems like so (line 354 of usbd_conf.c): hal_status = HAL_PCD_DeInit((PCD_HandleTypeDef*) pdev->pData);The errors are present in the latest version of the HAL (I updated STM32CubeMX and the project today)While correcting this I wondered about two things:1. Why do only these specific files not include the type casts that are included in other HAL library files. Done by a different programmer / added later to the HAL?2. Why were these errors not caught by ST? Perhaps this was not tested under linux or not tested from a freshly generated project?Or perhaps I am doing something wrong here?Thanks for your reply and best regards,JohnExample error
I'd like to know how I can resume receiving data from flow controlled UART.I use HAL, and I set USART2 into "flow control" with Cube MX code like ashuart2.Init.HwFlowCtl = UART_HWCONTROL_RTS_CTS;(115200 bps, data bit 8, stop bit 1, none parity, etc. )I start data receiving as follows,HAL_UART_Receive_DMA(&huart2, &g_recv_char, 1);and the 1 byte receiving is chained as follows.void HAL_UART_RxCpltCallback(UART_HandleTypeDef *UartHandle) { (......any processes......) HAL_UART_Receive_DMA(&huart2, &g_recv_char, 1);}It works for a while (10 - 30min), but after it the data receiving is stopped. When I read RDR register with debugger, the value is changed and it is explicit correct data sent from external device.But "HAL_UART_RxCpltCallback" func is not called.When I manually execute "HAL_UART_Receive_DMA(&huart2, &g_recv_char, 1);" (with debugger operation), continuous data receiving is resumed.So I guess the external device is st
Hi !After updating I'm not able to load any project or generating a new one. Each time a project is loaded the program crashes with... 2020-01-10 23:34:35,765 [INFO] BlockDiagram:1818 - stop enableDisableButtons java.lang.NullPointerException ... at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90) Exception in thread "AWT-EventQueue-0" java.lang.NoSuchMethodError: 'boolean com.st.microxplorer.mcu.IP.isDMASupported()' ...Please see attached text file for full log.
Since quite some time I am trying to find a way for an STM32 chip to receive and send data as a slave over i2c. The master always sends the same amount of bytes and after sending these bytes, requests two bytes back from the slave. I used the CubeMX example software for i2c with succes, however this example code as found here:https://github.com/fboris/STM32Cube_FW_F4/tree/master/Projects/STM32F401-Discovery/Examples/I2C/I2C_TwoBoards_ComITThis code works and enabling a 'global i2c interrupt' and triggering an LED in this interrupt works as well. However when I try to put the code in the interrupt, the LED does not even go on. The LED is just for testing and in the end I would like to be able to receive information through i2c on an interrupt. Putting following code in the main works for one receive and one send, however i would like to replace this code to the interrupt, which does not work as is:if(HAL_I2C_Slave_Receive_DMA(&hi2c2, (uint8_t *)aRxBuffer, RXBUFFERSIZE) != HAL_OK)&nb
i want to enable spi1 in stm32 F401RETx ,please help me to set baud rate configuration.thankssunil kumar reddy
I downloaded and installed stm32cubemx version 5.4,and the default installation configuration is maintained.When I tried to generate an MDK project, I reported an error.But it can be used normally after uninstalling and installing version 5.3.I don't know why?I have tried to uninstall and then reinstall, or check if there is a Chinese path and other methods, which are not available for normal use. Help me...I use the win10 64 bit system.java version "1.8.0_231"Java(TM) SE Runtime Environment (build 1.8.0_231-b11)Java HotSpot(TM) Client VM (build 25.231-b11, mixed mode, sharing)
Hello, I am using CubeMX to configure the STM32H745II-Discovery device and am also using several drivers from Segger. Like embOS , and others for example. Because CubeMX does not readily support Segger drivers, how best can I utilize CubeMX with these third party drivers and not have to do so much manual project manipulation each time I need to change a pin or periheral using CubeMX? I see some project management options but haven't figured out the best combination.
CubeMX 5.5.0STM32Cube_FW_F7_V1.15.0STM32F767IGAssert Failed: FILE - ../Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_rcc.c, LINE - 602RCC_OscInitStruct.PLL.PLLR is not assigned a value, therefore = 0, which fails above assertAdding following code resolves issue/* CUBEMX BUG FIX * PLLR not initialized to a valid value * PLLR >=2 && <= 7 * Initialize to 2 (reset value) */ RCC_OscInitStruct.PLL.PLLR = 2;Andy
Hi all,I am new to ST.I am struggling with the attached code.I am trying to transmit CAN message.Thanks
I'm using STM32L073RZ on my own board, and I am trying to program USB device (I tried virtual COM and HID, separately).But after plugging into PC it is detected (after a while) with "Unknown device (device descriptor request failed)" error in windows 1Electrically (PCB):I think that PCB is not an error here - I just have D+ and D- short tracks from the connector to the uC and that's all.I have a pull-up 1.5k (I tried with and without it), but it is not even needed in STM32. I have check connection and a cable and I'm certain it connects. Code:I'm using HAL and STM32CubeMx generated code merged with my project is this a software or hardware issue?
I selected TIM1 as Timebase Source of HAL libraries. I think the generated code from MX tool is wrong.HAL_InitTick() is called two times: the first during HAL_Init(), the second during SystemClock_Config(). However the first time is called as HAL_InitTick(TICK_INT_PRIORITY), the second time is called as HAL_InitTick(uwTickPrio).uwTickPrio is normally updated during HAL_InitTick() defined in _hal.c, when Systick is used as timebase source. When TIM1 is used, HAL_InitTick() defined in _hal_timebase_tim.c doesn't update the variable, that still have the init value, an invalid priority. So the second time HAL_InitTick() is called, an assert is fired during HAL_NVIC_SetPriority().void HAL_NVIC_SetPriority(IRQn_Type IRQn, uint32_t PreemptPriority, uint32_t SubPriority) { uint32_t prioritygroup = 0x00; /* Check the parameters */ assert_param(IS_NVIC_SUB_PRIORITY(SubPriority)); assert_param(IS_NVIC_PREEMPTION_PRIORITY(PreemptPriority)); prioritygroup = NVIC_GetPriorityGroupi
I am using STM32CubeMX with FreeRTOS/ CMSIS_RTOS_V2. However I think I have not understood the logic behind the creation of the files.CubeMX created a file "app_freertos.c" without a header file and the semaphore created is inside this file.I have two other files "busA.h" and "busA.c" where I use a couple of Timer ISRs with STM Low Layer APIs. "busA.h" is included inside "stm32g0xx_it.c".I need to call osSemaphoreRelease(semaphoreId) inside one of those ISR callbacks but because CubeMX created the semaphore inside "app_freertos.c", I just can't access it. It seems the semaphore scope is limited to "app_freertos.c". The problem is I have a lot going on inside my files (busA.c), bunch of variables etc. I am %90 sure if I try to move everything inside "app_freertos.c", it will be a mess.Shall I create a header file manually for "app_freertos.c", namely "app_freertos.h" and return semaphore address into my "busA.c" file (with a function)?
The LwIP code generated by the new STM32CubeMX 5.5.0 still need that the function SBC_CleanInvalidateDCache() be called before HAL_ETH_Transmit in the low_level_output function.
Hello FriendI have question about Target settingIn general I selected using processor in cubeMXthen make bt CubeMX Truestudio project must contain target Settingsbut some computer has no target Setting.Now, one by one select processor in Truestudio for the time beingHow can I solve this problem?Thanks.Winver : 10 1903cubeMX : 5.5.0TrueStudio : 9.3.0<normal target setting><has problem target setting>
screenshot from an .ioc file created with an earlier version of CubeMxCubeMx version 5.30screenshot from an .ioc file created with CUbeMx version 5.5.0Full details of installation:STM32CubeMX - STM32 Device Configuration ToolVersion: 5.5.0-RC6Build: 20191220-1511 (UTC)Copyright (c) 2018 STMicroelectronics. All rights reservedSTM32CubeIDEVersion: 1.2.1Build: 5190_20200115_1224 (UTC)(C) 2019 STMicroelectronics ALL RIGHTS RESERVEDThanks
can anyone suggest a method to sort hardfault error.I went on commenting few lines to sort the problem and found that when the uart is continuesly receiving and transmitting data this occurs.
I've been working with USB Mass Storage Class to create an SD Card reader with STM32L1 using SPI. I added the SDCard_SPI library and filled the missing functions in the "usbd_storage_if.c" file.What I've got is that my project works fine with SD Cards that have the boot sector at the address 0. But in other cases windows keeps sending commends repeatedly to read sector 0 and returns "please insert disk" error. Is this a library limitation ? or should I add something to make windows recognize that the boot sector isn't at the address 0?
I have linked the zipped test project that I used to verify the behavior that I will try to describe. I have a largely stripped down project with RTOS, USB Host Library with MSC, and a UART configured for printf() so I can utilize the USBLog debugging which has USBH_DEBUG_LEVEL at 3.The test I was running is on a NUCLEO_F429ZI development board with a USB OTG cable as well as a UART connected for viewing the debug messages. I plug the USB drive in and the system enumerates the device. Typically, if I am being careful to be quick when disconnecting the USB drive, I can continuously disconnect and reconnect with successful enumeration each time.If I am slow when disconnecting, the stack detects the disconnection, but then detects a faulty "USB Device Attached". At this point there is no drive installed. Any subsequent drive installations do not work. The MCU is still running, but it is stuck at the HOST_ENUMERATION state. I found this in a different project an dug into the stack a fair b
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.