QW1 TechTools, QW1 Datasheet

PROGRAMMER PIC MCU QUICKWRITER

QW1

Manufacturer Part Number
QW1
Description
PROGRAMMER PIC MCU QUICKWRITER
Manufacturer
TechTools
Series
QuickWriter™r
Type
QuickWriterr
Datasheets

Specifications of QW1

Contents
MCU Programmer with In-Circuit Serial Programming Cable and Optional GANG Adapters
For Use With/related Products
PIC Micro® MCU
For Use With
CBL-ICSP - CABLE PROG QUICKWRITER SERIALQW-4SSOP18 - ADAPTER QUICKWRITER 4GANG 18SSOPQW-4SSOP28 - ADAPTER QUICKWRITER 4GANG 28SSOPQW-4SO8/14W - ADAPT QUICKWRTR 4GANG 8/14SOIC WQW-4SO8/14N - ADAPT QUICKWRTR 4GANG 8/14SOIC NQW-4SOIC18 - ADAPTER QUICKWRITER 4GANG 18SOICQW-4ZIF18 - ADAPTER QUICKWRITER 4-GANG 18ZIFQW-4SOIC28 - ADAPTER QUICKWRITER 4GANG 28SOICQW-4PLCC44 - ADAPTER QUICKWRITER 4GANG 44PLCCQW-4ZIF40/28 - ADAPT QUICKWRITER 4GANG 40/28ZIFMP-ZIF14 - ADAPTER QUICKWRITER 14-PIN ZIFMP-SOIC8/14 - ADAPTER QUICKWRITER 8/14-SOICMP-SSOP18 - ADAPTER QUICKWRITER 18-SSOPMP-SSOP28 - ADAPTER QUICKWRITER 28-SSOPMP-14000 - ADAPTR QUICKWRTR PIC14000 28-PINMP-SOIC18 - ADAPTER QUICKWRITER 18-SOICMP-SOIC28 - ADAPTER QUICKWRITER 28-SOICMP-PLCC44 - ADAPTER QUICKWRITER 44-PIN PLCCMP-ZIF18/28 - ADAPTER QUICKWRITER 18/28PIN ZIFMP-ZIF40 - ADAPTER QUICKWRITER 40-PIN ZIF

Available stocks

Company
Part Number
Manufacturer
Quantity
Price
Part Number:
QW152
Manufacturer:
Laird Technologies IAS
Quantity:
135
PicTools Manual
3.0
© 2007 TechTools

Related parts for QW1

QW1 Summary of contents

Page 1

... PicTools Manual 3.0 © 2007 TechTools ...

Page 2

... In no event shall TechTools be liable for any loss of profit or any other commercial damage caused or alleged to have been caused directly or indirectly by this document. ...

Page 3

... Table of Contents Foreword Part I TechTools PicTools Introduction Part II QuickWriter MCU Programmer 1 HEX File ................................................................................................................................... 5 2 Setting Options ................................................................................................................................... 5 Setting Auto Options .......................................................................................................................................................... Setting General Options .......................................................................................................................................................... Setting HEX Options .......................................................................................................................................................... Setting Serial Number Options .......................................................................................................................................................... Setting Advanced Options .......................................................................................................................................................... Setting I.D. Locations .......................................................................................................................................................... Setting Options for Production Personnel .......................................................................................................................................................... ...

Page 4

... Watch List Options Trace Buffer Window ......................................................................................................................................................... Data Breakpoints .......................................................................................................................................................... DBP Enable and Break On options ......................................................................................................................................................... DBP File Register options ......................................................................................................................................................... DBP Match On options ......................................................................................................................................................... ......................................................................................................................................... 51 ......................................................................................................................................... 63 ......................................................................................................................................... 64 ......................................................................................................................................... 65 ......................................................................................................................................... 65 ......................................................................................................................................... 66 ......................................................................................................................................... 85 ......................................................................................................................................... 85 ......................................................................................................................................... 85 ......................................................................................................................................... 88 ......................................................................................................................................... 89 ......................................................................................................................................... 91 ......................................................................................................................................... 97 ......................................................................................................................................... 99 ......................................................................................................................................... 103 ......................................................................................................................................... 105 ......................................................................................................................................... 108 ......................................................................................................................................... 109 ......................................................................................................................................... 112 ......................................................................................................................................... 115 105 108 116 118 120 120 121 © 2007 TechTools ...

Page 5

... Addressing Definitions .......................................................................................................................................................... Data Types .......................................................................................................................................................... Expressions .......................................................................................................................................................... Symbols & Labels .......................................................................................................................................................... Local Labels .......................................................................................................................................................... Default_Symbol_Tables .......................................................................................................................................................... Comments .......................................................................................................................................................... Assembler Directives .......................................................................................................................................................... Source Code Formatting .......................................................................................................................................................... CVASM16 Error Messages .......................................................................................................................................................... 2 TechTools Instruction Set ................................................................................................................................... 144 Microchip to CVASM16 .......................................................................................................................................................... ADD, ADDB .......................................................................................................................................................... AND .......................................................................................................................................................... CALL .......................................................................................................................................................... CJA, CJAE .......................................................................................................................................................... CJB, CJBE .......................................................................................................................................................... CJE .......................................................................................................................................................... CJNE .......................................................................................................................................................... CLR .......................................................................................................................................................... CLRB, CLC, CLZ ...

Page 6

... MCLR Pull-Up Resistor ................................................................................................................................... 204 8 Optional Modules ................................................................................................................................... 205 Index 166 166 169 169 171 172 172 174 175 175 176 176 178 179 179 180 181 181 182 183 184 184 185 187 190 194 199 207 © 2007 TechTools ...

Page 7

... TechTools PicTools Introduction Part I ...

Page 8

... PicTools Manual 3.0 1 TechTools PicTools Introduction This manual covers information for using the following TechTools products: QuickWriter (MCU CVASM (ClearView QuickWriter and Mathias are hardware devices that use our CVASM and TDE software. This manual will reference both hardware products in the software sections, so not all features will be available unless you own both products ...

Page 9

QuickWriter MCU Programmer Part II ...

Page 10

... Selecting the MCU · Setting the Configuration Word (Fuses) · Using Gang Adapters · Using Serial Numbers · Reading the MCU Contents Advanced · Advanced · In-Circuit Programming · ICP with Self Powered Targets · Cable Connector © 2007 TechTools ...

Page 11

... Microchip : Includes Code, Data, ID and Configuration Word information. This format is normally saved with a ".hex" extension. TechTools : Includes Code, Data, ID, Device type, Configuration Word and sometimes Calibration information. This format is normally saved with a ".obj" extension. QuickWriter will accept the above formats and adjust all relative data according to the type of information found in the HEX file ...

Page 12

... Enable Erase - If available for the MCU and selected, a bulk erase is performed on the FLASH device during Auto Run cycles. Enable Blank Check - If selected, a blank check is performed on all enabled areas of the - Enable and set Serial Numbering details such as number of locations, area - Advanced settings mainly related to In-Circuit Programming. 12 © 2007 TechTools ...

Page 13

... Enable Fuses - If selected, the Configuration Word will be programmed and verified during Auto Run cycles. Shortcuts Alt+O, O 2.2.2 Setting General Options Overview General options that are not normally needed during development but help when preparing settings for production personnel. © 2007 TechTools QuickWriter MCU Programmer ). 17 7 Serial Number options ...

Page 14

... To match Microchip's "Code Protected" checksum value, enable this option and "Read" a code protected device. If not selected, QuickWriter's checksum will include all enabled buffers (Code, EEDATA, User IDs and FUSES) and the resulting calculation is displayed bit HEX value. Production Control: Setting the Configuration Word © 2007 TechTools ...

Page 15

... Setting Options for Production Personnel Shortcuts Alt+O, G 2.2.3 Setting HEX Options Overview Provides HEX file Overrides for the specific HEX file and selection of records to include when saving HEX files. Details Open HEX File - Override HEX Options: © 2007 TechTools QuickWriter MCU Programmer ) 14 9 ...

