.include "c:\avrtools\appnotes\2313def.inc" ;------ PortB Defines ---------------------------------------- .equ PhotoCell1 = 0 ;Edge detector .equ PhotoCell2 = 1 ;Edge detector .equ RunButton = 2 ;pushbutton ;------ PortD Defines ---------------------------------------- .equ Drive1 = 0 ;direction selector .equ Drive2 = 1 ;direction selector .equ Drive3 = 2 ;direction selector .equ Drive4 = 3 ;direction selector .equ LED1 = 4 ;floor LED .equ LED2 = 5 ;floor LED .equ LED3 = 6 ;mode LED ;------ Macros for Port control ----------------------------- .macro ModeLEDon cbi portd,LED3 .endm .macro ModeLEDoff sbi portd,LED3 .endm .macro FloorLEDon cbi portd,LED1 cbi portd,LED2 .endm .macro FloorLEDoff sbi portd,LED1 sbi portd,LED2 .endm ;------ Flag Bits --------------------------------------- .equ Tick = 0 ;Timer Tick bit ;------ Register Defines -------------------------------- .def lpmr0 = r0 ;used with lpm instruction .def ISRtimer = r1 ;timer ISR .def ISRtimer1 = r2 ;timer ISR .def temp = r3 ;temp register used in uart ISR .def Acc = r16 ;accumulator .def Flags = r17 ;Flag bits .def MyLoop = r18 ;loop counter .def Phase = r19 .def Ptr = r20 ;------ Code Start -------------------------------------- .cseg ;start code segment .org 0 rjmp Start ;reset vector reti ;irq0 reti ;irq1 reti ;timer1 capture reti ;timer1 compare reti ;timer1 overflow rjmp Timer ;timer0 overflow reti ;uart receive reti ;udr empty reti ;tx complete reti ;analog compare ;**************************************************************** ; Timer - Timer Interrupt Service Routine * ; Entry occurs every 4ms * ;**************************************************************** Timer: in ISRtimer,sreg ;save status register sbr Flags,1<