How To Program Micro Controllers?

Discussion in 'General Technical Questions and Answers' started by KI5CAW, Mar 3, 2020.

ad: L-HROutlet
ad: l-rl
ad: Left-2
ad: L-Geochron
ad: L-MFJ
ad: abrind-2
ad: Left-3
  1. KI5CAW

    KI5CAW Ham Member QRZ Page

    I recently bought a little digital dial kit from QRP Guys that uses a microcontroller (PIC 16F628A) as a frequency counter. It stopped working and I believe the MC is the problem. This has caused me to become curious as to just how designers program these little devices. Can any of you in Zed Land direct me to information resources regarding the nuts and bolts of how these devices are programmed, and how I can try that myself? I am very curious.
    -Dave KI5CAW
     
  2. N8YX

    N8YX Ham Member QRZ Page

    eBay has a selection of USB-type PROM/PIC programmers for sale. A TL866-II or similar setup will program the 628 series and a number of other PICs as well.

    You'll need a host PC (which supports the programmer's interfacing software) and the source code for the PIC you wish to program.

    ETA:

    As far as the "How To's" are concerned, Google is your friend. Quite a few hobby forums exist which detail the programming and usage of PIC devices, including source-code authoring tools.
     
  3. WA7ARK

    WA7ARK Ham Member QRZ Page

    If I were in your shoes, I would just forego the PIC and start by learning the Arduino, instead. It is geared more to the casual user, with more "support".

    I learned all about PICs when employed, and had access to $$$ compilers, debuggers, emulators, programmers, paid for libraries, etc. Today, I can do my silly little projects using the Arduino development system, almost for free.

    I use the Arduino Pro Mini in most of my projects. Costs about $10 to permanently build one into a project.
     
  4. W9WQA

    W9WQA Ham Member QRZ Page

    yrs ago i spent time with "mikroelektronica" forum in europe.
    they had a free assembler but a costly interface. very nice products.
    lots of fun as a hobby but not for one job. they did ALL pic chips...

    id like the Arduino Pro but my brain cant cope with "c"
     
    Last edited: Mar 3, 2020
  5. KI5CAW

    KI5CAW Ham Member QRZ Page

    In my case the kit worked fine at first. The display behaved as the manual described. But now it remains blank when turned on, and I realized that I know so little about these devices that I thought I could simply replace the PIC. But alas, I realized it has to be programmed first, hence my interest! I have already started following the leads you gentlemen have provided, thanks! I am assuming that if the display remains blank and the PIC definitely has power to it, it must be bad.
     
  6. N6UH

    N6UH Premium Subscriber QRZ Page

    Unless you have the source and or the object code for the device it would be quicker to start from scratch. Those devices have code protection bit(s) so even if you can read it with a suitable programmer you won't get any meaningful info from the original device
     
  7. KD2BD

    KD2BD Ham Member QRZ Page

    PICs have been around for a while, and so there are MANY options available.

    My approach (under a Slackware Linux environment) is to assemble code using the gpasm assembler (part of the https://gputils.sourceforge.io/ suite PIC of utilities), perform some simulations using gpsim (http://gpsim.sourceforge.net/), and flash the PIC using picprog (http://hyvatti.iki.fi/~jaakko/pic/picprog.html) working into a homebuilt serial port powered programmer, such as the following:

    [​IMG]

    By the way, this programmer works with a host of different PICs. In fact, my last PIC project involved teaching a 16F628 to copy CW. ;)

    If you have a spare PC with serial ports, you might consider tossing Linux on it and using an approach such as this.

    USB port programming is more complicated than serial port programming from a technical point of view. There are some USB port programmers you can build, but they often contain PICs themselves, so you can end up with a "chicken-and-egg" situation,


    73 de John, KD2BD
     
  8. K8AC

    K8AC XML Subscriber QRZ Page

    I did considerable programming of PICs about 10 years ago. A complex PIC application is not the place to start if you do not already have programming experience. At that time, all PIC programming was done in PIC assembler, using the MPLAB Integrated Development Environment, free from Microchip. I used a PIC simulator that I bought from a guy in Europe and used one of the Mikroelectronika kits for loading the programs to the PIC and for some basic debugging. To complicate things, there were architectural differences between the various PIC chips that you had to be aware of. At that point, I had 40 years of experience in writing assembler level code for microprocessors, and I still found it a challenge. As someone else has said, Arduino is probably the way to go today - you can buy low-cost learning kits from companies like Elegoo and then you can decide if you really want to pursue Arduino. Arduino development uses c++, which I find to be a terribly unfriendly language. For any complex application, you'll spend more time struggling with the language than in getting the application design worked out. Regarding your frequency counter, you probably fed too large a signal into the input, destroying the analog to digital converter in the Arduino chip.
     
  9. W2JKT

    W2JKT Ham Member QRZ Page

    There are several different methods but most of them involve a dedicated (or semi-dedicated) set of programming pins on the microcontroller.

    JTAG is one industry standard that describes a 4-pin interface that allows programmable devices to be connected in a chain for mass-programming

    ARM devices support Serial Wire Debugging (SWD) which can also be used for programming. This is a 2-pin interface.

    Some devices, like NXP's LPC 8051 microcontrollers are programmed via UART.

    PIC also has their own serial programming method called ICSP, though I've never used it. It's described in the datasheet for the part you're using.

    There are many, many PC-based programmers available. I use one from Segger called the "J-Link" which can support many different programming methods. Keil makes one called the ULINK which handles many different microcontrollers as well. TI makes the MSP-FET which does their MSP430 line (this one's manufacturer-specific).

    You have many (almost too many) options.
     
  10. WA7ARK

    WA7ARK Ham Member QRZ Page

    Or you can just get an Arduino Uno, which has a USB connector (emulates a PC serial comm-port interface) right on its board, as do most of the higher-end Arduinos. The USB cable connects between the PC and the micro while you are developing/debugging the code.

    The Mini I linked to does not have a USB connector; it just has a header that hooks to one of these units while you are programming it. Once you are done with a project, you unplug it, and use the USB interface for the next project.

    You can also get a small board with the USB interface on it.
     

Share This Page