File: /~heha/Mikrocontroller/LED-PWM.zip/3pwm.lst

AVRASM ver. 2.1.2  3pwm.a90 Sat May 29 02:06:17 2010

3pwm.a90(2): Including file 'C:\Programme\AVRStudio\AvrAssembler2\Appnotes\m8def.inc'
3pwm.a90(3): Including file 'makros.i90'
                 
                 .nolist
                 .list
                 // Port B
                 // PB1	OC1A	(15)
                 // PB2	OC1B	(16)	PWM-Ausgänge für LEDs
                 // PB3	OC2	(17)
                 
                 // Register R8..R15 sowie R23 für ISR erforderlich
                 .def	ZERO	=r8	// immer 0x00
                 .def	ONES	=r9	// immer 0xFF
                 .def	LEN2L	=r10	// gepuffert (Pulslänge, von außen zu setzen)
                 .def	LEN2H	=r11
                 .def	isrt1	=r12	// ISR-Register (SREG-Backup)
                 .def	TCNT2H	=r13	// High-Teil Zählerstand
                 .def	OCR2L	=r14	// ungepuffert
                 .def	OCR2H	=r15
                 
                 .def	r	=r4	// 0=AUS, 255=voll, logarithmisch skaliert
                 .def	g	=r5
                 .def	b	=r6
                 .def	isrt0	=r23	// ISR-Register, muss >= R16 sein
                 
                 
                 .org 0
000000 c021      	rjmp	Init
000001 9518      	reti
000002 9518      	reti
000003 9518      	reti
                 // Timer2-Überlauf-ISR
000004 b6cf      	in	isrt1,SREG
000005 94d3      	inc	TCNT2H			// High-Teil in Software
000006 f429      	brne	t2a
000007 0175      	 movw	OCR2H:OCR2L,LEN2H:LEN2L	// Bei Null Wert übernehmen (Doppel-Puffer)
000008 b575      	 in	isrt0,TCCR2
000009 6478      	 sbr	isrt0,1<<WGM21|1<<WGM20	// PWM EIN: WGM=3
00000a bd75      	 out	TCCR2,isrt0
00000b bc93      	 out	OCR2,ONES		// startet erst wenn TCNT2H == 1
00000c 14fd      t2a:	cp	OCR2H,TCNT2H
00000d f409      	brne	t2b
00000e bce3      	 out	OCR2,OCR2L		// LOW-Zeit setzen
00000f 2d7f      t2b:	mov	isrt0,OCR2H
000010 9573      	inc	isrt0			// Sonderfall OCR2H == 0xFF?
000011 f029      	breq	t2c
000012 157d      	cp	isrt0,TCNT2H		// Wenn  TCNT2H == OCR2H+1 ...
000013 f419      	brne	t2c
000014 b575      	 in	isrt0,TCCR2
000015 7b77      	 cbr	isrt0,1<<WGM21|1<<WGM20	// PWM AUS: WGM=0
000016 bd75      	 out	TCCR2,isrt0		// (COM2 bleibt 2: löscht ggf. OC2 später)
000017 becf      t2c:	out	SREG,isrt1
000018 9518      	reti
                 	
                 WaitT1:	// Wartet auf Timer1-Überlauf (bei F_CPU == 8 MHz ca. alle 8 ms)
000019 9ac0      w1:	sbi	PORTB,0			// SLEEP-Kontrollausgabe an Pin 14
00001a 9588      	sleep				// Strom sparen
00001b 98c0      	cbi	PORTB,0
00001c b708      	in	r16,TIFR
00001d ff02
00001e cffa      	jbrc	r16,2,w1
00001f e004
000020 bf08      	outi	TIFR,	0b00000100	// EOI
000021 9508      	ret
                 
000022 2488      Init:	clr	ZERO
000023 2499      	clr	ONES
000024 949a      	dec	ONES
000025 e004
000026 bf0e
000027 e50f
000028 bf0d      	outihl	SP,RAMEND		// Stackpointer initialisieren
000029 e400
00002a bf09      	outi	TIMSK,	0b01000000	// Timer2: Interrupt aktivieren
00002b e609
00002c bd05      	outi	TCCR2,	0b01101001	// Timer2: VT1, schnelle nichtinv. PWM
00002d ea02
00002e bd0f      	outi	TCCR1A,	0b10100010	// Timer1: schnelle nichtinv. PWM
00002f e109
000030 bd0e      	outi	TCCR1B,	0b00011001	// Timer1: VT1
000031 bc97
000032 bc96      	outhl	ICR1,ONES,ONES		// Timer1: Volle 16 bit Zählumfang
                 	
