(Newbie) Problem in lighting a LED with PIC16F84A

Thread Starter

lloydi12345

Joined Aug 15, 2010
103
Hi, I have a problem on lighting my LED. My PIC's MCLR pin has no connections, VSS is connected to the ground, VDD is connected from my 7808's output which is 4.8v. My PIC's 18th pin (RA1) is connected to my 1k resistor and connected also on a LED in series. The LED's negative polarity is connected to the ground and also the 7808's middle pin is connected to the ground. The PIC's 15th and 16th pin is connected to my 4mhz crystal oscillator and every leg of the oscillator is connected on two 22pF capacitor. The end pin of the two capacitors are connected on the ground. My problem is even just a blink my LED wont light.

Here's is my source code:

Rich (BB code):
;**********************************************************************
;   This file is a basic code template for assembly code generation   *
;   on the PIC16F84A. This file contains the basic code               *
;   building blocks to build upon.                                    *  
;                                                                     *
;   Refer to the MPASM User's Guide for additional information on     *
;   features of the assembler (Document DS33014).                     *
;                                                                     *
;   Refer to the respective PIC data sheet for additional             *
;   information on the instruction set.                               *
;                                                                     *
;**********************************************************************
;                                                                     *
;    Filename:        xxx.asm                                           *
;    Date:                                                            *
;    File Version:                                                    *
;                                                                     *
;    Author:                                                          *
;    Company:                                                         *
;                                                                     * 
;                                                                     *
;**********************************************************************
;                                                                     *
;    Files Required: P16F84A.INC                                      *
;                                                                     *
;**********************************************************************
;                                                                     *
;    Notes:                                                           *
;                                                                     *
;**********************************************************************


    list      p=16F84A            ; list directive to define processor
    #include <p16F84A.inc>        ; processor specific variable definitions

    __CONFIG   _CP_OFF & _WDT_ON & _PWRTE_ON & _RC_OSC

; '__CONFIG' directive is used to embed configuration data within .asm file.
; The lables following the directive are located in the respective .inc file.
; See respective data sheet for additional information on configuration word.




;***** VARIABLE DEFINITIONS
w_temp        EQU     0x0C        ; variable used for context saving 
status_temp   EQU     0x0D        ; variable used for context saving








;**********************************************************************
        ORG     0x000             ; processor reset vector
          goto    main              ; go to beginning of program


        ORG     0x004             ; interrupt vector location
        movwf   w_temp            ; save off current W register contents
        movf    STATUS,w          ; move status register into W register
        movwf    status_temp       ; save off contents of STATUS register


; isr code can go here or be located as a call subroutine elsewhere


        movf    status_temp,w     ; retrieve copy of STATUS register
        movwf    STATUS            ; restore pre-isr STATUS register contents
        swapf   w_temp,f
        swapf   w_temp,w          ; restore pre-isr W register contents
        retfie                    ; return from interrupt



main

; remaining code goes here

BSF STATUS, RP0
MOVLW 0X00
MOVWF PORTA

BCF STATUS, RP0
MOVLW 0X00
MOVWF PORTA

AGAIN

MOVLW 0XFF
MOVWF PORTA
MOVLW 0X00
MOVWF PORTA

GOTO AGAIN









        END                     ; directive 'end of program'
The compilation of the program is success and also programming the PIC from PICPgm Programmer is a success. Still the LED wont light. I hope you can help me. Thank you.
 
Last edited:

beenthere

Joined Apr 20, 2004
15,819
My PIC's MCLR pin has no connections,
Most often, a logic input pin left floating will tend to cause oscillations. It should be connected to ground or Vcc through a resistor so the state is established.

my 7808's output which is 4.8v.
Is this a miskey? A 7808 regulator should output close to 8 VDC. It will require an input about 2 volts larger in order to function properly. But 8 volts is well above the maximum allowable voltage for your PIC. That regulator really has to be a 7805.

How is the PIC mounted? If it is on a breadboard, the chances of proper operation are close to zero. There is just too much stray capacitance for one to function like that.
 

tom66

Joined May 9, 2009
2,595
Remember to include the capacitors around the voltage regulator, or you will get an unreliable regulator which will sometimes produce a low output voltage (100n capacitor on the input and 1µF capacitor on the output.)

If you have been running your PICs at 8V, you have probably damaged them. They usually require 2.0V to 5.5V.
 

debjit625

Joined Apr 17, 2010
790
Most PIC range works with 5VDC and as per datasheet 16F84a can have max 7.5 VDC so you applied 8VDC which may have damaged the mcu but the main problem is the power on reset ,connect the MCLR pin with a 10K resistor to positive rail and provide a regulated power of 5VDC ..
Connecting the MCLR pin to ground will cause reset.

Good Luck
 

Thread Starter

lloydi12345

Joined Aug 15, 2010
103
thanks for the reply, oh sorry,it was a mistake.. It was really 7805 which outputs 5v.. I also connected the tester not properly, now it outputs 5v. I tried connecting the mclr pin from 5v output of the regulator through a 10k resistor but nothing happens. The LED still wont light :(

I also changed my first line having PORTA:

Rich (BB code):
MOVLW 0x00
MOVWF TRISA
 

tom66

Joined May 9, 2009
2,595
Instead of manipulating the bank bits use the banksel macro.

Here is a program which should light an LED; the LED should never switch off.

Rich (BB code):
banksel TRISA
movlw   0xff
movwf   TRISA
banksel PORTA
movwf   PORTA       ; W = 0xff
goto    $
Try this instead of getting it to blink.
 

Markd77

Joined Sep 7, 2009
2,806
In the config change to _WDT_OFF and _HS_OSC.
The led will not look as though it is flashing as it will be over 100000Hz.
 

Thread Starter

lloydi12345

Joined Aug 15, 2010
103
Instead of manipulating the bank bits use the banksel macro.

Here is a program which should light an LED; the LED should never switch off.

Rich (BB code):
banksel TRISA
movlw   0xff
movwf   TRISA
banksel PORTA
movwf   PORTA       ; W = 0xff
goto    $
Try this instead of getting it to blink.
sir I can't make this work on Proteus ISIS
 

tom66

Joined May 9, 2009
2,595
That is good. Is the LED lit? If you have a scope, double check that the chip is not resetting (and the LED going off), and you should be all good to go.
 
Top