博文

How to include a file in an stm32cubeide project?

图片
 In STM32CubeIDE, “including a file” usually means adding it to the project so it gets built , and/or making headers discoverable by the compiler . Here are the common cases. 1) Add an existing .c/.h file into your project (copy into project) In Project Explorer , choose the target folder: C files → Core/Src Header files → Core/Inc Right-click the folder → Import… Choose General → File System → Next Browse to your file(s) → check them Make sure “Copy files into project” is enabled Finish Then in your code: # include "myfile.h" 2) Add a new source/header file (create inside the project) Right-click Core/Src → New → Source File Name it myfile.c → Finish Right-click Core/Inc → New → Header File Name it myfile.h → Finish 3) Use a file that lives outside the project (link, don’t copy) Useful if you share code across multiple projects. Right-click your target folder (e.g., Core/Src ) → Import… General → File System ...

How to burn jic files into FPGA?

图片
 A .jic file is most commonly an Intel/Altera Quartus “JTAG Indirect Configuration” image used to program the external configuration flash (EPCS/EPCQ/QSPI) through the FPGA’s JTAG , so the FPGA can boot from flash after reset/power-cycle. 0) Quick clarity: .SOF vs .JIC .sof → programs the FPGA directly (volatile). Works immediately, lost on power-off. .jic → programs the configuration flash (non-volatile). FPGA loads from flash on reboot. A) Program a .JIC into the flash (Quartus GUI) 1) Hardware + board setup Connect USB-Blaster / USB-Blaster II (or compatible) to the board’s JTAG header. Power the board. Set any board jumpers/switches to allow JTAG access (varies by board). 2) Open Quartus Programmer Tools → Programmer Click Hardware Setup… Select your cable (e.g., USB-Blaster ), then Close Set Mode = JTAG 3) Detect the JTAG chain Click Auto Detect Quartus should show your FPGA device in the chain. 4) Attach the flash de...

How to connect a Bluetooth controller to a Raspberry Pi?

图片
 Here’s the usual, reliable way to connect a Bluetooth controller to a Raspberry Pi (Raspberry Pi OS) . I’ll give you both GUI and terminal methods, plus the pairing combos for common controllers. 1) Quick GUI method (Raspberry Pi OS Desktop) Turn on Bluetooth on the Pi: Click the Bluetooth icon in the top bar (or go to Preferences → Bluetooth ). Put your controller into pairing mode (see section 3). In the Bluetooth window: Search / Add Device Select your controller Click Pair After pairing, choose Connect (some controllers auto-connect). Tip: If you don’t see a Bluetooth UI, install it: sudo apt update sudo apt install -y blueman 2) Terminal method (works on Desktop + Lite): bluetoothctl Open a terminal and run: bluetoothctl Inside bluetoothctl , type: power on agent on default-agent scan on Put the controller in pairing mode. Wait until you see it appear, then copy its MAC address (looks like AA:BB:CC:DD:EE:FF ). Pai...

How to reflash microcontroller Klipper?

图片
 Here’s the standard (safe) way to reflash Klipper firmware to a printer microcontroller board , plus the common variations (SD card, USB/DFU, RP2040 UF2, etc.). 0) When do you actually need to reflash? Most “Klipper updates” are host-only . You typically reflash the MCU when Klipper/Mainsail/Fluidd shows a firmware version mismatch or you changed MCU settings in make menuconfig . Klipper’s FAQ explicitly notes you may need to recompile + flash after upgrades (and that RESTART / FIRMWARE_RESTART does not load new firmware). 1) Build the correct firmware (on your Pi / host) Go to Klipper source and open config: cd ~/klipper make menuconfig Tip: the comments at the top of your printer board’s Klipper config usually tell you exactly what to pick in menuconfig . Compile: make clean make (“make clean” is commonly used before rebuilds.) Your output firmware will appear in ~/klipper/out/ (e.g., klipper.bin or klipper.uf2 ). 2) Find the MCU device path (USB fl...

How to load program in Arduino?

图片
 To “load a program” onto an Arduino , you’re basically compiling your sketch and uploading it to the board over USB (or via an external programmer). Here are the common ways. Method 1: Arduino IDE (most common) Install Arduino IDE (Arduino IDE 2.x). Connect the board to your PC with USB. In IDE: Tools → Board → pick your Arduino model (Uno/Nano/Mega, etc.). Tools → Port → select the COM/USB port that appears. Open an example: File → Examples → 01.Basics → Blink Click Verify (✓) to compile. Click Upload (→) to load it onto the Arduino. The board will reset and run the program automatically. Quick check: The “L” LED should blink after uploading Blink. Method 2: Upload using a USB-to-Serial adapter (for some boards) Used when: Your board doesn’t have USB built-in, or You’re programming a bare ATmega328P + bootloader setup. Typical wiring (adapter → Arduino/ATmega): TX → RX RX → TX GND → GND 5V → 5V (only if the adapter pr...

Where is my hex file on STM32?

图片
 On STM32 there isn’t a special “HEX storage” on the chip—your .hex file is generated on your PC by the build toolchain , and its location depends on the IDE/build config. If you use STM32CubeIDE (most common) Build Debug → typically here: <your_project>/Debug/ Example: ...\workspace\<project>\Debug\<project>.hex Build Release → typically here: <your_project>/Release/ Important: CubeIDE always creates an .elf . The .hex/.bin may not appear unless enabled. Enable it in CubeIDE: Project Properties → C/C++ Build → Settings → MCU Post build outputs → check “Convert to Intel Hex” (and/or Bin). If you use Keil µVision Usually in: <project>\Objects\ (or whatever you set in Options for Target). If you use IAR EWARM In the project output directory you configured (often under Debug/Exe or similar), depending on settings. Quick way to find it (any IDE) Search your project/workspace folder for: *.hex .

Detailed Discussion on IIC Communication Protocol of FPGA

图片
 “IIC” and “I²C” are the same 2-wire serial bus. In an FPGA you typically implement it as a bit-accurate state machine plus open-drain bidirectional I/O control . Below is a detailed, practical discussion (master + slave), with the stuff that usually trips people up. 1) I²C fundamentals (what the bus really is) Two wires, open-drain, “wired-AND” SCL = clock SDA = data Devices never drive a ‘1’ . They either: drive low (0) , or release the line (Z) so an external pull-up resistor makes it high. Because low is dominant, multiple devices can share the bus safely. Start/Stop are special conditions (not “bytes”) START (S): SDA goes 1→0 while SCL is high STOP (P): SDA goes 0→1 while SCL is high Repeated START (Sr): a START without a STOP in between (common for register reads) Data validity rule (the golden rule) SDA must be stable when SCL is high SDA is allowed to change only when SCL is low Receiver samples SDA on SCL rising edge...