Skip to content

Delay calculation and applications

Both use 2 cycles. BRA = relative jump for local loops. GOTO = absolute jump. Course expects BRA in delay loops.

Each NOP = 1 cycle. Two NOPs add +2 to Σ CI to hit 3 ms exactly after rounding A.

  • CM = 0.2 µs
  • Target 3000 µsΣ CI = 15,000
  • Two loops, N = 29, solve M = A:
Σ CI = 3NM + 4M + 5 + 2(NOP) = 91A + 7
91A + 7 = 15,000 → A ≈ 165

Check: 91×165 + 7 = 15,022 → 15,022 × 0.2 µs ≈ 3.00 ms

RETARDO_3MS
MOVLW .29
MOVWF CONTADOR_1
MOVLW .165 ; A
MOVWF CONTADOR_2
BUCLE_2
MOVLW .29
MOVWF CONTADOR_1
BUCLE_1
DECFSZ CONTADOR_1,F
BRA BUCLE_1
DECFSZ CONTADOR_2,F
BRA BUCLE_2
NOP
NOP
RETURN

T = 100 ms → 50 ms per half period. Use 3 nested loops + 3 NOP (PDF: M=2, inner values 252 and 164).

  • CM @ 20 MHz
  • Table 4.1
  • DECFSZ = N+1 cycles
  • Solve A for 3 ms
  • Explain NOP and BRA
Interactive exam

Delays — Calculation and partial exam

Based on: Clase Tema 4 y 5.pdf

0 of 0 answered

With a 4 MHz crystal, the machine cycle (CM) duration is...
The software delay formula is...
How many cycles does BRA normally consume?
DECFSZ uses more cycles when...
With a 20 MHz crystal, CM equals...
To fine-tune a delay by a few microseconds you use...
In a local delay loop BRA is preferred over GOTO because...
For a ~10 s delay @ 20 MHz you typically need...
For a 3 ms delay @ 20 MHz, Σ CI should be approximately...
The course formula for Σ CI with two nested loops (no CALL) is...