r/stm32 1h ago

Simulink STM32 help.

Upvotes

Hello everyone. I’m trying to build a project that involves 6 PIDs to drive motors of a rover, I’m not much of a programmer so I went with the simulink coder. My boards is nucleo H753ZI and my idea is to have it do the pid loops, the set points of which are to be sent through the ethernet port on the board. So far I’ve hit dead end on the ethernet, I tried settings from the matlab site, yt videos but can’t get it to ping. I put a simple model with sine connected to led pin to verify that the model is working and it works. Has anyone done something with ethernet on the same board in simulink? Where and how can I start the troubleshooting? Also would be great if anyone can share ioc settings, but only if it is for the same board.


r/stm32 23h ago

Help in programming a STM32 G0 series board without ST-Link.

Post image
27 Upvotes

I am trying to program a stm32 G0B1 series board. Most tutorial are using an ST Link to do so but is there a way to do it without one. Here is the picture of board I am using


r/stm32 1d ago

Nucleo F401RE Help!!

Thumbnail
gallery
23 Upvotes

I have a Nucleo and a LCD panel, I was trying to make a digital watch I only see these numbers and letters. I don't know what to do. If any of you can help this will make me very happy, thanks in advice.


r/stm32 2d ago

Fixing ST's Bugs - CMSIS-DSP from Arm Source | STM32 Tutorial #100

Thumbnail
youtube.com
3 Upvotes

r/stm32 2d ago

How do you test firmware against external peripherals and failure conditions?

1 Upvotes

I’m trying to understand how embedded teams test firmware that depends on external peripherals such as I²C, SPI, or UART devices.

In particular, how do you test cases like:

* peripheral disconnects / NACKs
* invalid or unexpected data
* timing-related behavior
* interrupts
* initialization failures
* other hardware edge cases

Do you normally use real peripherals, software mocks, another MCU pretending to be the peripheral, custom HIL hardware, or commercial tools?

I’m especially interested in what becomes difficult or annoying to automate in real projects, and whether your team has ended up building custom hardware or scripts to solve it.

Would be interested to hear what people are actually doing in production environments.


r/stm32 2d ago

Home Automation - STM32F10X

Thumbnail gallery
13 Upvotes

r/stm32 3d ago

