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

Funny problem with PWM

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








Funny problem with PWM
PostPosted: Wed Jun 01, 2005 5:52 am     Reply with quote

Hello,
I just finished settimg up my PWM for 38Khz.

chip used: PIC16F876A
Freq : 4Mhz

Code:

PWM_Setup()                                               //PWM setup function

{     
     setup_ccp1(CCP_PWM);                        // Configure CCP1 as a PWM
     setup_timer_2(T2_DIV_BY_1, 25, 1);
     set_pwm1_duty(13);
     
 }


void main()
{
   
   lcd_init();
   lcd_putc("\fPWM play\n");                                 
   PWM_setup();
   /*
         while(true)
      {
         printf("ping!\n");
      } */
         
}


A Hardware PWM is supposed to run in the background.
However the program seems to work only when the while loop is present.The PWM module shows no activity otherwise..
I have no idea why.

Regards
~ice
http://www.machinegrid.com
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Wed Jun 01, 2005 6:36 am     Reply with quote

Without the while loop, the program would fall off into nevernever land and eventually roll over and restart. For this reason, CCS inserts a sleep command at the end of main. The while loop keeps the pic running.
ice



Joined: 30 May 2005
Posts: 10
Location: India

View user's profile Send private message Visit poster's website

PostPosted: Thu Jun 02, 2005 10:26 pm     Reply with quote

Thanks Mark... : )
_________________
**ice**
Machinegrid.com :: Robots at Work!!
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