Again I have no luck with 32khz crystal and timer2
In ohter post in this forum I have try with mega8 and many friends help me with some instruction so finaly i have no erros on complier but the project didnt run.
Because for my project I will need more power μc I choose mega168 and start again the first step to make an overflow every second with 32khz crystal
I work with stk500,I have connect the crystal to expand1 connector on pin portb6,portb7
The jumpers on stk are all by default.
I program fuses 8mhz internal on studio.
And flash with this program, who in my dreams :) ,it will flash the leds on stk500 who is connected to portd.
What is complete wrong?
.INCLUDE "m168def.inc" .ORG $0000 .def TMP1 = R22 .def TMP2 = R23 .DEF COUNTER = R24 RJMP RESET rjmp TIM2_OVF RESET: ldi r16, high(RAMEND); Main program start out SPH,r16 ; Set Stack Pointer to top of RAM ldi r16, low(RAMEND) out SPL,r16 LDI R17,0B11111111 OUT DDRD,R17 LDI R17,255 OUT PORTD,R17 LDI COUNTER,10 RCALL LDELAY LDS R0,5 STS TCCR2B,R0 RCALL BUSY CLR R0 STS TCCR2A,R0 RCALL BUSY LDS R0,0 STS TCNT2,R0 RCALL BUSY LDS R0,1 STS TIMSK2,R0 CLR R0 STS TIFR2,R0 LDS R0,0B00100000 STS ASSR,R0 RCALL LDELAY SEI START: RJMP START TIM2_OVF: push r16 in r16,SREG push r16 DEC COUNTER BRNE EXIT LDI TMP1,0 OUT PORTD,TMP1 RCALL LDELAY EXIT: pop r16 out SREG,r16 pop r16 reti BUSY: CLR R0 LDS R0,ASSR SBRC R0,5 brne BUSY ret LDELAY: LDI R25,2 D1: LDI R26,2 D2: DEC R26 BRNE D2 DEC R25 BRNE D1 RET