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 support@ccsinfo.com

LED flasher

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



Joined: 13 Sep 2003
Posts: 87

View user's profile Send private message

LED flasher
PostPosted: Mon Apr 19, 2004 11:12 pm     Reply with quote

Hi,

Anyone has a sample code snippet for a LED flasher... say it turns on for 500mS at the same time it flashes then turns-off for one sec. I plan to use a timer interrupt.

Thnx
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Tue Apr 20, 2004 12:55 am     Reply with quote

Lazy??? How about doing some research yourself before asking a question here?

There have been numerous examples of this. Use the Search function!
carlosma



Joined: 24 Mar 2004
Posts: 53
Location: Portugal

View user's profile Send private message Send e-mail MSN Messenger

PostPosted: Tue Apr 20, 2004 10:34 am     Reply with quote

Hello

Code:
#include <16f877.h>
#use delay(clock=4000000)
#fuses HS,NOWDT,PUT,NOLVP

signed long int t0_conta;

#int_timer0
void trata_t0 ()
{
   static boolean led;
   t0_conta -= 256;
   if (t0_conta<=0)
   {
      
      t0_conta += 2500;
      led = !led; 
      output_bit (pin_c2,led);
   }
}

main()
{
   t0_conta = 2500;

   setup_timer_0 ( RTCC_INTERNAL | RTCC_DIV_4 );

   enable_interrupts (global | int_timer0);
   while (true); // espera interrupção
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