Getting Started with the PICmicro Nigel Gardner Bluebird Electronics Origin of the PIC PIC stands for Programmable Interface Controller and was originally designed in 1978 with an NMOS (power hungry) process by General Instruments as a device to ‘mop up’ external functions for their larger 16 bit microprocessors. A venture capital group bought the rights and Microchip Technology was formed in 1989. The product was converted into CMOS, development tools produced and the product released onto the open market as the first OTP production device. The story from then is reflected by the success of the PICmicro as one of the leading 8-bit microcontroller’s and the range of products being designed and manufactured. Uses The uses of the PIC are extensive but as examples:Consumer - TV/VCR equipment, Stereo receiver, CD player, Remote controls, Cable TV converter, Video games, Camera, Garage opener, Microwave oven, Washer/dryer, Kitchen appliances, Cordless tools, Vacuum cleaner, Electric blanket Automotive - Auto security system, Keyless entry, Radar detector, Cruise control, Anti-lock braking, Speedometer, Climate control, Turn signals, Active suspension, Fuel pump control, Fuel injection, Sun roof control, Air bag sensor, Power seats, Emission control Office Automation Computer mouse, Laptop trackball, Computer keyboard, Handheld scanner, Laser printer interface board, PC LAN system, X/Y plotter, Copier, Bar code reader, Disk drive, Tape back-up unit, Serial bus, Facsimile machine Telecom - Cellular telephone, Cordless telephone, Feature phone, Answering machine, Pay phone, Pager, Modem, Credit card verification Industrial - Motor control, Compressor, Thermostat, Security system, Postage meter, Utility meter, Robotics, Process control, Gas pump, Smoke detector, Carbon Monoxide detector, Electronic highway Advantages of the PIC over other microcontroller’s Low cost and easy to use development tools Extensive range of application notes & code examples No mask charge unless the user moves to a ROM based product Inventory kept to a minimum - the same product could be used for a wide variety of applications Better security than competitors devices Lower operating frequency (to produce same code speed) resulting in lower emitted radio interference Accessible technical support 32-Bit Microchip’s 16-Bit PIC17CXX High-End Family Hitachi H8 Family Motorola 68HC11 Family PIC16CXX Mid-Range Family Intel 80C51 Family PIC16C5X Base-Line Family Motorola 68HC05 Family Zilog Z86CXX Family SGS-Thomson ST6 Family 8-Bit 4-Bit Microchips position in the Microcontroller market ZILOG Z86E04 133 mils MOTOROLA MC68HC705-J1A 93 mils MICROCHIP PIC16C54A 244 mils 68 mils 167 mils 96 mils 32,500 sq. mils; SUR = 5 : 1 15,500 sq. mils; SUR = 2.4 : 1 6,500 sq. mils; SUR = 1 : 1 Die size comparison of some 8 bit microcontrollers Current products - See Microchip’s databook, product selection guide or Web page for full range and availability 16C52, 54, 55, 56, 57, 58 - devices aimed at the low cost end of the market 16C710, 711, 715, 73, 74 - the 7xx range have a/d capability 16C63, 64, 65 - similar to above but without the a/d 16F84 - EEPROM memory for program and non volatile data area 16C621, 622, 623 - brown out (power dip) detect + comparator’s + d/a 12C5xx - 8-pin version of 16C5x series aimed at compact low I/O products 12C67x – 8-pin PICmicro with A/D and EE memory 16C92x – in-built LCD driver 17C4x 17C75x - comparable performance with 68HC11 – non standard pinout 16F87x – flash memory based PICmicro 18Cxxx – latest technology PICmicro’s for high end applications What do I need to start development ? The minimum items required to start PIC development work are :An IBM compatible PC - preferably with Windows A data sheet on the chosen PIC The book - A Beginners Guide to the Microchip PIC MPLAB - free from the Microchip web site If you then wish to take the development from paper to a hardware design, you will need: A programmer - for reliability and support get the PICSTART Plus, which covers all the devices. A development board or hardware starter kit - to save time trying to debug software and hardware. Some EPROM (windowed) versions of the PICmicro’s to be used - say 3 to 5 to save time when they are being erased. An EPROM eraser. If developing with the 16F84 (EEPROM) or flash PICmicro’s, you don't need an eraser as the device is electrically erasable - i.e. no window. Development Path Zero Cost MPLAB - Assembler and Simulator foc from Microchip Web Site http://www.microchip.com Starter PICSTART Plus - Programmer + MPLAB (assembler, simulator, editor) + PIC sample. No trace or emulation function Intermediate Mcrochip ICD – ideal for development with 16F87x devices Serious ICE PIC In Circuit Emulator - allows debugging of hardware and software at same time. You need a programmer to go with the ICE see catalogue for part numbers Advanced C compilers - again see catalogue or Microchip product list for description and order codes. Support Products See Bluebird Electronics website for current range 8/18 pin PICmicro Hardware Starter Kit - PCB, 8 leds, regulator, 4MHz crystal, reset components. 16C55/57 Hardware Starter Kit - PCB, 8 leds, regulator, 4MHz crystal, reset components. Project Board 1 (18 pin PIC's) - PCB, leds, regulator, push buttons, speaker, thermistor, dip switch, PP3 battery holder, 4MHz crystal, reset switch - ideal starter kit for students or engineers. 16C64/74 Hardware Starter Kit - PCB, leds, regulator, push buttons, RS232 interface, EEPROM socket, 200 hole patch area, PIC Soft disk. PIC Converter - A pin conversion adapter to allow 16C63/73 devices (28 pin) to be used with the above 16C64/74 Hardware Starter Kit. PIC Soft - Project board software source code, application source code from Microchip Embedded Control Handbook plus MPLAB PIC in a Box - A complete starter kit for those intending to work with the PIC. PIC in a Box comprises PICSTART Plus, Beginners Guide to the PIC, PIC Cookbook Vol 1, Project Board, PIC Soft with additional projects aimed at the absolute beginner and starter guidance notes. Pointers to get started Start off with a simple program - don’t try to debug 2000 lines of code in one go. Use known working hardware - Bluebird starter kits for example - for the initial design phase to save debug time. Have a few windowed PIC’s to hand when developing to save time waiting for erasure If using the PIC Start (programmer only) you will need to use the program - test modify process - allow extra development time. An ICE will speed up development and save the company money - if an engineer costs his company £200 per day, 3 days wasted trying to sort out a bug without an ICE, and the ICE would have paid for itself, and met a deadline! Use some form of I/O map when starting your design to speed up port identification and function Draw a software functional block diagram to enable modular code writing Comment the software as it’s written. It is meaningless the following day or if read by another Write, test and debug each module stage by stage Update documentation at the end of the process How do I program a PIC ? Run MPLAB software on the PC Power up the programmer Build the project – without errors Set the defaults for product, Watchdog, Oscillator, POR, Brownout and Code Protection Check you have the correct PIC to program Check it’s blank Program Verify Test in the product How much will it cost me ? The programmer - PICSTART Plus Microchip CD ROM A Beginners Guide to the Microchip PIC PIC Cookbook Vol 1 and 2 PIC C an introduction to C on the PIC PIC's - a few windowed devices PIC's - for the finished project - less than 25 ICE PIC in circuit programmer CCS C Compiler circa £125 £19.95 £19.95 £19.95 £12 - £25 each £0.75 - £17 each approx. £550 £99.00 What about PIC designs for manufacture? For those embarking on product development with a deadline or a complicated design for their company, invest in the ICE PIC In Circuit Emulator. It will save time and money in product development and, the engineer from loosing their sanity. The ICE enables the programmer to step through a program, set breakpoints, trace what is happening within the PIC - to list a few of the features. The ICE will pay for itself on the first major project. What happens when my program won't run? Check the following: Has the oscillator configuration been set correctly when you programmed the PIC? Was the watchdog enabled when not catered for in the software? Have all the ports been initialised correctly. On 16C7x devices, check if the ADCON1 register is configured as analog or digital. Ensure the data registers are set to a known condition. Make sure no duplication of names given to variables, registers and labels. Is the reset vector correct, especially if code has been moved from one PIC family to another? Refer to the debug flowchart on page 100 of Beginners Guide to the PIC Microchip Approved Training Workshops Get your project off to a flying start! What are Training Workshops? PIC Training workshops are designed for those who want to know the practical aspects of using the PIC in their product design. Small class sizes (up to a maximum of 8 delegates) ensure individual needs are met. Why a Training Workshop will help your Company Typically an Engineer will spend a few weeks getting a reasonable understanding of a new microcontroller. The time spent on this learning curve is costly for the Company and delays product development. The workshop assists in getting the Engineer over the initial hurdle in a fraction of the time normally taken with the guidance of a Microchip Consultant. In just one day you'll learn... How the PIC operates - internal and external needs Hardware interfacing - the ins and outs Software preparation - flowcharts, code writing, assembler directives Debugging Code - with and without an ICE Development Tools - hands on use of ICE PIC and PICSTART PLUS The EMC directive - software techniques to assist in product reliability How is the day organised? The workshop is in two parts. The morning is spent working through the theoretical aspects of the PIC and product development. Following lunch, the afternoon is allocated to work on customer specific projects. Delegates are encouraged to bring along some hardware from their intended project to help get the project started. Some equipment is provided for project construction, debugging and programming including ICE PIC and PICSTART PLUS development tools for hands on experience. What does each delegate receive? Each delegate will receive a copy of “The Beginners Guide to the Microchip PIC”, 'PIC Cookbook', a PIC Project Board to continue the learning process together with any software developed during the day and some goodies. Where are the Training Workshops held? Workshops are held at Urchfont Manor, Wiltshire, where the isolation from on-site interruptions results in a truly intensive training session. When are the Training Workshops held? Workshops are held on a mutually agreed date giving flexibility in arranging training around staffing levels and project deadlines. How much does a Training Workshop cost? Contact june@bluebird-electronics.co.uk for information. What about large organisations? For larger companies, the Corporate workshop is intended for engineers involved in PIC based projects to work to a common set of standards. It can also form part of an ongoing training package for new members to the engineering department or existing engineers needing an understanding of the products being used by their team. Course content and duration is completely flexible, please call us to discuss your needs. What about large projects If you need to get a large project under way or a number of smaller ones, an extended course is available, covering 2, 3 or 4 days. These extended workshops have proved to be successful for clients needing more than a jump start. Previous clients CAA, British Gas, Scottish Nuclear, Trinity House, Scottish Constabulary, AC Deco, MK Electric, Foxguard, IMI Pactrol, Unitek, Cranfield Institute, Loughborough College, Lancing Linde and Army - Technical Support to list a few. Booking a Training Workshop To book or discuss your training requirements, phone Nigel or June on 01 380 827080. Happy PICing Nigel Gardner - Bluebird Electronics Microchip Registered Consultant and Trainer Tel - 01 380 827080 Fax - 01 380 827082 Email info@bluebird-electronics.co.uk Internet http://www.bluebird-electronics.co.uk