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

same code but different pulse width

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








same code but different pulse width
PostPosted: Mon Sep 27, 2004 2:30 am     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Sep 27, 2004 7:38 am     Reply with quote

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







PostPosted: Mon Sep 27, 2004 9:13 am     Reply with quote

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.
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