Get a working environment

It has been about 10 years since I last played with Microchip devices. I can no longer remember the exact environment I used to develop with Microchip (that hard drive is long gone). So I have had to start from scratch, investigate what tools are currently available, determine what support is available, and decide on a direction.

Wanting to develop on Linux, it became clear that most of the available tools and support was going to be for the Microchip line of micros. I was gratified to find that their top of the line development software, MPLABX, was available for Linux. I immediately downloaded that and looked over its capabilities. With both an assembler and a C compiler, it looked like a pretty useful tool. I’m not the biggest fan of IDEs, but it seemed that this was going to be pretty easy to use, and command line operation was a possibility.

I still had a handful of devices tucked away in a drawer. These included the

16F86, 16F86A, 16F876, and 16F877.

There was an early Microchip development board, the

MPLAB-ICD and demo board

I never tried to use those previously. It looks like the versions I have are not offered any longer.

I also stll had a

DonTronics DT001-RevC

development board. This is the hardware I previously used so long ago. I really liked the SIMM card and socket arrangement. I had a “processor” card and three additional SIMM cards with various peripheral circuits that I had built. Unfortunately, I had none of the code I had written saved anywhere. I tried out each peripheral card one at a time with the processor card. I got no LEDs to light up at all. (I always had at least one LED for a DEBUG light.) I don’t know what code was in the little ‘F86, but it obviously was not anything that I left in a working state.

So now I needed to concentrate on getting some sort of development environment set up. The main questions were could I compile some code, can I program a chip, and can I put together some hardware and run it? My

PICSTART Plus programmer.

was tucked away in a cabinet. From reading the Microchip forum, this programmer is an antique, having been replaced by PICKIT2 and PICKIT3. After reading some horror stories on the Microchip forum about not being able to connect, unrecognized chips, and code loading failures, I decided to not buy anything for now and use the PICSTART on this first attempt. One problem was that the software revision of my PICStart was pretty old. I’d have to keep that in mind if I ran into problems. I found the

picp

driver for Linux that will run the PICSTART and downloaded that. It looked like it would support all the chips I had on hand. I could check-off the programmer requirement.

Now I needed an assembler. I made an attempt to use

mpasm

(the 8-bit assembler included in MPLABX). I ran into a problem where mpasm would not recognize its section directive, “.text”. I never figured out what the problem could be. I started looking for another assembler. I may have used

gputils

previously and that looked to be a good tool to try. I downloaded that and was up and running with it in no time.

Using picp to look at the code in the chips I had on hand, it turned out that only three were programmed. I was very pleased to discover that gputils could disassemble the .hex file dumped from the chip using picp and the PICSTART Plus. Looking over the code in the F86 (referenced above) that didn’t do anything, I could make no sense of it as trying to talk to any of the SIMM cards I had built. No telling what the heck I was up to when I abandoned all this years ago. Anyway, I had enough tools now to try a simple bit of test code.

A first project specificattion

So exactly what should I try to include in this “first pass”? Well, I am jumping back into microcontroller development for a reason. One of the essential functions I will need is a motor controller. It will probably be your typical PWM driven motor controller. I don’t want to jump into the motor driver circuitry just yet. But looking at a PWM signal with a duty cycle of some randomly selected value would not be too interesting. Additionally, it would be good to determine if I understand how to specify the full duty cycle range available on the hardware. So how about a PWM function that sweeps the duty cycle from about 0% through 99% over and over? That would make for a nice display on my trusty, dusty Tektronix 465 oscilloscope.

I realize that not everyone has access to an oscilloscope. A DMM would also do nicely. But I would like for those people without either to be able to get some visual indication of what this project is doing. We can take the PWM output and feed it into a simple R/C integrator. This will create a slowly (depending on PWM sweep frequency) changing DC voltage. We can feed this integrated signal to one of the ADC (Analog/Digital Converter) channels and write the result to the display.

A quick note about coding for this project. I’m going to write this in assembly language. First, I think it is important to understand the guts of a microcontroller if you are going to design circuits on your own. This is best accomplished through using assembler. Second, I will not have to learn the details of a microcontroller C dialect right now. I want to concentrate on the functionality. Third, we will rewrite the code in C after this project is working correctly. So the over-all plan, then, will be to create display, PWM, and ADC functionality. That will be developed in the following pages.




©copyright 2014 pretzelogic LLC. All rights reserved.
No part of this page may be reproduced without permission.
Software, schematics, and text are presented as reference works only.
No claim as to useability, suitability, or correctness for any application is made.