Close

Programming PIC

A project log for Making Ted Yapos TritiLED

Documentation of the process and challenges along the way

schlionschlion 06/03/2023 at 22:420 Comments

This was my first time using PIC microcontrollers, before I had only used Arduinios and Atmels (programmed via Arduinos). I did not realize I would have to buy into a whole new µC universe. The first step was getting a programmer. I got a PICkit3 clone on ebay for about ~35€. I should probably have gotten something else, especially since Microchip acquired Atmel in 2016 their newer programmers also support Atmel chips (nice!). Getting a genuine and supported programmer is nice, since there is documentation, and you can be relatively sure that the problems one experiences are a result of a user error and not so much your programmer or software being flaky. Buuuut, since the reasonably priced MPLAB SNAP was out of stock and most of the other options were much more expensive, I stuck with the clone.

As soon as I had the programmer I realized I had no way to connect it to the PIC @Robert had the same question and @Ted Yapo suggested the use of a SOIC-8 Clip. So I got one.


The next problem was the tool chain. The newest version of the Microchip IDE and the corresponding programming software MPLAB IPE, do not support PICkit3. Luckily [PICkitminus](http://kair.us/projects/pickitminus/) exists. I was able to recognize my programmer. Connecting the clip to a bare PIC and setting the correct device family, I tried connecting to the PIC, but although I could read from the device, I could not write to it.

I tried activating the VDD, but it didn't work. What did solve my problem was just using an external 3.3V power supply. I actually used an ams1117 3.3v board and a USB brake -out board to get 3.3 V from my PC's USB.

Really handy, you should get some. Now I could finally program the PIC!

So now that we can write .hex files to the IC, I would like to generate them as well. Luckily, there is a makefile in the repository. For it to work, we need some kind of make utility and a compiler.  I got my make from the MPLAB X IDE, since windows doesn't have make natively. The compiler is not bundeled with the IDE, so I downloaded the MPLAB XC8 Compiler (it's the one used for 8-bit Microchip microcontrollers). Setting up a whole project in MPLAB seemed very tedious and complicated, so I just ran:

& "C:\Program Files\Microchip\MPLABX\v6.10\gnuBins\GnuWin32\bin\make.exe" tritiled_v30_selectable_runtime

 in the /tritiled/software/tritiled30/src folder. Additionally, I had to set the path to the compiler in the makefile:

XC8 = /opt/microchip/xc8/v1.34/bin/xc8
to
XC8 = "C:\Program Files\Microchip\xc8\v2.41\bin\xc8.exe"

 or wherever else your compiler is. Then I was set up to follow the procedure described in https://hackaday.io/project/11864-tritiled/log/82040-v3x-calibration-procedure/.

Discussions