Problem in trying to make a programmer for PIC18F

Discussion in 'Embedded Systems and Microcontrollers' started by gmrs, Dec 30, 2011.

  1. gmrs

    Thread Starter New Member

    Dec 30, 2011
    4
    0
    Hi to all,
    I am trying to make a programmer for PIC18F micro's and I have encountered some problems. For the moment I am using a PIC18F452 provided from a friend, though I will use more advanced ones in the future. I am using an ARM based evaluation board as the programmer, so all the I/O pins are @3.3V levels. Under Vdd = 3.3V the low voltage programming was not responding (using /MCLR,PGD,PGC,PGM), so I've tried to do it with the high-voltage way (using /MCLR-VPP,PGD,PGC and a maximum +12V for the /MCLR-VPP) but again with Vdd and I/O @ 3.3V. I was successful at reading the Device IDs by setting the Table Pointer @ 0x3FFFFE and doing two consecutive "Table Read,Post Increment" (see the 4-bit commands of the ICSP) and I get 0x26 and 0x04 for Device ID byte 1 and 2, which are within the expected values. The weird thing is that I cannot do it for a second time even if I set again the Table Pointer @ 0x3FFFFE. I've read that a reset won't change the value of the Table Pointer nor of the Table Latch register, but I don't understand why I cannot set the Table Pointer for a second time since I do that by executing core instructions through the ICSP 4-bit commands. Note that I have to disconnect both the PIC and the evaluation board from power to be again able to read the Device IDs. Any ideas what could be wrong?
    Apart from that, is it possible to write the flash in a per byte fashion rather than doing all the block write things that might differ from older to newer devices and from smaller to bigger flash memories and thus saving some programming time?

    Thanks

    PS: I have posted this to the Microchip forum but I haven't got an answer.
    It is the following
    http://www.microchip.com/forums/tm.aspx?tree=true&m=622790
    you can click on the yellow "error" image and the image of the schematic will pop-up, plus there is some of the code.
     
  2. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,386
    1,605
    I would first have to ask why you need to make a programmer when there are many available for purchase at reasonable prices?

    If you want to include a programmer on your own board I believe Microchip has released all the design info on the PICkit 2 including schematic, BOM, and source code.

    That wheel works and would be a good place to start.
     
  3. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    It is also a lot of simplified versions on the net. With only the parts needed for programing. Anyway unless this is a school project and you have to use the current method. Purchase a PICKIT 2 or 3 and save your self a lot of grief
     
  4. gmrs

    Thread Starter New Member

    Dec 30, 2011
    4
    0
    Hi,
    it's more for the learning experience and to some smaller extend to save some money since I am currently unemployed. I've made in the past an AVR programmer by using the PC Parallel Port and I did all of the hardware (which were very basic) and the software (the actual program that was controlling the AVR uC programming sequence through the parallel port interconnected to the SPI of the uC). I have experience with some other microcontrollers (ARM7 & Cortex,8051,Z80) but in PIC I am a total noob. Any ideas on what I might doing wrong would be appreciated!
     
  5. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,386
    1,605
    Sorry, you are pretty much on your own here. I've never worked on anything that runs that access point and I don't know of any projects where people have done such.

    Your best source of info may be searching the MC forums for previous work, or diving thru the PICkit source code.
     
  6. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    4,866
    988
    I think you are kidding yourself if you think you will be able build your own quality programmer for cheaper than you can buy one.

    You might just wind up with a bunch of components you can't use and no programmer.

    What good is building the programmer if you don't have the money to use it with other projects?

    The PICKit II and III aren't just programmers. They are in circuit programmer / debuggers. Both very, very useful tools. If you can't successfully duplicate that then save your money.
     
  7. bertus

    Administrator

    Apr 5, 2008
    15,638
    2,344
    praondevou likes this.
  8. gmrs

    Thread Starter New Member

    Dec 30, 2011
    4
    0
    Hi all and I wish you a happy new year! Thanks for your suggestions and replies. Finally, I've found the bug! It was a missing parentheses around a bitwise operation. I guess writing code late at night isn't a good practice :( and it seems that most of the times the bug is in the least expected place. Anyway, I can now read the whole of the code memory, configuration and device ID, and next I'll try writing something to the code memory.
     
  9. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    6,357
    718
    Some of my best code has been written at night, when extremely tired.

    I've paged through some new source file and say "wow, I would have never thought of this!", then later on hit another revision that was rather neat, and found my own signature in the comments, more than once, and I was the only one checking out that chunk of code from CVS.

    Those were after "binge coding" for a deadline, living on caffeine, and sleeping for a day or two afterward. I wish I could come up with those optimizations all the time.
     
Loading...