• AVR Freaks

Hot!16F84A LED 4MHZ One Second Delay Not Blinking

Author
The Loner
Super Member
  • Total Posts : 596
  • Reward points : 0
  • Joined: 2016/12/18 10:59:17
  • Location: 0
  • Status: offline
2020/12/01 13:50:27 (permalink)
0

16F84A LED 4MHZ One Second Delay Not Blinking

 
It lights up but does not blink.
 
Delay code is from 12F675. 4MHZ delay routine in PIC In Practice book.
 
Here is code.Anybody see what is causing the problem?
 

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

 __CONFIG _CP_OFF & _WDT_ON & _PWRTE_ON & _HS_OSC

;**********************************************************************

;EQUATES

ZEROBIT EQU 2 ;ZEROBIT is Bit 2.
COUNT EQU 0CH ;USER RAM LOCATION.
;TIME EQU 0DH ;TIME IS 39

;**********************************************************************

  ORG 0x000 ; processor reset vector
    goto START

;**********************************************************************

;SUBROUTINES

; 1/100 SECOND DELAY

DELAY CLRF TMR0 ;START TMR0
LOOPA MOVF TMR0,W ;READ TMR0 IN W
  SUBLW .39 ;TIME-W
  BTFSS STATUS,ZEROBIT ;CHECK TIME-W=0
  GOTO LOOPA
  RETLW 0 ;RETURN AFTER TMR0 = 39

; 1 SECOND DELAY

DELAY1 MOVLW .10
  MOVWF COUNT
TIMEC CALL DELAY
  DECFSZ COUNT
  GOTO TIMEC
  RETLW 0


;**********************************************************************

;CONFIGURATION

START BSF STATUS,5 ;Turns to Bank1.
  MOVLW b'00011111' ;5 bits of PORTA are I/P
  MOVWF TRISA
  MOVLW b'00000000'
  MOVWF TRISB ;PORTB is OUTPUT
  MOVLW b'00000111' ;Prescaler is /256
  MOVWF OPTION_REG ;TIMER is ? secs
  BCF STATUS,5 ;Return to Bank0
  CLRF PORTA ;Clears PortA
  CLRF PORTB ;Clears PortB
  CLRF COUNT
  
;**********************************************************************

;MAIN PROGRAM

BEGIN BSF PORTB,3 ;Turn ON B0.
  CALL DELAY1 ;Wait 1 second
  BCF PORTB,3 ;Turn OFF B0.
  CALL DELAY1 ;Wait 1 second
  GOTO BEGIN ;Repeat

  CALL DELAY1
   

  GOTO BEGIN

   END ; directive 'end of program'



 
 
 
 
 
 
 

 
 
 
 
 
#1

4 Replies Related Threads

    ric
    Super Member
    • Total Posts : 29459
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: 16F84A LED 4MHZ One Second Delay Not Blinking 2020/12/01 14:31:26 (permalink)
    +3 (7)
    How many times do you have to be told to NOT turn the WDT (Watchdog Timer) on?
    Change
     __CONFIG _CP_OFF & _WDT_ON & _PWRTE_ON & _HS_OSC
    to
     __CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _HS_OSC


     I am assuming you do have an external 4MHz crystal connected to your PIC.
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #2
    JTW
    Starting Member
    • Total Posts : 21
    • Reward points : 0
    • Joined: 2012/02/27 08:20:12
    • Location: Australia
    • Status: offline
    Re: 16F84A LED 4MHZ One Second Delay Not Blinking 2020/12/01 19:03:34 (permalink)
    +1 (1)
    Oops. Apologies. Wrong PIC chip replied to.
    post edited by JTW - 2020/12/01 19:07:10
    #3
    The Loner
    Super Member
    • Total Posts : 596
    • Reward points : 0
    • Joined: 2016/12/18 10:59:17
    • Location: 0
    • Status: offline
    Re: 16F84A LED 4MHZ One Second Delay Not Blinking 2020/12/02 09:29:11 (permalink)
    0
     
    Thanks Ric
     
    That did it.
    Yes.We are using board with 2 pin crystal socket and 22pf cap's soldered on.Right now 4MHZ crystal is in there.
     
    Thanks JTW
    I looked up that 20 address. That's for 'better' 16F84's. 16F818 and 16F628A.18 pin PIC's.
    Thought it sounded familiar.
    Book author says 818 is his favorite.Most of programs in book are for 16F84.He says it is most popular.
    2006 book.PIC in Practice.
     
    Thanks!

     
     
     
     
     
     
     

     
     
     
     
     
    #4
    ric
    Super Member
    • Total Posts : 29459
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: 16F84A LED 4MHZ One Second Delay Not Blinking 2020/12/02 13:58:52 (permalink)
    +3 (3)
    It would have been popular 14 years ago, but that's hardly relevant now.

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #5
    Jump to:
    © 2021 APG vNext Commercial Version 4.5