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

Help PWM in PIC16F684

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



Joined: 12 May 2011
Posts: 2

View user's profile Send private message

Help PWM in PIC16F684
PostPosted: Thu May 12, 2011 8:51 am     Reply with quote

Hi !
I have a problem with PIC16F684.
I would like to activate and see PWM in Proteus, but it doesn't work.

This is the code (partial code) :
Code:

#include <16F684.h>             
#device adc=10                 

#FUSES WDT                   
#FUSES HS                       
#FUSES NOCPD                   
#FUSES NOPROTECT               
#FUSES PUT                     
#FUSES BROWNOUT                 


#use delay(crystal=20000000)     

//=================================
void main()
{
   restart_wdt();
   set_timer0(1);       // poner el timer0 a 1
   
   setup_adc_ports(ALL_ANALOG);             
   setup_adc(ADC_CLOCK_DIV_2);               
   setup_timer_0(T0_EXT_L_TO_H|T0_DIV_1);                 
   setup_timer_1(T1_DISABLED);               
   setup_comparator(NC_NC);                   
    setup_wdt(WDT_2304MS);                   
   
   setup_timer_2(T2_DIV_BY_1,100,1); // Fpwm=50 kHz
   setup_ccp1(CCP_PWM);
   set_pwm1_duty(50);
   
   restart_wdt();
   set_timer0(1);       

for (;;)
{
      set_pwm1_duty(30);
         
      restart_wdt();
      set_timer0(1);
     
      delay_us(800);       
}
}

Please, could someone help me?
This code is now working (in proteus) in others PICs. I don't know why is not working with this PIC, I think maybe the fault is the simulator ...

Thanks in advance Smile
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu May 12, 2011 1:23 pm     Reply with quote

Always post your compiler version. Your version may have bugs.
If you post your version, then we (forum members) can look for
bugs in the ASM code.
temtronic



Joined: 01 Jul 2010
Posts: 9229
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu May 12, 2011 2:53 pm     Reply with quote

Proteus, like all other simulators, is FULL of bugs.....

Get real PICs,wire them up and test in the real world.

You'll be a LOT happier !!
jorsang2



Joined: 12 May 2011
Posts: 2

View user's profile Send private message

PostPosted: Fri May 13, 2011 3:22 am     Reply with quote

CCS PCM C Compiler, Version 4.104, 5967
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