<pre>
.include "m328Pdef.inc"
.def saveSR=r17
.def temp=r18
.org 0x0000
rjmp init
.org OC1Aaddr
rjmp TIMER
init:
ldi R16,high(RAMEND)
out SPH, R16
ldi r16, low(RAMEND)
out SPL, R16
ldi temp, high(31250)
sts OCR1AH, temp
ldi temp, low(31250)
sts OCR1AL, temp
ldi temp, (1 << CS12) | (1 << WGM12)
sts TCCR1B, temp
ldi temp, (1 << OCIE1A)
sts TIMSK1, temp
ser temp
out DDRB, temp
out PORTB, temp
sei
loop:
rjmp loop
TIMER:
in saveSR, SREG
in r16, PORTB
com r16
out PORTB, r16
out SREG, saveSR
reti
now i have this code, and its works! somebody with some tips for better code?