View previous topic :: View next topic |
Author |
Message |
meme
Joined: 29 Jun 2005 Posts: 13
|
the simplest task - not working |
Posted: Sun Jul 17, 2005 3:10 am |
|
|
Hello. I am trying to blink a led with a PIC16F877-A. the led is connected on pin D0 through a 3.6K resistor. I am using a 4MHz quartz oscillator and two 22pF capacitors
The mclr pin is connected like described in the datasheet: R1=6.6 K R2=3.3K and C1=1nF.
My program looks like this:
Code: |
#include "C:\Program Files\PICC\proiecte\led_pin_d0.h"
void main()
{
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_psp(PSP_DISABLED);
setup_spi(FALSE);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
disable_interrupts(GLOBAL);
while(1){
output_high(PIN_A0);
output_high(PIN_B0);
output_high(PIN_D0);
delay_ms(500);
output_low(PIN_A0);
output_low(PIN_B0);
output_low(PIN_D0);
delay_ms(200);
}
} |
the h file is this:
Code: |
#include <16F877A.h>
#device adc=8
#use delay(clock=4000000)
#fuses NOWDT,XT, NOPUT, NOPROTECT, NODEBUG, NOBROWNOUT, LVP, NOCPD, NOWRT |
The problem is that nothing happens. I put my oscilloscope on pinD0 and it is 0V - no oscillation. The same with A0 and B0 pins. I have 5V on the MCLR pin. The quartz is oscillating. And another thing: pin 14 (osc2) is oscillating according with the quartz (but around 5 V) and pin 13 (osc1) is not oscillating and stays in 0V. I really don't know where I am wrong ! It is my first PIC-based project. Thank you
P.S. I have connected pins 11-32-V+ togetger (VDD) and 12-33-V- (VSS). Is there something wrong ? |
|
|
meme
Joined: 29 Jun 2005 Posts: 13
|
|
Posted: Sun Jul 17, 2005 3:58 am |
|
|
I forgot to attach the schematics
Thank you |
|
|
Guest
|
|
Posted: Sun Jul 17, 2005 5:01 am |
|
|
Change the XT fuse to HS |
|
|
asmallri
Joined: 12 Aug 2004 Posts: 1635 Location: Perth, Australia
|
|
Posted: Sun Jul 17, 2005 8:36 am |
|
|
Unless you intended to enable LVP change the fuse to NOLVP. You cannot float this pin without problems. _________________ Regards, Andrew
http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!! |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Sun Jul 17, 2005 8:51 am |
|
|
Anonymous wrote: | Change the XT fuse to HS |
4Mhz should use the XT fuse
Definitely change LVP to NOLVP as asmallri stated.
Your value for the series resistor between the LED and micro is way to high. Given a source of 5V and a 2V drop for the LED that would be (5-2)/6600 = 0.45mA. You'll probably want atleast 5mA so try a 680ohm resistor in there. |
|
|
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Sun Jul 17, 2005 8:57 am |
|
|
1) Use the following configuration fuses:
#fuses NOWDT,XT, PUT, NOPROTECT, NODEBUG, NOBROWNOUT, NOLVP, NOCPD, NOWRT
2) Quote: |
The mclr pin is connected like described in the datasheet: R1=6.6 K R2=3.3K and C1=1nF.
|
The datasheet shows clearly that R2 must be between 100 Ohms to 1K.
Replace the R2 for a right value.
3) The 1N6265 is an infrared LED that support 100mA continuous forward current,
for testing purposes replace it for a regular visible LED.
4) Replace the 6.6K (6600 Ohms) resistor by 470 Ohms.
Keep well,
Humberto |
|
|
meme
Joined: 29 Jun 2005 Posts: 13
|
|
Posted: Mon Jul 18, 2005 11:41 am |
|
|
thank you so much ! IT REALLY WORKS ! thank you ! |
|
|
|