Made a demo stopwatch circuit, using a pic16f884. Trying to use int osc for now. (will use an xstal in real one)
Circuit works perfectly, but only if I turn on the thing twice. Nothing happens if I turn it on "cold", but if I filck the power back off, then back on, all good, works great.
Clearly I'm doing something wrong with the startup. But I have the power time out set. Not sure what else I could be doing wrong.
Here are some snipets of the setup:
Anyone have any ideas of what i'm obviously missing?
Circuit works perfectly, but only if I turn on the thing twice. Nothing happens if I turn it on "cold", but if I filck the power back off, then back on, all good, works great.
Clearly I'm doing something wrong with the startup. But I have the power time out set. Not sure what else I could be doing wrong.
Here are some snipets of the setup:
Code:
__CONFIG _CONFIG1, _LVP_OFF & _FCMEN_ON & _IESO_OFF & _BOR_OFF & _CPD_OFF & _CP_OFF & _MCLRE_ON & _PWRTE_ON & _WDT_OFF & _INTRC_OSC_NOCLKOUT
__CONFIG _CONFIG2, _WRT_OFF & _BOR21V
Later after at the begining of the program
BANKSEL OSCCON ;bank2
MOVLW b'01100001' ;low frequency internal oscillator 1mhz
MOVWF OSCCON
BCF OPTION_REG, T0CS ;1=use tock pin (ie off), 0=use internatl timer ir on.
BCF OPTION_REG, 3 ;Assign prescalar to Timer0 = 0, to WDT = 1
BCF OPTION_REG, 2 ;set scalar 000 = 1:2 011 = 1:16 110 = 1:128
BCF OPTION_REG, 1 ; 001 = 1:4 100 = 1:32 111 = 1:256
BCF OPTION_REG, 0 ; 010 = 1:8 101 = 1:64 ;
BSF INTCON, T0IE ;enable Timer 0 interupts
BSF INTCON, GIE ;enable interupts globaly
Last edited by a moderator: