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 <.....aabelianKILLspam
@spam@mason-electric.com> wrote:
{Quote hidden}>
> 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
>
> -