PIC18F6485 input output pins

Thread Starter

shanu

Joined Dec 29, 2008
3
hi
from the datasheet of PIC18F4685 for configuring any port as output we have to configure corresponding TRIS high.
but practically follwing problem is being faced
1. corresponding bit becomes high
2. setting one bit as input, it makes all the pins of the same port to behave as input.
3. after sometime when i made the port TRIS = 0, then by default it behaves as bidirectional port.


please tell me where i am wrong?
thnx in advance
 

hgmjr

Joined Jan 28, 2005
9,027
Maybe you can post your source code so that we can see for ourselves how you have coded the port settings.

hgmjr
 

mik3

Joined Feb 4, 2008
4,843
With SET_TRIS you set each pin as an input or as an output. To set the pin as high or low you have to use output_X(value).

X is the name of the corresponding port, for example A.

Are you using the GCC compiler?
 

Thread Starter

shanu

Joined Dec 29, 2008
3
my code is

void main()
{
TRISA = 0;
TRISB = 1; // set TRISB = 0 in later case.
PORTA = 0;
PORTB = 0;
while(1)
{
PORTA = PORTB;
}
}

i set the configuration CONFIG1H = 0xF8 with portA for controller to work on Internal oscillator block (, port function on RA6 and RA7)
and
CONFIG3H: = 0xFD for making portb as digital input/output.....

so when i run this program
corresponding bit becomes high (i.e 1st pin of portb )

and following things are observed
setting one bit as input, it makes all the pins of the port B to behave as input.

after sometime when i made the TRISB = 0,
then by default it behaves as input port as well showing its output on portA .

thnks...
 

Thread Starter

shanu

Joined Dec 29, 2008
3
sir
i am using following compiler to generate hex file...
mikroC, mikroElektronika C compiler
for Microchip PIC microcontrollers
Version: 8.2.0.0
 
Top