Ttelmah
Joined: 11 Mar 2010 Posts: 19546
|
|
Posted: Mon Oct 03, 2011 3:38 am |
|
|
I think you need to rephrase your question. 'Complement', would imply reading a value, and inverting this. Though it is possible to reverse a pin direction, it is complex. I think you are actually wanting to _toggle_ a pin. If so, look at the 'output_toggle' instruction.
However some comments:
1) Remember not to overload the pin. When you 'toggle' it, the value 'seen' on the pin, is the current output. If (for instance), you connected directly to an LED, then the pin would probably never drive 'high', so would never be seen as 'high', and the toggle would not work.
2) Remember to check your device's data sheet, for what pins can be outputs. On the 12F615, only GP0,1,2,4, & 5 have output capability. Look at the Register 5-2 table, and note that TRISIO3, is read only, and '1', and the pin diagrams of the chip, and note that GP3, only has an arrow 'inwards', not the two headed arrow used on the other pins.
On the timer, just have an interrupt routine, like:
Code: |
#int_timer0
void timer_tick(void) {
output_toggle(PIN_A0);
}
|
Best Wishes |
|