View previous topic :: View next topic |
Author |
Message |
Guest
|
same code but different pulse width |
Posted: Mon Sep 27, 2004 2:30 am |
|
|
Hi...
I have used 16F877 in our projectusing 20MHz Oscillator.
And now we have only one interrupt on Timer1.
I have set the Timer1 to overflow every 0.2mSec. If I run
this code saperately, it is giving correct pulse width and
Duty Cycle. But if I use it in our project which has long
code. It is giving different pulse width. And all the pulses
are not of the same pulse width or Duty Cycle. The code inside
the interrupt is simple.
I don't know why this is happen. But think it is due to long
code. As my RAM and ROM are about to fill and I have long
code in side the main(),while loop.
Can this be reason for incorrect Pulse Width..??
I can't understand, why interrupt is not happen at proper time
when it is having long code. while the same code is giving
correct pulse width in one simple program.
If Timer is incremented every instruction cycle, why is it not
same for same oscillator and circuit.
Thanks...Any help appriciated...
Regards
Prashant |
|
|
Neutone
Joined: 08 Sep 2003 Posts: 839 Location: Houston
|
|
Posted: Mon Sep 27, 2004 7:38 am |
|
|
My guess would be that you are using some code that disables interupts when it runs. That could give you a random amount of extra pulse time. |
|
|
valemike Guest
|
|
Posted: Mon Sep 27, 2004 9:13 am |
|
|
In addition to what Neutone mentioned (you're probably disabling interrupts somewhere), I also wonder where are the instructions to toggle the pin high and low?
If you are toggling these in the Timer1 ISR, then the only thing that causes random delay would be other ISRs and disabled interrupts in the main code.
It is also possible that you are toggling the pin outside of the timer1 ISR, and just setting some flag in the Timer1 ISR to which you react to later on outside the ISR. |
|
|
|