|
intanto ho modificato il programma...
char tempo;
void interrupt(){
if((OPTION_REG.INTEDG == 1) && (INTCON.F1 == 1))
{
TMR0 = 0;
OPTION_REG.INTEDG=0; //fronte di discesa
INTCON.F1=0; //reset del flag
}
if((OPTION_REG.INTEDG == 0) && (INTCON.F1 == 1))
{
tempo=TMR0; //prento il timer
OPTION_REG.INTEDG=1; //imposto controllo sul fronte di salita
INTCON.F1=0; //reset del flag
}
}
void main() {
trisa=0;
trisb=0b00000001;
porta=0;
portb=0;
OPTION_REG.T0CS = 0; //imposto l'utilizzo del clock
OPTION_REG.PSA = 0; //imposto il tipo di prescaler da utilizzare
OPTION_REG.PS0 = 1; //
OPTION_REG.PS1 = 1; //imposto il prescaler a 16
OPTION_REG.PS2 = 0; //
INTCON.T0IF = 0; //azzero interrupt timer
OPTION_REG.INTEDG = 1; //imposto controllo sul fronte di salita
INTCON.F1 = 0; //reset flag
INTCON = 0b00010000; //impostato unico interrupt rb0
INTCON.GIE = 1;
while(1){
if(tempo > 50 && tempo <=70)
{
portb.f1=1;
}else{
portb.f1=0;
}
if(tempo > 70 && tempo <=80)
{
portb.f2=1;
}else{
portb.f2=0;
}
if(tempo > 80 && tempo <=90)
{
portb.f3=1;
}else{
portb.f3=0;
}
if(tempo > 90 && tempo <=100)
{
portb.f4=1;
}else{
portb.f4=0;
}
if(tempo > 100 && tempo <=110)
{
portb.f5=1;
}else{
portb.f5=0;
}
if(tempo > 110 && tempo <=120)
{
portb.f6=1;
}else{
portb.f6=0;
}
if(tempo > 120 && tempo <=130)
{
portb.f7=1;
}else{
portb.f7=0;
}
}
}
|