Continue to Site

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.

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

Strange problem in PIC16F877A's

Status
Not open for further replies.

lloydi12345

Member
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?

EDIT: I tried desoldering the 4mhz XT Osc from the PCB and made a touch of my finger on pin 13, the LEDs go flash.
 
Last edited:
There are some crystals that you need to ground the case and what size of capacitor are you using with your crystal should be 20 to 30 pf

A lot of people for get the capacitors when they change to a pcb

In the breadboard most time you can get by with out them because the breadboard acts like a capacitor
 
Last edited:
Here's my code:

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

I tried connecting the Vcc and Gnd pins by a jumper.. But still wont work.. I'm using Olimex PIC Programmer Hardware and it works perfectly since it functions well on the breadboard.

The image below is the shot taken when the Vcc and Gnd pins are not yet hooked up to its pair.
 

Attachments

  • Image 1.JPG
    Image 1.JPG
    1.3 MB · Views: 264
  • Image 2.JPG
    Image 2.JPG
    1.6 MB · Views: 245
  • schematic.jpg
    schematic.jpg
    119.4 KB · Views: 292
Last edited:
I already have capacitors at the end of each XT Oscillator's pin. On my PCB I don't have 0.1uF cap hooked on Vcc and Gnd for my PIC. Will this help a lot if I'll drill this one and solder it?
 
Put a 104 from vdd to gnd and if that don't work clip a gnd on the crystal

I got hold of some crystals that wouldn't work if the case wasn't grounded

Your osc should be set to _HS_OSC
 
Last edited:
:D Oh, I've changed the code already.. Too bad I can't make the PCB work since the solder part now is messed up because of troubleshooting alot, so I'm abandoning my design and work for a new PCB design. Thanks though for the help really.
 
Last edited:
And don't forget the 0.1uF caps near as possible to the PIC power pins. Two would be nice, one on each side. You're also missing resistors on the LEDs. Your H-Bridge is missing clamp diodes (running motors I guess). A SN754410 would be an excellent choice IMO and can be speed controlled with the CCPx (PWM) outputs.
Added bonus use a 16F887 instead and you can skip the crystal. Or since you're programming in assembler take a peek at an 18F4620 or the like, none of that pesky bank switching and the 4620 is very pin similar to the 877A. Plus it's supported by Swordfish BASIC (really nice compiler with a free SE version)
 
Last edited:
And don't forget the 0.1uF caps near as possible to the PIC power pins. Two would be nice, one on each side. You're also missing resistors on the LEDs. Your H-Bridge is missing clamp diodes (running motors I guess). A SN754410 would be an excellent choice IMO and can be speed controlled with the CCPx (PWM) outputs.
Added bonus use a 16F887 instead and you can skip the crystal. Or since you're programming in assembler take a peek at an 18F4620 or the like, none of that pesky bank switching and the 4620 is very pin similar to the 877A. Plus it's supported by Swordfish BASIC (really nice compiler with a free SE version)

uhm, my bad on our place there's no SN754410. On my first design I didn't used protection diodes and it worked well. Then I made this second time and failed on the timing circuitry. So for the 3rd time can I still not use again any protection diodes on my Hbridge DC motor transistors. I've seen on many toys that there were no protection diodes on their PCB. I would like to know your opinion whether installing it or not.

EDIT: My motors are the DC motors of small toys, and I'll be using 4pcs. of 1.5v 2000ma batteries to power it..
 
Last edited:
Status
Not open for further replies.

Latest threads

Back
Top