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.

Power needs to be switched on twice

Status
Not open for further replies.

jstcd

New Member
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:
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
Anyone have any ideas of what i'm obviously missing?
 
Last edited by a moderator:
Hi jstcd,
First welcome to the forum :) Now it would be helpful if you can provide the full code and also a schematic of your circuit. You will notice your first post the code is now in the code format, when your making your reply with your code in the editor is the '#' option which is wrap
Code:
 tags around selected text. 

Regards Bryan
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top