View previous topic :: View next topic |
Author |
Message |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Nov 05, 2010 4:58 pm |
|
|
Try this program. I tested it right now, with vs. 4.084. It worked.
It made the LED light up on pin B3. The oscilloscope shows a 50%
duty cycle squarewave, with a frequency of 244 Hz:
Code: |
#include <16F628A.h>
#fuses INTRC_IO, NOWDT, PUT, NOLVP
#use delay(clock=4000000)
//==========================
void main()
{
setup_timer_2(T2_DIV_BY_16, 255, 1);
setup_ccp1(CCP_PWM);
set_pwm1_duty(128);
while(1);
}
|
If this doesn't work, my suggestion is to re-install the CCS compiler.
If that doesn't help, then get a new PIC. Maybe try a different PIC,
such as a 16F877, or something else. |
|
|
buAliSina
Joined: 02 Nov 2010 Posts: 8
|
Worked |
Posted: Fri Nov 05, 2010 5:40 pm |
|
|
hi,
Worked ! but whats the dif ?
it was 50% DC ( and i'm not sure about freq )
plz tell me about freq ( i'm tired of calculating ! )
and the dif between our codes r just PUT as you see what do you think ? _________________ Just a dead body ignores Human suffering |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Nov 05, 2010 6:11 pm |
|
|
The reason I chose the lowest possible frequency for hardware PWM
(244 Hz with a 4 MHz crystal) for my latest example was that I began to
suspect that maybe your board or your equipment has a problem with
frequency response or measuring.
Maybe your oscilloscope doesn't work over 500 Hz ? |
|
|
|