Searching \ for '[PIC] Heart bit led' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/displays.htm?key=led
Search entire site for: 'Heart bit led'.

Exact match. Not showing close matches.
PICList Thread
'[PIC] Heart bit led'
2007\06\28@165555 by Andre Abelian

flavicon
face
Hi to all,

I always use heart bit led to indicate every things fine or there is an error etc.
and noticed that my heart bit led routine is slowing down ADC conversion I have
it on 2 channels. now I am wondering if there is better routine that I used it.
I didn't use any delay that way will be no delay. here is the code I came up.
I use 16f876a and it is setup on timer1 interrupt. I use ccs compiler and i is
global int.


// Is PIC Alive or what?
#INT_TIMER1
void alive_isr()
{
   if ( td_status == OK )
   {
       //      Single Blink to indicate OK
       switch(i)
       {
           case 0 : alive_led_on;  i++; break;
           case 1 : alive_led_on;  i++; break;
           case 2 : alive_led_on;  i++; break;
           case 3 : alive_led_on;  i++; break;
           case 4 : alive_led_on;  i++; break;
           case 5 : alive_led_off; i++; break;
           case 6 : alive_led_off; i++; break;
           case 7 : alive_led_off; i++; break;
           case 8 : alive_led_off; i++; break;
           case 9 : alive_led_off; i++; break;
           default :  i=0;
       }// end of switch
   }
   else
   {
       //      Double Blink to indicate error
       switch(i)
       {
           case 0 : alive_led_on;  i++; break;
           case 1 : alive_led_off; i++; break;
           case 2 : alive_led_on;  i++; break;
           case 3 : alive_led_off; i++; break;
           case 4 : alive_led_off; i++; break;
           case 5 : alive_led_off; i++; break;
           case 6 : alive_led_off; i++; break;
           case 7 : alive_led_off; i++; break;
           case 8 : alive_led_off; i++; break;
           case 9 : alive_led_off; i++; break;
           default :  i=0;        
       }// end of switch
   }// end of if

}


my question is what is the best way of indicating single blink led
or double blink led that is not going to take lots of resources.


thanks

Andre

2007\06\29@112139 by alan smith

picon face
I always do mine in the ISR

Andre Abelian <spam_OUTaabelianTakeThisOuTspammason-electric.com> wrote:  Hi to all,

I always use heart bit led to indicate every things fine or there is an error etc.
and noticed that my heart bit led routine is slowing down ADC conversion I have
it on 2 channels. now I am wondering if there is better routine that I used it.
I didn't use any delay that way will be no delay. here is the code I came up.
I use 16f876a and it is setup on timer1 interrupt. I use ccs compiler and i is
global int.


// Is PIC Alive or what?
#INT_TIMER1
void alive_isr()
{
if ( td_status == OK )
{
// Single Blink to indicate OK
switch(i)
{
case 0 : alive_led_on; i++; break;
case 1 : alive_led_on; i++; break;
case 2 : alive_led_on; i++; break;
case 3 : alive_led_on; i++; break;
case 4 : alive_led_on; i++; break;
case 5 : alive_led_off; i++; break;
case 6 : alive_led_off; i++; break;
case 7 : alive_led_off; i++; break;
case 8 : alive_led_off; i++; break;
case 9 : alive_led_off; i++; break;
default : i=0;
}// end of switch
}
else
{
// Double Blink to indicate error
switch(i)
{
case 0 : alive_led_on; i++; break;
case 1 : alive_led_off; i++; break;
case 2 : alive_led_on; i++; break;
case 3 : alive_led_off; i++; break;
case 4 : alive_led_off; i++; break;
case 5 : alive_led_off; i++; break;
case 6 : alive_led_off; i++; break;
case 7 : alive_led_off; i++; break;
case 8 : alive_led_off; i++; break;
case 9 : alive_led_off; i++; break;
default : i=0;
}// end of switch
}// end of if

}


my question is what is the best way of indicating single blink led
or double blink led that is not going to take lots of resources.


thanks

Andre

2007\06\29@130752 by Tamas Rudnai

face picon face
Hi,

You can make lots of optimizations on that ISR, so if variable i is not
going to be modified outside of that routine you do not really need to
change led status every case - if you do not change state too often then it
works perfect. Also you could make FAST directive and write your own context
saving, and use fast_io option otherwise AFAIK CCS tickles TRIS every time
you access to a port. Also I do not know what those led_on_off macros are
doing, what type is i etc. These things can change a lots of things in your
compiled code - it would worth to see your disassembly window or list file
to see what's going on.

BTW you can blink the led depending on one bit of your i and let it overflow
(you need only that bit) so let's say bit 5 makes slow blinkink bit 2 makes
it faster... You save a lot by not comparing values regarding variable i -
and also takes smaller place in your code.

But anyway, it should not affect the acquisition time nor conversion time
except if your led has a bad electric influence on your circuit. It could
tough happen that you take more time for acquisition if you do the delay
manually so that the loop interrupted so many times. Or can also change the
way you detect if the conversion has finished (there is a long interrupt
that prevents to detecting it strait away).

Tamas


On 6/28/07, Andre Abelian <.....aabelianKILLspamspam@spam@mason-electric.com> wrote:
{Quote hidden}

> -

More... (looser matching)
- Last day of these posts
- In 2007 , 2008 only
- Today
- New search...