;

; Example Program for Lab 8

; Coded for use on EVB, changes required for use on THRSim11

; Program Inputs: None

; Program Outputs:      1. Prints ASCII 1 or 0 to screen

;                       2. Toggles Pin7 of PortA between 1 and 0

;                           every 1/2 second

;

 

      PutC = bfd3

     

      org c200

 

Main: lds #dfff

      ldy #c000         ; Make Y point at c000

      clr 0,y           ; Clear c000 for use as counter

      ldaa #80          ; initialize accum A with a 1 in bit 7

      ldx #1000         ; Make X point at top of special registers

      staa 26,x         ; Make DDRA 1 (PortA = Output port)

      staa 0c,x         ; Make FOC control only PA7 (bit 7 of PortA)

      cli

 

Loop: brset 25,x,80,TOFC      ; poll the TOF overflow flag

      bclr 23,x,7f            ; clear OC1 flag if it occurs (OC1 not used)

      bra Loop

 

TOFC: bclr 25,x,7f            ; clear TOF flag

      inc 0,y                 ; count number of TOF interrupts

      brset 0,y,10,TOG        ; if 16 TOFs have occurred, toggle output

      bra Loop

 

TOG:  clr 0,y           ; after 16 TOF periods, reset counter

      staa 0b,x         ; Force an output change of PA7 pin (put

                        ;    a 1 in bit 7 of 100B, the FOC register)

      ldab 100d         ; load current ouput value of PA7 (0 or 1)

      eorb #80          ; toggle the output value of PA7 (1 or 0)

      stab 100d         ; send toggled value to data register for PortA

      lsrb

      lsrb

      lsrb

      lsrb

      lsrb

      lsrb

      lsrb

      adab #30          ; make new value of PA7 an ASCII char

      pshb              ; and put it out to screen

      jsr PutC

      bra Loop