DM163035+TEFLCST3 Microchip Technology, DM163035+TEFLCST3 Datasheet

no-image

DM163035+TEFLCST3

Manufacturer Part Number
DM163035+TEFLCST3
Description
KIT, PICDEMLAB+FLOWCODE-HOME BUNDLE/
Manufacturer
Microchip Technology
Datasheet

Specifications of DM163035+TEFLCST3

Kit Contents
Component Kit, PICDEM Lab Development Board, PICkit 2 Programmer/ Debugger, CD Containing User Guide
Svhc
No SVHC (15-Dec-2010)
Development Tool Type
Hardware / Software - Dev
Silicon Manufacturer
Microchip
Core Architecture
PIC
Core Sub-architecture
PIC10, PIC12, PIC16
Silicon Core Number
PIC10F, PIC12F, PIC16F
Silicon Family Name
PIC10F2xx, PIC12F6xx, PIC16F6xx
Rohs Compliant
Yes
Lead Free Status / RoHS Status
Lead free / RoHS Compliant
PICDEM™ Lab Flowcode
Companion Guide
© 2009 Microchip Technology Inc.
DS41381A

Related parts for DM163035+TEFLCST3

DM163035+TEFLCST3 Summary of contents

Page 1

... PICDEM™ Lab Flowcode © 2009 Microchip Technology Inc. Companion Guide DS41381A ...

Page 2

... PowerInfo, PowerMate, PowerTool, REAL ICE, rfLAB, Select Mode, Total Endurance, TSHARC, WiperLock and ZENA are trademarks of Microchip Technology Incorporated in the U.S.A. and other countries. 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. ...

Page 3

... Testing the Application .............................................................. 56 2.4.5 Lab 5: Adding an Interrupt and Importing Macros for a Push Button Interface ................................................................................................ 56 2.4.5.1 New Registers Used in This Lab ............................................... 56 2.4.5.2 Overview .................................................................................... 56 2.4.5.3 Procedure .................................................................................. 57 2.4.5.4 Testing the Application .............................................................. 64 © 2009 Microchip Technology Inc. TM PICDEM COMPANION GUIDE Table of Contents LAB FLOWCODE DS41381A-page iii ...

Page 4

... Equipment Required ..................................................................................88 4.2.3 Lab 1: Simple ADC ....................................................................................89 4.2.3.1 New Registers Used in This Lab ................................................89 4.2.3.2 Overview ....................................................................................89 4.2.3.3 Procedure ..................................................................................90 4.2.3.4 Testing the Application ...............................................................95 4.2.4 Lab 2: Audible Temperature Sensor ..........................................................95 4.2.4.1 Overview ....................................................................................95 4.2.4.2 Procedure ..................................................................................96 4.2.4.3 Testing the Application .............................................................104 DS41381A-page iv © 2009 Microchip Technology Inc. ...

Page 5

... The manual layout is as follows: • Chapter 1. “Getting Started” • Chapter 2. “General Purpose Input/Output Labs” • Chapter 3. “Comparator Peripheral” • Chapter 4. “Analog-to-Digital Converter Peripheral Labs” © 2009 Microchip Technology Inc. PICDEM COMPANION GUIDE Preface NOTICE TO CUSTOMERS TM LAB FLOWCODE ® ...

Page 6

... Optional arguments mcc18 [options] file [options] Choice of mutually exclusive errorlevel {0|1} arguments selection Replaces repeated text var_name [, var_name...] Represents code supplied by void main (void) user { ... } © 2009 Microchip Technology Inc. Examples ® IDE User’s Guide ...

Page 7

... Programmers – The latest information on Microchip programmers. These include the MPLAB PM3 and PRO MATE Plus and PICkit™ 1 development programmers. © 2009 Microchip Technology Inc. ® II device programmers and the PICSTART Preface ® ...

Page 8

... Local sales offices are also available to help customers. A listing of sales offices and locations is included in the back of this document. Technical support is available through the web site at: http://support.microchip.com DOCUMENT REVISION HISTORY Revision A (April 2009) DS41381A-page 4 © 2009 Microchip Technology Inc. ...

Page 9

... Install Flowcode V3 – free version link. Click on the link to begin the installation process the File Download window, select Run (Figure 1-1). FIGURE 1-1: © 2009 Microchip Technology Inc. TM PICDEM LAB FLOWCODE COMPANION GUIDE FILE DOWNLOAD WINDOW ...

Page 10

... PICkit 2 Programming software could be used. However, for convenience, PPP is recommended to be installed. Click the Install PPP x.x button to open a separate installer and follow the prompts (Figure 1-4). DS41381A-page 6 SECURITY WINDOW FLOWCODE WELCOME WINDOW ® MCU Parallel Programming (PPP) © 2009 Microchip Technology Inc. ...

Page 11

... Next> to continue (Figure 1-5). FIGURE 1- the License Agreement window, ensure that the I accept the license agreement radio button is selected to continue with the installation and click Next> (Figure 1-6). © 2009 Microchip Technology Inc. INSTALL PREREQUISITE SOFTWARE WINDOW USER INFORMATION WINDOW Getting Started DS41381A-page 7 ...

Page 12

... PICkit 2 Programmer/Debugger will be used. In the Choose the Default Programmer window, be sure to select the Microchip PICkit 2 radio button to select the PICkit 2 Programmer/Debugger as the default programmer and click Next> to continue (Figure 1-8). DS41381A-page 8 LICENSE AGREEMENT WINDOW DESTINATION FOLDER WINDOW © 2009 Microchip Technology Inc. ...

