博文

目前显示的是 六月, 2025的博文

Why is my MCU resetting unexpectedly?

图片
 If your MCU ( Microcontroller Unit) is resetting unexpectedly , it's likely due to faults, environmental issues, or software bugs . Here's a structured breakdown of the most common causes and how to troubleshoot them:  1. Power Supply Issues Low voltage or unstable power can trigger brown-out detection or watchdog resets. Check for: Power dips or noise Insufficient current supply Poor decoupling (add capacitors close to Vcc/GND)  Fix: Use a regulated power supply, add capacitors (e.g. 0.1 µF + 10 µF), verify with oscilloscope if possible.  2. Watchdog Timer (WDT) Reset If the watchdog( What is a Watchdog? ) timer is enabled but not reset ("fed") properly , the MCU will reset.  Fix: Ensure wdt_reset() (or equivalent) is called regularly, or disable WDT in code if not needed.  3. Brown-Out Reset (BOR) Happens when supply voltage drops below a safe level . Some MCUs reset to protect memory or ensure stable operation....

How to use PWM on the STM32F407 microcontroller?

图片
 Here's a complete guide to using PWM on the STM32F407 microcontroller using TIM4 and GPIO pin PD12 (which maps to TIM4_CH1 ) — commonly used on STM32F4 Discovery boards.  Goal Generate PWM signal on PD12 (TIM4 Channel 1) using STM32F407 and HAL drivers via STM32CubeMX + STM32CubeIDE .  Required Tools STM32F407 MCU or Discovery board STM32CubeMX STM32CubeIDE USB cable, LED, or oscilloscope (to observe PWM)  Step-by-Step Instructions 1. STM32CubeMX Configuration a. Select Device Open CubeMX and choose STM32F407VGTx (or your variant). b. Configure Pin Click on pin PD12 , set as TIM4_CH1 → PWM Generation CH1 . c. Configure Timer 4 Go to Timers → TIM4 → Mode → PWM Generation Channel 1 . Set: Prescaler : 83 → 84 MHz / (83+1) = 1 MHz timer frequency Counter Period (ARR) : 999 → PWM frequency = 1 MHz / 1000 = 1 kHz Pulse : 500 → 50% duty cycle d. Clock Configuration Ensure the system clock is at 84 MHz (fr...

Operating Systems for Automotive SoCs

图片
  The automotive industry relies on   real-time, safety-critical, and high-performance computing   for applications like   advanced driver-assistance systems (ADAS), infotainment, and autonomous driving . Here are the most common   OS choices for automotive SoCs , categorized by use case: 1. Real-Time & Safety-Critical Systems (ADAS, ECUs) For  low-latency, deterministic control  (braking, engine control, sensor fusion): A. QNX Neutrino (BlackBerry QNX) Why? Certified for ISO 26262 (ASIL-D)  – highest automotive safety standard. Microkernel architecture  (fault isolation, high reliability). Used in  Tesla, BMW, Ford, and Audi  infotainment/ADAS. Example SoCs: Qualcomm Snapdragon Ride (SA8155P) NXP S32G (ARM Cortex-A/M) B. AUTOSAR OS (Classic & Adaptive) Why? Industry-standard OS  for Electronic Control Units (ECUs). Supports  hard real-time  requirements (ASIL-B to ASIL-D). Used in  powertrain, body c...

The automatic white balance algorithm of Raspberry Pi

图片
  The   automatic white balance (AWB)   algorithm on the   Raspberry Pi   (used in its camera modules) is part of the   Picamera software stack   and the   libcamera   framework (used in newer Raspberry Pi OS versions). Below is a detailed breakdown of how it works, its limitations, and ways to customize it. 1. How AWB Works on Raspberry Pi AWB in Picamera (Legacy) Algorithm : Uses a simple  gray-world assumption  (averages colors to neutral gray). Control : Adjusted via  awb_mode  in Python ( 'auto' ,  'sunlight' ,  'tungsten' , etc.). Limitations : Prone to errors in scenes with dominant colors (e.g., green grass skews balance). Less accurate than modern smartphone AWB. AWB in libcamera (New Default) Algorithm : More advanced, leveraging  machine learning  (trained on diverse scenes). Control : Configured via  libcamera  commands or  rpicam-apps  (e.g.,  --awb auto ). Modes : ...