Page 16

... HEX file during a save. When multiple MCU devices with configuration data are present (i.e using a 4-gang adapter), the configuration data will be saved from the current selection in the Calibration Editor. Shortcuts Alt+O, H 2.2.4 Setting Serial Number Options Overview Enable and set Serial Numbering details such as number of locations, area of the MCU and © 2007 TechTools ...

Page 17

... Help information provided with MPLAB equivelant HEX file can be generated manually with an identical address specified for each HEX line. NOTE: When this option is selected, the "Locations" and "Address" options are disabled since this information is retreived from the SQTP file. © 2007 TechTools QuickWriter MCU Programmer 11 ...

Page 18

... Each step in the selector (shown above) will increase the duration of the programming pulse by 1/4 of the Factory Recommended Value. The 5 steps are as follows: PPW = Tmin or 1 PPW PPW = (Tmin + (Tmin /4)) or 1.25 PPW PPW = (Tmin + ((Tmin /4) * 2)) or 1.50 PPW PPW = (Tmin + ((Tmin /4) * 3)) or 1.75 PPW PPW = (Tmin * PPW ) 17 © 2007 TechTools ...

Page 19

... If your HEX file does not include ID information or you would like override the ID with a different value whenever the HEX file is opened, select the "Override" check box after changing the ID values. Details © 2007 TechTools ) 21 QuickWriter MCU Programmer ICP with Self 13 ...

Page 20