Page 13

... The install process should begin. This may take a few minutes. 11. In the Enter Flowcode for PIC a key (upgrade or no key)” to use the free version of the software and click Next> to continue (Figure 1-10). © 2009 Microchip Technology Inc. CHOOSE THE DEFAULT PROGRAMMER WINDOW READY TO INSTALL APPLICATION WINDOW ® ...

Page 14

... Following successful installation, a Confirmation window will open. Click Finish to exit the installer (Figure 1-11). FIGURE 1-11: Flowcode V3 – free version is now installed and ready to use. DS41381A-page 10 ® ENTER FLOWCODE FOR PIC MCU LICENSE KEY SUCCESSFUL INSTALLATION CONFIRMATION WINDOW © 2009 Microchip Technology Inc. ...

Page 15

... PICDEM_Lab_Flowcode.zip link. Extract the contents of the .zip file to the C:\ directory. These files provide a location to store any projects developed while completing the labs in this user’s guide and solutions for each in a folder called solutions. © 2009 Microchip Technology Inc. Getting Started DS41381A-page 11 ...

Page 16

... TM PICDEM Lab Flowcode Companion Guide NOTES: DS41381A-page 12 © 2009 Microchip Technology Inc. ...

Page 17

... Reference Resources Free support documentation from www.microchip.com: • DS41262D – PIC16F690 data sheet - Section 2.2.2.2: Option Register - Section 2.2.2.3: Interrupt Control Register INTCON - Section 4: I/O Ports © 2009 Microchip Technology Inc. TM PICDEM LAB FLOWCODE COMPANION GUIDE ® devices have multiple GPIO peripherals ...

Page 18

... PICDEM LAB SCHEMATIC FOR GPIO OUTPUT LABS RC5 RC0 6 RC4 RC1 7 RC3 RC2 8 RC6 9 RC7 470Ω 470Ω 470Ω 470Ω LED7 LED6 LED5 LED4 470Ω 470Ω 470Ω LED3 LED2 LED1 © 2009 Microchip Technology Inc. ...

Page 19

... Start>All Programs>Matrix Multimedia>Flowcode Vx>Flowcode Vx 2. Click OK to continue the Start-up window, ensure the Create a new FlowCode Flowchart radio button is selected and click OK (Figure 2-2). © 2009 Microchip Technology Inc. General Purpose Input/Output Labs Creating a Project in Flowcode to Light LEDs ). The Flowcode software will automatically ...

Page 20

... TM PICDEM Lab Flowcode Companion Guide FIGURE 2- the Choose a Target window, highlight the PIC16F690 microcontroller and click OK (Figure 2-3). FIGURE 2-3: 5. The FlowCode workspace should now resemble Figure DS41381A-page 16 FLOWCODE START-UP WINDOW CHOOSE A TARGET WINDOW 2-4. © 2009 Microchip Technology Inc. ...

Page 21

... FIGURE 2- Note: A more detailed overview of the workspace is provided in the FlowCode Help files: Help>Contents. 6. Save the project to the C:\PICDEM_Lab\flowcode\GPIO_Labs\GPIO_Lab1 directory as GPIO_Lab1.fcf. © 2009 Microchip Technology Inc. General Purpose Input/Output Labs FLOWCODE WORKSPACE FlowCode Workspace: 1 Simulation Toolbar 2 Compiler Toolbar 3 Microcontroller View Window 4 Icons Toolbar ...

Page 22

... Figure 2-6. DS41381A-page 18 ® Configuration window, select “Switch to Expert ® PIC CONFIGURATION WINDOW ® Configuration (expert) window, ensure that the PIC16F690 is ® MCU Configuration Tool to © 2009 Microchip Technology Inc. ...

Page 23

... FIGURE 2-7: Click OK. The PIC16F690 is now configured for the application. In the next series of steps, the flowchart for the application will be developed: © 2009 Microchip Technology Inc. General Purpose Input/Output Labs PIC16F690 CONFIGURATION FOR LAB 1 (Done or OK???). ...

Page 24

... In the Flowchart window, open the Output icon properties by either doubling clicking on the icon or by right clicking on the icon and selecting Properties (Figure 2-9). FIGURE 2-9: DS41381A-page 20 OUTPUT ICON INSERTION POINT IN MAIN FLOWCHART Flowchart Window Drag and drop Output Icon into flowchart OUTPUT ICON PROPERTIES WINDOW © 2009 Microchip Technology Inc. ...

Page 25

... These parameters can be edited within the Properties: Loop window by double-clicking on the icon in the flowchart or by right clicking on the icon and selecting Properties... (Figure 2-11). © 2009 Microchip Technology Inc. General Purpose Input/Output Labs LOOP ICON INSERTION ...

Page 26

... Click the Output icon added earlier in the flowchart and drag/drop it between the start and finish of the While loop added in the previous step. The flowchart should now resemble Figure 2-12. FIGURE 2-12: DS41381A-page 22 LOOP ICON PROPERTIES WINDOW UPDATED FLOWCHART WITH OUTPUT ICON INSIDE OF LOOP © 2009 Microchip Technology Inc. ...

Page 27

... Figure 2-13 and select Component Connections... from the drop-down menu. The Specify Component Pin Connections window should now be open. Using the “Connect to:Port:” drop-down menu, select PORTC as shown in Figure 2-14. FIGURE 2-14: © 2009 Microchip Technology Inc. General Purpose Input/Output Labs USING THE LEDS COMPONENT Click here to edit Component ...

Page 28

... Once completed, the Compiler Messages window should indicate that the project compiled and was successfully downloaded to the DS41381A-page 24 FLOWCODE SOFTWARE SIMULATION TOOLBAR LEDS COMPONENT SIMULATION RESULT Step over Step into Stop Pause Run in the compiler © 2009 Microchip Technology Inc. ...

Page 29

... Once programmed and powered, the LEDs connected to the individual PORTC pins should now resemble the output shown in Figure 2-18. FIGURE 2-18: R8 470Ω LED8 LED ON © 2009 Microchip Technology Inc. General Purpose Input/Output Labs COMPILER MESSAGES WINDOW INDICATING SUCCESSFUL COMPILATION Indicates successful compilation LAB 1 LED OUTPUT ...

Page 30

... PORTC. Using a variable, rather than simply assigning a value to PORTC, allows the firmware to manipulate the data in the variable without outputting data to the I/O pins until it is finally assigned to DS41381A-page 26 THE SOFTWARE CONTROL LOOP START Initialize Get_Inputs Decide Loop Forever Do_Outputs Timing © 2009 Microchip Technology Inc. ...

Page 31

... In this application, the LED_Output variable will be assigned to the 8-bit PORTC register. Therefore, the Byte variable type will be used. The Create a New Variable window should now resemble Figure 2-20. © 2009 Microchip Technology Inc. General Purpose Input/Output Labs DS41381A-page 27 ...

Page 32

... PICDEM Lab Flowcode Companion Guide FIGURE 2-20: Click OK to continue. The Variable Manager window should now display the newly created variable as shown in Figure 2-21. FIGURE 2-21: Click Close. DS41381A-page 28 CREATE A NEW VARIABLE WINDOW VARIABLE MANAGER WINDOW © 2009 Microchip Technology Inc. ...

Page 33

... Next, change the “Display name:” in the Properties: Calculation window to Initialize. Add the calculation code to assign the initial value of 0b11111111 (all LED_Output data bits high), as shown in Figure 2-23. © 2009 Microchip Technology Inc. General Purpose Input/Output Labs ADDING THE CALCULATION ICON ...

Page 34

... Click OK to close the window. 5. Immediately under the Initialize block, drag/drop a Loop icon to create the Infinity loop, as was done in step 12 of the previous lab. The flowchart should now resemble Figure 2-24. DS41381A-page 30 CONFIGURING THE CALCULATION PROPERTIES FOR THE INITIALIZE BLOCK © 2009 Microchip Technology Inc. ...

Page 35

... While loop. Open the Properties: Calculation window, change the “Display name:” to Decide, add the LED_Output variable as per step 4 and add the XOR operation calculation code as shown in Figure 2-25. © 2009 Microchip Technology Inc. General Purpose Input/Output Labs FLOWCHART WITH INITIALIZE BLOCK AND INFINITY WHILE LOOP ...

Page 36

... Entire Port radio button is enable. Use the “Variable or value” drop menu to select the LED_Output vari- able. The Properties: Output window should now resemble Figure 2-26. DS41381A-page 32 PROPERTIES: CALCULATION FOR DECIDE FUNCTIONAL BLOCK © 2009 Microchip Technology Inc. ...

Page 37

... Software Control loop to execute in 1-second intervals. To accomplish this, the Delay icon is used. Drag/drop the Delay icon from the icon toolbar into the flowchart immediately after the Do_Outputs functional block (Figure 2-27). © 2009 Microchip Technology Inc. General Purpose Input/Output Labs PROPERTIES: OUTPUT FOR DO_OUTPUTS FUNCTIONAL ...

Page 38

... FIGURE 2-28: Click OK to close the window. The project flowchart should now resemble Figure 2-29. DS41381A-page 34 ADDING THE DELAY ICON Icon Toolbar Drag and drop Delay Icon into flowchart PROPERTIES: DELAY FOR TIMING FUNCTIONAL BLOCK Flowchart Window © 2009 Microchip Technology Inc. ...

Page 39

... Compile the project to HEX and download to the PIC16F690 as per steps 16 through 20 of Lab 1. There should be no errors. 2.3.5.3 TESTING THE APPLICATION The LEDs connected to the individual PORTC pins should now all flash ON/OFF in 1-second intervals. © 2009 Microchip Technology Inc. General Purpose Input/Output Labs GPIO_LAB 2 FLOWCHART DS41381A-page 35 ...

Page 40

... Enter the description shown in Figure 2- description that clearly defines how this macro will behave and click OK to close the window. DS41381A-page 36 RESULTS OF DO_OUTPUT( ) PORTC Do_Outputs assigns LED_Output to PORTC PORTC Do_Outputs assigns LED_Output to PORTC Corresponding LED lights Corresponding LED lights © 2009 Microchip Technology Inc. ...

Page 41

... LED_Output variable for the condition when the LSb is set, a Decision icon is used. Drag/drop a Decision icon from the icon toolbar into the macro flowchart between the BEGIN and END blocks (Figure 2-32). © 2009 Microchip Technology Inc. General Purpose Input/Output Labs CREATE A NEW MACRO WINDOW FOR SHIFT_RT ...

Page 42

