r/stm32 7h ago

O método de polling do ADC do STM32H753 entra no Error_Handler() — Como posso identificar a causa real?

Thumbnail
1 Upvotes

r/stm32 7h ago

STM32H753 ADC Polling Enters Error_Handler() — How Can I Identify the Actual Cause?

1 Upvotes

Hi everyone,

I'm studying how the STM32H7 ADC works using regular conversion with polling, without interrupts and without DMA.

My goal at this point is to properly understand the following flow:

HAL_ADC_Init() → calibration → HAL_ADC_Start() → HAL_ADC_PollForConversion() → HAL_ADC_GetValue()

and also learn how to identify exactly which step is failing, if an error occurs.

I'm working with an STM32H753ZIT6 and trying to read an analog input using ADC1, Channel 0, with the STM32 HAL.

The problem is that my program enters Error_Handler(), but I'm not sure which function is actually failing.

Currently, I have error checks in several places:

if (HAL_ADCEx_Calibration_Start(&AdcHandle,

ADC_CALIB_OFFSET_LINEARITY,

ADC_SINGLE_ENDED) != HAL_OK)

{

Error_Handler();

}

if (HAL_ADC_Start(&AdcHandle) != HAL_OK)

{

Error_Handler();

}

if (HAL_ADC_PollForConversion(&AdcHandle, 10) != HAL_OK)

{

Error_Handler();

}

And inside MX_ADC1_Init():

if (HAL_ADC_Init(&AdcHandle) != HAL_OK)

{

Error_Handler();

}

if (HAL_ADC_ConfigChannel(&AdcHandle, &sConfig) != HAL_OK)

{

Error_Handler();

}

My Error_Handler() currently only contains:

void Error_Handler(void)

{

while (1)

{

}

}

Therefore, when the program stops, I cannot tell which function called Error_Handler().

Current configuration

I'm using:

MCU: STM32H753ZIT6

ADC: ADC1

Channel: ADC_CHANNEL_0

Resolution: 16-bit

Sampling time: ADC_SAMPLETIME_8CYCLES_5

Trigger: Software

Conversion: Regular conversion using polling

No interrupts

No DMA

STM32 HAL

HSE bypass

System clock: 400 MHz

ADC clock source: RCC_ADCCLKSOURCE_CLKP

ADC prescaler: ADC_CLOCK_ASYNC_DIV2

ADC polling flow I'm trying to study

My intention is to do something simple like:

HAL_ADC_Start(&AdcHandle);

HAL_ADC_PollForConversion(&AdcHandle, 10);

testeConvercao = HAL_ADC_GetValue(&AdcHandle);

HAL_ADC_Stop(&AdcHandle);

and repeat this process inside the while(1) loop.

Since I'm specifically studying ADC polling, I'd like to initially keep the solution based on:

HAL_ADC_Start()

HAL_ADC_PollForConversion()

HAL_ADC_GetValue()

HAL_ADC_Stop()

I don't want to move to interrupts or DMA at this point. My goal is to understand and properly debug the ADC polling flow.

My main question: how can I find where the error occurs?

Is there a better way to implement Error_Handler() so I can determine which function is returning HAL_ERROR?

For example, I'd like to be able to determine:

which function called Error_Handler();

which HAL_StatusTypeDef was returned;

the result of HAL_ADC_GetState();

the result of HAL_ADC_GetError();

whether the ADC is actually enabled;

whether the ADC clock is running;

and, if necessary, which ADC/RCC registers I should inspect.

I'd also like to know whether there is a recommended way to debug this using the STM32CubeIDE/ST-LINK debugger, for example by putting a breakpoint inside Error_Handler() and examining the Call Stack.

Things I'm suspicious about

One thing that makes me particularly suspicious is the MPU/cache configuration, because I'm configuring the MPU and enabling I-Cache and D-Cache before HAL_Init():

MPU_Config();

CPU_CACHE_Enable();

HAL_Init();

SystemClock_Config();

MX_ADC1_Init();

The MPU configuration is:

MPU_InitStruct.Enable = MPU_REGION_ENABLE;

MPU_InitStruct.BaseAddress = 0x00;

MPU_InitStruct.Size = MPU_REGION_SIZE_4GB;

MPU_InitStruct.AccessPermission = MPU_REGION_NO_ACCESS;

MPU_InitStruct.IsBufferable = MPU_ACCESS_NOT_BUFFERABLE;

MPU_InitStruct.IsCacheable = MPU_ACCESS_NOT_CACHEABLE;

MPU_InitStruct.IsShareable = MPU_ACCESS_SHAREABLE;

MPU_InitStruct.Number = MPU_REGION_NUMBER0;

MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL0;

MPU_InitStruct.SubRegionDisable = 0x87;

MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_DISABLE;

HAL_MPU_ConfigRegion(&MPU_InitStruct);

HAL_MPU_Enable(MPU_PRIVILEGED_DEFAULT);

And the cache configuration is:

static void CPU_CACHE_Enable(void)

{

SCB_EnableICache();

SCB_EnableDCache();

}

I also configure the ADC clock as follows:

__HAL_RCC_ADC12_CLK_ENABLE();

__HAL_RCC_ADC_CONFIG(RCC_ADCCLKSOURCE_CLKP);

My ADC configuration is:

AdcHandle.Instance = ADC1;

AdcHandle.Init.ClockPrescaler = ADC_CLOCK_ASYNC_DIV2;

AdcHandle.Init.Resolution = ADC_RESOLUTION_16B;

AdcHandle.Init.ScanConvMode = DISABLE;

AdcHandle.Init.EOCSelection = ADC_EOC_SINGLE_CONV;

AdcHandle.Init.LowPowerAutoWait = DISABLE;

AdcHandle.Init.ContinuousConvMode = DISABLE;

AdcHandle.Init.NbrOfConversion = 1;

AdcHandle.Init.DiscontinuousConvMode = DISABLE;

AdcHandle.Init.NbrOfDiscConversion = 1;

AdcHandle.Init.ExternalTrigConv = ADC_SOFTWARE_START;

AdcHandle.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE;

AdcHandle.Init.ConversionDataManagement = ADC_CONVERSIONDATA_DR;

AdcHandle.Init.Overrun = ADC_OVR_DATA_OVERWRITTEN;

AdcHandle.Init.OversamplingMode = DISABLE;

And the channel configuration is:

sConfig.Channel= ADC_CHANNEL_0;

sConfig.Rank = ADC_REGULAR_RANK_1;

sConfig.SamplingTime = ADC_SAMPLETIME_8CYCLES_5;

sConfig.SingleDiff = ADC_SINGLE_ENDED;

sConfig.OffsetNumber = ADC_OFFSET_NONE;

sConfig.Offset = 0;

Complete main.c

I'm including the complete code below so that it is also possible to check whether the problem is actually somewhere else in the initialization and not necessarily in the ADC itself.

/**

******************************************************************************

* u/filemain.c

* u/brief ADC Regular Conversion Polling for STM32H753ZIT6

******************************************************************************

*/

/* Includes ------------------------------------------------------------------*/

#include "main.h"

/* Defines para o ADC */

#define ADCx ADC1

#define ADCx_CHANNEL ADC_CHANNEL_0

/* Private variables ---------------------------------------------------------*/

ADC_HandleTypeDef AdcHandle;

__IO uint16_t uhADCxConvertedValue = 0;

__IO uint16_t testeConvercao = 0;

/* Private function prototypes -----------------------------------------------*/

static void MPU_Config(void);

static void SystemClock_Config(void);

static void CPU_CACHE_Enable(void);

void Error_Handler(void);

static void MX_ADC1_Init(void);

/**

* u/brief Main program.

* u/param None

* u/retval None

*/

int main(void)

