Appendix

This section describes additional materials and howtos that may be useful while following tutorials.

Building a serial port board with the max232 device

In this tutorial, we're going to build a serial port that can connect your PIC's TX and RX pins to your pc or other hardware using a max232 chip.

Many circuits will require some serial port communication, you may buy yourself a rs232 to TTL adapter off the net for as little as $10, or you can build one yourself. The max232 is a very popular chip. It converts your 5v circuit to the 12v required for serial communication to things like your PC. Many microcontrollers have RX and TX output pins. Here is a image of the max232 adapter I purchased. It has input pins for RX, TX, CT, RT as well as GND and 5v. The RX and TX pins can be directly connected to your PIC.

Now, lets build our own!

First get yourself a RS232 port, you can cut up one of your serial port cords, or buy a port from the store for a dollar or two.

I am going to use a cut serial port cord since it already has leads on it, and is long enough to reach my pc. Use your multi-meter to find the pin numbers, and touch up the wires with solder so they’ll go into your breadboard easily.

Now build the circuit, As you can see, you will need the max232 chip from your local electronics store and a few 1uf capacitors.

Great job, now connect the RX and TX pins to your circuit, and plug the rs232 port directly your pc, or to a usb-to-serial adapter, or even to a bluetooth-to-serial adapter for short range wireless.

I strongly suggest you make this on a PCB with pins that will plug to your breadboard. you’ll use it a lot!

In this image, I did not complete my PIC circuit, but I think you get the idea:

You can use serial_hardware lib or serial_software lib to transmit data to your pc, check for it in the other jallib projects. I suggest the software realterm for sending/receiving data to your PIC

Open Source REALTERM http://realterm.sourceforge.net/

It can be downloaded for free from http://sourceforge.net/projects/realterm/files/

Open the software, click “Port”, choose your speed and port number and press “open”

Hex output

Ascii output

In Circuit Programming

Author: Matthew Schinkel | Jallib Group

Intro to in-circuit programming & ICSP

What is ICSP?

ICSP stands for In-Circuit Serial Programming. More information can be found at http://ww1.microchip.com/downloads/en/DeviceDoc/30277d.pdf

Benefits of ICSP

  1. You may program your PIC while it is in your breadboard circuit
  2. You may program your PIC while it is on a soldered circuit board
  3. You will save time programming so you can write more code faster
  4. You can reset your circuit from your PC
  5. You can program surface mount PIC's that are on soldered circuit board
  6. You won't bend or break any pins
  7. You won't damage your PIC by placing it in your breadboard wrong
  8. With a remote desktop software like VNC, you can program your PIC from anywhere around the world.
  9. I can program my PIC in my living room on my laptop while I watch tv with my wife! (I keep my mess in my office)

Intro to ICSP & in-circuit programming

When I got started in micro-controllers and JAL, I needed to choose a programmer. At the time, I did not know anything about choosing a programmer, so I just went on ebay and bought one that is able to program many different PIC's.

For years, I used this programmer by putting my 16f877 chip into it, programming it, and putting it into my circuit. I broke pins and wasted a lot of time. Little did I know, my programmer has an ICSP output for in-circuit programming. My programmer even says ICSP on it, but I did not know what ICSP is.

Eventually I got sick and tired of moving my micro-controller back and forth from the breadboard to the programmer, and I had herd some talk about ICSP. I found a ICSP circuit on the net, and I took a harder look at my programmer, it has 6 pins sticking up labeled ICSP. However, I did not know what pin was what, they where not marked well, and I could not find info about my programmer. One of the pins was marked pin 1 on the programmer. If you know your ICSP pinouts already, you may skip to the circuit diagram.

I searched for 6-pin ICSP in Google and found that pinouts are different depending on the programmer. So, I took out my volt-meter and logic probe (and oscilloscope, although it is not needed) and measured the voltages off each pin while programming a chip and while not. I could see on the PCB that pin 3 is connected to ground and pin 6 is connected to nothing. Here's what I got:

PIN # While Idle While Programming
1 0v 12v
2 0v 5v
3 0v 0v
4 5v Pulsing 0v to 5v (random)
5 0v Pulsing 0v to 5v (square wave)
6 not connected 0v - can see no connection on PCB

Get the pin names

The pin names for ICSP are VPP1, LOW, DATA, CLK, VCC, GND. So lets match them up:

0v pin 6 must be pin “AUX”, I think this one is actually not connected

0v pin 3 must be pin “GND”

pin 1 is a programming enable pin, VPP1

pin 2 is 5v, mostly used to power a not powered circuit during programming.

pin 4/5 are pulsing pins. They must be “CLK” and “DATA” (you may have to guess which is which if you don't ave a oscilloscope.

Lets make a new chart. I believe most ICSP ports have pins in this order:

PIN # PIN NAME While idle While Programming
1 VPP1 0v 12v
2 VDD 0v 5v
3 GND 0v 0v
4 DATA 5v Pulsing 0v to 5v (random)
5 CLK 0v Pulsing 0v to 5v (square wave)
6 AUX not connected not connected

Build a circuit with ICSP

VDD can be connected to your PIC’s 5v supply (as seen in the schematic below), but many programmers do not need this pin. If you do not need it you can disconnect it. I feel that it is more safe to disconnect it if you are not going to use it. You can test disconnecting this wire after you get ICSP working.

VDD is for power-off programming. Power-off programming does not work in my circuit because there is too much current drain. In my projects, I do use the VCC pin, and I will program my chips while my circuit power supply is ON.

GND must be connected to your circuits ground. Follow this circuit diagram:

Your done! Turn on your power supply and try to program your chip!

File attachments: 

Changelog

Jallib Tutorial Book Changes & Updates

Table 1. Version 0.4 (Release date: To Be Released
Date Comments
2011/05/23 Added print & format library.
2011/05/19 Added FAT32 tutorial
2010/04/22 Fixed English and integrate Youtube flash object in HTML output
2010/04/06 Alphabetical TOC
2010/04/05 Added RC servo & motor speed control tutorial
2010/04/01 Changed hard disk tutorial schematic
2010/03/25 Updated ICSP schematic and tutorial to reflect PIC Kit 2 pinouts. ICSP schematic matches Microchip Specification
2010/03/12 Updated SD Card schematic. Added pull-up resistor on chip-select line, changed resistor values for 5v-3v conversion
Table 2. Version 0.3 (Release Date: 2010/03/12)
Date Comments
2010/01/27 Fixed I²C bus schematic and modified I²C titles
2010/01/21 Added ADC introduction, re-organized PWM tutorials and titles
2010/01/20 Better quality Images on Getting Started, serial board, blink a led tutorials.
2010/01/19 Added serial & rs-232 tutorial
2010/01/15 New ICSP Schematic
Table 3. Version 0.2 (Release date: 2009/12/30)
Date Comments
2009/12/06 Added SD Card tutorial
2009/12/06 Added PATA Hard Disk tutorial
2009/12/06 Added ICSP tutorial
Table 4. Version 0.1 (Release date: 2009/11/22)
Date Comments
2009/11/22 Initial Release