... MSb. To accomplish this, drag/drop a Calculation icon onto the “Yes” branch of the Decision icon, as shown in Figure 2-34. DS41381A-page 38 ADDING A DECISION ICON Icon Toolbar Drag and drop Decision Icon into flowchart PROPERTIES: DECISION FOR SHIFT_RT MACRO Flowchart Window © 2009 Microchip Technology Inc. ...

Page 43

... FIGURE 2-34: 7. Open the Properties: Calculation window and configure, as shown in Figure 2-35. FIGURE 2-35: © 2009 Microchip Technology Inc. General Purpose Input/Output Labs ADDING A CALCULATION ICON ONTO THE YES BRANCH OF THE DECISION ICON CONFIGURING THE CALCULATION ICON TO RE-INITIALIZE LED_OUTPUT DATA DS41381A-page 39 ...

Page 44

... Decision icon before the intersection with the arrowhead from the icon added in the previous steps (Figure 2-36). FIGURE 2-36: 9. Open the Properties: Calculation window and configure, as shown in Figure 2-37. DS41381A-page 40 ADDING CALCULATION ICON TO THE NO BRANCH OF DECISION ICON © 2009 Microchip Technology Inc. ...

Page 45

... Alternately, to shift the contents of LED_Output to the left, the left shift operator “<<” is used. The Shift_Rt macro is now completed. The flowchart should resemble Figure 2-38. © 2009 Microchip Technology Inc. General Purpose Input/Output Labs CONFIGURING CALCULATION ICON TO SHIFT LED_OUTPUT DATA RIGHT BY 1 BIT ...

Page 46

... Return to the Main flowchart by clicking on it. To call the Shift_Rt macro, drag/drop a Macro icon from the icon toolbar and inset it into the main flowchart immediately before the Do_Outputs functional block (Figure 2-39). DS41381A-page 42 SHIFT_RT MACRO FLOWCHART © 2009 Microchip Technology Inc. ...

Page 47

... Macro: window. Select the Shift_Rt macro by clicking highlight. Next, change the Display name: to Decide and click OK to close the window (Figure 2-40). FIGURE 2-40: © 2009 Microchip Technology Inc. General Purpose Input/Output Labs ADDING THE MACRO ICON Icon Toolbar ...

Page 48

... The final flowchart should now resemble Figure 2-41. FIGURE 2-41: Compile the project to chip. There should be no errors. 2.3.6.3 TESTING THE APPLICATION The LEDs connected to the individual PORTC pins should now flash ON/OFF sequentially from left-to-right in 1-second intervals. DS41381A-page 44 FINAL FLOWCHART FOR GPIO_LAB3 © 2009 Microchip Technology Inc. ...

Page 49

... PICDEM Lab Development Board Setup for GPIO Input Labs The GPIO input labs will require that the PICDEM Lab Development Board be configured as shown in Figure 2-42, using the components listed in the previous section. © 2009 Microchip Technology Inc. General Purpose Input/Output Labs DS41381A-page 45 ...

Page 50

... PICDEM LAB SCHEMATIC FOR GPIO INPUT LABS RA2 RC5 RC0 6 RC4 15 RC1 7 14 RC3 RC2 8 13 RC6 9 12 RC7 470Ω 470Ω 470Ω 470Ω LED6 LED5 LED4 LED3 SW1 R9 10KΩ 470Ω 470Ω LED2 LED1 © 2009 Microchip Technology Inc. ...

Page 51

... Immediately following the Initialize block, add the loop component to implement the Infinity loop discussed in the previous labs. The flowchart should now resemble Figure 2-43. © 2009 Microchip Technology Inc. General Purpose Input/Output Labs (refer to Figure 2-42). The pull-down resistor ensures SS ...

Page 52

... Select the switch component from the component toolbar by clicking on it (Figure 2-44). FIGURE 2-44: Switch Component DS41381A-page 48 GPIO_LAB4 FLOWCHART WITH INITIALIZE BLOCK AND INFINITY LOOP ADDED SELECTING THE SWITCH COMPONENT Click here to edit Component connections and properties Component Toolbar © 2009 Microchip Technology Inc. ...

Page 53

... Component Connections... In the Specify Component Pin Connections window, select Bit: 2 from the appropriate drop-down menu. The window should now resemble Figure 2-46. © 2009 Microchip Technology Inc. General Purpose Input/Output Labs CONFIGURING THE NUMBER OF SWITCHES AND DEBOUNCE TIME ...

Page 54

... To access these pre-defined macros, the Component Macro icon is used. Drag/drop the Component Macro icon from the icon toolbar to the flowchart within the While loop (see Figure 2-47). DS41381A-page 50 CONNECTING THE SINGLE SWITCH TO PORTA BIT 2 © 2009 Microchip Technology Inc. ...

Page 55

... Return Value:(BYTE) window copy the direction variable initialized in step 2 of this lab. The window should now resemble Figure 2-48. © 2009 Microchip Technology Inc. General Purpose Input/Output Labs ADDING A COMPONENT MACRO ...

Page 56

... Create a new macro as was done in step 3 of the previous lab. Name the macro Shift and provide a “Description of new macro:” as shown in Figure 2-49 or some other description equally as revealing as to the purpose of the macro. DS41381A-page 52 CONFIGURING THE COMPONENT MACRO © 2009 Microchip Technology Inc. ...

Page 57

... Flowcode workspace shown in Figure 2-51. The reader should refer to the previous lab sections on how to add each icon in the component macro. © 2009 Microchip Technology Inc. General Purpose Input/Output Labs CREATE A NEW MACRO WINDOW FOR LAB 4 ...

