x. How to make a 32-bit PIC32MX250F128B or PIC32MX270F256B (PIC32) microcontroller to work on USB 2.0

PIC32MX250F128B is much more difficult to make to work over USB than 8-bit PIC microcontrollers. Comparing the PIC32MX microcontroller family electrical specifications with PIC18F family ones, I found out that some delays need to be more precisely timed. But this was only a beginning...

Homemade JTAG PIC32 programmer (How it works?)

The next step was modifying my PIC18F2xJ50 programmer to support PIC32MX2xxFxxxB chips. At first glance someone might thing that it was just the matter of adapting a few program lines. But even getting the proper documentation was tricky. PIC18F documentation is available in two technical documents. The first describes the general microcontroller operation and the second is the programming documentation that enables you to make your own programmer. But PIC32 reference documentation is divided to more than 30 documents, each describing a particular functionality. There is also a general document describing each microcontroller family, but you have to look at the PIC32 reference documentation to get certain details beyond programming the microcontroller in C language. However, the PC32 microcontroller documentation is insufficient for making a successful PIC32MX2xxFxxxB programmer. There is no mention of where you can obtain the programming executive (PE) needed a piece of PIC32 code that has to be preloaded into a PIC32 microcontroller enable fast programming. Of course there is a detailed enough description of a slow programing procedure, but I wouldn’t recommend it. I used a trick of modifying the PE loader to quickly pump the data into the microcontroller.

Making a successful basic circuit

Unfortunately, there were more obstacles to overcome. JTAG PIC programmer started to work, but it was unreliable and it turned out that it would not program the configuration words due to its programming error. But a PIC32MX250F128B or a PIC32MX270F256B would still work on its internal 8 MHz oscillator…. This was really deceiving and it was difficult to realize what prevented the microcontroller to work over USB 2.0. At first it seemed to me that the crystal oscillator quality was to blame. I tried different types of the oscillators, form crystal resonators to full crystal oscillators. But nothing worked until I discovered the error in the programmer software. As the programmer started to program the configuration words a surprising error occurred. The programmed PIC32MX250F128B and PIC32MX270F256B microcontrollers were somehow locked and I was unable to read back their program codes, nor erase their program memories. The experimental basic circuit would still not work over USB. It was unclear, if only the homemade programmer was to blame, or there was also something wrong with the basic circuit or PIC32MX250F128B firmware.

My project stalled and it was obvious that only a commercial programmer that would serve as a reference would enable me to solve all the riddles. In fact, I needed just a quality programming header like PICkit 3. I turned my homemade programmer into a programmer header for PICkit 3, but PICkit 3 would refuse to connect. Fortunately, this time it was only a miss connected wire. The PICkit 3 finally connected, programming was successful and the microcontroller on the basic circuit would connect to the PC over USB 2.0 with ease.

It quickly became obvious to me that my programmer was to blame. The PICkit 3 programmed microcontrollers were also not locked for reading… However, if you intend to build your own JTAG programmer, it is not all bad news. I plan to work on the programmer after I finish Visual Basic support for PIC32MX2xxFxxxB microcontrollers.

NOTE: JTAG PIC32MX2xxFxxxB microcontroller programmer SW from this website (version 3.0) does not program microcontroller configuration words. Therefore programmed mocrocontrollers work only on their internal 8 MHz oscillators, which is still sufficient for most applications that do not require USB support.

Success at last!

Finally, I decided to buy a Pickit 3 programmer/debugger header for approx. 40 €, which solved all my problems and even enabled me to program all Microchip microcontrollers. However, I decided to finish my PIC32MX250F128B/PIC32MX270F256B programmer. I finally made it to work in the end of November 2013. See JTAG PROGRAMMER FOR PIC32 FAMILY in Microcontroller programmers section for details. Source code is included!

More information:

- PC USB Projects PROGRAMMING GUIDE

- PICkit 3 header for PIC32MX250F128B programming

- PIC32MX250F128B configuration samples (*.h files for C-language applications)

- Basic circuit for PIC32MX2xxFxxxB to work over USB with a 20 MHz external oscillator

- Basic circuit for PIC32MX2xxFxxxB to work over USB with an 8.000000 MHz crystal resonator

- Velleman K8055N board to 32-bit PIC32MX250F128B adapter schematic

- ADT7410 & PIC32MX250F128B: 16-bit digital thermometer

Click on the photo to enlarge.