Hi everyone.
I put this topic here because I think it may contain information more than PIC.
If the code is written in this way:
switch(period)
{
case 0:
PORTBbits.RB3=1;
PORTBbits.RB4=1;
PORTBbits.RB5=1;
break;
case 4:
PORTBbits.RB3=1;
PORTBbits.RB4=1;
PORTBbits.RB5=1;
break;
..........
...........
default:break;
}
The one of the output (RB4) will show strange behavior as in figure 1.
If the codes are written in this way:
switch(period)
{
case 0:
PORTBbits.RB3=1;
break;
case 4:
PORTBbits.RB3=1;
break;
..........
...........
default:break;
}
switch(period)
{
case 0:
PORTBbits.RB4=1;
break;
case 4:
PORTBbits.RB4=1;
break;
..........
...........
default:break;
}
switch(period)
{
case 0:
PORTBbits.RB5=1;
break;
case 4:
PORTBbits.RB5=1;
break;
..........
...........
default:break;
}
The outputs are just fine, which is shown in figure 2.
It seems that the pins have to be updated separately.
It is soooo strange, why?????
Because of the power supply is not clean???????
Thank you.
BTW, why the voltage may go to -2V in figure 2????
I put this topic here because I think it may contain information more than PIC.
If the code is written in this way:
switch(period)
{
case 0:
PORTBbits.RB3=1;
PORTBbits.RB4=1;
PORTBbits.RB5=1;
break;
case 4:
PORTBbits.RB3=1;
PORTBbits.RB4=1;
PORTBbits.RB5=1;
break;
..........
...........
default:break;
}
The one of the output (RB4) will show strange behavior as in figure 1.
If the codes are written in this way:
switch(period)
{
case 0:
PORTBbits.RB3=1;
break;
case 4:
PORTBbits.RB3=1;
break;
..........
...........
default:break;
}
switch(period)
{
case 0:
PORTBbits.RB4=1;
break;
case 4:
PORTBbits.RB4=1;
break;
..........
...........
default:break;
}
switch(period)
{
case 0:
PORTBbits.RB5=1;
break;
case 4:
PORTBbits.RB5=1;
break;
..........
...........
default:break;
}
The outputs are just fine, which is shown in figure 2.
It seems that the pins have to be updated separately.
It is soooo strange, why?????
Because of the power supply is not clean???????
Thank you.
BTW, why the voltage may go to -2V in figure 2????
Attachments
-
13.9 KB Views: 25
-
18.1 KB Views: 23