Programming a PIC 12F1822 Issues


Closed Thread
Results 1 to 16 of 16

Hybrid View

  1. #1
    Join Date
    Jul 2013
    Posts
    7

    Default Programming a PIC 12F1822 Issues

    HI,
    I have a PICKIT 2 programming a 18F1822. Compiling the program works, but the program won't load. The same setup works for the 12F683. Any ideas?

    Thanks

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


    Did you find this post helpful? Yes | No

    Default Re: Programming a PIC 12F1822 Issues

    Easy one here. I can't find a datasheet for an 18F1822. Correct number, code, schematic and what you've done in the attempt to correct issue might help us help you.

  3. #3
    Join Date
    Jul 2013
    Posts
    7


    Did you find this post helpful? Yes | No

    Default Re: Programming a PIC 12F1822 Issues

    Sorry about that. The part is right in one part of the post! It is a 12F1822.

    The code is below - I am just trying to get a blinking light at this point(code from this forum). Thanks for your kindness is responding. As far as a schematic, I have 5 Volts, Ground and a connection to an LED on Port A.1 through a 1K resistor.

    #CONFIG
    _CONFIG _CONFIG1, _CLKOUTEN_OFF & _FOSC_INTOSC & _WDTE_OFF & _PWRTE_ON & _MCLRE_OFF & _BOREN_ON & _IESO_OFF & _FCMEN_OFF
    _CONFIG _CONFIG2, _PLLEN_OFF & _LVP_OFF & _STVREN_ON & _BORV_19
    #ENDCONFIG
    PORTA = 0 ' LED Off
    TRISA = 0 ' all outputs
    OSCCON = %01101000 ' 4MHz internal
    ANSELA = 0 ' all digital

    Here:
    HIGH PORTA.1
    PAUSE 500
    LOW PORTA.1
    PAUSE 500
    GOTO Here

    END

  4. #4
    Join Date
    Dec 2012
    Location
    Tennessee
    Posts
    262


    Did you find this post helpful? Yes | No

    Default Re: Programming a PIC 12F1822 Issues

    Since your just testing this to begin with, I would leave out the oscon, let it run at whatever it wants. also swap location of the first tris and porta statement, and instead of using HIgh and Low, actually assign a value. see modified code below

    Code:
    #CONFIG
    _CONFIG _CONFIG1, _CLKOUTEN_OFF & _FOSC_INTOSC & _WDTE_OFF & _PWRTE_ON & _MCLRE_OFF & _BOREN_ON & _IESO_OFF & _FCMEN_OFF 
    _CONFIG _CONFIG2, _PLLEN_OFF & _LVP_OFF & _STVREN_ON & _BORV_19 
    #ENDCONFIG
    TRISA = 0 ' all outputs
    PORTA = 0 ' LED Off 
    ANSELA = 0 ' all digital 
    
    Here: 
    PORTA.1 = 1 
    PAUSE 500 
    PORTA.1 = 0
    PAUSE 500 
    GOTO Here 
    END
    Also you replace the HERE loop with this code

    Code:
    Here:
    Toggle PORTA.1
    Pause 500
    Goto Here:
    you might want to make sure your led is actually hooked to PIN PORTA.1 and not PORTA.0, I have made this mistake in coding many times.
    Chris


    Any man who has accomplished anything in electronics at one time or another has said... " STOP! WAIT! NOOO! Dangit.... Oh Well, Time to start over..."

  5. #5


    Did you find this post helpful? Yes | No

    Default Re: Programming a PIC 12F1822 Issues

    Are you using PBP3 and Microcode Studio version MCSX ?

  6. #6
    Join Date
    Jul 2013
    Posts
    7


    Did you find this post helpful? Yes | No

    Default Re: Programming a PIC 12F1822 Issues

    Yes I am using PBP3 Gold and MCSX. Thanks

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


    Did you find this post helpful? Yes | No

    Default Re: Programming a PIC 12F1822 Issues

    I see you're working this issue on the MELabs forum also. I think just about anything Darrel scribes is correct. In the last few years I've only seen him wrong once and that was only partially. Please post solution on both forums.

  8. #8


    Did you find this post helpful? Yes | No

    Default Re: Programming a PIC 12F1822 Issues

    Hi natcsparky,
    I tried your program using a breadboard circuit I had on hand with a 12F1822. After making corrections to the CONFIG lines as mentioned by AvionicsMaster, the program compiled OK with 60 program words. The hex file imported into MSCX with no problem, and the device programmed fine using ICSP.

    Do you have the PicKit2 device file containing 12F1822? I think you must if you are able to compile as you say.

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


    Did you find this post helpful? Yes | No

    Default Re: Programming a PIC 12F1822 Issues

    Not sure about the semi-colon after GOTO HERE though.

    Robert

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


    Did you find this post helpful? Yes | No

    Default Re: Programming a PIC 12F1822 Issues

    I also think you need to look at your CONFIG statement. PBP3 requires an indent and a double underscore to start the CONFIG statement and I don't think you can start a second line as you have done. Though if all you're trying to do is blink a light I'd leave all that stuff off and try it without.

    RA0 is also a comparator input. On the 12F683 you need to turn the comparators off with CMCON = 7 and I think you need to do that with the CMxCON1 register. RA0 is also an input for a few other things and you'd think you wouldn't need to turn them off but you just might. One of the inputs is the ICSPDAT and the diode may be stopping the program loading. Try removing it, programm it, reinstall the LED and see if it works.

    Also, if you didn't notice, wdmagic put the TRIS first and then the GPIO which I'm thinking is the preferred order. But they should come after the ANSEL, CMCON(if needed) and the OSCCON and DEFINE OSC settings.

    If you think you might have the LED connected to a different pin on PORTA turn the whole port on with PORTA = %11111111.

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


    Did you find this post helpful? Yes | No

    Default Re: Programming a PIC 12F1822 Issues

    Or maybe try another port just to get it blinking.

    Robert

  12. #12
    Join Date
    Jul 2013
    Posts
    7


    Did you find this post helpful? Yes | No

    Default Re: Programming a PIC 12F1822 Issues

    Thanks to all.

    I have been successful in compiling, but will try these suggestions. The programming part is what is not working. Based on some more research, it appears that my problem may be the PICKIT2 firmware I am using. I am upgrading now, and will try the stand alone to load in the HEX file. Again, thanks to all.

  13. #13
    Join Date
    Jul 2013
    Posts
    7


    Did you find this post helpful? Yes | No

    Default Re: Programming a PIC 12F1822 Issues

    I have the latest device file and installed it per instructions. Did you use a PICKIT2? Microchip said (on the phone) today that it won't work and I need a PICKIT3.

    Thanks

  14. #14


    Did you find this post helpful? Yes | No

    Default Re: Programming a PIC 12F1822 Issues

    Yes, I'm using a PicKit2 .... also tried it with a clone Pic programmer, (ICP01-V2.0) and it worked as well. I use the PicKit2 for other F1 family parts as well with no problems. Hex file attached. Note: extension must be changed back to .hex.

    Have you tried skipping around MCSX and loading directly to the PicKit2 Programmer software?

    test2.txt

  15. #15
    Join Date
    Jul 2013
    Posts
    7


    Did you find this post helpful? Yes | No

    Default Re: Programming a PIC 12F1822 Issues

    It works! I borrowed a PICKIT3 and it programs just fine. Thanks to all for your help.

  16. #16
    Join Date
    Jul 2013
    Posts
    7


    Did you find this post helpful? Yes | No

    Default Re: Programming a PIC 12F1822 Issues

    I tried the PICKIT2 GUI with the HEX file. Was not successful. Microchip says Pickit2 will not work, but I might try again. Thanks for the assistance.

Similar Threads

  1. 12F1822 troubles
    By Charlie in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 24th June 2012, 12:53
  2. Replies: 19
    Last Post: - 26th April 2012, 20:23
  3. MIBAM and 12F1822...
    By alesniak in forum mel PIC BASIC Pro
    Replies: 27
    Last Post: - 17th September 2011, 06:45
  4. Programming Issues
    By mitchf14 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 7th July 2009, 19:25
  5. New to PIC Programming
    By Keiou in forum General
    Replies: 3
    Last Post: - 29th October 2003, 19:13

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