... Each selected item will be performed when the production department chooses "Auto Run" ( Alt+A you have enabled Serialization, verify the serial number length and address settings to prevent overlapping valid code or EE data. Also verify the "last serial number" and "Auto Increment" settings (see Using Serial Numbers ). 17 © 2007 TechTools ...

Page 21

... MCU, provided "Option Editing" is enabled for this HEX file (see: Options for Production Personnel Specific bits in each Configuration Word control available MCU options when programmed. © 2007 TechTools QuickWriter MCU Programmer 15 15 ...

Page 22

... OTP (one time programmable). Newer MCUs with these fuse options allow a "Power first" of VPP (programming Voltage), which ensures the device can re-enter programming mode and be read after the fuses have been programmed © 2007 TechTools ...

Page 23

... EE Data will be stored as " 00". If auto increment is selected, the next four incremented serial numbers will be stored as: " 00" " 00" " 00" " 00" © 2007 TechTools Socket B disabled. (FFFFh or 65535) (10000h or 65536) (10001h or 65537) (10002h or 65538) QuickWriter MCU Programmer ...

Page 24

... Manual - Serial numbering preferences have changed to Manual mode. Auto - Serial numbering preferences have changed to Auto Mode. Skipped - An earlier error has dictated skipping serialization for this socket. The serial number is not incremented for skipped sockets. Setting Serial Number Options 10 ): © 2007 TechTools ...

Page 25

... Alt+ performs a "Serialize Only" programming task. 2.3.5 Reading the MCU Contents Overview Sometimes it may be desirable to "reproduce" an MCU that has already been programmed or to visually verify the contents this, you will need to read the contents of the MCU instead of opening a HEX file. © 2007 TechTools QuickWriter MCU Programmer 19 ...

Page 26

... All suggestions presented in the error dialog should be checked thoroughly before another programming attempt is made. Target Design Recommendations Use a 10K Ohm or larger pull up on MCLR Use 10uF or less capacitance on MCLR (most targets use none). ; and Setting Options for Production Personnel © 2007 TechTools ...

Page 27

... If the target circuit has larger current requirements not feasible to power the circuit from the 5 volt power trace (i.e. when this will apply 5 volts to the output of a voltage regulator), then you should choose QuickWriter's "Monitor a Self Powered Target" option. © 2007 TechTools ) 21 ...

Page 28

... QuickWriter's TVDDEN signal will help automate control of the target's power and make it possible to meet the required timing for power sequence specifications. TVDDEN is a new signal, available on QuickWriter's 26 pin interface connector not available in the standard ICSP cable included with the unit. You may need to customize your in- © 2007 TechTools ...

Page 29

... Overview QuickWriter's programming cable connector is compatible with existing PICwriter and Parallax PIC16CXX-PGM programmer adapters while also providing Gang programming with TechTools Gang programming adapters and In-Circuit Programming with the included ICP Cable. A newer signal, TVDDEN is also provided on this connector for automated control of the Target Circuit's power supply (see: 2 ...

Page 30

... Error Detected, BAD data received 'Current Programming Task Failed' { 'Firmware update Required' { 'Higher Transfer Speed Failed' { 'User Aborted Task in progress.' { 'Unknown Error has Occurred.' { 'VDD Voltage TOO LOW (+5 'VDD Voltage TOO HIGH' { 'VDD not rising' { 'MCLR Voltage TOO LOW © 2007 TechTools ...

Page 31

... An error occurred for at least one socket while performing this task. - This task was completed successfully. - This task has been disabled in Option Settings and will be skipped. - This task is not available for the selected MCU and will be skipped. © 2007 TechTools QuickWriter MCU Programmer } 25 ...

Page 32

... TechTools Design Environment Part III ...

Page 33

... It’s assumed that you have successfully installed the Mathias hardware and software, as described in the previous sections of this chapter. If not, please review the installation sections before trying this project. © 2007 TechTools 118 TechTools Design Environment TDE Details ...

Page 34

... PicTools Manual 3.0 3.1.1 Starting TDE Step 1: Start the TDE software. You should be able to select TDE from the Windows taskbar. 3.1.2 Opening The Project Step 2: Select Open from TDE’s Project menu, or click the equivalent button as shown above. © 2007 TechTools ...

Page 35

... Tool" option has been set to "CVASM16". ( For a detailed example of creating a new project and selecting project options, see the section "Project and File Operations" late r in this chapter. ) Now highlight the source file for this project and click the Open button. © 2007 TechTools TechTools Design Environment 29 ...

Page 36

... PicTools Manual 3.0 After Step 3, you should see the fo llowing screen. The tutorial program appears in the text editor window. © 2007 TechTools ...

Page 37

... Hardware Settings, Project Info Step 4: Select Project from the Setup menu. Step 5: Select the serial com port that the emulator is connected to, as well as the baud rate for communication with the PC. © 2007 TechTools TechTools Design Environment 31 ...

Page 38

... Ready"; otherwise, it will indicate that no emulator was found.) Stack Viewing and the "Break on Stack Overflow/Underflow" options are not available on 5X 3.1.5 Device Settings, Building the Project Step 6: Under the Device heading, select the following settings: Device: 16C554 Frequency : 5X Note: devices. 20 MHz. © 2007 TechTools ...

Page 39

... This project does not use the optional trace buffer, so there need to adjust any settings under the fourth heading (Trace). Now click the OK button to close this dialog. Step 7: Select Build from the Project menu, or click the equivalent button. © 2007 TechTools TechTools Design Environment F4 33 ...

Page 40

... PicTools Manual 3.0 3.1.6 Running the Code, Stopping Execution If the build function worked properly, you should see the status bar as above. Note the status "Project Build Complete." Step 8: Select Go from the Run menu, or click the equivalent button. F5 © 2007 TechTools ...

Page 41

... The status line (which is in the toolbar, but not shown here) will indicate the current address, such as "User Halted at 000Dh". 3.1.7 Single-Stepping Step 10: Select Single Step from the Run menu, or click the equivalent button. © 2007 TechTools TechTools Design Environment F6 35 ...

Page 42

... This ability makes it easier to find the exact instruction that may be causing an error. Try single-stepping several times. The green highlighted line should advance each time you step through the code. 3.1.8 Animation, Watching Variable Values Step 11: Select Animate from the Run menu, or click the equivalent button © 2007 TechTools ...

Page 43

... When you stopped execution, the program probably stopped on a line where you can see the variable called Value. Let’s add this variable to the watch list, so you can watch its value as the program runs. Start by highlighting the variable’s name in the source code window. © 2007 TechTools TechTools Design Environment F6 37 ...

Page 44

... Watch List. To open the Watch List use the Open Watch button or select "Watch List" from the VIEW menu. 3.1.9 Watching Variables, Viewing Special Registers Step 14: Now select the Watch List option from the View menu. Watch © 2007 TechTools ...

Page 45

... This opens the Symbols Window which displays the Special Registers, user variables and etc. The Special Registers portion displays the contents of the PIC’s special register memory (status, fsr, option, etc). Step 16: Select Animate from the Run menu, or click the equivalent button. © 2007 TechTools TechTools Design Environment F9 39 ...

Page 46

... PicTools Manual 3.0 3.1.10 Watching the Program Run The screen should look something like this. The green highlighted line should be stepping through the program, and the two new windows (Watch & Special Registers) should be updated and values highlighted as they change. © 2007 TechTools ...

Page 47

... Step 17: After a few seconds, click the Stop button to stop execution of the program. 3.1.11 Resetting the Emulator, Setting Breakpoints Step 18: Select Reset from the Run menu, or click the equivalent button. © 2007 TechTools TechTools Design Environment F6 F10 41 ...

Page 48

... Note that lines with breakpoints are highlighted in red. If the "current execution line" (green) lands on a breakpoint line, the resulting color will be blue (green + red = blue). © 2007 TechTools ...

Page 49

... To disable a breakpoint, just double-click in the left column again. 3.1.12 Finishing the Project Step 20: Select Animate from the Run menu, or click the equivalent button. © 2007 TechTools TechTools Design Environment F9 43 ...

Page 50

... Project and File Operations · Creating a Single-file Project · Creating a Multiple-file Project · Adding Files · Mode of Operation · Watch Dog Timer · Breaking on Stack Over/Underflow · Device Settings · Trace buffer settings · Environment Settings · Resetting the emulator © 2007 TechTools ...

Page 51

... Breaking on Stack Over/Underflow · Device Settings · Trace buffer settings · Environment Settings · Resetting the emulator · Printing 67 All compile or debug sessions in TDE require a project name. This next section explains how to create a single-file project using the included TechTools © 2007 TechTools ...

Page 52

... TDE will open the Project file dialog. Here you can type a new project name. For this example we will use the name " Newprog1". If the file does not exist, TDE will ask create this new project filename. After you click "OK", a dialog will appear like the one below. oscillator speed, editor settings, etc. © 2007 TechTools ...

Page 53

... The highlighted item "Project", is the main Node in your project file. You can now select the tool you would like to use for your project by clicking on the Tool drop-down list under Node Build Settings.This tool selection lets TDE know how to handle the build process. © 2007 TechTools TechTools Design Environment 47 ...

Page 54

... Now that we have selected CVASM16 as the tool for our Project Node, lets add a file. Click on the ADD button and a dialog will appear similar to the one shown below. Here you can select an existing file, or just type a new filename and TDE will create the file for you. Project => Setup => © 2007 TechTools ...

Page 55

... Now we can choose the appropriate tool for the selected file. Since we have chosen CVASM16 as our Project Node Tool, we will select NONE as the File Node Tool. This will pass the file to the Project Tool for processing. © 2007 TechTools TechTools Design Environment 49 ...

Page 56

... BCtest". TDE will verify that the name does not al ready exist in the selected directory. After you click "OK", a dialog will appear like the one below. For this example we will select By tecraft Linker as our Project tool. © 2007 TechTools ...

Page 57

... Click on the ADD button and a dialog will appear similar to the one shown here. We have selected an existing file, but you can just type a new filename and TDE will create the file for you. Multiple files could also be selected by using the ctrl or shift keys. © 2007 TechTools TechTools Design Environment Setup => Project => 51 ...

Page 58

... After selecting a file, your Project Dialog should resemble the graphic below. Now we can choose the appropriate tool for each file added to the project. Since we have chosen Bytecraft Linker as our Project Node Tool, AND added a 'C' source file, we will select Bytecraft C to OBJ as the File Node Tool. © 2007 TechTools ...

Page 59

... The first file added to the project will be the last file processed during build operations. Likewise, the last file added to the project will be the first file processed. After selecting OK, the Project Dialog will close and your Edit window should resemble the graphic below. © 2007 TechTools TechTools Design Environment NOTE: 53 ...

Page 60

... TDE will create an empty text file and open it in the Editor window. You will want to reference the Bytecraft Linker documentation for complete information regarding the requirements of the link file, however an exam ple is shown below. © 2007 TechTools ...

Page 61

... Project option from the Setup menu in TDE). © 2007 TechTools TechTools Design Environment You can now edit, compile and debug your project. Link files must have the extension of ".LNK". ...

Page 62

... Now you can select the serial com port the emulator is connected to, as well as the baud rate for communication with the PC. Mode of Operation Mathias: Full Emulation mode with Mathias attached. Virtual Mathias: This allows you to start experiencing all of TDE and Mathias's features - even if you do not have a Mathias connected. © 2007 TechTools ...

Page 63

... Editor window whenever a timeout occurs. (Always RESET the program after a Break on Timeout). * Break on Stack Over/Underflow, and WDT Break on Timeout are not available on 12bit or 3.2.1.5 Break on Stack Over/Underflow © 2007 TechTools TechTools Design Environment Setup => Project => 16C5X devices Setup => Project => 57 ...

Page 64

... Stack Viewing is only available with 14bit device emulation and Mathias firmware Version 2.1 or higher and Break on Stack Over/Underflow is not available on 12bit or 16C5X devices. is required ( part #CVMT2 ). This will give you an execution 116 Note: © 2007 TechTools ...

Page 65

... In this case, just select the proper device that you wish to emulate and proceed with the rest of your settings. Frequency The Mathias hardware is capable of operating at any frequency from 32 KHz to 25 MHz, with certain limitations. Certain "Bondout" combinations may be limited even 10 MHz. © 2007 TechTools TechTools Design Environment Setup => Project => 59 ...

Page 66

... If you require the ability to emulate a 20Mhz PIC, the newer 25Mhz PICs or would like the new feature of Data Breakpoints, we now offer an Advanced Family Module for 14bit devices: part #CVM03F. 3.2.1.7 Trace Buffer If you have a Trace Buffer Module ( part #CVMT2 ), select the Trace tab. Setup => Project => © 2007 TechTools ...

Page 67

... External Break: If this is enabled, the emulator will halt execution if the external Break input goes low. External Inputs: There are eight external trace inputs, shown at the end of the hardware installation section. © 2007 TechTools TechTools Design Environment 61 ...

Page 68

... Environment Preferences can be mod ified by selecting the Environment option from the Setup menu in TDE. This option allows you to set general features that affect all editing/debugging sessions. Environment Option Groups · Editor 63 · General 64 · Build 65 · Debug 65 Mathias and display it at the bottom of the window. © 2007 TechTools ...

Page 69

... When this option is enabled, a carriage-return will automatically space over the beginning of the next line to match the one above it. Auto Backup TDE will automatically create a backup copy of modified files and use the extension '.bak', before saving changes made from the editor window. © 2007 TechTools TechTools Design Environment 66 63 ...

Page 70

... Auto Load last Project If this option is enabled, TDE will automatically load the project that was active the last time TDE was closed. Beep on Errors Whenever an error is encountered by TDE, the PC speaker will emit a short beep. Beep on Stop © 2007 TechTools ...

Page 71

... If NOT selected, Mathias will halt immediately when requeste d. Step OUT of unknown code When selected, any STEP operation will run full speed through compiled code that does not have a source line reference. © 2007 TechTools TechTools Design Environment 65 ...

Page 72

... Resetting the Emulator Sometimes, it may be necessary to reset the emulator hardware. For instanc e, there may be a communications error between the PC and the emulator, which will require a reset. To reset the emulator, select Reset Mathias from the File menu. © 2007 TechTools ...

Page 73

... To print from either window, just click on the window and then select Print from the File menu. TDE will display the Print dialog box: © 2007 TechTools TechTools Design Environment in the Run menu just resets the emulated PIC. the one in the Run menu. Reset ...

Page 74

... The process of assembling or compiling source code is called "building." When you tell TDE to build the project, it calls upon the selected tools to assemble/compile the each node in the project.* To build the project, select Build from the Project menu, or click the corresponding button, or press F4 © 2007 TechTools ...

Page 75

... Build Complete" shown below: If errors are encountered, then TDE will display an error list: To see a corresponding error in the source code, just click on the error in the error listing; the original source code line will be highlighted: © 2007 TechTools TechTools Design Environment 69 ...

Page 76

... PicTools Manual 3.0 * The assembler/compiler is selected by using the 3.2.2.2 Executing Code at Full Speed To execute code at full speed in the emulator, select Go from the Run menu, or click the corresponding button, or press F5. Project the Setup menu. F5 option in 46 © 2007 TechTools ...

Page 77

... Execution will be halted and TDE will update information in any open windows. 3.2.2.4 Single-Step Execution To execute one line or instruction, select Single Step from the Run menu, or click the corresponding button, or press F8. © 2007 TechTools TechTools Design Environment Device tab of the Project option of the Setup menu ). Execution ...

Page 78

... If the editor window is the active window, then the emulator will execute one line of source code. If the code window is the active window, then the emulator will execute one instruction of code. When using the TechTools assembler or any C compiler, one line of source code may be multiple instructions. ...

Page 79

... Step Over Execution To execute in step-over mode, select Step Over from the Run menu, or click the corresponding button, or press F7. The emulator will execute one instruction, and then TDE will update any open windows. © 2007 TechTools TechTools Design Environment F7 73 ...

Page 80

... Animate Over Execution To execute in animation mode, select Animate Over from the Run menu, or press "Shift" and click the Animate button, or press "Shift" and F9. single-step execution. In this mode, the emulator 71 F9 Environment option from the Setup menu. 62 Shift + F9 © 2007 TechTools ...

Page 81

... Showing the Execution Point To show the execution point, select Show Execution Point from the Run menu. The execution point will be indicated by a green highlighted line in the text editor window. © 2007 TechTools TechTools Design Environment 75 ...

Page 82

... TDE to quickly take you back. 3.2.2.10 Resetting the Emulated PIC To reset the PIC, select Reset from the Run menu, or click the corresponding button, or press F10. F10 © 2007 TechTools ...

Page 83

... To do this, click on the line where you wish to set the program counter: After clicking on the new line, select Set PC from the Run menu. © 2007 TechTools Reset ClearView option in the File menu, which resets the emulator 66 TechTools Design Environment Environment settings ). This ...

Page 84

... To set a breakpoint, just double-click in the left margin of the desired line. The line will be highlighted in red, indicating the presence of a breakpoint. To remove the breakpoint, just double-click in the left margin of the same line. If you prefer, you can also use the keyboard and menu options shown below. © 2007 TechTools ...

Page 85

... Note that you can set breakpoints in the text editor window and in the code window. Any change in one window will be reflected in the other window, as well. © 2007 TechTools Red highlighting shows the location of a breakpoint. TechTools Design Environment 79 ...

Page 86

... Window Basics Before we examine any particular window, let’s review the basics concernin g all windows: things like scroll bars, close boxes, etc. If you already understand such things, you may want to skip to the Editor Window section 105 108 116 © 2007 TechTools ...

Page 87

... To move a window, click and hold the mouse button on the window’s "Title bar" while moving the mouse. To change its size, click and hold the mouse button on one of the window’s edges or corners while moving the mouse. Pop-up menu: © 2007 TechTools TechTools Design Environment 81 ...

Page 88

... Set and clear breakpoints · Cut, copy, and paste · Undo and redo · Search and replace · Place markers There are several ways to see the editor window: Open an existing or new project, OR open an existing or new file. Then © 2007 TechTools ...

Page 89

... Select Edit from the View menu OR, · Select Open from the · Double-click on a File-node from the The open editor window looks like this: © 2007 TechTools TechTools Design Environment Files tab of the Setup->Project option, OR... 51 Files tab of the Setup->Project option. ...

Page 90

... PicTools Manual 3.0 "Cycles and Time" and "Total cycles" are only available if the NOTE: Buffer or Timing Module is installed. 60 Trace © 2007 TechTools ...

Page 91

... Highlight the desired text, and then select Cut from the Edit menu, or select Cut from the © 2007 TechTools Files tab of the Project Dialog 51 discussion at the end of the previous section. , see the Data Breakpoints Section at the end of this Chapter. 118 TechTools Design Environment 85 ...

Page 92

... Place the mouse at the beginning of the text, and then click and hold the mouse button while moving the mouse to the end of the text. Step 2: copy text to clipboard memory Select Copy from the Edit menu. Step 3: place cursor at new location © 2007 TechTools ...

Page 93

... Move the mouse to the new location, and then click the mouse button. The cursor will appear at the new location. Step 4: insert the copied text Select Paste from the Edit menu. The copied text will appear where the cursor was placed in step 3. Notice the new pair of CLC and RR instructions. © 2007 TechTools TechTools Design Environment 87 ...

Page 94

... Also, the return key itself is a change. So, if you type "abc" on one line, and then you type "xyz" on the next line, there are three changes: 1) abc, 2) return key, and 3) xyz. , these functions are fairly standard on most editors, 85 © 2007 TechTools ...

Page 95

... If you want to search the entire editor, you must place the cursor at the beginning of the file before starting the search. To start a search, select Search from the Edit menu, or press Ctrl-F; after doing so, you’ll see the following window: © 2007 TechTools TechTools Design Environment 89 ...

Page 96

... Replace All: Click this button to replace all occurrences of the search text with the replacement text. This is really useful if you decide to change the name of a variable or other item throughout your program. Cancel: Click this button to exit the window. © 2007 TechTools ...

Page 97

... To set or clear a marker on the current line (the line where the cursor is), click the right mouse button to see the editor’s pop-up menu, then select Toggle Marker, and then select the marker number you want to use (0-9). © 2007 TechTools TechTools Design Environment pop-up menu . 80 ...

Page 98

... If the chosen marker is already present, then it will be removed. To find a marker that was placed earlier, select Go to Marker fr om the menu , and then select the marker you want to find. The editor will move to the 80 line where the marker was placed. pop-up © 2007 TechTools ...

Page 99

... Build Log window. The Build Log is automatically shown if TDE encounters errors. However, if you would like to see the Build Log (if it’s behind another window), just select Build Log from the View menu; the following window will appear: © 2007 TechTools TechTools Design Environment 93 ...

Page 100

... PicTools Manual 3.0 Each line in the Build Log marked "error", corresponds to an error in the source code. To see a corresponding error in the source code, just click on the error in the errors window; the original source code line will be highlighted: © 2007 TechTools ...

Page 101

... Like the editor window, the code window shows the execution point and any breakpoints; breakpoints can be set and cleared by double-clicking on any executable line. © 2007 TechTools TechTools Design Environment Creating a Single-file Project 95 ...

Page 102

... The Symbols window contains several special windows important to Editing and Debugging. · Special Registers · Variables · Labels 103 · Files 105 To see the symbols window, select Symbols from the View menu. Editor Window This feature helps the user to 82 © 2007 TechTools ...

Page 103

... B - Toggles displaying of the Binary Column Toggles displaying of the ASCII (Character) Column. A-Z Sorts the registers by NAME 0-9 Sorts the registers by ADDRESS To modify the value in a register, just double-click on the value; the following register modification window will appear: © 2007 TechTools TechTools Design Environment 97 ...

Page 104

... From this window, you can enter a new register value in hex, binary, or decimal. You can also use the handy register modification pop-up menu. To use the pop-up menu, click the right mouse button; you’ll see the pop-up menu as shown here. bits cannot be modified. DBL-Clicking on the register. © 2007 TechTools ...

Page 105

... This window allows you to see and modify Defined RAM Locations, including the special registers if selected. From this window register values can be edited, variable display characteristics can be modified and items can be added to the Watch Window. © 2007 TechTools TechTools Design Environment editor window 99 ...

Page 106

... K - Toggles displaying Defined Constants Toggles displaying of Defined Bits Toggles displaying of the Special Registers. A-Z Sorts the registers by NAME 0-9 Sorts the registers by ADDRESS Modifying a Register Value and Display Format: To modify the value in a register or to change the display format, just double-click © 2007 TechTools ...

Page 107

... Signed: - Display as a signed value. Big Endian the Length is greater than 8 bits, this option will display the MSB first when selected. Repeat Count - Treat as an array of the above settings with the specified number of elements. © 2007 TechTools TechTools Design Environment 101 ...

Page 108

... PicTools Manual 3.0 String Options: Format: - Select the desired string type. Max Chars - Enter the maximum number of characters to associate with this string. Repeat Count - Treat as an array of the above settings with the specified number of elements. Float Options: © 2007 TechTools ...

Page 109

... HEX, proceeded For example, address 127 must be entered a s 0x7F. 3.2.3.5.3 Labels Window From this window, you can jump to the position of a specific label in your source code. Double-Click on any label in this window and the associated source code line will be © 2007 TechTools TechTools Design Environment 103 ...

Page 110

... PicTools Manual 3.0 brought into view and highlighted yellow. Local labels are grouped with its Global label as seen with the label ' FIFO ' above. FIFO is a global label that has two local labels defined as PAD and PUSH. © 2007 TechTools ...

Page 111

... This window allows you to see and modify the emulated PIC’s file registers. Most file registers serve as general-purpose storage space for variables and program data. To see the file registers window, select File Registers from the View menu; the window below will appear. © 2007 TechTools TechTools Design Environment 105 ...

Page 112

... Gray - Undefined ram location that has NOT changed since the last Halt. Yellow - Undefined ram location that has changed since the last Halt. The file register window works just like the previously-discussed special registers window. To modify the value in a register, just double-click on the value; the following window will appear: © 2007 TechTools ...

Page 113

... The File Registers window has additional options that are accessible by a POPUP Menu: FILL ALL - Select this option to fill all general purpose ram locations with a specific value. Watch - Select this option to add the ram location (or its label if defined) to the watch window. © 2007 TechTools TechTools Design Environment 107 ...

Page 114

... Items can be added to the Watch Window directly from the source code editor. To add a watch, simply Highlight the item to watch, then Right-Click in the editor and select Add Watch Selected from the popup menu. and File Registers windows 99 105 108 109 112 115 Special Registers , but using the Watch List window © 2007 TechTools 97 ...

Page 115

... Watches can be added to the Watch wind ow from the Variables Window in the three ways described below. To select which items are visible in the Variables Window, see: Symbols - Variables Window Select and Add - First, select one or more registers by using the left mouse button © 2007 TechTools TechTools Design Environment . 99 109 ...

Page 116

... Add button at the top of the window (+). Select and Drag & Drop - First, select one or more registers by using the left mouse button (and optionally the Shift or Control keys for multiple selections). Then, Drag & Drop the selected items onto the Watch Window. © 2007 TechTools ...

Page 117

... Edit and Add - Enter the Name of the item or its address in the edit box at the top of the window and press the Enter key (or click the add button). If entering an address, it must be specified in HEX, proceeded For example, address 127 must be entered as 0x7F. © 2007 TechTools TechTools Design Environment 111 ...

Page 118

... Integer Options: Radix: - Select HEX, Binary or Decimal formatting. Length: - Group the selected number of bits as a single value (consecutive). Note 1: Note 2: File Reg ister options Data Breakpoints Dialog . 118 in the 120 © 2007 TechTools ...

Page 119

... Repeat Count - Treat as an array of the above settings with the specified number of elements. String Options: Format: - Select the desired string type. Max Chars - Enter the maximum number of characters to associate with this string. Repeat Count - Treat as an array of the above settings with the specified number of elements. © 2007 TechTools TechTools Design Environment 113 ...

Page 120

... PicTools Manual 3.0 Float Options: Format - Choose the desired float format. Precision - cho ose from bit precision. Big Endian - If selected, value will be displayed MSB first. Repeat Count - Treat as an array of the above settings with the specified number of elements. © 2007 TechTools ...

Page 121

... Deletes the currently selected watch item. Show Address Toggles displaying of the Address Column Default Radix Sets the RADIX (HEX, Decimal or Binary) for all items that have not been customized (see: Modifying © 2007 TechTools TechTools Design Environment Watch Item Values ). 112 112 115 ...

Page 122

... Microchip instructions . Some instructions, such as JMP and GOTO, take two processor cycles, and therefore take two locations in the trace buffer memory. In addition, some TechTools instructions utilize two or three Microchip instructions, and will therefore take multiple locations in the trace buffer (this is also true of high-level compiled languages, such as C) ...

Page 123

... The pop-up menu has four options; to select a function, just move the mouse to the desired option and then click the left mouse button. The options are described below: Clear trace buffer Select this option to erase the trace buffer. © 2007 TechTools TechTools Design Environment 117 ...

Page 124

... Enable and Break On options · File Register options · Match On options · Include Constants option · Breaking on Data Note 1: end of the Hardware Installation section. Note 2: make room for new records. 120 120 121 123 124 Trace tab in 60 © 2007 TechTools ...

Page 125

... Some MCUs have a "Self Modifying Code" feature. This option must be disabled in order to enable Data Breakpoints. Disable the self modifying features by selecting "Setup - Project - Emulator", then selecting "Ignored" for the Code Read and Code Write options. © 2007 TechTools TechTools Design Environment 119 ...

Page 126

... Select a predefined symbol from the drop down list as shown here, or enter an absolute address as shown in the examples below : ). 118 Special Register (also see: Variables Window ) your code has access to. The data 99 or General Purpose 97 Match On option. 121 © 2007 TechTools ...

