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

LED constant On then Blink. What pin is best for the job?

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



Joined: 02 Dec 2003
Posts: 15

View user's profile Send private message

LED constant On then Blink. What pin is best for the job?
PostPosted: Thu Apr 01, 2004 12:17 pm     Reply with quote

if there is an alarm
I need to turn the red LED constant On
afte 45 seconds then I need to make it blink 1/2 sec ON 1/2 sec oFF to get more attention from user.

my part is 18F452
Should I use pin portB-3 pwm output when CCP2MX bit is enabled?

What pin is best for the job?
mvaraujo



Joined: 20 Feb 2004
Posts: 59
Location: Brazil

View user's profile Send private message

PostPosted: Thu Apr 01, 2004 12:57 pm     Reply with quote

wynnet,

it really depends a lot on your application. If you system timer running over interrupts you can use it to count time between light/blink and the own blink rate. This way you should only a pretty simple function to monitor flags from timer interrupt service.

Marcus
wynnet



Joined: 02 Dec 2003
Posts: 15

View user's profile Send private message

PostPosted: Fri Apr 02, 2004 11:33 am     Reply with quote

Ok, I am not sure about your answer.
I already use timer0 to generate a tickcount.

OK, do you suggest I use this tickcount to do my on/on=blink?

hum, may be it is easier now.

Can you expand your idea a little more?
Guest








PostPosted: Fri Apr 02, 2004 11:51 am     Reply with quote

That's it! You got it! I didn't have a lot of time to answer so I didn't describe it very well:

You can use your TMR0 interrupt ticker to count in a variable and apply the action of turn the leds on or off. You can also control blink rate by other variables.

This would be a very small code, not very time demanding since it's called by interrupt and you'll have your main code running also.

I hope it helps a little.

Marcus
mvaraujo



Joined: 20 Feb 2004
Posts: 59
Location: Brazil

View user's profile Send private message

PostPosted: Fri Apr 02, 2004 11:52 am     Reply with quote

I forgot to login before answer, sorry! The last post is mine!

Marcus
Neutone



Joined: 08 Sep 2003
Posts: 839
Location: Houston

View user's profile Send private message

PostPosted: Fri Apr 02, 2004 12:35 pm     Reply with quote

This is how I handle flashing LED's

Code:
/***********************************************************
*    Flash LED's                                           *
*    This routine requires ~xxuS to execute                *
***********************************************************/
#inline
void Flash_LEDs(void)
{ static int16 LED_Data_Good_Delay;
   if(Flash_Data_Good)
   {  ++LED_Data_Good_Delay;
      PIN_DATA_GOOD = bit_test(LED_Data_Good_Delay,6);
      if(LED_Data_Good_Delay>1000)
      {  Flash_Data_Good=0;
         PIN_DATA_GOOD=0;
         LED_Data_Good_Delay=0;
      }
   }
}


This is called on a 1mS time base. The Flash_Data_Good flag is set elsewhere in code. This will flash several times and then trun off one seconds later. The same concepts could apply for you.
wynnet



Joined: 02 Dec 2003
Posts: 15

View user's profile Send private message

LED constant On then Blink. What pin is best for the job?
PostPosted: Mon Apr 05, 2004 2:11 pm     Reply with quote

Thanks Neutone and Marcus,

Great idea

Have a good day
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