|
|
View previous topic :: View next topic |
Author |
Message |
RF Guest
|
16F870 Port C |
Posted: Mon Jun 09, 2003 9:12 am |
|
|
Hi,
I’ve configured a 28-pin 16F870 port C, RC4 to RC7 as outputs connected to a 4-phase (ie. 4 connections) stepper motor.
I also would like to use port C, RC0 and RC1 as inputs.
If RC0 and RC1 are initially set to high, and I use output_c(0xF0), RC4 to RC7 will be set to high. Will RC0 and RC1 be set from high to low? Basically, my aim is to ensure that RC0 and RC1 are not affected by the output_c() function and I would like them to stay high in this example.
If RC0 and RC1 inputs are affected by the output_c() function, how do I make RC0 and RC1 to be independent from output_c() function?
Please clarify the above for me.
RF
___________________________
This message was ported from CCS's old forum
Original Post ID: 144515114 |
|
|
R.J.Hamlett Guest
|
Re: 16F870 Port C |
Posted: Mon Jun 09, 2003 10:19 am |
|
|
:=Hi,
:=
:=I’ve configured a 28-pin 16F870 port C, RC4 to RC7 as outputs connected to a 4-phase (ie. 4 connections) stepper motor.
:=
:=I also would like to use port C, RC0 and RC1 as inputs.
:=
:=If RC0 and RC1 are initially set to high, and I use output_c(0xF0), RC4 to RC7 will be set to high. Will RC0 and RC1 be set from high to low? Basically, my aim is to ensure that RC0 and RC1 are not affected by the output_c() function and I would like them to stay high in this example.
:=
:=If RC0 and RC1 inputs are affected by the output_c() function, how do I make RC0 and RC1 to be independent from output_c() function?
:=
:=Please clarify the above for me.
:=
:=RF
They wont be affected by 'bit' I/O operations, but would be changed by a byte operation as you show. The best way, to avoid this, and give extra speed, is to use the 'fast_io' option.
So you would need the following:
#USE fast_io(C)
//This prevents the compiler from controlling the TRIS
//register for the port 'automatically'.
set_tris_C(0x0F);
//This now sets the top four bits as outputs, and the bottom
//four bits as inputs.
Now the standard input and output functions, will no longer control the bits in the TRIS register. This makes them work faster, and prevents any interaction. If (for instance), you asked for:
output_c(0xFF);
The top four bits will be set, but the bottom four input pins will remain as inputs, and no change will be seen on their signals. :-)
Best Wishes
___________________________
This message was ported from CCS's old forum
Original Post ID: 144515116 |
|
|
RF Guest
|
Re: 16F870 Port C |
Posted: Tue Jun 10, 2003 1:33 am |
|
|
:=:=Hi,
:=:=
:=:=I’ve configured a 28-pin 16F870 port C, RC4 to RC7 as outputs connected to a 4-phase (ie. 4 connections) stepper motor.
:=:=
:=:=I also would like to use port C, RC0 and RC1 as inputs.
:=:=
:=:=If RC0 and RC1 are initially set to high, and I use output_c(0xF0), RC4 to RC7 will be set to high. Will RC0 and RC1 be set from high to low? Basically, my aim is to ensure that RC0 and RC1 are not affected by the output_c() function and I would like them to stay high in this example.
:=:=
:=:=If RC0 and RC1 inputs are affected by the output_c() function, how do I make RC0 and RC1 to be independent from output_c() function?
:=:=
:=:=Please clarify the above for me.
:=:=
:=:=RF
:=They wont be affected by 'bit' I/O operations, but would be changed by a byte operation as you show. The best way, to avoid this, and give extra speed, is to use the 'fast_io' option.
:=So you would need the following:
:=
:=#USE fast_io(C)
:=
:=//This prevents the compiler from controlling the TRIS
:=//register for the port 'automatically'.
:=
:=set_tris_C(0x0F);
:=
:=//This now sets the top four bits as outputs, and the bottom
:=//four bits as inputs.
:=
:=Now the standard input and output functions, will no longer control the bits in the TRIS register. This makes them work faster, and prevents any interaction. If (for instance), you asked for:
:=
:=output_c(0xFF);
:=
:=The top four bits will be set, but the bottom four input pins will remain as inputs, and no change will be seen on their signals. :-)
:=
:=Best Wishes
Hi,
Many thanks for your suggestion. It sounds logical and I'll give it a try as soon as my hardware is built in a few days time.
RF
___________________________
This message was ported from CCS's old forum
Original Post ID: 144515134 |
|
|
|
|
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
|
Powered by phpBB © 2001, 2005 phpBB Group
|