000033 2c48      	mov	r,ZERO
000034 2c58      	mov	g,ZERO
000035 2c69      	mov	b,ONES			// Start mit 100 % Blau
                 	
000036 e10f
000037 bb07      	outi	DDRB,	0b00011111	// Ausgabeports
000038 e800
000039 bf05      	outi	MCUCR,	0b10000000	// SLEEP aktivieren, nur IDLE
00003a 9478      	sei
                 MainLoop:
00003b dfdd      p1:	rcall	WaitT1
00003c 946a      	dec	b
00003d d02b      	rcall	SetPwmB
00003e 9443      	inc	r
00003f d011      	rcall	SetPwmR
000040 1449      	cp	r,ONES
000041 f7c9      	brne	p1
000042 dfd6      p2:	rcall	WaitT1
000043 944a      	dec	r
000044 d00c      	rcall	SetPwmR
000045 9453      	inc	g
000046 d016      	rcall	SetPwmG
000047 1459      	cp	g,ONES
000048 f7c9      	brne	p2
000049 dfcf      p3:	rcall	WaitT1
00004a 945a      	dec	g
00004b d011      	rcall	SetPwmG
00004c 9463      	inc	b
00004d d01b      	rcall	SetPwmB
00004e 1469      	cp	b,ONES
00004f f7c9      	brne	p3
000050 cfea      	rjmp	MainLoop
                 	
                 SetPwmR:
000051 2de4      	mov	ZL,r
000052 d021      	rcall	getexp
000053 bd1b
000054 bd0a      	outhl	OCR1A, r17,r16
000055 b50f      	in	r16,TCCR1A
000056 2044      	tst	r
000057 f011      	breq	ppr1
000058 6800      	sbr	r16,1<<COM1A1
000059 c001      	rjmp	ppr2
00005a 770f      ppr1:	cbr	r16,1<<COM1A1
00005b bd0f      ppr2:	out	TCCR1A,r16
00005c 9508      	ret
                 	
                 SetPwmG:
00005d 2de5      	mov	ZL,g
00005e d015      	rcall	getexp
00005f bd19
000060 bd08      	outhl	OCR1B, r17,r16
000061 b50f      	in	r16,TCCR1A
000062 2055      	tst	g
000063 f011      	breq	ppg1
000064 6200      	sbr	r16,1<<COM1B1
000065 c001      	rjmp	ppg2
000066 7d0f      ppg1:	cbr	r16,1<<COM1B1
000067 bd0f      ppg2:	out	TCCR1A,r16
000068 9508      	ret
                 	
                 SetPwmB:
000069 2de6      	mov	ZL,b
00006a d009      	rcall	getexp
00006b 0158      	movw	LEN2H:LEN2L,r17:r16
00006c b505      	in	r16,TCCR2
00006d 2066      	tst	b
00006e f011      	breq	ppb1
00006f 6200      	sbr	r16,1<<COM21
000070 c001      	rjmp	ppb2
000071 7d0f      ppb1:	cbr	r16,1<<COM21
000072 bd05      ppb2:	out	TCCR2,r16
000073 9508      	ret
                 	
                 getexp:
                 // PE: ZL = Index 0..255
                 // PA: R17:R16 = logarithmischer OCR-Wert mit der Eigenschaft:
                 //	Y[ZL=0] = egal (PWM-Länge 0, ganz AUS)
                 //	Y[ZL=1] = 0 (PWM-Länge 1, minimal)
                 //	Y[ZL=255] = 65535 (PWM-Länge 65536, ganz EIN)
                 // Die PWM des ATtiny/ATmega hat die innewohnende Eigenschaft der
                 // Impulsausgabe: 1 Takt länger als der OCR-Wert
000074 27ff      	clr	ZH
000075 0fee      	lsl	ZL			// WORD-Adresse generieren (0..510)
000076 1fff      	rol	ZH
000077 50e8      	subi	ZL,LOW(-exptab*2)	// Anfangsadresse der Tabelle "addieren"
000078 4fff      	sbci	ZH,HIGH(-exptab*2)
000079 9105      	lpm	r16,Z+			// Tabellenwert lesen
00007a 9115      	lpm	r17,Z+
00007b 9508      	ret
                 exptab:


RESOURCE USE INFORMATION
------------------------

Notice:
The register and instruction counts are symbol table hit counts,
and hence implicitly used resources are not counted, eg, the
'lpm' instruction without operands implicitly uses r0 and z,
none of which are counted.

x,y,z are separate entities in the symbol table and are
counted separately from r26..r31 here.

.dseg memory usage only counts static data declared with .byte

ATmega8 register use summary:
r0 :   0 r1 :   0 r2 :   0 r3 :   0 r4 :   6 r5 :   6 r6 :   6 r7 :   0 
r8 :   3 r9 :   9 r10:   2 r11:   2 r12:   2 r13:   3 r14:   2 r15:   3 
r16:  36 r17:   4 r18:   0 r19:   0 r20:   0 r21:   0 r22:   0 r23:   9 
r24:   0 r25:   0 r26:   0 r27:   0 r28:   0 r29:   0 r30:   5 r31:   3 
x  :   0 y  :   0 z  :   2 
Registers used: 17 out of 35 (48.6%)

ATmega8 instruction use summary:
adc   :   0 add   :   0 adiw  :   0 and   :   0 andi  :   0 asr   :   0 
bclr  :   0 bld   :   0 brbc  :   0 brbs  :   0 brcc  :   0 brcs  :   0 
breq  :   4 brge  :   0 brhc  :   0 brhs  :   0 brid  :   0 brie  :   0 
brlo  :   0 brlt  :   0 brmi  :   0 brne  :   6 brpl  :   0 brsh  :   0 
brtc  :   0 brts  :   0 brvc  :   0 brvs  :   0 bset  :   0 bst   :   0 
cbi   :   1 cbr   :   4 clc   :   0 clh   :   0 cli   :   0 cln   :   0 
clr   :   3 cls   :   0 clt   :   0 clv   :   0 clz   :   0 com   :   0 
cp    :   5 cpc   :   0 cpi   :   0 cpse  :   0 dec   :   4 eor   :   0 
fmul  :   0 fmuls :   0 fmulsu:   0 icall :   0 ijmp  :   0 in    :   7 
inc   :   5 ld    :   0 ldd   :   0 ldi   :   9 lds   :   0 lpm   :   2 
lsl   :   1 lsr   :   0 mov   :   7 movw  :   2 mul   :   0 muls  :   0 
mulsu :   0 neg   :   0 nop   :   0 or    :   0 ori   :   0 out   :  23 
pop   :   0 push  :   0 rcall :  12 ret   :   5 reti  :   4 rjmp  :   6 
rol   :   1 ror   :   0 sbc   :   0 sbci  :   1 sbi   :   1 sbic  :   0 
sbis  :   0 sbiw  :   0 sbr   :   4 sbrc  :   0 sbrs  :   1 sec   :   0 
seh   :   0 sei   :   1 sen   :   0 ser   :   0 ses   :   0 set   :   0 
sev   :   0 sez   :   0 sleep :   1 spm   :   0 st    :   0 std   :   0 
sts   :   0 sub   :   0 subi  :   1 swap  :   0 tst   :   3 wdr   :   0 

Instructions used: 28 out of 108 (25.9%)

ATmega8 memory use summary [bytes]:
Segment   Begin    End      Code   Data   Used    Size   Use%
---------------------------------------------------------------
[.cseg] 0x000000 0x0002f8    248    512    760    8192   9.3%
[.dseg] 0x000060 0x000060      0      0      0    1024   0.0%
[.eseg] 0x000000 0x000000      0      0      0     512   0.0%

Assembly complete, 0 errors, 0 warnings
Detected encoding: ANSI (CP1252)4
Wrong umlauts? - Assume file is ANSI (CP1252) encoded