CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

How to complement Single bit or PIN

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Spradecom



Joined: 01 Jun 2011
Posts: 19
Location: INDIA

View user's profile Send private message MSN Messenger

How to complement Single bit or PIN
PostPosted: Sun Oct 02, 2011 11:41 pm     Reply with quote

I am using 12F615. I want to complement one PIN to blink LED using timer 0. How can i write function for that.
Ttelmah



Joined: 11 Mar 2010
Posts: 19513

View user's profile Send private message

PostPosted: Mon Oct 03, 2011 3:38 am     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group