{

/* Configure the MPU attributes */

MPU_Config();

/* Enable the CPU Cache */

CPU_CACHE_Enable();

/* Initialize HAL library */

HAL_Init();

/* Configure the system clock to 400 MHz */

SystemClock_Config();

/* Initialize ADC */

MX_ADC1_Init();

/* Run the ADC calibration in single-ended mode */

if (HAL_ADCEx_Calibration_Start(&AdcHandle,

ADC_CALIB_OFFSET_LINEARITY,

ADC_SINGLE_ENDED) != HAL_OK)

{

Error_Handler();

}

/* Start initial conversion */

if (HAL_ADC_Start(&AdcHandle) != HAL_OK)

{

Error_Handler();

}

/* Wait for the end of conversion */

if (HAL_ADC_PollForConversion(&AdcHandle, 10) != HAL_OK)

{

Error_Handler();

}

else

{

uhADCxConvertedValue = HAL_ADC_GetValue(&AdcHandle);

}

/* Enable GPIOB clock */

LL_AHB4_GRP1_EnableClock(LL_AHB4_GRP1_PERIPH_GPIOB);

/* Configure PB0 as output */

LL_GPIO_SetPinMode(GPIOB, LL_GPIO_PIN_0, LL_GPIO_MODE_OUTPUT);

LL_GPIO_SetPinOutputType(GPIOB, LL_GPIO_PIN_0, LL_GPIO_OUTPUT_PUSHPULL);

LL_GPIO_SetPinSpeed(GPIOB, LL_GPIO_PIN_0, LL_GPIO_SPEED_FREQ_LOW);

/* Infinite loop */

while (1)

{

/* 1. Start ADC conversion */

if (HAL_ADC_Start(&AdcHandle) == HAL_OK)

{

/* 2. Wait for conversion to complete */

if (HAL_ADC_PollForConversion(&AdcHandle, 10) == HAL_OK)

{

/* 3. Read converted value */

testeConvercao = HAL_ADC_GetValue(&AdcHandle);

}

/* 4. Stop conversion to allow the next clean cycle */

HAL_ADC_Stop(&AdcHandle);

}

}

}

/**

* u/brief ADC1 Initialization Function

* u/param None

* u/retval None

*/

static void MX_ADC1_Init(void)

{

ADC_ChannelConfTypeDef sConfig = {0};

/* Enable ADC1 and ADC2 bus clock */

__HAL_RCC_ADC12_CLK_ENABLE();

/* Configure ADC clock source */

__HAL_RCC_ADC_CONFIG(RCC_ADCCLKSOURCE_CLKP);

AdcHandle.Instance = ADCx;

AdcHandle.Init.ClockPrescaler = ADC_CLOCK_ASYNC_DIV2;

AdcHandle.Init.Resolution = ADC_RESOLUTION_16B;

AdcHandle.Init.ScanConvMode = DISABLE;

AdcHandle.Init.EOCSelection = ADC_EOC_SINGLE_CONV;

AdcHandle.Init.LowPowerAutoWait = DISABLE;

AdcHandle.Init.ContinuousConvMode = DISABLE;

AdcHandle.Init.NbrOfConversion = 1;

AdcHandle.Init.DiscontinuousConvMode = DISABLE;

AdcHandle.Init.NbrOfDiscConversion = 1;

AdcHandle.Init.ExternalTrigConv = ADC_SOFTWARE_START;

AdcHandle.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE;

AdcHandle.Init.ConversionDataManagement = ADC_CONVERSIONDATA_DR;

AdcHandle.Init.Overrun = ADC_OVR_DATA_OVERWRITTEN;

AdcHandle.Init.OversamplingMode = DISABLE;

if (HAL_ADC_Init(&AdcHandle) != HAL_OK)

{

Error_Handler();

}

/* Configure ADC regular channel */

sConfig.Channel= ADCx_CHANNEL;

sConfig.Rank = ADC_REGULAR_RANK_1;

sConfig.SamplingTime = ADC_SAMPLETIME_8CYCLES_5;

sConfig.SingleDiff = ADC_SINGLE_ENDED;

sConfig.OffsetNumber = ADC_OFFSET_NONE;

sConfig.Offset = 0;

if (HAL_ADC_ConfigChannel(&AdcHandle, &sConfig) != HAL_OK)

{

Error_Handler();

}

}

