Ask questions on STM32CubeMX. Discuss code generation and configuration challenges, among other topics.
Most recent activity
I am trying to understand how to configure a custom GPIO pin via the CubeMX/CubeIDE. I am using the STM32H7B3I-EVAL. Through the CubeMX, I am trying to assign PA13 to a GPIO (in output mode). I enabled PA13 via the CubeMX without issue. Now I want to configure the GPIO in the CubeIDE and use it. In the GPIO Example for my STM32H7B3I-EVAl board, they configure it as follows: /* Configure IO in output push-pull mode to drive external LEDs */ gpio_init_structure.Mode = GPIO_MODE_OUTPUT_PP; gpio_init_structure.Pull = GPIO_PULLUP; gpio_init_structure.Speed = GPIO_SPEED_FREQ_VERY_HIGH; gpio_init_structure.Pin = GPIO_PIN_13; HAL_GPIO_Init(GPIOG, &gpio_init_structure);What I don't understand is how they knew that gpio_init_structure.Pin = GPIO_PIN_13. How did the example know to use PIN_13? How do I know which pin PA15 should be?
I am using below code;void HAL_UARTEx_RxEventCallback(UART_HandleTypeDef *huart, uint16_t Size){ if (huart->Instance == USART3) { oldPos = newPos; // Update the last position before copying new data // If the data is large and it is about to exceed the buffer size, we have to route it to the start of the buffer // This is to maintain the circular buffer // The old data in the main buffer will be overlapped if (oldPos+Size > MainBuf_SIZE) // If the current position + new data size is greater than the main buffer { uint16_t datatocopy = MainBuf_SIZE-oldPos; // find out how much space is left in the main buffer memcpy ((uint8_t *)MainBuf+oldPos, RxBuf, datatocopy); // copy data in that remaining space oldPos = 0; // point to the start of the buffer memcpy ((uint8_t *)MainBuf, (uint8_t *)RxBuf+datatocopy, (Size-datatocopy)); // copy the remaining data newPos = (Size-datatocopy); // update the position } // if the current position
I am using a STM32H723zg board for a project and I must read analog signals so I am using one 16-bit ADC. Based on the datasheet of this microcontroller serie, the maximum ADC clock frequency is 50 MHz for BOOST = 11.However when I am configuring the ADC clock frequency with the STM32CubeMX, the ADC clock is automatically set with 96 MHz with no error. I would like to know if this ADC clock frequency configuration (96 MHz) affects negatively to the performance of the ADC (noise or erros in measurements) and if this ADC clock frequency is actually used by the microcontroller or if the microcontroller automatically uses another frequency that does not exceed 50 MHz.I didn't find anything very useful in the documentation related to this question.
What I need to achieve: dry battery provides power for more than 5 years. There are only three external interfaces, two GPIO and one USART. Two GPIOs are used for external interrupt, and USART is used for communication with upper computer. The project uses STM32CubeMX to generate code. The LL selected by the template has a dry battery voltage of 3V and a capacity of 1000mAh. STM32L010K8T6 is powered on for initialization. The important codes are as follows:LL_PWR_EnterLowPowerRunMode(); LL_PWR_SetRegulVoltageScaling(LL_PWR_REGU_VOLTAGE_SCALE3);Enter the STOP mode immediately after initialization. The code is as follows: uart2_prepare_stop(); //LL_mDelay(1000); PWR->CR &= ~PWR_CR_PDDS; PWR->CR |= PWR_CR_CWUF; LL_mDelay(1); SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk; __wfi(); LL_USART_DisableInStopMode(USART2);Function uart2_prepare_stop code is as follows: LL_USART_EnableIT_RXNE(USART2); LL_USART_EnableClockInStopMode(USART2); LL_USART_EnableIT_WKUP(USART2); LL_USART_Enabl
Hi Team,I am using the .extsettings to pass values of certain macros to the code. I am able to achieve the following by using the "Define=" parameter in the [others] section in .extsettings :#define ABCDHowever, I do not see the values of macros getting reflected on CubeIDE:#define ABCD 1The macro name gets reflected on the IDE settings, but the value doesn't.It would be great if there are any inputs on how can macro values be set via the extsettings?. Thanks in advance.Regards,Janani
..
Hello,I need some help about using LWIP on STM32F107VCT6 without RTOS using RAW API.For the moment I just want to ping my board with a computer but the problem is that if I make an arp command my computer doesn't see my board. I have enable ICMP, TCP, ARP on LWIP configuration on my generated CubeMX project.I have debug my project and in the fucntion ethernetif_set_link it says me that the netif set link is down. I think that the problem of LWIP configuration come frome here and more precisely from my varaible reg_value wich is equal to 0 so the netif link can't set up. My variable regvalue get is value from the function HAL_ETH_ReadPHYRegister.So I think the problem is link to the register configuration of my ethernet controller (LAN8720A).Is there anybody who know why my regvalue is never equal to 1 after the excution of this line in ethernetif.c : regvalue &= PHY_LINKED_STATUS;Here is the configuration register on my LAN8720A in LWIP:/* Section 3: Common PHY Registers */
I'm using the latest 6.7.0 version of STM32CubeMX for generating the code. I'm selecting just the serial wire and the a different timer for tick generation and nothing else. The code generation is completed without any errors. But when I try to compile I get about a zillion errors regarding FreeRTOS. Did a lot of search and tried different solutions provided. Like this one here. But nothing worked so far. :weary_face: Has anybody tried similar config ? Thanks in advance for your help :smiling_face_with_smiling_eyes: Here is the starting and ending lines of the build output. Had to snip off a bit as the post was getting too long. :grinning_face_with_sweat: Build started: Project: Test *** Using Compiler 'V6.19', folder: 'C:\Keil_v5\ARM\ARMCLANG\Bin' Build target 'Test' compiling stm32g0xx_ll_rcc.c... compiling stm32g0xx_hal_timebase_tim.c... compiling app_freertos.c... compiling main.c... assembling startup_stm32g030xx.s... compiling stm32g0xx_it.c... compiling stm32g0xx_hal_msp.c... co
Good day sir.ST's EVM�?development software and firmware informations or else are as below :NUCLEO-H743ZI2CubeMX : 6.2.1CubeIDE : 1.1.0.1Firmware package : STM32Cube FW_H7 V1.9.0 lwip : 2.1.2, raw api without rtos. After modifying according to the How-to-create-project-for-STM32H7-with-Ethernet-and-LwIP-stack-working setting, currently PC PING to the EVM board�?EVM board as the TCP/UDP client that working fine. EVM board as the TCP/UDP server, after running for a while, PC can't ping the EVM board what a problem with the lwip parameter setting I guess, however that's not my point.Currently SYS time source of test project is TIM6(1mS measurement from oscilloscope), what If I set the SYS time source to SysTick or else. are there any issues/problem problem occurred when lwip working?
Hello,I'm trying to trigger ADC on the STM32F303RE Nucleo board with an external clock generator. Without external trigger settings, it works. I changed the trigger source to Timer8, then in TIM8 settings, I chose External Clock Source. What am I doing wrong? I didn't change any user codes, should I add pin up/down commands to start ADC in user code sections? My ADC(DMA) and TIM8 settings:(My clock(square wave) generator connected to PB6 pin)
I have used STM32CubeMX to generate the configuration required to use SPI1 with DMA for a nucleo H743ZI2 board: Then, I generate the code as a Makefile project and modify the main function to have: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(); /* USER CODE BEGIN SysInit */ /* USER CODE END SysInit */ /* Initialize all configured peripherals */ MX_GPIO_Init(); MX_DMA_Init(); MX_USB_OTG_FS_PCD_Init(); MX_SPI1_Init(); /* USER CODE BEGIN 2 */ /* USER CODE END 2 */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ uint8_t buff[8] = {0}; while (1) { /* USER CODE END WHILE */ /* USER COD
I have a project where I want to add a simple PWM. I'm using the stm32h series. I have a scope on PA3, and I set up my timer2 for PWM on channel 4. I did this all in the IOC file as I want to understand how to create the PWM I need. I see it added my init code and I'm guessing I need to add a few lines to start it.maybe a timer startHAL_TIM_Base_Start_IT(&htim2);and a pwm startHAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_4);the lines it added werestatic void MX_TIM2_Init(void) { /* USER CODE BEGIN TIM2_Init 0 */ /* USER CODE END TIM2_Init 0 */ TIM_ClockConfigTypeDef sClockSourceConfig = {0}; TIM_MasterConfigTypeDef sMasterConfig = {0}; TIM_OC_InitTypeDef sConfigOC = {0}; /* USER CODE BEGIN TIM2_Init 1 */ /* USER CODE END TIM2_Init 1 */ htim2.Instance = TIM2; htim2.Init.Prescaler = 0; htim2.Init.CounterMode = TIM_COUNTERMODE_UP; htim2.Init.Period = 83999999; htim2.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; htim2.Init.AutoReloadPreload =
Hello,we are trying to listen to can messages with our evaluation board. We are using a PCAN-USB adapter to play a can log to our eval board.When starting the PC program it says that there is no can buffer detected. We assume that somehow our CAN Transceiver is not working or properly configured.Following is our CAN1 initialization.With this configuration we reach 500kbit/s baud rate at 216Mhz, which we are aiming for. hcan1.Instance = CAN1; hcan1.Init.Prescaler = 27; hcan1.Init.Mode = CAN_MODE_SILENT; hcan1.Init.SyncJumpWidth = CAN_SJW_1TQ; hcan1.Init.TimeSeg1 = CAN_BS1_1TQ; hcan1.Init.TimeSeg2 = CAN_BS2_2TQ; hcan1.Init.TimeTriggeredMode = DISABLE; hcan1.Init.AutoBusOff = DISABLE; hcan1.Init.AutoWakeUp = DISABLE; hcan1.Init.AutoRetransmission = DISABLE; hcan1.Init.ReceiveFifoLocked = DISABLE; hcan1.Init.TransmitFifoPriority = DISABLE; if (HAL_CAN_Init(&hcan1) != HAL_OK) { Error_Handler(); } Since we're trying to test the communication we have not yet configured an s
I am trying to get CAN working on the STM32G491RE. I happily worked with CAN on STM32F4xxx micros, but the landscape seems to have changed on the STM32G491RE.The presented code is from a minimal project for the NUCLEO-STM32G491RE board. It is in default configuration, plugged in to my PC. The project was created using STM32CUBEIDE MX and HAL. There is no other hardware than the NUCLEO, PC, Logic Analyser and cables.The idea is that the program configures FDCAN1 interface and transmits a two-byte payload every second. I have my logic analyser attached to FDCAN1-TX (PA12 or CN10<12> on this NUCLEO) where I expect to see the CAN transmission. I anticipate seeing just three transmissions before the TX buffer is full.On resetting the NUCLEO I see the TX line dragged low for around 30ms, released and that's it.I am obviously doing something stupid, but after days of struggling I am now going around in circles.Info:Ceramic CLK giving 96 MHz on HCLKFDCAN1 set to: Nominal Presc
I'm trying to setup an USART for a very small MCU of the STM32G0 family, the MCU it's theoretically being programmed, but the USART is not responding, I configured the MCU just like I did in other projects (of bigger MCUs), I'm not able to find what I'm doing wrong in this case.This is what I can see from the USART (theoretically in this image I'm sending "0xFF" all the time, but it does the same whatever I put in the buffer).Codewise I'm enabling the USART DMA with LL_USART_EnableDMAReq_TX(USART1), then configuring with LL_DMA_ConfigAddresses. Some checks with LL_DMA_IsEnabledChannel, and finally sending stuff with both LL_DMA_SetDataLength & LL_DMA_EnableChannel once the buffer has something on it.Also tried to clear TC1 flag & disable channel every communication, checking it with LL_DMA_IsActiveFlag_TC1. The USART is configured as Half-duplex (as it need to be) & baudrate, word length, etc...are correct:
Based on Reference Manual of the STM32H742IG (RM0433 Rev 7; Table 16.), Flash memory for 1MB devices is divided in two banks with address ranges 0x800000-0x807FFFF and 0x810000-0x817FFFF. There is 512kB gap between them. As a test i have created a project in the CubeIDE (1.6.1 with H7 package 1.9.0) for STM32H742IG with big byte array. Generated binary file is without a gap. For example, array addresses fall to this gap.From listing: t = img_map[642000]; 80002de: 4a05 ldr r2, [pc, #20] ; (80002f4 <main+0x1c>) 80002e0: 4b05 ldr r3, [pc, #20] ; (80002f8 <main+0x20>) 80002e2: 4413 add r3, r2 80002e4: 781b ldrb r3, [r3, #0] 80002f4: 08001838 .word  
I am having an issue similar to https://community.st.com/s/question/0D53W000027iXpbSAE/spi-dma-configuration-generated-by-stm32cubemx-does-not-work but with the SDMMC peripheral rather than SPI.I have an STM32CubeMX project targeting the 32F746GDISCOVERY with the following relevant peripherals and settings:SDMMC SD 4 Bits Wide busSDMMC1 global interrupt enabledSDMMC1 bidirectional DMA request enabled on DMA2 stream 3FatFS enabled with DMA templateWith the above STM32CubeMX configuration and the minimum working example below:#define TEST_DATA_SIZE 32768 // -- snip static FRESULT fatfs_err; static const unsigned char test_data[TEST_DATA_SIZE] __attribute__ ((section (".dtcm"), aligned (4))) = {0}; static unsigned int bytes; // -- snip int main(void) { // -- snip fatfs_err = f_mount(&SDFatFS, SDPath, 1); if (fatfs_err != FR_OK) { printf("failed to mount card, code: %i.\n", fatfs_err); if (fatfs_err != FR_NOT_READY) { printf("exiting.\n"); exit
Hello,UsingCubeMX 6.7F7 Firmware 1.17.0When generating with ETH interface, changing the Rx Mode from Polling Mode to Interrupt Mode do not change anything!The ioc is changed, but none of the .c/.h files
Hello,I am attempting to add CAN communication to one of my co-worker's boards, who is using the STM32F303RE MCU with an external 30 MHz crystal oscillator. The CAN communication uses the APB1 Peripheral Clock, which is currently using 30 MHz as well. When I attempt to make a specific baud rate (250 kBit/s), I used http://www.bittiming.can-wiki.info/ to get the parameters to achieve that. When I put the values in, it shows the baud rate in a greyed out section that says it's 249.999 kBit/s.What I want to know is if that will cause issues when actually applied? Since it's not "exactly" 250 kBit/s. Has anyone else had this occur and can say whether it works or not?
Creating the project with CubeMX for the STM32H743i_EVAL board and allowing it to generate the Initializing function and call for the SDMMC1 (or 2 for that matter), generates initialization code that attempts to power up the card without checking to see if there is a card present. Obvious failure waiting to happen. And even if there is a card present, the power On function is doomed to fail because the code never exectues the SD_MspInit wich enables all the io for communicating with the card. I am curious to know why that code is not present in the GPIO initialization functions? If that is not bad enough, it gets worse when the BSP code for SD is added to the project, it causes all sorts of compiler errors because of duplicate definitions.
Hello,I'm using STM32H747XIH6 MCU and I have developed the code on STM32 cube ide software 1.7.0 by generating the code in stm32 cube mx 6.5.0.I have written a simple code of GPIO toggle pin.Below is my code for clock configuration. I have connected an external clock of 25MHz.void SystemClock_Config(void) { RCC_OscInitTypeDef RCC_OscInitStruct = {0}; RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; /** Supply configuration update enable */ HAL_PWREx_ConfigSupply(PWR_DIRECT_SMPS_SUPPLY); /** Configure the main internal regulator output voltage */ __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE3); while(!__HAL_PWR_GET_FLAG(PWR_FLAG_VOSRDY)) {} /** Initializes the RCC Oscillators according to the specified parameters * in the RCC_OscInitTypeDef structure. */ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; RCC_OscInitStruct.PLL.PLLSource =
Reason for the question:We want to generate two different hardware settings (CubeMX projects) into one software program running on a STM32 controller. Then at startup, the controller finds out, which HW configuration it has to use and uses just one of the two available ones to startup/init the system peripherals/hardware.Thanks for any help.
Hi,I've just tried to set up TIM2 on an STM32G0B1RE in CubeMX like this:The exact purpose shouldn't matter for this question, but the timer is supposed to generate an interrupt when a LOW pulse of a given minimum length is detected on an external signal, entirely in hardware. I already have a plan for how to do that.The problem is that with this configuration, the ETR pin (for the gate input signal) actually seems to become an output! After some head scratching, I found that this only happens if I use specifically Channel 1 for Output Compare. I assume that's because ETR1 and CH1 are somehow connected internally and can't be freely used at the same time. It just surprises me that this matters even in "No Output" mode, and CubeMX did not stop me from configuring it this way. It DOES stop me from using "Output Compare CH1", the tooltip of which is so far the only indication that ETR1 and CH1 might be related that I could find. Admittedly I just skimmed the reference manual, but couldn't
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.