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

Harrington

Joined Dec 19, 2009
85
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:
Top