how to declare port a to be input n output.??

Discussion in 'Programmer's Corner' started by fiezzshah, Feb 3, 2010.

  1. fiezzshah

    Thread Starter New Member

    Feb 2, 2010
    6
    0
    * PIC16f84A:

    how to declare the port A0-to-port A3 to be output?

    how to declare the port A4 to be input?
     
  2. AllVol

    AAC Fanatic!

    Nov 22, 2005
    55
    2
    TRIS controls port direction.
     
  3. fiezzshah

    Thread Starter New Member

    Feb 2, 2010
    6
    0
    can you show some example?
     
  4. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    Download the PIC16f84A data sheet from Microchip. It is full of examples
     
  5. Harrington

    New Member

    Dec 19, 2009
    86
    3
    Its a good idea to learn some assembler when you do This will give you a better idea of indirect and direct addressing Although there are many high level languages out there for doing this The best way I've found to learn this is with assembler first You develop a good knowledge of the different registers the special function registers, Timers, Interrupts etc
    To answer your question the easy way to do this is as follows

    TRISA = %00001000 ' this makes portA output on bits 0 to 3 bit 4 an input
    Dont forget to clear your ports as well by writing 0's to them before attempting to read

    Also bear in mind Port A bit 5 is open drain which means you need to be careful when making this output This is in the datasheet
     
    Last edited: Mar 2, 2010
Loading...