Page 127

... Any Data: When this option is selected, the data value is ignored. A Match is determined by the Break On © 2007 TechTools HEX value to indicate an Absolute address. This notation is also used in the selection, without any further qualifiers. 120 TechTools Design Environment Add Watch Dialog . 109 121 ...

Page 128

... ONLY if the data matches the specified value exactly. Bit Pattern: This option allows you to define specific bits which should be ignored during the match evaluation. Each bit has three possible states; on, off and don't care OFF X = Don't Care © 2007 TechTools ...

Page 129

... HEX values to the "this_task" register: A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, AA, AB, AC, AD, AE binary; any value from: 3.2.4.4 DBP Include Constants © 2007 TechTools TechTools Design Environment 10100000 through 10101111. Any combination of 1's, 0's and X's is valid. 123 ...

Page 130

... If the code line is located in another file, TDE will bring that file into view before moving the cursor. The correct code line is also identified in the status bar as shown above. . 120 Data Breakpoint and select Go to Data Breakpoint. This will move the cursor execution will be halted and 118 © 2007 TechTools ...

Page 131

... This section contains Hints on integrating popular compilers and assemblers with TDE. · How · CVASM16 · SPASM 127 · MPASM 127 · MPLINK 128 · Bytecraft C · Bytecraft Linker © 2007 TechTools executed after the data breakpoint occurs. 126 127 128 128 TechTools Design Environment 125 ...

Page 132

... It usually only happens if the compiler has a critical error. The following sections describe each compiler we currently support. If you are using a TOOL that we do not list here, let us know. TOOLs that generate standard symbol formats are easy to integrate. 129 130 131 131 © 2007 TechTools ...

Page 133

... SINGLE FILE MODE: This is the traditional mode, similar to CVASM16. A typical project would specify MPASM as the TOOL in the PROJECT node. A single file NODE would be added to indicate the main source file. Its TOOL would be NONE. © 2007 TechTools TechTools Design Environment NOTE: TDE. CVASM16 127 ...

Page 134

... It may affect the way you use GLOBALS and STATICS but eliminates the need for a LINKER file. 3.3.7 Bytecraft LINKER When working with multiple source file projects, you must select the Bytecraft LINKER for the PROJECT NODE. to produce a complete image file. In this mode, MPASM-to-OBJ is used . Both modes are discussed below. 128 © 2007 TechTools ...

Page 135

... In this case, you would specify Hi-Tech C for the PROJECT NODE TOOL. Then ADD your source file and specify 'NONE' for its tool. © 2007 TechTools TechTools Design Environment HINT: project. 129 ...

Page 136

... If CCS changes the format of this file in the future, simply replace the one in the TDE directory with an updated version. TDE will then use the new PC.DEF file for all future builds. © 2007 TechTools ...

