Hallo JayCool!
Ich habe mal so ein Problem gehabt und so wie im Code gelöst (es ist ein Fragment meines Programms für PIC18F252, soll aber auf allen PICs laufen). Die Variable ist im DTemp und hat einen wert 0...7. Man kann es aber biliebig erweitern. Nach dem feststellen des Wertes der Variablen wird mit goto ein bit im DTemp2 gesetzt. Z.B. wenn die Variable im DTemp gleich 3 ist, wird ein bit 4 im DTemp2 gesetzt. Es ist vieleicht nicht die optimale Lösung, hat aber funktioniert.
Alles klar ? Wenn nicht, bitte weiter fragen !![]()
MfG
Code:Comp00_07 movf DTemp,0 sublw 7 btfsc _Z goto SetB0 movf DTemp,0 sublw 6 btfsc _Z goto SetB1 movf DTemp,0 sublw 5 btfsc _Z goto SetB2 movf DTemp,0 sublw 4 btfsc _Z goto SetB3 movf DTemp,0 sublw 3 btfsc _Z goto SetB4 movf DTemp,0 sublw 2 btfsc _Z goto SetB5 movf DTemp,0 sublw 1 btfsc _Z goto SetB6 movf DTemp,0 sublw 0 btfsc _Z goto SetB7 SetB0 bsf DTemp2,0 return SetB1 bsf DTemp2,1 return SetB2 bsf DTemp2,2 return SetB3 bsf DTemp2,3 return SetB4 bsf DTemp2,4 return SetB5 bsf DTemp2,5 return SetB6 bsf DTemp2,6 return SetB7 bsf DTemp2,7 return







Zitieren

Lesezeichen