Join conversations with your peers and ST experts. Explore the full potential of STM32 microcontrollers for your embedded design.
Most recent activity
Hello,I am trying to communicate with an SDI-12 sensor using STM32L072CZY6TR. I'm using UART half-duplex with the following configuration:Baud rate: 1200Word length: 7 bitsParity: EvenStop bits: 1My questions:Do I need a UART to SDI-12 converter module, or can I connect the sensor directly to the STM32?Do I need signal inversion, and if so, should it be done in hardware or software?What pull-up resistor value is recommended for the SDI-12 data line?My current understanding:SDI-12 uses inverted logic compared to standard UARTSDI-12 requires a pull-up resistor on the data lineLevel shifting may be needed between 3.3V and 5VHas anyone successfully implemented SDI-12 communication with STM32L0 series? Any schematic examples or code snippets would be greatly appreciated.Thank you!
My application senario: sample the sensor signal every second, and transmit through UART. to save power supply, I select ADC single mode, and used average as filter.void ConfigureADC(void) { ADC1->CFGR1 |= ADC_CFGR1_AUTOFF; ADC1->CFGR2 = (ADC1->CFGR2 & (~ADC_CFGR2_CKMODE)) | (ADC_CFGR2_OVSE | ADC_CFGR2_OVSR_2 | ADC_CFGR2_OVSR_1 | ADC_CFGR2_OVSR_0| ADC_CFGR2_OVSS_2); ADC1->SMPR |= ADC_SMPR_SMP_0 | ADC_SMPR_SMP_1 | ADC_SMPR_SMP_2; ADC1->CR |= ADC_CR_ADEN; ADC->CCR |= ADC_CCR_VREFEN|ADC_CCR_TSEN; } unsigned int SignleADC(unsigned long int channel) { ADC1->CHSELR = channel; ADC1->CR |= ADC_CR_ADSTART; while ((ADC1->ISR & ADC_ISR_EOC) == 0) { } ADC1->CR |= ADC_CR_ADSTP; return ADC1->DR; } unsigned int Sensor_Read(void) { unsigned int gas[128]; unsigned long int read=0; for(unsigned char i=0;i<128;i++) gas[i] = SignleADC(ADC_CHSELR_CHSEL5); for(unsigned char i=0;i<128;i++) read += gas[i]; read = read>>7; return((unsigned int
I'm trying to get USBX MSC working in standalone mode on the STM32H573I Discovery board.I've come across a few tutorials for setting up USBX in VCP mode and have attempted to adapt them for MSC, but I haven’t been able to get the USB to enumerate properly. My background is in electronic hardware design, so this software side is quite new to me.Are there any tutorials specifically for setting up USB MSC in standalone mode that I can follow? Alternatively, are there any example projects available?Thank you
I've be trying to learn CAN for the past few days for a project using 2 Nucleo F103RB and 2 CAN transceivers. I made a very basic code using normal mode and without using RTR. Now I want to learn how to code using RTR, can someone help me please?(I already know what is RTR, I want to use it and can't find where to learn it).
Hi all,We’re a small startup developing a commercial product using an STM32H755ZI, and we’re getting ready to ship. One of the key things we want to bulletproof before launch is firmware recovery for end users, especially in case the firmware upload fails (e.g., they unplug during flashing, or the update crashes). At the moment we erase the flash memory and uploads elf files using dfu utils. It works most of the times but we've noticed that when it fails there is no way of getting the device running again unless st-link is used. Even having a switch for boot pin is not helping.Here are our questions:• Is relying on the dfu utils safe and recommended for production units?• What are the best practices for implementing this kind of user-friendly recovery flow?• Are there better tools or alternatives to dfu-util for desktop apps?Any help or advice would be really appreciated. Thanks!
Hi ST Community,I'm working with the STM32U5G9ZJT6Q and need to send real-time data from DCMI over USB through CDC . I generated a CDC-ACM project using CubeMX 6.14.0, and by default, it appears as a Virtual COM Port under device manager . Then i used Zadig to replace the driver with libusb-win32, and now the device shows up under libusb devices, ready for high-speed (HS) USB communication.However, all CDC-ACM examples I’ve found using with UART, which doesn’t meet the performance needs for my video streaming use case.I’m requesting a sample project or reference code using the STM32U5 USB stack, where CDC-ACM works with libusb (HS mode) and does not rely on UART, so I can send DCMI data directly over USB.thanks,
Hello everyone,I have a project using the STM32H7, using FreeRTOS and with a FatFS (ChaN) runnin on a 4GB eMMC (Kingston), using peripheral SDMMC1.Normally everything works fine. SDMMC1 and FatFS (FAT32) are initialized at main, before OS, and is used later on for many things such as creating and writing/reading files, etc.However, we found some devices that were working fine and suddenly (after a couple of thousands of writings in the eMMC, I'd assume not too intense) we start having a constant and reproducible error. What happens is that the FatFS initializes OK but as soon as we want to write something (still at main, before OS), it fails. Basically when trying to open a file (that already exists) it fails with FR_DISK_ERR and we cannot use the FatFS anymore. Trying to debug a bit, I saw that on the lowest level HAL_MMC_ReadBlocks (from stm32h7xx_hal_mmc.c) is failing with HAL_TIMEOUT.However, if I send a "reset" command to our device (it basically just executes a __NVIC_SystemReset
Hello,As per CM4 guide and TRM of Nucleo f446re,interruot vector table is array of function pointers and each pointer holds the entry address(initial address) of each IRQ_handler, Where interrupt IRQ_number is used for indexing.While debugging I failed to observe the intial address of teh reset handler and USART2_Handler at location 0x0000 0004 and 0x0000 00DC respectively.Please find the samething in attachments.Address fo the IRQ_handlers are available in expressions window snapshot and actuall value stored at location 0x0000 0004 and 0x0000 00DC is not matching.Am I missing something here?I am just verifying my understanding -->"At each location in IVTable,address oif IRQ handlers should be ther (&<IRQ_Handler_Name> "
Hey everyone. I am trying to print something on TeraTerm console using USART2. I am using STM32L4R5ZI board for this function. Below is a picture of my .ioc file: Below is the Code in my while(1) Loop: Below is the configuration for USART2 in main.c file and msp_c: Finally, this is my clock configuration for this project: My teraterm settings are as follows: I am trying to send some data to TeraTerm. However, nothing is being printed out. Can someone help me out with this issue? @Peter BENSCH
So, I've got a circular transfer working, sending 24-bit words to a dual channel SPI DAC (with hardware NSS), paced by TIM2 and working well. For every edge of TIM2 a word is sent. Since this is a dual channel DAC, I would ideally like the transfer 2 words for each pulse of TIM2. So if I had a buffer [ADATA1, BDATA2, ADATA1, BDATA2, etc..], we would send ADATA1, and immediately (after the idle cycles setup for SPI) send BDATA1, then on the next trigger edge, do the same for ADATA2 and BDATA2. Is this possible? Maybe with the 2D addressing channels? I cannot simply set the timer exactly twice as fast as the one that my ADC is using or else they slightly loose sync and get really ugly jitter. Not sure what this is but it just won't work for me. With my ADC DMA and DAC using the same timer they are locked up perfectly and no jitter.
Does the BLE stack full also support encrypted advertising? The only example available is for the extended stack (link)
Hello,I am using STM32F030C8T6 to implement Modbus RTU protocol which uses UART and RS485 as physical layer.I have already implemented the complete protocol with UART's RXNE and TCIE interrupts.Now I am trying to implement through DMA by which I will free micro-controller core from lot of interrupts.With great support from ST forum, I already implemented Tx using DMA.Now I m trying to implement the RX logics using UART through DMA.As usual I am stuck somewhere and I request your support. Please help me to fix this issue too.As per the Modbus protocol, my hardware as a slave will read sequence bytes, process and then respond.Length of sequence will not be known during reception of the bytes.Slave must decide the length of frame when there a silence in the Rx for more than 3.5 times of character length.For this logic, I have used IDLE Line interrupt to detect initial silence then, inside the IDLE ISR I start Timer 3 in OPM for 3.6ms (time depends Baud rate and number of 11 bits streams).
I have stm32cubeIDE version 1.17.0 and I'm not able to import this project and build it: https://github.com/stm32-hotspot/USBD_Composite_STM32H503
I'm starting a project on the STM32U5G9, and one feature we want is USB connectivity, just a simple virtual COM port (CDC class). Looking at the Middleware picker in CubeMX, the only USB-related items are USBPD (don't need Power Delivery at the moment), and USBX, which is the ThreadX/Azure RTOS USB stack. If I look for CubeMX examples for the STM32U5G9J-DK2, the only USB examples offered are for ThreadX and USBX.Is it reasonable to assume that if I don't want to be writing my USB application from scratch on the STM32U5, I should be using ThreadX/Azure RTOS instead of FreeRTOS?Dana M.
Hello everyoneI watched the video on ST's MOOC about how to integrate FUOTA via BLE for the STM32WB55 microcontroller and applied this Bootloader feature via the "ST BLE Sensor" smartphone app to the project of a product I'm developing and it's working very well. Now I need to work with a partner to develop our proprietary application on our smartphone app for both Android and iOS. I tried to find something on GitHub, but I couldn't find it. If you have a link or any recommendations, I'd appreciate it.Edited to fix FOUTA typo.
Hi all,I'm Fairly new to both STM32 and the SPI protocol. I'm struggling to get communication working. MCU: STM32F722RETXDevices: GS12281 & GS12170I have both devices connected to my SPI1 bus with SPI initialized as follows: hspi1.Instance = SPI1; hspi1.Init.Mode = SPI_MODE_MASTER; hspi1.Init.Direction = SPI_DIRECTION_2LINES; hspi1.Init.DataSize = SPI_DATASIZE_8BIT; hspi1.Init.CLKPolarity = SPI_POLARITY_LOW; hspi1.Init.CLKPhase = SPI_PHASE_1EDGE; hspi1.Init.NSS = SPI_NSS_SOFT; hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_16; hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB; hspi1.Init.TIMode = SPI_TIMODE_DISABLE; hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE; hspi1.Init.CRCPolynomial = 7; hspi1.Init.CRCLength = SPI_CRC_LENGTH_DATASIZE; hspi1.Init.NSSPMode = SPI_NSS_PULSE_DISABLE; The device(s) Datasheets specify a 48bit (3 word) communication exchange for read/write operations. I've minimized the test code to the bare minimum to try writing to th
Hi All, I had the need to use the independent watchdog timer and rather than a straight reset of the system I wished to put the system into a fault mode. You can do this by examining the RCC control and status register (CSR) viz: int main(void) { /* MCU Configuration--------------------------------------------------------*/ /* TODO: */ /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ HAL_Init(); /* Configure the system clock */ SystemClock_Config(); MX_USART2_UART_Init(); checkIWDG(); #if(IWDG_ENABLE == 1) void checkIWDG(void) { if(RCC->CSR & RCC_CSR_IWDGRSTF) { /*** FAULT MODE ***/ /* The IWDG has reset the system */ printf("IWDG Reset\n\r"); /* Run fans flat out */ GPIO_InitTypeDef GPIO_InitStruct = {0}; __HAL_RCC_GPIOA_CLK_ENABLE(); /*Configure GPIO pins : PA9_FAN1_POWER_Pin PA10_FAN2_POWER_Pin */ GPIO_InitStruct.Pin = PA9_FAN1_POWER_Pin|PA10_FAN2_POWER_Pin|PA11_TEST_OUTPUT_Pin|PA6_TIM3_CH1_FAN1_SPEED_DEMAN
Hi, from the update it looks like current sensing mode can now be enabled on 6 steps, but from the MC workbench it still looks disabled. attached to confirm it's the mc workbench 6.4.0 - see attached imagesi selected EVSPIN32G4NH which has stspin32g4 + evspin32g4
I'm working on a project using STM32U5 and I'm trying to communicate with a TMC2209 stepper driver over UART in single-wire (half-duplex) mode. This is the connections: In order to test the connection I'm trying to read the IFCNT values of the driver, which is the register in TMC2209 frame counter used to track how many valid UART datagrams the driver has received since power-on. This is my code: /* USER CODE BEGIN PV */ volatile uint8_t tx_done = 0; volatile uint8_t rx_done = 0; uint8_t tmc2209_rx_buf[8]; /* USER CODE END PV *//* USER CODE BEGIN 0 */ uint8_t TMC2209_calcCRC(uint8_t* datagram, uint8_t datagramLength) { uint8_t crc = 0; uint8_t currentByte; for(uint8_t i=0; i<datagramLength; i++) { currentByte = datagram[i]; for(uint8_t j=0; j<8; j++) { if((crc >> 7) ^ (currentByte & 0x01)) { crc = (crc << 1) ^ 0x07; } else { crc <<= 1; } currentByte >>= 1; } } return crc; } void TMC2209_WriteRegister(uint8_t reg, uint3
[PN]: STM32G431CB (B-G431B-ESC1), Custom board with STM MCU[VERSION]: MCSDK 6.3.0[TOOL]: STM32CubeIDE 1.16.1, MotorControl Workbench 6.3.0[DETAILS]:I’m analyzing the Back-EMF sensing circuit of the B-G431B-ESC1 board for FOC.In this circuit:The back EMF from each motor phase is connected directly to the MCU ADC pin.The battery voltage is up to 25V (6S).Each BEMF line appears to be connected through a diode to 3.3V and GPIO_BEMF.All BEMF signals seem to share a common GPIO_BEMF.My confusion:How is the high phase voltage (e.g., 25V) safely sensed by the MCU’s ADC which only accepts ~3.3V max?How is this protection implemented with minimal components?How does this translate into proper zero-cross detection for sensorless FOC?I am building a custom ESC board (6S, 12S, and 20S variants) with similar sensorless FOC requirements. I want to design a robust and safe Back-EMF sensing system that:Can safely interface high voltage (~50V or ~80V in 12S/20S) phase lines to MCU GPIO/ADC.Still al
Hi, Are there any EV (Evaluation) boards available that support GPS functionality? Thank You
Hello, I've bought Riverdi board and I'm developing a code that uses Ethernet and act as TCP server. The code sends "Hello word %d", i++ every 10ms on that TCP socket and it works fine, but when I try to send some byte on client size it goes to HardFault: Can some one help me ? it is related to HardFault_Handler when enable LWIP and touchgfx - Page 2 - STMicroelectronics Community
Hi I'm trying to connect NUCLEO-H755ZI-Q with X-NUCLEO-WB05KN via usart. I'm using usart2 (pd3, pd4, pd5, pd6) on the host board and CN7 on the shield. BLE initialisation fails if I set `hw-flow-control` in Zephyr in devicetree. Without flow control and with the same connection, it works fine. I'm using BLE_TransparentMode_UART_with_Updater from X-CUBE-wb05n. I tried soldering SB10 and SB11, but to no avail. It would be great to have a full datasheet with a detailed description of all interfaces and how they work, the only document I could find is UM3355, which is not very helpful.
Setup: NUCLEO-H503RB with X-NUCLEO-IKS4A1, using STM32CubeIDE. To familiarize myself with I3C, I am playing around in this setup and have some source code which causes I3C interaction between controller and target. I have a logic analyzer attached, and all looks good. However, this only works when executing the code without breakpoints. As soon as I break to debug, I can never see the "Tx FIFO not full flag" in the event register but the code relies on it. When I continue stepping, the code obviously misbehaves because it doesn't see the flag either. Code that was executed without breakpoints does see the flag and behaves as expected. Does the flag auto-clear after a while? Where is this documented? Why do I never see it in the debugger? This prevents me from stepping through the code which contradicts the purpose of my setup. Example: I hit a breakpoint in the interrupt handler in stm32h5xx_hal_i3c.c. The event register does not show the TXFNFF: But the ISR code has obviou
Hello, I am working with an STM32F769I-DISCO board and trying to implement functionality that allows switching between USB Host and Device modes via a button press. I have configured the board for OTG/Dual Role in STM32CubeMX, but I did not enable the Middleware for USB Host or USB Device, so I need to manage the switching at the register level and using HAL APIs. I would appreciate any advice or code examples for properly managing this switch: Initialization: How should I correctly initialize the USB peripheral to support both modes (Host and Device)? Mode Switching: What are the recommended steps to deactivate one mode and activate the other without causing conflicts or stability issues? Specific APIs and Registers: Are there specific HAL APIs to use, or do I need to manipulate the registers directly? If so, which are most relevant for this purpose? I've attempted to implement a basic switch using HAL_PCD_Stop() and HAL_HCD_Start(), but I'm not sure if this is the best approa
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.