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

Timer1 interrupt is not serving first...

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



Joined: 19 Jul 2004
Posts: 33

View user's profile Send private message

Timer1 interrupt is not serving first...
PostPosted: Wed Sep 29, 2004 10:52 pm     Reply with quote

Hi...I am using 16F877 with 20MHz oscillator

I have a Timer1 interrupt which is generating 20mSec
pulse with 30% duty cycle.
And I have one buttun, and the code for identifying
button press is put inside the main()-->while() loop.

Now when ever I press the Mode Button for some seconds
then Timer1 generating one big pulse instead of the
20mSec pulse.

Even though the Timer1 is an interrupt, why it is not
generating the exact pulses.
The code is as below:
-----------------------------------------------------
signed int8 count1,DCOnDuty=30;

#INT_TIMER1
void timer1_isr() {

set_timer1(64536);

if(count1<=DCOnDuty)
output_high(PIN_D0);
else
output_low(PIN_D0);

count1++;

if(count1>=100)
count1=0;

}//timer1_isr


void UpButton()
{
// Some code for Up Button press.
//If we press this button for some seconds,it should
//not change the interrupt time for Timer1. But is it
//affecting it...why..???
}
void main() {

set_tris_d(0x00);
set_tris_b(0xFF);

while(TRUE)
{

if(!input(PIN_B1))
{
delay_ms(20);
UpButton();
}
}
}
-----------------------------------------------------

Thanks...any guidance appreciated....

Regards
Prashant
Haplo



Joined: 06 Sep 2003
Posts: 659
Location: Sydney, Australia

View user's profile Send private message

PostPosted: Wed Sep 29, 2004 11:21 pm     Reply with quote

You might need to post your full code as a few important questions can't be answered by looking at what you have posted. Such as

-How are you setting up the Timer and the interrupts?
-Is the button-checking code also interrupt driven?
-Does the button-checking code disable the interrupts by any chance?
-The variables count1 and DCOnDuty are globals. Is there any chance that they get modified by UpButton() ?
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