Set PIC pin as input and output with CCS?

2

Good afternoon, I want to switch a PIC pin set as output to the middle of the program execution, and then return the pin as output.

    
asked by anonymous 04.07.2016 / 22:29

2 answers

1

uses the directive:

#use standard_io(A)

Then just use the normal functions for reading and writing: input (pin) , output_high (pin) and output_low(pin) .

    
19.08.2016 / 16:42
1

You have two options using #USE STANDARD_IO(port) or #USE FAST_IO(port) directives:

#USE STANDARD_IO (port)

Advantage: It "takes care" of the direction of the pins. So when you use input(pin) , output_high(pin) or output_low(pin) you do not have to worry about setting the direction of the pins.

Disadvantage: When you do a reading or writing, more code is always generated to set the direction of the pin, even without needing it. This way it uses more memory and this can be a problem depending on the size of your firmware and the available memory of your μController.

#USE FAST_IO (port)

Advantage: Uses less memory because it only generates the code needed to read or write to the pin.

Disadvantage: You have to be careful and set the direction of the pin before doing a read or writing using the command set_tris_x(value)

    
02.12.2016 / 14:18