Erratic PIC12F675 behavior


Closed Thread
Results 1 to 10 of 10
  1. #1
    russman613's Avatar
    russman613 Guest

    Default Erratic PIC12F675 behavior

    So, i am new to the whole PIC programming thing but think i have all the gear and set up to get going.

    i am sure i am missing something very small in the category of DFU.

    I am using the blinking led sample program from Melanie in this post: http://www.picbasic.co.uk/forum/show...ghlight=12f675

    here is the code:

    ' PIC Defines
    ' -----------
    @ DEVICE pic12F675, INTRC_OSC_NOCLKOUT
    ' System Clock Options (Internal)
    @ DEVICE pic12F675, WDT_ON
    ' Watchdog Timer
    @ DEVICE pic12F675, PWRT_ON
    ' Power-On Timer
    @ DEVICE pic12F675, MCLR_OFF
    ' Master Clear Options (Internal)
    @ DEVICE pic12F675, BOD_ON
    ' Brown-Out Detect

    '
    ' Initialise
    ' ----------
    TRISIO=%00001000
    CMCON=%00000111
    ANSEL=%00000000

    '
    ' Hardware Defines
    ' ----------------
    LED var GPIO.0

    '
    ' Program Body
    ' ------------
    Loop:
    Toggle LED
    Pause 500
    Goto Loop

    End


    My problem is that the starting of the led blinking is erratic. usually, when i first put it in my test circuit it blinks as expected. if i cycle the power it will not come back on . if i fiddle with it or leave it, sometimes it will work again. if i leave it alone, after a few minutes, the led will turn on and stay on. it seems to work the first time every time after i reprogram it. when it does blink, it does seem to blink blink at the right frequency.

    i am using the new melabs USB programmer, PicBasic Pro compiler 2.46 with MicroCode studio 2.3.0.0. Under compile and program options, i have Use MPASM unchecked.

    the test circuit has a .1uf bypass capacitor connected to pin 1 and pin 8. the led is connected to pin 7 (gpio.0) vdd is on pin 1 and vss is on pin 8. all other pins are not connected to anything. pretty simple. it is powered via a LM2940CT-5.0 with the manufacturer specified cpacitors on either side, plus some bulk capacitors (since i eventually want to run an hbridge off the unregulated side of the same power supply).

    Since my setup could not be any simpler, clearly I must be missing something. i have tried three different prototype breadboards.

    thoughts? Suggestions?? insults???

    thanks in advance.

    russ
    Last edited by russman613; - 24th February 2006 at 23:54.

  2. #2
    Join Date
    May 2004
    Location
    New England
    Posts
    164


    Did you find this post helpful? Yes | No

    Default

    Just curious - if you let the circuit sit for a long time - say 4 hours - with power shut off, does it then work properly again when power is re-applied?

    Arch

  3. #3
    russman613's Avatar
    russman613 Guest


    Did you find this post helpful? Yes | No

    Default

    It turns out that if i let the whole test circuit sit with the power off for about 10 minutes or so, it works fine. then, if i power it off right away, it does not blink but after about two minutes the LED comes on and stays on. then, if i power it off and let it sit for 10 min or so, it seems to blink per normal (for one power cycle).

    interesting test to suggest. what are you thinking may be my problem?

    russ
    Last edited by russman613; - 25th February 2006 at 02:19.

  4. #4
    russman613's Avatar
    russman613 Guest


    Did you find this post helpful? Yes | No

    Default

    Little more testing. it seems that if i let the unit sit for about 30 seconds, it will work.

    any thoughts anyone?

    thx in advance

    russ

  5. #5
    Join Date
    Nov 2004
    Location
    Saskatchewan Canada
    Posts
    189


    Did you find this post helpful? Yes | No

    Default

    I'm going to go out on a limb here with my limited knowledge, but I had similar problems while trying to learn this stuff.

    First was the MCLR pin not connected to the + side with a 4.7K resistor and not turned ON in the programmer. That really caused erratic operation like you descibed. My resistor had popped out of the breadboard and I hadn't noticed so I had it ON, but it wasn't there.

    Second is that I have read here a few times that all unused pins should be set to input and grounded via a resistor or they end up floating which can also cause problems.

    Since I'm still learning this too I may be completely off base, but your problems do sound a lot like mine.

    Bart

  6. #6
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    This is about as simple a piece of code as you can get.

    Check, when you programmed your PIC (do it again if need be) that your Config Fuse settings in your programmer matched those in the program. If you haven't programmed MCLR_OFF into the chip, that could be the problem, alternatively, look for bad hardware connections or bad PSU.

  7. #7
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Smile

    If the above suggestions have not fixed your problem ...

    I have observed this behavior before in my own circuits. My problem was the “added” capacitors for the power supply were not immediately fully discharging below the brown-out range when I turned off the power. If I waited 30 seconds or so, they did eventually leak and everything worked great. If I turned the power back on sooner, sometimes it worked and sometimes it did not. Try measuring the voltage across the power supply and seeing what happens when you turn the power off. If the voltage hangs on, you can add a bleed resistor to your power supply so you do not have to wait. This worked in my case. Good Luck.

    Paul Borgmeier
    Salt Lake City, Utah
    USA

  8. #8
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,614


    Did you find this post helpful? Yes | No

    Lightbulb Internal MCLR ... so good ???

    Hi, Russman

    I encountered such problems sometimes with different pics, last time it was with a ST 6265...
    the only way I found to have a strong trusty reset is an external MC 33064 or TC54VN43 ( µChip) to drive the MCLR pin.

    Like that, it works fine ... at each time.

    May be it's a supply problem ... I remember µChip tells about that in their datashheets, may be a reason !!!


    May be we could also think to a lost PC ... due to power up and bad reset.

    Something to try then could be to add an ASM GOTO pointing to the reset vector ( 00 ??) at the last available program memory location ( care to 3FF , sleep and goto sleep at the end of the HEX !!! ) ... as it was on the older 16C54 -58 i.e.



    add :

    ASM

    org 3FCh
    GOTO 0 ; ... or GOTO INIT

    ENDASM

    just before the PbP END

    Note 3FD and 3FE are occupied by PbP ( endless sleep ... smells the lost PC !!! ) and 3FF by the clock calibration value.

    Alain
    Last edited by Acetronics2; - 25th February 2006 at 14:09.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  9. #9
    Join Date
    May 2004
    Location
    New England
    Posts
    164


    Did you find this post helpful? Yes | No

    Default

    I was thinking along the lines of what Paul mentioned. Have had problems with that in the past - the reset circuit like Alain mentioned should fix it if that is the problem.

  10. #10
    russman613's Avatar
    russman613 Guest


    Did you find this post helpful? Yes | No

    Thumbs up

    Thanks for all the suggestions - it turns out that the bulk capacitors i had on the power supply were most likely the culpret.

    i manually put a bleed resistor on as suggested and voila - the problem vanished.

    i will spend the rest of the week understanding what Acetronics has suggested - sounds like some good stuff there if my understanding was a little more progressed

    i am now having a complely different problem, will post that next.

    thx for the suggestions all.

Similar Threads

  1. PIC12F675 problem with port 5
    By NL2TTL in forum mel PIC BASIC
    Replies: 2
    Last Post: - 5th June 2009, 01:23
  2. Replies: 8
    Last Post: - 7th December 2006, 15:42
  3. erratic behavior when using MPASM vs. PM
    By cool_justin in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 8th June 2006, 01:08
  4. Erratic LCD behavior
    By Travin77 in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 1st April 2006, 19:48
  5. PIC12F675 trouble
    By russman613 in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 27th February 2006, 18:40

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts