Advertisement
DimaT1

AsmBlink

Oct 11th, 2016
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. .nolist
  2. #ifndef _TN13DEF_INC_
  3.   .include "tn13def.inc"
  4. #endif
  5.  
  6. ;ticks
  7. .equ T0MAXTICK = 100
  8.  
  9. ;work
  10. .def t0tick = R22
  11. .def state = R21
  12.  
  13. .cseg
  14.  
  15. .org 0x00
  16.   rjmp reset
  17.  
  18. .org 0x03
  19.   rjmp TIM0_OVF
  20.  
  21.  
  22. .macro outi
  23.   ldi    r16, @1        
  24.   out    @0, r16        
  25. .endm
  26.  
  27. ;==============================================================
  28. .macro show
  29.   ;tst state
  30.   ;breq PC+3
  31.   ;OUTI PortB, 1
  32.   ;rjmp m1
  33.   ;OUTI PortB, 0
  34.   ;m1:
  35.   out portb, state
  36. .endm
  37.  
  38.  
  39. ;==============================================================
  40. ;ISR
  41. TIM0_OVF:
  42.   dec t0tick
  43.   breq PC+2
  44.     reti
  45.   ldi R17, 1
  46.   eor state, R17
  47.   ldi t0tick, T0MAXTICK
  48.   reti
  49.  
  50. ;==============================================================
  51. .list
  52.  
  53. reset:
  54.   ;RAM stack
  55.     ldi R17, low(RAMEND)
  56.     OUT SPL, R17
  57.  
  58.   ;PORTS
  59.     OUTI DDRB, 0xFF
  60.     OUTI PORTB, 1
  61.  
  62.   ;timers
  63.     outi TIMSK0, 0x02
  64.     outi TCCR0A, 0x00
  65.     outi TCCR0B, 0x03
  66.    
  67.   ;init
  68.     ldi state, 1
  69.     ldi t0tick, T0MAXTICK  
  70.    
  71.     sei
  72.  
  73. ;==============================================================
  74. main:
  75.   show
  76.   rjmp main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement