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

18f6525 timer3 interrupt problem

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







18f6525 timer3 interrupt problem
PostPosted: Wed Feb 01, 2006 2:31 pm     Reply with quote

Using PCH v 3.230.

Code below.

Explanation: Timer 2 provides the period (1Khz)for the software PWM. I need two seperate duty cycles. Timer 4 provides one and timer 3 provides the other one. Timer 4 is adjustable (30-99% of 1Khz) depending on a setting, this part works flawlessly. My problem is with timer 3, I'm wanting a fixed 50% duty cylce of the 1Khz. Using the o-scope on a pin it works "most of the time", but a lot of the time it is a 2% duty cylce instead of the set 50%.

I'm not using either compare or capture, what else could cause the timer1 to interrupt before it rolls over?

void timer2_int(void)
{
set_timer4(0);
PIR3 &= 0xF7; // clear interrupt for Timer
enable_interrupts(int_timer4);

if(PWM_dutyflag)
output_high(regulator);
else
output_low(regulator);

//PMW for dump valve
output_high(SOLSTART);
set_timer3(64900);
enable_interrupts(int_timer3);
}

#int_timer4
void timer4_int(void)
{
disable_interrupts(int_timer4);
output_low(regulator);
}

#INT_TIMER3
void timer3_int(void)
{
disable_interrupts(int_timer3);
if(!(input(compsw)))
output_low(SOLSTART);
}

Thanks for the time.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Feb 01, 2006 3:03 pm     Reply with quote

Quote:
I'm not using either compare or capture, what else could cause the timer1 to interrupt before it rolls over?

In your post you refer to Timers 2, 3, and 4, and you have code for
them, but then in your question you ask about Timer 1.
Can you explain this ?
jg
Guest







PostPosted: Wed Feb 01, 2006 3:18 pm     Reply with quote

timer1 was a typo, should read timer3
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Feb 01, 2006 4:10 pm     Reply with quote

I noticed two things:

1. You clear the interrupt flag for Timer4 before you enable it,
but you don't do this for Timer3.

2. You read a switch inside the Timer3 isr. Switches can bounce.
jg
Guest







PostPosted: Wed Feb 01, 2006 4:21 pm     Reply with quote

not a switch, but either way wouldn't cause what I am seeing.

I'll try clearing timer 3.

Thanks for the time.
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