Include 'M64DEF.INC'
ORG 0X0000
JMP main
ORG 0X0020
JMP TIMER0_ISR
ORG 0X0050
main:
LDI R16,low(RAMEND)
OUT SPL,R16
LDI R16,high(RAMEND)
OUT SPH,R16
LDI R16,0X07
OUT TCCR0,R16 ; 10.24MHz/1024=10KHz      1/10KHz=0.1msec   1msec/0.1msec=10       256-20=246 
LDI R16,246
OUT TCNT0,R16
LDI R16,0X01
OUT TIMSK,R16
LDI R16,0X0FF
OUT DDRA,R16
LDI R17,25
CLR R18
LDI R22,25
LDI R23,50
CLR R24
CLR R25
SEI


LOOP:
OUT PORTA,R22
JMP LOOP


TIMER0_ISR:
LDI R16,246
OUT TCNT0,R1
INC R18
CPI R18,101
BRSH NEXT1
INC R25
CPI R25,4
BREQ NEXT 
RETI

NEXT:
DEC R22
CLR R25
OUT PORTA,R22
RETI

NEXT1:
CPI R18,151
BRSH NEXT2
OUT PORTA,R22
RETI

NEXT2:
CPI R18,251
BRSH NEXT3
OUT PORTA,R23
RETI

NEXT3:
OUT PORTA,R24
RETI









