Microcontroller Simulator Task 7 - Electronics Tutorials |
|
The AQA microcontroller contains a timer register called TMR. If PRE contains zero, TMR does nothing. When TMR reaches zero, the TMR (T) flag is set and stays set until a non zero value is assigned to TMR. TASK: Copy and paste this code into the simulator and run the program.
START:
; ===========================================
; Initialise PRE and TMR
; ===========================================
MOVW 0X1 ; Copy 1 into ...
MOVWR PRE ; ... the prescaler
MOVW 0X08 ; Copy 8 into ...
MOVWR TMR ; ... the timer
; ===========================================
; Poll the TMR flag (T)
; ===========================================
POLL:
MOVRW SR ; Copy SR into W
ANDW 0x02 ; Bit mask
JPZ POLL
; ============================================
; === This code runs when TMR reaches zero ===
; ============================================
NOP
NOP
NOP
NOP
JMP START
; ============================================
|