PIC18F6485 input output pins

Discussion in 'Embedded Systems and Microcontrollers' started by shanu, Jan 1, 2009.

  1. shanu

    Thread Starter New Member

    Dec 29, 2008
    3
    0
    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
     
  2. hgmjr

    Moderator

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

    hgmjr
     
  3. mik3

    Senior Member

    Feb 4, 2008
    4,846
    63
    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?
     
  4. shanu

    Thread Starter New Member

    Dec 29, 2008
    3
    0
    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...
     
  5. shanu

    Thread Starter New Member

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