Te aconsejo que te des una vuelta por
Ejemplitos en C para 16F648A y por
Microcursillo en C. Ahí tienes ejemplos de todo
Pero si te interesa esto es lo que dice el Manual de CCS
INPUT()Syntax:
value = input (pin)
Parameters:
Pin to read. Pins are defined in the devices .h file. The actual value is a bit address. For example, port a (byte 5) bit 3 would have a value of 5*8+3 or 43. This is defined as follows: #define PIN_A3 43
Returns:
0 (or FALSE) if the pin is low,
1 (or TRUE) if the pin is high
Availability:
input_x(), output_low(), output_high(), #use xxxx_io
Function:
This function returns the state of the indicated pin. The method of I/O is dependent on the last USE *_IO directive. By default with standard I/O before the input is done the data direction is set to input.
All devices.
Requires
Pin constants are defined in the devices .h file
Examples:
while ( !input(PIN_B1) );
// waits for B1 to go high
if( input(PIN_A0) )
printf("A0 is now high\r\n");
Example Files:
EX_PULSE.C
Also See:
C Compiler Reference Manual
120
INPUT_STATE()Syntax:
Nothing
value = input_state(pin)
Parameters:
pin to read. Pins are defined in the devices .h file. The actual value is a bit address. For example, port A (byte 5) bit 3 would have a value of 5*8+3 or 43. This is defined as follows: #define PIN_A3 43.
Returns:
Bit specifying whether pin is input or output. A 1 indicates the pin is input and a 0 indicates it is output.
Function:
This function reads the I/O state of a pin without changing the direction of the pin as INPUT() does.
Availability:
All devices.
Requires
Examples:
dir = input_state(pin_A3);
printf("Direction: %d",dir);
Example Files:
None
Also See:
input(), set_tris_x(), output_low(), output_high()
Built-In Functions
121
INPUT_x()Syntax:
value = input_a()
value = input_b()
value = input_c()
value = input_d()
value = input_e()
value = input_f()
value = input_g()
value = input_h()
value = input_j()
value = input_k()
Parameters:
None
Returns:
An 8 bit int representing the port input data.
Function:
Inputs an entire byte from a port. The direction register is changed in accordance with the last specified #USE *_IO directive. By default with standard I/O before the input is done the data direction is set to input.
Availability:
All devices.
Requires
Nothing
Examples:
data = input_b();
Example Files:
ex_psp.c
Also See:
input(), output_x(), #USE xxxx_IO