Ask questions on STM32CubeMX. Discuss code generation and configuration challenges, among other topics.
Most recent activity
Hey guys,i did setup my project using Cube MX, configured all outputs and inputs.Generated the Startupcode with CubeMX.Directly after start of main() MX_ADC1_Init() is called.I did setup the Temp Sensor as well/** Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time. */ sConfig.Channel = ADC_CHANNEL_TEMPSENSOR; sConfig.Rank = 11; if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK) { Error_Handler(); }Howeverassert_param(IS_ADC_CHANNEL(sConfig->Channel));fails. So i was wondering. is there a Bug in the IS_ADC_CHANNEL Macro or am I missing something?I'm using the latest HAL (STM32F4 Cube V1.24)
I'm using STM32CubeMX 5.0.1 for creating projectsWhile configuring GPIO using configuration window the properties windows on the bottom of selected GPIO pin overrides the visibility of other GPIO pins at the bottom on configuration window It is not scrolling to view, but we need to select different operation to make all GPIO visibleI'm attaching the screen shots of GPIO Config window without Properties and with PropertiesIt would be better to make gpio config with scrolling to view the bottom GPIO while property window is open
Hi all,Just upgrade to CubeMX v5.1 (from 4.xx) and just to give you feedback:Code Generation Error:"The Code is successfully generated under PATH but MDK-ARM V5project generation have a problem" This is due to "[" and "]" in my PATH. This was not an issue with previous version (and IMHO should not be an issue anymore in 2019)Display:To avoid text being not correctly readable I have to set font size to larger. But this makes button very big. Not sure if I just get used to previous version but I didn't remember such poor GUI. Embedded software package:Going to "Install or remove embedded software packages" selecting the latest package (STM32Cube MCU Package for STM32L0 Series 1.11.2) and trying to install gives error stm32cube _fw_l0_v1112.zip "timeout". I tried manually by downloading on ST site the fw package. For me it's https://www.st.com/en/embedded-software/stm32cubel0.html See two ".zip" to download. en.stm32cubel0.zip installed correctly but en.patch_cubel0.zip don't (m
#define LL_RTC_MONTH_JANUARY (uint8_t)0x01 /*!< January */ #define LL_RTC_MONTH_FEBRUARY (uint8_t)0x02 /*!< February */ #define LL_RTC_MONTH_MARCH (uint8_t)0x03 /*!< March */ #define LL_RTC_MONTH_APRIL (uint8_t)0x04 /*!< April */ #define LL_RTC_MONTH_MAY (uint8_t)0x05 /*!< May */ #define LL_RTC_MONTH_JUNE (uint8_t)0x06 /*!< June */ #define LL_RTC_MONTH_JULY (uint8_t)0x07 /*!< July */ #define LL_RTC_MONTH_AUGUST (uint8_t)0x08 /*!< August */ #define LL_RTC_MONTH_SEPTEMBER (uint8_t)0x09 /*!< September */ #define LL_RTC_MONTH_OCTOBER (uint8_t)0x10 /*!< October */ #define LL_RTC_MONTH_NOVEMBER (uint8_t)0x11 /*!< November */ #define LL_RTC_MONTH_DECEMBER (uint8_t)0x12 /*!< December */LL_RTC_MONTH_OCTOBER (uint8_t)0x10 /*!< October */LL_RTC_MONTH_NOVEMBER (uint8_t)0x11 /*!< November */ LL_RTC_MONTH_DECEMBER &nb
I’m using:CubeMX v5.0STM32F105RCTxHAL_API_version 1.6.1And I have a compilation errors.This happens because CubeMX generates a CAN_InitTypeDef structure for new libraries (version 1.7.0).See what should be the structure for libraries 1.6.1I noticed something else, errors are generated only under EWARMPlease checking this.Regards, Dmitrij Budejkin
Hello GuysI am asking you kindly your help.I am trying to read register data from the LSM6DS3 IMU sensor from STM using SPI. I succeeded reading the value 0x69 from register WHO_AM_I using Arduino.Now I am stuck when trying to do it with STM32 micro-controller.Reading data sheet I concluded the following specs: Max SCLK 10MHz, 8 bits word, MSB first, CPOL high, CPAHSE 2 Edge (sampling on trailing edge).I think I am setting the stm32 micro-controller like so but I am not able to read any data from register WHO_AM_I .The following code is the reading process, followed by the SPI init routine.the problem is when I track the evolution of MOSI line and SCLK by doing a transmit then receive, I am getting the reading in picture 1 using oscilloscope, it look different than when I use the "HAL_SPI_TransmitReceive" as shown in picture 2. in the case of transmit then receive I can read 0x8F on oscilloscope but also an other byte 0x00 which I dont know where it i
Just trying to set PWM with DMABuffer which I try to use as duty cycleuint16_t BUF_DMA[6] = {3, 4, 2, 7, 9, 1}; PWM is started by buttonHAL_TIM_PWM_Start_DMA(&htim1,TIM_CHANNEL_4,(uint32_t*)&BUF_DMA, 6);Output I getI can't understand why BUF_DMA[3] and BUF_DMA[5] are doubling and tripling.
In some cases the USER sections are not sufficient to make some needed modifications to the HAL drivers. When modifying a configuration in STM32CubeMX, it would be useful to be able to flag drivers so that they are not overwritten when the code is generated.Obviously, one can work around the current scheme by inserting code in the IRQ handler call, and include other routines with names that do not conflict with the HAL driver names, but that becomes a bit of a mess, especially when there is only minor change called for in the HAL driver.
Hi all,I am having troubles mounting a USB using the "f_mount" function in the fatfs library. My usb does mount but only after many attempts, using a simple counter I have found it to be 81, every single time I run the code it is the same amount of attempts.Once mounted it works flawlessly and as I expect, however I am struggling to understand why it is taking so many attempts to mount. I have a "dirty" function to test writing to a file, shown below:void USB_WriteTest(void){ // Attempt to mount usb if(f_mount(&USBHFatFS, USBHPath, 1)==FR_OK){ HAL_Delay(100); HAL_UART_Transmit_IT(&huart3, (uint8_t*)"Mount Success...\r\n", strlen("Mount Success...\r\n")); //Name of file being created char myFileName [] = "config.txt"; // Open a file to write to if(f_openAppend(&USBHFile, myFileName)==FR_OK){ HAL_Delay(100); HAL_UART_Transmit_IT(&huart3, (uint8_t*)"Open Success...\r\n", strlen("Open Success...\r\n"
I have the stm32f429 discovery board and I'm experiencing a conflict between the usb otg hs and the i2c3. I use the cdc usb library which when initialized on it's own works fine as a virtual com port and I can communicate in windows. When any other communication peripheral is initialized such as I2C or USART, the usb vcp is still visible in windows but I cannot connect with putty or realterm. Here is the USB init and I2C init code. When I2C is commented out, the communication works fine:void MX_USB_DEVICE_Init(void) { /* Init Device Library, add supported class and start the library. */ if (USBD_Init(&hUsbDeviceHS, &HS_Desc, DEVICE_HS) != USBD_OK) { Error_Handler(); } if (USBD_RegisterClass(&hUsbDeviceHS, &USBD_CDC) != USBD_OK) { Error_Handler(); } if (USBD_CDC_RegisterInterface(&hUsbDeviceHS, &USBD_Interface_fops_HS) != USBD_OK) { Error_Handler(); } if (USBD_Start(&hUsbDeviceHS) != USBD_OK) { Error_H
By using timer I want to generate a wave of 27Mhz frequency. Present time I can generate only 13.48khz frequency wave. My timer settings are below please tell me how can I generate it.static void MX_TIM2_Init(void){ TIM_ClockConfigTypeDef sClockSourceConfig; TIM_MasterConfigTypeDef sMasterConfig; TIM_OC_InitTypeDef sConfigOC; htim2.Instance = TIM2; htim2.Init.Prescaler =27; htim2.Init.CounterMode = TIM_COUNTERMODE_UP; htim2.Init.Period = 1000; htim2.Init.ClockDivision = TIM_CLOCKDIVISION_DIV4; htim2.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_ENABLE; if (HAL_TIM_Base_Init(&htim2) != HAL_OK) { _Error_Handler(__FILE__, __LINE__); } sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL; if (HAL_TIM_ConfigClockSource(&htim2, &sClockSourceConfig) != HAL_OK) { _Error_Handler(__FILE__, __LINE__); } if (HAL_TIM_OC_Init(&htim2) != HAL_OK) { _Error_Ha
I am using STM32F103C8T6 and STM32CubeMX and TrueSTUDIO for development purpose.I am trying to get interrupt on rising edge and in ISR I wrote LED blinking code.I gave high input for rising edge detection but not getting LED blink.My code as follows...static void MX_GPIO_Init(void) { GPIO_InitTypeDef GPIO_InitStruct = {0}; /* GPIO Ports Clock Enable */ __HAL_RCC_GPIOC_CLK_ENABLE(); __HAL_RCC_GPIOA_CLK_ENABLE(); __HAL_RCC_GPIOB_CLK_ENABLE(); /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(LED_GPIO_Port, LED_Pin, GPIO_PIN_RESET); /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(SD_CS_GPIO_Port, SD_CS_Pin, GPIO_PIN_SET); /*Configure GPIO pin : LED_Pin */ GPIO_InitStruct.Pin = LED_Pin; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM; HAL_GPIO_Init(LED_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pin : SD_CS_Pin */ GPIO_InitStruct.Pin = SD_CS_
I was unable to retrive data from RTC DS3231 using I2C.And I am perfectly getting from ADXl325 accelerometer using I2C.RTC DS3231 works perfectly with arduino mega 2560 but problem getting data for STM32F103C8T6.Dont know why?I am using STM32CubeMX and TrueSTUDIO
Hello, friends!I configured the project for STM32L011 Nucleo board for read ADC input and I noticed that some of frequency devider options were greyed out for some reason).However I tried to change this setting in the c file with 100% success:At least the code worked perfectly as was expected.So the question is: why Cube greyed out this options while being applicable? Is there any method to get the information on why option is grey?
Hello,I am facing trouble in sending data out from STM32F407VG Discovery board (connected to base board) using UART6 (J1 and J2 jumpers are connected). Connected the Tx pin of RS232 port on baseboard to PC COM port Rx pin and sending data periodically. I have enabled DMA on the board and program is in FreeRTOS.Using baud rate 115200 at both ends, 8 bits no parity, 1 stop bit.(Using code generated using CubeMX 5.1.0 and added my code on top of it) Using Atollic TrueSTUDIO® for STM32, Built on Eclipse Neon.1a. Version: 9.0.1 Build id: 20180420-1214On the receiving side, have a blocking receive call which waits for each byte (Linux) as below which is tested with some other program and working: read(fd,arg_buf,1); // arg_buf is char array pointerThe receiving side remains blocked not receiving any data. That is the issue.Checked similar issues on forum to no avail.Code brief (STM32 code on FreeRTOS):-------------------------------------#include "main.h" #include "c
..
Hi guys,I have a question about my project with STM32L4R5ZIT6.I want to use the SDMMC1 peripheral together with the FAT-file system to write some logging data on a sd card.After several failed tries to write a test-file on the sd card with the FAT functions f_open...f_write I think there is a problem with the lower level driver (sdmmc1).I searched for some solutions in this community.There I found some topics near the same I have.(https://community.st.com/s/question/0D50X00009XkWAsSAN/sdmmc-on-stm32-l476-l4)(https://community.st.com/s/feed/0D70X000006SpXHSA0)They had attached some configuring files for the CubeMX and inside them there was a possibility to configure the dma working together with the sdmmc1 peripheral. In my CubeMX project there is no possibility to link the dma and the sdmmc1 peripheral.Is there any possibility to get this working?I don't want to code all from the datasheet so maybe there are some examples or something.Kind regards,felix
In my code I use I2C. But when I reset the MCU with my debugger (I-jet from IAR) the I2C peripheral indicates BUSY as soon as it is initialized by the MX_I2C1_Init() function.But if I add the following I2C reset in the MX_I2C1_Init() function before the HAL_I2C_Init(&hi2c1) the BUSY flag is cleared: I2C1->CR1 |= I2C_CR1_SWRST; I2C1->CR1 &= ~I2C_CR1_SWRST;Is this a CubeMX bug?
Hello,I have made a project with FreeRTOS 10.0.1.However there is a problem: when I try to call a function with ‘ISR’ suffix from interrupt service routine the macros configASSERT catches mismatch between priority that ISR has and priority that is permissible.The project was generated by CubeMX v5.1.0. The LIBRARY_LOWEST_INTERRUPT_PRIORITY is set to 15, the configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY is set to 5. Interrupt that is served by the ISR has priority 8. It’s seems that parameters are correct.I have excluded the checking by configASSERT and the code works properly now, but I am doubting, is it correctly? Why macros gave an error?Victor
I have a project I've migrated from the STM32F407 to the STM32F405. I started by creating a new project in STM32CubeMX with the STM32F405 selected, importing my existing project, and updating the pin assignments. I was able to regenerate the project in STM32CubeMX, but encountered issues in TrueStudio when attempting to build. It seems the issues all stem from the fact that the old references to the previous MCU (STM32F407) were not stripped out of the project during the regeneration process. Specifically, the "STM32F407xx" was still defined under "C Compiler - Symbols", and caused redefinition issues during build. Additionally, the linker script file didn't appear to be updated. I was able to fix the issues manually, but I think these should be addressed in an updated version of STM32CubeMX.
Hello All,I updated to CubeMX 5 and use STM32F4 USB CDC.After update my programm crashes directly after init.This is because the USB driver calles directly into ErrorHandler when USB is not connected.The ErrorHandler does a while(1) forever loop.Why did STM changed that behaviour?As in the ErrorHandler itself I have no possibility to test where it comes from and react according to the problem. The ErrorHandler is generic and global and should only be called on severe problems.But a not connected USB interface is not "severe" but is a generic use-case.What I currently do is to modify the ErrorHandler to return immediately.I think this behaviour now is not good solution.There should be a parameter in the call to ErrorHandler, so that ErrorHandler can react properly to the problem.My 2ct.Adib.
Hey,I´m confused why i can not use Pin PD2 on Cube MX on the Nucleo Board L433RC even though it should actually exist because it exist when you select another STM32L433.Without that Pin, i can´t use SDMMC. If i select for example the STM32L433RCTx, there is the Pin PD2. But if i try to use it with the Nucleo it wont work.Any suggestions?
With the new 5.1.0 version of CubeMX, the SAI synchronization seems to be broken.I'm using a STM32F765VGTx controller.I have attached my SAI configuration as a screenshot. With CubeMX 5.0.1 this was no problem and the correct code was generated. However, after the update, my configuration is broken and I can't select the "Synchronous Slave" configuration.Am I doing something wrong or is this broken in the new CubeMX version?I have the same behavior, when I create a completly new project.
Hi,I am working on STM32L476G-DISCO, and I want to interface it with Arduino uisng SPI, but I found that this STM all SPI (SPI1,SPI2 and SPI3) PIN is not on I/O PIN, so how I interface it with Arduino using SPI??
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.