Page 58

... Shift LED_Output data right one bit LED_Output position = 0b00000001 LED_Output data all zeros? NO END FLOWCHART FOR COMPONENT MACRO AS IT SHOULD APPEAR IN FLOWCODE ENVIRONMENT YES Significant bit set? NO make LED_Output position = 0b10000000 YES make LED_Output = 0b00000001 © 2009 Microchip Technology Inc. ...

Page 59

... Timing and configuring the properties to perform a 1-second delay. 14. The main flowchart should now resemble Figure 2-52. FIGURE 2-52: Compile the project to chip. There should be no errors. © 2009 Microchip Technology Inc. General Purpose Input/Output Labs FINAL FLOWCHART FOR GPIO LAB 4 DS41381A-page 55 ...

Page 60

... Other events that trigger interrupts associated with different peripherals on the PIC16F690 include a change on the output of the comparator peripheral or the completion of a conversion using the Analog-to-Digital Converter (ADC), to name but a few. DS41381A-page 56 ® device will have an interrupt associated with it that © 2009 Microchip Technology Inc. ...

Page 61

... Macro dialog. Highlight the Shift macro and click Export (see Figure 2-53). FIGURE 2-53: 2. The user will be prompted to select a directory into which to save the Shift macro. Navigate to the C:\PICDEM_Lab\flow- code\GPIO_Labs\GPIO_Lab5 directory and save the macro there. © 2009 Microchip Technology Inc. General Purpose Input/Output Labs EXPORT MACRO WINDOW DS41381A-page 57 ...

Page 62

... Add the Timing functional block below the Do_Outputs functional block using the Delay icon and configure for 1 second. 9. The flowchart should now resemble Figure 2-55. DS41381A-page 58 CONFIGURING THE MACRO PROPERTIES TO CALL THE SHIFT MACRO CREATED IN LAB 4 © 2009 Microchip Technology Inc. ...

Page 63

... RA2 pin. To create the interrupt, the Interrupt icon will be used. Drag/drop an Interrupt icon to the very beginning of the main flowchart just beneath the BEGIN point (see Figure 2-56). © 2009 Microchip Technology Inc. General Purpose Input/Output Labs FLOWCHART UP TO THIS POINT DS41381A-page 59 ...

Page 64

... Interrupt Properties window, select “rising edge of RB0/INT” in the “Interrupt Edge Select” drop-down menu (see Figure 2-58). DS41381A-page 60 ADDING THE INTERRUPT ICON Icon Toolbar Drag and drop Interrupt Icon into flowchart CONFIGURING AN INTERRUPT FOR INT Flowchart Window © 2009 Microchip Technology Inc. ...

Page 65

... Macro... button. The Create a New Macro window will now open. Rename the macro as INT_ISR and provide a description in the Description of New Macro: window similar to that shown in Figure 2-59. © 2009 Microchip Technology Inc. General Purpose Input/Output Labs CONFIGURING THE INT INTERRUPT PROPERTIES ...

Page 66

... Change the “Display name:” to “Toggle direction variable”. In the Calcu- lations: window add the text that will toggle the direction variable from 0-to-1 or 1-to-0 each time the interrupt is triggered using the XOR command as was done in previous labs (see Figure 2-60). DS41381A-page 62 INT_ISR MACRO PROPERTIES © 2009 Microchip Technology Inc. ...

Page 67

... Click OK to continue. 17. The INT_ISR flowchart should now resemble Figure 2-61. FIGURE 2-61: 18. Return to the main Flowchart window. The main flowchart should now resemble Figure 2-62. © 2009 Microchip Technology Inc. General Purpose Input/Output Labs CALCULATION PROPERTIES FOR INT_ISR INT_ISR FLOWCHART DS41381A-page 63 ...

Page 68

... ON/OFF flashing to left-to-right. This should behave the same as the previous lab. The user may notice that the LEDs are now more responsive to the push button press thanks to the addition of an interrupt. DS41381A-page 64 FINAL FLOWCHART FOR GPIO_LAB 5 © 2009 Microchip Technology Inc. ...

Page 69

... KΩ potentiometer 5. 1 – 100 KΩ NTC Thermistor 6. 4 – Light Emitting Diodes 7. 1 – 1N4148 Diodes 8. 1 – 1 μF Capacitor 9. PIC16F690 populating socket U2 10. Assorted jumper wires © 2009 Microchip Technology Inc. TM PICDEM LAB FLOWCODE COMPANION GUIDE DS41381A-page 65 ...

Page 70

... A LED connected to the output of Comparator 1 (C1OUT) will light or turn off as follows: • inverting reference > non-inverting reference = C1OUT is LOW = LED OFF • inverting reference < non-inverting reference = C1OUT is HIGH = LED ON The PICDEM Development Board configuration schematic is shown in Figure DS41381A-page 66 3-1. © 2009 Microchip Technology Inc. ...

Page 71

... In the Flowcode environment add a Loop icon between the BEGIN and END points of the main flowchart. 3. Next, create a new macro by selecting Macro>New.... Name the new macro Init_Comparator and provide a description of the macro similar to that shown in Figure 3-2. © 2009 Microchip Technology Inc. Comparator Peripheral SCHEMATIC FOR COMPARATOR LAB ...

Page 72

