timer1.s 801 B

12345678910111213141516171819202122232425262728293031323334353637
  1. ;Incs and Defs----------------------------------------------------------
  2. .include "atm328p.inc"
  3. .include "global.inc"
  4. ;Initialisierungen------------------------------------------------------
  5. .global timer1_reset
  6. timer1_reset:
  7. sts TCCR1A, false ;clear Registers
  8. sts TCCR1B, false
  9. sts TCCR1C, false
  10. sts TCNT1H, false
  11. sts TCNT1L, false
  12. sts TIMSK1, false
  13. sts timer1_cnt, false ;set Variables
  14. sts timer1_bool, false
  15. ret
  16. ;Interrupt-Handler------------------------------------------------------
  17. .global timer1_OVF
  18. timer1_OVF:
  19. push timer1_r
  20. lds timer1_r, timer1_cnt ;Timer-Scaling
  21. inc timer1_r
  22. lds temp, timer1_MAX
  23. cp timer1_r, temp
  24. brne .+6
  25. clr timer1_r ;timed instructions
  26. sts timer1_bool, true
  27. sts timer1_cnt, timer1_r
  28. pop timer1_r
  29. reti