Fighting a 12F675...

Discussion in 'Embedded Systems and Microcontrollers' started by Dodgy Geezer, Nov 30, 2009.

  1. Dodgy Geezer

    Thread Starter Member

    Nov 30, 2009
    10
    0
    I have been able to cut some simple code for a PIC, though I am still a rank beginner.

    From another forum I was provided with some hex for a project which I needed to write to a 12F675. I have a Vellerman 8048 programmer; I was using the Vellerman ProgPic2 code, and worked out that I needed to 'load' the hex file and then write it. XP is the OS.

    My first attempts didn't work - incompatible serial port, and I'm not sure that I copied the hex correctly - but then I found an old laptop that seemed to recognise the programmer. I think I wrote the hex to a pic, but when I tried to read that pic the programmer board would not recognise that there was a pic onboard. I could recognise an unwritten pic in my programmer, but whatever I had done to the first one seemed to have left it uncontactable.

    I think I was able to erase it using WinPIC, but this didn't get it recognised again. Have I ruined it somehow, or can someone suggest a way to talk to it again?
     
  2. markosillypig

    Active Member

    Jul 21, 2008
    184
    0
    hi
    i use this free program to program the chips
    http://members.aon.at/electronics/pic/picpgm/
    some times i find it does not find the chip so i take it out and do a dummy run and put the chip back in and hey presto it programs it
    try it for free you cant hurt it
    where did you get the hex file from??
     
  3. Dodgy Geezer

    Thread Starter Member

    Nov 30, 2009
    10
    0
    Hex file is from here: http://www.giantcod.co.uk/forum/viewtopic.php?f=15&t=3050

    Interesting project! I have done a bit of research, and found some people saying that the Velleman 8048 programmer has a bit of a bug, and won't recognise or erase Pic 12F675s if they are coded with a program that holds one output high.. Unfortunately, that data was hard to find - I bookmarked it meaning to study it at length, and then my system went down and I lost the reference - haven't found it again yet...
     
  4. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    I think the K8048 unit is not the the best PIC tool. The PICKIT 2 and 3 are much better and more flexible
     
  5. Dodgy Geezer

    Thread Starter Member

    Nov 30, 2009
    10
    0
    Unfortunately, I am working with an 8048!

    I know the 8048 works - I have written pics with it in the past, but I have never tried to take a hex file and write that. I am having all sorts of basic problems - for instance, the hex is given in lines of 24bytes, each starting with a : Look at the reference to see what I mean.

    Now, do I just copy/paste this to a notepad file and give it a .hex extension? I assumed not, and took all the colons out, as well as the line throws. Then I saved it as an ANSI file with a .hex extension, and tried to load it - progpic2 said it was the wrong file format.

    I tried saving in a variety of formats, and found one that the programmer would accept, but then it complained there was no eof! There does not seem to be any simple tutorial on the web about using hex - all beginner stuff assumes you are writing your own code...
     
  6. eblc1388

    Senior Member

    Nov 28, 2008
    1,542
    102
    The HEX code you tried to load to the PIC had enabled the PIC internal oscillator, as mentioned in the notes by the author.

    What you have done is enabled the PIC internal oscillator so as soon as the PIC is powered up(even inside your Velleman programmer), it will start to execute the code inside and so will not enter program mode. Therefore the programmer cannot contact the PIC again.

    Some other programmers can still contact the PIC under this situation but I doubt if the Velleman can.

    Any Velleman user can confirm?
     
  7. blueroomelectronics

    AAC Fanatic!

    Jul 22, 2007
    1,758
    98
    Your 8048 does not support VPP before VDD so it cannot reprogram a PIC with MCLR set as an input pin.
     
    Last edited: Dec 2, 2009
  8. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    I'd assume that you should just rename the file .hex
    This is a bit of a .HEX file straight from MPLAB:
    :020000040000FA
    :020000002D28A9
    :040002000034003492
    :08000800A900030EAA00240860
    :100010002202031D102823082102031D10280515A4
    :100020002308031D1B282403031D1B282108A300EC
    :100030002208A40022280130A40203182228230346

    On a side note, I just got some 12F675s and plan to use them with the internal oscillator. Can the PICKIT2 reprogram them once they are programmed that way? I use a ZIF for programming because I'm paranoid about letting the smoke out of the PICKIT2 if I connect something up wrong using ICP.
     
  9. Dodgy Geezer

    Thread Starter Member

    Nov 30, 2009
    10
    0
    Well, I didn't find the 8048 bug discussion, but I recalled enough of it to remember that some people suggested holding the base of one transistor (T4) low by shorting out a diode (D7).This seemed to work - the pic was recognisable again. Some people have soldered a line in to do this at will, or added a little resistor/capacitor pair to enable VPP before VDD...

    Anyway - I wrote something to the pic which looks like the original hex. I had woried that I might have overwritten the internal oscillator calibration - indeed, perhaps I have. Is there any way I can check this easily?
     
  10. Dodgy Geezer

    Thread Starter Member

    Nov 30, 2009
    10
    0
    Thanks, Markd77 - your illustration does look exactly like the file I had. I renamed it as you said, and the file wrote and validated fine. I think I ran into this 'no VPP before VDD' issue (which BlueRoomElectronics accurately said the 8048 did not support), but which can be got round by temporarily jumping out D7.

    I can't test the code until the muxes arrive, but I did try running a little flashing led prog using the internal oscillator, and it ran - so I presume my calibration is still ok... Panic over....
     
  11. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    6,357
    718
    The PicKit 2 is amazingly robust if you stay within the recommended voltage ranges, and use the recommended ICSP layout.

    Itcan also read and set the calibration value in PICs, and there are some programs around which work with the PicKit 2 that will re-calculate the cal value if it is lost.

    Due to the extra features, such as "load and go" (program without a computer), logic probe + serial debugger (connected to a computer), the PicKit 2 is an awesome value for the money!
     
  12. vane

    Active Member

    Feb 28, 2007
    181
    0
    I think i have had the same problem can you just talk me through how to do it? i tried shorting out D7 but did nothing, maybe i did it wrong...

    I couldn't bring myself to throw these chips away, there must be something i can do :s I better not have rendered 2 out of 4 of my 675s crap :(
     
  13. mixed_signal

    New Member

    Dec 5, 2009
    22
    3
    For 8-bit PICs I've also had good luck with a PicKit1 development board, which is $36 compared to 50 for a PicKit2. With a spare 14 pin socket and some flat cable and a 5 pin header I made it into an in-circuit programmer, as well. Just wire up the header in the same order as the PicKit2 for compatibility.

    And, yes it works with rewriting chips using internal oscillator mode just fine, for both a 12F675 and a 12F684, at least.

    PicKit1:
    http://www.microchipdirect.com/productsearch.aspx?Keywords=DV164101

    PicKit2:
    http://www.microchipdirect.com/productsearch.aspx?Keywords=DV164121
     
  14. vane

    Active Member

    Feb 28, 2007
    181
    0
    So if i get a PIC kit1 i can write to PIC 675s without MCLR?
     
  15. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    Vane do not get the pickit 1. Get at least the pickit 2. You can buy the pickit 2 programmer separate. If you are on budget this device is the best value for money.
     
  16. vane

    Active Member

    Feb 28, 2007
    181
    0
    Will getting the pickit2 allow me to program 675s without MCLR then?
     
  17. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    Last edited: Dec 6, 2009
  18. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    It will also work with the simple debugger in pickit 2 :)
     
  19. vane

    Active Member

    Feb 28, 2007
    181
    0
    The 12f675 is on the K8048 aswell but i can't use my chips because they have MCLR set as an output, which means the K8048 does not put it into program mode, it automatically goes into cycle mode and runs the program, so the pickit2 would remedy this? I might wet the solder joints on the board incase that is the problem. I am running it off of a 12v supply yet i have heard to put it into program mode it has to be 13.5v+

    I can't believe Microchip could make such a big cock up with the 8 pin PICs
     
  20. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    I'm using a PICKIT2 (clone) with the 12F675 and can confirm it can write and rewrite them fine.
    I think the problem is more with Velleman than Microchip although Microchip do often seem to make things more complicated than necessary. It took me a while the other day to work out that some of the eeprom registers are in different banks on different PICs. That makes no sense to me.
     
Loading...