; ATtiny15L LED blinker ; Row Control: PB5, PB4 (cathode) ; Column Ctrl: PB3, PB0, PB1 (anode) ; Button Ctrl: PB2 (INT0) ; ; eric@elegantinvention.com ; lain<3jack .include "tn15def.inc" ; friggin include lacks PORTB5 b/c ; external #RESET has to be disabled.. .equ PORTB5 = 5 .equ PB5 = 5 ; define our control lines .equ ROW1 = PORTB5 .equ ROW2 = PORTB4 .equ COL1 = PORTB3 .equ COL2 = PORTB0 .equ COL3 = PORTB1 .equ BTN_PIN = PORTB2 ; define our LED bit positions .equ LEDRT = 0 ; right top row1,col1 .equ LEDRM = 1 ; right middle row1,col2 .equ LEDRB = 2 ; right bottom row1,col3 .equ LEDLB = 3 ; left bottom row2,col3 .equ LEDLM = 4 ; left middle row2,col2 .equ LEDLT = 5 ; left top row2,col1 .equ LEDRST = 6 ; LED RESET .equ LEDOVF = 7 ; LED OVERFLOW ; define the bit positions for up/down/updwn modes list .equ LIST1 = 0 ; use item 1 (top 2) .equ LIST2 = 1 ; use item 2 (middle 2) .equ LIST3 = 2 ; use item 3 (bottom 2) .equ LISTOVF = 3 ; LIST overflow .equ LTDIR = 5 ; LIST direction for _m_updwn .equ LTMISC = 6 ; unused MISC bit .equ LISTUNF = 7 ; LIST "underflow" ; modes .equ m_cw = 0x00 .equ m_ball = 0x01 .equ m_bhalf = 0x02 .equ m_down = 0x03 .equ m_up = 0x04 .equ m_updwn = 0x05 .equ m_sleep = 0x06 ; "variables" .def count1 = R16 ; used for the delay loop .def count2 = R17 .def loops = R18 ; number of loops to perform .def mode = R19 ; holds the current mode .def temp = R20 ; temporary stuff .def tempi = R21 ; don't want the interrupt vector screwing with temp .def leds = R22 ; led status register .def item1 = R23 ; list of states for up/down/updwn modes .def item2 = R24 .def item3 = R25 .def listp = R26 ; current list position/direction and over/under-flow flags .cseg .org 0 rjmp main ; reset condition .org INT0addr rjmp button ; button pressed (int0 vector 0x001) .org INT_VECTORS_SIZE ; start after interrupt vectors delay: ldi count1, 0xff _delay_outer: ldi count2, 0xff ; reload count2 for next loop _delay_inner: dec count2 ; count2-- cpi count2, 0x00 ; if count2 != 0, keep looping brne _delay_inner dec count1 ; count1-- cpi count1, 0x00 ; if count1 != 0, keep looping brne _delay_outer dec loops ; loops-- cpi loops, 0x00 ; if loops != 0, keep looping brne delay ret button: ldi loops, 0x03 ; wait 1.6MHz/(65025*3) = ~122ms (debounce) rcall delay sbr leds, (1<bottom->top->bottom->.... mov temp, listp ; listp -> temp cbr listp, (1<