Can't get a 12F629 to blink a led


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2005
    Location
    Denmark
    Posts
    31

    Angry Can't get a 12F629 to blink a led

    Hi,

    What is wrong with this code, I know that is has to be very simple but I can not get it to work!

    @ DEVICE pic12F629, INTRC_OSC_NOCLKOUT ; System Clock Options
    @ DEVICE pic12F629, WDT_ON ; Watchdog Timer
    @ DEVICE pic12F629, PWRT_ON ; Power-On Timer
    @ DEVICE pic12F629, MCLR_OFF ; Master Clear Options (Internal)
    @ DEVICE pic12F629, BOD_OFF ; Brown-Out Detect
    @ DEVICE pic12F629, CPD_OFF ; Data Memory Code Protect
    @ DEVICE pic12F629, PROTECT_OFF

    DEFINE OSCCAL_1K 1' Set OSCCAL for 1k
    cmcon = 7 ' Comparator OFF

    loop:
    High GPIO.0 ' Turn on LED connected to PORT0
    Pause 500 ' Delay for .5 seconds

    Low GPIO.0 ' Turn off LED connected to PORTB.0
    Pause 500 ' Delay for .5 seconds

    GoTo loop ' Go back to loop and blink LED forever
    I have tried to download a hexfile for the 12F629 that blinks GPIO.0 and 1 that is working just fine, but when I try the above code it don't work.

    An the worst thing is that when i have tried to run the above code my PIC dies, in other words it is not possible to program it again

    Regards
    Sharky
    *Let's do it*

  2. #2
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Does the code that works include DEFINE OSCCAL_1K 1..?

    This define places a call to program location 03ffh. If your device programmer has erased this location, then using this define will cause a continuous loop.

    I.E. call 03ffh, wrap around back to 0, land on call 03ffh again, etc,,

    Location 03ff has a retlw xx instruction. xx is the factory oscillator calibration value returned by the retlw instruction.

    I read one of my 12F629's with my programmer. This is what's read from location 03ff.

    03ff- 3494

    34 is the retlw instruction. This should always be the same. 94 is the factory oscillator calibration value (for this particular 12F629) returned in w when call 03ffh is issued.

    If your programmer has erased this, you have a few options.

    1. Remove the DEFINE OSCCAL_1K 1, and use the default value that's already in osccal. That eliminates to continuous loop if the retlw xx at location 03ffh has been erased.

    2. Replace DEFINE OSCCAL_1K 1 with osccal = xx (xx is the value to load into the osccal register). You'll need to experiment to find the optimum value if you didn't read & record the value before programming/erasing your 12F629.

    3. Use the PBP pokecode command to replace the retlw xx at location 03ffh.
    Assuming 94h is the calibration value you find works best, then pokecode @$3ff, $94 would place retlw 94 at location 03ffh, and you could then use DEFINE OSCCAL_1K 1 again.

    Your code above works fine as-is on the 12F629 I programmed, but I have my programmer (meLabs serial programmer) setup to not erase or re-program the calibration value at 03ffh.

    I'm not sure what would cause it to not be re-programmable unless your programmer is over-riding config fuse settings in your .hex file and setting code protection. Then you have to erase the part before re-programming.

    What programmer are you using?

    Can you read the 12F629 to verify location 03ffh is blank or has the retlw xx?

    Can you erase the PIC?
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  3. #3
    Join Date
    Mar 2005
    Location
    Denmark
    Posts
    31


    Did you find this post helpful? Yes | No

    Post

    Hi Bruce,

    Right now I use the K8048 from Velleman. I like the programmer but I really don't like the software called ProgPic2.

    The code that works is a HEX file that I have downloaded from the web,
    just to check if the programmer and the PIC was working,
    so I don't know if it uses include DEFINE OSCCAL_1K.

    After I have tried to program my own code (the code shown in my previous post) It seems that the PIC dies totally. It's not possible to read it or erase it, the software just tell me that there is no device placed in the programmer.

    I will try to upgrade one of my home made JDM pic-programmers so it will have an 8-pin socket and then try to program the PIC with IC-Prog software.

    But I still just don't understand that the downloaded HEX file work perfectly, I can program it into the 12F629, erase the PIC and then program it again. It is first when I use my own program that the 12F629 dies.

    Thank U very much for your help

    Regards
    Gert
    Last edited by Sharky; - 26th June 2005 at 22:37.
    *Let's do it*

  4. #4
    Join Date
    Mar 2005
    Location
    Denmark
    Posts
    31


    Did you find this post helpful? Yes | No

    Thumbs up It's working now

    Now I solved the problems.

    The first thing was my JDM programming device, when I use:
    @ DEVICE pic12F629, INTRC_OSC_NOCLKOUT
    @ DEVICE pic12F629, MCLR_OFF
    It is not possible to program the PIC again with my JDM or Velleman programmer.

    I solved the problem by reading this: http://feng3.cool.ne.jp/en/vddctrl.html and by using a few components and a solderiron.

    And Bruce thanks for the OSCCAL learning, I have used your suggestions to get the pic up and running again.

    Thanks!

    Regards
    Gert
    *Let's do it*

Similar Threads

  1. Conway's Game Of Life
    By wellyboot in forum mel PIC BASIC Pro
    Replies: 45
    Last Post: - 28th May 2020, 06:14
  2. new and need help
    By smeghead in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 3rd November 2008, 20:19
  3. Novice 16F83A BLINK LED program help
    By owali in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 25th July 2007, 05:02
  4. LCD will not start
    By btaylor in forum mel PIC BASIC Pro
    Replies: 49
    Last Post: - 24th May 2007, 02:30
  5. Using HPWM to blink an LED?
    By Christopher4187 in forum General
    Replies: 8
    Last Post: - 7th August 2006, 00:48

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