PIC16F877A Oscillator pin problem?

Thread Starter

lloydi12345

Joined Aug 15, 2010
103
I tried a simple flashing LEDs program on a breadboard and it worked well even if the two vcc and gnd aren't hooked together with the other vcc and gnd pin of the PIC.

Breadboard connections:
pin 1 - 10k ohms to Vcc
pin 13 & 14 - 4mhz xt osc
pin 32 - vcc
pin 31 - gnd

I already designed alot of PCBs and this is my first time to encounter this problem. Flashing LEDs on my newly designed PCB isn't working. What's strange is that, when I touch pin 13 of the PIC or even the copper path going to it makes the PIC work properly, but when I'm not touching it by my finger, the PIC wont make the LEDs flash.

PCB connections:
pin 1 - 10k ohms to Vcc
pin 13 & 14 - 4mhz xt osc
pin 32 - vcc
pin 31 - gnd

Can you help me?

I tried desoldering the 4mhz XT Osc from the PCB and made a touch of my finger on pin 13, the LEDs go flash.
 

t06afre

Joined May 11, 2009
5,934
Take a look at figure 14-1 in the data sheet. And solder in some caps from each crystal leg to ground. Place the cap as close to crystal as you can. It could also be a bad solder
 

Thread Starter

lloydi12345

Joined Aug 15, 2010
103
Take a look at figure 14-1 in the data sheet. And solder in some caps from each crystal leg to ground. Place the cap as close to crystal as you can. It could also be a bad solder
Erhm, I have 2 22pf Caps soldered already going to the ground and it is 1cm away from the XT crystal.
 

t06afre

Joined May 11, 2009
5,934
Erhm, I have 2 22pf Caps soldered already going to the ground and it is 1cm away from the XT crystal.
Erhm......I am not clairvoyant. And you did not mention any cap in your first post. So how could know anything about any caps then:confused:
Make it a habbit of posting ALL relevant information like schematics or code in your first post. Just a friendly tip:)
 

Thread Starter

lloydi12345

Joined Aug 15, 2010
103
:) Okay sir, but I'm still charging the cam's battery.. BTW, here is my source code

Rich (BB code):
    list        p=16f877A    ; list directive to define processor
    #include    <p16f877A.inc>    ; processor specific variable definitions
    
    __CONFIG _CP_OFF & _WDT_OFF & _BODEN_OFF & _PWRTE_ON & _XT_OSC & _WRT_OFF & _LVP_OFF & _CPD_OFF




CBLOCK 0x0C
    FIRST
    SECOND
    THIRD
ENDC


    ORG     0x000            
      goto    main              ; go to beginning of program

    ORG     0x004 
; isr code can go here 


main

BANKSEL TRISC
MOVLW 0x00
MOVWF TRISC
BANKSEL PORTC

FORWARD:
    MOVLW B'00000001'
    MOVWF PORTC
    CALL DELAY
    MOVLW B'00000000'
    MOVWF PORTC
    CALL DELAY
    GOTO FORWARD

    
    
DELAY                        ;    1 second delay
        MOVLW .10
        MOVWF THIRD
LOOP_1_SEC:
        MOVLW .250
        MOVWF SECOND
LOOP_125_MS:
        MOVLW .250
        MOVWF FIRST
LOOP_.5_MS:
        NOP
        DECFSZ    FIRST,F
        GOTO    LOOP_.5_MS
        
        DECFSZ     SECOND,F
        GOTO    LOOP_125_MS
        
        DECFSZ    THIRD,F
        GOTO    LOOP_1_SEC
        return

END
Do you see any problem here?

Is it on the hardware problem? because it works perfectly on the breadboard.
 

Thread Starter

lloydi12345

Joined Aug 15, 2010
103
Erhm......I am not clairvoyant. And you did not mention any cap in your first post. So how could know anything about any caps then:confused:
Make it a habbit of posting ALL relevant information like schematics or code in your first post. Just a friendly tip:)
oh, my bad, wait sir.. I'll look for my schematic
 

nerdegutta

Joined Dec 15, 2009
2,684
All this for just lighting 3 LEDs...? There's got to be more... I think this is a bit overkill for just 3 LEDs...

Am I the only one? What happend to K. I. S. S.
 

t06afre

Joined May 11, 2009
5,934
Are you connecting the LEDs directly to the output pin without a series resistor? That is a circuit design NO-NO. You may damage your PIC or the LEDs Use about 300 Ohm.
 

Thread Starter

lloydi12345

Joined Aug 15, 2010
103
LOL (I was expecting your reactions about the LEDs having no resistors :D). Anyway my PCB actually is about an obstacle detection. The LEDs will show if there are obstacles detected in front, left or right and then they will light. I already did this before but there was no LED and it worked. I was thinking that there would be less current coming from the PIC since 5v is also powering up my LM324 and also the next PCB which was not yet connected because I would like to try first my motors. But I didn't expected that even just by flashing one LED here will be a problem. I don't have anymore space for a resistor so perhaps I'll remove it? Or will it be okay if i'll not light them? :D

EDIT: Yes the LEDs are directly connected to the PIC
 
Last edited:

thatoneguy

Joined Feb 19, 2009
6,359
Do you have a dev board or breadboard to prototype before making a PCB?

If so, make sure the same code runs on the dev board (Such as EasyPIC6), before committing to etching a PCB.
 

t06afre

Joined May 11, 2009
5,934
. I was thinking that there would be less current coming from the PIC since 5v is also powering up my LM324 and also the next PCB which was not yet connected
Never assume then working with hardware design. Always check then in doubt. And check then not in doubt also Attention to details is very important. And your "less current coming from the PIC" theory is very wrong.
Could you also post a new picture(or replace) of the board solder side. The picture is very blurry
 

Thread Starter

lloydi12345

Joined Aug 15, 2010
103
Sorry for the blurry images.





I'm having problem with the PCB I made. (Vcc Pins 11 & 32 not connected together, Gnd Pins 12 & 31 not connected since I find them not helpful). I tried the same code for lighting the LED directly from the PIC and it works well on the breadboard even when the two Vcc and two Gnd are not hooked up together with their pairs.
 
Top