Skip to content

Delay loops

RETARDO
MOVLW .N
MOVWF CONTADOR
BUCLE
DECFSZ CONTADOR,F
BRA BUCLE
RETURN

With CALL: Σ CI ≈ 3N + 4. Body only: ≈ 3N + 2.

Σ CI = 605 → delay = 121 µs.

Course PDF slide: two- and three-loop nested delays with cycle counts and formulas
PDF slide 8: line-by-line cycle count and Σ CI = 3NM + 4M + 5 (two loops) / 3NMP + 4MP + 4P + 5 (three loops). — Clase Tema 4 y 5 — Delays · UNEXPO · Prof. Ing. Yoel Pire
MOVLW .M
MOVWF CONTADOR_2
BUCLE_2
MOVLW .N
MOVWF CONTADOR_1
BUCLE_1
DECFSZ CONTADOR_1,F
BRA BUCLE_1
DECFSZ CONTADOR_2,F
BRA BUCLE_2
RETURN

Σ CI ≈ 3NM + 4M + 5 (no CALL).

Σ CI ≈ 3NMP + 4MP + 4P + 5

This table is the class exercise from the PDF («Create a comparative table of maximum delay for 1, 2, and 3 loops @ 20 MHz»). The 2-loop row (Σ CI = 196,100, 39.22 ms) comes from that slide — not from the partial exam.

PDF exercise: comparative table of max delays for 1, 2, and 3 loops at 20 MHz
PDF slide 9 — class exercise: N=M=P=255 and table with 770 / 196,100 / 50,005,250 cycles. — Clase Tema 4 y 5 — Delays · UNEXPO · Prof. Ing. Yoel Pire
LoopsΣ CIMax delay
17700.154 ms
2196,10039.22 ms
350,005,250~10 s

Ejercicio · Parcial

Comparative table (PDF exercise)

Verify row 1: N=255, Σ CI=770, delay = 770 × 0.2 µs = 0.154 ms.

Ejercicio · Parcial

How much with 2 loops? (same slide)

N=M=255 → Σ CI = 3×255×255 + 4×255 + 5 = 196,100 → 39.22 ms.

Next: Calculation and applications.

Interactive exam

Delay loops

Based on: Clase Tema 4 y 5.pdf

0 of 0 answered

In a simple loop, DECFSZ over N iterations totals...
Σ CI for two nested loops (no CALL) is...
With N=M=P=255 @ 20 MHz, max delay with 3 loops is approx...
The maximum counter value in an 8-bit loop is...
PDF example: N=200 @ 20 MHz gives Σ CI=605 and delay of...
For second-scale delays @ 20 MHz with pure software you typically use...