Avatar of lisa_mc
lisa_mc
Flag for United Kingdom of Great Britain and Northern Ireland

asked on 

Setting up ports for PIC16F877A

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
C

Avatar of undefined
Last Comment
NovaDenizen

8/22/2022 - Mon