-
Categories
-
Platforms
-
Content
That should not be the case. PORT A should be useable as input or output, depending n the state of TRISA.Port A cannot be input.
I believe it means "Tri-State" Register. IE a port that can have one of 3 states. High (5V), Low(0V) or Open(Hi Z).Hmm. I am thinking the same too, but it works using port d instead of port a. Still wondering.
Sorry that i'm still new to PIC, thanks for your reply.
Anyway, may i know the word 'TRIS' stands for?
Anyway, may i know the word 'TRIS' stands for?
Oh, tri-state. Thanks. May I know what do you mean by 'Open(Hi Z)'?I believe it means "Tri-State" Register. IE a port that can have one of 3 states. High (5V), Low(0V) or Open(Hi Z).
Chris
from this www site ..... http://www.mikroe.com/chapters/view/16/chapter-3-pic16f887-microcontroller/
3.3 INPUT/OUTPUT PORTS
In order to synchronize the operation of I/O ports with the internal 8-bit organization of the microcontroller, they are, similar to registers, grouped into five ports denoted by A, B, C, D and E. All of them have several features in common:
By clearing any bit of the TRIS register (bit=0), the corresponding port pin is configured as an output. Similarly, by setting any bit of the TRIS register (bit=1), the corresponding port pin is configured as an input. This rule is easy to remember 0 = Output, 1 = Input.
- For practical reasons, many I/O pins are multifunctional. If a pin performs any of these functions, it may not be used as a general-purpose input/output pin.
- Every port has its ‘satellite’, i.e. the corresponding TRIS register: TRISA, TRISB, TRISC etc. which determines the performance of port bits, but not their contents.
View attachment 21240
PORTA and TRISA register
Port A is an 8-bit wide, bidirectional port. Bits of the TRISA and ANSEL registers control the Port A pins. All Port A pins act as digital inputs/outputs. Five of them can also be analog inputs (denoted by AN):
View attachment 21241
Dave
Oh, tri-state. Thanks. May I know what do you mean by 'Open(Hi Z)'?
void initiate_main()
{
cmcon = 7;
cvrcon = 0;
adcon1 = 0x87;
trisa = 1;
porta = 0;
}
void main()
{
initiate_main();
delay_ms(200);
while(1)
{
if(porta.f0 == 1)
{
delay_ms(50);
if(porta.f0 == 1)
{
portd.f0 = 1;
}
}
else if(porta.f0 == 0)
{
delay_ms(50);
if(porta.f0 == 0)
{
portd.f0 = 0;
}
}
}
}