1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

XTAL Problem in PIC 16F877A

Discussion in 'Microcontrollers' started by Hesam Kamalan, Jul 16, 2006.

  1. Hesam Kamalan

    Hesam Kamalan New Member

    Joined:
    Oct 15, 2005
    Messages:
    130
    Likes:
    0
    Hi
    I have a problem with 16f877a. I build a PCB for this PIC component. After programming (for example I wrote blinking LED), LED is off, but when I touch XTAL, LED turned on continuously. I change XTAL several times but outcome was the same. My XTAL is 20MHz and Caps 33pF.
     
  2. rtamas

    rtamas New Member

    Joined:
    Jul 11, 2006
    Messages:
    2
    Likes:
    0
    That's why the XTAL's body must be soldered to GND and ofcourse the PCB's GND must be rastered.I think this method will solve your problem.
    P.S. You can use oscillators insted of XTAL.They are more stabile.
     
  3. mramos1

    mramos1 Active Member

    Joined:
    Sep 15, 2005
    Messages:
    2,403
    Likes:
    9
    Location:
    Boynton Beach, Florida USA
    Can you send the start of your code (where you define PIC, OSC, etc)?

    Do you have any 20pf caps? Maybe try swapping the 33 for something smaller.
     
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. zkt_PiratesDen

    zkt_PiratesDen New Member

    Joined:
    Jun 29, 2006
    Messages:
    68
    Likes:
    0

    Are you sure about this ?
     
  6. Hesam Kamalan

    Hesam Kamalan New Member

    Joined:
    Oct 15, 2005
    Messages:
    130
    Likes:
    0
    Thank you very much for your Helps and advertises, my code is written as follows:
    PROCESSOR 16F877A
    #INCLUDE "P16F877A.inc"
    #INCLUDE "HESAM.INC"

    __CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC

    CBLOCK 0X20
    HICNT
    LOCNT
    LOOPCNT
    ENDC

    ORG 0X00
    BANK3
    MOVLW 0X02
    MOVWF ADCON1
    BANK1
    MOVLW 0X00
    MOVWF TRISE
    BANK0
    MOVLW 0X00
    MOVWF PORTE

    MAIN:
    MOVLW 0X01
    MOVWF PORTE
    PAUSEMS 500
    MOVLW 0X02
    MOVWF PORTE
    PAUSEMS 500
    MOVLW 0X04
    MOVWF PORTE
    PAUSEMS 500

    GOTO MAIN

    END
     
  7. mister_e

    mister_e New Member

    Joined:
    Jul 14, 2006
    Messages:
    350
    Likes:
    2
    Location:
    Montreal, Canada
    1. you must use HS_OSC
    2. Be sure you connect all VSS lines and all VDD line
    3.as suggested, try something in between 15-33pF
    4. be sure your MCLR pin is tied to VDD via resistor
    5. Be sure you'd place capacitor (0.1uF) as close as possible of your PIC. For this one, i suggest 2, one on each side as you have VDD and VSS on both side of it.
     
  8. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,319
    Likes:
    653
    Location:
    Derbyshire, UK
    As suggested, use smaller capacitors, check my tutorial hardware at http://www.winpicprog.co.uk/pic_tutorial_main3_board.htm which uses 12pF ones. You don't mention how you're building it?, but you need as short a leads as possible, both to the crystal and from the capacitors to 0V.

    As also suggested, it's important that you select HS_OSC, which is for high speed crystals.
     
  9. Mike - K8LH

    Mike - K8LH Well-Known Member

    Joined:
    Jan 22, 2005
    Messages:
    3,642
    Likes:
    109
    Location:
    Michigan, USA
    Your problem may be that you have not disabled LVP in the configuration fuses and you have left the PGM pin 'floating'. I've seen these symptoms described many times and easily corrected by reprogramming the PIC with the LVP option in the config' fuses turned off.

    Regards, Mike
     
    Last edited: Jul 16, 2006

Share This Page