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.
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.
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)
.
You have two options using #USE STANDARD_IO(port)
or #USE FAST_IO(port)
directives:
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.
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)