View previous topic :: View next topic |
Author |
Message |
wynnet
Joined: 02 Dec 2003 Posts: 15
|
LED constant On then Blink. What pin is best for the job? |
Posted: Thu Apr 01, 2004 12:17 pm |
|
|
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
|
|
Posted: Thu Apr 01, 2004 12:57 pm |
|
|
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
|
|
Posted: Fri Apr 02, 2004 11:33 am |
|
|
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
|
|
Posted: Fri Apr 02, 2004 11:51 am |
|
|
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
|
|
Posted: Fri Apr 02, 2004 11:52 am |
|
|
I forgot to login before answer, sorry! The last post is mine!
Marcus |
|
|
Neutone
Joined: 08 Sep 2003 Posts: 839 Location: Houston
|
|
Posted: Fri Apr 02, 2004 12:35 pm |
|
|
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
|
LED constant On then Blink. What pin is best for the job? |
Posted: Mon Apr 05, 2004 2:11 pm |
|
|
Thanks Neutone and Marcus,
Great idea
Have a good day |
|
|
|