diff --git a/Configuration-Variables-(CV)-List.md b/Configuration-Variables-(CV)-List.md index 49e847f..e1c01cd 100644 --- a/Configuration-Variables-(CV)-List.md +++ b/Configuration-Variables-(CV)-List.md @@ -150,6 +150,26 @@ Every slice controls two independent output channels, duty cycle from 0% to 100% * Clock Divider: Additional clock divider * Level Channel A / Level Channel B - (16Bit each): Determining how many of the x cycles the signal is at a high level - effectively determining the duty cycle +To see which CVs correspond to which slice and channel, it is advisable to use CV.h as a reference + +The PWM-frequency is calculated as follows: fPWM = 125 MHz / [ (CVclk_div + 1) * (CVwrap + 1) ] + +The duty-cycle can be calculated as follows: D = CVLevel / CVwrap + 1 + +**Example configuration - (AUX2: PWM-Frequency fPWM = 10kHz; Duty-cycle D = 20%):** + +AUX1 => GPIO25 => Slice 4 / Channel B => Wrap: CV_144 & CV_145; Clock-divider: CV_146; Level(B): CV_149 & CV_150 + +=> fPWM = 10kHz = 125 MHz / [ (0 + 1) * (12499 + 1) ]; + +=> CV_144 = 110000, CV_145 = 11010011, CV_146 = 0; --- (Note: "12499dec" = "11000011010011bin") + +=> CVLevel = CV_149 & CV_150 = D * (CVwrap + 1) = 0.2 * 12500 = 2500 + +=> CV_149 = 1001, CV_150 = 11000100; --- (Note: "2500dec" = "100111000100bin") + +Another configuration which also achieves 10kHz and D = 20% would be CVclk_div = 10, CVwrap = 1249, CVLevel = 250. + A more detailed explanation can be found in the [RP2040-Datasheet](https://datasheets.raspberrypi.com/rp2040/rp2040-datasheet.pdf) in Chapter 4.5.