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

18F452, PWM and TMR0 problem

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



Joined: 05 Apr 2006
Posts: 23

View user's profile Send private message

18F452, PWM and TMR0 problem
PostPosted: Wed Apr 05, 2006 8:19 pm     Reply with quote

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
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Apr 05, 2006 10:43 pm     Reply with quote

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



Joined: 05 Apr 2006
Posts: 23

View user's profile Send private message

PostPosted: Thu Apr 06, 2006 6:12 pm     Reply with quote

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