... In the Init_Comparator macro flowchart workspace, drag/drop a C Code icon between the BEGIN and END points (see Figure 3-3). FIGURE 3-3: C Code Icon DS41381A-page 68 INIT_COMPARATOR MACRO DETAILS ADDING A C CODE ICON Icon Toolbar Drag and drop C Code Icon into flowchart Flowchart Window © 2009 Microchip Technology Inc. ...

Page 73

... The Properties: C Code window should now resemble Figure 3-4. FIGURE 3-4: Click OK to continue. The flowchart should now resemble Figure 3-5. FIGURE 3-5: © 2009 Microchip Technology Inc. Comparator Peripheral PROPERTIES: C CODE WINDOW WITH COMPARATOR CONFIGURATION CODE ADDED FINAL FLOWCHART FOR INIT_COMPARATOR MACRO ...

Page 74

... Double-click on the Macro icon to open its properties. Change the “Display name:” to Initialize, highlight the Init_Comparator macro created in the previous steps and click OK (see Figure 3-6). FIGURE 3-6: The final flowchart for this lab should now resemble Figure 3-7. DS41381A-page 70 INITIALIZE FUNCTIONAL BLOCK MACRO © 2009 Microchip Technology Inc. ...

Page 75

... The LED connected to the C1OUT pin should light when the voltage present on the C12IN0- pin is less than the 2.5V present on the C1IN+ pin and turn off when the 2.5V is exceeded. The solution for this project can be found in the C:\PICDEM_Lab\Flowcode\Comparator_Labs\Comparator_Lab1\solution directory. © 2009 Microchip Technology Inc. Comparator Peripheral FINAL FLOWCHART FOR COMPARATOR_LAB1 DS41381A-page 71 ...

Page 76

