1. redtree

    Thread Starter New Member

    Feb 3, 2014
    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?

  2. Ian Rogers


    Dec 12, 2012
    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.
  3. embpic


    May 29, 2013
    there may problem in hardware that is power supply post sch for more clear
  4. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    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.
  5. redtree

    Thread Starter New Member

    Feb 3, 2014
    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.
  6. tshuck

    Well-Known Member

    Oct 18, 2012
    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.
  7. Ian Rogers


    Dec 12, 2012
    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.....
  8. redtree

    Thread Starter New Member

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

    Live and learn!
    ErnieM likes this.
  9. Markd77

    Senior Member

    Sep 7, 2009
    I use the little loop that is in a lot of the datasheets to clear registers in almost all programs:
    Code ( (Unknown Language)):
    1.     MOVLW 0x20                  ;clear files
    2.     MOVWF FSR
    3. NEXT
    4.     CLRF INDF
    5.     INCF FSR, F
    6.     BTFSS FSR, 7
    7.     GOTO NEXT
    Obviously changing as required. Compared to the actual startup time of a PIC this is very quick.