We help IT Professionals succeed at work.
Get Started

Setting up ports for PIC16F877A

lisa_mc
lisa_mc asked
on
337 Views
Last Modified: 2012-08-13
I have recently been given code which was written to program a PIC16F877A.  This code has been written in C.

I understand the different ports but I dont understand what TRISA is and what they are used for.

Also I have noticed in the code when each of the ports is setup the code is used:

TRISA = 0xFF    // sets to inputs
PORTA = 0x00 // sets to zero

TRISD = 0x4E // set bits (0,1,2,5) inputs, others outputs
PORTD = 0x00

What I dont understand is how does 0xFF sets this to an input, and also how does 0x4E set this to bit 0,1,2,5 as inputs and others outputs

I have tried searching the internet but I dont really understand so if anyone would have a simple way of explaining this would be greatly appreciated
Comment
Watch Question
CERTIFIED EXPERT
Top Expert 2009
Commented:
This problem has been solved!
Unlock 1 Answer and 2 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE