Page 1 of 1

PIC16F877 Input Ports

PostPosted: Thu Jul 06, 2006 8:13 am
by 1064453
Hi AEK:

For the code below:
TX output to hyperterminal even I have
not connected 5v to the port RB7.
Can you please advice?


#include <salvo.h>

_OSLabel(TaskCheckInput1)
_OSLabel(TaskCheckSMS1)


void TaskCheckInput(void)
{



for(;
{
if (RB7 == 1)
{
TXREG='0';
}

OS_Yield(TaskCheckInput1);
}
}

void TaskCheckSMS(void)
{
for(;
OS_Yield(TaskCheckSMS1);
}


void main (void)
{

RCSTA=0b10010000;
TXSTA=0b00100000;
//SPBRG =0x19; //2400-25
SPBRG =0x33; //1200-51
TRISB=0b11110000;
OSInit();
OSCreateTask(TaskCheckInput,OSTCBP(1),1);
OSCreateTask(TaskCheckSMS,OSTCBP(2),1);

for (;
OSSched();

}


Re: PIC16F877 Input Ports

PostPosted: Thu Jul 06, 2006 11:07 am
by aek
Read up on the I/O (GPIO) pins of the PIC more carefully -- the PICs have pull-up resistors, and so the pin is likely to be reading +5V anyway.

Also note that with PIC16's that have analog inputs, I think the default is (surprisngly) for the pins to be analog inputs, not digital ones.

Read your databook more carefully is the best advice I can give you.

Also, if you have an ICD or whatever, you can usually single-step and probe the ports of the chip statically to see what the SFRs are recording.

------------------