Advertisement
Giovanni_vangelista

arduino_assembly_blink.asm

Nov 5th, 2019
2,212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;
  2. ; arduino_assembly_blink.asm
  3. ;
  4. ; Created: 21/10/2019 18:58:07
  5. ; Author : Giovanni Vangelista
  6. ; Site: https://www.make4future.com
  7.  
  8. ;Turns an LED on for 100ms, then off for 100ms, repeatedly.
  9. ;This program use a on-board LED of your arduino. On the arduino UNO, NANO, MEGA and ZERO it is attached to digital pin 13 (PB5)
  10.  
  11.     ldi r16,0B00000000 ;write on the register r16 a binary value
  12.     ldi r17,0B00100000
  13.  
  14.     out DDRB,r17 ;Set the port out equal to the r17 value (1=output;0=input)
  15.  
  16. Start:
  17.  
  18.    
  19.     out PortB,r17 ;scrivo su portX i valori del registro rX
  20.     call timer  ;call subroutine named 'timer'
  21.     out PortB,r16
  22.     call timer
  23.  
  24.     rjmp Start  ;go to 'Start'
  25.  
  26.  
  27.  
  28. timer:  ;subroutine of delay (100ms)
  29.     ldi  r18, 9
  30.     ldi  r19, 30
  31.     ldi  r20, 229
  32. L1: dec  r20
  33.     brne L1
  34.     dec  r19
  35.     brne L1
  36.     dec  r18
  37.     brne L1
  38.     nop
  39.     ret ;return from subroutine
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement