E
Eraser
Guest
Ho costruito questo programma, in C, questo è un pingpong condotto, su 16f877a pic, ma il lavoro doesnt programma al 100%, la mossa LED per un lato e ritorno dont, e non so perché.
Qualcuno può aiutarmi??
il programma è:# include <htc.h>
int direzione = 0;
__CONFIG (XT & WDTDIS & PWRTDIS & BORDIS & LVPEN & WRTEN & DEBUGDIS & DUNPROT & Unprotect);void inittimer0 (void)
(
T0CS = 0;
T0SE = 0;
PSA = 0;
PS2 = 1;
PS1 = 1;
PS0 = 1;
TMR0 = 0;
)
void initporto (void)
(
TRISD = 0;
PORTD = 0;
Rd7 = 1;
)void interrupcoes (void)
(
T0IF = 0;
T0IE = 1;
GIE = 1;
)void main (void)
(
inittimer0 ();
initporto ();
interrupcoes ();
while (1)
(
)
)my_isr void interrupt (void)
(
if (direzione == 0)
(
T0IF = 0;
PORTD = PORTD * 10;
if (RD0 == 1)
(
direzione = 1;
)
)
altro
(
T0IF = 0;
PORTD = PORTD/10;
if (Rd7 == 1)
(
direzione = 0;
)
)
)
Last edited by Eraser il 31 luglio 2008 20:19, modificato 1 volta in totale
Qualcuno può aiutarmi??
il programma è:# include <htc.h>
int direzione = 0;
__CONFIG (XT & WDTDIS & PWRTDIS & BORDIS & LVPEN & WRTEN & DEBUGDIS & DUNPROT & Unprotect);void inittimer0 (void)
(
T0CS = 0;
T0SE = 0;
PSA = 0;
PS2 = 1;
PS1 = 1;
PS0 = 1;
TMR0 = 0;
)
void initporto (void)
(
TRISD = 0;
PORTD = 0;
Rd7 = 1;
)void interrupcoes (void)
(
T0IF = 0;
T0IE = 1;
GIE = 1;
)void main (void)
(
inittimer0 ();
initporto ();
interrupcoes ();
while (1)
(
)
)my_isr void interrupt (void)
(
if (direzione == 0)
(
T0IF = 0;
PORTD = PORTD * 10;
if (RD0 == 1)
(
direzione = 1;
)
)
altro
(
T0IF = 0;
PORTD = PORTD/10;
if (Rd7 == 1)
(
direzione = 0;
)
)
)
Last edited by Eraser il 31 luglio 2008 20:19, modificato 1 volta in totale