... REF features: REF DD SS Range Selection (VRR) bit in the VRCON (Voltage Reference REF Value Selection bits (VR<3:0>). The Value REF voltage is determined using Equation 3-1: REF CVREF Output Voltage CV = (VR<3:0>/24 REF /4) + (VR<3:0> REF DD DD /32) © 2009 Microchip Technology Inc. ...

Page 77

... Changes to the PICDEM Development Board configuration schematic for this lab are shown in Figure 3-8. FIGURE 3-8: J8 3.2.5.3 PROCEDURE 1. Create a new project in Flowcode saving the project as Comparator_Lab2.fcf in the C:\PICDEM_Lab\flowcode\Comparator_Labs\Comparator_Lab2 directory. © 2009 Microchip Technology Inc. Comparator Peripheral Calculating a 2.5V Internal Reference (Low-Range Method (VR<3:0>/24 REF DD = 2.5V, V approximately 5V REF DD 2.5V = (VR< ...

Page 78

... The application should behave exactly as it did in Lab 1 with the exception of less components used. The solution for this project can be found in the C:\PICDEM_Lab\Flowcode\Comparator_Labs\Comparator_Lab2\solution directory. DS41381A-page 74 REF //as non-inverting input to //Comparator 1 REF UPDATED PROPERTIES: C CODE WINDOW FOR INIT_COMPARATOR MACRO peripheral. Therefore, the output REF to 2.5V. © 2009 Microchip Technology Inc. ...

Page 79

... R1. Once the capacitor charge drops below the voltage on the non-inverting reference, the cycle repeats and the system oscillates. The frequency of this oscillation is dependant on the RC time constant (τ C), or the time it takes to © 2009 Microchip Technology Inc. Comparator Peripheral / external clock source on the Timer0 Clock Input pin ...

Page 80

... In other words: increase temp. = increased oscillator frequency = decrease counter value decrease temp. = decreased oscillator frequency = increased counter value The schematic for this lab is shown in Figure 3-11. DS41381A-page 76 ® microcontrollers is the 8-bit timer/counter © 2009 Microchip Technology Inc. /4) as OSC ...

Page 81

... Prescaler rates for the Timer0 module available are: -1 TMR0 increment: 1 clock source pulse -1 TMR0 increment: 2 clock source pulse -1 TMR0 increment: 4 clock source pulse -1 TMR0 increment: 8 clock source pulse -1 TMR0 increment: 64 clock source pulse © 2009 Microchip Technology Inc. Comparator Peripheral SCHEMATIC FOR COMPARATOR LAB 3 D1 1N4148 U2 ...

Page 82

... The Properties: C Code window should now resemble Figure 3-13. DS41381A-page 78 ADDING LINES OF C CODE //Turn on Comparator 2 //Enable Comparator 2 output on the //C2OUT pin //Connect Comparator non-inverting //reference to RC0/C2IN+ pin //Connect Comparator inverting reference //to RC1/C12IN1- pin © 2009 Microchip Technology Inc. ...

Page 83

... FIGURE 3-13: Click OK. Note: The nomenclature to set individual bits in C requires the source register be identified in lowercase followed by a decimal then the specific bit in upper- case. © 2009 Microchip Technology Inc. Comparator Peripheral PROPERTIES: C CODE WINDOW INIT_C2_TMR0 DS41381A-page 79 ...

Page 84

... The Properties: Calculation window should now resemble Figure 3-14. FIGURE 3-14: Click OK to continue. The Init_Peripherals macro flowchart should now resemble Figure 3-15. DS41381A-page 80 PROPERTIES: CALCULATION WINDOW FOR INITIALIZE_ VARIABLES © 2009 Microchip Technology Inc. ...

Page 85

... Double-click the Interrupt icon to open the Properties: Interrupt window. Select TMR0 Overflow from the “Interrupt on:” drop-down menu. Click on the Properties... button and using the associated drop-down menus, configure the Timer0 interrupt, as shown in Figure 3-16. © 2009 Microchip Technology Inc. Comparator Peripheral INIT_PERIPHERALS FLOWCHART FOR COMPARATOR_LAB3 DS41381A-page 81 ...

Page 86

... In the Properties: Interrupt window click the Create New Macro... button to open the Create a New Macro window. Rename the macro TMR0_ISR and provide a description of the macro similar to that shown in Figure 3-17. DS41381A-page 82 CONFIGURATION FOR TMR0 OVERFLOW INTERRUPT © 2009 Microchip Technology Inc. ...

Page 87

... LEDs connected to the PIC16F690 pins. The Properties: Calculation window should now resemble Figure 3-18. © 2009 Microchip Technology Inc. Comparator Peripheral CREATE A NEW MACRO WINDOW FOR TMR0 INTERRUPT SERVICE ROUTINE ...

Page 88

... In the main flowchart window, drag/drop a Loop icon immediately beneath the Interrupt icon to create the Infinity loop used in all the previous labs. DS41381A-page 84 ASSIGNING THE COUNTER VARIABLE TO LED_OUTPUT USING THE CALCULATION ICON TMR0_ISR FLOWCHART FOR TIMER0 OVERFLOW INTERRUPT © 2009 Microchip Technology Inc. ...

Page 89

... LED_Output variable from the “Variable or value:” drop-down menu and select PORTB from the “Port:” drop-down menu as the destination for the value in LED_Output. The Properties: Output window should now resemble Figure 3-21. © 2009 Microchip Technology Inc. Comparator Peripheral PROPERTIES: CALCULATION CONFIGURATION FOR DECIDE FUNCTIONAL BLOCK ...

Page 90

... Double-click the icon, rename to Timing and configure for 1mS delay as shown in Figure 3-22. FIGURE 3-22: Click OK to continue. The final flowchart for Comparator_lab3 should now resemble Figure 3-23. DS41381A-page 86 PROPERTIES: OUTPUT WINDOW FOR DO_OUTPUTS FUNCTIONAL BLOCK PROPERTIES: DELAY CONFIGURATION FOR TIMING FUNCTIONAL BLOCK © 2009 Microchip Technology Inc. ...

Page 91

... Comparator 2 “trip” level by changing the voltage on the non-inverting reference input. The solution for this project can be found in the C:\PICDEM_Lab\Flowcode\Comparator_Labs\Comparator_Lab3\solution directory. © 2009 Microchip Technology Inc. Comparator Peripheral FINAL FLOWCHART FOR COMPARATOR_LAB3 DS41381A-page 87 ...

Page 92

... TM PICDEM Lab Flowcode Companion Guide NOTES: DS41381A-page 88 © 2009 Microchip Technology Inc. ...

Page 93

... ADC RESULT Note: Assumes that V the voltage present on V Example: If following an ADC, the result is the following 10-bit value: 10-BIT ADC RESULT 2.5V = © 2009 Microchip Technology Inc. PICDEM COMPANION GUIDE 10-BIT ADC RESULT BIT SIGNIFICANCE used as the ADC reference external reference is used, DD ...

Page 94

... ADC RESULT BIT SIGNIFICANCE used as the ADC reference external reference is used, DD pin is substituted for V REF 128 128 0.625V 0.15625V 0.0390625V + + + 256 128 . Bit positions set to 1 are added together = 3.32V (rounded to the nearest mV) voltage as a reference. DD © 2009 Microchip Technology Inc. ...

Page 95

... ADC and will be used to capture the 8-bit representation of the voltage level. The 8-bit result will then be assigned to PORTC to light LEDs connected to its 8 pins for display. The PICDEM Lab Development Board configuration schematic is shown in Figure 4-3. © 2009 Microchip Technology Inc. voltage internally. Flowcode DD DS41381A-page 89 ...

Page 96

... SCHEMATIC FOR ADC LAB RC5 RC0 6 15 RC4 RC1 7 14 RC3 RC2 8 13 RC6 RB4/AN10 9 12 RC7 470Ω 470Ω 470Ω 470Ω LED6 LED5 LED4 LED3 100 KΩ 470Ω 470Ω LED2 LED1 © 2009 Microchip Technology Inc. ...

Page 97

... ADC:” drop-down menu, select ADC10 to use the RB4/AN10 pin as the ADC input channel. The Specify Component Pin Connections window should now resemble Figure 4-6. © 2009 Microchip Technology Inc. MAIN FLOWCHART WITH THE INITIALIZE FUNCTIONAL BLOCK AND LOOP USING THE ADC COMPONENT ...

Page 98

... Double-click the Component Macro icon to open the Properties: Component Macro window and rename to Get_Inputs. In the “Component:” list, select ADC(0) to reveal the available component macros. In the “Macro:” list, select the SampleADC macro (see Figure 4-7). DS41381A-page 92 ADC SPECIFY COMPONENT PIN CONNECTIONS WINDOW © 2009 Microchip Technology Inc. ...

Page 99

... Select the LED_Output variable as the destination for the 8-bit ADC value from the “Return Value:(BYTE)” drop-down list. The Properties: Component Macro window should now resemble Figure 4-8. © 2009 Microchip Technology Inc. SELECTING THE SAMPLEADC MACRO FOR THE ADC COMPONENT ...

Page 100

... Drag/drop an Output icon immediately under the Decide functional block, rename to Do_Outputs and assign the LED_Output value to PORTC (Figure 4-9). FIGURE 4-9: DS41381A-page 94 PROPERTIES: COMPONENT MACRO WINDOW FOR DECIDE FUNCTIONAL BLOCK OUTPUT ICON CONFIGURATION FOR DO_OUTPUTS FUNCTIONAL BLOCK © 2009 Microchip Technology Inc. ...

Page 101

... ADC peripheral. The PWM is used to drive an N-Channel MOSFET connected to the RC0 pin that will drive the speaker mounted on the PICDEM Lab Development Board. A resulting tone will be generated by the © 2009 Microchip Technology Inc. FINAL FLOWCHART FOR ADC_LAB1 DS41381A-page 95 ...

Page 102

... Create a new project in Flowcode using steps 1 through 9 from GPIO_Lab1 sav- ing the project as ADC_Lab2.fcf in the C:\PICDEM_Lab\flowcode\ADC_Labs\ADC_Lab2 directory. DS41381A-page 96 SCHEMATIC FOR ADC LAB RC0 RB4/AN10 1KΩ KΩ 100Ω J19 SP+ LS1 8Ω SP- Q1 IRFD010 N-Channel MOSFET KΩ © 2009 Microchip Technology Inc. ...

Page 103

... Ensure that the ADC Component is selected and appears in the workspace. Drag/drop two Component Macro icons into the flowchart. Double-click on the top icon to open the Properties window and rename to Initiate ADC. Select the SampleADC macro as shown in Figure 4-13. © 2009 Microchip Technology Inc. CREATE A NEW MACRO WINDOW FOR READ_ADC DS41381A-page 97 ...

Page 104

... Assign result to adc_result, select the ReadAsByte macro and assign to the adc_result variable created in the Initialize functional block (see Figure 4-14). FIGURE 4-14: DS41381A-page 98 PROPERTIES: COMPONENT MACRO WINDOW FOR INITIATE ADC PROPERTIES: COMPONENT MACRO WINDOW FOR ASSIGN RESULT TO ADC_RESULT © 2009 Microchip Technology Inc. ...

Page 105

... ADC result from the resistor/thermistor voltage divider. Once comfortable with the contents of this lab, the reader is encouraged to manipulate this code and observe the results. The Read_ADC macro flowchart should now resemble Figure 4-16. © 2009 Microchip Technology Inc. PROPERTIES: CALCULATION WINDOW FOR SHIFT ADC_RESULT BITS DS41381A-page 99 ...

Page 106

... Calculation icon and double-click to open the Properties window. In the Properties window, rename the icon to Decide and enter the code to toggle the bits within the toggle variable (see Figure 4-17). FIGURE 4-17: DS41381A-page 100 FLOWCHART FOR READ_ADC MACRO PROPERTIES: CALCULATION WINDOW FOR DECIDE FUNCTIONAL BLOCK © 2009 Microchip Technology Inc. ...

Page 107

... Next, the Delay loop that will vary the frequency of the RC0 toggle will be created. Create a new macro called Loop_Delay and provide a description similar to that shown in Figure 4-19. FIGURE 4-19: © 2009 Microchip Technology Inc. PROPERTIES: OUTPUT WINDOW FOR THE DO_OUTPUTS FUNCTIONAL BLOCK CREATE A NEW MACRO WINDOW FOR LOOP_DELAY MACRO ...

Page 108

... To decrement the adc_result variable each time through the loop, drag/drop a Calculation icon into the newly created loop and add the code shown in Figure 4-21. FIGURE 4-21: DS41381A-page 102 PROPERTIES: LOOP FOR ADC_RESULT VARIABLE DEPENDANT LOOP PROPERTIES: CALCULATION WINDOW TO DECREMENT ADC_RESULT VARIABLE © 2009 Microchip Technology Inc. ...

Page 109

... Properties window and rename to Timing and call the Loop_Delay macro created in the previous steps. Click OK to close the window. The main flowchart for this application should now resemble Figure 4-23. © 2009 Microchip Technology Inc. FINAL FLOWCHART FOR LOOP_DELAY MACRO DS41381A-page 103 ...

Page 110

... Pinching the thermistor should introduce body heat to the component thereby increasing the frequency of the speaker output. Colder temperature sources applied to the thermistor should reduce the speaker output frequency. The solution for this project can be found in the C:\PICDEM_Lab\Flowcode\ADC_Labs\ADC_Lab2\solution directory. DS41381A-page 104 FINAL FLOWCHART FOR ADC_LAB2 © 2009 Microchip Technology Inc. ...

Page 111

... PICDEM™ Lab Flowcode Companion Guide NOTES: © 2009 Microchip Technology Inc. DS41381A-page 105 ...

Page 112

... Fax: 886-3-6578-370 Taiwan - Kaohsiung Tel: 886-7-536-4818 Fax: 886-7-536-4803 Taiwan - Taipei Tel: 886-2-2500-6610 Fax: 886-2-2508-0102 Thailand - Bangkok Tel: 66-2-694-1351 Fax: 66-2-694-1350 © 2009 Microchip Technology Inc. EUROPE Austria - Wels Tel: 43-7242-2244-39 Fax: 43-7242-2244-393 Denmark - Copenhagen Tel: 45-4450-2828 Fax: 45-4485-2829 France - Paris Tel: 33-1-69-53-63-20 ...

Related keywords