OK, ich hab die Matrix-Abfrage jetzt noch auf Interrupts umgestellt...
Funktioniert sehr gut, ist sicherlich die sauberere Lösung. Denn auch wenn der AVR nicht anderes als ne Fernbedienung sein soll, kann man so ja später noch prima den Stromspar-Modus zuschalten...
Den Code habe ich modifiziert von hier übernommen:
http://www.mcselec.com/index.php?opt...=175&Itemid=41
(SourceCodes -> EDBexperiment10.bas)
Verwendet wird der PinChange-Interrupt (sehr praktisch, kannte ich noch garnicht)
Dummerweise kommt immer noch 27 - klar, im Prinzip hat sich ja auch nix geändert...
Irgendwelche Ideen?
Code:$regfile = "attiny2313.dat" ' specify the used micro $crystal = 8000000 ' used crystal frequency $hwstack = 64 $swstack = 16 $framesize = 21 $baud = 9600 Config Kbd = Portb , Debounce = 100 , Rows = 6 , Row5 = Pind.5 , Row6 = Pind.4 Dim Key_scan As Byte Dim Togbit As Byte , Address As Byte Pcmsk = &B00001111 'This sets the interrupt mask On Pcint Matrixinput 'On interrupt goto MATRIXINPUT Enable Pcint 'Enable interrupts Enable Interrupts Do 'HIER DER PROGRAMMCODE Loop End Matrixinput: 'If we do not disable the interrupts Disable Interrupts 'GetKBD would generate interrupts Waitms 2 'That we cannot use Key_scan = Getkbd() 'Look in the help file on how to connect the matrix keyboard Waitms 2 'Waitms anti bounce If Key_scan <> 24 Then Goto Rc5_senden Print "Keynr.: " ; Key_scan ; " received" '24 is no key pressed, so if 24 do nothing End If Return_from_interrupt: Enable Interrupts Return Wait_for_matrix_24: 'Will wait until no key is pressed before enableing the interrupts Key_scan = Getkbd() If Key_scan = 24 Then Goto Return_from_interrupt Goto Wait_for_matrix_24 Rc5_senden: Togbit = 0 Address = 0 Config Pinb.3 = Output Rc5send Togbit , Address , Key_scan







Zitieren

Lesezeichen