Advertisement
Guest User

Untitled

a guest
Jul 11th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;***** STK600 LEDS and SWITCH demonstration
  2. .include "m2560def.inc"
  3. .def Temp =r16 ; Temporary register
  4. .def Delay =r17 ; Delay variable 1
  5. .def Delay2 =r18 ; Delay variable 2
  6. ;***** Initialization
  7. RESET:
  8.     ser Temp
  9.     out DDRB,Temp       ; Set PORTB to output
  10. ;**** Test input/output
  11. LOOP:
  12.     out PORTB,temp      ; Update LEDS
  13.     sbis    PIND,0x00       ; If (Port D, pin0 == 0)
  14.     inc Temp            ; then count LEDS one down
  15.     sbis    PIND,0x01       ; If (Port D, pin1 == 0)
  16.     dec Temp            ; then count LEDS one up
  17.     sbis    PIND,0x02       ; If (Port D, pin2 == 0)
  18.     ror Temp            ; then rotate LEDS one right
  19.     sbis    PIND,0x03       ; If (Port D, pin3 == 0)
  20.     rol Temp            ; then rotate LEDS one left
  21.     sbis    PIND,0x04       ; If (Port D, pin4 == 0)
  22.     com Temp            ; then invert all LEDS
  23.     sbis    PIND,0x05       ; If (Port D, pin5 == 0)
  24.     neg Temp            ; then invert all LEDS and add 1
  25.     sbis    PIND,0x06       ; If (Port D, pin6 == 0)
  26.     swap    Temp            ; then swap nibbles of LEDS
  27.     ;**** Now wait a while to make LED changes visible.
  28.     DLY:
  29.     dec Delay
  30.     brne    DLY
  31.     dec Delay2
  32.     brne    DLY
  33.     rjmp    LOOP            ; Repeat loop forever
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement