PICkit2 programming problem

Discussion in 'Embedded Systems and Microcontrollers' started by poriet, Mar 10, 2010.

  1. poriet

    Thread Starter New Member

    Feb 26, 2010
    22
    2
    Hi,
    I'm just learning to program PICs; I have the PICkit2.
    Rather than use the LPC demo board with its F690, I opted to use a 16F54 baseline chip ( I just had one handy ) for which I made a breakout board.
    However, all this is academic for, when you open MPLAB and select this PIC, it tells you that you cannot use the PICkit2 programmer. This is odd: the microchip website states that the F54 is supported; also the PICkit2 menu shows the F54.
    PIC chips, huh! One part inspiration, 10 parts bloody frustration.

    Bruce
     
  2. AlexR

    Well-Known Member

    Jan 16, 2008
    735
    54
    Yes I've noticed the same thing not that I have used any 16F5X chips so I'm not talking from experience.

    I don't know why MPLAB does not support 16F5X chips under pickit2 since the chips do support ICSP so in theory the pickit2 should be able to program them. One solution could be to use the pickit2 stand-alone GUI to program the chips. Its not as convenient as programming from the PMLAB IDE but it might get you around the problem.

    The other solution is to cut your losses, ditch the 16F5X chips you have and get something a bit more powerful. The 16F5X series are pretty terrible chips and as you get deeper into programming you will find their lack of interrupts, absents of any useful peripherals, and a mere 2 level stack depth very limiting.
     
  3. blueroomelectronics

    AAC Fanatic!

    Jul 22, 2007
    1,758
    98
    Since the 16F54 doesn't support debug...
    You can configure the PICKit2 software to automatically program on button or change of hex file. So after MPLAB creates the hex file the PICKit2 can program it.
     
  4. poriet

    Thread Starter New Member

    Feb 26, 2010
    22
    2
    Thank you guys. I know this is a crap chip, but I only want to get the feel of flashing a few LEDs and maybe a 7-seg display. I've gone to the trouble of making a breakout board, so....
    Blueroom...I fear I dont really understand what you mean. I write the program in MPLAB, then what? I open the PIC kit2 menu, click on 'write on PICkit button' and then press the button. Is that it?

    Bruce
     
  5. BMorse

    Senior Member

    Sep 26, 2009
    2,675
    234

    The Pickit2 comes with its own standalone program for programming a hex file to a pic, you do not have to use it as a programmer right in MPLAB.... compile your code in MPLAB, close MPLAB, open the Pickit2 app, load the hex you just compiled and program that into the pic....

    B. Morse
     
  6. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    Then using the Pickit 2 programmer you must select MCU. Else the Pickit 2 will not start programming. I checked and could not find any 16f5* device on my setup (ver 2.61) I think the using the programmer to go option is the best alternative, but I can not check it
     
    Last edited: Mar 10, 2010
  7. poriet

    Thread Starter New Member

    Feb 26, 2010
    22
    2
    Thanks; I'll give it a go. BTW, I'm using PICkit2 ver2.5 and the F54 is right there!
    Bruce
     
  8. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
  9. AlexR

    Well-Known Member

    Jan 16, 2008
    735
    54
    Probably you were looking in the wrong place. The PIC16F5X are classed as "Baseline" chips
     
  10. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    Yes you and BMorse are correct. And I am wrong. I have never used the the Pickit 2 software besides testing the programmer to go option once. So i should have done my homework much better before I gave a statement. I hope I did not cause any confusion for you Poriet
     
  11. blueroomelectronics

    AAC Fanatic!

    Jul 22, 2007
    1,758
    98
    The PK2 2.61 software has much to offer. A UART tool and 3 channel logic analyzer are really handy.
     
  12. poriet

    Thread Starter New Member

    Feb 26, 2010
    22
    2
    Hi,
    Good news and bad, really. I used the PICkit2 as a stand-alone and it was a cinch: I imported the HEX file, pressed the button and it came up with 'PIC programmed successfully'. BUT... I fail to understand this: the F54 requires a programming voltage of 12V. The MCLR checkbox to the right of the menu wont go above 5V.
    Of course, this would be academic if the chip worked, but it doesn't and it isnt necesarily the program. There is no internal oscillator. To save time, instead of fitting a crystal, I fitted a resistor and capacitor ( as per datasheet ). Oddly, the datasheet gives absolutely no guidance on what values to try. I used 1K with 1n hoping for around 1MHz. I got zip! I just hope this isnt a dud PIC!

    Bruce
     
  13. poriet

    Thread Starter New Member

    Feb 26, 2010
    22
    2
    Hello Blueroom: I only just saw your post. Thanks. As soon as I get this wretched chip just to say 'hello', I'll load ver 2.61. Onwards and upwards.
     
  14. AlexR

    Well-Known Member

    Jan 16, 2008
    735
    54
    All PICs use 12volt Vpp so I don't think that is your problem. In any case there is no way to change Vpp. You can set Vdd within certain limits but not Vpp. The only time Vpp is not 12 is when you use volt low voltage programming (LVP) but since neither PICkit2 nor the PIC16F5X chip series support LVP, its not going to be an issue.

    If you are not confident that the chip was programmed correctly do a verify, i.e. click the verify button on the PICkit2 GUI. That will tell you if the chip memory matches your hex file.
     
  15. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    A common mistake is to not set the configuration bits correct. Use this for more info
    http://forum.allaboutcircuits.com/showthread.php?p=206486 But read the section in your data sheet describing the settings for your chip
    Then programming your Pickit will supply the 12 volt needed. If you power your application from the Pickit 2 you must select on and set the correct voltage in that I think you name the MCLR checkbox. And the MCLR shall not be selected, unless you want to do a MCLR of course. The setting is for normal operation, and not programming
    Hope this will help
     
  16. blueroomelectronics

    AAC Fanatic!

    Jul 22, 2007
    1,758
    98
    The PICkit2 can generate 12V VPP with it's boost converter. It can go higher or lower as needed. Try the troubleshooting mode to see.
     
  17. poriet

    Thread Starter New Member

    Feb 26, 2010
    22
    2
    OK guys: I still have my suspicions about the oscillator, and, until I'm happy about that, I see no point in looking at the code/PICkit or whatever. You are supposed to be able to see the clock waveform on pin 15, but I cant see anything. I'll do it the hard way and fit a crystal.

    Bruce
     
  18. poriet

    Thread Starter New Member

    Feb 26, 2010
    22
    2
    Hello guys,
    If anyone remembers this thread, I have a follow-up: I programmed the PIC with the PICkit2 as a stand-alone, yet it failed to work. While it could have been a programming failure, I was suspicious that I could see no signal on CLKOUT. In a way this was fortuitous because I had never really learned about the Configuration word, so I had to spend a while reading up about it. I have to say thet the source of this info is supposed to be the Microchip F54 programming guide. In the entire article there is NO mention of the configuration word! Still, I got there in the end.
    It transpired that the default was the RC oscillator, which by sheer luck I had done ( I was going to use a crystal ). Yet still no clock signal. Infuriatingly, the datasheet gives absolutely NO guidance on the values to use. I mentioned that I tried 1K and 1n to achieve approx 1MHz. No-one picked upon that. Luckily, a book I have by Bob Penfold states that R must be greater than 3K. I changed the resistor and, lo and behold! Success.
    Isnt this fun? Now I have a LED light up, time to get it to blink.

    Bruce
     
  19. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    I can assure you that if any of us had know this, we would have mentioned it. The "problem" with Microchip is the wast number of MCUs. They are all somewhat different in specs. So you must know the actual chip. I have never used this chip as it is somewhat simple even for Microchip. I browsed through the data sheet but could not find anything about recommended values for the RC osc. I have used the 16f690 chip and for this chip Microchip recommend 3 kΩ ≤ REXT ≤ 100 kΩCEXT > 20 pF. But I could not know that this would apply to the 16f54 also ;). Also be very careful then assuming default values for the configuration bits. It is good programming practice to set or reset all the bits
     
  20. poriet

    Thread Starter New Member

    Feb 26, 2010
    22
    2
    Hello t06afre,
    I take your point, but it seems that this resitor limit applies to them all, although they havnt spelled it out in the datasheet for the F54, which is a bit naughty. It shows the value of having several different sources of info.
    One more thing: I did say that I was suspicious of the oscillator because I could not pick up any signal on the CLKOUT pin. I changed the resistor and, because it worked, didnt check the CLKOUT pin. Well, the clock is running, but there is still no signal on CLKOUT!
    In retrospect this is not a great choice of chip, but it was there. I've come this far, so I might as well persist with it while I learn the basics. It might well come in handy for a simple project.

    Bruce
     
Loading...