Ask questions on STM32CubeMX. Discuss code generation and configuration challenges, among other topics.
Most recent activity
Posted on October 14, 2016 at 02:43STM32CubeMX generates MX_GPIO_Init() which calls HAL APIs in following order,static void MX_GPIO_Init(void){ __HAL_RCC_GPIO_CLK_ENABLE(); ... HAL_GPIO_Init(); ... HAL_GPIO_WritePin();This calling order makes a problem when the pin should output high level from the beginning. Because the default output level is low, the pin outputs low between HAL_GPIO_Init() and HAL_GPIO_Write().My board has a sub CPU whose RESETn pin is connected to GPIO of STM32F7. Every time MX_GPIO_Init() is called, the sub CPU is reset because of this calling order.Calling APIs in following order fixes the problem. __HAL_RCC_GPIO_CLK_ENABLE(); ... HAL_GPIO_WritePin(); // call WritePin() before Init() ... HAL_GPIO_Init(); #stm32cubemx
Anyone Helps me!Anyone please show the basic USART's tx/rx code. Or check my CubeMX Project File.HAL's USART won't work.it code is generate from STM32Cube.There is two USART, one(huart2) everytime send data to STM, another(huart1) everytime wait comming data.But they won't work. For example, I wrote follow code.```cvoid sio_puts(char *str){ HAL_UART_Transmit(&huart1, (uint8_t *)str, strlen(str), 1000);}..int main(void){ ... MX_USART2_UART_Init(); MX_USART1_UART_Init(); ... sio_puts("SerialTest\r\n"); ... while(1){...}}```Params that baud, bit, and etc are correct setting.Anyone would you show the basic code to use USART.Maybe there is wrong with CubeMX settings.I'll attach the .ioc file, so please check it.Thanks
As STM32CubeMX 4.25.1 is not compatible with <X-CUBE-SPN14> Stepper motor driver software expansion for STM32Cube package, i tried to include manualy the Driver to my project. Then, i copy the <BSP> repertory from <en.x-cube-spn14\...\Drivers> to my project Drivers repertory and include it to my Keil's project. i also configurated the Bord pins and Timer (2 and 3) like described in user manual <UM2300> pages (8, 12, 13). when I compile the project, I have no Warning or Error. I am using a bipolar step Motor with a step angle of 1,8 degree.when i run the program, the step motor run Forward for 2 run an then Backward for 2 Run and Blocks by runing indefinitely in an <HAL_Delay() > function.by debugging, i found that the problem occurs on instruction <BSP_MotorControl_SetStopMode(0, HIZ_MODE); at line 306 of main.c file> when a change parameter "HIZ_MODE" to "STANDBY_MODE " the program still occurs. but if i change "HIZ_MODE" to "HOLD_MODE" the Program
Hi, I'm using STM32F746ZG Nucleo board, Atollic Truestudio and STM32CubeMX for generate source code. I'm trying for a couple of days to configure Update Event of TIM6 to trigger ADC3 .There isn't problem with TIM1 triggering ADC3 (Edit Line 104: hadc3.Init.ExternalTrigConv = ADC_EXTERNALTRIGCONV_T1_TRGO;) but if triggering from any APB1 timer (TIM2, TIM4, TIM6...).Here's my main code (I've deleted irrelevant source).I would appreciate it if someone could help or guide me, thank you.int main(void) { /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ HAL_Init(); /* Configure the system clock */ SystemClock_Config(); /* Initialize all configured peripherals */ MX_GPIO_Init(); MX_ADC3_Init(); MX_TIM1_Init(); MX_TIM6_Init(); /* USER CODE BEGIN 2 */ HAL_TIM_Base_Start(&htim1); HAL_TIM_Base_Start(&htim6); // HAL_ADC_Start(&hadc3); HAL_ADC_Start_IT(&hadc3); /* USER CODE END 2 */ /* Infinite loop */ while
I have a problem with a new generated code from CubeMX 5 (latest version), when compiling it with the latest version of OpenStm32. I am using SPI, I2C, UART, ADC-IN10, RTC and ext. 32kHz QuarzHere are some of the errors I receive:Description Resource Path Location Type'uint16_t' undeclared here (not in a function); did you mean '__uint16_t'? arm_common_tables.h /E2xx/Drivers/CMSIS/Include line 90 C/C++ Problem#error "Define according the used Cortex core ARM_MATH_CM7, ARM_MATH_CM4, ARM_MATH_CM3, ARM_MATH_CM0PLUS or ARM_MATH_CM0" arm_math.h /E2xx/Drivers/CMSIS/Include line 314 C/C++ Problemexpected ')' before numeric constant arm_common_tables.h /E2xx/Drivers/CMSIS/Include line 90 C/C++ Problemexpected '=', ',', ';', 'asm' or '__attribute__' before 'arm_bilinear_interp_f32' arm_math.h /E2xx/Drivers/CMSIS/Include line 6752 C/C++ Problemexpected '=', ',', ';', 'asm' or '__attribute__' before 'arm_bilinear_interp_q15' arm_math.h /E2xx/Drivers/CMSIS/Include line 6892 C/C++ Problemexpected '
Am Working with STM32L4R9 Discovery Kit Trying to connect our module to STM module with FAN-OUT Expansion Board (using SPI interface)Generated the code from STMCUBE with following specsSPI Pin connectionsMOSI----PIN_15/GPIOBMISO----PIN_14/GPIOBCS--------PIN_6/GPIOBSCK------PIN_13/GPIOBWithout DMANSS signal softwareSPI data exchange not happening (DR is always zero)Can you pls share the default SPI codeSuggest me about CS how to configure
Hi all,I am trying to use the virtual COM port in the STM32L432KC Nucleo to send and receive data from the PC using UART. I have managed to transmit data to the computer succesfully but when I try to receive data, then it doesn't work. I am trying with a simple program and I have used STM32CubeMX to generate the code. I have set it as follows:USART2 (baud rate 115200)Enabled USART2 global interruptUSART2_RX and USART2_TX added (Circular mode, Increment Address Memory)The code is the following: HAL_UART_Receive_DMA(&huart2, rxData, 11); while (1) { HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_3); HAL_Delay(200); }And in the Rx complete callback function I am transmiting the data received:void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) { HAL_UART_Transmit(&huart2, rxData, 11, 10); }I have executed it in debug mode and watched the rx buffer but it doesn't receive anything.
I generated a simple project to create a base for a project including a web server on STM32F429 Nucleo board.The CubeMX-generated code fails to build.This morning, within CubeMX plug-in I downloaded and installed the latest pack and CubeMX, but the Help->About still says version 5.0.0 STMCube v1.0. What version am I actually running?I've attached the IOC so you can easily generate code and reproduce the problem.Please let me know how to get a working example!Thanks, Best Regards, Dave
Posted on February 19, 2018 at 08:44Hi ,First of all,i want to thank ST for providing and developing such useful tools for developers.Found couple of bugs in STM32CubeMX v 4.24 U(S)ART code generation when using LL Drivers During my work ,I wrote an custom bootloader and decided to use LL Drivers generation in CubeMx instead of using HAL Drivers.And found some bugs:I worked on STM32f302xC MCU : 1. When enabling U(S)ART other than USART1,for ex. UART4,UART5 , the CubeMX does not generates call to some functions like :LL_USART_DisableOverrunDetect(UART4);LL_USART_ConfigAsyncMode(UART4); // criticalLL_USART_Enable(UART4);//criticalbut for USART1 it does.2.When in CubeMX for some U(S)ART ,I set OverRunDetect to disable for some UART(ex. UART4 also on USART1),the CubeMX generates LL_USART_EnableOverrunDetect(UART4) function and vise versa .3.In CubeMX,if I chose USART's clocksource as HSE with PLL(I thing is nevermind) ,in boudrate calculations the source
Hi. I need to create USB MSC Device on STM32F407. I use CubeMX for create project. When I compiled the project with MSC_MEDIA_PACKET = 512 windows did not see the mass storage device, then I changed MSC_MEDIA_PACKET = 256 and windows saw the mass storage device and also offered to format it. I also did projects on stm32f0 and stm32f3 with MSC_MEDIA_PACKET = 512, everything worked without problems for them, Windows found the device and offered to format the disk. How to do when define MSC_MEDIA_PACKET = 512 for Windows to see it?
Hi, I have updated CubeMX to version 5.0.1 and after this I noted an issue in Micro Vision 5 which I have no idea how to resolve. I am new in STM32 world, just have a couple of months since started to learn.I use to put user labels on GPIOs, it is much easier for me to handle things like this. Until this CubeMX update everything was working fine. Now I get an error for the labeled GPIOs: "use of undeclared identifier "<GPIO label/port>".I need some help with this issue. Thank you in advance. I would add a screen shot but I didn't figure out how to do it.
Regarding to the question posted here:https://community.st.com/s/question/0D50X00009XkaG2SAJ/using-stm32fcubemx-hal-drivers-for-uart-rx-with-unknown-size-dataI have the exact same problem using a STM32-L432KC. Is there any sample code showing how to implement a Receive Timeout Interrupt handler using HAL?Thanks in advance
Hello!I use CubeMx 5.0.1, my project based on STM32F413 cpu and was migrated from previous version of Cube. I need to set ADC1 to perform multiple regular conversions. This is what Cube shows me:You can see two entries marked Rank1. How can it be?And if I generate the code, this is a fragment of code what I get: hadc1.Instance = ADC1; hadc1.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV8; hadc1.Init.Resolution = ADC_RESOLUTION_12B; hadc1.Init.ScanConvMode = ENABLE; hadc1.Init.ContinuousConvMode = DISABLE; hadc1.Init.DiscontinuousConvMode = DISABLE; hadc1.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE; hadc1.Init.ExternalTrigConv = ADC_SOFTWARE_START; hadc1.Init.DataAlign = ADC_DATAALIGN_RIGHT; hadc1.Init.NbrOfConversion = 9; hadc1.Init.DMAContinuousRequests = ENABLE; hadc1.Init.EOCSelection = ADC_EOC_SEQ_CONV; if (HAL_ADC_Init(&hadc1) != HAL_OK) { Error_Handler(); } /**Configure for the selected ADC regular channel its corresponding rank in the sequencer a
How do I change MCU in STM32CubeMX project?I have tried to create a new project and the use the "import project". But it does not import any user code from the c-files.Could someone reply the steps needed to also import the user code.
HiTimer make me crazy !!!Is there a simple formula to compute prescaler and ARR for a defined Delay and Pulse ?I have a STM32F411 Nucleo at 100 MHz. For the Timer2, APB1 is at 50 MHz.I want a delay of 10 ms with a pulse of 50 us. ThanksLionelNote : why CubeMX has not a tool for that and in general to compute prescaler and ARR for a any period ?
My goal: I'm trying to read two ADC pins with 12 bit resolution and output the values through DMA over USART.I can see that the ADC values are being read in the debug tab in STM32CubeMX. I can "talk" over USART to my serial capture program by having it print "Hello World". However, I cannot get the ADC values to be sent over USART. Part of the problem might be that I need to convert a uint32 to a uint_8 for the USART, although I thought had solved that (with help), but now I'm not so sure. I have a lot of commented out sections of code but would really appreciate someone advice on what I'm doing wrong. The Baud rate on the STM32 and serial monitor are both at 115200.I attached a zip but I think the issue is likely with the UART transmit part of code:uint32_t adcVal[2]; /*array to store ADC values*/ HAL_UART_Transmit(&huart2,(void *)adcVal, sizeof(adcVal),10); // Sends 4 bytes, binary data
I'm using STM32f401re nucleo board and Truestudio IDE. I am only concentrating on ADC peripheral. I want to measure the number of clock cycles consumed for single ADC conversion. I am willing to measure conversion time for 6, 8, 10, 12 bit resolution ADC. Can somebody suggest how can do this? I tried to use ADC in interrupt mode and timer. Then I used HAL_ADC_ConvCpltCallback function to store the counter value but this did not work for me.
..
Hello,I'm working with an STM32F401RE (on a Nucleo), and I have some problem with the TIMER frequency. a) The frequency APBx is 84Mhz, and I want a 500Hz PWM frequency on TIM3.I set prescaler to 167 (168-1) and period to 999 (1000-1), is it correct ? b) I also want a 500uS interrupt from TIM1 and i set prescaler to 0 and period to 41999 (42000-1), is it correct ?In both case the frequency isn't the expected value (checked with oscilloscope), so I was wondering if it's my fault of that is due to the accuracy of the internal oscillator.ThanksRiccardo
If, as the basis of time, I use a different timer than the systick in the hal_timebase_tim file in the ruler uwTimclock = HAL_RCC_GetPCLK2Freq ();there is an error. Should uwTimclock = HAL_RCC_GetPCLK1Freq ();
It appears that v5.0.1 is assigning the wrong firmware package on import.I start a new CubeMX project using the MCU Selector and pick an F103c8. Then go to file->Import and select a .ioc for an existing f303 project. When I generated code for the basic project it would not compile because of lot's of missing files. Looking at the Project Manager page I see that the Firmware package name has been changed from the F1 package which is appropriate for the F1 MCU I've chosen, to the F3 package from the project I imported.I edited the project.ioc file to have it point to the F1 firmware package, generated the code and it all compiled with no complaint. It looks like there's a bug in Import. The Firmare Package should match the selected MCU, not the imported project.Dave
#include "main.h" #include "stm32f4xx_hal.h" /* USER CODE BEGIN Includes */ /* USER CODE END Includes */ /* Private variables ---------------------------------------------------------*/ CAN_HandleTypeDef hcan1; /* USER CODE BEGIN PV */ /* Private variables ---------------------------------------------------------*/ CAN_TxHeaderTypeDef TxHeader; CAN_RxHeaderTypeDef RxHeader; uint8_t TxData[8]; uint8_t RxData[8]; uint32_t TxMailbox; /* USER CODE END PV */ /* Private function prototypes -----------------------------------------------*/ void SystemClock_Config(void); static void MX_GPIO_Init(void); static void MX_CAN1_Init(void); /* USER CODE BEGIN PFP */ /* Private function prototypes -----------------------------------------------*/ static void CAN_CONF(void); /* USER CODE END PFP */ /* USER CODE BEGIN 0 */ /* USER CODE END 0 */ /** * @brief The application entry point. * * @retval None */ int main(void) { /* USER CODE B
I am using STM32CubeMX v5.0.1 on Windows10. I am trying to set up the B-L475E-IOT01A board's SPI2 port to communicate with a SPI based PMOD device. The user manual for the board shows SPI2 to be the port that connected to PMOD. STM32CubeMX will not let me set up the SPI2 port at all. It has the red circle with a line and only allows the mode to be "Disabled". USART2 is disabled. There does not appear to be a method for setting the GPIOs into the right alternate functions. What settings am I missing to make SPI2 operational? I have attached my .ioc file if anyone has an idea on this.Thanks!
Autogenerated code for STM32L433RB with LL takes care about skipping re-initializing RTC when first backup register has value 0x32F2. It's OK, works correctly - but this is totally useless because in SystemClock_Config RCC backup domain always reseted.What's about adding an option for this to CubeMX to reset or kepp RTC backup SRAM?
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.