B
bbgil
Guest
Labas.Turiu šį paprastą kodą, kurį turėtų įjungti 7 segmentų ekranas (bendro anodo) 0-9 kartus.I'm using switch funkcija ir TMR0.problema aš negaliu padaryti to count.jį išlaikytas 8.Manau, problema yra mano TMRO ir kaip skaičiuoti, todėl tai valdymo jungiklis funkcija.Bet kuris iš C guru out there help bus įvertintas.dar išmokti naudotis C. Čia yra kodas.thnx in advance.
unsigned cnt;
unsigned cnt1;
tuščia nutraukti () (
cnt ;
if (CNT == 400)
(cnt = 0;
cnt1 = cnt1
/ / didinti vertę cnt ant kiekvieno pertraukti
INTCON = 0x20;
TMR0 = 96 / / Set T0IE, aišku T0IF
) / / ~
void main () (
OPTION_REG = 0x84; / / priskyrimas Prescaler į TMR0
TRISb = 0; / / PORTB yra išėjimas
PORTb = 0xFF / / inicjalizacja PORTB
TMR0 = 0x96;
INTCON = 0xA0 / / Įjungti TMRO pertraukti
cnt = 0;
cnt1 = 0; / / inicjalizacja CNT
do (
if (cnt1 <0x09)
switch (cnt1) (
case 0: portb = 0x81;
1 atvejis: portb = 0xf3;
2 atvejis: portb = 0x49;
3 atvejis: portb = 0x61;
case 4: portb = 0x33;
case 5: portb = 0x25;
case 6: portb = 0x05;
Case 7: portb = 0xf1;
Case 8: portb = 0x01;
Case 9: portb = 0x31;
Default: portb = 0x81;
)
cnt1 = 0;
/ / Reset CNT
) While (1);
}//~!
unsigned cnt;
unsigned cnt1;
tuščia nutraukti () (
cnt ;
if (CNT == 400)
(cnt = 0;
cnt1 = cnt1
INTCON = 0x20;
TMR0 = 96 / / Set T0IE, aišku T0IF
) / / ~
void main () (
OPTION_REG = 0x84; / / priskyrimas Prescaler į TMR0
TRISb = 0; / / PORTB yra išėjimas
PORTb = 0xFF / / inicjalizacja PORTB
TMR0 = 0x96;
INTCON = 0xA0 / / Įjungti TMRO pertraukti
cnt = 0;
cnt1 = 0; / / inicjalizacja CNT
do (
if (cnt1 <0x09)
switch (cnt1) (
case 0: portb = 0x81;
1 atvejis: portb = 0xf3;
2 atvejis: portb = 0x49;
3 atvejis: portb = 0x61;
case 4: portb = 0x33;
case 5: portb = 0x25;
case 6: portb = 0x05;
Case 7: portb = 0xf1;
Case 8: portb = 0x01;
Case 9: portb = 0x31;
Default: portb = 0x81;
)
cnt1 = 0;
/ / Reset CNT
) While (1);
}//~!