{"id":101,"date":"2016-10-29T23:15:53","date_gmt":"2016-10-29T21:15:53","guid":{"rendered":"http:\/\/www.b00z.nl\/blog\/?p=101"},"modified":"2017-06-29T21:57:53","modified_gmt":"2017-06-29T19:57:53","slug":"programming-a-pic-pic16f88p-for-example-the-heart-of-otgw","status":"publish","type":"post","link":"https:\/\/www.b00z.nl\/blog\/2016\/10\/programming-a-pic-pic16f88p-for-example-the-heart-of-otgw\/","title":{"rendered":"Programming a PIC (PIC16F88P), for example the heart of OTGW"},"content":{"rendered":"<p>This blog is about programming your own PIC microcontroller. I had never done it before and while I was working on my own OTGW (See <a href=\"http:\/\/www.b00z.nl\/blog\/2016\/04\/my-first-steps-at-home-automation-and-pcb-design-otgw-led-panel-design-with-eagle-software\/\" target=\"_blank\" rel=\"noopener\">http:\/\/www.b00z.nl\/blog\/2016\/04\/my-first-steps-at-home-automation-and-pcb-design-otgw-led-panel-design-with-eagle-software\/<\/a>) I had to program it myself. Sure they offer links to people who can send you preprogrammed PIC&#8217;s, but what&#8217;s the fun of that? ;o)<\/p>\n<p>First I needed some hardware. All items were ordered through AliExpress:<br \/>\nThe PIC itself : PIC16F88-I\/P<br \/>\nThe programmer: <a href=\"https:\/\/www.aliexpress.com\/item\/PICKIT2-Programmer-PIC-ICD2-PICKit-2-PICKIT-3-Programming-Adapter-Universal-Programmer-Seat-Free-Shipping\/2026952121.html?spm=2114.13010608.0.0.REylZa\" target=\"_blank\" rel=\"noopener\">PICKIT2 Programmer + PIC Programming Adapter<\/a><\/p>\n<p>And, for this project, the OTGW firmware: download latest (gateway.hex) from <a href=\"http:\/\/otgw.tclcode.com\/download.html#hexfiles\" target=\"_blank\" rel=\"noopener\">http:\/\/otgw.tclcode.com\/download.html#hexfiles<\/a><\/p>\n<p>There are may utils that can programm PICs with eg. the pickit, however for just programming the hex I found that Linux is still the fastest way to go. At least for me.<\/p>\n<p>So first you&#8217;ll install all necessary software (I&#8217;m using an Ubuntu distro):<\/p>\n<p>pk2cmd<br \/>\npk2cmd source: <a href=\"https:\/\/sourceforge.net\/projects\/pk2cmdv1-20-linux\/\" target=\"_blank\" rel=\"noopener\">https:\/\/sourceforge.net\/projects\/pk2cmdv1-20-linux\/<\/a><br \/>\nDirect Download: <a href=\"https:\/\/sourceforge.net\/code-snapshots\/svn\/p\/pk\/pk2cmdv1-20-linux\/code\/pk2cmdv1-20-linux-code-3-trunk.zip\" target=\"_blank\" rel=\"noopener\">https:\/\/sourceforge.net\/code-snapshots\/svn\/p\/pk\/pk2cmdv1-20-linux\/code\/pk2cmdv1-20-linux-code-3-trunk.zip<\/a><br \/>\nOr checkout by SVN: svn checkout svn:\/\/svn.code.sf.net\/p\/pk2cmdv1-20-linux\/code\/trunk pk2cmdv1-20-linux-code<\/p>\n<p>First install libusb-dev:<br \/>\nsudo apt-get install libusb-dev<\/p>\n<p>Next unpack the pk2cmd code into a directory or go into the pk2cmdv1-20-linux-code\/pk2cmdv1.20LinuxMacSource\/ directory if using the svn checkout.<br \/>\nThen build the software and install it:<\/p>\n<pre>onno@programhost:~\/Software\/picprogrammer\/pk2cmd$ make linux\r\n make TARGET=linux\r\n make[1]: Entering directory '\/home\/onno\/Software\/picprogrammer\/pk2cmd'\r\n g++ -Wall -D_GNU_SOURCE -O2 -I\/usr\/local\/include -DLINUX -DUSE_DETACH -DCLAIM_USB -o cmd_app.o\u00a0 -c cmd_app.cpp\r\n (..SNIP..)\r\n pk2usbcommon.o pk2usb.o P24F_PE.o dsP33_PE.o strnatcmp.o -L\/usr\/local\/lib -lusb\r\n make[1]: Leaving directory '\/home\/onno\/Software\/picprogrammer\/pk2cmd\/pk2cmdv1-20-linux-code-3-trunk\/pk2cmdv1.20LinuxMacSource'\r\n\r\nonno@programhost:~\/Software\/picprogrammer\/pk2cmd$ sudo make install\r\n mkdir -p \/usr\/share\/pk2\r\n cp pk2cmd \/usr\/local\/bin\r\n chmod u+s \/usr\/local\/bin\/pk2cmd\r\n cp PK2DeviceFile.dat \/usr\/share\/pk2\/PK2DeviceFile.dat<\/pre>\n<p>When all finished, temporarily add the pk2 directory to your PATH var:<\/p>\n<pre>onno@programhost:~\/Software\/picprogrammer$ PATH=$PATH:\/usr\/share\/pk2\/\r\n onno@programhost:~\/Software\/picprogrammer$ export PATH<\/pre>\n<p>Now you should be able to run the following commands:<\/p>\n<pre>onno@programhost:~\/Software\/picprogrammer$ pk2cmd -?v\r\n\r\nExecutable Version:\u00a0\u00a0\u00a0 1.20.00\r\n Device File Version:\u00a0\u00a0 1.55.00\r\n OS Firmware Version:\u00a0\u00a0 2.32.00\r\n\r\nOperation Succeeded<\/pre>\n<p>If you haven&#8217;t connected your picit hardware, the result of the -?v command will be:<\/p>\n<pre>onno@programhost:~\/Software\/picprogrammer$ sudo pk2cmd -?v\r\n\r\nExecutable Version:\u00a0\u00a0\u00a0 1.20.00\r\n Device File Version:\u00a0\u00a0 not found\r\n OS Firmware Version:\u00a0\u00a0 PICkit 2 not found<\/pre>\n<p>To display the help:<\/p>\n<pre>onno@programhost:~\/Software\/picprogrammer$ sudo pk2cmd -?\r\n PICkit 2 COMMAND LINE HELP\r\n Options\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Description\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Default\r\n ----------------------------------------------------------------------------\r\n A&lt;value&gt;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Set Vdd voltage\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Device Specific\r\n B&lt;path&gt;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Specify the path to PK2DeviceFile.dat\u00a0\u00a0\u00a0 Searches PATH\r\n and calling dir\r\n C\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Blank Check Device\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 No Blank Check\r\n D&lt;file&gt;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 OS Download\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 None\r\n E\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Erase Flash Device\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Do Not Erase\r\n F&lt;file&gt;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Hex File Selection\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 None\r\n G&lt;Type&gt;&lt;range\/path&gt;\u00a0 Read functions\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 None\r\n Type F: = read into hex file,\r\n path = full file path,\r\n range is not used\r\n Types P,E,I,C: = ouput read of Program,\r\n EEPROM, ID and\/or Configuration\r\n Memory to the screen. P and E\r\n must be followed by an address\r\n range in the form of x-y where\r\n x is the start address and y is\r\n the end address both in hex,\r\n path is not used\r\n (Serial EEPROM memory is 'P')\r\n H&lt;value&gt;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Delay before Exit\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Exit immediately\r\n K = Wait on keypress before exit\r\n 1 to 9 = Wait &lt;value&gt; seconds\r\n before exit\r\n I\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Display Device ID &amp; silicon revision\u00a0\u00a0\u00a0\u00a0 Do Not Display\r\n J&lt;newlines&gt;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Display operation percent complete\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Rotating slash\r\n N = Each update on newline\r\n K\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Display Hex File Checksum\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Do Not Display\r\n L&lt;rate&gt;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Set programming speed\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Fastest\r\n &lt;rate&gt; is a value of 1-16, with 1 being\r\n the fastest.\r\n M&lt;memory region&gt;\u00a0\u00a0\u00a0\u00a0 Program Device\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Do Not Program\r\n memory regions:\r\n P = Program memory\r\n E = EEPROM\r\n I = ID memory\r\n C = Configuration memory\r\n If no region is entered, the entire\r\n device will be erased &amp; programmed.\r\n If a region is entered, no erase\r\n is performed and only the given\r\n region is programmed.\r\n All programmed regions are verified.\r\n (serial EEPROM memory is 'P')\r\n N&lt;string&gt;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Assign Unit ID string to first found\u00a0\u00a0\u00a0\u00a0 None\r\n PICkit 2 unit.\u00a0 String is limited to 14\r\n characters maximum.\u00a0 May not be used\r\n with other options.\r\n Example: -NLab1B\r\n P&lt;part&gt;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Part Selection. Example: -PPIC16f887\u00a0\u00a0\u00a0\u00a0 (Required)\r\n P\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Auto-Detect in all detectable families\r\n PF\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 List auto-detectable part families\r\n PF&lt;id&gt;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Auto-Detect only within the given part\r\n family, using the ID listed with -PF\r\n Example: -PF2\r\n Q\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Disable PE for PIC24\/dsPIC33 devices\u00a0\u00a0\u00a0\u00a0 Use PE\r\n R\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Release \/MCLR after operations\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Assert \/MCLR\r\n S&lt;string\/#&gt;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Use the PICkit 2 with the given Unit ID\u00a0 First found unit\r\n string.\u00a0 Useful when multiple PICkit 2\r\n units are connected.\r\n Example: -SLab1B\r\n If no &lt;string&gt; is entered, then the\r\n Unit IDs of all connected units will be\r\n displayed.\u00a0 In this case, all other\r\n options are ignored. -S# will list units\r\n with their firmware versions.\r\n See help -s? for more info.\r\n T\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Power Target after operations\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Vdd off\r\n U&lt;value&gt;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Program OSCCAL memory, where:\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Do Not Program\r\n &lt;value&gt; is a hexadecimal number\r\n representing the OSCCAL value to be\r\n programmed. This may only be used in\r\n conjunction with a programming\r\n operation.\r\n V&lt;value&gt;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Vpp override\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Device Specific\r\n W\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Externally power target\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Power from Pk2\r\n X\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Use VPP first Program Entry Method\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 VDD first\r\n Y&lt;memory region&gt;\u00a0\u00a0\u00a0\u00a0 Verify Device\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Do Not Verify\r\n P = Program memory\r\n E = EEPROM\r\n I = ID memory\r\n C = Configuration memory\r\n If no region is entered, the entire\r\n device will be verified.\r\n (Serial EEPROM memory is 'P')\r\n Z\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Preserve EEData on Program\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Do Not Preserve\r\n ?\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Help Screen\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Not Shown\r\n\r\nEach option must be immediately preceeded by a switch, Which can\r\n be either a dash &lt;-&gt; or a slash &lt;\/&gt; and options must be separated\r\n by a single space.\r\n\r\nExample:\u00a0\u00a0 PK2CMD \/PPIC16F887 \/Fc:\\mycode \/M\r\n or\r\n PK2CMD -PPIC16F887 -Fc:\\mycode -M\r\n\r\nAny option immediately followed by a question mark will invoke\r\n a more detailed description of how to use that option.\r\n\r\nCommands and their parameters are not case sensitive. Commands will\r\n be processed according to command order of precedence, not the order\r\n in which they appear on the command line.\r\n Precedence:\r\n -?\u00a0\u00a0\u00a0\u00a0\u00a0 (first)\r\n -B\r\n -S\r\n -D\r\n -N\r\n -P\r\n -A -F -J -L -Q -V -W -X -Z\r\n -C\r\n -U\r\n -E\r\n -M\r\n -Y\r\n -G\r\n -I -K\r\n -R -T\r\n -H\u00a0\u00a0\u00a0\u00a0\u00a0 (last)\r\n\r\nThe program will return an exit code upon completion which will\r\n indicate either successful completion, or describe the reason for\r\n failure. To view the list of exit codes and their descriptions,\r\n type -?E on the command line.\r\n\r\ntype -?V on the command line for version information.\r\n\r\ntype -?L on the command line for license information.\r\n\r\ntype -?P on the command line for a listing of supported devices.\r\n type -?P&lt;string&gt; to search for and display a list of supported devices\r\n beginning with &lt;string&gt;.\r\n\r\nSpecial thanks to the following individuals for their critical\r\n contributions to the development of this software:\r\n Jeff Post, Xiaofan Chen, and Shigenobu Kimura\r\n\r\nOperation Succeeded<\/pre>\n<p>Even though you&#8217;ve updated your PATH var, it still might complain it can&#8217;t find the PK2DeviceFile.dat file:<\/p>\n<pre>onno@programhost:~\/Software\/picprogrammer$ sudo pk2cmd -P\r\n PK2DeviceFile.dat device file not found.<\/pre>\n<p>Therefore I always use the -B option:<\/p>\n<pre>onno@programhost:~\/Software\/picprogrammer$ sudo pk2cmd -B\/usr\/share\/pk2\/ -P\r\n Auto-Detect: No known part found.<\/pre>\n<p>It seems the programmer can&#8217;t recognize the PIC. This might be because it&#8217;s not one of the &#8216;default&#8217; type (see listing further down), or maybe you haven&#8217;t connected it the right way to the device. One indication of the PIC not being correctly connected to the programmer is with the following output:<\/p>\n<pre>onno@programhost:~\/Software\/picprogrammer$ sudo pk2cmd -B\/usr\/share\/pk2\/ -P\r\n Auto-Detect: No known part found.\r\n\r\nVDD Error detected.\u00a0 Check target for proper connectivity.<\/pre>\n<p>I bought my programmer including an adapter. Which had several options for different PICs. I ended up using a multimeter with the Continuity setting (howto: <a href=\"https:\/\/learn.sparkfun.com\/tutorials\/how-to-use-a-multimeter\/continuity\" target=\"_blank\" rel=\"noopener\">https:\/\/learn.sparkfun.com\/tutorials\/how-to-use-a-multimeter\/continuity<\/a>) to verify the right pins are connected to the right input pins. As you see below my adapter has three jumpers with different settings for different PIC&#8217;s. In my case it turned out (using the multimeter) that I had to move my PIC one place up for the pins to line up correctly.<\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-111 size-medium alignleft\" src=\"http:\/\/www.b00z.nl\/blog\/wp-content\/uploads\/2016\/10\/20161029_223224-300x225.jpg\" alt=\"Adapter settings\" width=\"300\" height=\"225\" srcset=\"https:\/\/www.b00z.nl\/blog\/wp-content\/uploads\/2016\/10\/20161029_223224-300x225.jpg 300w, https:\/\/www.b00z.nl\/blog\/wp-content\/uploads\/2016\/10\/20161029_223224-768x576.jpg 768w, https:\/\/www.b00z.nl\/blog\/wp-content\/uploads\/2016\/10\/20161029_223224-1024x768.jpg 1024w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-110 size-medium alignnone\" src=\"https:\/\/www.b00z.nl\/blog\/wp-content\/uploads\/2016\/10\/20161029_181834-e1477775575430-300x225.jpg\" alt=\"PIC and jumpers\" width=\"300\" height=\"225\" srcset=\"https:\/\/www.b00z.nl\/blog\/wp-content\/uploads\/2016\/10\/20161029_181834-e1477775575430-300x225.jpg 300w, https:\/\/www.b00z.nl\/blog\/wp-content\/uploads\/2016\/10\/20161029_181834-e1477775575430-768x576.jpg 768w, https:\/\/www.b00z.nl\/blog\/wp-content\/uploads\/2016\/10\/20161029_181834-e1477775575430-1024x768.jpg 1024w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/p>\n<p>Another way, like when you don&#8217;t have an adapter, is to directly connect the pins of the PIC to the right pins of the programmer using jumper wires.<\/p>\n<p>To get a list of supported PIC&#8217;s, run:<\/p>\n<pre>onno@programhost:~\/Software\/picprogrammer$ sudo pk2cmd -B\/usr\/share\/pk2\/ -PF\r\n\r\nAuto-Detectable Part Families:\r\n\r\nID#\u00a0 Family\r\n 0\u00a0\u00a0 Midrange\/Standard\r\n 1\u00a0\u00a0 Midrange\/1.8V Min\r\n 2\u00a0\u00a0 PIC18F\r\n 3\u00a0\u00a0 PIC18F_J_\r\n 4\u00a0\u00a0 PIC18F_K_\r\n 5\u00a0\u00a0 PIC24\r\n 6\u00a0\u00a0 dsPIC33\r\n 7\u00a0\u00a0 dsPIC30\r\n 8\u00a0\u00a0 dsPIC30 SMPS\r\n 9\u00a0\u00a0 PIC32\r\n\r\nOperation Succeeded<\/pre>\n<p>When all is setup correctly, and you&#8217;re using a PIC16F88P, it should auto detect the PIC, the indicator LED&#8217;s on the programmer will flash:<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-107 aligncenter\" src=\"http:\/\/www.b00z.nl\/blog\/wp-content\/uploads\/2016\/10\/20161029_180206-300x225.jpg\" alt=\"20161029_180206\" width=\"300\" height=\"225\" srcset=\"https:\/\/www.b00z.nl\/blog\/wp-content\/uploads\/2016\/10\/20161029_180206-300x225.jpg 300w, https:\/\/www.b00z.nl\/blog\/wp-content\/uploads\/2016\/10\/20161029_180206-768x576.jpg 768w, https:\/\/www.b00z.nl\/blog\/wp-content\/uploads\/2016\/10\/20161029_180206-1024x768.jpg 1024w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/p>\n<pre>onno@programhost:~\/Software\/picprogrammer$ sudo pk2cmd -B\/usr\/share\/pk2\/ -P\r\n Auto-Detect: Found part PIC16F88.\r\n\r\nOperation Succeeded<\/pre>\n<p>To get the best results, first you erase your PIC memory:<\/p>\n<pre>onno@programhost:~\/Software\/picprogrammer$ sudo pk2cmd -B\/usr\/share\/pk2\/ -PPIC16F88 -X -E\r\n Erasing Device...\r\n\r\nOperation Succeeded<\/pre>\n<p>And then\u00a0 program it, in this case with the gateway.hex:<\/p>\n<pre>onno@programhost:~\/Software\/picprogrammer$ sudo pk2cmd -B\/usr\/share\/pk2\/ -PPIC16F88 -M -Fgateway.hex\r\n PICkit 2 Program Report\r\n 29-10-2016, 18:03:09\r\n Device Type: PIC16F88\r\n\r\nProgram Succeeded.\r\n\r\nOperation Succeeded<\/pre>\n<p>After programming, always double check it loaded correctly:<\/p>\n<pre>onno@programhost:~\/Software\/picprogrammer$ sudo pk2cmd -B\/usr\/share\/pk2\/ -PPIC16F88 -Y -Fgateway.hex\r\n PICkit 2 Verify Report\r\n 29-10-2016, 18:03:40\r\n Device Type: PIC16F88\r\n\r\nVerify Succeeded.\r\n\r\nOperation Succeeded<\/pre>\n<p>If the programmed code doesn&#8217;t match the hex file, you&#8217;ll get:<\/p>\n<pre>onno@programhost:~\/Software\/picprogrammer$ sudo pk2cmd -B\/usr\/share\/pk2\/ -PPIC16F88 -Y -Fgateway.hex\r\n PICkit 2 Verify Report\r\n 29-10-2016, 17:59:39\r\n Device Type: PIC16F88\r\n\r\nProgram Memory Errors\r\n\r\nAddress\u00a0\u00a0 Good\u00a0\u00a0\u00a0\u00a0 Bad\r\n 000000\u00a0\u00a0\u00a0 00158A\u00a0\u00a0 003FFF<\/pre>\n<p>Well, that are the basics from my point of view. I hope you found this post useful.<br \/>\n&#8211; Onno.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This blog is about programming your own PIC microcontroller. I had never done it before and while I was working on my own OTGW (See http:\/\/www.b00z.nl\/blog\/2016\/04\/my-first-steps-at-home-automation-and-pcb-design-otgw-led-panel-design-with-eagle-software\/) I had to program it myself. Sure they offer links to people who can &hellip; <a href=\"https:\/\/www.b00z.nl\/blog\/2016\/10\/programming-a-pic-pic16f88p-for-example-the-heart-of-otgw\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":110,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[51,41,47,48,49,50,46],"class_list":["post-101","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-howto","tag-hex","tag-otgw","tag-pic","tag-pic16f88p","tag-pickit2","tag-pk2cmd","tag-programming"],"_links":{"self":[{"href":"https:\/\/www.b00z.nl\/blog\/wp-json\/wp\/v2\/posts\/101","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.b00z.nl\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.b00z.nl\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.b00z.nl\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.b00z.nl\/blog\/wp-json\/wp\/v2\/comments?post=101"}],"version-history":[{"count":14,"href":"https:\/\/www.b00z.nl\/blog\/wp-json\/wp\/v2\/posts\/101\/revisions"}],"predecessor-version":[{"id":137,"href":"https:\/\/www.b00z.nl\/blog\/wp-json\/wp\/v2\/posts\/101\/revisions\/137"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.b00z.nl\/blog\/wp-json\/wp\/v2\/media\/110"}],"wp:attachment":[{"href":"https:\/\/www.b00z.nl\/blog\/wp-json\/wp\/v2\/media?parent=101"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.b00z.nl\/blog\/wp-json\/wp\/v2\/categories?post=101"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.b00z.nl\/blog\/wp-json\/wp\/v2\/tags?post=101"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}