Advertisement
DimaT1

TinyBlinkV2

Oct 8th, 2016
133
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. ;.include "regs.inc"
  7.  
  8. ;timers
  9. .equ CLK1024 = (1<<CS00) | (1<<CS02)
  10.  
  11. ;ticks
  12. .equ T0MAXTICK = 2
  13.  
  14. ;work
  15. .def t0tick = R22
  16. .def state = R21
  17.  
  18. .org 0
  19.   rjmp reset
  20.  
  21. .org 0x0003
  22.   rjmp TIM0_OVF
  23.  
  24.  
  25. .macro outi
  26.   push R16
  27.   ldi    r16, @1        
  28.   out    @0, r16        
  29.   pop R16
  30. .endm
  31.  
  32. ;==============================================================
  33. .macro show
  34.   push R17
  35.  
  36.   OUTI PORTB, 1
  37.  
  38.  
  39. ;  mov R17, state
  40. ;  dec R17
  41.  
  42. ;  breq PC+3
  43. ;  OUTI PORTB, (1 << 0)
  44. ;  rjmp m1
  45. ;  OUTI PORTB, (0 << 0)
  46.  
  47. ;  m1:
  48.  
  49.   pop R17
  50. .endm
  51.  
  52.  
  53. ;==============================================================
  54. ;ISR
  55. TIM0_OVF:
  56.  
  57.   OUTI PORTB, 1
  58.  
  59.   dec t0tick
  60.   breq PC+2
  61.   reti
  62.   push R17
  63.   ldi R17, 1
  64.   eor state, R17
  65.   ldi t0tick, T0MAXTICK
  66.   pop R17
  67.   reti
  68.  
  69. ;==============================================================
  70.  
  71. reset:
  72.   ;RAM stack
  73.     ldi R17, low(RAMEND)
  74.     OUT SPL, R17
  75.  
  76.   ;PORTS
  77.     OUTI DDRB, 0xFF
  78.     OUTI PORTB, 0
  79.  
  80.   outi COM0A1, 1
  81.   outi COM0A0, 0
  82.  
  83.   ;timers
  84.     ;outi tccr0a, 0b10100011      ; режим fast pwm
  85.     ;COM00, 0
  86.     ;COM01, 0
  87.     ;WGM0, 0
  88.     ;WGM1, 0
  89.     ;WGM2, 0
  90.    
  91.     outi TCNT0, 0b0000101      ; делитель на 1024
  92.     ;outi gtccr, 0b00000001        ; сброс предделителя
  93.   ;OUTI TCCR0A, 8
  94.    
  95.   ;init
  96.     ldi state, 1
  97.     ldi t0tick, T0MAXTICK  
  98.    
  99.     sei
  100.  
  101. ;==============================================================
  102. main:
  103.   ;show
  104.   breq main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement