博文

目前显示的是标签为“PWM”的博文

How to generate sine wave in FPGA?

图片
 Here are the most practical ways to generate a sine wave on an FPGA —from “quick & clean” to “resource-lean.” I’ll give you design rules, formulas, and drop-in HDL. The main approaches (pick one) Method When to use Notes DDS/NCO + LUT Easiest, precise frequency control Phase accumulator → lookup table. Best with an external DAC or 1-bit ΣΔ + RC. CORDIC You want to save BRAM / make sin/cos on the fly Uses add/shift stages; needs scaling factor compensation. PWM or ΣΔ DAC No external DAC available Filter the pin with RC/active LPF. ΣΔ generally cleaner than plain PWM. 1) DDS / NCO + LUT (golden path) How it works Phase accumulator : phase <= phase + phase_inc; Top M bits of phase index a sine LUT (ROM/BRAM). Frequency : f out = phase_inc 2 N   f clk f_\text{out} = \frac{\text{phase\_inc}}{2^N}\,f_\text{clk} f out ​ = 2 N phase_inc ​ f clk ​ Resolution example (N=32, fclk=100 MHz): ~ 0.0233 Hz steps. Compute phase_inc : round(f_out * 2^N / f_clk) – ...

What pins on Raspberry Pi 5 can use PWM?

图片
  The Raspberry Pi 5 has significantly improved and expanded its PWM capabilities compared to its predecessors. Here's a detailed breakdown of the PWM pins on the Raspberry Pi 5. Quick Answer: Which GPIO Pins Have PWM? The Raspberry Pi 5 has  up to 10 independent PWM channels  that can be output on multiple GPIO pins. PWM0:  GPIO  12 ,  18 ,  40 PWM1:  GPIO  13 ,  19 ,  41 ,  45 PWM2:  GPIO  10  (Note: This is also used for the EEPROM for HATs, so use with caution) PWM3:  GPIO  11  (Note: This is also used for the EEPROM for HATs, so use with caution) PWM4:  GPIO  20 ,  42 ,  52 ,  54 PWM5:  GPIO  21 ,  43 ,  53 ,  55 PWM6:  GPIO  6 ,  31 ,  56 PWM7:  GPIO  7 ,  31 ,  57 PWM8:  GPIO  2 ,  8 ,  44 PWM9:  GPIO  3 ,  9 ,  44 ⚠️ Important Note:  You can only use ...