View previous topic :: View next topic |
Author |
Message |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Nov 05, 2010 2:11 pm |
|
|
There may be a hardware problem with your PIC board, or your PIC.
Your programmer may not work.
Try the following simple program that blinks an LED on Pin B0.
Try to make this program work:
Code: |
#include <16F628A.h>
#fuses INTRC_IO, NOWDT, PUT, NOLVP
#use delay(clock=4000000)
//==========================
void main()
{
while(1)
{
output_high(PIN_B0);
delay_ms(500);
output_low(PIN_B0);
delay_ms(500);
}
} |
Here is a schematic that shows how the LED and series resistor should
be connected to the PIC:
Code: |
pin 330 ohms LED
B0 -----/\/\/\/------->|----
|
|
----- Ground
---
- |
|
|
|
buAliSina
Joined: 02 Nov 2010 Posts: 8
|
Weird |
Posted: Fri Nov 05, 2010 4:17 pm |
|
|
hi,
LED blinked with no error !!! (as i knew it ) ;
_________________ Just a dead body ignores Human suffering |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Nov 05, 2010 4:25 pm |
|
|
Change the program to use pin B3. This is the PWM output pin. See if
you can blink an LED on pin B3. Example:
Quote: |
#include <16F628A.h>
#fuses INTRC_IO, NOWDT, PUT, NOLVP
#use delay(clock=4000000)
//==========================
void main()
{
while(1)
{
output_high(PIN_B3);
delay_ms(500);
output_low(PIN_B3);
delay_ms(500);
}
} |
|
|
|
buAliSina
Joined: 02 Nov 2010 Posts: 8
|
<> |
Posted: Fri Nov 05, 2010 4:48 pm |
|
|
Blinked with no problem ; _________________ Just a dead body ignores Human suffering |
|
|
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 ? |
|
|
|