I am new into CCS and I am using a PIC12F683. Reading the status of an input pin is no problem. But how can I read the status of an output pin? I know that I am controlling the pin, but if I want to do something only when the pin set to high. Like: "if (PIN_A0 = 1)"
Hope you understand what I mean.
Rohit de Sa
Joined: 09 Nov 2007 Posts: 282 Location: India
Posted: Mon Sep 07, 2009 2:51 am
I haven't really understood what exactly it is that you want to do. Almost all pins can be set as inputs or outputs. In more technical terms almost all pins have an input buffer and an output latch (there are a few pins which may be input-only). Have a look at this code segment:
Code:
output_high(pin_a0);
flag_var=input(pin_a0);
This first outputs a '1' onto pin A0, and then attempts to read the status of the same pin. This is all you require to do - the compiler does the hard work of changing the tristate register of the PIC. The above statements make the pin an output, and then change it to an input.
If you wish that the pin remain an output while you check its status, you want to use the statement:
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