Menu

PIC Programming with GCB on a Mac

mkstevo
2016-07-28
2018-01-04
  • mkstevo

    mkstevo - 2016-07-28

    I hope I'm not duplicating anything here, but I struggled to find any guides for using a Mac for programming PIC processors.

    I looked for ages to find out how I could program PICs using only my iMac, I have been using GCB and a GQ-4X programmer by running them under VirtualBox. This works very well and I'd recommend it, my problem is that this still requires a valid Windows Licence and a (virtual) PC which needs 'booting' every time I need to program a PIC. At home I don't have a GQ-4X programmer and so I've been looking for a way of using something else both for me and at work. I searched for Mac compatible programmers but very few seemed to offer Mac compatibility, most that did were for older operating systems or out of production. The MicroChip Pickit3 kept claiming Mac compatibility but looking for specifics on the MicroChip website never gave me much in the way of solid (Mac) facts.

    Eventually I downloaded "MPLABX-v3.35-osx-installer" (440Mb) and ran it. This gave me the option of installing only the mplab_ipe (Integrated Programming Environment). This installed (with an error message at the end). I ran it and it was just what I wanted, a simple, standalone programmer that can load pre-compiled .hex files and program them into a processor. No 'Projects' or other nonsense required, just a programmer, compatible with the 16F182x range of PICs I use at work. Great. I never found out what the error message meant. So far I've had no problems.

    I then ordered a Pickit3 (clone) from a Chinese supplier, along with a ZIF adaptor, USB cable and an extension cable for the programmer socket. This cost a fraction under £11 including postage. Two weeks or so later, the Pickit3 package arrived. I plugged it into a USB socket, checked that it was recognised as a Pickit3 (it was) and started mplab_ipe that I'd previously installed.

    The IPE loaded and found the Pickit3. I selected my Device as a 16F1829 (I borrowed one from work to test), set my Tool as PICkit3, plugged in the ZIF socket to the Pickit3 then selected Connect. Failed. Hmm... I then went to Settings > Advanced Mode and logged in using the password microchip. The options here allow you to turn on the power from the Pickit, so that it supplies power to the connected chip. For reliable error free connections, I had to set the power voltage to 4.55V as asking for 5V gave a message that the target voltage couldn't be set. This could just be my USB hub being slightly underpowered. Once I'd selected that, I tried to connect to the Pickit again and got a message of success. I have found that if the device is blank, it will connect at 5V, once programmed, it seems to only work without error messages at the 4.55V. Still, it's no hardship to set a slightly lower voltage.

    I loaded a previously compiled .hex file and pressed the program button. After only two seconds or so, I saw a message of success. Thinking this was suspiciously fast, I clicked Verify. The verify failed. I tried again, and again but the verify kept failing. I searched MicroChip's site for solutions and on the second or third page someone mentioned code protection... Of course! I'd turned on code protection! Fool. I had programmed the chip, the verification failed as I'd protected the code. Plugging the programmed chip into a block of breadboard showed it to be working as expected. Success. I really had erased it and then programmed it that quickly.

    One thing I've not managed to do is to get mplab_ipe to retain the settings for powering the target device, thiss needs to be turned on each time I start the program.

    I usually have the Settings option for 'Erase All Before Program' selected as otherwise a previously programmed device may fail to work correctly. It might just be me, but I prefer to start with a blank device.

    Now to get GCB to run on the iMac.

    This was rather easier. I downloaded a copy of the most recent GCB installer. I'd already got a copy of WineSkin so I started that, pointed it to the GCB installer and let that run. I then set the startup program to "/GCB@Syn/IDE.exe" and started up. GCB then ran happily. Compiling a program this way is rather slower than compiling it under Windows but to be able to use GCB and program PICs without needing Windows is just wonderful. As GCB runs (under WineSkin) in it's own 'bubble' I can't see how it could connect to the Pickit3 using the batch tools. To be honest I've not tried, I was so pleased to get this to work, I'm happy to leave things as they are. If a 'hex file is open in mplab_ipe and it is re-compiled in GCB mplab-ipe does offer to re-load the file. This mostly works, though once or twice, it re-loaded an older version. I prefer to manually load the new version myself but you may be luckier than I.

    I hope this helps anyone else wondering how to program PICs using a Mac.

     

    Last edit: mkstevo 2016-07-28
  • bed

    bed - 2017-10-21

    You could use the same command_line Parameter as I use for Linux. Mac is very similar to it :-)
    My actual Commandlines in geany are

    COMPILE:
    /opt/GCBASIC/makehex.sh %f
    FLASH:
    java -jar /opt/microchip/mplabx/v3.65/mplab_ipe/ipecmd.jar -TPPK3 -P18F25K22 -M -F"%d/%e.hex"
    

    Downside of this method is, the Flash Command_line contains the pic_type, which must be changed, when the Target is changed.
    I will do a extract of your expierence in our new FAQ, there is nothing for MAC, yet

     
  • stan cartwright

    stan cartwright - 2017-10-21

    I don't have java installed on win. I don't need or want it. I don't want to install mplabx to use tk3 either.

     
  • mkstevo

    mkstevo - 2017-10-26

    You don't need to install all of MPLABX. Download the whole file, then run the installer and when presented with a choice, choose to install MPLAB IPE only. Once installed, the MPLABX download is no longer required.

    Obviously, I've only tried this on a Mac, but it worked for me.

    The two steps of 'Compile' and 'Download' suits my thought process anyway, so I don't really need the automatic Compile & Download.

     
  • bed

    bed - 2017-10-26

    For my part, I will not use wine (linux), tried two times and I'm not satiesfied. GCB works, but Compiling is lasting 6 times longer than doing it native.
    And it tends to hangup. With native Compiler I did not suffer from such hangs, it is working very smooth.

     
  • mkstevo

    mkstevo - 2017-11-15

    There is a way of speeding up the compile time under WINE. I have modified the GSTools .exe which skips some of the tests for the library files. This makes an enormous difference to the speed of compilation. The tools and instructions are located somewhere on the forum...

    Hopefully, here: https://sourceforge.net/p/gcbasic/discussion/629990/thread/2dc2255b/

    The only occasional problems I notice is that sometimes the code completion causes the editor to hang [I must try turning it off...]. If I minimise the editor on my Mac, I can never get back to the window and end up having to force close it. Other than that, I don't have any problems. I use it almost daily for work and only rarely suffer from crashes. It is much better than running a copy of Windows in VirtualBox.

     

    Last edit: mkstevo 2017-11-15
  • mkstevo

    mkstevo - 2018-01-04

    I have at long last discovered a way of minimising a WINE window running GCB and SynWrite on my iMac(s) without causing the WINE environment to vanish and be unable to ever retrieve it. This is terrible if you have not saved any recent changes prior to minimising the WINE window as the only way to continue is to force quit the running WINE and then restart another copy.

    As the WINE application appears as a single file, here are the edited instructions on how to make the changes required:
    Locate the GCB WINE application in Finder. For me this is: Users/MkStevo/Applications/GCB
    Right click on the application and select 'Show Package Contents'.
    A couple of directories should be displayed, and an Application called 'Wineskin'.
    Double click on Wineskin which should open a small window showing four options: Install Software, Set Screen Options, Advanced and Quit.
    Select 'Set Screen Options'.
    Set the options as shown in the attached image and then click Done.
    The resolution selected here can be any resolution to suit the size of your monitor, all other options should be as shown.

    Now minimising a GCB window within WINE should minimise it (minimize?) to the dock and allow it to be maximised from the dock normally.

    Just in case the picture fails to load here are the Set Screen dialog options required.

    Override Settings
    Rootless (windowed)

    Virtual Desktop at: 1920 x 1200 [resolution can be altered here to suit monitor]

    Installer Options
    Use These Settings

    Override Wine control of Screen Settings?
    Override

    Extra Gamma Correction
    None

    Other Options
    Use Mac Driver instead of X11: No (MUST be Un-Checked)
    In fact, all options here can be un-checked. On a slower Mac, selecting the other options seems to just slow everything down quite a bit...

    Just to clarify: I am using a Mac, running macOS Sierra 10.12. This may or may not apply to older or newer versions, so far I haven't tried anything else. It does work on at least two iMacs as I use one at work and one at home. The one at work is an older machine with smaller monitor and slower processor but I can't say what that processor is.

     

    Last edit: mkstevo 2018-01-05

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.