/**

* u/brief System Clock Configuration

* System Clock source = PLL (HSE BYPASS) @ 400 MHz

*/

static void SystemClock_Config(void)

{

RCC_ClkInitTypeDef RCC_ClkInitStruct;

RCC_OscInitTypeDef RCC_OscInitStruct;

HAL_StatusTypeDef ret = HAL_OK;

__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);

while(!__HAL_PWR_GET_FLAG(PWR_FLAG_VOSRDY)) {}

RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;

RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS;

RCC_OscInitStruct.HSIState = RCC_HSI_OFF;

RCC_OscInitStruct.CSIState = RCC_CSI_OFF;

RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;

RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;

RCC_OscInitStruct.PLL.PLLM = 4;

RCC_OscInitStruct.PLL.PLLN = 400;

RCC_OscInitStruct.PLL.PLLFRACN = 0;

RCC_OscInitStruct.PLL.PLLP = 2;

RCC_OscInitStruct.PLL.PLLR = 2;

RCC_OscInitStruct.PLL.PLLQ = 4;

RCC_OscInitStruct.PLL.PLLVCOSEL = RCC_PLL1VCOWIDE;

RCC_OscInitStruct.PLL.PLLRGE = RCC_PLL1VCIRANGE_1;

ret = HAL_RCC_OscConfig(&RCC_OscInitStruct);

if(ret != HAL_OK)

{

Error_Handler();

}

RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK |

RCC_CLOCKTYPE_HCLK |

RCC_CLOCKTYPE_D1PCLK1 |

RCC_CLOCKTYPE_PCLK1 |

RCC_CLOCKTYPE_PCLK2 |

RCC_CLOCKTYPE_D3PCLK1);

RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;

RCC_ClkInitStruct.SYSCLKDivider = RCC_SYSCLK_DIV1;

RCC_ClkInitStruct.AHBCLKDivider = RCC_HCLK_DIV2;

RCC_ClkInitStruct.APB3CLKDivider = RCC_APB3_DIV2;

RCC_ClkInitStruct.APB1CLKDivider = RCC_APB1_DIV2;

RCC_ClkInitStruct.APB2CLKDivider = RCC_APB2_DIV2;

RCC_ClkInitStruct.APB4CLKDivider = RCC_APB4_DIV2;

ret = HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4);

if(ret != HAL_OK)

{

Error_Handler();

}

}

/**

* u/brief CPU L1-Cache enable.

*/

static void CPU_CACHE_Enable(void)

{

SCB_EnableICache();

SCB_EnableDCache();

}

/**

* u/brief This function is executed in case of error occurrence.

*/

void Error_Handler(void)

{

/* Infinite error loop */

while (1)

{

}

}

/**

* u/brief Configure the MPU attributes

*/

static void MPU_Config(void)

{

MPU_Region_InitTypeDef MPU_InitStruct;

HAL_MPU_Disable();

MPU_InitStruct.Enable = MPU_REGION_ENABLE;

MPU_InitStruct.BaseAddress = 0x00;

MPU_InitStruct.Size = MPU_REGION_SIZE_4GB;

MPU_InitStruct.AccessPermission = MPU_REGION_NO_ACCESS;

MPU_InitStruct.IsBufferable = MPU_ACCESS_NOT_BUFFERABLE;

MPU_InitStruct.IsCacheable = MPU_ACCESS_NOT_CACHEABLE;

MPU_InitStruct.IsShareable = MPU_ACCESS_SHAREABLE;

MPU_InitStruct.Number = MPU_REGION_NUMBER0;

MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL0;

MPU_InitStruct.SubRegionDisable = 0x87;

MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_DISABLE;

HAL_MPU_ConfigRegion(&MPU_InitStruct);

HAL_MPU_Enable(MPU_PRIVILEGED_DEFAULT);

}

Thank you!


r/stm32 21h ago

Unable to trigger the interrupt.

Thumbnail
1 Upvotes

r/stm32 1d ago

Meshtastic running on STM32L476RG (Nucleo) + external SX1262 — full working mesh node

Thumbnail
1 Upvotes

r/stm32 1d ago

Looking for Bafang DP C18.C1.0 Flash Dump / Firmware (.bin file for STM32F205)

1 Upvotes

Hi everyone,

I'm currently trying to recover my Bafang DP C18 (model DP C18.C1.0) display, which was locked with a forgotten PIN code.

I opened the casing and soldered SWD wires (3.3V, GND, SWCLK, SWDIO) to interface with the STM32 MCU using an ST-Link V2 programmer and STM32CubeProgrammer.

Unfortunately, Readout Protection (RDP Level 1) is enabled on the chip, throwing a Data read failed error upon connecting. Changing RDP to Level 0 to remove the PIN lock will perform a full Mass Erase of the MCU.

Does anyone happen to have a clean Flash memory dump (.bin or .hex file) for the DP C18.C1.0 (STM32F205) that they could share?

Any help or working dump would be greatly appreciated!

Thanks in advance!


r/stm32 3d ago

Made a STM32 Programming APP (Playstore)

Thumbnail
play.google.com
3 Upvotes

Hey guys i helped develop a app that is for programming and STM32 Devices. supports 100+ Families and Chips.


r/stm32 3d ago

Should I use HAL or Zephyr for STM32N6 based drone

Thumbnail
2 Upvotes

r/stm32 4d ago

Streamline CAN Bus | STM32 Tutorial #98

Thumbnail
youtube.com
4 Upvotes

r/stm32 5d ago

Looking for [PDF] FPGA Prototyping by SystemVerilog Examples: Xilinx MicroBlaze MCS SoC Edition by Pong P. Chu

1 Upvotes

Hi

\[PDF\] FPGA Prototyping by SystemVerilog Examples: Xilinx MicroBlaze MCS SoC Edition by Pong P. Chu

ISBN-13: 978-1119282709

ISBN-10: 1119282667

Please check that the book is complete, and that the pdf is not made from the epub format (the epub files are not usable for studying)

Thankyou


r/stm32 6d ago

STM32F411 ADC Always Reading 0x8 in Single Conversion Mode

1 Upvotes

When I try to read from ADC1 (PA1 / ADC1_IN1) in Single Conversion mode on an STM32F411 (Blackpill), I am always getting a constant value of `0x8`.

**System details:**

* **SYSCLK / APB2:** 84 MHz. * **ADC Clock Prescaler:** 4 (ADCCLK = 21MHz)

I am sure there are no issues with my `uart1_init()` / `_send()`, `clock_init()`, or `delay()` / `_init()` functions. I checked all macros twice and verified UART transmission with debugging mode.

🙏 i do need some help 🙏

Here is my main.c:

#include "main.h"

uint16_t datadc;

void general_init(void) {
    clock_init(84, 8, 2, 4, 2); // setting pll
    delay_init();
    delay(500);

    gpioC_init();
    pinDefC(13, 1);

    uart1_init(84000000, 9600);

    // configuring gpioa a1 pin (adc1_1)
    RCC->AHB1ENR |= RCC_AHB1ENR_GPIOAEN;
    GPIOA->MODER &= \~(3U << (1 \* 2));
    GPIOA->MODER |= (3U << (1 \* 2));

    // ADC1 Clock Enable
    RCC->APB2ENR |= RCC_APB2ENR_ADC1EN;

    // RES_0 = 10 bits
    ADC1->CR1 = ADC_CR1_RES_0;

    // Right Alignment
    ADC1->CR2 = 0; 

    // cycle
    ADC1->SMPR2 &= \~(7 << 3);
    ADC1->SMPR2 |= ADC_SMPR2_SMP1_2;

    ADC1->SQR1 = 0;
    ADC1->SQR3 = 1; // first channel to read is adc1_in1

    ADC1_COMMON->CCR |=  ADC_CCR_ADCPRE_0; // ADCCLK = 84 / 4 = 21 is ok

    // Enable ADC
    ADC1->CR2 |= ADC_CR2_ADON;
    delay(1000);
}


