PIC12F629 flash led


Closed Thread
Results 1 to 14 of 14
  1. #1
    Join Date
    Nov 2013
    Posts
    3

    Default PIC12F629 flash led

    Hello all.

    I'm seeking help to put a simple led flashing on 12F629.

    I've try all kinds of configs and get always same result... nothing blinks.

    Anybody knows id 629 have any particularity thah i don't see?

    i'm using internal 4 mhz osc and 1k resistor on mclr and picall programmer.

    led on gpio.0

    Can anyone give some ideias?

    ps. i've read datasheet and manual...

    thanks
    Paul

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,604


    Did you find this post helpful? Yes | No

    Default Re: PIC12F629 flash led

    Hi,
    Post your code, complete with the CONFIG-settings you're using.

    /Henrik.

  3. #3
    Join Date
    Sep 2010
    Location
    Las Vegas, NV
    Posts
    305


    Did you find this post helpful? Yes | No

    Default Re: PIC12F629 flash led

    Probably oughta add a schematic also.

  4. #4
    Join Date
    Nov 2013
    Posts
    3


    Did you find this post helpful? Yes | No

    Default Re: PIC12F629 flash led

    Hello again.
    tks for your aswers!

    code follows:

    Define OSCCAL_1K 1
    DEFINE OSC 4

    CMCON = 7
    OPTION_REG.7= 0
    GPIO = %00000000
    TRISIO = %00000001


    Start:

    HIGH GPIO.0
    PAUSE 1000
    LOW GPIO.0
    PAUSE 1000

    GOTO Start
    END



    Quote Originally Posted by HenrikOlsson View Post
    Hi,
    Post your code, complete with the CONFIG-settings you're using.

    /Henrik.

  5. #5
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,154


    Did you find this post helpful? Yes | No

    Default Re: PIC12F629 flash led

    Shouldn't DEFINE be uppercase?

    Robert

  6. #6
    Join Date
    Jan 2011
    Location
    Sydney, Australia
    Posts
    172


    Did you find this post helpful? Yes | No

    Default Re: PIC12F629 flash led

    You have set GPIO.0 as an input with your TRISIO = %00000001 statement.

    Try using TRISIO = 0 instead and see how it goes.

    Also, I am not sure of your purpose for the OSCCAL statement. IMO, it shouldn't be necessary for such a simple LED flash program.

    Cheers
    Barry
    VK2XBP

  7. #7
    Join Date
    Feb 2012
    Location
    PERTH AUSTRALIA
    Posts
    838


    Did you find this post helpful? Yes | No

    Default Re: PIC12F629 flash led

    dont know if you fixed the input to an output as barry suggested but i think that the problem

    you can remove the pullup option as they are turn off anyway if outputs
    the calibration setting in osccal seems to be cleared during an erase on this chip
    so setting the register if you need to it adjust may be needed , but other wise id not worry if it just blink a led
    i would also recommend a more up to date IC such as 12F683 as the new designed chips have very similar instruction / register setups which make it easy to go to other new chips when learning a PIC

    hope it helps

    Cheers

    Sheldon

    Code:
    #CONFIG
      __config _INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_ON & _MCLRE_OFF & _CP_OFF 
     
    #ENDCONFIG
    
    OSCCAL = %100000                ' 4MhZ - Set calibration register to Center Freq - Note Erasing the device also clears the calibration value for internal osc
    
    CMCON        = 0               ' Comparators not used 
    TRISIO        = %00000000       ' set all GPIO as outputs  - Note Master clear pin GPIO is not used 
    OPTION_REG.7 = 0                 ' Set Week Pullups globle off    . Note when GPIO  SET AS output Week pullups  is automaticly turned off 
    
    
    DEFINE OSC 4            ' Timing reference for pause , pauseus commands 
    
    Start:
    
    toggle GPIO.0
    pause 1000         ' pause of 1sec 
    
    goto Start
    
    End

  8. #8
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,604


    Did you find this post helpful? Yes | No

    Default Re: PIC12F629 flash led

    Hi,

    I don't see any real issues with the original code which would prevent it from working.

    Yes, the TRIS-setting is indeed backwards and setting it correctly is always good practice but HIGH/LOW takes care of it for you so it shouldn't be a showstopper in this particular case.

    The situation with define/DEFINE/DefINe/defiNE has been covered many times by now. The actual keyword (DEFINE) is NOT case sensitive, what comes after the keyword IS and that looks alright to me although the OSCCAL shouldn't be needed AFAIK. So, not a problem with that either. Comparator (which has a Connection on GPIO.0) is turned off correctly so not an issue with that either. I can't see any real problem.

    My vote is on a hardware issue, perhaps your programmer doesn't release MCLR after programming - if you keep it attached that is.

    Which version of PBP are you using?

    /Henrik.

  9. #9
    Join Date
    Sep 2010
    Location
    Las Vegas, NV
    Posts
    305


    Did you find this post helpful? Yes | No

    Default Re: PIC12F629 flash led

    I have been schooled by the wizard and Henrik is correct on deFINE.

    I agree OSSCAL is unneccessary but you do need to set the ports to digital with the ANSEL = 0. You really don't need the OPTION_REG statement for just a simple program. TRISIO should just read TRISIO = 0 to set all pins, except GPIO.3 (pin 4), as outputs. HIGH/LOW will do that but it looks cleaner setting it in the TRISIO. At least IMHO.

    DEFINE OSC 4
    ANSEL=0
    CMCON = 7
    OPTION_REG.7= 0
    GPIO = 0
    TRISIO = 0
    Start:

    HIGH GPIO.0
    PAUSE 1000
    LOW GPIO.0
    PAUSE 1000

    GOTO Start
    END

    I would also submit you need a 300ish ohm resistor in series with the LED and not much higher. If you lack the resistor you can hook it directly up to the PIC as the PIC will protect itself and only source about 20ish mA. I don't remember exactly what the PIC will source or sink but you can find it in the datasheet. GPIO.0 is pin 7 on the 12F629 and should have the unmarked(Anode) end of the LED hooked to it with the marked end (Cathode) to ground/common/return or whatever you want to call it.

    Make sure pin 4 MCLR is tied to the voltage source, +5 VDC, with a 10kish resistor. If you're not hooked to +5VDC then you'll have to adjust the size of the resistor in series with the LED.

    It should work.

  10. #10
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,604


    Did you find this post helpful? Yes | No

    Default Re: PIC12F629 flash led

    Hi,
    The 12F629 doesn't have an ADC, there is no ANSEL register available.

    Since my last post I've breadboarded a 12F629 and tried Pauls code as posted, it works just fine. So I'm still leaning towards a hardware issue.

    /Henrik.

  11. #11
    Join Date
    Nov 2013
    Posts
    3


    Did you find this post helpful? Yes | No

    Default Re: PIC12F629 flash led

    Hello,

    Thanks all for your comments.

    i recheck hardware and all seems ok.

    i'm going crazy with this one. defective ic? its uncommon...

    Henrik: can post hex to see if any diference? do you use default settings file?

    thanks again,
    Paul

  12. #12
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,604


    Did you find this post helpful? Yes | No

    Default Re: PIC12F629 flash led

    Hi,
    Have you verified that MCLR is at Vcc?
    LED connected with correct polarity and verified to be working?
    Verified that the programmer and its application is working correctly, can you program other chips?

    Yes, I've compiled your code with the PBP default CONFIG, which I quote here for reference:
    Code:
    #CONFIG
      __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_ON & _CP_OFF
    #ENDCONFIG
    This is the code I compiled, using PBP 3.0.7.4
    Code:
    Define OSCCAL_1K 1
    DEFINE OSC 4
    
     CMCON = 7
     OPTION_REG.7= 0 
     GPIO = %00000000 
     TRISIO = %00000001
    
    Start:
    
     HIGH GPIO.0
     PAUSE 1000
     LOW GPIO.0
     PAUSE 1000
    
     GOTO Start
     END
    And here's the resulting hex
    Code:
    :020000040000FA
    :100000002828A301A200FF30A207031CA307031C9A
    :1000100023280330A100DF300F200328A101E83E90
    :10002000A000A109FC30031C1828A00703181528FC
    :10003000A0076400A10F152820181E28A01C222844
    :1000400000002228080083130313831264000800B1
    :10005000FF238316900083120730990083168113C3
    :1000600083128501831601308500831205148316DF
    :100070000510FA3083120120051083160510FA309E
    :0A0080008312012036286300432894
    :02400E00FC3F75
    :00000001FF
    Again, it works fine here. 10k pullup on MCLR, 1k5 in series with LED on GPIO.0

  13. #13
    Join Date
    Sep 2010
    Location
    Las Vegas, NV
    Posts
    305


    Did you find this post helpful? Yes | No

    Default Re: PIC12F629 flash led

    I guess you actually have to read the hyperscript numbers. Sorry for the inconenience.

  14. #14
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default Re: PIC12F629 flash led

    Quote Originally Posted by pmafer View Post
    Hello,

    Thanks all for your comments.

    i recheck hardware and all seems ok.

    i'm going crazy with this one. defective ic? its uncommon...


    Paul
    How OLD is your breadboard ? Those breadboards into which you just push the wires in corrode BIG TIME in just a couple of years especially if kept in a basement or garage. So verify your connections with an ohm meter, if it is not relatively new.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

Similar Threads

  1. Pic12f629-i/p
    By karenhornby in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 13th June 2008, 20:50
  2. I can't even make an LED flash!
    By George in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 3rd April 2007, 06:39
  3. Ultrasound with PIC12F629
    By ewandeur in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 28th February 2007, 16:22
  4. elapsed time between two led flash...
    By dario in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 5th February 2006, 16:09
  5. can't even flash an LED
    By bruno333 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 28th April 2005, 13:27

Members who have read this thread : 0

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