CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

USE of #use fixed_io

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
cf



Joined: 08 Nov 2004
Posts: 4

View user's profile Send private message

USE of #use fixed_io
PostPosted: Mon Nov 08, 2004 10:24 am     Reply with quote

Hi,

Who can explain me how to use #use fixed_io.

I'm see that if i'm want to use 232 and I2C i'm must do

#use delay(clock=xxxxxxx)

#use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7,parity=N,bits=8,xxxxx)
#use I2C(master, sda=PIN_C4, scl=PIN_C3)

and if i'm want to work with an over bit on port C as output

#use fixed_io(c_outputs=PIN_C0)

but now if i'm want to use an over pin PIN_C2 as input what must i do

generaly i'm use this kind of funtion to initialise my port :

/**************************************/
/* initialisation du port J en sortie */
/**************************************/
void ini_outpj (void)
{
//clear portg
output_J(0);
//direction en sortie
set_tris_J(0X00);
}
/**************************************/
/* initialisation du port J en entre */
/**************************************/
void ini_outpj (void)
{
//clear portg
output_J(0);
//direction en entre
set_tris_J(0XFF);
}


thank

c.f
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Mon Nov 08, 2004 10:52 am     Reply with quote

Straight from the help file

Quote:
#USE FIXED_IO


Syntax:
#use fixed_io (port_outputs=pin, pin?)



Elements:
port is A-G, pin is one of the pin constants defined in the devices .h file.



Purpose:
This directive affects how the compiler will generate code for input and output instructions that follow. This directive takes effect until another #use xxx_IO directive is encountered. The fixed method of doing I/O will cause the compiler to generate code to make an I/O pin either input or output every time it is used. The pins are programmed according to the information in this directive (not the operations actually performed). This saves a byte of RAM used in standard I/O.



Examples:
#use fixed_io(a_outputs=PIN_A2, PIN_A3)



Example Files:
None



Also See:
#use fast_io, #use standard_io


Ttelmah
Guest







PostPosted: Mon Nov 08, 2004 11:15 am     Reply with quote

As has been pointed out by another poster, the manual does cover this pretty well. However it is worth pointing out firstly, that in the code you post, the 'tris_J' statement, effectively acomplishes nothing, unless you are selecting fast_io or fixed_io.
Basically, with the default setting, if you output to a port bit, the compiler automatically clears the corresponing TRIS bit (making the pin an output), and costing one instruction to do it, then outputs the bit. If instead you perform an input on a pin, the compiler instead sets the corresponding TRIS bit, and then reads from the pin. With both 'fixed_Io', and 'fast_IO', this automatic behaviour is turned off. With the latter it is completely disabled for the port, requiring you to have a tris control instruction, but with the former, the 'pin' definitions in the statement, are applied to the TRIS register at that point in the code, and remain in force till either a different 'fixed_IO' statement changes it, or you use TRIS. The default form is bulkier, but has the advantage of allowing 'psuedo tri-state' operation on the pins. With this form, you can leave the compiler to control TRIS for you as needed.

Best Wishes
cf



Joined: 08 Nov 2004
Posts: 4

View user's profile Send private message

USE FIXED IO
PostPosted: Tue Nov 09, 2004 9:19 am     Reply with quote

Hi,

Thank for your answser.

I'm not understand all, so my question was not the good question.

My problem is how to use a demo board whith PIC18F8720 and have the possibility of use or not use hardware resouces implant on it :

RS232 driver tx:PIN_C6, rx:PIN_C7,cts:PIN_B2,rts:PIN_B1

Temperature sensor scl:PIN_C3,sda:PIN_C4

In all case these pin must be affected in the good direction for not have electrical problem


if i'm not use the directive
#use rs232(baud=2400, xmit=PIN_C6, rcv=PIN_C7)
#use I2C( xxxx, scl=PIN_C3,sda=PIN_C4)

i'm can use #use fast_io(C) and SET_TRIS_C( xxx ) to have alway the pin in the good direction.

if i'm use only the directive #use rs232(baud=2400, xmit=PIN_C6, rcv=PIN_C7)

what must i'm do to put PIN_C3 and PIN_C4 for ever in the good direction ?

how work a#use RS232 directive ? it is the complier provide code for input and output.

If i'm use #use fast_io(C) is it in contradiction whith the #use RS232

Or simply i'm can do that an set the tris register for
C3 and C4 in the direction what i'm want to use
C6 and C7 in correspondance with the #use RS232 ?


thank

C.F
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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