set_tris_a(0xff); // set porta as inputs
set_tris_b(0x00); // set portb as outputs
set_tris_c(0xff); // set portc as inputs
output_b(0x00); // clear portb
{
input_c(); //
output_b(input_c()); //
}
}
Last edited by agompert on Tue Jan 15, 2008 12:38 pm; edited 5 times in total
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
Posted: Tue Jan 15, 2008 12:00 pm
Please use a title for topic that describes the problem, such as
Quote:
"Need help with i/o ports."
Don't just say "Need help".
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
Posted: Tue Jan 15, 2008 12:17 pm
The code is not 'looping' because there is no loop command.
You have the following loop commands in C:
- while
- for
- do / while
An explanation of these commands is out of the scope of this forum, any C book or online course will handle that.
The tris setting commands are not needed as the compiler will handle this for you on every call to input or output data to a port.
The main part of your code could then look like:
Code:
int8 port_value;
while (TRUE)
{
port_value = input_c();
output_b( port_value );
}
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum