PIC16F877A Oscillator pin problem?

Discussion in 'Embedded Systems and Microcontrollers' started by lloydi12345, Nov 2, 2010.

  1. lloydi12345

    Thread Starter Member

    Aug 15, 2010
    103
    0
    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.
     
  2. nerdegutta

    Moderator

    Dec 15, 2009
    2,515
    785
    Do you got a picture of this?
     
  3. lloydi12345

    Thread Starter Member

    Aug 15, 2010
    103
    0
    I don't have a cam right now sir. Maybe you can assume. Have you experienced this already?
     
  4. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    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
     
  5. lloydi12345

    Thread Starter Member

    Aug 15, 2010
    103
    0
    Erhm, I have 2 22pf Caps soldered already going to the ground and it is 1cm away from the XT crystal.
     
  6. nerdegutta

    Moderator

    Dec 15, 2009
    2,515
    785
    With a picture, we could have seen that right away. :)
     
  7. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    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:)
     
  8. lloydi12345

    Thread Starter Member

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

    Code ( (Unknown Language)):
    1.     list        p=16f877A    ; list directive to define processor
    2.     #include    <p16f877A.inc>    ; processor specific variable definitions
    3.    
    4.     __CONFIG _CP_OFF & _WDT_OFF & _BODEN_OFF & _PWRTE_ON & _XT_OSC & _WRT_OFF & _LVP_OFF & _CPD_OFF
    5.  
    6.  
    7.  
    8.  
    9. CBLOCK 0x0C
    10.     FIRST
    11.     SECOND
    12.     THIRD
    13. ENDC
    14.  
    15.  
    16.     ORG     0x000            
    17.       goto    main              ; go to beginning of program
    18.  
    19.     ORG     0x004
    20. ; isr code can go here
    21.  
    22.  
    23. main
    24.  
    25. BANKSEL TRISC
    26. MOVLW 0x00
    27. MOVWF TRISC
    28. BANKSEL PORTC
    29.  
    30. FORWARD:
    31.     MOVLW B'00000001'
    32.     MOVWF PORTC
    33.     CALL DELAY
    34.     MOVLW B'00000000'
    35.     MOVWF PORTC
    36.     CALL DELAY
    37.     GOTO FORWARD
    38.  
    39.    
    40.    
    41. DELAY                        ;    1 second delay
    42.         MOVLW .10
    43.         MOVWF THIRD
    44. LOOP_1_SEC:
    45.         MOVLW .250
    46.         MOVWF SECOND
    47. LOOP_125_MS:
    48.         MOVLW .250
    49.         MOVWF FIRST
    50. LOOP_.5_MS:
    51.         NOP
    52.         DECFSZ    FIRST,F
    53.         GOTO    LOOP_.5_MS
    54.        
    55.         DECFSZ     SECOND,F
    56.         GOTO    LOOP_125_MS
    57.        
    58.         DECFSZ    THIRD,F
    59.         GOTO    LOOP_1_SEC
    60.         return
    61.  
    62. END
    Do you see any problem here?

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

    Thread Starter Member

    Aug 15, 2010
    103
    0
    Here it is sir:

    [​IMG]

    [​IMG]
     
  10. lloydi12345

    Thread Starter Member

    Aug 15, 2010
    103
    0
    oh, my bad, wait sir.. I'll look for my schematic
     
  11. lloydi12345

    Thread Starter Member

    Aug 15, 2010
    103
    0
    And here is my schematic my friends.

    [​IMG]

    I'm just trying to light the LEDs but it wont light properly
     
  12. nerdegutta

    Moderator

    Dec 15, 2009
    2,515
    785
    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.
     
  13. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    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.
     
  14. lloydi12345

    Thread Starter Member

    Aug 15, 2010
    103
    0
    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: Nov 2, 2010
  15. nerdegutta

    Moderator

    Dec 15, 2009
    2,515
    785
    Remove what you don't use.
     
  16. lloydi12345

    Thread Starter Member

    Aug 15, 2010
    103
    0
    Uhm, Remove the what part? I'm using everything. Do you mean the LEDs?
     
  17. nerdegutta

    Moderator

    Dec 15, 2009
    2,515
    785
    Yes. I mean the LEDs.
     
  18. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    6,357
    718
    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.
     
  19. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    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
     
  20. lloydi12345

    Thread Starter Member

    Aug 15, 2010
    103
    0
    [​IMG][​IMG]Sorry for the blurry images.

    [​IMG]

    [​IMG]

    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.
     
Loading...