Lesson Microcontroller Course # Explanation of TRIS
First, we must know the legs that we can control in the pick
For example pic16f84a
In this microcontroller, we can control 13 men RA AND RB
RA0 RA1 RA2 RA3 RA4
RB0 RB1 RB2 RB3 RB4 RB5 RB6 RB7
I mean, we can enter information and get it out of 13 men into the controller by programming it in C or Microsi language
The condition is that the legs that will be the entrances and the legs that will be the exits are determined, and we cannot use a leg that acts as an entrance and an exit at the same time.
Example :
I want when I press a button or button to turn on the lamp
I mean, inside the program, we will program a pin to be an input input and a pin to be an output
The input man will be the one who will know that we have pressed the button, and the exit man will be the one who will take out v5 volts to turn on the lamp.
Now we will explain what TRIS is
It is simply a function that tells the microcontroller about the inputs and outputs that you will use in your project
We mark the entries with the number 1 and the exits with the number 0
input = 1
output = 0
for example
I want to use all legs of RA as inputs
As we know we have 5 legs in RA
TRISA=0b11111;
0b = means that the number is written in binary
There is also 0x means that the number is written Hexadecimal HEX
Brown is the man RA0
RA1
RA2
RA3
Yellow is the man RA4
Example 2
TRISA=0b11000;
This code means that we told the controller that the legs RA0 RA1 will act as inputs and the rest of the legs RA2 RA3 RA4 will act as outputs
Write the complete code as follows
void main(){
; TRISA=0b110000
}
Any questions, you are welcome + I did not go into much depth so as not to make it difficult for you, good luck
Join the conversation