The divider is (PSC+1), notPSC. To divide by 8: PSC+1=8⇒PSC=7.
Recall Solution 1.2
Output Compare / PWM: Timer → Pin (the count reaches CCR, hardware drives the pin).
Input Capture: Pin → Timer (an edge on the pin copies CNT into CCR).
Mnemonic: Compare = Control the pin; Capture = Copy the time.
Recall Solution 1.3
ARR sets the period (the whole saw-tooth length). CCR sets the HIGH duration (how far up the plum line sits). Frequency stays fixed as you change duty — only the orange split moves.
(a) ftim=71+172MHz=7272×106=1MHz → each tick is 1μs.
(b) The counter sweeps 0→999, i.e. ARR+1=1000 ticks per period, so fPWM=ARR+1ftim=1000106=1000Hz=1kHz.
(c) D=ARR+1CCR×100%=1000250×100%=25%.
Recall Solution 2.2
Keep 1μs ticks ⇒ ftim=1MHz ⇒ PSC=71.
Period T=2000Hz1=500μs=500 ticks. Because the sweep takes (ARR+1) ticks, ARR+1=500⇒ARR=499.
Duty: CCR=0.75×(ARR+1)=0.75×500=375.
Recall Solution 2.3
1μs ticks ⇒ PSC=71. Frame T=20ms=20000 ticks =(ARR+1) ⇒ ARR=19999.
Servos read the pulse width directly, so CCR=2.0ms=2000 ticks. → CCR=2000.
(See Servo and ESC Control for why width, not duty %, is what the servo decodes.)
The scope is right; the student divided by the wrong number. Duty is ARR+1CCR=1000500=50.0%, not CCR/ARR. The counter has ARR+1=1000 distinct tick-slots per period (it spends one tick at each of 0…999), and HIGH occupies CCR=500 of them → exactly half. Using ARR (=999) in the denominator invents a phantom 0.05% error that the hardware never had.
Recall Solution 3.2
The counter wrapped once between the two edges (it hit 65535, reset to 0, then kept counting). Raw subtraction goes negative because it ignores the wrap.
Here mod(ARR+1) means "the non-negative remainder after removing whole counter cycles of length (ARR+1)=65536" — it adds back one full cycle to a negative difference. So:
Δ=(c2−c1)mod65536=(1500−60000)mod65536=−58500+65536=7036 ticks.
At 1μs/tick: T=7036μs≈7.036ms, so fsignal=7.036ms1≈142.1Hz.
Recall Solution 3.3
ftim=72 MHz, so overflows occur every ARR+1=100 ticks → overflow rate =72×106/100=720 kHz. But toggle flips the pin each overflow, and it takes two flips (HIGH→LOW→HIGH) for one full wave. So fout=720kHz/2=360kHz.
Use 1μs ticks → PSC=71, ftim=1 MHz.
Frame T=400Hz1=2.5ms=2500 ticks =(ARR+1) ⇒ ARR=2499.
Idle pulse 1.0ms=1000 ticks ⇒ CCRidle=1000.
Full pulse 2.0ms=2000 ticks ⇒ CCRfull=2000.
Fits? Longest pulse (2000) is well under the frame (2500) → yes, comfortable margin. (See Servo and ESC Control.)
Recall Solution 4.2
With PSC=71 (ftim=1 MHz), a 1 Hz period needs ARR+1=106 ⇒ ARR=999999 — far above the 16-bit ceiling of 65535. Impossible.How to choose the divisor: the total division is (PSC+1)(ARR+1)=fclk/fPWM=72×106. We must split this product into two factors that each fit in 16 bits (≤65536). A tidy split is to make ftim a round number: pick PSC=7199 ⇒ ftim=720072×106=10kHz (tick =100μs), leaving ARR+1=10000 (ARR=9999) — both comfortably under 65536. (Many splits work; this one keeps the tick a clean 100μs.)
Period 1 Hz =1s=10000 ticks ⇒ ARR=9999 (fits!).
Duty 10 %: CCR=0.10×10000=1000.
Check: fPWM=7200×1000072×106=7.2×10772×106=1Hz. ✓
HIGH holds while CNT<CCR, across CNT=0…999 (ARR+1=1000 slots).
0 %:CCR=0 → the condition CNT<0 is never true → pin never HIGH.
100 %: need HIGH for all 1000 slots → CCR=ARR+1=1000.
Wait — can CCR exceed ARR? Yes. The compare register is not clamped to ARR; it is just a 16-bit value the hardware compares against. If CCR>ARR, the counter never reaches or exceeds CCR during its 0…ARR sweep, so the "go LOW" condition never fires and the pin stays HIGH for the whole cycle — exactly the 100 % we want. Then CNT<1000 is true for every count 0…999.
CCR=999 leaves the single slot CNT=999 LOW → duty =999/1000=99.9%, not 100 %. The missing tick is the classic "almost-but-not-quite full brightness" bug.
Recall Solution 5.2
Let k = number of full counter overflows between the two edges; here k=3. Each full cycle is ARR+1=65536 ticks, so the true gap adds k whole cycles onto the raw difference:
Δ=k(ARR+1)+(c2−c1)=3×65536+(10000−40000)=196608−30000=166608 ticks.
At 1μs/tick: T=166608μs≈166.6ms, so fsignal=0.166608s1≈6.002Hz.
Single-wrap modulo would have under-counted by 2×65536 ticks — you must track the overflow count k for multi-cycle gaps.
Recall Solution 5.3
The counter wrapped once. Recall mod65536 means "add back one full cycle to a negative difference":
Δ=(cf−cr)mod65536=(200−64000)mod65536=−63800+65536=1736 ticks.
At 1μs/tick the HIGH pulse is 1736μs=1.736ms. (This is exactly how H-bridge current-sense timing gets measured.)
Recall Solution 5.4
Resolution = one tick =72MHz1≈13.9ns.
Longest single-cycle span = ARR+1=65536 ticks =72×10665536≈910μs≈0.91ms. Anything longer wraps and demands overflow bookkeeping — the trade-off is fine resolution vs short unambiguous range.