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.

Problem pic

Status
Not open for further replies.

ElectroGeek_87

New Member
Ok i have a pic16f84a and a JDM style programmer. I programmed the code onto the chip, and it was verified. Now when I hook up the power and the oscillator and try to run the chip absolutely nothing happens. The chip is programmed to write a I to portA pin#1 and turn on an led. I am using a 5v 200ma power supply. I suspect the problem is the oscillator. I have a rc oscillator using a 100pf cap and a 2.5kohm resistor connected to the osc1 pin. (pin#16). I was sure to program the chip with the rc oscillator configuration selected, so that can not be the problem I HAVE tried using (3) 16f84a chips so far so the chips are not the problem. I will include the code below. Thanks for any help you may provide, I hope I have explained my predicament well enough.

bsf 03h, 5
movlw b'00100'
movwf 85h
bcf 03h, 5
movlw b'00100'
movwf 05h
end
 
Try this:

Code:
 bsf 03h, 5 
 movlw b'00000'  ; make all pins output
 movwf 85h 
 bcf 03h, 5 
 movlw b'00100' 
 movwf 05h
 
ElectroGeek_87 said:
Ok i have a pic16f84a and a JDM style programmer. I programmed the code onto the chip, and it was verified. Now when I hook up the power and the oscillator and try to run the chip absolutely nothing happens. The chip is programmed to write a I to portA pin#1 and turn on an led. I am using a 5v 200ma power supply. I suspect the problem is the oscillator. I have a rc oscillator using a 100pf cap and a 2.5kohm resistor connected to the osc1 pin. (pin#16). I was sure to program the chip with the rc oscillator configuration selected, so that can not be the problem I HAVE tried using (3) 16f84a chips so far so the chips are not the problem. I will include the code below. Thanks for any help you may provide, I hope I have explained my predicament well enough.

bsf 03h, 5
movlw b'00100'
movwf 85h
bcf 03h, 5
movlw b'00100'
movwf 05h
end

I suggest you use PORTB to perform this tests. Sometimes PORTA is a little tricky to get it working
 
also people use the include files, thats what they are for
its so simple to make a typo on an address like TRISB

but when you use the include files, a simple typo looks obvious, alough i do get pissed off with the warnings about banks.
 
For starters, get MPLAB IDE, it's free and it will immensely help. There you will be able to compile and test your code, use include files, debug and what not...

If you use the tool MPLAB and the includes, full code to turn the LED on would be:

Code:
     list p=16f84a           ; processor = 16f84a
     __config H'3FFF'       ; set osc to RC, and Watchdog timer on

include <p16f84a.inc>

    bsf STATUS, 5           ; switch to bank 1
    movlw b'00000'         ; put 00h into W register (low=output)
    movwf TRISA            ; value in W into register TRISA
    bcf STATUS, 5           ; switch back to bank 0
    movlw b'00100'         ; set the 04h to high in W register (for RA2)
    movwf PORTA           ; value in W into register PORTA
                                   ; the RA2 should indicate HIGH, LED on
    end

Perhaps as a side tool, you should have a logic probe, it helps to probe pins at times like these, just for the sake of a trial and error :)
 
Don't know if you got your problem fixed yet, but.....

Same problem happened to me.

I had forgotten to place a pull-up resistor on the MCLR pin, which is pin 1.
 
usaf1 said:
Don't know if you got your problem fixed yet, but.....

Same problem happened to me.

I had forgotten to place a pull-up resistor on the MCLR pin, which is pin 1.

Actually...(looked from the bottom), on the 16F84A pinout MCLR is pin 4.
You should really put it on HIGH (connected to VCC and filtered via 0.1uF to the ground)
Code:
                        +----------+
                    RB3 |9       10| RB4
                    RB2 |8       11| RB5
                    RB1 |7       12| RB6
                    RB0 |6       13| RB7
                    GND |5       14| VCC
                  !MCLR |4       15| CLKOUT
                    RA4 |3       16| CLKIN
                    RA3 |2       17| RA0
                    RA2 |1       18| RA1
                        +----------+
 
sorry for any confusion, I should've pointed out that I was meaning pin 1 on the 877.

But I have just used it with MCLR to VCC through a 10k res. Is there any real advantage of filtering with the cap?
 
Yes I did get my problem fixed but in a different way. Instead of using the f84a I switched to the f627, which has an internal oscillator. I did not connect the mclr pin to pin 14 but I can still get my code to work. I still do have some problems though I can turn the ports on and off, I can not get a delay loop to work. I will include the code below if someone could help me out. I ran the code in mplab and it worked perfectly. Sorry I did not include comments but its simple.



#include <p16f627.inc>



clrf porta
clrf portb
bsf status,rp0
clrf porta
clrf portb
bcf status,rp0
Start movlw 0x01
movwf porta
movwf portb
movlw b'1111111'
movwf 0x25
movwf 0x26
movwf 0x27
movwf 0x28

Count1 equ 0x25
Count2 equ 0x26
Delay1
Label1 decfsz Count1,1
goto Label1
Label2 decfsz Count2,1
goto Label2


movlw 0xff
movwf porta
movwf portb

Count3 equ 0x27
Count4 equ 0x28

Delay2
Label3 decfsz Count3,1
goto Label3
Label4 decfsz Count4,1
goto Label4
goto Start

end
 
usaf1 said:
sorry for any confusion, I should've pointed out that I was meaning pin 1 on the 877.

But I have just used it with MCLR to VCC through a 10k res. Is there any real advantage of filtering with the cap?
That cap is for decoupling, but I think a 100ohm resistor in series to MCLR would be a protection from high current that could fry the PIC.
 
ElectroGeek_87,

Here's my version of the code, see if that works out for you (MPLAB compiles it and tests it 100%)

Change the values of the loop size and repeat as necessary, I used 1 for repeat just during testing, didn't feel like waiting too long :)

Code:
#include <p16f627.inc> 

;;;;;;;;;;;;;;;;;;;
; Counter storage ;
;;;;;;;;;;;;;;;;;;;

Count1 equ 0x25 
Count2 equ 0x26

;;;;;;;;;;;;;;;;
; Main Program ;
;;;;;;;;;;;;;;;;

             clrf PORTA 
             clrf PORTB 
             bsf STATUS,RP0 
             clrf PORTA
             clrf PORTB 
             bcf STATUS,RP0 

Start
             movlw 0x01 
             movwf PORTA 
             movwf PORTB 
		
             call Delay 

             movlw 0xff
             movwf PORTA
             movwf PORTB

             call Delay

             goto Start 

;;;;;;;;;;;;;;;
; Delay loop;
;;;;;;;;;;;;;;;

Delay
             movlw 0xff       ; size of the loop (FFh)
             movwf Count1
             movlw 0x01       ; number of times to repeat the loop (01h)
             movwf Count2
Loop1        decfsz Count1,1  ; default loop
             goto Loop1       ; for the delay
             decfsz Count2,1  ; how many times
             goto Loop1       ; to repeat it
return
             
             end
 
I copied your code directly into mplab, assembled it, and programmed my chip. It didn't work though. Could it be that my program is not executing?
If a program a simple command to set the ports a and b high or low, that will work but not anything else. How can this be? I do not have the mclr pin connected to the vcc. What is this for?

Thanks for the help
 
I just copied the values for the ports from your code to mine, I'm not really sure what you are trying to accomplish so perhaps if you can elaborate on that ... though the port values did work in simulation.
Otherwise I'd get a Vcc hooked to !MCLR via a 100ohm or maybe a 1K resistor in series. I usually add a 0.1uF capacitor for decoupling to !MCLR, connected to the GND.
 
1111

holly crap, you people are too much, i just put both my VCC and MCLR to +5V, and 0v for VEE and everything is fine, I have no capacitors in my circcuits at all, and everything is Perfect....geeez
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top