Pic Serial Programmer

  

About the Programmer This is a Simple com port based Microchip PIC microcontroller Programmer,This Programmer is based on JDM programmer.The entire programmer is built around commonly available components Features. Does not support the usb to serial converter. Works with most of PIC mcu. Works with 18F2550 and other 18F series mcu. This project is based on the JDM circuit suggested on for a serial JDM programmer with voltage control. This serial programmer is intended to be used with PICpgm a free and simple PIC Development Programmer Software for Windows and Linux that can be downloaded from here. Supports melabs Serial Programmer only. The current version above is recommended, as it supports more PICmicro MCUs. Download melabs Serial Programmer Software version 3.31 (EXE file, 736K) This installation includes an update for your programmer's firmware (firmware version 3.5). After installation, run the software and select Options More.

RS232 Communication with PIC Microcontroller

Description

This article shows how to do a simple communication via a RS232 interface with a PICmicrocontroller. RS232 is a standard for a serial communication interface which allowsto send and receive data via at least three wires. With the RS232 interface it is possibleto setup a connection between a microcontroller and a PC (via PC's COM port) or betweentwo microcontrollers.

The RS232 interface can be used for many purposes like sending commands from a PC to amicrocontroller, send debug information from a micontroller to a terminal, downloadnew firmware to the microcontroller and many other things.

In this tutorial I will show how to link a PIC microcontroller to a standard PC.On the PC we will use a termial program to send and receive data. Data sent bythe microcontroller will be shown in the terminal window and any key pressed insidethe terminal will send the corresponding key code to the microcontroller.We will use this simple configuration to test and understand the RS232 communication.

Note that modern PCs don't have a serial port so you need to get a USB to serial converter.They are available at low cost.

Block Diagram

The following block diagram shows the whole setup:

Pic

For serial communication the line used to transmit data is called TX and the line used toreceive data is called RX. The level converter is required to translate the voltage levelof the microntroller to RS232 voltage level. The microntroller operates at TTL level(0V = logic 0, +5V logic 1) whereas RS232 uses around +/-12V. A very famous RS232 levelconverter is the MAX232 chip.

Hardware

In the schematic below a PIC microcontroller is connected to the RS232 level converter chip.A PIC18F2620 micocontroller is used, but it will also work with any other microcontrollerwhich has a built-in UART.

Pic serial programmer resume

Schematic

Grizzly honey dab pen user manual. The PIC is running at 10MHz. This will be important later when we configure the baudratefor the serial communication.

Ther RS232 level converter uses the famous MAX232 chip, but any other MAX232 compatible chipwill also work. It just requires 4 capacitors to do its job. These external capacitors arerequired for the charge pump inside the chip which generates the required voltage levels.

The connections on the DB9 connector between pins 1,4,6 and 7,8 are required to satisfythe RS232 hardware handshake signals which we will not use here.

I have developed a RS232 modulewhich allows direct connection to the microcontroller.It consists of a DB9 Female connector, a MAX232 compatible RS232 level converter and thecapacitors. You can find the RS232 module here.

RS232 Cable

To connect the above circuit to the PC we need a RS232 cable. The below picture showsthe necessary connections.

Hardware Picture

Below a picture of the hardware setup. As you can see I have used myPIC16F/18F Experiment Boardand myRS232 Module.

Software

Now since the hardware is ready we have to write the software for the PIC microcontroller.The different compiler vendors provide different ways to setup the UART in the PIC. So I willshow how to use the UART for different compilers.

RS232 communication with CCS C compiler

The CCS C compiler provides a very simple way to do serial communication via RS232. It hidesall the register settings for the user. Only the some parameters have to be provided, therest is done by the compiler. By the way, the CCS C compiler also allows to do RS232 communication viageneral I/O pins, i.e. software based RS232 communication instead of using the built-in UART.That is a really great feature of the CCS C compiler.

Here the code lines which are required to setup the UART for RS232 communication.

As you can see, it is very simple!

The #use delay directive provides the compiler with the information about the clockfrequency at which the PIC is running. We run the PIC at 10MHz with the 4X PLL fuseenabled, hence it is running at 40MHz, so we have to set clock=40000000.

The #use rs232 directive provides the compiler the information about the RS232parameters which shall be used for the communication. It is more or less self explaining:

  • baud=57600: specifies the baud rate for communication, we will use 57600 baud
  • parity=: specifies whether a parity bit shall be used or not, we will not use it, hence we disable it
  • xmit=PIN_C6: specifies the pin to be used for transmission, since we want to use the built-in UART we have to use pin RC6
  • rcv=PIN_C7: specifies the pin to be used for receiption, since we want to use the built-in UART we have to use pin RC7
  • bits=8: specifies the number of bits per transmitted data

To transmit data the following functions can be used:

To receive data the following functions can be used:

Here a simple demo program for the CCS C compiler.Project download link.To run the demo, the HEX file needs to be flashed into the PIC, e.g. withPICPgm Programmer.

RS232 communication with HI-TECH C compiler

To be done ..

PC connection

Now, since we have the required hardware and firmware, we can connect the hardwareto the PC.

To be able to see the data transmitted from the Microcontroller and to send datato the Microcontroller we have to run a terminal program on the PC. There are a lotof terminal programs available. I will show here how to use HyperTerminal whichis included in Microsoft Windows.

Pic Serial Programmer Resume

HyperTerminal Setup

If you are using Windows XP start HyperTerminal.You can find it in the Communication Folder: Start Menu->All Programs->Accessories->Communication.

On startup it will ask for a connection name. Just enter a text which will identifythe connection, e.g. use 'RS232 Demo'. In the next dialog select the COM port where thePIC is connected to.

In the following dialog we have to set the connection properties. Needless to say, the propertieshave to match the settings we are using in the PIC.

Once this is done, just reset the PIC and the demo output shal be visible.

Download

  • Demo project (CCS Compiler): rs232demo_ccs.zip


In-Circuit Serial Programming (ICSP) with the ME Labs Serial
Programmer or U2/USB Programmer

Our programmers may be used for in-circuit serial programming ofserial programmable PIC® MCUs through the 10-pin expansion header J3. TheU2 programming header is detailed below. Our other programmers use thesame header pin-out.

If you're designing a PCB or circuit for ICSP, read the considerationsbelow. At the bottom of this page, you'll find aguide for connecting a board that is already equipped with a 10-pin header thatmatches our programmers. (A LAB-X Experimenter Board, for example.)

PIN#SIGNAL
1+5V always on (It is not recommended that you use this supply to power your target board. Current capability is limited.)
2Programming Voltage (Vpp) - Connect to MCLR/Vpp pin on target device.
3Reserved - do not connect
4Switched Vdd (This pin should not be used to power your target board. It is intended to power a target PICmicro only when one of our programming adapters is used.)
5Reserved - do not connect
6Programming Data - Connect to PGD or ICSPDAT on the target PICmicro
7Reserved - do not connect
8Programming Clock - Connect to PGC or ICSPCLK on the target PIC MCU.
9, 10Ground - A ground connection to your target board is required.
Design considerations for ICSP-capable circuits (Refer to schematicdiagram below.)

1. If possible, dedicate the Programming Clock and Data pins to ICSP. If you must also use these pins for other purposes on your board, some thoughtshould be given to the type of hardware that is connected. The best caseis to use the programming pins for normally-open, pushbutton inputs. Aslong as you don't push the buttons while programming, the switches won't affectthings at all.

If loads are connected to the clock and data lines, they must not interact withthe clock and data signals. Capacitive loads will causeproblems. High-impedance loads are usually ok. LEDs withcurrent-limiting resistors are less desirable, but usually don't cause problems.

You should always prototype and test the ICSP connections before sending yourPCB design out for fabrication. Bios dolphin emulator android.

2.The MCLR pin on the PIC will be driven to approximately 13V duringprogramming. This raises two concerns. The first is that yourcircuit must allow 13V on the pin. Don't connect the pin directly to theVdd rail. The second concern is that the rest of your circuit may need tobe protected from this voltage. If 13V on the MCLR pin might put at riskother components on your board, use a diode in series with the RESET pullup tokeep the 13V off of the Vdd line.

3. Configure MCLR as a RESET pin if possible. Theprogrammer will attempt to reset the target device at the beginning of theprogramming process. If the MCLR pin is configured as an input, theprogrammer may have problems putting the chip into program-mode. This isespecially problematic if the target has been previously programmed and is usingthe programming clock or data lines as outputs.

In some situations, there just aren't enough pins to allow the use of aRESET. Your project will require that MCLR be used as an input. Thisis common on small, 8-pin PIC MCUs. In these cases, it helps toset the clock and data pins to inputs and place a delay at the beginning of yourcode. This will allow you to cycle power to the part and start theprogramming process while the pause is executing.

In a PICBASIC PRO program intended for the PIC12F675, you might start with:

TRISIO = $FF ' set all pins to inputs
PAUSE 1000 ' wait a second

This can make reprogramming much easier to accomplish when the programmer hasno means to reset the target device.

Pic Serial Programmer App

4.Make sure the 'low-voltage programming' pin is pulled to ground. Low-voltage programming is not used by melabs programmers and should always bedisabled in the configuration settings. Even so, the low-voltageprogramming pin (labeled PGM or LVP) should be pulled to ground whenprogramming. If it is left floating or in a high condition, it mayinterfere with the programming process. We use a 100K resistor to pull thepin low when designing a board for ICSP. For most 16F series parts, RB3doubles as the PGM pin. On 18F series, it is usually RB5 that needs to below. Notable exceptions are the 16F62x and 16F64x family, which need RB4 to be pulled low.

5. Always connect every available power pin to the appropriate power orground source. Many PIC devices have multiple pins that are labeled Vdd,Vss, AVdd, and AVss. If even one of these pins is left unconnected, it mayresult in programming errors. This applies to analog supply pins even ifyou don't plan to use the analog functions.

6.Use bypass capacitors between Vdd and Vss. This is goodpractice in any case, but it's especially important for ICSP. A single capacitorof 0.1uF is the minimum recommended, but more is the norm.

7.Connect a 5V supply to the Vdd pins on the PIC. You cando this with the normal power supply on your board or with an externalsupply. The ICSP header on the programmer has a 5V pin (pin-1) that can beused, but only if your board doesn't consume too much power. The Vdd pin(pin-4) on the header shouldn't be used. Such use will probably causeerrors during programming, and it's possible that it will damage the programmerhardware.

If your board is designed to run at a lower supply voltage like 3.3V and youcan't safely connect 5V to the PIC, you may have issues when erasing a flashPIC. For some devices, a low-voltage erase option is available (Options> More Options in the meProg software). Do not enable low-voltageprogramming in the configuration settings! This setting has nothing to do with thesupply voltage for the PIC.

Some of the new PIC microcontrollers cannot by powered at 5V. Theseparts usually require additional circuitry for in-circuit programming. Seethe following link for details: PIC18FxxJ,PIC18FxxK, PIC24xJ, and dsPIC33FJ 3.3 Volt Programming Information

Note for PIC17C7xx: These(practically obsolete) devices mayalso be programmed in-circuit. However, different pins are required than aredetailed here. See the Microchip programming spec on these devices for more information.

The following schematic shows a typical ICSP connection for thePIC16F876A

Connecting a programmer to a LAB-X board forin-circuit serial programming

Install the programming software according to the instructions included with yourprogrammer.

Connect your programmer to the LAB-X board using a 10-pin ribbon cable(part# 10CAB). Do not twist or fold the cable to make the connection. Theconnectors on the programmer and LAB-X boards should line up to allow a straightconnection.

If your LAB-X board has a ZIF socket, raise the lever. Insert themicrocontroller into the socket on the LAB-X board and lower the lever to lockit into place. Make sure that the notch on the end of the microcontroller isaligned with the lever end of the socket.

Pic Serial Programmer Circuit

If your LAB-X board does not have a ZIF socket, carefully line up thePICmicro microcontroller's pins with the holes in the socket and press it intoplace. Make sure the notch on the end of the microcontroller is aligned with thenotch at the end of the socket.

Connect a 16VDC adapter (part# ACAD) to the programmer's power jack (notrequired for USB/U2 Programmer). You may havedifferent adapters for the programmer and LAB-X board. Make sure you power theprogrammer with the 16V adapter.

Connect a 12VDC adapter (part# ACADX) to the LAB-X power jack. You mustconnect power to the LAB-X board in order to program the microcontroller.

Run the programmer software on your computer and use the programmingprocedure to program the part.*

*The LED indicator on the EPIC willremain lit at half intensity when the EPIC is connected to the LAB-X board. Theindicator should light fully when a programming operation is in progress.