TRISA register controls the direction of a pin or an entire port. Think of it this way, setting a bit in the register as a 0 – think output. Setting a bit as a 1 – think input.
After a power on or reset – the Pins are set to Input mode.
To make pin RA0, an output we would..
ANSELAbits.ANSA0 = 0; //Disable Analog – This is important disable analog because it is enabled by default. TRISAbits.TRISA0 = 0; //Set Pin 0 PortA.0 as output
Once it is set as an output we can write to the associated LATA register to make it high or low.
LATAbits.LATA0 = 1; //Sets the pin A.0 high LATAbits.LATA0 = 0; //Sets the pin A.0 low
(Note**) Pin RA3 can only be an input pin you can not set it as an output..
Have a technology project in mind? Let’s talk!
I am currently available for hire
Need a custom technology solution for your business? Please send me an email (firstname.lastname@example.org) to discuss your project needs.
I can help you get started on the road of building a simple and well-tested working solution, together, with your team.