tinyrgb_new.zip

Sterownik Led /zmieniacz kolorów świecenia.

Proszę bardzo wedle życzenia sterowanie diodą RGB, znalazłem w 30 sekund. :D:D:D .include "tn12def.inc" .def omod = r29 .def temp1 = r16 .def temp2 = r17 .def output = r18 .def swcount0 = r19 .def output = r20 .def pwmcount = r21 .def pwmvalue_red = r22 .def pwmvalue_green = r23 .def pwmvalue_blue = r24 .def direction = r25 .def colorselect = r26 .def pwmvalue = r27 .def dirty = r28 .equ EE_OSCCAL=$3f .equ EE_PWM_RED=$00 .equ EE_PWM_GREEN=$01 .equ EE_PWM_BLUE=$02 .equ EE_OMOD=$03 .equ timer_value = $80 ;reset handler .org $0000 rjmp main ;timer overflow interrut handler .org OVF0Addr rjmp OVF0Handler .org $0010 main: ;stack setup ;read osccal byte waitstableosccal: sbic eecr,eewe rjmp waitstableosccal ldi temp1,EE_OSCCAL out eear,temp1 sbi eecr,eere in temp1,eedr out osccal,temp1 ;port setup ;port b input with pullups ldi temp1,$00 out ddrb,temp1 ;port b output off, pullups on ldi temp1,$18 out portb,temp1 setstatus: sbic eecr,eewe rjmp setstatus ldi temp1,EE_OMOD out eear,temp1 sbi eecr,eere in temp1,eedr ;Toggle Power On Mode, only onboard-Pushbutton sbic pinb,3 rjmp notoggle toggle: inc temp1 ;aktuellen wert lesen ;und sicherstellen, dass er gültig ist ;neuen status schreiben writeok: sbic eecr,eewe rjmp writeok ldi temp2,EE_OMOD out eear,temp2 out eedr,temp1 sbi eecr,eemwe sbi eecr,eewe notoggle: sbis pinb,pb3 rjmp notoggle sbis pinb,pb4 rjmp notoggle ldi omod,$00 sbrs temp1,1 ldi omod,$07 ldi temp2,$00 sbrs temp1,0 ldi temp2,$07 ldi temp1,$1f eor temp1,omod out portb,temp1 out ddrb,temp2 ;Timer zurücksetzen ldi temp1,timer_value out tcnt0,temp1 ;Timer interrupts an ldi temp1,(1<<toie0) out timsk,temp1 ;Timer starten ldi temp1,$04 out tccr0,temp1 ldi swcount0, $00 ldi pwmcount,$00 rcall readsettings ldi colorselect,$00 ldi direction,$00 ldi dirty,$00 sei loop: ;leds aus ldi output,$1f cp pwmvalue_red,pwmcount brsh check_green ;leds an cbr output,$01 check_green: cp pwmvalue_green,pwmcount brsh check_blue ;leds an cbr output,$02 check_blue: cp pwmvalue_blue,pwmcount brsh writeoutput ;leds an cbr output,$04 writeoutput: eor output,omod out portb,output inc pwmcount sbic ddrb,0 rjmp loop ;wenn LED's aus sein sollen, dann auch die Pullups abschalten ldi output,$18 out portb,output ; warten, bis über Tastendruck die Pullups wieder angeschaltet werden. waiton: sbic ddrb,0 rjmp loop rjmp waiton OVF0Handler: in r1,sreg sbis pinb,4 rjmp pressedhandler sbis pinb,3 rjmp pressedhandler cpi swcount0,$02 brlo exitreleasehandler cpi swcount0,$1f brsh exitreleasehandler cpi swcount0,$08 brsh setcolor ;turn on / Off in temp1,ddrb ldi temp2,$07 eor temp1,temp2 out ddrb,temp1 rcall writesettings rjmp exitreleasehandler setcolor: ;turn on ldi temp1,$07 out ddrb,temp1 inc colorselect cpi colorselect,$03 brne showcolor ldi colorselect,$00 showcolor: ldi temp1,$1e cpi colorselect,$00 breq writecolor ldi temp1,$1d cpi colorselect,$01 breq writecolor ldi temp1,$1b writecolor: eor temp1,omod out portb,temp1 ldi temp2,$00 delay: dec temp1 nop nop nop brne delay dec temp2 brne delay exitreleasehandler: ldi swcount0,$00 exit_ovf0Handler: out sreg,r1 reti ;zähler nur bis zum maximum erhöhen pressedhandler: cpi swcount0,$20 brsh noinc inc swcount0 noinc: cpi swcount0,$20 brlo exit_ovf0handler ;auf alle fälle einschalten ldi temp1,$07 out ddrb,temp1 cpi colorselect,$00 brne test_green mov pwmvalue,pwmvalue_red rcall updown mov pwmvalue_red,pwmvalue rjmp exit_ovf0handler test_green: cpi colorselect,$01 brne test_blue mov pwmvalue,pwmvalue_green rcall updown mov pwmvalue_green,pwmvalue rjmp exit_OVF0Handler test_blue: cpi colorselect,$02 brne exit_ovf0Handler mov pwmvalue,pwmvalue_blue rcall updown mov pwmvalue_blue,pwmvalue rjmp exit_ovf0Handler updown: ldi dirty,$ff sbrs direction,0 rjmp uphandler ldi temp1,$01 cpi pwmvalue,$f0 brsh more1 ldi temp1,$02 cpi pwmvalue,$e8 brsh more1 ldi temp1,$08 more1: clc sub pwmvalue,temp1 brcc exitsub ldi pwmvalue,$00 cbr direction,1 rjmp exitsub uphandler: ldi temp1,$01 cpi pwmvalue,$f0 brsh more2 ldi temp1,$02 cpi pwmvalue,$e8 brsh more2 ldi temp1,$08 more2: clc add pwmvalue,temp1 brcc exitsub ldi pwmvalue,$ff sbr direction,1 exitsub: ret readsettings: ldi temp1,$00 out eear,temp1 waitstable: sbic eecr,eewe rjmp waitstable sbi eecr,eere in pwmvalue_red,eedr inc temp1 out eear,temp1 sbi eecr,eere in pwmvalue_green,eedr inc temp1 out eear,temp1 sbi eecr,eere in pwmvalue_blue,eedr ret writesettings: ;eeprom-Schonen! ;nur schreiben, wenn sich was geändert hat cpi dirty,$00 breq endwrite ldi dirty,$00 ldi temp1,$00 out eear,temp1 waitstable1: sbic eecr,eewe rjmp waitstable1 out eedr,pwmvalue_red sbi eecr,eemwe sbi eecr,eewe waitstable2: sbic eecr,eewe rjmp waitstable2 inc temp1 out eear,temp1 out eedr,pwmvalue_green sbi eecr,eemwe sbi eecr,eewe waitstable3: sbic eecr,eewe rjmp waitstable3 inc temp1 out eear,temp1 out eedr,pwmvalue_blue sbi eecr,eemwe sbi eecr,eewe endwrite: ret Jeśli jesteś jednak leniem, nie chce Ci się szukać, nie umiesz szukać, kazali zrobić a Ty nie wiez jak * (* niepotrzebne skreślić) - zajęło mi to następne 30 sekund, w sumie dłużej niż pisanie tego postu, ale co tam, trzeba sobie pomagać. :D:D:D http://www.loetstelle.net/projekte/atmelmicro/atmelmicro.php Troszkę inny układ + soft http://obrazki.elektroda.net/20_1206557216.jpg

  • tinyrgb_new.zip
    • tinyRGB.asm
    • tinyRGB.hex


Pobierz plik - link do postu