Tuesday, May 26, 2015

Timer on ATTiny13A using Interrupt


 It started with this

.include "../tn13Adef.inc" 
.org 0000 
rjmp reset 
.org 0003 
rjmp timer

reset:
sbi ddrb,0           
ldi r16,0b00000101    
out tccr0b,r16
ldi r16,0b00000010    
out timsk0,r16
sei

loop:
ldi r16,(1<<SE)
out mcucr,r16
sleep
rjmp loop

timer:
sbi   pinb,0       

reti




Nugrohos-MacBook-Air:timer nugroho$ avra -o timer.hex timer.s 
AVRA: advanced AVR macro assembler Version 1.3.0 Build 1 (8 May 2010)
Copyright (C) 1998-2010. Check out README file for more info

   AVRA is an open source assembler for Atmel AVR microcontroller family
   It can be used as a replacement of 'AVRASM32.EXE' the original assembler
   shipped with AVR Studio. We do not guarantee full compatibility for avra.

   AVRA comes with NO WARRANTY, to the extent permitted by law.
   You may redistribute copies of avra under the terms
   of the GNU General Public License.
   For more information about these matters, see the files named COPYING.

Pass 1...
Pass 2...
done

Used memory blocks:
   Code      :  Start = 0x0000, End = 0x0000, Length = 0x0001
   Code      :  Start = 0x0003, End = 0x000F, Length = 0x000D

Assembly complete with no errors.
Segment usage:
   Code      :        14 words (28 bytes)
   Data      :         0 bytes
   EEPROM    :         0 bytes
Nugrohos-MacBook-Air:timer nugroho$ vavrdisasm timer.s.hex 
   0: c0 03       rjmp .+6 ; 0x8
   6: c0 0a       rjmp .+20 ; 0x1c
   8: 9a b8       sbi $17, 0
   a: e0 05       ldi R16, 0x05
   c: bf 03       out $33, R16
   e: e0 02       ldi R16, 0x02
  10: bf 09       out $39, R16
  12: 94 78       sei 
  14: e2 00       ldi R16, 0x20
  16: bf 05       out $35, R16
  18: 95 88       sleep 
  1a: cf fc       rjmp .-8 ; 0x14
  1c: 9a b0       sbi $16, 0
  1e: 95 18       reti 
Nugrohos-MacBook-Air:timer nugroho$ 

.