Visualizza messaggio singolo
Vecchio 26 novembre 10, 23:16   #97 (permalink)  Top
elicottero78
User
 
L'avatar di elicottero78
 
Data registr.: 14-05-2005
Residenza: bergamo
Messaggi: 1.278
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;
}
}
}
__________________
NUOVO DRONE TAGLIATO AL LASER CO2 https://www.youtube.com/watch?v=cBgCVNyPH5c&t=7s
GRUPPO LASER https://www.facebook.com/groups/1880460478909243/
elicottero78 non รจ collegato   Rispondi citando