M PICDEMTM MSC1 USER'S GUIDE 2001 Microchip Technology Inc. DS41178A Note the following details of the code protection feature on PICmicro(R) MCUs. * * * * * * The PICmicro family meets the specifications contained in the Microchip Data Sheet. Microchip believes that its family of PICmicro microcontrollers is one of the most secure products of its kind on the market today, when used in the intended manner and under normal conditions. There are dishonest and possibly illegal methods used to breach the code protection feature. All of these methods, to our knowledge, require using the PICmicro microcontroller in a manner outside the operating specifications contained in the data sheet. The person doing so may be engaged in theft of intellectual property. Microchip is willing to work with the customer who is concerned about the integrity of their code. Neither Microchip nor any other semiconductor manufacturer can guarantee the security of their code. Code protection does not mean that we are guaranteeing the product as "unbreakable". Code protection is constantly evolving. We at Microchip are committed to continuously improving the code protection features of our product. If you have any further questions about this matter, please contact the local sales office nearest to you. Information contained in this publication regarding device applications and the like is intended through suggestion only and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. No representation or warranty is given and no liability is assumed by Microchip Technology Incorporated with respect to the accuracy or use of such information, or infringement of patents or other intellectual property rights arising from such use or otherwise. Use of Microchip's products as critical components in life support systems is not authorized except with express written approval by Microchip. No licenses are conveyed, implicitly or otherwise, under any intellectual property rights. Trademarks The Microchip name and logo, the Microchip logo, FilterLab, KEELOQ, MPLAB, PIC, PICmicro, PICMASTER, PICSTART, PRO MATE, SEEVAL and The Embedded Control Solutions Company are registered trademarks of Microchip Technology Incorporated in the U.S.A. and other countries. dsPIC, ECONOMONITOR, FanSense, FlexROM, fuzzyLAB, In-Circuit Serial Programming, ICSP, ICEPIC, microID, microPort, Migratable Memory, MPASM, MPLIB, MPLINK, MPSIM, MXDEV, PICC, PICDEM, PICDEM.net, rfPIC, Select Mode and Total Endurance are trademarks of Microchip Technology Incorporated in the U.S.A. Serialized Quick Turn Programming (SQTP) is a service mark of Microchip Technology Incorporated in the U.S.A. All other trademarks mentioned herein are property of their respective companies. (c) 2001, Microchip Technology Incorporated, Printed in the U.S.A., All Rights Reserved. Printed on recycled paper. Microchip received QS-9000 quality system certification for its worldwide headquarters, design and wafer fabrication facilities in Chandler and Tempe, Arizona in July 1999. The Company's quality system processes and procedures are QS-9000 compliant for its PICmicro(R) 8-bit MCUs, KEELOQ(R) code hopping devices, Serial EEPROMs and microperipheral products. In addition, Microchip's quality system for the design and manufacture of development systems is ISO 9001 certified. DS41178A 2001 Microchip Technology Inc. 12 PICDEMTM MSC1 USER'S GUIDE Table of Contents Preface Chapter 1. Overview and Installation 1.1 Introduction ..................................................................................... 5 1.2 Highlights ........................................................................................ 5 1.3 Unpacking Your PICDEMTM MSC1 ................................................. 5 1.4 Installing the Hardware ................................................................... 6 1.5 Installing the GUI Software ............................................................. 7 1.6 What the PICDEMTM MSC1 Is ........................................................ 7 Chapter 2. Basic Functions 2.1 Starting Communications with the Evaluation Tool ........................ 9 Chapter 3. Tutorial/Demo 3.1 Digital-to-Analog (DAC) Module Configuration ............................. 23 Appendix A. PICDEMTM MSC1 Schematics A.1 Introduction ................................................................................... 35 A.2 Highlights ...................................................................................... 35 A.3 Schematics ................................................................................... 36 Index ......................................................................................................... 39 Worldwide Sales and Service................................................................. 40 2001 Microchip Technology Inc. DS41178A-page iii PICDEMTM MSC1 USER'S GUIDE NOTES: DS41178A-iv 2001 Microchip Technology Inc. 12 PICDEMTM MSC1 USER'S GUIDE Preface Introduction This chapter contains general information about this manual and contacting customer support. Highlights Topics covered in this chapter: * About this Guide * Warranty Registration * Recommended Reading * The Microchip Internet Web Site * Development Systems Customer Notification Service * Customer Support About This Guide Document Layout This document describes how to install a PICDEMTM MSC1 (Mixed Signal Controller1) on a PC and load the GUI software as a development tool for creating the initialization assembly code for your PIC16C781/782 application. The PICDEMTM MSC1 is the tradename for the PIC16C781/782 Microcontroller Evaluation Tool described in this manual. The manual layout is as follows: * Chapter 1: Overview and Installation - What the PICDEMTM MSC1 is and how to install it. * Chapter 2: Basic Functions - Describes how to get started using the PICDEMTM MSC1 and how to access the basic functions using the GUI software. * Chapter 3: Tutorial/Demo - Provides an example of how you can configure a typical peripheral using the PICDEMTM MSC1 and create the initialization assembly code corresponding to your configuration. * Appendix A: Schematics - Provides the schematics and board layout for the PICDEMTM MSC1. * PICDEMTM MSC1 Worldwide Sales and Service - Lists Microchip sales and service locations and telephone numbers worldwide. 2001 Microchip Technology Inc. DS41178A-page 1 PICDEMTM MSC1 User's Guide Updates All documentation becomes dated, and this user's guide is no exception. Since the PICDEMTM MSC1 and other Microchip tools are constantly evolving to meet customer needs, please refer to our web site at http:// www.microchip.com to obtain the latest documentation available. Warranty Registration Please complete the enclosed Warranty Registration Card and mail it promptly. Sending in your Warranty Registration Card entitles you to receive new product updates. Interim software releases are available at the Microchip web site. Recommended Reading This user's guide describes how to use the PICDEMTM MSC1. The data sheets contain current information on programming the specific microcontroller devices. README.TXT For the latest information on using PICDEMTM MSC1, read the README.txt file (ASCII text file) included with the PICDEMTM MSC1 software. The README.txt file contains update information that may not be included in this document. MPLAB(R) IDE User's Guide (DS51025) Comprehensive guide that describes installation and features of Microchip's MPLAB Integrated Development Environment (IDE), as well as the editor and simulator functions in the MPLAB environment. MPASMTM User's Guide with MPLINKTM & MPLIBTM (DS33014) Describes how to use Microchip Universal PICmicro(R) Microcontroller Assembler (MPASM), Linker (MPLINK), and Librarian (MPLIB). Technical Library CD-ROM (DS00161) This CD-ROM contains comprehensive data sheets for Microchip PICmicro(R) MCU devices available at the time of print. To obtain this CD-ROM, contact the nearest Microchip Sales and Service location (see back page) or download individual data sheet files from the Microchip web site (http:// www.microchip.com). PICmicro Mid-Range MCU Family Reference Manual (DS33023) This manual explains the general details and operation of the MCU family architecture and peripheral modules. It is designed to complement the device data sheets. DS41178A-page 2 2001 Microchip Technology Inc. Preface Microsoft(R) Windows(R) Manuals This manual assumes that users are familiar with Microsoft Windows operating system. Many excellent references exist for this software program, and should be consulted for general operation of Windows. PIC16C781/782 Data Sheet (DS41171) This book contains details about the PIC16C781/782 Microcontroller and more. The Microchip Internet Web Site Microchip provides online support on the Microchip World Wide Web (WWW) site. The web site is used by Microchip as a means to make files and information easily available to customers. To view the site, the user must have access to the Internet and a web browser, such as Netscape(R) Communicator or Microsoft(R) Internet Explorer(R). Files are also available for FTP download from our FTP site. Connecting to the Microchip Internet Website The Microchip web site is available by using your favorite Internet browser. Visit: http://www.microchip.com The file transfer site is available by using an FTP program/client to connect to: ftp://ftp.microchip.com Development Systems Customer Notification Service Microchip started the customer notification service to help our customers keep current on Microchip products with the least amount of effort. Once you subscribe to one of our list servers, you will receive e-mail notification whenever we change, update, revise or have errata related to that product family or development tool. See the Microchip web page at http://www.microchip.com for other Microchip list servers. The Development Systems list names are: * Compilers * Emulators * Programmers * MPLAB * Otools (other tools) 2001 Microchip Technology Inc. DS41178A-page 3 PICDEMTM MSC1 User's Guide Once you have determined the names of the lists that you are interested in, you can subscribe by sending a message to: listserv@mail.microchip.com with the following as the body: subscribe yourname Here is an example: subscribe programmers John Doe To UNSUBSCRIBE from these lists, send a message to: listserv@mail.microchip.com with the following as the body: unsubscribe yourname Here is an example: unsubscribe programmers John Doe The following sections provide descriptions of the available Development Systems lists. Customer Support Users of Microchip products can receive assistance through several channels: * Distributor * Local Sales Office * Field Application Engineer (FAE) * Corporate Applications Engineer (CAE) * Systems Information Upgrade Hotline Technical Support can be obtained through your local FAE or CAE. CAEs may be contacted at (480) 792-7627. Contact the Sales office for prices and literature requests. Sales offices are listed on the back cover of this User Guide. In addition, there is a Systems Information and Upgrade Line. This line provides system users a listing of the latest versions of all of Microchip's development systems software products. Plus, this line provides information on how customers can receive any currently available upgrade kits. The Hotline Numbers are: 1-800-755-2345 for U.S. and most of Canada, and 1-480-792-7302 for the rest of the world. DS41178A-page 4 2001 Microchip Technology Inc. 12 PICDEMTM MSC1 USER'S GUIDE Chapter 1. Overview and Installation 1.1 Introduction The PICDEMTM MSC1 with its PC-based Graphical User Interface (GUI) software serves as a stand-alone development and evaluation tool for the PIC16C781/782 Microcontrollers, or as a user interface to the peripherals. 1.2 Highlights The topics covered in this chapter are: * Unpacking your PICDEMTM MSC1 hardware and software * Installing the hardware * Installing the GUI software * What the PICDEMTM MSC1 is * How the PICDEMTM MSC1 helps the Developer 1.3 Unpacking Your PICDEMTM MSC1 1.3.1 Supplied Items The items contained in your PICmicro box are: * PICDEMTM MSC1 Circuit Board with a programmed PIC16C782 installed * PIC16C781/782 Data Sheet (DS41171) * CD-ROM containing: GUI software, User's Guide, Board Schematics, Monitor Firmware, Example Arbitrary Waveform * Assorted jumpers 1.3.2 Required Items The items required are: * PC running Windows 95 or newer operating system * 9 VDC Power Supply * 9-pin RS-232 Cable 2001 Microchip Technology Inc. DS41178A-page 5 PICDEMTM MSC1 User's Guide 1.4 Installing the Hardware Perform the following procedure to install the PICDEMTM MSC1 hardware: 1. Connect the PICDEMTM MSC1 circuit board to the 9 VDC Power Supply as shown in the Figure 1.1 and plug in the AC connector for the 9 VDC Power Supply. PICDEMTM MSC1 Circuit Board RS-232 connector RS-232 cable To PC Serial Port AVDD LED VDD LED 9 VDC Power Connector 9 VDC Power Supply AC Power Figure 1.1: Installing the Hardware 2. Connect one end of the RS-232 cable to the Serial Port of your PC. 3. Connect the other end of the RS-232 cable to the PICDEMTM MSC1 circuit board as shown in Figure 1.1. This completes the hardware installation. Note: DS41178A-page 6 The AVDD LED and the VDD LED should be lit, indicating the Analog and Digital Power Supplies are operating. 2001 Microchip Technology Inc. Overview and Installation 1.5 Installing the GUI Software The GUI software adheres to standard Windows(R) conventions and should be easy to install for anyone familiar with other Windows applications. Perform the following procedure to install the GUI software: 1. Insert the CD containing the GUI software into your PC. Locate and double-click on the setup.exe file in the CD Root Directory. An Installation Wizard will guide you through the installation process. 2. Follow the instructions in the Installation Wizard. The installation creates an entry in the Start Programs group. The Wizard will also create a PICDEMTM MSC1 icon for your desktop. 3. You can start the GUI software by using the Start Programs PICDEMTM MCS1 sequence. 1.6 What the PICDEMTM MSC1 Is The Evaluation Tool is comprised of: * Printed circuit board * PC based GUI * UV erasable PIC16C782 with monitor firmware * 9V power supply (IEC) * RS-232C cable (9-pin) * General purpose jumper wires In stand-alone mode, the GUI is useful for discovering the features of all the PIC16C781/782 peripherals and identifying which registers are affected by the different configurations. When used in conjunction with the evaluation board, the GUI gives instant access to the PIC16C781/782 peripherals allowing on-the-fly configuration changes by means of an RS-232 link between a PC and the evaluation board. The GUI includes a Code Generator that can build the initialization assembly code that corresponds to the selected configuration. Developers can use the Code Generator to perform an entire configuration using the Evaluation Tool and save it as a disk file. The firmware of the PICDEMTM MSC1 allows you to: * Configure the inputs and outputs of each peripheral module using your application parameters * Configure the operation of each peripheral module * Load and view the contents of the Special Purpose Registers needed to run your application * Operate a dynamic conversion loop for scoping the Output of the DAC Module * Save the configuration file that you have created and insert it into your application software. 2001 Microchip Technology Inc. DS41178A-page 7 PICDEMTM MSC1 User's Guide NOTES: DS41178A-page 8 2001 Microchip Technology Inc. 12 PICDEMTM MSC1 User's Guide Chapter 2. Basic Functions 2.1 Starting Communications with the Evaluation Tool 2.1.1 Introduction Start the GUI software by selecting StartPrograms PICDEM MSC1, or you can double-click the PICDEM MSC1 program icon on your desktop. The GUI Control Panel displays, as shown in Figure 2.1. 2.1.2 Using the GUI Control Panel Features Global to All Peripherals Figure 2.1: PICDEMTM MSC1 Control Panel 2001 Microchip Technology Inc. DS41178A-page 9 PICDEMTM MSC1 User's Guide Port Selection Communications port selection is not automatic, so you need to make the communications port selection with the OptionsCommunications Setup pull-down menu option (see Figure 2.2) before attempting to connect to the Evaluation Board. Figure 2.2: Communications Setup Select the Communications Port that matches the one you are using for the serial communications with the Evaluation Board, as shown in Figure 2.3. Figure 2.3: Communications Port Selection Menu DS41178A-page 10 2001 Microchip Technology Inc. Basic Functions Starting Communications Select the Pull-down menu OptionsEnable Eval Board to begin communications between the GUI Control Panel and the PICDEMTM MSC1, as shown in Figure 2.4. Figure 2.4: Enable Evaluation Board Select the Input/Output tab and note the Port A and Port B functions to verify that the GUI is communicating with the Evaluation Board. Note: The MCLR function in Port A and the Dgtl Out: RB4 and DGtl In: RB5 functions are shown in gray when the GUI software is initially communicating with the Evaluation Board. Serial Communications with the PICDEMTM MSC1 Evaluation Board Since the PIC16C781/782 does not have a UART peripheral, serial communications are "bit-banged" with software timing loops. Timing calibration is performed automatically each time the board is enabled. The Evaluation Board clock is the internal RC oscillator. One characteristic of this oscillator is that it may drift slightly in frequency with changes in temperature. If you expect to use the Evaluation Board over a wide temperature variation, you will need to recalibrate the communication timing at each new operating temperature. You can recalibrate at any time by de-selecting the PICDEM MSC1 board by selecting OptionsEnable Eval Board, then selecting OptionsEnable Eval Board a second time to recalibrate and re-establish communications. When the connection is made, all registers will be initialized to the values set in the GUI. This procedure of disconnecting, then reconnecting, is also useful if you accidentally RESET the PIC16C781/782 with a stray probe or ground strap. PERIPHERAL ORGANIZATION The PIC16C781/782 peripherals are organized as tabbed pages (see Figure 2.1), one for each major peripheral function. These include: * Input/Output * Analog-to-Digital Converter (ADC) * Digital-to-Analog Converter (DAC) * Comparators and Operational Amplifier * Programmable Switch Mode Controller (PSMC) 2001 Microchip Technology Inc. DS41178A-page 11 PICDEMTM MSC1 User's Guide * Timers * Memory Access When a configuration change is made, the register(s) affected by the change will turn red, calling attention to where the changes occurred. Register values cannot be entered directly. However, when the Evaluation Board is active, register values may be retrieved from the Evaluation Board by double-clicking on the register name. The register font color changes to blue in response. Changing the Default Font In some cases, the default font will not fit in the Register Display boxes. You can change the font selection and size with the Options->Data Font menu option, as shown in Figure 2.5. Figure 2.5: Data Font Selection The best results will be obtained by choosing a scalable fixed-spacing font such as Courier New. Some controls of the GUI are interlocked so that a change to one selection automatically selects other controls necessary for the proper operation of the selected item. For example, selecting PORTA RA0 as the non-inverting Op Amp input automatically selects RA1 as the inverting input and RB3 as the Op Amp output. Special Conventions A special convention pertains to the following edit boxes: * PORTA * PORTB * Timer0 * Timer1 * Memory Address * Memory Data When typing in one of these boxes, the font color changes to red, indicating that the entry is local only to that box. When the key is pressed, the entry in the box is sent to the corresponding register and the font color reverts to black. If focus (i.e., clicking outside the box) is moved outside of the edit box before the key is pressed, the box is restored to its original con- DS41178A-page 12 2001 Microchip Technology Inc. Basic Functions tents and no action is taken. When the GUI is actively connected to the Evaluation Board, entries are instantly and automatically sent to the PIC16C782. GLOBAL ITEMS Items that are global to all the peripherals are located in the GUI outside of the tabbed pages (see Figure 2.1). Global items include: * Special Function Registers * Internal Voltage Reference Control (VR) * Display Mode Selection (Binary or HEX) * Pull-Down Menus * Edit Boxes for the AVDD and VREF1 voltages Note: The AVDD and VREF1 entries are used to compute some of the display values for the ADC and DAC peripherals, and have no other effects. If these inputs are known to be different than the values shown, enter the correct values. File Menu Functions Click on the File menu to view the options, as shown in Figure 2.6. Figure 2.6: File Menu Options Except for the Generate Code option, the options on the File Menu are standard Microsoft Windows functions: * Open... - allows you to open a previously saved version of the PICDEM MSC1 GUI configuration with all the parameters and data to use as a starting point for a new configuration. * Save - allows you to capture and save the GUI information and configuration data as a file. * Save As... - same as Save, but allows you to change the name of the file saved. * Generate Code... - Creates an Initialization assembly code file that corresponds to the selected configuration. * Exit - Closes and terminates the program. 2001 Microchip Technology Inc. DS41178A-page 13 PICDEMTM MSC1 User's Guide 2.1.2.1 Input/Output Use the Input/Output tab to configure the Port A and B functions, as shown in Figure 2.7. Some of the Port pins can be mixed signal (i.e., they can be either digital or analog). I/O functions are fully described in Section 3.0 of the PIC16C781/782 Data Sheet (DS41171). Use drop-down menu to configure Port bit functions. Register values are Read Only. Double-click on register name to read value from PICDEM MSC1 board. Figure 2.7: Input/Output Functions DS41178A-page 14 2001 Microchip Technology Inc. Basic Functions 2.1.2.2 Analog-to-Digital Converter (ADC) Use the ADC tab to configure the 10 inputs (shown in the ADC Input Select area) to the Analog to Digital Converter, as shown in Figure 2.8. The ADC allows conversion of an analog input signal to a corresponding 8-bit digital value. ADC functions are fully described in Section 9.0 of the PIC16C781/782 Data Sheet (DS41171). Names change to correspond with selected pin function Read ADC Continuous Mode checkbox(1) single ADC read button ADC - Internal RC clock source - Required when performing ADC conversions during SLEEP Mode Note 1: When the Read ADC Continuous Mode is checked, ADC readings are automatically updated about 10 times per second. Figure 2.8: Analog-to-Digital Converter Peripheral (ADC) Functions 2001 Microchip Technology Inc. DS41178A-page 15 PICDEMTM MSC1 User's Guide 2.1.2.3 Digital-to-Analog Converter (DAC) Use the DAC tab to configure the Digital to Analog Converter (DAC) module, as shown in Figure 2.9. The DAC module generates an output voltage proportional to the value in the 8-bit DAC Register. DAC functions are fully described in Section 10.0 of the PIC16C781/782 Data Sheet (DS41171). Change DAC Output by moving slider or by entering desired value in Output text box Figure 2.9: Digital-to-Analog (DAC) Peripheral Functions DS41178A-page 16 2001 Microchip Technology Inc. Basic Functions ARBITRARY WAVEFORM The DAC Arbitrary Waveform function is a utility that provides for sending a set of user-defined data bytes to the DAC one byte at a time, with a userdefined dwell time between each byte. The data set must consist of 2 to 80 bytes. The dwell time is determined by waiting a user-defined number of timer0 count intervals. The utility computes dwell time as a function of : * Timer0 clock * Timer0 prescale * Number of points in the waveform * User-defined waveform period or frequency parameter. Timer0 counts must be between 2 and 255. Adjust the paramaters to ensure the count is within these limits. The period of the waveform is defined as the time required for all the waveform points to be output. Two types of waveforms can be computed by the utility: 1. A sine wave (see Figure 2.10) 2. A triangle wave (see Figure 2.11) An unlimited number of other waveforms can be generated external to the utility and saved as a text file, which the utility can retrieve. Each point of the waveform is represented as an integer between 0 and 255. The set of points is saved as a text file with one integer per line. If the waveform file contains more than 80 integers, the Arbitrary Waveform utility accepts only the first 80. The DAC data is displayed in the preview window when the waveform is generated or loaded from a file. Two waveform periods are displayed, so that unexpected discontinuities between the last and first data bytes can be identified. The preview window displays the waveform in an unsmoothed format that represents the expected DAC output. Figures 2.10 and 2.11 show examples of utility generated sine and triangle waveforms respectively. 2001 Microchip Technology Inc. DS41178A-page 17 PICDEMTM MSC1 User's Guide (Up to 80 max) The more points sampled, the smoother the waveform Frequency Divider for Timer0/WDT Timer Counts must be between 2 and 255 Figure 2.10: Sine Wave Example (Up to 80 max) Frequency Divider for Timer0/WDT Output of DAC waveform will resemble this stepped pattern on a scope Figure 2.11: Triangle Waveform Example DS41178A-page 18 2001 Microchip Technology Inc. Basic Functions 2.1.2.4 Comparators/Op Amp Use the Comparators/Op Amp tab to configure the two separate voltage comparators, C1 and C2, as shown in Figure 2.12. Internal voltage reference is provided by the VDAC option for both comparators. An external voltage reference can be supplied to C1 via the AN3/VREF input and the AN2/VREF2 input for C2. You can also use the same tab to configure the Operational Amplifier (OPA) module. The Comparator Module functions are fully described in Section 12.0 of the PIC16C781/782 Data Sheet. The Operational Amplifier (OPA) Module is fully described in Section 11.0 of the PIC16C781/782 Data Sheet (DS41171). Calibrate function is enabled only when PICDEM MSC1 board is active Enabling the Op Amp automatically configures the GUI I/O pin functions. Figure 2.12: Comparators/Op Amp Peripheral Functions 2001 Microchip Technology Inc. DS41178A-page 19 PICDEMTM MSC1 User's Guide 2.1.2.5 Programmable Switch Mode Controller (PSMC) Use the PSMC tab to configure the PSMC module, as shown in Figure 2.13. This module provides all the necessary features to implement a pulsed feedback control system. The PSMC generates a pulsed output based on its analog feedback. The Programmable Switch Mode Controller (PSMC) is fully described in Section 13.0 of the PIC16C781/782 Data Sheet (DS41171). Enabling the PSMC automatically configures the GUI I/O pin functions Figure 2.13: PSMC Peripheral Functions DS41178A-page 20 2001 Microchip Technology Inc. Basic Functions 2.1.2.6 Timers Use the Timers tab to configure Timer0 and Timer1, as shown in Figure 2.14. Timer0 can operate as either a timer or a counter. The Timer0 Module is described in Section 5.0 of the PIC16C781/782 Data Sheet (DS41171). The Timer1 module is fully described in Section 6.0 of the PIC16C781/782 Data Sheet (DS41171). Internal External Figure 2.14: Timers / Peripheral Functions 2001 Microchip Technology Inc. DS41178A-page 21 PICDEMTM MSC1 User's Guide 2.1.2.7 Memory Use the Memory tab to access Data or Program Memory, as shown in Figure 2.15. The Memory tab also contains the Configuration Word functions which may be changed only when communications between the GUI and the PICDEMTM MSCI Board have been turned off. Memory Organization is fully described in Section 2.0 of the PIC16C781/782 Data Sheet (DS41171). Program Memory Read (PMR) is fully described in Section 4.0 of the PIC16C781/782 Data Sheet (DS41171). Oscillator Configuration is fully described in Section 14.2 of the PIC16C781/ 782 Data Sheet (DS41171). The Brown Out Threshold Voltages are fully described in Section 17.7.4 of the PIC16C781/782 Data Sheet (DS41171). The Configuration bits are fully described in Section 14.1 of the PIC16C781/ 782 Data Sheet (DS41171). Configuration Setup Tool Area Figure 2.15: Memory Functions Note: DS41178A-page 22 The Configuration Word Setup Tool Area in the GUI is active only when the communications with the Evaluation Board have been turned off. The Configuration Word does not affect the PICDEM MSC1 board configuration. The Configuration Word is used at the beginning of Code files. 2001 Microchip Technology Inc. 12 3.1 PICDEMTM MSC1 User's Guide Chapter 3. Tutorial/Demo Digital-to-Analog (DAC) Module Configuration 3.1.1 DAC Module Setup In this project you will configure a digital-to-analog conversion that requires stepping through a series of digital values to produce an analog sine wave output. You can utilize the Arbitrary Waveform feature of the PICDEMTM MSC1 to set up the conversion parameters and exercise them in a looping environment to allow scoping the output of the DAC. In this example, you will perform the setup tasks to: * Configure a single digital input/output line * Exercise a conversion loop to allow scoping of the DAC output * Save the configuration file to be used in your application. 3.1.1.1 Enabling the DAC Module 1. Start the GUI software by selecting StartProgramsPICDEM MSC1, or you can double-click the PICDEM MSC1 icon on your desktop. 2. Select the Pull-down menu OptionsEnable Eval Board to begin communications between the GUI Control Panel and the PICDEMTM MSC1. 3. Select the Input/Output tab on the GUI Control Panel, as shown in Figure 3.1. 2001 Microchip Technology Inc. DS41178A-page 23 PICDEMTM MSC1 User's Guide Figure 3.1: Selecting the Input/Output Tab 4. Using the drop-down menu of RB1, select the Anlg Out:VDAC option and press , as shown in Figure 3.2. Figure 3.2: Enabling the VDAC Output 5. Select the DAC tab on the Evaluation Tool Control Panel. The Control Panel displays the DAC controls, as shown in Figure 3.3. Note the DAC output is shown enabled. DS41178A-page 24 2001 Microchip Technology Inc. Tutorial/Demo DAC module enable DACON0 shows DAC Output enabled DAC output enable Arbitrary Waveform button Figure 3.3: DAC Setup Initial Display The DAC module is controlled by means of four Special Function registers: * DACON0 * DAC * TRISB * ANSEL. The DACON0 register controls three items: * Enable/disable the DAC * Enable DAC output on RB1/AN5/VDAC pins (providing ANSEL<5>=1 and TRISB<1>=1) * Selection of reference voltage. The DAC register holds the digital value to be converted to analog output. Note: DACON0 register shows all zeros before the DAC is enabled and configured. The TRISB and the ANSEL registers are the primary controls for the configuration of PORTB pins. 2001 Microchip Technology Inc. DS41178A-page 25 PICDEMTM MSC1 User's Guide The Evaluation Board software has built-in safeguards against performing certain functions out of sequence, or executing functions with missing parameters. For example, if you were to click the Arbitrary Waveform button (shown above) at this point in the configuration, you see the following warning message, shown in Figure 3.2: Figure 3.4: DAC Warning This message informs you that the Arbitrary Waveform will not display on the DAC output pin unless the DAC output has been enabled, the DAC module is turned on, and the timer source is defined as either internal or, if external, supplied via jumpering to the clock source input pin. You can ignore the warning and continue with your configuration by clicking OK, but the output waveform will not be available if you have not satisfied the conditions mentioned in the warning message. 6. Enable the DAC module by clicking the DAC ON radio button. The Control Panel changes to appear as shown in Figure 3.3. DS41178A-page 26 2001 Microchip Technology Inc. Tutorial/Demo DAC module is enabled DACON0 shows (in red) DAC module enabled and DAC output is enabled DAC output to RB1 is enabled Figure 3.5: Enabling the DAC Module and Output 7. Select the Timer tab on the Evaluation Board Control Panel. The Timer0 and Timer1 controls display as shown in Figure 3.4. For this example, we will use the internal clock function, FOSC/4 as the clock source for Timer0. 2001 Microchip Technology Inc. DS41178A-page 27 PICDEMTM MSC1 User's Guide Set clock source to FOSC/4 Note Option_Reg changes value when clock source changes Figure 3.6: Clock Source Selection 8. Select FOSC/4 as the source for the internal clock. Note: Bit 5 of the OPTION_REG is set to a zero, indicating the Internal instruction cycle clock (FOSC/4) has been selected. See the PIC16C781/782 Data Sheet (DS41171) for Option Register details. 3.1.1.2 Using the Arbitrary Waveform Feature The PICDEMTM MSC1 GUI contains an Arbitrary Waveform feature that can be used for testing the DAC peripheral. This feature allows you to generate sinusoid or triangle wave data to upload to the DAC. You can also load a wave data file previously generated and saved as a text file. Wave data files consist of integers between 0 and 255, one integer per line. Each line corresponds to a waveform data point. Up to 80 points can be specified. If more than 80 points are in the file, only the first 80 will be used. Less than 80 points will automatically RESET the point counter to the number of points specified in the file. An example waveform file (ArbWave.txt) is included in the installation directory. 9. Select the Arbitrary Waveform button on the DAC control section of the Control Panel. The Arbitrary Waveform dialog box displays, as shown in Figure 3.5. DS41178A-page 28 2001 Microchip Technology Inc. Tutorial/Demo Sine waveform button waveform sampling parameters Figure 3.7: Arbitrary Waveform Dialog Box 10. Select the Sine waveform button. The following waveform representing two periods of a sine wave is displayed, as shown in Figure 3.6: Figure 3.8: Sine Waveform Selected 11. Select the GO button. The following message appears, as shown in Figure 3.7: 2001 Microchip Technology Inc. DS41178A-page 29 PICDEMTM MSC1 User's Guide Figure 3.9: Adjust Prescale Message Note: When you change the Prescale setting, the Timer Count changes to a new value. The timer counts parameter is Read Only. Timer Counts are automatically computed as a function of Timer0 frequency, number of points, period (or frequency), and prescaler value. You can decrease the Timer Count by increasing the prescale ratio. 12. Set the Prescale ratio to 1:4. This will bring the Timer Count down to 250, as shown in Figure 3.8. Set Prescale to 1:4 to change Line Count to 250 Figure 3.10: Setting the Prescaler 13. Click the GO button to start the DAC output loop execution. The GO button changes to STOP. DS41178A-page 30 2001 Microchip Technology Inc. Tutorial/Demo Note: The Prescale values are grayed out when the timing loop is active. While the timing loop is active, you cannot change parameters. To change any parameters, you must stop the loop by clicking the STOP button or the EXIT button. At this point the firmware is performing a troubleshooting loop on the digitalto-analog conversion. You can now scope the output of the DAC module to see the actual waveform as it approximates a sine wave analog output. To stop the loop, click the STOP button. If you want to make the waveform steps smoother, increase the number of points to 80 and press . Then recompute the 80 point sine wave by selecting the Sine Button. The sinewave changes to the one shown in Figure 3.9. Increasing the Number of Points to 80 makes the Sine Waveform smoother Figure 3.11: Smoothing the Waveform 3.1.1.3 Generating a Code File The PICDEMTM MSC1 includes a Code Generator that will write an initialization assembly code file corresponding to the selected configuration. If you want a Configuration Word different from the PICDEM MSC1 configuration, you will need to turn off communications between the Evaluation Board and the GUI: 2001 Microchip Technology Inc. DS41178A-page 31 PICDEMTM MSC1 User's Guide 1. Select the Pull-down menu OptionsEnable Eval Board to uncheck this selection and stop communications between the GUI Control Panel and the PICDEMTM MSC1. 2. Select the Memory tab of the PICDEMTM MSC1 control panel. The Configuration Word section of the panel is now active, as shown in Figure 3.10. 3. Select the desired Configuration Word parameters for your application. Figure 3.12: Configuration Word Functions 4. Select the Generate Code option from the File menu, as shown in Figure 3.11. Figure 3.13: Generate Code Option A File Dialog displays, asking you to choose a folder or location for storing the *.inc file that will be generated. The generated file will look similar to the one shown in Figure 3.12. DS41178A-page 32 2001 Microchip Technology Inc. Tutorial/Demo __CONFIG org goto 0x3FFF 0x000 Initialize org 0x004 ; Insert interrupt service routine here Initialize BANKSEL PORTA movlw movwf movlw movwf movlw movwf movlw movwf 0x20 PORTA 0xF0 PORTB 0x00 T1CON 0x00 ADCON0 BANKSEL ANSEL movlw movwf movlw movwf movlw movwf movlw movwf movlw movwf movlw movwf movlw movwf 0xFF ANSEL 0xFF WPUB 0xFF TRISA 0xFF TRISB 0x00 REFCON 0x00 ADCON1 0xFF OPTION_REG BANKSEL DACON0 movlw 0x00 movwf DACON0 movlw 0x00 movwf CM1CON0 movlw 0x00 movwf CM2CON0 movlw 0x00 movwf CM2CON1 movlw 0x00 movwf OPACON movlw 0x00 movwf CALCON movlw 0x00 movwf PSMCCON0 movlw 0x00 movwf PSMCCON1 ; Insert user code here Figure 3.14: Sample Generated Code File 2001 Microchip Technology Inc. DS41178A-page 33 PICDEMTM MSC1 User's Guide NOTES: DS41178A-page 34 2001 Microchip Technology Inc. 12 PICDEMTM MSC1 User's Guide Appendix A. PICDEMTM MSC1 Schematics A.1 Introduction This appendix contains schematics associated with the PICDEMTM MSC1. A.2 Highlights Topics covered in this appendix: * Evaluation Board Schematic * Parts Placement * Evaluation Board Hardware * Evaluation Board Firmware. 2001 Microchip Technology Inc. DS41178A-page 35 R6 Red 470 R10 4MHz Y1 RA7 J2 1 3 2 DJ005B 1N4001 D3 VDD C3 7 RA2 RA2 U2 VBAT AVDD AVSS .1f RB6 RB5 RB4 14 13 12 11 AVSS ANSUP AVSS U1 LM2937-IMP-5.0 DIGSUP 1IN OUT 3 OUT 3 U4 LM2937-IMP-5.0 RB5 RB4 +5V U3 +5V 6 V- 3 C1- FIDUCIAL_PP FIDUCIAL_PP X3 X1 FIDUCIAL_PP X2 AVSS H E A D E R P I N 4 0 J5 2 4 6 8 10 12 14 J3 1 16 2 18 3 20 4 22 SIP_4 24 26 28 30 32 34 36 38 ANSUP 40 DIGSUP RED RED 3.3KD5 3.3KD6 3.3KD7 R15 R16 R17 AVSS RED RED 3.3KD4 R14 AVSS P2 CW R12 1 2 TP 470 TP-60R38 CCW AVDD R8 10K POT-3352E HDR2X20O/E AVDD +5V RA6 RA7 RB3 RB2 RA0 RA1 RA4 RA5 RB7 RB6 AVSS RA2 RB5 RA3 RB0 RB1 RB4 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 C2- 5 PIN1 1 PIN6 PIN2 6 2 PIN7 7 3 PIN3 PIN8 8 PIN4 4 PIN9 PIN5 9 5 J1 DE9S-FRS AVSS AVDD CW 3 P1 R13 R9 2 TP 1 10K TP-60R38 470 CCW 1 POT-3352E 11 T1OUT 14 330 10 T1IN T2IN T2OUT 7 R4 330 R1 TC232_MAX232A 12 R1OUT 13 R1IN 330 9 R2IN 8 R3 330 R2OUT R2 1 C1+ C2+ 4 2 V+ Y2 +5V 1NC/OE VCC 4 2 GND OUT 3 OSC1 OSC_CAN RB7 RB6 RB5 RB4 AVSS 6 AVSS PIC16C78X_DIP OSC2/CLKOUT RB7 1 IN RB2 RB1 RB0 AVDD 19 10 9 15 RB3 20 RB3 RB2 RB1 RB0/INT OSC1/CLKIN 5 VSS 17 18 RA4 3 RA4/TOCKI RA3 8 RA3 2 RA1 RA1 RA0 1 RA0 4 MCLR 16 RA5 +5V J6 RA6 2 1 J4 2PHDR OPTIONAL (NOT INSTALLED) +5V R7 AVSS S1 +5V R11 C1 RESONATOR-ZTT 3.3K D2 Red AVDD OSC1 RC mode 47K 0.1F 33pF +5V 33pF R5 1f AVDD .1F 4 1 3 2 SW-B3F1000 C13 3.3K D1 2 1 C12 47F VCC 16 GND 15 C10 .1f C4 C14 2PHDR .1F 2 COM 2 COM .1f 1f C15 1F 10F 1f C9 C6 C7 J7 C11 C5 1f C2 C8 DS41178A-page 36 3 A.3 1 +5V PICDEMTM MSC1 User's Guide Schematics Figure A.1: PICDEMTM MSC1 Schematic 2001 Microchip Technology Inc. PICDEMTM MSC1 Schematics Optional Plug in external oscillator here Optional Plug in crystal or resonator here Remove these 2 jumpers when using external oscillator D4 pin D5 pin D6 pin General Purpose D7 pin Bus Lines RS-232 Connector LED D4 LED D5 LED D6 LED D7 Prototyping Area 40-pin header VDD Jumper AVDD LED AVDD Jumper VDD LED Master Clear (MCLR) Pushbutton +9VDC Connector Figure A.2: Parts Placement Diagram PICDEMTM MSC1 HARDWARE The supplied Evaluation Board consists of: * A PIC16C782 with the MONITOR firmware * Dual linear 5 volt DC supplies * An RS-232 interface * A generous prototyping area (see Figure A.2). Note: 2001 Microchip Technology Inc. There are four General Purpose Bus Lines provided in the Prototyping Area for distributing signals across the area (see Figure A.2). DS41178A-page 37 PICDEMTM MSC1 User's Guide A 40-pin header between the PIC16C782 and the prototype area is intended for jumpering prototype circuitry to the PIC16C782 or expanding the prototype area by plugging a pre-made circuit onto the evaluation board. The VDD and AVDD jumpers connect the on-board linear regulators to the PIC16C782 circuit and prototype areas. Removal of these jumpers allows for supply voltages and capacity other than that provided by the on-board five volt regulators. The RS-232 interface is two lines, asynchronous without handshaking. Connection to the PC is via a 9-pin subminiature D connector, wired for a standard 9-conductor serial port cable. Note: The AVDD and VDD jumpers must be in place as shown when the internal supply is the primary power source. EVALUATION BOARD FIRMWARE The Evaluation Board firmware is a simple monitor program that provides read access to any of the PIC16C781/782 Special Function and memory data registers or program locations. The firmware also provides write access to any of the Special Function and data registers. The RS-232 interface is "bitbanged," since the PIC16C781/782 does not contain a USART peripheral. Immediately after a RESET, the firmware enters a Search mode for baud rate calibration. The first character must be a ten-bit serial sequence composed of: * Start bit (zero) * Seven consecutive data zeros * A one data bit * A stop bit (one). This is equivalent to sending a H'80' character from a serial port set up for: * Eight data bits * One start bit * One stop bit * No parity. You can communicate with the PICDEMTM MSC1 Evaluation Board directly from a PC with a hyperterminal window setup as just described with a baud rate of 9600 or less, and local echo turned off. Immediately after the Evaluation Board Reset, send the calibration character from the hyperterminal window by typing (0128). In other words, hold down the key down while typing the four Key Pad numbers 0, 1, 2, 8 in sequence, then release the key. The Num Lock function must be enabled and the Key Pad numbers must be used instead of the number keys at the top of the keyboard. Confirm proper calibration by typing the key. The Evaluation Board will respond with the '>' character. All characters are echoed by the Evaluation Board firmware. Only those sequences corresponding to an actual command will be processed. See the MONITOR.ASM file for details about the command protocol. Baud rate recalibration can be remotely requested by sending a break character that is at least three times the character time of the most recent calibration. A Break can be sent from the Hyperterminal by typing together. DS41178A-page 38 2001 Microchip Technology Inc. 12 PICDEMTM MSC1 USER'S GUIDE Index A Analog to Digital Converter (ADC) ................. 15 Arbitrary Waveform ........................................ 17 C Changing the Default Font ............................. 12 Clock Source Selection .................................. 28 Comparators/Op Amp .................................... 19 Components ..................................................... 5 Configuration Word Functions ........................ 32 customer notification service ............................ 3 Customer Support ............................................ 4 D DAC Module Setup ......................................... 23 Development Systems list names .................... 3 E Enabling the DAC Module .............................. 23 Evaluation Board Firmware ............................ 38 F File Menu Functions ....................................... 13 S Sample Initialization Assembly Code .............. 33 Schematics ..................................................... 36 Serial Communications with the PICDEMTM MSC1 Evaluation Board ............... 11 Setting the Prescaler ...................................... 30 Special Conventions ....................................... 12 Starting Communications with the Evaluation Tool ................................................. 9 T The Configuration Word Setup Tool Area ....... 22 Timers ............................................................. 21 Triangle Waveform ......................................... 18 U Using the Arbitrary Waveform Feature ........... 28 Using the GUI Control Panel ............................ 9 W Warranty Registration Card .............................. 2 WWW Address ................................................. 3 G Global Items ................................................... 13 I Input/Output .................................................... 14 Installing the GUI Software ............................... 7 Installing the Hardware ..................................... 6 Internet Address ............................................... 3 M Memory .......................................................... 22 Microchip Internet Web Site ............................. 3 Microchip World Wide Web (WWW) site. ......... 3 P Parts Placement Diagram .............................. 37 Peripheral Organization .................................. 11 PICDEMTM MSC1 Hardware .......................... 37 Port Selection ................................................. 10 Programmable Switch Mode Controller (PSMC) ........................................................... 20 R Recommended Reading ................................... 2 Required Items ................................................. 5 2001 Microchip Technology Inc. DS41178A-page 39 M WORLDWIDE SALES AND SERVICE AMERICAS ASIA/PACIFIC Japan Corporate Office Australia 2355 West Chandler Blvd. Chandler, AZ 85224-6199 Tel: 480-792-7200 Fax: 480-792-7277 Technical Support: 480-792-7627 Web Address: http://www.microchip.com Microchip Technology Australia Pty Ltd Suite 22, 41 Rawson Street Epping 2121, NSW Australia Tel: 61-2-9868-6733 Fax: 61-2-9868-6755 Microchip Technology Japan K.K. Benex S-1 6F 3-18-20, Shinyokohama Kohoku-Ku, Yokohama-shi Kanagawa, 222-0033, Japan Tel: 81-45-471- 6166 Fax: 81-45-471-6122 Rocky Mountain China - Beijing 2355 West Chandler Blvd. Chandler, AZ 85224-6199 Tel: 480-792-7966 Fax: 480-792-7456 Microchip Technology Consulting (Shanghai) Co., Ltd., Beijing Liaison Office Unit 915 Bei Hai Wan Tai Bldg. No. 6 Chaoyangmen Beidajie Beijing, 100027, No. China Tel: 86-10-85282100 Fax: 86-10-85282104 Atlanta 500 Sugar Mill Road, Suite 200B Atlanta, GA 30350 Tel: 770-640-0034 Fax: 770-640-0307 Boston 2 Lan Drive, Suite 120 Westford, MA 01886 Tel: 978-692-3848 Fax: 978-692-3821 Chicago 333 Pierce Road, Suite 180 Itasca, IL 60143 Tel: 630-285-0071 Fax: 630-285-0075 Dallas 4570 Westgrove Drive, Suite 160 Addison, TX 75001 Tel: 972-818-7423 Fax: 972-818-2924 Dayton Two Prestige Place, Suite 130 Miamisburg, OH 45342 Tel: 937-291-1654 Fax: 937-291-9175 Detroit Tri-Atria Office Building 32255 Northwestern Highway, Suite 190 Farmington Hills, MI 48334 Tel: 248-538-2250 Fax: 248-538-2260 Kokomo 2767 S. Albright Road Kokomo, Indiana 46902 Tel: 765-864-8360 Fax: 765-864-8387 Los Angeles 18201 Von Karman, Suite 1090 Irvine, CA 92612 Tel: 949-263-1888 Fax: 949-263-1338 New York 150 Motor Parkway, Suite 202 Hauppauge, NY 11788 Tel: 631-273-5305 Fax: 631-273-5335 San Jose Microchip Technology Inc. 2107 North First Street, Suite 590 San Jose, CA 95131 Tel: 408-436-7950 Fax: 408-436-7955 Toronto 6285 Northam Drive, Suite 108 Mississauga, Ontario L4V 1X5, Canada Tel: 905-673-0699 Fax: 905-673-6509 China - Chengdu Microchip Technology Consulting (Shanghai) Co., Ltd., Chengdu Liaison Office Rm. 2401, 24th Floor, Ming Xing Financial Tower No. 88 TIDU Street Chengdu 610016, China Tel: 86-28-6766200 Fax: 86-28-6766599 China - Fuzhou Microchip Technology Consulting (Shanghai) Co., Ltd., Fuzhou Liaison Office Rm. 531, North Building Fujian Foreign Trade Center Hotel 73 Wusi Road Fuzhou 350001, China Tel: 86-591-7557563 Fax: 86-591-7557572 China - Shanghai Microchip Technology Consulting (Shanghai) Co., Ltd. Room 701, Bldg. B Far East International Plaza No. 317 Xian Xia Road Shanghai, 200051 Tel: 86-21-6275-5700 Fax: 86-21-6275-5060 China - Shenzhen Microchip Technology Consulting (Shanghai) Co., Ltd., Shenzhen Liaison Office Rm. 1315, 13/F, Shenzhen Kerry Centre, Renminnan Lu Shenzhen 518001, China Tel: 86-755-2350361 Fax: 86-755-2366086 Hong Kong Microchip Technology Hongkong Ltd. Unit 901-6, Tower 2, Metroplaza 223 Hing Fong Road Kwai Fong, N.T., Hong Kong Tel: 852-2401-1200 Fax: 852-2401-3431 India Microchip Technology Inc. India Liaison Office Divyasree Chambers 1 Floor, Wing A (A3/A4) No. 11, O'Shaugnessey Road Bangalore, 560 025, India Tel: 91-80-2290061 Fax: 91-80-2290062 Korea Microchip Technology Korea 168-1, Youngbo Bldg. 3 Floor Samsung-Dong, Kangnam-Ku Seoul, Korea 135-882 Tel: 82-2-554-7200 Fax: 82-2-558-5934 Singapore Microchip Technology Singapore Pte Ltd. 200 Middle Road #07-02 Prime Centre Singapore, 188980 Tel: 65-334-8870 Fax: 65-334-8850 Taiwan Microchip Technology Taiwan 11F-3, No. 207 Tung Hua North Road Taipei, 105, Taiwan Tel: 886-2-2717-7175 Fax: 886-2-2545-0139 EUROPE Denmark Microchip Technology Nordic ApS Regus Business Centre Lautrup hoj 1-3 Ballerup DK-2750 Denmark Tel: 45 4420 9895 Fax: 45 4420 9910 France Microchip Technology SARL Parc d'Activite du Moulin de Massy 43 Rue du Saule Trapu Batiment A - ler Etage 91300 Massy, France Tel: 33-1-69-53-63-20 Fax: 33-1-69-30-90-79 Germany Microchip Technology GmbH Gustav-Heinemann Ring 125 D-81739 Munich, Germany Tel: 49-89-627-144 0 Fax: 49-89-627-144-44 Italy Microchip Technology SRL Centro Direzionale Colleoni Palazzo Taurus 1 V. Le Colleoni 1 20041 Agrate Brianza Milan, Italy Tel: 39-039-65791-1 Fax: 39-039-6899883 United Kingdom Arizona Microchip Technology Ltd. 505 Eskdale Road Winnersh Triangle Wokingham Berkshire, England RG41 5TU Tel: 44 118 921 5869 Fax: 44-118 921-5820 10/01/01 DS41178A-page 40 2001 Microchip Technology Inc.