Page 137

... HEX file to the project and specify 'NONE' for its TOOL. Whenever you update the HEX file, simply press TDE's BUILD button or press F4 or select the BUILD menu item and TDE will update Mathias. © 2007 TechTools TechTools Design Environment 131 ...

Page 138

ClearView Assembler Part IV ...

Page 139

... However, most people find it preferable to use an assembler. The TechTools assembler (CVASM16 ) is unique in its ability to accept two instruction sets: our own 8051-like instruction set, and the original Microchip instruction set. Many customers appreciate the TechTools instruction set, because it resembles other processors ...

Page 140

... An example is shown below: 134 134 135 135 135 136 136 138 138 139 139 140 140 142 142 Assembles text file filename.src into hex file filename.obj. © 2007 TechTools ...

Page 141

... This option is use ful for other tools that won’t accept any Device or Fuse information embedded in the hex file. 4.1.5 Assembler Basics The purpose of the assembler is to convert assembly language source code into hex code. The assembler accomplishes its task in two passes: © 2007 TechTools ClearView Assembler 135 ...

Page 142

... A 13-bit address (anywhere in program memory in a device with address for bitwise operations. Example: PortC.3 = bit 3 of port C A file register (RAM) address. A relative address ranging from -7Fh to +80h. An immediate 8-bit value. · Binary value · ASCII value · EEPROM address (origin) Generating Assembly Listings 135 © 2007 TechTools ). ...

Page 143

... CALL MOV ; ; org 200h TABLE1 JMP RETW 'The fox jumped over the lazy dog' © 2007 TechTools Decimal value 100 Hex value 18 Hex value A7 Binary value 1011 ASCII value for the letter A (65 decimal) Label called Start Local label called :loop ...

Page 144

... HOT different temperature. Symbols may character long. They must begin with a letter or underscore (_) / Divide << Shift left >> Shift right < High byte > Low byte . Bit address ;Set bit 0 on port A. ;Store 88h in location Count+3. ;Define empty space of Nx2 bytes. © 2007 TechTools ...

Page 145

... A Local label can be called from outside its usual area as demonstrated in the line: jmp 4.1.11 Default_Symbol_Tables When the assembler is started, its symbol table is initialized with various PIC symbols, such as C for the Carry register, RA for Port A, etc. This saves you from having to define © 2007 TechTools = 20h = 21h ...

Page 146

... Load 61h into Input ; Load 10h into Output ; Call routine to communicate with host Assigns a value to a symbol (same as EQU) Assigns a value to a symbol (same as =) Sets the current origin to a new value. This is used to set the program © 2007 TechTools ...

Page 147

... EEDATA is only available for PICs that have EEPROM memory. Assembler Directive Examples © 2007 TechTools Defines an amount of free space. No code is generated. This is Sets the PIC’s identification bytes. PIC16C5x chips have two ID bytes, Loads another source file during assembly. This allows you to insert an NOTE that FUSE CONFIGURATIONs can be '& ...

Page 148

... Set 16C5x ID to 1234h ; Set newer PIC ID to 'ABCD' ‘KEYS.SRC’ ; Include KEYS.SRC file at ; point of insertion ; Set 16C5x reset jump to ; location at Start Count,#00 ; This will be executed when a '5X PIC is reset 10h ; Set EEPROM address to 10h 02h,88h,34h ; Store 3 bytes in EEPROM © 2007 TechTools ...

Page 149

... Line length exceeded the line limit of 256 characters. Mnemonic field cannot exceed 7 characters: More than 7 characters were in the mnemonic (instruction) field. Illegal mnemonic/operand combination: The operand structure did not match the instruction’s or directive’s possibilities. © 2007 TechTools ClearView Assembler 143 ...

Page 150

... A symbol was referenced in the operand, which was never declared earlier in your program. 4.2 TechTools Instruction Set For a listing of the Microchip Instruction set and the equivalent CVASM16 instruction; see the next section, ADD, ADDB 148 AND 150 CALL 151 CJA, CJAE 152 CJB, CJBE 153 "Microchip to CVASM16 " 145 © 2007 TechTools ...

Page 151

... This table is designed to help the CVASM16 user to understand source code written in Microchip format. It can also be a valuable reference when converting source to TechTools format. When doing this, keep in mind that CVASM16 will accept ALL of Microchip's instruction set, but not Microchip's directives and macros. ...

Page 152

... RL f 172 MOV 179 RR f 172 MOV 172 SUB f,W 172 MOV 184 SWAP f 185 XOR W,f 185 XOR f,W CLRB 157 bit SETB 180 bit 182 SNB bit 179 SB bit ('xx) ADD 148 AND 150 ('5x) CALL 151 © 2007 TechTools ...

Page 153

... DC,addr11 BNC addr9 addr11 BNDC DC,addr9 DC,addr11 BNZ addr9 addr11 BZ addr9 © 2007 TechTools Clear WDT and prescaler addr Go to address lit Or literal into W lit Move literal into W Move W into OPTION Return from interrupt lit Return with literal in W Return, clearing W ...

Page 154

... LCALL 166 ('5x) LJMP 166 ('xx) LJMP 172 MOV W,f NEGF f,0 NEGF f,1 180 STC 180 SETB DC 180 STZ 179 SC 179 SB DC 182 SNC SNB 182 DC SNZ 182 SZ 179 SUBCF f,0 SUBB 183 SUBDCF f,0 SUBB 183 184 TEST f © 2007 TechTools ...

Page 155

... Z will be set if the result is 0, otherwise Z will be cleared. Coding: ADDWF ADDB fr,bit Words: 2 Operation: © 2007 TechTools Add fr2 into fr1 Cycles: 2 Affects DC, Z Fr2 is added into fr1 via W. C will be set if an overflow occurs; Add W into fr Cycles: 1 Affects added into fr ...

Page 156

... Literal is AND’d into fr via W. Z will be set if the result is 0; otherwise, Z AND fr2 into fr1 Cycles: 2 Affects Fr2 is AND’d into fr1 via W. Z will be set if the result is 0; otherwise, Z AND W into fr Cycles: 1 Affects AND’d into fr. Z will be set if the result is 0; otherwise, Z will be fr,1 145 © 2007 TechTools ...

Page 157

... CALL. See Coding: CALL CALL addr11 Words: 1 © 2007 TechTools AND literal into W Cycles: 1 Affects: Z Literal is AND’d into W. Z will be set the result was 0, otherwise Z literal 145 AND fr into W into fr ...

Page 158

... Fr is compared to literal via greater than literal, a jump to literal^0FFh fr,0 3,0 addr9 Compare fr1 to fr2 and jump if above Cycles (jump) Affects DC, Z Fr1 is compared to fr2 via W. If fr1 is greater than fr2, a jump to addr9 fr1,0 fr2,0 3,0 addr9 Compare fr to literal and jump if above or equal © 2007 TechTools ...

Page 159

... Compare fr to literal and jump if below Words: 4 Operation: is executed. Coding: MOVLW SUBWF BTFSS GOTO CJB fr1,fr2,addr9 © 2007 TechTools Cycles (jump) Affects compared to literal via greater than or equal to literal, a literal fr,0 3,0 addr9 Compare fr1 to fr2 and jump if above or equal Cycles (jump) Affects: C, DC, Z Fr1 is compared to fr2 via W ...

Page 160

... Fr is compared to literal via less than or equal to literal, a literal fr,0 3,0 addr9 Compare fr1 to fr2 and jump if below or equal Cycles (jump) Affects: C, DC, Z Fr1 is compared to fr2 via W. If fr1 is less than or equal to fr2, a jump to fr1,0 fr2,0 3,0 addr9 © 2007 TechTools ...

Page 161

... CJNE fr,#literal,addr9 Compare fr to literal and jump if not equal Words: 4 Operation: addr9 is executed. Coding: MOVLW SUBWF BTFSS GOTO CJNE fr1,fr2,addr9 © 2007 TechTools Cycles (jump) Affects compared to literal via equal to literal, a jump to addr9 is literal fr,0 3,2 addr9 Compare fr1 to fr2 and jump if equal Cycles (jump) Affects: C, DC, Z Fr1 is compared to fr2 via W ...

Page 162

... Fr1 is compared to fr2 via W. If fr1 is not equal to fr2, a jump to addr9 is fr2,0 fr1,0 3,2 addr9 Cycles: 1 Affects cleared set 145 Cycles: 1 Affects cleared set to 1. 145 Cycles: 1 Affects: TO, PD The watchdog timer is cleared, along with the prescaler, if assigned. 145 © 2007 TechTools ...

Page 163

... CLRB, CLC, CLZ CLRB bit Clear bit Words: 1 Operation: Coding: BCF 145 Note: The TechTools assemblers define a bit as port.bitposition the following examples: RA.3 = bit 3 of port A PortB.0 = bit 0 of port B CLC Clear carry Words: 1 Operation: Coding: BCF 145 CLZ Clear zero ...

Page 164

... Coding: MOVLW SUBWF BTFSS 3,0 Note: Only one word is skipped by this instruction. To avoid strange results, make sure that any instruction following CSAE is a single-word instruction. literal fr,0 Affects: C, DC, Z fr1,0 fr2,0 Affects: C, DC, Z literal fr,0 © 2007 TechTools ...

Page 165

... CSB is a single-word instruction. CSB fr1,fr2 Compare fr1 to fr2 and skip if below Words: 3 Operation: instruction word is skipped. © 2007 TechTools Cycles (skip) Affects: C, DC, Z Fr1 is compared to fr2 via W. If fr1 is >= fr2, the following instruction fr2,0 fr1,0 ...

Page 166

... Cycles (skip) Affects compared to literal via less than or equal to literal, the literal fr,0 3,0 Cycles (skip) Affects: C, DC, Z Fr1 is compared to fr2 via W. If fr1 is less than or equal to fr2, the fr1,0 fr2,0 3,0 Compare fr to literal and skip if equal © 2007 TechTools ...

Page 167

... CSE is a single-word instruction. 4.2.14 CSNE CSNE fr,#literal Words: 3 Operation: instruction word is skipped. Coding: MOVLW SUBWF BTFSC © 2007 TechTools Cycles (skip) Affects compared to literal via equal to literal, the following literal fr,0 3,2 Cycles (skip) Affects: C, DC, Z Fr1 is compared to fr2 via W ...

Page 168

... Fr1 is compared to fr2 via W. If fr1 is not equal to fr2, the following fr2,0 fr1,0 3,2 Cycles: 1 Affects decremented. Z will be set the result was 0, otherwise Z will fr,1 145 Cycles (skip) Affects: none Fr is decremented. The next instruction word will be skipped if the fr,1 145 © 2007 TechTools ...

Page 169

... Coding: INCF INCSZ fr Increment fr and skip if zero Words: 1 Operation: © 2007 TechTools Cycles (jump) Affects: none Fr is decremented. If the result is not 0, a jump to addr9 is executed. fr,1 Cycles (jump) Affects: none Fr is incremented. If the result is not 0, a jump to addr9 is executed. fr,1 ...

Page 170

... If bit is set, a jump to addr9 is executed. bit addr9 Jump if carry Cycles (jump) Affects: none If the carry bit is set, a jump to addr9 is executed. 3,0 addr9 Jump to address Cycles: 2 Affects: none The lower 9-bits of the literal addr9 is moved into the program counter. addr9 145 © 2007 TechTools ...

Page 171

... JNB bit,addr9 Words: 2 Operation: Coding: BTFSS GOTO Note: The TechTools assemblers define a bit as port.bitposition the following examples: RA.3 = bit 3 of port A PortB.0 = bit 0 of port B © 2007 TechTools Jump to PC+W Cycles: 2 Affects: C, DC, Z W+1 is added into the program counter. The 9th bit of the program ...

Page 172

... Jump if not zero Cycles (jump) Affects: none jump to addr9 is executed. 3,2 addr9 Jump if zero Cycles (jump) Affects: none jump to addr9 is executed. 3,2 addr9 Cycles: 2-4 Affects: none Depending on the device size, from zero to two BCF/BSF instructions © 2007 TechTools ...

Page 173

