![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
jimcbride
Joined: 05 Apr 2006 Posts: 23
|
18F452, PWM and TMR0 problem |
Posted: Wed Apr 05, 2006 8:19 pm |
|
|
Greetings,
I have some code that uses the TMR0 interrupt for a timing loop set to 50ms. I also use both hardware PWM units. Before entering main, PWMs are set to 500. OK there. The interrupt occurs 8 times and then performs some calculations. (8 times gives me 50ms) Anyway with the TMR0 interrupt disabled, the PWM gets set to 500 and stays there. When TMR0 is enabled, on the second time through, upon exiting the routine, both PWM signals get turned off. I have no idea why this is happening. I had very similar code running on a 16F877 with no problems.
Any ideas?
JIMc |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Apr 05, 2006 10:43 pm |
|
|
Quote: |
When TMR0 is enabled, on the second time through, upon exiting
the routine, both PWM signals get turned off. |
Post a test program. Limit the program to setting up Timer0,
setting up the PWM, and also the Timer0 isr. Show the #use,
#fuses, and #include statements. Don't post any code that is likely
to be irrelevant to the problem such as A/D setup code, etc.
Just post Timer0 and PWM code. Then test the shortened program
to verify that it shows the problem and post it.
Also post your compiler version. |
|
![](templates/subSilver/images/spacer.gif) |
jimcbride
Joined: 05 Apr 2006 Posts: 23
|
|
Posted: Thu Apr 06, 2006 6:12 pm |
|
|
Thanks, good advice. This is exaclty what I did after writing my post. And of course it worked fine so the problem was in my "large" code. I did fix it, although I am not entirely sure how. I just started stepping through it and commenting out the problem areas. At one point I noticed something odd that made no sence or had any use. I suspect the problem was an int declaration in the main( ) before the setup declarations. I have no idea why it was there. I have not looked at this code in over a year so who knows? Thanks for the help. |
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|