troubleshooting Question

Setting up ports for PIC16F877A

Avatar of lisa_mc
lisa_mcFlag for United Kingdom of Great Britain and Northern Ireland asked on
C
2 Comments1 Solution338 ViewsLast Modified:
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
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros