Pumpkin, Inc.

Pumpkin User Forums

PIC16F877 Input Ports

For issues specific to Microchip's PICmicro® MCUs, including compilers (e.g. HI-TECH PICC & PICC-18, Microchip MPLAB®-C18) and IDEs (e.g. Microchip MPLAB®).

PIC16F877 Input Ports

Postby 1064453 » Thu Jul 06, 2006 8:13 am

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();

}

1064453
 
Posts: 25
Joined: Wed Nov 16, 2005 12:00 am

Re: PIC16F877 Input Ports

Postby aek » Thu Jul 06, 2006 11:07 am

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.

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

-------
aek
aek
 
Posts: 1888
Joined: Sat Aug 26, 2000 11:00 pm


Return to PICmicro MCUs

Who is online

Users browsing this forum: No registered users and 4 guests

cron