Ask questions on STM32CubeMX. Discuss code generation and configuration challenges, among other topics.
Most recent activity
Hi.. I am working with stm32f429disco 1.. .I have generated with cube mx the fw init for usb host.. When I start my fw with the usb stick connected at least I am able to go inside the routine USBH_Process but when i run again the fw i am not able to stop in the same place.. What i mean is that with the usb stick connected just one time this variable is at value 1 phost->device.is_connectedThe second time i try to stop the before variable is 0Instead when I run the fw without the usb key conncted i never stop in the state HOST_DEV_WAIT_FOR_ATTACHMENTwhat could be wrong ? It seems it is able to see the usb key just once and then something bad is happeningI think the setup from cube mx should be correct but i uploaded here ..Can you please help me ? VBus is enabled because the related led it is working.. Thanks
I'm trying to use the LPTIM4 while in STOPMode2, in a stm32U575ZI-Q microcontroller, as a external pulse counter, and use this pulse value to refresh a LCD screen. For this question I'm only using the usart1 to tell me how many pulses were detected in an one second window when the microcontroller is in STOPMode2. I'm using the LSE clock for the LPTIM4 so I can count in this mode.In the final project the pulses will come at different frequencies, so I'm using a waveform generator configured as a square form wave, with 3Vdc of amplitude, and a frecuence range of 1-500Hz.The problem is that the amount of pulses read by the usart is always lower than the real amount of generated pulses. For example if I'm sending a 10 Hz square waveform, It has to read 10 pulses or similar (probably because of the low speed of the LSE, lower), but it always reads a lot less, like 0 or 1 pulses. The amount of read pulses increases with the frecuence, but not in a "propper way". With 100 Hz it reads 2 or 3 p
Hi,I have just installed STM32CubeIDE Version: 1.12.1 Build: 16088_20230420_1057 (UTC) onto my Kubuntu 22.04.2 LTS (fully updated) system. The install process ended stating that the IDE had been installed correctly.I then wanted to install the package STM32Cube_FW_F4_V1.27.0. So, following the step given by community member RJepp.1 on https://community.st.com/s/question/0D53W00001vE2MNSA0/how-do-i-install-stm32cube-mcu-package-for-stm32f4-series-1271-without-an-internet-connection, I also went to (IDE) Help->Manage Embedded Software Packages. However, in my case, nothing appeared on screen. All that happened was that the Help drop down menu disappeared.I should state that I did this while the IDE was displaying the Information Center<tab>/STM32CubeIDE Home page/screen.In the response noted above it is stated that "1. rename the main pack from "en.stm32cubef4_v1-27-0.zip" to "stm32cube_fw_f4_v1270.zip". I did this.The response noted above also stated that "2. Copy the zip file
Hello All,I am using STM32F777IITx MCU based custom board with STM32CubeMx v4.24.I want to built a application where i want to Read/Write data from/to flash.I am have written a small application where i write 10 bytes of data to flash and also read those 10 bytes from flashMy code Complies properly with no errors, However, when i tried to run the code in Debug mode i am getting the error mentioned below.Whereas i have not changed anything in the Startup script, also i have attached the startup script below # Set flash parallelism mode to 32, 16, or 8 bit when using STM32 F2/F4 microcontrollers # 2=32 bit, 1=16 bit and 0=8 bit parallelism mode monitor flash set_parallelism_mode 2 # Load the program executable load # Enable Debug connection in low power modes (DBGMCU->CR) set *0xE0042004 = (*0xE0042004) | 0x7 # Set a breakpoint at main(). tbreak main # Run to the breakpoint. continueSo please help me to get rid of this issue at the earliest and if i am making an
HAL_IWDG_Init is implemented in file stm32L4xx_hal. Here two statement from the L476 documentation: a) "When the independent watchdog is started by writing the value 0x0000 CCCC in the IWDG key register (IWDG_KR), the counter starts counting down from the reset value of 0xFFF. When it reaches the end ..."b) "As soon as the window value is changed, a reload operation is performed in order to reset the downcounter to the IWDG reload register (IWDG_RLR) value ..."Now my issue: I don't want to use the window feature. Therefore i pass 4095 to the init function. This should - according tho the docu - not influence the counter because the window value isn't change in the register. However, the implementation in the iwdg-hal-file triggers explicitly a reload even if the window value is NOT changed: if (hiwdg->Instance->WINR != hiwdg->Init.Window) { ... the window change case ... not relevant for this discussion } else { /* Reload IWDG counter with
Hello all, I want to use a NucleoU575 board to test an accelerometer sensor.I have written the driver for this accelerometer and currently, without having it connected to the Nucleo, I am trying to check whether my SPI3 Clock is working.This is the code: int main(void){ /* USER CODE BEGIN 1 */ /* USER CODE END 1 */ /* MCU Configuration--------------------------------------------------------*/ /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ HAL_Init(); /* USER CODE BEGIN Init */ /* USER CODE END Init */ /* Configure the system clock */ SystemClock_Config(); /* Configure the System Power */ SystemPower_Config(); /* USER CODE BEGIN SysInit */ /* USER CODE END SysInit */ /* Initialize all configured peripherals */ MX_GPIO_Init(); MX_ADC1_Init(); MX_SPI3_Init(); MX_UCPD1_Init(); MX_USART1_UART_Init(); MX_USB_OTG_FS_PCD_Init(); MX_ICACHE_Init(); /* USER CODE BEGIN 2 */ /
Greetings,What is the reason for not being able to use the SMPS (or the SMPS supplying LDO) option for VOS0 on STM32H745II?VOS0 means the highest voltage, so won't the dissipation on the LDO be the highest?I have been using the PWR_SMPS_1V8_SUPPLIES_LDO option with VOS0 (core running at 480 MHz) and have seen no problem.Can you please tell me what are the possible risks of using this configuration?Best regards,Domagoj
Hi, I have an unsolved issue with SDcard.The project is based on STM32L476, the IDE is Atollic and configuration is made by STM32CucbeMX (as I do with all my designs).Without DMA (no DMA template in FATFS and no configured DMA channels) the SDcard works. When I use the DMA (see screenshot), the very first read operation stucks and after the 30s timeout I get an error. I have investigated inside the code and I have the evidence that there is not any interrupt after the HAL_SD_ReadBlocks_DMA(). This is the cause of the timeout. The function itself returns no error, so it believes the data transfer is running, but it is not.The interrupts are so configured:The CubeMX is version 6.2.1. and the STM32L4 packages are updated.My opinion is that there is some error in libraries or in the Cube generated code. I have seen other (rare) posts about a similar issue suspecting a libray error.This is very imbarassing for me because I have an important design that is waiting for the SD card workin
Hi community.. I am working with stm32f429disco1 (the one with display) I created the code with cube mx and you can find it here in the attachments.. The usb host function it is not working.. I am able to get just at the beginning one connection phost->device.is_connected = 1USBH_StatusTypeDef USBH_Process(USBH_HandleTypeDef *phost) { __IO USBH_StatusTypeDef status = USBH_FAIL; uint8_t idx = 0U; /* check for Host pending port disconnect event */ if (phost->device.is_disconnected == 1U) { phost->gState = HOST_DEV_DISCONNECTED; } switch (phost->gState) { case HOST_IDLE : if ((phost->device.is_connected) != 0U) { USBH_UsrLog("USB Device Connected"); /* Wait for 200 ms after connection */ phost->gState = HOST_DEV_WAIT_FOR_ATTACHMENT; USBH_Delay(200U); (void)USBH_LL_ResetPort(phost); /* Make sure to start with Default address */ phost->device.address = USBH_ADDRESS_DEFAULT; phost->Timeout = 0U; #if (USBH_U
In STM32CubeMX 6.8.1. (and before), there is an option to enter a custom path to the firmware. But, in contrast to what it says, I can only pick an absolute path here. This is unwanted when projects are shared between users/machines. For example, I would like to store the firmware in the same git repository as a number of projects using it. Workaround: patching the generated Makefiles :(KnarfB
Hi everyone. I want to establish an ethernet connection between the laptop and the microcontroller. For this purpose, I have seen many tutorials that first activate units ETH, freeRTOS and LWIP in Cube MX software. But I have noticed a few things:1. It seems that the configurable parameters in the Ethernet section are different for each version. For example, in version 5.6, parameter “PHY address�? can be set, but in version 6.8, there is no such parameter, and parameters “First Tx Descriptor Address�? and “First Rx Descriptor Address�? have been added instead. 2. Apart from the above problem, in the new version 6.8, I set the values of “First Tx Descriptor Address�? and “First Rx Descriptor Address�? to 0x20020120 and 020020000 according to the Reference manual stm32f7xxx , but I still encounter problem “Destination Host Unreachable�? when pinging the laptop and the microcontroller.It should be noted that I generate the code in keil uvision 5 software.Thank you for tel
I try to measure frequency and duty of a PWM input signal with an STM32G474. For this i have selected the combined channels option "PWM input on CH2" for Timer 15 in CubeMX. The measurement works well, as long as the input signal is not to slow. When the input frequency drops below 1300Hz, i get wrong frequency values. Obviously this is because the 16 Bit timer runs over: I use the 170MHz system clock divided by 2. dividing 85.000.000Hz by 0xFFFF results in about 1296Hz. When i apply a frequency of say 1200Hz, the time between two rising edges used for period detection is more than 0xFFFF timer ticks. So the timer counter wraps around and I get only the 16bit fraction of a number slightly above 0xFFFF, corresponding to a very short period or respectively a very high frequency. Of course the measurement range can be controlled by adjusting the timers prescaler. The problem is, that I need a criterion if the measurement was valid, of if overrun had occurred.In my understanding, the PWM i
..
Hello everybody!LWIP has a possibility to assign new port number every time after reboot the device. There is define in cc.h#define LWIP_RAND() ((u32_t)rand())But it does not work properly. Every time after reboot I get same port number. For solve this, I defined in lwipopts.h:#define LWIP_RAND() ((u32_t)(HAL_RNG_GetRandomNumber(&hrng)%16384+49152))But compiler shown me warnings about redefine LWIP_RAND(). And I was forced to change the code in cc.h. CubeMX will overwrite this changes at next code generation. How to fix it?
I use MAX9611 to measure current. It has 2 register to read current. 12 bits divides 2 bytes. MSB(8 bits) and LSB(4 bits). I tried to read only MSB but I couldn't, Can anyone help me? Note: there is no externall pull up res, I configure an internal pull up.I write a simple code. HAL_I2C_IsDeviceReady return HAL_OK. But when I debug HAL_I2C_Mem_Read returns nothing uint16_t deviceAdress = 0xE1; uint16_t regAdress = 0x02; uint8_t CurVal; void isDeviceReady() { HAL_StatusTypeDef status; status = HAL_I2C_IsDeviceReady(&hi2c1, deviceAdress, 1, 50); if(status == HAL_OK) { return 1; } else return 0; } while(1) { isDeviceReady(); HAL_GPIO_WritePin(ENABLE_M_GPIO_Port, ENABLE_M_Pin, 1); // Enables mosfet HAL_I2C_Mem_Read(&hi2c1, deviceAdress, reg_adress, 1, &CurVal, 1, 100); }https://eu.mouser.com/data
I am currently attempting to build code in simulink for a GIGA R1 project I have. However when setting the ioc file up in CubeMX I am unable to change the init functions to be global. Any help would be appreciated. Thanks!
Are the LL drivers for RCC ready for production code (I plan to use the STOP mode using the LL drivers ...)?There seems an issue with stm32cubemx 6.8.0 generated code for the NUCLEO L476 dev. board in SystemClock_Config() when selecting RCC LL drivers: it blocks in a while loop. The code is as follows:__STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_VOS(void) { return ((READ_BIT(PWR->SR2, PWR_SR2_VOSF) == (PWR_SR2_VOSF)) ? 1UL : 0UL); } void SystemClock_Config(void) { LL_FLASH_SetLatency(LL_FLASH_LATENCY_0); while(LL_FLASH_GetLatency()!= LL_FLASH_LATENCY_0) { } LL_PWR_SetRegulVoltageScaling(LL_PWR_REGU_VOLTAGE_SCALE1); while (LL_PWR_IsActiveFlag_VOS() == 0) { } ...LL_PWR_IsActiveFlag_VOS() returns 1 while the regulator is adjusting itself according to the data specification:Bit 10 VOSF: Voltage scaling flagA delay is required for the internal regulator to be ready after the voltage scaling has beenchanged. VOSF indicates that the regulator reached the voltage level defin
Hi, I'm trying to make a c++ project for STM32CubeIDE using the STM32CubeMX.However there doesn't seem to be any c++ option, is there something I'm missing or is the software just not made for it?
With RTOS the CubeMX generated code creates threads, which do the reception of packets and link state management. Without RTOS the example code does the lwIP processing in the main infinite loop. But, when CubeMX generates lwIP application without RTOS, the main infinite loop is left empty and therefore the network code is completely dysfunctional. The issue seems to be present for all series with lwIP support.
The manual for the STM32F415 says that the BOOT1 signal "...is shared with a GPIO pin", but it doesn't say actually which pin. CubeMX does not show it either. I've seen online that at least for some other MCU's in the F4 range, BOOT1 is mapped on PB2. So does the STM32F415 also have the BOOT1 mapped on PB2?
I use ADC0 and ADC1 of STM32F334,I put a resistor of 1K between amplifier and ADC channel, configuring every IO setting by using CubeMX, but I find something strange, there is a pulse on ADC input pin,while amplier output is flat. And the result reading from ADC is about 0.5 V above its actual voltage, which is exactly the pulse voltage,when the input voltage goes high, the ADC pin pulse goes high,but it seems that there is always 0.5 V high. it can be seen from the image below, yellow is ADC0, blue is ADC1.ADC1 pulse is later than ADC0. Why is this happening ,how to solve it
HiI get a hardfault as soon as the HALL sensor (which is connected & set up using CubeMX & EXTI GPI(O)) gets an interrupt.I have debugged the code to the part where I can safely say that the hard fault only occurs when the " __HAL_TIM_SET_COUNTER(&htim2, 0);" is involved.EXTI is working properly, that's not my problem, my problem is the hardfault I get when trying to reset the timer / do anything with the timer.My Question now is, do you spot any mistake in the code below that could cause the Hard Fault?If no, how could I debug this?void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) { if ((GPIO_Pin == (Hall1_IN_Pin || Hall2_IN_Pin)) && e_ProgramState == Menu) { HAL_TIM_Base_Start(&htim2); } if(GPIO_Pin == Hall2_IN_Pin) { __HAL_TIM_SET_COUNTER(&htim2, 0); } }Best regardseditProblem was solved using the Fault Analyzer in CubeIDE where I found out I had a division by Zero which caused the HardFault, nothing to do with the EXTI or Timer
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.