Programming the Velleman k8048 pic micro on Mac OS X

Deciding to get back into pic programming after a long break of 5 years or so. My previous set up was a very old Windows machine which i bought for $100 purely for the serial output port.

Of course the Apple gave up on serial ports a long time ago to replace them with USB only which leads to a raft of problems.

From their product page PIC PROGRAMMER & EXPERIMENT BOARD at the bottom of the page is an important warning.

IMPORTANT
not compatible with USB to serial (RS232) convertor !

This, coupled with the only having a Mac meant that the first step was to fire up the old parallels desktop into Windows XP and pray1 for the best.

The USB to serial (RS232) converter I got was a Prolific chipset based model – which seems to be the most available 2.

I tried the following:

  • Installing the Prolific driver on the Mac, attaching it to Parallels and giving a whirl DOESN’T WORK
  • Installing the Prolific driver on Parallels NO LUCK HERE

So, at a loss, and thinking of buying another programmer, I finally stumbled across the following page for the Velleman programmer (amongst others): http://dev.kewl.org/k8048/Doc/.

In a nutshell, these are the steps:

Step 1: Download the required files

Download the programmer from http://dev.kewl.org/k8048/k8048.tar.gz.

Download the GNU Pic Utils (gputils) from http://gputils.sourceforge.net/. You should get the latest version – I am using version 0.13.7 here.

Step 2: Compile the programmes

  1. Open up a terminal (/Applications/Utilities/Terminal.app)
  2. change directory to the downloaded files
  3. untar/gzip the files
  4. Make the binaries

Assuming that you have downloaded the files to the Downloads directory – in the terminal you should do the following:

cd Downloads
tar xvzf gputils.tar.gz
cd gputils-0.13.7
./configure
make
sudo make install

for the cd gp-utils-0.13.7 you may need to update this directory to the version of gputils that you are using.

for the last command you will need to enter your password.

now, in the same window

cd ~
cd Downloads
tar xvzf k8048.tar.gz
cd k8048/k8048
make

This will now make the binaries for the k8048 programmer.

Note that I do not install the package yet…

Step 3: Install the programmer

I have created a bin directory in my home directory which I place all of my useful binaries/programmes.

I will assume that you wish to do the same – alternatively you may leave the built k8048 programmer as is and use it from that directory.

cd ~
mkdir bin
cd bin
mv ~/Downloads/k8048/k8048/k8048 .
ln -s k8048 kdebug
ln -s k8048 ktest 
ln -s k8048 k16
ln -s k8048 k14

Now that we have all of the programmes in the bin directory we need to make sure that we can access them from the command line (i.e. Terminal).

you will need to edit your .bash_profile file for the changes to be picked up.

More Terminal work:

open -a TextEdit .bash_profile 

Which should open up a new TextEdit window where you need to add the following line at the bottom of the file:

export PATH=$PATH:~/bin/

Save and close the file and IMPORTANTLY: start a new Terminal session (this will pick up the changes made.

Step 4: Start programming

Assuming that everything went well from the above, you should now be able to start programming the k8048 programmer.

A few notes

Configuring the pic

I like the following configuration table – rather than using the built in acronyms:

  __config b'11111101010000'
          ;  1111----------  code protection off
          ;  -----1--------  data memory protection off
          ;  ------0-------  low voltage programming disabled
          ;  -------1------  brown out detect enabled
          ;  --------0-----  MCLR pin acts as MCLR, not RA5
          ;  ----------0---  power up timer enabled
          ;  -----------0--  watchdog timer disabled
          ;  ---------1--00  internal 4MHz oscillator, RA6 and RA7 I/O pins

Using the master clear as an input/output

As the MCLR3 is used by the velleman programmer, you will have problems re-programming the pic. Never fear, all you need to do is to blank the pic first.

For example:

k14 s PIC16F627 b

Which sets the pic to be the PIC16F627 with the b argument for blanking the pic.

How I programme

I generally run the following:

k14 s PIC16F627 b; gpasm -p p16f627 dual-digit-countdown.asm; k14 p dual-digit-countdown.hex

In order (the semi-colons ‘;’ delimit commands)

  1. blank the pic (k14 s PIC16F627 b)
  2. assemble the code (gpasm -p p16f627 dual-digit-countdown.asm)
  3. programme the pic (k14 p dual-digit-countdown.hex)

Wrap-up

So there you have it – easily done – it is relatively slow – but it does work.

Footnotes:

  1. No, I am not a religious man
  2. if not the most popular
  3. Pin 5 from memory

Like my footnotes?
Want to add footnotes to your blog?
They can be added easily to your WordPress installation


Leave a Reply

You must be logged in to post a comment.