Reset PIC

Thread Starter

redtree

Joined Feb 3, 2014
14
I've got kind of a strange (I think) PIC programming issue.
I'm coding a PIC16F1933 in assembly and have a power-up issue.
When I build/program and reset my program things seem to work fine.
If I remove the circuits main power (and leave the ICD3 connected), things still work fine. It's only when I COMPLETELY remove the PIC power sources, then the program does not seem to do what its supposed to.

The steps seem to execute and the program is running, it just powers-up in the wrong state.

How could this be different from a reset/clear power up state?

How can reproduce this without the total removal of power?

Thanks!
 

Ian Rogers

Joined Dec 12, 2012
1,136
Most of these issues IMHO come from not initializing variables... Simulators and ICD's initialize variables to 0.... So check if some variable isn't starting where you need it.
 

ErnieM

Joined Apr 24, 2011
8,415
... It's only when I COMPLETELY remove the PIC power sources, then the program does not seem to do what its supposed to.

The steps seem to execute and the program is running, it just powers-up in the wrong state.
Are you running the debugger to see this? Uh-uh... that's a no-no. If you take power away you disturb the debugger state and generally need to reload the program.

If you're not in debug mode... we need more input.
 

Thread Starter

redtree

Joined Feb 3, 2014
14
I'm checking the variable initialization now; we'll see.

I'm running the program on the board independently (not in debug mode). But (until now) I've been leaving the ICD3 connected while running and testing and everything seemed happy. I only see and issue when I dis-connect the board power AND disconnect the ICD.
 

tshuck

Joined Oct 18, 2012
3,534
Could you post a schematic?

Most programmers pull the reset (MCLR) high, and removing the programmer without a pullup (when MCLR is enabled) will cause issues similar to what you describe.
 

Ian Rogers

Joined Dec 12, 2012
1,136
I'm checking the variable initialization now; we'll see.

I'm running the program on the board independently (not in debug mode). But (until now) I've been leaving the ICD3 connected while running and testing and everything seemed happy. I only see and issue when I dis-connect the board power AND disconnect the ICD.
Yeah! the reason I posted that was.. I have just done the exact same thing with a GLCD... The GLCD didn't initialize when stand alone.. but when I connected up to the debugger it ran fine... After assigning values to a couple of variables, it worked fine.....
 

Thread Starter

redtree

Joined Feb 3, 2014
14
thanks for the help.
Looks like it was the initialization thing.
I cleared EVERYTHING and it seems to work.

Live and learn!
 

Markd77

Joined Sep 7, 2009
2,806
I use the little loop that is in a lot of the datasheets to clear registers in almost all programs:
Rich (BB code):
	MOVLW 0x20					;clear files
	MOVWF FSR
NEXT
	CLRF INDF
	INCF FSR, F
	BTFSS FSR, 7
	GOTO NEXT
Obviously changing as required. Compared to the actual startup time of a PIC this is very quick.
 
Top