Ask questions and find answers on STM32Cube packages, including HAL, LL and middleware, and expansion software.
Most recent activity
I'm trying to build a simple HTTP server using Mongoose with the LWIP IP stack on FreeRTOS CMSIS_V1. It is important that I let LWIP handle the network interface since I'm also using it to advertise a service using mDNS. This is what my task looks like:void StartMongooseTask(void const * argument) { /* init code for LWIP */ MX_LWIP_Init(); /* init code for USB_DEVICE */ MX_USB_DEVICE_Init(); while (netif_default == NULL || !netif_is_up(netif_default) || !ip4_addr_isany_val(*netif_ip4_addr(netif_default)) ) { osDelay(100); } extern struct dhcp_state_enum_t; struct dhcp *dhcp_client = netif_dhcp_data(netif_default); while (dhcp_client == NULL || dhcp_client->state != 10) { osDelay(100); } ip = *netif_ip4_addr(netif_default); printf("IP acquired: %u.%u.%u.%u", ip4_addr1(&ip), ip4_addr2(&ip), ip4_addr3(&ip), ip4_addr4(&ip)); mdns_resp_init(); mdns_resp_add_netif(netif_default, "22223335", 3600); mdns_resp_add_service(netif_defa
I’m using the STM32F401RET6 board, collecting data from a USB accelerometer at 16 kHz.I wanted to verify that the data is actually being collected at 16 kHz, and then run an FFT to compare it with previously collected PC data. To do this, I need to transfer the data to the PC.At first, I tried collecting data and transmitting it with HAL_UART_Transmit, but due to the transmission overhead, the actual sampling rate wasn’t 16 kHz—it dropped to about 9 kHz.So I tried using the DMA + double buffer method, where data collection and transmission happen simultaneously. I structured my task like this: void vUSBReadTask(void *pvParameters) { AUDIO_HandleTypeDef *audio_handle; uint8_t *buf; static uint8_t isoc_submitted = 0; for (;;) { MX_USB_HOST_Process(); audio_handle = (AUDIO_HandleTypeDef *)hUsbHostFS.pActiveClass->pData; if (!(audio_handle && audio_handle->microphone.supported)) { // taskYIELD(); continue; } buf = audio_handle->microphone.buf; // Submit
Hi, I'm having the following issue with the F103C8 USART DMA.After reset, sometimes the USART DMA Receive doesn't work. It doesn't happen every time, but it happens about once every 10 resets. HAL_UARTEx_ReceiveToIdle_DMA(&huart1, (uint8_t *)RxDataUsart1, 128); __HAL_DMA_DISABLE_IT(&hdma_usart1_rx, DMA_IT_HT); HAL_UARTEx_ReceiveToIdle_DMA(&huart2, (uint8_t *)RxDataUsart2, 128); __HAL_DMA_DISABLE_IT(&hdma_usart2_rx, DMA_IT_HT);void HAL_UARTEx_RxEventCallback(UART_HandleTypeDef *huart, uint16_t Size) { if(huart == &huart1) { timer_UART1_Datalost = millis(); uart_1_Ready = SET; __HAL_UART_CLEAR_FEFLAG(&huart1); memcpy(copyRxDataUsart1, RxDataUsart1, 128); copyRxDataUsart1[127] = '\0'; usart1Datareceived = 1; for (int i=Size; i < 128; i++)RxDataUsart1[i]=0; } __HAL_UART_ENABLE_IT(&huart1, UART_IT_IDLE); HAL_UARTEx_ReceiveToIdle_DMA(&huart1, (uint8_t *)RxDataUsart1, 128); __HAL_DMA_DISABLE_IT(&hdma_usart1_rx, DMA_IT_HT); if(huar
I'm losing my mind a little, because this seems like it should be a simple task. I have configured my I2C module to enable DMA and interrupts: I can confirm that my call to HAL_I2C_Master_Transmit_DMA returns OK. I can also confirm that the generated DMA1_Channel2_IRQHandler is called. That's where things start breaking down. Other modules in the HAL library give you a hook (e.g.HAL_GPIO_EXTI_Callback) signature that you can implement and have it be called by the HAL top-level ISR, but it seems like DMA has not implemented that. Instead, the HAL DMA module implements HAL_DMA_RegisterCallback, and you can successfully call it - but then those callback pointers are overwritten by ones in the HAL itself. OK... so then I tried copying some of the code from HAL_DMA_IRQHandler to (re-)determine which DMA flag applies: static void dma_states( const DMA_HandleTypeDef *restrict hdma, bool *restrict is_complete, bool *restrict is_error ) { const uint32_t flag_it = h
I use STM32Cube FW_N6 V1.2.0 to create an FW to run a web server on the DK board. I figured out that I can not talk to the PHY chip to read the PHY ID. I compared the code with another example that ST released and figured out that these codes are missing on HAL_ETH_MspInit __HAL_RCC_ETH1MAC_CLK_ENABLE(); __HAL_RCC_ETH1RX_CLK_ENABLE(); __HAL_RCC_ETH1TX_CLK_ENABLE(); after adding this to my MSPInit function problem was solved! I wonder if this is a bug in this package or if I need to set it in the CubeMX settings?
Hello, I am working with an stm32f429_disc board, which has an onboard i3g4250d gyroscope that communicates via SPI. The Zephyr SDK includes a sensor driver for this specific sensor. However, even though I have defined this sensor under the SPI node in my overlay file, I am getting an undefined reference to __device_dts_ord_... linker error. The strange part is that when I define a sensor with a different compatible string under this same node (for example, bosch-bme280), I don't get any errors. But when I specifically define it as st-i3g4250d, I receive the linker error.My code is as follows; #define I3G_NODE DT_NODELABEL(i3g4250) const struct device* dev_sensor = DEVICE_DT_GET(I3G_NODE);; int main() { if (!device_is_ready(dev_sensor)){ printk("error device is not ready\n"); return 0; } }&spi5 { compatible = "st,stm32-spi"; pinctrl-0 = <&spi5_sck_pf7 &spi5_miso_pf8 &spi5_mosi_pf9>; pinctrl-names = "default"; status = "okay"; cs-gpios = <&gpio
Hello,I'm using a H743 with the DMA2D device in RegToMem mode. Generally it seems to work for larger images, but I've been trying to fill a small rectangle (5 x 60) pixels, and I was expecting 300 write pulses. Instead, I'm getting 480 pulses (8 x 60 pixels)???. Is there a weird requirement that the width of the fill has to be a multiple of 8? I don't remember seeing such a requirement in the datasheet.thanksMatthew
I am simulating messages to be received via CAN on the STM32F0xx series uC. The hardware FIFO does not overflow as I have activated the overflow interrupt and checked the FIFO level, which never exceeds 1. The current implementation consists of a 128-byte software buffer. Now, the system is able to handle messages sent at 100 ms intervals. When I start sending messages at 10 ms intervals, it begins to overwrite the previous entry in the buffer. It does so once after a long time of sending messages, and does not happen frequently.The potential issue is that the interrupt fires every 10 milliseconds, while the main message processing happens every 50 milliseconds, so the buffer is cleared/read after 5 messages have already been sent. What I am noticing is that the current index for the ring buffer "resets" to the previous interrupt's counter value, the occurrence of which is low. Hence, when the message counter in the CAN frame is received, due to the current index being "reset", it
I've been trying to read the analog temperature sensor on an STM32H723 MCU. Somehow, my readings were invalid. So, I've started debugging and realized that there are possibly faulty macros defined in stm32h7xx_ll_adc.h (HAL v1.11.5). As shown below, these macros treat ADC3 (to which the internal temperature and Vref are connected) as a 16-bit ADC instead of a 12-bit ADC. When I use LL_ADC_RESOLUTION_12B instead of LL_ADC_RESOLUTION_16B in those macros, the problem gets solved.Am I missing something?/** * @brief Helper macro to calculate analog reference voltage (Vref+) * (unit: mVolt) from ADC conversion data of internal voltage * reference VrefInt. * @note Computation is using VrefInt calibration value * stored in system memory for each device during production. * @note This voltage depends on user board environment: voltage level * connected to pin Vref+. * On devices with small package, the pin Vref+ is not present * and internally bonded to pin Vdd
Hello, I am trying to set up an external flash memory (MX25V1635F) on a Nucleo-U575ZI-Q using SPI.- I managed to simulate a disk using RAM memory, Windows formats it perfectly, which leads me to believe that my USBX configuration is correct.- I also tested my LevelX functions for reading and writing to my NOR flash, and they seem to be working correctly, which leads me to believe that the LevelX configuration is correct.- I disabled all my FileX functions (format, open, read, and write) because it seems that Windows (USB Host) takes over the formatting. (Btw, if FileX can't be used, how can I write a formatted file to my flash memory?). My problem: when I leave the USBD_STORAGE_Write and USBD_STORAGE_Read functions empty, Windows can see the size of my disk and offers to format it (without success):And when I implement these two functions (based on the only example I found online using the Levelx functions lx_nor_flash_sector_write and lx_nor_flash_sector_read: LINK), Windows
#include <stdint.h> #include <stdio.h> #include "stm32f4xx.h" volatile uint8_t rxdata = 0; int main(void) { SystemInit(); SystemCoreClockUpdate(); // clock configutation RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE); // TX: PB6 RX: PB7 RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE); // LED LED4: PD12 LED3: PD13 RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE); RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE); NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4); // gpio initialization GPIO_InitTypeDef GPIO_InitStruct; GPIO_StructInit(&GPIO_InitStruct); GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStruct.GPIO_OType = GPIO_OType_PP; GPIO_InitStruct.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7; GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_UP; GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOB, &GPIO_InitStruct); GPIO_PinAFConfig(GPIOB, GPIO_PinSource6, GPIO_AF_USART1); GPIO_PinAFConfig(GPIOB, GPIO_PinSource7, GPIO_AF_USART1); // usart initiali
Title edited to name the device being hosted. Hello , I am currently trying to configure STM32F407 board as USB host. The code for it is given below. I am not receiving anything from the USB device(bus powered). I have a doubt that it might be related to the hardware of it(VBUS). The rest of the code is generated by the IDE itself so there is no doubt related to it. I have configured it as USB host only mode. I am new to embedded systems so any kind of help would be appreciated. Is there anything wrong with the code or any links to help me configure the USB host.I would be glad to clarify any queries related to the above.
I am using Nucleo STM32H753ZI board. The STMCube IDE version is 1.19.0 and FreeRTOS version is 1.3.1 and CMSIS RTOS1 version is 1.02 I have enabled Icache, DCache and MPU. Integrated the stacks of LWIP,Ethernet and FreeRTOS too.Basic ping functionality is not working.Could you please look into this.
I am using the HAL FDCAN driver in queue mode (STM32G431, FW_G4 V1.6.1).The application is (intentionally) working with a high bus load (~90%), so it is expected that there will occasionally be times when there are no transmit message buffers available - so HAL_FDCAN_AddMessageToTxFifoQ() is expected to return HAL_Error, as that is what it does if this is the case.The application code can then use HAL_FDCAN_GetError() to get the ErrorCode (though this seems a bit pointless, as instance->ErrorCode does the same, so not a lot of abstraction here).However, it only becomes clear from looking at the HAL code that ErrorCode uses bits to represent the set of possible errors - so it is not as simple as comparing the value with HAL_FDCAN_ERROR_FIFO_FULL (the test needs to use a mask operation). The documentation does not explain that this is the case.How should the error be cleared once it has been handled? The HAL does not provide an API for this, so it appears as if the user
Hi,I'm working on a project using STM32H733 and Azure RTOS. I have written my own implementation of malloc and other memory allocation functions. I'm using the `tx_byte_pool_create` function to first create a byte pool in SDRAM and then using `tx_byte_allocate` in my custom malloc to allocate memory from the byte pool.The byte pool is created successfully in SDRAM, and I can also see the contents of SDRAM. Everything seems to work fine.I'm able to ping my device, etc. However, as soon as I trigger an API to hit an endpoint running on an HTTPS server, the device triggers the callback function. While preparing the response, it encounters one of the memcpy operations (where the HTTP server allocates memory and stores the buffer in SDRAM) and gets stuck in the Hard Fault Handler.Work-Around: I replaced `json_asprintf` with `sprintf` and passed it with a memory block allocated in SDRAM using a custom malloc implementation. And it worked, I successfully got a response from the HTTPS server.
I use stm32h7r3 to develop USB audio recording function. My device can work successful in Ubuntu/Android/Windows, but failed in iOS. I had tried many iOS version, but still can't work. The below is my device USB parameters:2 channels L/R32 bit data length48KHz sample rateHigh speedUAC1.0my reference code(stm32F769I) from https://www.st.com/en/embedded-software/x-cube-audio.htmlCould someone give me some advice?
I have STM32H747I-Disco board i was trying to blink two leds in diffrent core , but not able to do so . it's showing some error while building the project.
Hi everyone,I'm using STM32H573I-DK, since I wanted to experiment with it a little bit. I want to do some audio processing, so I wanted to configure I2S (not planning on using the on board audio codec) to use DMA for circular buffering of RX (using GPDMA1_Channel4 for it) and TX (GPDMA1_Channel5 for it). I didn't know that the DMA changed so much in configuring it, but oh well, I started learning the linked-list mode since it uses it anyway for circular mode. I looked up at different tutorials and posts here, but I still have a problem. I also followed the procedure for setting up the I2S transfer using DMA from 52.9.16 section, Programing Examples.Anyway, I tried to set it up using the node configuration in CubeMX and using HAL functions, but I just could't get it to work. Whenever I looked at the Linked List registers in GPDMA_XXXX (as in for example GPDMA_C4SAR, GPDMA_C4CCR) they were filled with zeros. So I started to use LL so that I can be sure that I write the correct confi
I am trying to use pins on ADC3 of an STM32h735g in Zephyr, but I am getting a "Could not read (-22)" error, despite not having issues with ADC1. Is ADC3 supported? If so, can you help me with how to configure it?This is based on the Zephyr samples/drivers/adc/adc_dt and I am using the stm32h735g Discovery Kit to test this.I modified boards/stm32h735g_disco.overlay to/* Copyright (c) 2021 STMicroelectronics SPDX-License-Identifier: Apache-2.0 */ / { zephyr,user { /* Adding adc3 1 to the existing definition of io-channels */ io-channels = <&adc1 0>, <&adc3 1>; }; }; &adc1 { #address-cells = <1>; #size-cells = <0>; channel@0 { reg = <0>; zephyr,gain = "ADC_GAIN_1"; zephyr,reference = "ADC_REF_INTERNAL"; zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>; zephyr,resolution = <16>; }; }; /* The following I defined for adc3 */ &adc3 { #address-cells = <1>; #size-cells = <0>; /* Compiler requiess
Hello,I try to jump into the default bootloader of the STM32H563 from user code by setting the NSBOOTADDR:extern void HalRebootInBootloaderMode(void) { FLASH_OBProgramInitTypeDef options; HAL_FLASHEx_OBGetConfig(&options); options.BootAddr = 0x0BF97000u; // From AN2606. Also tried 0x0BF80000 start of sytem memory found in table 48 of RM0481 options.BootConfig = OB_BOOT_NS; options.OptionType = OPTIONBYTE_BOOTADDR; HAL_FLASH_Unlock(); //Returns HAL_OK HAL_FLASH_OB_Unlock(); //Returns HAL_OK HAL_FLASHEx_OBProgram(&options); //Returns HAL_OK HAL_FLASH_OB_Launch(); //Returns HAL_ERROR, because of OPT_CHANGE_ERR HAL_FLASH_OB_Lock(); HAL_FLASH_Lock(); HAL_NVIC_SystemReset(); }A similar mechanism worked pretty well on STM32H743 (using registers BOOT_ADDR1 and BOOT_ADDR_0 instead on that MCU).But the snippet above fails on the H563 (HAL_FLASH_OB_Launch() returns HAL_ERROR, and my application always start in my user code).However HAL_FLASH_OB_Launch() return HAL_OF if
Post edited by ST moderator to be inline with the community rules especially with the code sharing. In next time please use </> button to paste your code. Please read this post: How to insert source code In STM32C092 board, when I configured in ioc file for ADC, with scan conversion mode and:- enable analog channel 0 only, it is able to measure the analog channel 0 correctly.- enable analog channel 1 only, it is unable to measure the analog channel 1 correctly.- enable analog channels 0 & 1, it is able to measure the analog channel 0 correctly but channel 1 is mirroring the value of channel 0, instead of giving an independent value on changing voltages. I tried:- ranking ADC sequence manually, since in ioc file, it doesn't give options for ranking.- verified the GPIO settings for analog function.- increased sampling time for channel 1.- gave sampling time for channel0 as 1.5 cycles and for channel1 as 160.5 cycles. Am I doing something wrong here?The IOC default cod
HI,I need help because I'm going crazy.I’m trying to use SD card with STM32H747 on the M4 core using FatFS and SDMMC1 and FreeRTOS, but the MDMA write never completes and the write complete callback is never called. This happens when I try to format the SD card with f_mkfs, f_mkfs calls SD_write, which eventually triggers HAL_SD_WriteBlocks_DMA. and in which i it crashes. Reading works OK problem occurs only in writing. Tested on many SD cards.Here’s a snippet of SD_write function with debug:uint8_t res; printf("[SD_write] Starting DMA write: %lu blocks to sector %lu...\n", count, sector); res = BSP_SD_WriteBlocks_DMA((uint32_t*)buff, sector, count); if (res == MSD_OK) { printf("[SD_write] DMA write started OK. Waiting for queue event...\n"); #if (osCMSIS < 0x20000U) event = osMessageGet(SDQueueID, SD_TIMEOUT); if (event.status == osEventMessage && event.value.v == WRITE_CPLT_MSG) { printf("[SD_write] Write complete received\n"); } #else status = osMessage
I'm using the STM32H562. The STM side is configured as a slave and is successfully communicating with another board via SPI. Now, I'm trying to incorporate DMA into the setup, but it's not working as expected. The transfer complete interrupt is being handled correctly, but the send/receive results are not as expected on either the external board or the STM32 board. Although fixed values are being transmitted and received, the results are coming out as 0 or 0xFF. The GPDMA configuration is as follows. (stm32h5xx_hal_msp.c) /* SPI3 DMA Init */ /* GPDMA1_REQUEST_SPI3_TX Init */ handle_GPDMA1_Channel5.Instance = GPDMA1_Channel5; handle_GPDMA1_Channel5.Init.Request = GPDMA1_REQUEST_SPI3_TX; handle_GPDMA1_Channel5.Init.BlkHWRequest = DMA_BREQ_SINGLE_BURST; handle_GPDMA1_Channel5.Init.Direction = DMA_MEMORY_TO_PERIPH; handle_GPDMA1_Channel5.Init.SrcInc = DMA_SINC_INCREMENTED; handle_GPDMA1_Channel5.Init.DestInc = DMA_DINC_FIXED; handle_GPDMA1_Channel5.Init.SrcDataWidth = DMA_SRC_DATAWI
Hello, I don't seam to see anything related to the implementation of the USB PD AVS system to allow a sink to request voltages of up to 48V. Am I miss-reading the X-CUBE-TCPP code? If it is missing, is there a plan to implement it? Thanks a lotHave a nice day
Hello!I am using a custom board with STM32H563VIT6. I want to create an MQTT project which will send data to a local laptop via an Ethernet cable. I am using STM32H573I-DK\Applications\NetXDuo\Nx_MQTT_Client as the example project to do so, but I am facing a problem.The problem is that when the nx_app_thread_entry function is called it will get stuck when this line is calledif(tx_semaphore_get(&DHCPSemaphore, TX_WAIT_FOREVER) != TX_SUCCESS)Then this leads to "__tx_ts_wait" in the nx_thread_schedule.S forever.This is my call stack up to __tx_ts_wait:__tx_ts_wait@0x08000336 (...\STM32H563VIT6_Ethernet\Middlewares\ST\threadx\ports\cortex_m33\gnu\src\tx_thread_schedule.S:279) <signal handler called>@0xffffffbc (Unknown Source:0) _tx_ipsr_get@0x08009bdc (...\STM32H563VIT6_Ethernet\Middlewares\ST\threadx\ports\cortex_m33\gnu\inc\tx_port.h:511) _tx_thread_system_return_inline@0x08009bdc (...\STM32H563VIT6_Ethernet\Middlewares\ST\threadx\ports\cortex_m33\gnu\inc\tx_port.h:615) _
ST Community highlights – April to June 2026
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.