[[STM32 / Cortex-M] Intern looking for recommended books/resources to learn writing bare-metal startup code and linker scripts from scratch (in C)

Thumbnail
2 Upvotes

r/stm32 4d ago

Sensorless (HFI+SMO) FOC from scratch on STM32

Enable HLS to view with audio, or disable this notification

60 Upvotes

r/stm32 5d ago

I made a STM32 HAL driver for MPU6050

9 Upvotes

Includes support for hardware interrupts and custom config options for the sensor. Code is in fashion of similar drivers already on github but with additional support. It has been tested but I am very new to this so Im sure there are things I missed. Criticism welcome.

Repo:

https://github.com/mihalamot/STM32-MPU6050-HAL-Driver

I am 21yo CS student with a recently found passion for embedded/low level programming. Job market is not the best right now so I am trying to distinguish myself with hobby projects like this one. It would help me a lot if anyone could take the time to check this out and potentially star it. If someone actually used my code I know that it would help my employment chances.

Thanks


r/stm32 5d ago

Import to altium designer from stm32cubeMX

Post image
3 Upvotes

I placed the names of the pins in stm32cubeMX (the picture is taken from the Internet) and now I want to transfer them to the altium designer in the form of NetLabel. Now I'm doing it manually. Soon I will write my script for automatic transfer. But before that, I wanted to ask you how you do it now?


r/stm32 5d ago

I need help with connecting a sensor to my nucleo board

0 Upvotes

I am having a huge skill issue with my stm32, i can not manage to read an output from my VL53L0X distance sensor. Any help would be appreciated, really; i tried using simple librarys from github but i couldn't make it work. I tried the st's official library but that one was way too complicated for me so i couldn't make it work either. I am using i2c protocol.

GitHub - Squieler/VL53L0X---STM32-HAL: VL53L0X - STM32 HAL Library · GitHub

this is the one i used. I arranged some code for my nucleo-g474 but as i said i couldn't even see anything in the terminal.


r/stm32 6d ago

STM32WBA65 TSC

2 Upvotes
I am using the STM32WBA65 TSC with four groups, each equipped with one sampling capacitor. The sampling capacitors are 39nF, and the pad size is 10mm x 10mm. Within the same group, three values ​​differ from each other at 800, 900, and 1000, and there is one channel showing a maximum difference of up to 2000 compared to other groups. Is it normal for there to be such a large difference?

The wiring width of the touch sensor is 0.12mm, and the spacing between wires is approximately 0.3mm.

I would appreciate your help.

r/stm32 7d ago

Openflops STM32F105RBT6 can't flash a firmware

3 Upvotes

So I've built an Openflops board and I bought STM32F105RBT6 from Aliexpress (might be a counterfeit chip) soldering it and all components, all pins checked and everything seems to be okey but no matter what I do I can't flash it:

tried usb ttl serial method and it just timeouts as if nothing is detected (BOOT0 connected to 3.3v obviously)

tried via st-link and still chip is not detected as if it is dead.

I don't have much experience with stm32 so consider me a noob

checked pins and all the necessary ones receive voltage but nothing seems to work

There doesn't seem to be any soldering issue so the only thing I have left to assume is that chip is fake or I am doing something wrong


r/stm32 8d ago

Is internal SRAM mirrored across the SRAM region?

2 Upvotes

For a STM32F3 with 64 KiB of SRAM, will accessing addresses 0x2001FFFC, 0x2002FFFC, 0x2003FFFC, etc., access the SRAM at 0x2000FFFC, or will a fault be generated?

That is to say, will these two pieces of code have the same result, with version 1 being 1 cycle faster than version 2? Or will version 1 generate a fault?

_UserIRQHandler1:
  MOV.W R12,#0x20400000
  LDR.W PC,[R12,#-0x04]  // jump to the pointer @ 0x2000FFFC (0x203FFFFC)?

_UserIRQHandler2:
  MOVW R12,#:lower16:0x20010000
  MOVT R12,#:upper16:0x20010000
  LDR.W PC,[R12,#-0x04]  // jump to the pointer @ 0x2000FFFC

r/stm32 7d ago

Should I document my STM32 learning journey on LinkedIn?

0 Upvotes

I recently bought an STM32 Nucleo-F446RE and I’m starting to seriously learn embedded systems/firmware.

I’ve noticed that UI/UX designers and some software developers often share their learning process through well-designed LinkedIn posts — almost like mini case studies. I was wondering if something similar would work for embedded/firmware engineering.

I’m thinking of documenting my journey from the very beginning rather than only posting when I have an impressive project.

For example:

- What is an MCU and how does STM32 work?

- Getting started with STM32CubeIDE

- GPIO and register-level programming

- Understanding the STM32 clock system

- Timers, interrupts, PWM

- UART, SPI, I2C

- Debugging and reading registers

- Small experiments and what I learned from each one

- Eventually building more complete embedded projects

I could make each post visually clean — showing the circuit/setup, code snippets, block diagrams, oscilloscope/logic-analyzer output when available, and a short explanation of what I learned.

My goal isn't to pretend to be an expert, but to build a public portfolio that shows my progression toward becoming an embedded/firmware engineer.

For people working in embedded systems:

Is this a good strategy?

What kind of STM32/embedded content would actually be worth posting on LinkedIn?

And if you were starting from zero again, what would you post first and how would you structure the journey as you progressed?

Any advice on what recruiters or experienced engineers actually find useful would be really appreciated.


r/stm32 9d ago

Ok, how is an stm oscilloscope for a hobby project ?

17 Upvotes

I realised im doing nothing but waste all my free time by scrolling or something stupid. so i have decided to learn stm32 properly. for that, i want to build an oscilloscope, which can measure atleast till 1MHz ? 100kHz ? (idk whats possible with 2msps) with a g474 nucleo. wht all should i look into ? good resources ?

how do go about programming it in linux, from cli and vim ?

is python with matplotlib good enough for gui or should i go with c ?


r/stm32 9d ago

Streamline CAN Bus (part 2) | STM32 Tutorial #99

Thumbnail
youtube.com
3 Upvotes

r/stm32 9d ago

made a traffic control system 😛

Thumbnail github.com
1 Upvotes

r/stm32 10d ago

Senior citizen kinda lost and don’t know which STM chip to use for starters

2 Upvotes

I'm an old dude who used to be an electronics engineer 35 years ago. I only know about analog electronics, but now I decided to finally figure out microcontrollers. I have plenty of time for this task. Well at least until I'm alive. In order to learn things I came up with a task for myself. An electronic device project. I always learn stuff this way.

But I'm kinda lost because of huge range of options.

So here it is. I am a moonshiner (and an alcoholic of course) so I couldn't think of anything better than to make a thermal controller for my distillation setup. So I am asking this community for help - please tell me where to start?

So I think about project of a device that must compare the temperature from two digital temperature sensors and based on their readings clicks 8 relays states open/closed. In addition, it must have LCD with temperature readings and some kind of settings menu to well... set some settings via 4-5 buttons for temperature threshold values which will trigger relays closed or opened. All of this must be recorded in some memory and stored there even after a power outage. I don't need networking features or anything else. That kind of device. Sounds simple but like everything in the world I know it's not.

Here are specific questions:

- There are lots of MCUs. And I don't know which one is suitable for this task? Or how to choose one which will be OK for such device.

- Is there any methodology or even a tool to help choosing particular chip based on typical applications?

Thanks everybody!

Upd #1: In the r/embedded Everybody suggests me ESP32 kits. Thank you all! I've checked them. It seems they all almost complete devices with their own pcbs and stuff. But I can and want to go old school hard mode - pick a chip, trace my own pcb and so on.

Upd #2: I've decided to go with STM32 but... I've been buried in ST documentation and completely lost it. So many chips... Can I really use STM32C0 for my project with graphic menu screen, power independed storage or not? Will it be enough? Or should I go with STM32U575/585? Or STM32H503? Damn... I don't even understand how to choose MCU for my task and keep it cost effective.


r/stm32 11d ago

Arduino IDE refuses to let me upload to my stm32 bluepill

Thumbnail
gallery
1 Upvotes

I have the programmer set to Winusb using zadig but it still won’t upload. Any ideas?


r/stm32 11d ago

TMC2209 driver for STM32 — looking for feedback

Thumbnail
2 Upvotes

r/stm32 11d 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 12d ago

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

2 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 12d ago

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

Thumbnail
1 Upvotes