i am new to this PIC. I’m doing a wireless home alarm system. I’m able to decoder my data and i connect one of the data pin into port RB0. The voltage for the data is 5v. Here is my testing programming code using micro C:
//
void main()
{
portb=0x00;/* initializing all the ports used to be 0*/
portc=0x00;
trisb=0xff;/* initializing port b to be input and portc to be output*/
trisd=0x00;
while(1)
{
if(portb==0x01)
{
portd=0x01;
}
if(portb==0x02)
{
portd=0x02;
}
if(portb==0x03)
{
portd=0x04;
}
if(portb==0x04)
{
portd=0x08;
}
if(portb==0x05)
{
portd=0x10;
}
if(portb==0x06)
{
portd=0x20;
}
if(portb==0x07)
{
portd=0x40;
}
else
{
portd=0x00;
}
}
}
//
According to the program, i should get port RD0 as 1 (5v). But i only manage to get 0.01V at pin.
When i stimulate it using my design, it works well…
Plz help me… I really need assistance to solve this problem…
If PORTB isn’t exactly equal to 0x07, then PORTD will be set to 0. If you want to keep your code as is, you should change all your if statments (except the first one) to else if.