View previous topic :: View next topic |
Author |
Message |
jorsang2
Joined: 12 May 2011 Posts: 2
|
Help PWM in PIC16F684 |
Posted: Thu May 12, 2011 8:51 am |
|
|
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](images/smiles/icon_smile.gif) |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu May 12, 2011 1:23 pm |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
temtronic
Joined: 01 Jul 2010 Posts: 9177 Location: Greensville,Ontario
|
|
Posted: Thu May 12, 2011 2:53 pm |
|
|
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 !! |
|
![](templates/subSilver/images/spacer.gif) |
jorsang2
Joined: 12 May 2011 Posts: 2
|
|
Posted: Fri May 13, 2011 3:22 am |
|
|
CCS PCM C Compiler, Version 4.104, 5967 |
|
![](templates/subSilver/images/spacer.gif) |
|