博文

How to turn off Raspberry Pi?

图片
 To safely turn off a Raspberry Pi , do one of these: From the terminal (recommended) Shutdown now sudo shutdown -h now Power off immediately sudo poweroff Halt (stops CPU; usually also powers off) sudo halt With a desktop GUI Click Menu (Raspberry icon) → Shutdown… → Shutdown If it’s frozen Try the “magic SysRq” safe reboot sequence (works only if enabled): Hold Alt + PrintScreen Slowly type: R E I S U B (reboots safely; for shutdown you’d usually still need power control afterward) After shutdown When the Pi finishes shutting down, the green ACT LED stops blinking . Then you can remove power (unless you have a power management board that cuts power automatically).

How to find model of microcontroller for Arduino IDE?

图片
 In Arduino -land, the “ microcontroller model” is usually determined by which Board (and sometimes Processor) you select in the IDE. If you don’t know what chip is on the board, there are a few reliable ways to find it. 1) The fastest: check Tools → Board (and Tools → Processor ) Connect the board. In Arduino IDE: Tools → Board : pick (or confirm) the board family (Uno, Nano, Mega, ESP32 Dev Module, Pico, etc.) Tools → Processor (only appears for some AVR boards like Nano/Pro Mini): this often directly shows the MCU choice, e.g. ATmega328P vs ATmega168 . If you see a “Processor” submenu, that’s basically your answer. 2) Arduino IDE 2.x: Tools → Get Board Info With the board plugged in and the correct Tools → Port selected: Tools → Get Board Info shows things like board name , VID/PID , and sometimes the identified board profile. This won’t always print the exact MCU model, but it helps you confirm the board family so you can map it to the MCU. 3...

How to collect Arduino serial print data?

图片
 Here are the most practical ways to collect (log) Arduino Serial.print() data —from quick manual capture to fully automated logging. 1) Arduino IDE Serial Monitor (quick + manual) Open Tools → Serial Monitor Select the correct baud rate You can copy/paste the text out. IDE 2.x also has a Serial Plotter (good for quick graphs, not great for saving clean logs). Best for: quick debugging. 2) Use a terminal program and log to a file (easy + reliable) Windows PuTTY Find the COM port (Device Manager) In PuTTY: Connection type = Serial , set COMx and baud Enable logging: Session → Logging → “All session output” → choose a log file Open the session → your serial data is saved. Tera Term File → Log… to save the session output. macOS / Linux Use screen to view, and tee to save: # replace /dev/ttyACM0 or /dev/ttyUSB0 with your device, and 115200 with your baud screen /dev/ttyACM0 115200 For logging, screen alone isn’t great; better use pyse...

How to disable all interrupt on STM32?

图片
 Here are the practical ways to “disable all interrupts” on STM32 , depending on what you mean (mask CPU interrupts vs. stop peripherals from generating them). 1) Mask (disable) all CPU interrupts globally This is the most common meaning: prevent any interrupt handler from running on the Cortex-M core. CMSIS (portable) way # include "cmsis_gcc.h" // or core_cm*.h via your device header __disable_irq(); // masks IRQs (PRIMASK = 1) // critical section... __enable_irq(); // unmasks IRQs Direct register (same thing) __set_PRIMASK( 1 ); // disable IRQ // ... __set_PRIMASK( 0 ); // enable IRQ Notes This masks all “normal” interrupts (IRQ) . NMI (Non-Maskable Interrupt) and HardFault still happen. 2) Also stop Fault exceptions (more “everything”) If you also want to block most fault exceptions (MemManage/BusFault/UsageFault), use FAULTMASK . __disable_fault_irq(); // sets FAULTMASK = 1 // ... __enable_fault_irq(); // clea...

What is FPGA XDC?

图片
 An FPGA XDC is a Xilinx Design Constraints file (extension .xdc ) used in Vivado to tell the tools how your design must be connected and timed . Think of it as the “rules + wiring map” for implementation. What an XDC file contains 1) Pin assignments (physical I/O mapping) Maps your top-level ports to FPGA package pins and sets I/O standards. Example: set_property PACKAGE_PIN W5 [get_ports {clk}] set_property IOSTANDARD LVCMOS33 [get_ports {clk}] 2) Timing constraints (so timing analysis is correct) Defines clocks and timing relationships. Example: create_clock -period 10.000 [get_ports clk] ;# 100 MHz You can also constrain: input/output delays ( set_input_delay , set_output_delay ) clock uncertainty, generated clocks, false paths, multicycle paths, etc. 3) I/O electrical constraints Sets things like: IOSTANDARD (LVCMOS33, LVDS, SSTL, etc.) drive strength ( DRIVE ) slew rate ( SLEW FAST/SLOW ) pullups/pulldowns ( PULLUP , PULLDOWN ) 4) Ot...

How to add programs to the Raspberry Pi 4B?

图片
 On a Raspberry Pi 4B (Raspberry Pi OS), you “add programs” mainly in these ways: 1) Easiest (GUI): Add/Remove Software If you’re using the desktop: Menu → Preferences → Add/Remove Software Search the app → install This uses the same package system as the terminal (APT).  2) Recommended (Terminal): APT packages APT is the standard/recommended way to install/update/remove software on Raspberry Pi OS.  sudo apt update sudo apt install <package-name> Examples: sudo apt install git sudo apt install python3 sudo apt install vlc To update everything: sudo apt update sudo apt full-upgrade To remove: sudo apt remove <package-name> sudo apt autoremove 3) Install a downloaded .deb package If you downloaded a Debian package (must match your architecture: armhf/arm64 , not x86_64):  cd ~/Downloads sudo apt install ./some-package.deb (Using apt install ./file.deb is nice because it pulls dependencies automatically.) 4) Python...

How does interrupts works exactly in microcontrollers?

图片
 Interrupts are how a microcontroller stops what it’s doing (briefly) to handle an important event right now , then returns to exactly where it left off. Here’s how it works “under the hood”, step by step. The core idea Your main code runs in a loop (or an RTOS task). Hardware events happen asynchronously: a timer hits zero, a UART byte arrives, a GPIO edge occurs, ADC completes, etc. Instead of polling (“are we there yet?”), the MCU uses an interrupt : a hardware signal that asks the CPU to run a specific function called an ISR (Interrupt Service Routine). What happens when an interrupt occurs (exact sequence) 1) An event sets an interrupt flag Example: a timer overflows → the timer peripheral sets a status bit like TIMERx_IF = 1 . 2) The interrupt controller decides if it should fire An interrupt triggers the CPU only if: The peripheral’s interrupt is enabled (local enable bit), The interrupt is unmasked/enabled in the interrupt controller (e.g., N...