... The bit set/clear instructions are followed by a jump to addr8. This instruction is only useful for PICs with more than 512 words. Coding: (BCF/BSF (BCF/BSF © 2007 TechTools addr8 Cycles: 2-4 ...

Page 174

... Depending on the device size, from zero to two BCF/BSF instructions will be assembled to load the PCLATH bits to addr13’s page. This instruction is only useful for PICs with more than 2K words. Coding: (BCF/BSF (BCF/BSF Affects: none 0A ,3) Affects: none 3, 5) Affects: none 0A ,3) © 2007 TechTools ...

Page 175

... NOTE: Since the OPTION register on 'xx devices is readable and writable, it can be accessed as a normal File Register. To maintain upward compatibility with future devices, these instructions should not be used when coding for 'xx devices. MOV !OPTION,#literal Words: 2 © 2007 TechTools Move literal into fr Cycles: 2 Affects: none Literal is moved into fr via W. literal fr ...

Page 176

... On 16C5x parts, you must use the explanation mark (!) before the word OPTION; this causes the assembler to assemble an OPTION instruction. On 16Cxx parts, the mark (!) is optional. Microchip added an OPTION register to the newer parts, so literal Move fr into OPTION Affects: Z fr,0 Move W into OPTION Affects: none © 2007 TechTools ...

Page 177

... Operation: disables the corresponding port pin’s output buffer, allowing input use, while a "0" bit enables the output buffer for high or low output. Port_fr must be (at Address © 2007 TechTools Cycles: 2 Affects: none Literal is moved into the I/O control register of port_fr via W. A "1" bit in ...

Page 178

... Fr is moved into W. Z will be set the value moved was 0, fr,0 145 Move not fr into W Cycles: 1 Affects: Z The one’s complement moved into W. Z will be set the fr,0 145 Cycles: 1 Affects subtracted from fr and the result is stored will be cleared © 2007 TechTools ...

Page 179

... Coding: RLF 145 MOV W,>>fr Move the right-rotated value of fr into W Words: 1 © 2007 TechTools fr,0 145 Cycles: 1 Affects: Z The incremented value moved into W. Z will be set the fr,0 145 Move the decremented value of fr into W ...

Page 180

... MOVB bit1,bit2 Words: 4 Operation: Coding: BTFSS bit2 BCF BTFSC bit2 BSF Note: The TechTools assemblers define a bit as port.bitposition the following examples: RA.3 = bit 3 of port A MOVB bit1,/bit2 Words: 4 Operation: The right-rotated value moved into W. On entry, C must hold the fr,0 ...

Page 181

... Coding: BTFSC bit2 BCF BTFSS bit2 BSF Note: The TechTools assemblers define a bit as port.bitposition the following examples: RA.3 = bit 3 of port A 4.2.28 MOVSZ MOVSZW,++fr Move the incremented value of fr into W and skip if zero Words: 1 Operation: will be skipped if the result was 0. Coding: ...

Page 182

... Fr is converted into its one’s complement value. Z will be set the fr,1 145 Cycles: 1 Affects converted into its one’s complement value. Z will be set the 0FFh 145 OR literal into fr Cycles: 2 Affects: Z Literal is OR’d into fr via W. Z will be set the result was 0, literal fr,1 © 2007 TechTools ...

Page 183

... Coding: IORLW OR W,fr Words: 1 Operation: be cleared to 0. Coding: IORWF © 2007 TechTools Cycles: 2 Affects: Z Fr2 is OR’d into fr1 via W. Z will be set the result was 0, fr2,0 fr1 into fr Cycles: 1 Affects OR’d into fr. Z will be set the result was 0, otherwise Z will ...

Page 184

... Assemble RET’s which load W with literal data Cycles: 2 per RETLW Affects: none A list of RET’s with literal data in the W area is assembled, which can literal1 145 literal2) ...) pc+w ;Jump to byte at location pc+w ;Return with w holding appropriate ;value © 2007 TechTools ...

Page 185

... Coding: BTFSS Note: Only one word is skipped by this instruction. To avoid strange results, make sure that any instruction following single-word instruction. Note: The TechTools assemblers define a bit as port.bitposition the following examples: RA.3 = bit 3 of port A © 2007 TechTools Rotate fr left Cycles: 1 Affects rotated left ...

Page 186

... single-word instruction. 4.2.35 SETB, STC, STZ SETB bit Words: 1 Operation: Coding: BSF 145 Note: The TechTools assemblers define a bit as port.bitposition the following examples: RA.3 = bit 3 of port A Skip if carry Cycles (skip) Affects: none the following instruction word is skipped. 3,0 145 Skip if zero ...

Page 187

... Only one word is skipped by this instruction. To avoid strange results, make sure that any instruction following SKIP is a single-word instruction. 4.2.37 SLEEP SLEEP Words: 1 Operation cleared to 0. Coding: SLEEP © 2007 TechTools Set carry Cycles: 1 Affects set to 1. 3,0 Set zero flag Cycles: 1 Affects set to 1. ...

Page 188

... Operation: Coding: BTFSC Note: Only one word is skipped by this instruction. To avoid strange results, make sure that any instruction following SNB is a single-word instruction. Note: The TechTools assemblers define a bit as port.bitposition the following examples: RA.3 = bit 3 of port A SNC Words: 1 Operation: Coding: ...

Page 189

... C will be set will be cleared or set, depending on whether or not an underflow occurred in the least-significant nibble. Z will be set the result was 0, otherwise Z will be cleared to 0. Coding: SUBWF © 2007 TechTools Subtract literal from fr Cycles: 2 Affects: C, DC, Z Literal is subtracted from fr via W. C will be cleared underflow ...

Page 190

... Z will be cleared to 0. This instruction is useful for subtracting the carry from the upper byte of a double-byte value after the lower byte has been subtracted. Coding: BTFSS 3,0 DECF Note: The TechTools assemblers define a bit as port.bitposition the following examples: RA.3 = bit 3 of port A 4.2.40 SWAP SWAP fr Words: ...

Page 191

... Operation: otherwise Z will be cleared to 0. Coding: MOVF XORWF XOR fr,W Words: 1 Operation: be cleared to 0. © 2007 TechTools Test W for zero Cycles: 1 Affects will be set otherwise Z will be cleared 145 XOR literal into fr Cycles: 2 Affects: Z Literal is XOR’d into fr via W. Z will be set the result was 0, ...

Page 192

... XOR literal into W Cycles: 1 Affects: Z Literal is XOR’d into W. Z will be set if the result was 0, otherwise Z will literal 145 XOR fr into W Cycles: 1 Affects XOR’d into W. Z will be set the result was 0, otherwise Z will fr,0 145 187 190 194 © 2007 TechTools ...

Page 193

... Before continuing, build the circuit shown below. Only seven parts are necessary, so the task shouldn’t be too laborious. If you don’t have exactly what’s called for, you can substitute a close match (the 4.7K resistor and 20 pF capacitor should not be substituted with smaller values, however). © 2007 TechTools ClearView Assembler 187 ...

Page 194

... KHz to 25 MHz using its programmable on-board ( For this project we suggest using a frequency between 1 and 4 The following listing is the source code for the project Simple.tpr. It’s contained in a file called SIMPLE.SRC, which is located in the APPS subdirectory of the TDE installation. Note: oscillator. MHz. ) © 2007 TechTools ...

Page 195

... Check button status. ; back to the first loop ; ChkBtn jnb RA.0,Start:Loop ;Jump to 1st loop if button is pressed © 2007 TechTools Normally, the LED flashes slowly. A current-limited LED is connected from RA1 to ground For an oscillator capacitor to ground and Lastly, power and ground are connected to Vdd status line displays " ...

Page 196

... The schematic below shows the circuit. Whenever the button is pressed, the value shown on the 7-segment display increments. ;(button is low when pressed) Count1,:Loop ;Decrement Count1. ;jump back to :Loop Start:Loop ;Jump back to first loop If it’s not zero, © 2007 TechTools ...

Page 197

... KHz to 25 MHz using its programmable on-board ( For this project we suggest using a frequency between 1 and 4 The following listing is the source code for the project Table.tpr. It’s contained in a file called TABLE.SRC, which is located in the APPS sub-directory of the PIC Tools Diskette. © 2007 TechTools ClearView Assembler Note: oscillator. ...

Page 198

... A ;(make bit 0 an input) ;Set data direction register for port B ;(make all bits outputs) ;Move Number into W ;Get bit pattern for digit ;Show digit ;If flag is clear, check for 2048 reads A push For an oscillator, Lastly, © 2007 TechTools ...

Page 199

... If the program assembles correctly, the assembler will produce a hex file, called TABLE.OBJ, in the APPS directory. You can now select Run, and your circuit will operate as if you had already inserted a programmed PIC. © 2007 TechTools ;of button not pressed Button,Digit ;Jump if flag set, but button not ;pressed Number ...

Page 200

... The schematic below shows the circuit. The PIC itself requires just three parts to operate: a 4-MHz crystal and two capacitors to form its oscillator. The remaining three parts are a 10K potentiometer, a 330-ohm resistor, and an 8-segment LED bargraph (common anode). © 2007 TechTools ...

Related keywords