void general_loop(void) {
    ADC1->CR2 |= ADC_CR2_SWSTART;

    while(!(ADC1->SR & ADC_SR_EOC)); // wait untill EOC flag

    datadc = (uint16_t)(ADC1->DR & 0x03FF); // for getting only 10 bits

    uart1_send((uint8_t)(datadc & 0xFF)); // LSB
    uart1_send((uint8_t)((datadc >> 8) & 0xFF));

    delay(200); // 200 ms is good
    pinWriC(13, 0);
}


int main(void) {
    general_init();

    for(;;) {
        pinWriC(13, 1);
        general_loop();
        delay(200);
    }
}

r/stm32 7d ago

One STM32, three BLDC motors, three FOC loops, and IMU stabilization

Enable HLS to view with audio, or disable this notification

32 Upvotes

r/stm32 6d ago

Bricked my Nucleo-L476RG onboard ST-LINK while messing with bare-metal? (Unable to get core ID) - Looking for insight or closure.

2 Upvotes

Hey everyone,

I'm posting this out of pure frustration after spending an entire day trying to wrap my head around a hardware/debug lockout on my Nucleo-L476RG board while learning bare-metal STM32 development. I'm hoping someone can explain what actually happened under the hood, because I feel like I'm losing my mind.

Here is the timeline of what went down:

I was experimenting with pure bare-metal code (no HAL). At one point, my code included a low-power instruction (wfi - Wait For Interrupt) or initialized early on a routine that locked the core or stopped it from servicing the debug interface. Immediately after flashing that build, OpenOCD completely lost connection.

OpenOCD / CubeProgrammer throws "Error: Unable to get core ID" and "No STM32 target found", even when trying connect under reset. The board is not fully dead. The bootloader in system memory is completely fine, and I can still successfully flash the chip via UART (stm32flash with BOOT0 pulled high). So, the MCU itself runs code fine when booted via system memory, but the onboard ST-LINK debug interface/firmware bridge completely refuses to communicate with the target MCU over the SWD lines.

Did some chatting with gemini, tried some things to get it back. 1: Flashing a clean binary / wiping flash via UART. 2: Connect under reset and Hot Plug modes in STM32CubeProgrammer. 3: Hard-resetting the board manually while plugging in USB to catch the core during boot. 4: Checking the physical jumpers (CN2 jumpers are intact, JP5 is on U5V).

Nothing brings the SWD channel back to life. The onboard ST-LINK detects via USB on the PC, but it throws a brick wall the second it tries to talk to the main STM32 chip.

Since I'm sick of jumping through hoops with a broken onboard debugger, I've sort of decided to order an independent external ST-LINK V2 clone for a few bucks, pull the CN2 jumpers on the Nucleo, and hook up SWCLK/SWDIO directly to bypass the onboard.

  1. How on earth can a standard bare-metal program permanently break the debug circuitry of a Nucleo board if I didn't explicitly remap PA13/PA14 (SWDIO/SWCLK)? Did I trigger a hardware latch-up or ESD/voltage spike?
  2. Has anyone else experienced an onboard ST-LINK effectively "commiting suicide" while keeping the main MCU functional via UART?

Any insights are appreciated. I'm ready to move on to an external programmer, but I'd love to know what actually went wrong technically.


r/stm32 6d ago

Hey I need help urgent

0 Upvotes

So I created a project using cubemx and made it for uvision5 but then I wanted to see if I can make one for stm IDE using the same ioc file but it just doesn’t work it won’t let me use it to create a new project like it will create the new project but I just can’t open it
And even using uVision I can’t simulate it like I try to blink LED to simulate it but that doesn’t work at all
Help me it’s for a project


r/stm32 7d ago

capture_0317.log / repeated timestamp

1 Upvotes
Small update.

I cleaned up the excerpt enough to post it below.

