All pastes #470156 Raw Edit

Unnamed

public text v1 · immutable
·published 2007-05-04 03:05 UTC
rendered paste body
; 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

; modes
.equ 	m_cw	= 0x00
.equ	m_ccw	= 0x01
.equ	m_cw2	= 0x02
.equ	m_ccw2	= 0x03
.equ	m_ball	= 0x04
.equ	m_bhalf	= 0x05
.equ	m_down	= 0x06
.equ	m_up	= 0x07
.equ	m_sleep	= 0x08

; "variables"
.def	count1	= R17
.def	count2	= R18
.def	mils	= R19	; milliseconds to delay
.def	mode	= R20
.def	temp	= R21

.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:
	ret

button:
	reti

main:
	ldi	mode,	m_sleep					; set default mode

	ser	temp							; temp=0xff (all pins output)
	cbr	temp,	(1<<BTN_PIN)			; button pin is input w/ pull-up
	out	DDRB,	temp
	
	in	temp,	MCUCR					; get current MCUCR status
	cbr	temp,	(1<<ISC01)+(1<<ISC00)	; low level on BTN_PIN triggers int0
	out	MCUCR,	temp					; update MCUCR

	in	temp,	GIMSK					; grab GIMSK and enable external int0
	sbr	temp,	(1<<INT0)
	out	GIMSK,	temp

	sei									; global interrupt enable

main_loop:
	rjmp main_loop

; eof