Ask questions and find answers on STM32Cube packages, including HAL, LL and middleware, and expansion software.
Most recent activity
L562 processor. SPI1. Blocking mode. Two sequential writes, second write variably returns error.code:// uses CS if USE_CS is set to CS_ACTIVE (default) // CS is not used if USE_CS is set to CS_INACTIVE uint32_t HAL_SPI::Send( uint8_t* cmdptr, uint32_t cmd_count, uint8_t* dataptr, uint32_t data_count, bool USE_CS, enum SPI_TRANSFER_MODE Override) { enum SPI_TRANSFER_MODE NEW_mode = OUT_mode; int error_code; // int old_divisor; // ********************************** check input parameters*********************************** // need to check overrides switch (Override) { case SPI_DMA: // TRANSMIT IS DMA FROM BUFFER, RECEIVE IS IRQ QUEUE (MAY CHANGE) case SPI_IRQ: // TRANSMIT IS IRQ DRIVEN case SPI_BLOCKING: // TRANSMIT AND RECEIVE ARE BYTE BLOCKING { NEW_mode = Override; break; } default: { NEW_mode = OUT_mode; // leave mode as is, cannot override } } switch (NEW_mode) { case
I am trying to load LwIP_TCP_Echo_Server (an example project created by STMicroelectronics) onto a Nucleo_H7S3L8 Evaluation Board (produced by STMicroelectronics) and it's crashing. I had some trouble getting the BootLoader to run through to the JumptoApp function (covered under a different post) and used a workaround fix it.I set a break point just before the jump and examined the App memory at 0x70000000 (memory mapped). It was all 0xFFFFFFFF. No wonder the code crashed. I used the STM Programmer, and the memory looked ok. Code at 0x70000000 looked like a vector table and definitely not 0xFFFFFFFF. I added the Template_XIP_Boot project to my build as described in the README.md.I really need to get this piece of ... code to work. Like now. This stuff is basic startup operation. This is an ST example project on ST Nucleo hardware. What's going on? I've seen no other forum posts on my recent issues. Why is everyone else having fabulous success? Am I alone? What's wrong with
I have a custom board with a STMU5F7VJT, programmed over SWD, with an on board MMC and a usb connector. I am trying to access the onboard MMC with FileX and ThreadX. Using USBX, I can access the MMC just fine, and even format it from my computer, so MMC, ThreadX and DMA should be working fine. When trying to format the MCU through FileX however it hard faults during the synchronization deep in the ThreadX stack when calling tx_semaphore get() in the auto generated macro FX_STM32_MMC_WRITE_CPLT_NOTIFY().Curiously, this hard fault only happens when the cpu is allowed to run. When manually stepping through, the hard fault never occurs. The hard fault is extremely cryptic. It fails within the function:VOID _tx_thread_system_suspend(TX_THREAD *thread_ptr) #ifndef TX_NOT_INTERRUPTABLE {At the line of the macro "#ifndef TX_NOT_INTERRUPTABLE before entering the function proper.I've increased the stack sizes/memory pool to a ludicrous amount, double checked memory alligned buffers and all
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 HI I am having an issue with starting measurements using the on-board microphone. Everything has been configured based on the BSP code, but set up from scratch using CubeMX. The problem is that when I start the DMA Receive if (HAL_SAI_Receive_DMA(&hsai_BlockA4, (uint8_t*)PDM_Buffer, PDM_BUF_SIZE) != HAL_OK) { printf("SAI RX start error!\r\n"); } else { printf("SAI RX started OK"); } //callbacks: void HAL_SAI_RxHalfCpltCallback(SAI_HandleTypeDef *hsai) { printf("HAL_SAI_RxHalfCpltCallback\n"); } void HAL_SAI_RxCpltCallback(SAI_HandleTypeDef *hsai) { printf("HAL_SAI_RxCpltCallback\n"); } void HAL_SAI_ErrorCallback(SAI_HandleTypeDef *hsai) { printf("SAI error: 0x%08lx\n", hsai->ErrorCode); } I immediately get an interrupt rep
Resuming studies, regarding:I'm resuming my STM32 studies, having not used them for a few months.After this time, and updates to CubeID and CubeMX, I'm trying to get back to it using the Nx_webserver example. Although the code appears to be correct, it doesn't work; it doesn't even get a valid IP address in DHCP.I've tried changing the MAC address, but even then, nothing in DHCP works.Is there anything I should do to make it work?I have the following console output: ------------------------------------------------------------------- STM32CubeProgrammer v2.20.0 ------------------------------------------------------------------- Log output file: /tmp/STM32CubeProgrammer_q4oXBH.log ST-LINK SN : 066EFF353445503043075718 ST-LINK FW : V2J46M31 Board : NUCLEO-F429ZI Voltage : 3,23V SWD freq : 4000 KHz Connect mode: Under Reset Reset mode : Hardware reset Device ID : 0x419 Revision ID : Rev 5/B Device name : STM32F42xxx/F43xxx Flash size : 2 MBytes Device type : MCU Device CPU : Cortex-M
I'm developing a bootloader for a project using the STM32H563VGT6 with 1MB of internal flash memory. I've developed a bootloader in the past for STM32H743 which works correcty.In this H5 bootloader I seem to have problems writing to the internal flash memory. Below is the code I have to write a block of data to flash memory.uint32_t Flash_Write_Data (uint32_t StartSectorAddress, uint32_t *data, uint16_t numberofwords) { static FLASH_EraseInitTypeDef EraseInitStruct; uint32_t SECTORError; int sofar=0; /* Unlock the Flash to enable the flash control register access *************/ HAL_FLASH_Unlock(); /* Erase the user Flash area */ /* Get the number of sector to erase from 1st sector */ uint32_t StartSector = GetSector(StartSectorAddress); uint32_t EndSectorAddress = StartSectorAddress + numberofwords*4; uint32_t EndSector = GetSector(EndSectorAddress); /* Fill EraseInit structure*/ EraseInitStruct.TypeErase = FLASH_TYPEERASE_SECTORS; EraseInitStruct.Sector = Sta
ADC1 clocked @ 65 MHz, prescalar 0 for divide by 1, continuous conversion, DMA circular mode, 640.5 cycle sampling time, 256x oversampling, 12-bit resolution, 3 channels per sequence. The channels in the sequence are: IN3, temp sensor channel, Vrefint channel. I would expect a sequence to be converted in (3 * 256 * (640.5 + 12.5)) / 65000000 => ~7.7 ms.HAL_ADC_ConvCpltCallback() increments a counter for TC and HT. In 120 seconds (used debugger to stop) I get 60102. TC count = 60102/ 2 = 30051 for 120 seconds or 3.9 ms average/sequence. HAL_ADC_ErrorCallback() never called.Why the discrepancy: 7.7 ms expected vs 3.9 ms observed?MX_ADC1_Init() looks like…static void MX_ADC1_Init(void) { /* USER CODE BEGIN ADC1_Init 0 */ /* USER CODE END ADC1_Init 0 */ ADC_ChannelConfTypeDef sConfig = {0}; /* USER CODE BEGIN ADC1_Init 1 */ /* USER CODE END ADC1_Init 1 */ /** Common config */ hadc1.Instance = ADC1; hadc1.Init.ClockPrescaler = ADC_CLOCK_ASYNC_DIV1; hadc1.Init.Resolution =
I need to calibrate STM32l431 RTC in software for using LSI clock. When I compare STM32 RTC with GPS reference I get the following GPS 1759492828 1759493307 => RTC 1759500022 1759500494Diff GPS: 479 secondsDiff STM32: 472 seconds=> 7 seconds = 1.48% difference andPrefered frequency to RTC 32473 I thought smooth calibration could be used for this kind of calibration but it seems it can only calibrate small changes for crystal.Any ideas how this can be done? I cannot modify PCB for external pulses, I need to correct in software. Clock will be syncronised 8, 16 and 24 hours interval, so accuracy does not need to be like a crystal.
Hi In the past 6 months, I created a project for an STM32H755. For middleware, I selected CMSIS RTOS v2 (using FreeRTOS underneath).I noted that the header file is cmsis_os.h, which at first seemed wrong. I (maybe naively) asked the "AI", and with it's usual confident tone, suggested I change them (however, this is hard to maintain if you change your .ioc file).Looking at past posts on these forums, and inside cmsis_os.h, I confirmed that cmsis_os2.h is indeed included within it (despite the AI not finding this).So, I challenged the "AI", stating what I had found. Of course, in it's somewhat complimentary way, it agreed with me, but still insisted that if I am using entirely v2 APIs, I should change the headers.Of course, such responses derive from human content written elsewhere, and I fear it may not backed by actual facts. I have left the headers as they are for now. I have a bad feeling about changing them as ST might have reasons to do things the way they have. So, is it
Hi all, STM32 start executes the following during startup in main.c:HAL_Init();SystemClock_Config();Initialize all configured peripherals (e.g., MX_GPIO_Init())Enter the main while loopHowever, I've observed a cold-start issue:If the power supply is disconnected for 3–5 seconds or more, the system hangs and never reaches the main while loop after reboot.If the supply is disconnected for a short interval or a manual reset is applied, the system boots normally.While debugging, I suspected that the LSE/LSI/HSI oscillators might need more time to stabilize.Looking into HAL_RCC_OscConfig(), it waits for the HSI to be ready by checking RCC_FLAG_HSIRDY with a timeout mechanism: /* Get Start Tick */ tickstart = HAL_GetTick(); /* Wait till HSI is ready */ while(__HAL_RCC_GET_FLAG(RCC_FLAG_HSIRDY) == 0U) { if((HAL_GetTick() - tickstart ) > HSI_TIMEOUT_VALUE) { return HAL_TIMEOUT; } } When I set a breakpoint here, I noticed:tickstart is always 0HAL_GetTick() always returns
We have developed a custom board based on an eval board that has a LoRa transceiver and an RFID tag reader connected to two UARTs of the MCU. A serial console is also connected to a third UART. DMA streams are configured for the LoRa and RFID UARTs, and for Ethernet. The software application uses FreeRTOS and has an Ethernet stack implemented using LwIP. The app responds to UDP commands received by the device, which trigger interactions with the LoRa or RFID devices.The application works as expected when a USB J-Link JTAG interface is connected to the board, whether using the debugger, or just running. However, if the board is powered on without the USB J-Link attached, Ethernet does not work. The board does not receive any UDP packets or even respond to pings. The LEDs still flash, indicating that the main thread is still running.Any suggestions?
After solving my issue with reading the USER1 button (thanks to everyone who helped me on this forum :folded_hands:), I am now trying to handle USER1 button detection using interrupts.My project is running in FSBL mode, so I’m using NVIC FSBL. I’m trying to configure the USER1 button (EXTI13) with a pull-down in CubeMX. …but unfortunately without success.what is wrong ? in my configuration in CubeMX ? Cheers Emmanuel my code stm32n6xx_it.c : with void EXTI13_IRQHandler(void)/* USER CODE BEGIN Header */ /** ****************************************************************************** * @file GPIO/GPIO_IOToggle/Src/stm32n6xx_it.c * @author MCD Application Team * @brief Main Interrupt Service Routines. * This file provides all exceptions handler and * peripherals interrupt service routine. ****************************************************************************** * @attention * * Copyright (c) 2024 STMicroelectronics. * All
Hello everyone! I'm working on an application using AzureRTOS and FileX, however, I'm getting a hard fault that I can't pin down.Here is a screenshot of the variable states when entering _fx_directory_search (in middleware fx_directory_search.c) which causes the hard fault. It seams to occur as the function is called. (Not sure why the resolution is bad but don't think there is anything I can do about it I'm sorry!)I'm seeing a lot of 0x0 in the function arguments.media_ptr FX_MEDIA * 0x0 name_ptr CHAR * 0x0 entry_ptr FX_DIR_ENTRY * 0x0 last_dir_ptr FX_DIR_ENTRY * 0x0 last_name_ptr CHAR ** 0x200012a8 <fx_byte_pool_buffer+408> i ULONG 4025479151 n ULONG 1627389952 found UINT 134272988 status UINT 4025479151 v UINT 134276061 j UINT 10 cluster ULONG 536875464 next_cluster ULONG 4025479151 directory_size ULONG64 2305863900471563680 And a screenshot of the states before entering the above function: I take note of:name_ptr CHAR * 0xffffffff <error: C
I would like to ensure that I can use HAL_FDCAN_GetRxFifoFillLevel() function in HAL_FDCAN_RxFifo0Callback() like this: void HAL_FDCAN_RxFifo0Callback(FDCAN_HandleTypeDef *hfdcan, uint32_t RxFifo0ITs) { if (RxFifo0ITs & FDCAN_IT_RX_FIFO0_NEW_MESSAGE) { // used loop to read all messages from FIFO while (HAL_FDCAN_GetRxFifoFillLevel(hfdcan, FDCAN_RX_FIFO0) > 0) { can_msg_t rx_msg = {0}; if (HAL_FDCAN_GetRxMessage(hfdcan, FDCAN_RX_FIFO0, &rx_msg.hdr, rx_msg.data) != HAL_OK) { break; } rx_msg.data.data_len = (uint8_t)dlc_to_bytes(rx_msg.hdrDataLength); // put rx msg to queue osMessageQueuePut(rx_queue_handle, &rx_msg, 0, 0); } } } When I googling more whether I can use HAL_FDCAN_GetRxFifoFillLevel() in ISR CalIback I got:HAL_FDCAN_GetRxFifoFillLevel is not guaranteed to be ISR-safe because it's a read operation on a peripheral register that doesn't automatically handle atomic operations, which are required in interrupt contexts to preven
Hi all,I'm working on an audio project with an STM32U575, where SAI 1A is receiving TDM data from an ADC and SAI 2A needs to take the data after processing and output it over I2S to a DAC.The audio sample rate is 48 KHz in both cases, and both SAI blocks get their clocks from PLL2P at 12.288 MHz.How should I buffer and process the data? I'm concerned about whether the SAI peripherals will drift apart from each other if I try to start a naive double-buffering system.Thanks for any tips!
Dear ST Community/Support Team, We are developing a Firmware Over-The-Air (FOTA) solution for an IoT asset tracking device using the STM32H747IIT6 microcontroller (LQFP176 package, dual-core Cortex-M7/M4, 2MB dual-bank Flash). The system integrates a SIMCOM cellular/GNSS module for connectivity and location services, with firmware downloads staged via AT commands (e.g., HTTP for files like fwv1.bin) and processed using STM32 HAL UART/Flash APIs. Project Overview: Hardware: STM32H747IIT6 as main MCU; SIMCOM module on UART1 for AT commands (e.g., AT+FSOPEN/FSREAD for file staging); GNSS NMEA parsing on UART2 (offloaded to M4 core). Software Stack: STM32CubeH7 HAL (v1.13+), FreeRTOS on M7 for multitasking, dual-bank Flash for safe updates (Bank1: Bootloader + Active App; Bank2: New Firmware). FOTA Flow: Poll server for update manifest (version, URL, checksum). Download chunks to SIMCOM FS or SD card. Verify (CRC/SHA256), copy to inactive bank, set flag, reset.
Hello,I am currently trying to collect acceleration data at 16 kHz from a USB accelerometer using an STM32F401RET6 in USB Host mode.I created two tasks: vUSBInitTask and vUSBReadTask as shown below. void vUSBInitTask(void *pvParameters) { MX_USB_HOST_Init(); for (;;) { MX_USB_HOST_Process(); vTaskDelay(pdMS_TO_TICKS(10)); } } void vUSBReadTask(void *pvParameters) { AUDIO_HandleTypeDef *audio_handle; uint8_t *buf; char msg[64]; static int32_t sample_buffer[SAMPLES_TO_SAVE]; int collected_samples = 0; while (Appli_state != APPLICATION_READY) // wait until USB is ready { vPrintString("Waiting for USB ready...\r\n"); vTaskDelay(pdMS_TO_TICKS(500)); } for (;;) { audio_handle = (AUDIO_HandleTypeDef *)hUsbHostFS.pActiveClass->pData; if (audio_handle && audio_handle->microphone.supported) { buf = audio_handle->microphone.buf; if (buf) { USBH_StatusTypeDef status = USBH_IsocReceiveData(&hUsbHostFS, buf, audio_handle->microphone.frame_l
i can not create a simple project on stm32F407 that blink leds with the use of freertos
I built a custom application based on the LwIP_HTTP_Server_Netconn_RTOS example in the CubeMX SDK 1.17.4. RX and TX work after power-up and in 50% of cases also after a debugger reset. However, in 50% of cases, RX doesn't work at all. The symptoms in the error case: the yellow LED flashes once when booting, then it's constantly on The link is detected as "up" The MMCTGFCR register shows that some packets have been successfully sent (my application sends some packets after boot) No packet is received at all replugging the network cable usually makes everything work, but not always I restart the debugger multiple times until it works, but the whole situation is annoying. I wonder what the problem could be? Since I use the initialization code in the example, only the timing is different. Is there any timing dependency between phy and eth driver? Or can I rule out the phy as a potential problem here? I found this thread with a maybe similar problem, but the workaround proposed there seem
Hello all,I am on the STM23 H750 discovery dev. kit working either in Keil or CubeZone IDE-just started, anyway, so far so good, and according to the logic analyser the LIN works, at least the checksum is right :) So far I am sending the frame once the button is pressed, made with switch and different states... this only sends out the LIN frame once the button is pressed, is this normal, OK, or should the LIN frame be send once the button is pressed continuously every 3 or more seconds... For example, I am reading the bus from the other device, random, and it is sending out frame every few seconds, looks rather random... attaching a pic of analyser...Thank you in advance and I am looking forward!Best.
Hi all,I ran into an issue regarding FreeRTOS tickless idle mode. I wanted to share my findings and solution in case others encounter the same problem and also to ask if that's intended structure (so I am missing something) or if its not generated properly.Background:I was using SysTick as the OS kernel timebase.Tickless idle was enabled (configUSE_TICKLESS_IDLE = 1).I noticed that the portNVIC_SYSTICK_COUNT_FLAG_BIT was cleared unexpectedly during sleep, which caused the tickless idle implementation (vPortSuppressTicksAndSleep) to miscalculate elapsed ticks.Debugging revealed that the auto-generated SysTick_Handler in cmsis_os2.c was clearing the COUNTFLAG, even in tickless mode.The autogenerated handler looked like this: void SysTick_Handler(void) { /* Clear overflow flag */ SysTick->CTRL; if (xTaskGetSchedulerState() != taskSCHEDULER_NOT_STARTED) { xPortSysTickHandler(); } }Reading the Cortex-M documentation shows that reading SYST_CSR clears the COUNTFLAG.This m
Hi Sir,I tried to refer to the PWM example:~\stm32cubeh7-v1-12-0\STM32Cube_FW_H7_V1.12.0\Projects\STM32H743I-EVAL\Examples\TIM\TIM_PWMOutput I see the four GPIO pins are initialized: And I see the four PWM channels are setup: But I can't find the code where each GPIO pin is bound to each PWM channel or the ISR where each GPIO is toggled whenever a PWM channel interrupt occurs. Please advise. Thanks. Jimmy
Exploring ADC discontinuous mode with interrupts. Any issues calling HAL_ADC_Start_IT() from ADC ISR? Looks like a lot of code to run from an ISR.
Hello,I would like to transfer 3 linked list blocks over UART DMA. When I started HAL_MDMA_START_IT, it transmits only 16 bytes. How can I send big files back to back? Configurations are as follows:MCU : STM32H7 seriesFirmware : Last release
Hello,[Question]How should I modify the sample project so that I can achieve the expected current consumption in standby mode (as described in the user manual)?[Board]NUCLEO-U385RG-Q[Development Environment]STM32CubeIDE 1.19.0STM32CubeMX 6.15.0[PWR_STANDBY]I am using the sample project “PWR_STANDBY” generated from STM32CubeMX 6.15.0. I would like to modify this project for my purpose.[Goal]I want to put the board into standby mode, measure the current through JP4, and reproduce the expected value described in the user manual (https://www.st.com/resource/en/datasheet/stm32u385rg.pdf, page 115).[Current Situation]When I run the sample project without any modification, I measure about 255 µA. This is much higher than the expected value in the user manual.Thank you for your advice and support.
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.