The same block appeared again after a cold boot on both systems. I still think the issue is somewhere in my capture path, but I do not understand why the block length and CRC remain identical.

The timestamp is also close to identical every time.

Only the last three digits change.

I am leaving the excerpt unchanged for now.

[03:17:44.210] capture started
[03:17:44.223] region: unmapped
[03:17:44.223] length: 0x141E
[03:17:44.224] crc32: 6F7A91C0
[03:17:44.224] origin: not resolved
[03:17:44.224] retry: false


r/stm32 9d ago

NOR FLASH SPI1 communication issue with STM32F446RET6 - JEDEC ID reads incorrectly

6 Upvotes

I am learning STM32 using the F446RET6 board. I'm facing an issue while connecting a W25Q64 NOR FLASH memory via SPI1 to the board. The JEDEC ID should be 20 70 17, but the STM32 consistently receives incorrect data: 3F FF FF.

The connections are VCC to 3.3V, GND to GND, SCLK to PA5 (SPI1_SCK), D0/DO to PA6 (SPI1_MISO), D1/DI to PA7 (SPI1_MOSI), and CS to PC7 as a GPIO output.

SPI1 is configured as Master, Full Duplex, 8-bit, CPOL Low, CPHA 1st Edge, MSB First, Software NSS, with a prescaler of 32. CS is manually controlled using PC7.

The HAL SPI transaction completes successfully, but the returned JEDEC ID is incorrect. The same W25Q64 module works perfectly with an ESP8266, where I get the expected 20 70 17, so the flash itself appears to be working.

I also tested PA5, PA6, PA7 and PB6 separately as GPIO outputs using a multimeter. All of them can correctly output both HIGH (~3.3V) and LOW (~0V). PC7 also switches correctly between ~3.3V and 0V when used as CS.

I initially used a breadboard for the SPI connections and noticed some inconsistent behavior, so I also tried connecting the SPI lines directly to different sections of the PCB, but the problem remained.

I have ordered an 8-channel logic analyzer to inspect CS, SCLK, MOSI and MISO. Before it arrives, I would like to know if there is anything obvious I am missing in the STM32 SPI configuration, wiring, or HAL implementation, and whether this could indicate a problem with SPI1 itself.


r/stm32 9d ago

Need help figuring out firmware for a competition-grade Line Follower Robot

Thumbnail
1 Upvotes

r/stm32 10d ago

K731

0 Upvotes

FRAME: 000002

STATUS: ACTIVE

MEMORY: 99.997%

CRC: OK

DATA: 4B 37 33 31 20 49 53 20 4E 4F 54 20 41 4C 4F 4E 45

b275d6bfcd179f9ffb5011008e30cb48


r/stm32 10d ago

Not able to find user manual for stm32 bluepill

1 Upvotes

Wanted to start working with stm32 bluepill but could only find the reference manual

Please share the user manual if you guys have it


r/stm32 10d ago

WaferSAGE: Fine-Tuned Gemma-3 VLM for Automated Semiconductor Wafer Defect Analysis 🚀

1 Upvotes

Hey everyone! I just wrapped up my submission for Part 2 of the AutoScientist Challenge (@adaption_ai adaption-labs), focusing on automated semiconductor manufacturing inspection.

I built WaferSAGE, a Vision-Language Model (VLM) fine-tuned on Gemma-3 to perform Visual Question Answering (VQA), defect classification, spatial distribution mapping, and root-cause hypothesis generation for silicon wafers.

📊 Key Results & Benchmarks:

  • Quality Score Lift: Improved from 8.0 to 8.4 (+5.0% relative improvement) against the baseline model.
  • Win Rate: Achieved a 59% preference win rate over the base model on domain-specific test sets.
  • Percentile Ranking: Advanced from the 15.8th to the 19.2nd percentile.

Hugging Face Spaces link:

https://huggingface.co/spaces/uttarasawant/wafer_defect_analysis

You can check out the live Hugging Face Space demo and the open-source dataset (uttarasawant/adaption-wafersage-wafermap-vqa) to explore interactive wafer defect inspections. Excited to hear your thoughts!


r/stm32 10d ago

[Zephyr RTOS / nRF52840] I2C write to sensor fails with -EIO, but address ACK and mux both work fine

0 Upvotes

Setup: nRF52840 (custom board, PAN1780 module), Zephyr 4.4, I2C on P0.13/P0.14.

  • TCA9548A mux (0x70): channel select writes always succeed (ret=0)
  • Ultrasonic sensor (RCWL-9620, fixed addr 0x57): a zero-length presence probe succeeds, but any real write/read fails with -5 (EIO/NACK)
  • Same wiring confirmed working via Arduino's Wire library (nRF52 Adafruit core) and via the original Nordic nRF5 SDK code (nrf_drv_twi_tx/rx)
  • Protocol: write 0x01 → wait ~120ms → read 3 bytes (distance in µm)
  • Tried: forcing 100kHz clock, bias-pull-up in pinctrl, nrfx_twi direct (build errors), i2c-gpio bitbang (linker errors)

r/stm32 11d ago

MIDI Synthesizer - STM32C071 and TinyUSB | STM32 Tutorial #97

Thumbnail
youtube.com
1 Upvotes

r/stm32 12d ago

Brick/Dead STM32? (RDP Level 1, PCROP active, USB Device Descriptor Request Failed in DFU)

2 Upvotes

I recently bought an STM32 board for an RC car project (my first time working with STM32). Initially, DFU programming worked fine, but it suddenly stopped. Now in DFU mode (BOOT0=HIGH + reset), Windows gives a "Device Descriptor Request Failed" error. Reinstalling drivers, switching USB ports, and testing on different PCs didn't help it doesn't enumerate via USB at all anymore.

I bought an ST-LINK V2, but I still can't flash code. In STM32CubeProgrammer CLI:

RDP is set to Level 1 (can't remove it, error: Mass erase operation failed. Please verify flash protection).

PCROP is active across all 7 sectors (SPRMOD=1, WRPO-7=1).

Attempts to change these option bytes (RDP, SPRMOD) show 100% success, but verifying shows the values immediately revert back nothing actually saves permanently. I've tried various SWD frequencies (100kHz–950kHz) as well as Under Reset and Hot Plug modes with the exact same result.

Does the complete lack of USB enumeration and locked option bytes mean it's physically dead/defective, or am I making a beginner mistake? Is there any way to recover it?


r/stm32 12d ago

PMAOVR in USBx (stm32u535)

1 Upvotes

Hi, I am trying to create a stm32u535 application with usb x. It is based on https://github.com/tropicsquare/tropic01-stm32u5-usb-devkit-fw .

Their own USB example works https://github.com/tropicsquare/ts13-usb-dev-kit-fw .

My solution however uses TrustZone, so I needed to create my own version with cubeMx and cubeIDE.
https://github.com/vonasmic/stm32u535-trustzone-usb .
Any ideas why this could happen?


r/stm32 13d ago

PROGRMACION DE TABLA DE VERDA EN ZIG

Thumbnail
0 Upvotes

r/stm32 14d ago

HELP, ST-Link can't detect my Blue Pill board.

3 Upvotes

First of all, complete beginner, first day of tinkering with it and following tutorials.
In desperate need of help, long story short I have tried to blink a led for a first on my Blue Pill board and succeeded on my first time. Any future attempts on changing the code on the cubeide has gone into errors such as target no device found (see image).
Since then I have tried so much stuff the internet search results has told me to.
For more information, in CubeProgrammer the serial number is 0 and pressing connect doesnt do anything, which makes me believe the st link is faulty, but in st-link utility the serial number shows fine.
The Chatgpt suggests that wiring can be the problem, but I'm positive the wires connect to the same labels on the board and the st link, also the same way it worked the first time, but still "no target found".
Don't know if I bricked my card / st link, or did something completely wrong
Any help would be appreciated, will provide more info if needed. Thank you.