F1 LV Evaluation Platform for Enhanced PIC® Microcontrollers User's Guide

F1 LV Evaluation Platform for
Enhanced PIC® Microcontrollers
User’s Guide
 2011 Microchip Technology Inc.
DS41614A
Note the following details of the code protection feature on Microchip devices:
•
Microchip products meet the specification contained in their particular Microchip Data Sheet.
•
Microchip believes that its family of products is one of the most secure families of its kind on the market today, when used in the
intended manner and under normal conditions.
•
There are dishonest and possibly illegal methods used to breach the code protection feature. All of these methods, to our
knowledge, require using the Microchip products in a manner outside the operating specifications contained in Microchip’s Data
Sheets. Most likely, the person doing so is engaged in theft of intellectual property.
•
Microchip is willing to work with the customer who is concerned about the integrity of their code.
•
Neither Microchip nor any other semiconductor manufacturer can guarantee the security of their code. Code protection does not
mean that we are guaranteeing the product as “unbreakable.”
Code protection is constantly evolving. We at Microchip are committed to continuously improving the code protection features of our
products. Attempts to break Microchip’s code protection feature may be a violation of the Digital Millennium Copyright Act. If such acts
allow unauthorized access to your software or other copyrighted work, you may have a right to sue for relief under that Act.
Information contained in this publication regarding device
applications and the like is provided only for your convenience
and may be superseded by updates. It is your responsibility to
ensure that your application meets with your specifications.
MICROCHIP MAKES NO REPRESENTATIONS OR
WARRANTIES OF ANY KIND WHETHER EXPRESS OR
IMPLIED, WRITTEN OR ORAL, STATUTORY OR
OTHERWISE, RELATED TO THE INFORMATION,
INCLUDING BUT NOT LIMITED TO ITS CONDITION,
QUALITY, PERFORMANCE, MERCHANTABILITY OR
FITNESS FOR PURPOSE. Microchip disclaims all liability
arising from this information and its use. Use of Microchip
devices in life support and/or safety applications is entirely at
the buyer’s risk, and the buyer agrees to defend, indemnify and
hold harmless Microchip from any and all damages, claims,
suits, or expenses resulting from such use. No licenses are
conveyed, implicitly or otherwise, under any Microchip
intellectual property rights.
Trademarks
The Microchip name and logo, the Microchip logo, dsPIC,
KEELOQ, KEELOQ logo, MPLAB, PIC, PICmicro, PICSTART,
PIC32 logo, rfPIC and UNI/O are registered trademarks of
Microchip Technology Incorporated in the U.S.A. and other
countries.
FilterLab, Hampshire, HI-TECH C, Linear Active Thermistor,
MXDEV, MXLAB, SEEVAL and The Embedded Control
Solutions Company are registered trademarks of Microchip
Technology Incorporated in the U.S.A.
Analog-for-the-Digital Age, Application Maestro, chipKIT,
chipKIT logo, CodeGuard, dsPICDEM, dsPICDEM.net,
dsPICworks, dsSPEAK, ECAN, ECONOMONITOR,
FanSense, HI-TIDE, In-Circuit Serial Programming, ICSP,
Mindi, MiWi, MPASM, MPLAB Certified logo, MPLIB,
MPLINK, mTouch, Omniscient Code Generation, PICC,
PICC-18, PICDEM, PICDEM.net, PICkit, PICtail, REAL ICE,
rfLAB, Select Mode, Total Endurance, TSHARC,
UniWinDriver, 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.
© 2011, Microchip Technology Incorporated, Printed in the
U.S.A., All Rights Reserved.
Printed on recycled paper.
ISBN: 978-1-61341-776-8
Microchip received ISO/TS-16949:2009 certification for its worldwide
headquarters, design and wafer fabrication facilities in Chandler and
Tempe, Arizona; Gresham, Oregon and design centers in California
and India. The Company’s quality system processes and procedures
are for its PIC® MCUs and dsPIC® DSCs, KEELOQ® code hopping
devices, Serial EEPROMs, microperipherals, nonvolatile memory and
analog products. In addition, Microchip’s quality system for the design
and manufacture of development systems is ISO 9001:2000 certified.
DS41614A-page 2
 2011 Microchip Technology Inc.
F1 LV EVALUATION PLATFORM
USER’S GUIDE
Table of Contents
Chapter 1. F1 LV Evaluation Platform Overview
1.1
1.2
1.3
Introduction ............................................................................................. 11
Platform Contents ................................................................................... 11
Hardware Features ................................................................................. 11
1.3.1
1.3.2
1.3.3
1.3.4
1.3.5
1.3.6
1.3.7
1.3.8
1.3.9
1.3.10
1.3.11
1.3.12
PIC16LF1947 ........................................................................................ 11
MCP9800 I2C™ Temperature Sensor ................................................... 11
PICkit™ 3 Programming/Debug Header ............................................... 12
MCP2200 USB to Serial Converter ....................................................... 12
Two Push Buttons, One Potentiometer, 7 LEDs ................................... 12
One Custom LCD .................................................................................. 12
20-pin Add-on Connector ...................................................................... 12
Current Monitoring Connector ............................................................... 12
Generous Prototyping Area ................................................................... 12
MCP1640 Synchronous Boost Regulator .............................................. 12
MCP1703 LDO Regulator ...................................................................... 12
User Selectable Power Sources ............................................................ 13
Chapter 2. Getting Started
2.1
2.2
2.3
2.4
2.5
2.6
2.7
2.8
Introduction ............................................................................................. 15
Powering the F1 LV Evaluation Platform ................................................ 16
Powering with PICkit™ 3 ........................................................................ 16
Powering from External Power Supply ................................................... 17
Powering with the ADD-on Expansion Header J3 .................................. 18
Powering with a AAA Battery .................................................................. 18
Powering with a USB Cable ................................................................... 19
Default Firmware .................................................................................... 19
2.8.1
2.8.2
2.8.3
2.8.4
2.8.5
Blinking LEDs ........................................................................................ 19
Measuring the Ambient Temperature .................................................... 19
Add-on Motor Expansion ....................................................................... 20
LCD Display ........................................................................................... 20
User Interface ........................................................................................ 20
Chapter 3. Programming the F1 LV Evaluation Platform
3.1
3.2
3.3
Introduction ............................................................................................. 21
Programming/Development Tool Support .............................................. 21
Hardware Resources .............................................................................. 22
Chapter 4. Demo Code
4.1
4.2
4.3
4.4
Introduction ............................................................................................. 25
Service Drivers ....................................................................................... 25
Combined Demo ..................................................................................... 25
Motor Control GUI Application ................................................................ 25
 2011 Microchip Technology Inc.
DS41614A-page 3
F1 LV Evaluation Platform User’s Guide
4.5
4.6
4.7
4.8
BLDC Demo ........................................................................................... 25
BDC Demo ............................................................................................. 26
Unipolar Stepper Demo .......................................................................... 26
Bipolar Stepper Demo ............................................................................ 26
Chapter 5. Hardware Libraries and Drivers
5.1
5.2
5.3
5.4
5.5
5.6
Introduction ............................................................................................. 27
I2C™ Driver ............................................................................................ 27
MCP9800 Driver ..................................................................................... 27
RTCC Driver ........................................................................................... 27
LCD Driver .............................................................................................. 27
Using the I2C™ Driver ............................................................................ 28
5.7
Using the LCD driver .............................................................................. 30
5.8
Using the RTCC Driver ........................................................................... 33
5.9
Using the MCP9800 Driver ..................................................................... 34
5.6.1
5.6.2
5.7.1
5.7.2
5.7.3
5.8.1
5.9.1
I2C Data Structures ................................................................................28
I2C Function Interface ............................................................................29
LCD Data Structures ..............................................................................30
LCD Function Interface ..........................................................................31
LCD Segment Definitions .......................................................................32
RTCC Function Interface .......................................................................33
MCP9800 Function Interface .................................................................34
Chapter 6. Troubleshooting
6.1
6.2
Introduction ............................................................................................. 35
Common Problems ................................................................................. 35
6.2.1
6.2.2
The board will not power up ...................................................................35
LCD is blank, but everything else works ................................................35
Chapter 7. Schematics
7.1
Introduction ............................................................................................ 37
7.1.1
7.1.2
7.1.3
7.1.4
DS41614A-page 4
F1 LV Evaluation Platform Schematic (1 of 4)
F1 LV Evaluation Platform Schematic (2 of 4)
F1 LV Evaluation Platform Schematic (3 of 4)
F1 LV Evaluation Platform Schematic (4 of 4)
.......................................38
.......................................39
.......................................40
.......................................41
 2011 Microchip Technology Inc.
F1 LV EVALUATION PLATFORM
USER’S GUIDE
Preface
NOTICE TO CUSTOMERS
All documentation becomes dated, and this manual is no exception. Microchip tools and
documentation are constantly evolving to meet customer needs, so some actual dialogs
and/or tool descriptions may differ from those in this document. Please refer to our web site
(www.microchip.com) to obtain the latest documentation available.
Documents are identified with a “DS” number. This number is located on the bottom of each
page, in front of the page number. The numbering convention for the DS number is
“DSXXXXXA”, where “XXXXX” is the document number and “A” is the revision level of the
document.
For the most up-to-date information on development tools, see the MPLAB® IDE online help.
Select the Help menu, and then Topics to open a list of available online help files.
INTRODUCTION
This chapter contains general information that will be useful to know before using the
F1 LV Evaluation Platform User’s Guide. Items discussed in this chapter include:
•
•
•
•
•
•
•
•
Document Layout
Conventions Used in this Guide
Warranty Registration
Recommended Reading
The Microchip Web Site
Development Systems Customer Change Notification Service
Customer Support
Document Revision History
DOCUMENT LAYOUT
This document describes how to use the F1 LV Evaluation Platform User’s Guide as a
development tool to emulate and debug firmware on a target board. The manual layout
is as follows:
•
•
•
•
•
•
•
Chapter 1. “F1 LV Evaluation Platform Overview”
Chapter 2. “Getting Started”
Chapter 3. “Programming the F1 LV Evaluation Platform”
Chapter 4. “Demo Code”
Chapter 5. “Hardware Libraries and Drivers”
Chapter 6. “Troubleshooting”
Chapter 7. “Schematics”
 2011 Microchip Technology Inc.
DS41614A-page 5
F1 LV Evaluation Platform User’s Guide
CONVENTIONS USED IN THIS GUIDE
This manual uses the following documentation conventions:
DOCUMENTATION CONVENTIONS
Description
Arial font:
Italic characters
Initial caps
Quotes
Underlined, italic text with
right angle bracket
Bold characters
N‘Rnnnn
Text in angle brackets < >
Courier New font:
Plain Courier New
Represents
Referenced books
Emphasized text
A window
A dialog
A menu selection
A field name in a window or
dialog
A menu path
MPLAB® IDE User’s Guide
...is the only compiler...
the Output window
the Settings dialog
select Enable Programmer
“Save project before build”
A dialog button
A tab
A number in verilog format,
where N is the total number of
digits, R is the radix and n is a
digit.
A key on the keyboard
Click OK
Click the Power tab
4‘b0010, 2‘hF1
Italic Courier New
Sample source code
Filenames
File paths
Keywords
Command-line options
Bit values
Constants
A variable argument
Square brackets [ ]
Optional arguments
Curly brackets and pipe
character: { | }
Ellipses...
Choice of mutually exclusive
arguments; an OR selection
Replaces repeated text
Represents code supplied by
user
DS41614A-page 6
Examples
File>Save
Press <Enter>, <F1>
#define START
autoexec.bat
c:\mcc18\h
_asm, _endasm, static
-Opa+, -Opa0, 1
0xFF, ‘A’
file.o, where file can be
any valid filename
mcc18 [options] file
[options]
errorlevel {0|1}
var_name [,
var_name...]
void main (void)
{ ...
}
 2011 Microchip Technology Inc.
Preface
WARRANTY REGISTRATION
Please complete the enclosed Warranty Registration Card and mail it promptly.
Sending in the Warranty Registration Card entitles users to receive new product
updates. Interim software releases are available at the Microchip web site.
RECOMMENDED READING
This user’s guide describes how to use the F1 LV Evaluation Platform. Other useful
documents are listed below. The following Microchip documents are available and recommended as supplemental reference resources.
Readme for F1 LV Evaluation Platform User’s Guide
For the latest information on using F1 LV Evaluation Platform User’s Guide, read the
“Readme for F1 LV Evaluation Platform User’s Guide.txt” file (an ASCII
text file) in the Readmes subdirectory of the MPLAB® IDE installation directory. The
Readme file contains update information and known issues that may not be included
in this user’s guide.
Readme Files
For the latest information on using other tools, read the tool-specific Readme files in
the Readmes subdirectory of the MPLAB IDE installation directory. The Readme files
contain update information and known issues that may not be included in this user’s
guide.
 2011 Microchip Technology Inc.
DS41614A-page 7
F1 LV Evaluation Platform User’s Guide
THE MICROCHIP WEB SITE
Microchip provides online support via our web site at www.microchip.com/F1LVEval.
This web site is used as a means to make files and information easily available to
customers. Accessible by using your favorite Internet browser, the web site contains
the following information:
• Product Support – Data sheets and errata, application notes and sample
programs, design resources, user’s guides and hardware support documents,
latest software releases and archived software
• General Technical Support – Frequently Asked Questions (FAQs), technical
support requests, online discussion groups, Microchip consultant program
member listing
• Business of Microchip – Product selector and ordering guides, latest Microchip
press releases, listing of seminars and events, listings of Microchip sales offices,
distributors and factory representatives
DEVELOPMENT SYSTEMS CUSTOMER CHANGE NOTIFICATION SERVICE
Microchip’s customer notification service helps keep customers current on Microchip
products. Subscribers will receive e-mail notification whenever there are changes,
updates, revisions or errata related to a specified product family or development tool of
interest.
To register, access the Microchip web site at www.microchip.com, click on Customer
Change Notification and follow the registration instructions.
The Development Systems product group categories are:
• Compilers – The latest information on Microchip C compilers and other language
tools. These include the HI TECH C® C16, MPLAB C18 and MPLAB C30 C compilers; MPASM™ and MPLAB ASM30 assemblers; MPLINK™ and MPLAB
LINK30 object linkers; and MPLIB™ and MPLAB LIB30 object librarians.
• In-Circuit Debuggers – The latest information on the Microchip in-circuit
debugger, MPLAB ICD 2, ICD3, PICkit™ 3.
• MPLAB® IDE – The latest information on Microchip MPLAB IDE, the Windows®
Integrated Development Environment for development systems tools. This list is
focused on the MPLAB IDE, MPLAB SIM simulator, MPLAB IDE Project Manager
and general editing and debugging features.
• Programmers – The latest information on Microchip programmers. These include
the MPLAB PM3 device programmers and PICkit™ 3 development programmers.
DS41614A-page 8
 2011 Microchip Technology Inc.
Preface
CUSTOMER SUPPORT
Users of Microchip products can receive assistance through several channels:
•
•
•
•
Distributor or Representative
Local Sales Office
Field Application Engineer (FAE)
Technical Support
Customers should contact their distributor, representative or field application engineer
(FAE) for support. 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 (November 2011)
• Initial Release of this Document.
 2011 Microchip Technology Inc.
DS41614A-page 9
F1 LV Evaluation Platform User’s Guide
NOTES:
DS41614A-page 10
 2011 Microchip Technology Inc.
F1 LV EVALUATION PLATFORM
USER’S GUIDE
Chapter 1. F1 LV Evaluation Platform Overview
1.1
INTRODUCTION
Thank you for choosing the F1 LV Evaluation Platform. This kit allows you to begin
development using the PIC16LF1947 microcontroller (MCU).
The PIC16LF1947 is the first in a family of enhanced mid-range microcontrollers.
These architectural enhancements allow for more memory and faster computation than
that of legacy PIC16 microcontrollers.
The PIC16F1 and PIC12F1 family of microcontrollers are a series of 8-bit
microcontrollers derived from the popular PIC16 series of 8-bit PIC® microcontrollers.
The F1 LV derivatives feature an enhanced CPU, support for extended amounts of
memory, improved peripherals, and XLP low power. The F1 LV Evaluation Platform
allows you to evaluate these features for your application in a simple, low-cost platform.
This chapter introduces the F1 LV Evaluation Platform:
• Platform Contents
• Hardware Features
1.2
PLATFORM CONTENTS
The F1 LV Evaluation Platform contains the following items:
1. F1 LV Evaluation Platform Demo Board – www.microchip.com/F1LVEval
1.3
HARDWARE FEATURES
The F1 LV Evaluation Platform has the following hardware features:
1.3.1
PIC16LF1947
The PIC16LF1947 is a 64-pin full-featured device, including:
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
Enhanced PIC16 instruction set
16K words of Flash memory
1K of RAM
256 bytes of EEPROM
2 CCPs and 3 enhanced CCPs
MSSP (I2C™, SPI)
Enhanced USART
8- and 16-bit timers
32 MHz internal oscillator
Low-power 32 kHz crystal oscillator
LCD controller
LF Operating Range: 1.8-3.6V
1.3.2
MCP9800 I2C™ Temperature Sensor
The MCP9800 is a low-power, I2C temperature sensor with selectable 9 to 12 bits of
output resolution.
 2011 Microchip Technology Inc.
DS41614A-page 11
F1 LV Evaluation Platform User’s Guide
1.3.3
PICkit™ 3 Programming/Debug Header
The PICkit 3 is a low-cost development tool that allows programming and debugging of
the PIC16LF1947 MCU using the PICkit ICSP™ header.
1.3.4
MCP2200 USB to Serial Converter
The MCP2200, with the associated driver, makes the F1 LV Evaluation platform appear
as a serial port when connected to a PC. The demo code includes utilities to control the
various add-on boards through this serial interface.
1.3.5
Two Push Buttons, One Potentiometer, 7 LEDs
Simple applications need the basic user interface elements. Two push buttons, one
potentiometer and 4 green LEDs are available for any application. The remaining three
LEDs are used as indicators, a red LED is used to indicate the board is powered, the
remaining two LEDs are green and indicate RX/TX communication through the USB
Serial Converter.
1.3.6
One Custom LCD
The LCD glass supplied on this board is a Microchip custom display with icons for a
battery indicator, 4 large numerical digits, 2 small numerical digits, adjustable decimal
point, colon for time keeping, 4 function mode (Fx) indicators, 8 segment bar, a
three-segment battery power indicator and 1 custom Microchip symbol. The
PIC16LF1947 makes controlling the LCD very simple.
1.3.7
20-pin Add-on Connector
This connector expands the F1 LV Evaluation Board with optional add-on boards.
Currently, there are 4 motor control add-ons planned or in production. The
PIC16LF1947 has complete control of 3 phases, so other 1, 2, or 3-phase motor
topologies are supported.
1.3.8
Current Monitoring Connector
To demonstrate the Extreme Low Power (XLP) features of the PIC16LF1947, a
precision ammeter can be connected to the current monitoring connector. This allows
your application to be easily optimized for the lowest possible current.
1.3.9
Generous Prototyping Area
Our circuits are not your circuits. A prototyping area has been provided to extend the
functionality of this demo board to demonstrate the utility of the PIC16LF1947 in your
application.
1.3.10
MCP1640 Synchronous Boost Regulator
The MCP1640 is a compact, high-efficiency, fixed frequency, synchronous step-up
DC-DC converter. Through the use of this component, the F1 LV Evaluation board has
the option of boosting an AAA 1.8V battery to 3.3V, which is then used to power the
board and supporting circuitry.
1.3.11
MCP1703 LDO Regulator
The MCP1703 is a low-dropout voltage regulator with a 250 mA maximum output.
Through the use of this component, the user has the option of powering the F1 LV
Evaluation board through the USB Serial Converter connector. The USB supplies 5V,
and the MCP1703 reduces this to the operating voltage of 3.3V.
DS41614A-page 12
 2011 Microchip Technology Inc.
F1 LV Evaluation Platform Overview
1.3.12
User Selectable Power Sources
The F1 LV Evaluation board operates at 3.3V and comes with a flexable range of
powering options.
• J5 – (EXT SUPP) The user can power the board from a external power supply
connected to the +/- headers.
• J6 – (EXP PWR) The user can power the board from any Add-on board through
the expansion connector.
• J7 – (AAA BATT) The user can power the board by inserting a single AAA battery
into B1 battery clamp.
• J8 – (USB PWR) The user can power the board by connecting a USB cable to J2
USB SERIAL CONV header.
 2011 Microchip Technology Inc.
DS41614A-page 13
F1 LV Evaluation Platform User’s Guide
NOTES:
DS41614A-page 14
 2011 Microchip Technology Inc.
F1 LV EVALUATION PLATFORM
USER’S GUIDE
Chapter 2. Getting Started
2.1
INTRODUCTION
This chapter gives instructions to get your F1 LV Evaluation Platform powered up and
running the default demonstration. The following sections include:
•
•
•
•
Powering the F1 LV Evaluation Platform
Default Firmware
Programming the F1 LV Evaluation Platform with the PICkit™ 3
Measuring the current consumption
FIGURE 2-1:
 2011 Microchip Technology Inc.
F1 LV EVALUATION PLATFORM
DS41614A-page 15
F1 LV Evaluation Platform User’s Guide
2.2
POWERING THE F1 LV EVALUATION PLATFORM
The PIC16LF1947 supplied with your F1 LV Evaluation Platform requires a supply
voltage of 1.8V-3.6V. Voltages above 3.6V will degrade or damage the device. There
are five ways to supply the necessary power.
1. Use PICkit 3
Select Power Supply Source via cross jumper configuration
2.
3.
4.
5.
2.3
External Power Source, J5
Use the Add-on Expansion Header, J6
Use an AAA Battery, J7, or
Use USB Cable, J8.
POWERING WITH PICkit™ 3
To power with the PICkit 3, perform the following steps:
1. Make sure a jumper or an ammeter is connected across J4.
2. Configure the PICkit 3 to supply a voltage between 1.8 and 3.6V. For proper LCD
contrast, the supply should be 3.3V.
3. Attach the PICkit 3 to the PICkit ICSP™ connector at the end of the board.
4. Activate the PICkit 3 power output.
Note:
When powering from the PICkit 3, all power supply jumpers (J5 - J8) should
be removed.
FIGURE 2-2:
DS41614A-page 16
POWERING FROM PICkit™ 3
 2011 Microchip Technology Inc.
Getting Started
2.4
POWERING FROM EXTERNAL POWER SUPPLY
To power from an external power supply, perform the following steps:
1. Make sure a jumper or an ammeter is connected across J4.
2. Connect VREF+ to EXT SUPP (+), connect VREF- to EXT SUPP(-).
3. Verify the supply voltage to be between 1.8 and 3.6V. For proper LCD contrast,
the supply should be 3.3V.
4. Populate EXT PWR jumper, J5.
5. Turn on the power supply.
FIGURE 2-3:
 2011 Microchip Technology Inc.
POWERING WITH EXTERNAL POWER SUPPLY
DS41614A-page 17
F1 LV Evaluation Platform User’s Guide
2.5
POWERING WITH THE ADD-ON EXPANSION HEADER J3
The add-on expansion hardware will supply the F1 LV Evaluation board with 3.3V DC
through use of a linear regulator. This allows the 5-12V motor power supply to power
the PIC16LF1947. J3, pin 6, is the source for the 3.3V power. To use this power
perform the following steps.
1.
2.
3.
4.
5.
Make sure a jumper or an ammeter is connected across J4.
Verify that any attached PICkit 3 is not supplying power.
Populate the EXP PWR jumper, J6.
Attach the add-on expansion board.
Connect power to the add-on expansion board.
FIGURE 2-4:
2.6
EXPANSION SLOT POWER
POWERING WITH A AAA BATTERY
To power with a single AAA battery, the MCP1640 Boost Regulator is used to take the
supplied 1.8V and convert it to 3.3V.
1. Make sure the jumper or an ammeter is connected across J4.
2. Insert AAA battery into B1 battery clip.
3. Populate AAA BATT jumper, J7.
FIGURE 2-5:
DS41614A-page 18
POWERING FROM BATTERY
 2011 Microchip Technology Inc.
Getting Started
2.7
POWERING WITH A USB CABLE
To power with the USB cable, perform the following steps:
1. Make sure a jumper or an ammeter is connected across J4.
2. The USB cable will supply 5V DC to the F1 LV Evaluation board. The MCP1703
converts the 5V to 3.3V supply voltage for the PIC16LF1947.
3. Populate the USB PWR jumper, J8.
FIGURE 2-6:
2.8
USB POWER
DEFAULT FIRMWARE
The default firmware supplied with your F1 LV Evaluation Board Demo performs the
following functions:
1. Blink LEDs
2. Measure the ambient temperature
3. Run an attached add-on board motor (the firmware will auto-detect the add-on
motor type, or indicate if no add-on board is attached.)
4. Display time/temperature/pot position/motor RPM on the LCD
5. User interface with a button and pot
For the latest firmware go to www.microchip.com/F1LVEval
2.8.1
Blinking LEDs
LED RA4 is used to indicate timing of the demonstration main loop. The LED toggles
at each cycle through the demonstration program main loop. LEDs RA6, RA7 and RC5
are add-on board dependent, their function will change depending on the add-on board
attached.
2.8.2
Measuring the Ambient Temperature
The MCP9800 is polled when in Temperature Measurement mode. The measured
temperature is filtered, scaled to either Centigrade or Fahrenheit and displayed on the
LCD.
 2011 Microchip Technology Inc.
DS41614A-page 19
F1 LV Evaluation Platform User’s Guide
2.8.3
Add-on Motor Expansion
A main task of the demo code is to allow the user to connect any of the expansion
add-on motor boards and have the PIC16LF1947 determine the motor type and adjust
the drive accordingly. The code provided with the F1 LV Evaluation board works with
the following add-on boards:
-
BLDC
BDC
Unipolar Stepper
Bipolar Stepper
2.8.4
(DM164130-2)
(DM164130-6)
(DM164130-7)
(DM164130-8)
LCD Display
The time, temperature, pot position and motor speed are displayed on the LCD. The
LCD is a display with multipurpose icons. The display uses 4 commons and 28
segment drives. The Timer1 oscillator is used to clock the display peripheral and allow
the LCD to display data even in Sleep. Normally, the Timer1 counter would be used to
drive the display, but this timer is required for the BLDC software. This requires
configuring the LCD peripheral for a Type B waveform for this demo. The Type B
waveform requires coordinating LCD updates when the peripheral is ready. The BLDC
Interrupt requirements preclude using the built-in LCD interrupt for update
coordination, therefore, the LCD interrupt is polled as part of the main loop. Type A
waveforms can update the display without the extra coordination complexity. The
different waveform types are described in section 21.9 of the PIC16LF1947 data sheet
(DS41414). Because the LCD is clocked from the 32.768 kHz crystal, the LCDIF
operates at a multiple of the crystal frequency, providing a very accurate time base for
the real-time clock.
2.8.5
User Interface
Due to the extreme simplicity of this board, only a single button and a single pot are
available for user input. A MCLR button is also present for the demonstration, this will
function as a master clear switch. These two elements allow the user to cycle through
the display elements, change the motor speed and change the time.
Pressing and releasing the button cycles through the following display modes:
1.
2.
3.
4.
5.
6.
7.
Add-on Motor Indicator
Setable AM/PM Clock
24-hr clock with seconds
Temperature (C)
Temperature (F)
POT ADC Value
Motor RPM (BLDC and stepper motors only)
By holding down the RD2 button during the Setable Clock mode, the minutes will begin
to increment. The minutes will increment from 0-9; when the minutes increment past 9,
the minutes will begin to increase by factors of 10. When incrementing reaches an hour,
the hours will begin to increment and the minutes will stay at 00. The AM/PM indicator
will automatically change accordingly. To set the clock, first set the hours and release
the button. Then, set the tens of minutes and release the button. Finally, set the
seconds. To synchronize the seconds, increment the minutes one final time at the
instant the time reference advances to the next minute.
Turning the pot will change the motor speed.
When an expansion board is present, the F1 LV Evaluation code will automatically
detect the add-on type and modify the motor drive accordingly.
DS41614A-page 20
 2011 Microchip Technology Inc.
F1 LV EVALUATION PLATFORM
USER’S GUIDE
Chapter 3. Programming the F1 LV Evaluation Platform
3.1
INTRODUCTION
The F1 LV Evaluation Platform makes extensive use of the on-board peripherals of the
PIC16LF1947. This chapter provides guidance concerning the tools used for
programming the F1 LV Evaluation Board and a map of the board function to I/O pin
and pin function.
3.2
PROGRAMMING/DEVELOPMENT TOOL SUPPORT
The following development tools support the F1 LV Evaluation Platform:
1. PICkit™ 3
2. ICD 3
3. REAL ICE™ in-circuit emulator (with adapter AC164110)
The PICkit™ or ICD 3 tools can also power the F1 LV Evaluation Platform, therefore,
no additional hardware is required to get started. The ICSP pins of the PIC16LF1947
are dedicated to the PICkit ICSP connector, eliminating interactions between the
Evaluation Platform and the programmer/debugger.
If you are developing with the REAL ICE emulator ICD, you will need the AC164110
adaptor, or the high-speed trace adaptor. These adaptors provide the inline 6-pin
connector required by the PICkit ICSP programming capability interface. You will also
need a power supply, please see Chapter 2. “Getting Started” for more on powering
the F1 LV Evaluation Platform.
 2011 Microchip Technology Inc.
DS41614A-page 21
F1 LV Evaluation Platform User’s Guide
3.3
HARDWARE RESOURCES
TABLE 3-1:
HARDWARE RESOURCES
Pin Number
PORT ID
I/0
Use
Name
Description
1
RE1
2
RE0
0
RE1
J3 – Pin 10
0
RE0
J3 – Pin 12
3
RG0
0
4
RG1
I
LCD
P3A
Low Side Drive C; J3 – Pin 9
SEG43
S1/S2/S3/S4
5
RG2
I
LCD
SEG44
T1/T2/T3/T4
6
RG3
0
R3
J3 – Pin 8
7
RG5
I
MCLR/VPP
MCLR
8
RG4
0
RG4
J3 – Pin 2
9
10
NC
VSS
Supply Return
NC
Pin tied to VDD
11
RF7
I
AN5
C12IN3-
BEMF A; J3 – Pin 15
12
RF6
I
AN1
C1IN+
BEMF Reference; J3 – Pin 16
13
RF5
I
AN10
C12IN1-
BEMF C; J3 – Pin 19
14
RF4
I
AN9
C2IN+
Current Sense Reference; J3 – Pin 18
15
RF3
I
AN8
C12IN2-
BEMF B; J3 – Pin 17
16
RF2
0
RF2
C1OUT
17
RF1
I
LCD
SEG19
S5/S6/S7/S8
18
RF0
I
AN16
C12IN0-
Current Sense; J3 – Pin 20
19
AVDD
Power Supply
20
AVSS
Supply Return
21
RA3
I
AN3
RA3
Battery Voltage
22
RA2
I
LCD
SEG34
6A/6D/6E/6F
23
RA1
I
LCD
SEG18
5B/5C/5G/P5
24
RA0
I
LCD
SEG33
5A/5D/5E/5F
25
VSS
Supply Return
26
VDD
Power Supply
RA5
Speed Control Input (New Layout)
RA4
LED [D4]
27
RA5
I
28
RA4
0
AN4
29
RC1
I
RC1
T1OSCI
30
RC0
0
RC0
T1OSCO
31
RC6
0
TX1
Serial Transmit
32
RC7
I
RX1
Serial Receive
33
RC2
0
P1A
Low Side Drive B; J3 – Pin 1
34
RC3
I
SCK1
I2C™ Clock
35
RC4
I
SDA1
I2C Data
36
RC5
0
RC5
Phase C LED, LED [D3]
37
RB7
0
RGD
ICSP™ Data (TestPoint 1)
VDD
Power Supply
38
39
RA7
0
RA7
Phase B LED; LED [D2]
40
RA6
0
RA6
Phase A LED; LED [D1]
VSS
Supply Return
42
RB6
0
PGC
ICSP Clock (TestPoint 1)
43
RB5
I
SEG29
F2/6B/6C/6G
41
DS41614A-page 22
LCD
 2011 Microchip Technology Inc.
Programming the F1 LV Evaluation Platform
TABLE 3-1:
44
HARDWARE RESOURCES (CONTINUED)
RB4
I
LCD
SEG11
F1/F3/F4/P6
45
RB3
I
LCD
SEG10
4B/4C/4G/P4
46
RB2
I
LCD
SEG9
4A/4D/4E/4F
47
RB1
I
LCD
SEG8
3B/3C/3G/P3
48
RB0
I
LCD
SEG30
3A/3D/3E/3F
49
RD7
I
LCD
SEG7
2B/2C/2G/P2
50
RD6
0
P1B
High Side Drive A; J3 – Pin 3
51
RD5
0
RD5
J3 – Pin 4
52
RD4
0
P3B
High Side Drive C; J3 – Pin 11
53
RD3
I
SEG3
2A/2D/2E/2F
54
RD2
I
RD2
Push Button
55
RD1
I
LCD
LCD
56
SEG1
1B/1C/1G/1P
VSS
Supply Return
VDD
Power Supply
LCD
SEG0
1A/1D/1E/1F
P2A
Low Side Drive B; J3 – Pin 5
I
LCD
COM3
COM4
RE5
I
LCD
COM2
COM3
RE4
I
LCD
COM1
COM2
LCD
COM0
COM1
P2B
High Side Drive B; J3 – Pin 7
57
58
RD0
I
59
RE7
0
60
RE6
61
62
63
RE3
I
64
RE2
0
 2011 Microchip Technology Inc.
DS41614A-page 23
F1 LV Evaluation Platform User’s Guide
NOTES:
DS41614A-page 24
 2011 Microchip Technology Inc.
F1 LV EVALUATION PLATFORM
USER’S GUIDE
Chapter 4. Demo Code
4.1
INTRODUCTION
The F1 LV Evaluation Platform demo is located at www.microchip.com/F1LVEval. The
F1 LV Evaluation demonstration program uses a single Combined Demo. The Combined Demo source code is organized into sectional code for ease of portability:
This chapter provides an overview to the functions provided by these demos.
4.2
SERVICE DRIVERS
Multiple services drivers are utilized during this demo for operation. For user ease,
these drivers have been separated for easy portability.
- The I2C driver is used by the MCP9800 driver to read the current temperature
from the on-board MCP9800 I2C temperature sensor.
- Using the LCD and RTCC drivers, the LCD is used for display of the clock,
temperature, motor status and motor type.
- The UNI/O® driver is used to read from each add-on board which motor type
is being attached, and which firmware should be used.
4.3
COMBINED DEMO
The combined demo combines all the software from all the previous demos to show the
power of the PIC16LF1947. In this demo, the user can attach any of the (4) add-on
motor boards for use. The F1 LV Evaluation Board will auto-detect the type of motor
add-on used and automatically configure accordingly for use. All drivers are reused
from the previous demos. The RTCC is driven from the LCD peripheral.
The combined demo is preprogrammed in the F1 LV Evaluation Platform.
4.4
MOTOR CONTROL GUI APPLICATION
The F1 LV Evaluation Platform is developed to connect through the MCP2200 to the
user’s computer emulating a serial port. The GUI is capable of detecting which F1 LV
add-on board is being used. Through the application, the user is capable of exploring
the many options made with these motor types.
The GUI is capable of detecting and displaying which firmware version is being used
through the F1 LV Evaluation Platform, and also which add-on board is connected. The
features of the GUI in use with the F1 LV Evaluation Platform with its add-on boards is
discussed in the Add-on User’s Guide.
4.5
BLDC DEMO
The BLDC demo controls a sensorless, brushless DC motor connected to the PIC16F1
BLDC Expansion board (DM164130-2). Motors of the same type, but other than the
motor supplied, can also be driven by making appropriate modifications to the motor
control parameters.
Refer to application note AN1305, “Sensorless 3-Phase Brushless Motor Control with
the PIC16FXXX”, for detailed information regarding BLDC motor control.
 2011 Microchip Technology Inc.
DS41614A-page 25
F1 LV Evaluation Platform User’s Guide
4.6
BDC DEMO
The BDC demo controls a brushed DC motor connected to the PIC16F1 BDC
Expansion board (DM164130-6). Motors of the same type, but other than the motor
supplied, can also be driven by making appropriate modifications to the motor control
parameters.
4.7
UNIPOLAR STEPPER DEMO
The Unipolar Stepper Demo controls a Unipolar stepper motor connected to the
PIC16F1 Unipolar Expansion board (DM164130-8). Motors of the same type, but
other than the motor supplied, can also be driven by making appropriate modifications
to the motor control parameters.
4.8
BIPOLAR STEPPER DEMO
The Bipolar Stepper Demo controls a Unipolar stepper motor connected to the
PIC16F1 Bipolar Expansion board (DM164130-7). Motors of the same type, but other
than the motor supplied, can also be driven by making appropriate modifications to
the motor control parameters.
DS41614A-page 26
 2011 Microchip Technology Inc.
F1 LV EVALUATION PLATFORM
USER’S GUIDE
Chapter 5. Hardware Libraries and Drivers
5.1
INTRODUCTION
The demo code uses a common set of libraries to provide I2C, real-time clock,
MCP9800 and LCD services. These libraries may be useful for other applications so
they are documented here. These drivers are located at www.microchip.com/F1LVEval.
5.2
I2C™ DRIVER
The I2C driver allows I2C requests to be queued and then handled either by interrupts
or by polling. The driver is configured during compilation to support polling or interrupts.
The I2C and LCD demos configure the driver for interrupt mode. The Combined Demo
polls the I2C handler within the MCP9800 driver.
5.3
MCP9800 DRIVER
The MCP9800 driver uses the I2C driver to get the current temperature. The
mcp9800_get_temp function is fully blocking, so once a request is queued, the driver
polls the I2C subsystem until the data is complete. If the I2C driver is operating without
interrupts, the mcp9800_get_temp function repeatedly calls the I2C_handler
function to process all the I2C events. If the I2C driver is operating with interrupts, the
mcp9800_get_temp function simply inserts an I2C_TRANSACTION_T into the I2C
transaction queue and waits for the transaction to complete.
5.4
RTCC DRIVER
A software RTCC is managed by the supplied RTCC driver. This driver implements the
time() function required by the C compiler. Time is internally kept as seconds since
January 1, 1970. Standard C functions can be used to convert the time to the current
date. This driver has two modes. In the first mode, it expects to be called once per
second by the Timer1 interrupt. In the second mode, it expects to be called on every
LCD mode B frame. This allows the RTCC to keep accurate time even if Timer1 is
being used by some other function, such as the BLDC motor driver.
5.5
LCD DRIVER
The LCD driver contains the initialization code required for the LCD peripheral and the
mapping code required to control the LCD supplied with this demo board. It is a good
starting point for the LCD driver your unique application will require.
 2011 Microchip Technology Inc.
DS41614A-page 27
F1 LV Evaluation Platform User’s Guide
5.6
USING THE I2C™ DRIVER
The supplied software includes an I2C Master mode driver with the following features:
1.
2.
3.
4.
5.
6.
Interrupt driven or polled
Queued requests
Minimum memory requirements
Uses Restart to maximize bus bandwidth
Multiple atomic I2C transactions allowed at each queue entry
Completion flag for each queued block of I2C commands.
5.6.1
I2C Data Structures
Two data structures are defined to simplify interactions with the I2C driver.
5.6.1.1
I2C_RESULTS
The I2C_RESULTS is an enumerated type with the following enumerations:
TABLE 5-1:
I2C_RESULTS_T
I2C_REQUEST_PENDING
Request is in the queue or in process but it is not
done.
I2C_REQUEST_COMPLETE
The request is finished successfully.
I2C_REQUEST_STUCK_START
The request was aborted. The Start condition did
not clear correctly.
I2C_REQUEST_ADDRESS_NO_ACK
The request was aborted. No ACK occurred on
the address, so the target device must not exist
or is not functioning.
I2C_REQUEST_DATA_NO_ACK
The request was aborted. Not all of the data
could be sent because the device did not ACK a
byte.
I2C_REQUEST_LOST_STATE
The I2C state machine had a RAM corruption
and the default case caught the failure. This will
infinite loop so you should never see it.
The data completion flag for an I2C request is of type I2C_RESULTS. This flag will be
I2C_REQUEST_PENDING until the request is complete. If the request completed
without errors, the value will be I2C_REQUEST_COMPLETE. If there were errors, the
value will reflect one of the other 4 error conditions.
5.6.1.2
I2C_TRANSACTION_REQUEST_BLOCK
The I2C_TRANSACTION_REQUEST_BLOCK is a structure representing one
transaction on the I2C bus. A transaction contains the following elements:
1. A 7- or 10-bit address. Address type is determined automatically by the driver.
R/W mode is implicit in the address and specified by bit 0.
2. An 8-bit baud rate. This is the value placed in SPADD. Predefined constants are
included that compute the SPADD value given an FOSC value. Set FOSC with
a #define before #including the I2C.h file.
3. A buffer_length. This is the number of bytes available for reading or writing
at the supplied data buffer.
4. A Buffer Pointer. Your application will allocate a block of memory for an I2C
transaction. Pass a pointer to this block via the Buffer Pointer. The block must
remain valid until the transaction is complete (i.e., if you allocate the block as a
non-static array within a function, you must not leave the function until the I2C
transaction is complete or the array may be reused by a different function).
DS41614A-page 28
 2011 Microchip Technology Inc.
Hardware Libraries and Drivers
5.6.2
I2C Function Interface
5.6.2.1
i2c_init
The function i2c_init configures the I2C driver and makes it ready to receive
transaction in the transaction queue.
FIGURE 5-1:
initialize()
{
i2c_init;
}
5.6.2.2
i2c_insert
The function i2c_insert places one complete set of Transaction Request Block
(TRBs). TRBs can be bundled into an array of multiple TRBs and inserted as one large
request. The driver will ensure that all the TRBs in the list will be processed sequentially
with I2C restarts separating them.
FIGURE 5-2:
Send_data()
{
I2C_TRANSACTION_REQUEST_BLOCK trb_list[5];
I2C_RESULTS flag;
… populate the trb’s …
i2c_insert(5,trb_list, &flag);
}
5.6.2.3
i2c_build_write_trb / i2c_build_read_trb
The i2c_build_write_trb and i2c_build_read_trb functions are helpers to
assemble the I2C_TRANSACTION_REQUEST_BLOCKS from passed parameters.
FIGURE 5-3:
Send_one_byte()
{
I2C_TRANSACTION_REQUEST_BLOCK trb_list;
unsigned char data;
I2C_RESULTS flag;
data_block = .. my data byte ..
i2c_build_write_trb(&trb_list,ADDRESS, 1, &data, i2c_200K);
i2c_insert(1,&trb,&flag);
}
5.6.2.4
i2c_write_block / i2c_read_block
The i2c_write_block and i2c_read_block functions are helpers that assemble
a TRB, insert it into the queue and wait for the transaction to complete.
 2011 Microchip Technology Inc.
DS41614A-page 29
F1 LV Evaluation Platform User’s Guide
FIGURE 5-4:
Send_one_byte()
{
unsigned char data;
i2c_write_block(ADDRESS, 1, &data, i2c_200K);
}
5.6.2.5
i2c_handler
The i2c_handler function must be called for each I2C state to be handled. This
function can be placed into the Interrupt Service Routine for your application or, you
can simply poll it often. If the i2c_write_block or i2c_read_block functions are
used when the driver is configured for polling, then this function will repeatedly be
called until the transaction completes.
FIGURE 5-5:
Interrupt_service_routine()
{
i2c_handler();
}
5.7
USING THE LCD DRIVER
The supplied LCD driver configures the LCD module for the I/O pins used by the F1 LV
Evaluation Platform. Icon definitions are provided to simplify the software. A BCD to
7-segment display mapping function is also provided to further simplify control of the
LCD glass. For more information concerning the LCD peripheral, please consult the
LCD chapter in the PIC16LF1947 data sheet (DS41414).
5.7.1
LCD Data Structures
5.7.1.1
BCD_TYPE
To simplify BCD to the 7-segment display mapping, a BCD segment data type has been
provided. This data type is simply four 4-bit fields representing digits 0, 1, 2 and 3.
FIGURE 5-6:
typedef union
{
UINT16
val;
struct
{
unsigned
digit0 : 4;
unsigned
digit1 : 4;
unsigned
digit2 : 4;
unsigned
digit3 : 4;
};
} BCD_TYPE;
Simply place the number you want displayed in each digit position and call
lcd_display_digits.
DS41614A-page 30
 2011 Microchip Technology Inc.
Hardware Libraries and Drivers
5.7.2
LCD Function Interface
5.7.2.1
lcd_init
This function configures the LCD peripheral for this board and this glass. Type B
waveforms are used to allow the LCD peripheral to be used for the real-time clock
function. The Timer1 oscillator is configured as the LCD clock source.
FIGURE 5-7:
System_initialize()
{
lcd_init();
}
5.7.2.2
lcd_display_digits
This function accepts a BCD_TYPE variable and maps each digit to the correct
segments. Mapping the segments is done in two stages. First, the digit is converted to
the correct 7-segment mapping. Then, the 7-segment mapping is converted to the
actual glass segments with a long series of “if-else” statements. This function will need
extensive work in the “if-else” statements for applications driving different glass.
FIGURE 5-8:
void display_int(int t)
{
BCD_TYPE bcd;
bcd.digit0 = t %10;
t /= 10;
bcd.digit1 = t % 10;
t /= 10;
bcd.digit2 = t % 10;
t /= 10;
bcd.digit3 = t%10;
lcd_display_digits(bcd);
}
5.7.2.3
lcd_display_on/lcd_display_off
These two functions simply turn the LCD peripheral off. The Timer1 oscillator is left
running. One use for these functions is to implement display blinking.
FIGURE 5-9:
void update_blinking()
{
if(time(0) % 2) // if an odd number of seconds
{
lcd_display_on();
}
else
{
lcd_display_off();
}
}
 2011 Microchip Technology Inc.
DS41614A-page 31
F1 LV Evaluation Platform User’s Guide
5.7.3
LCD Segment Definitions
FIGURE 5-10:
LCD DISPLAY
TABLE 5-2:
PIN
COM1
1
2
3
4
5
6
7
8
9
1A 1B 2A 2B 3A 3B 4A 4B F1
10
11
12
13
14
15
F2 6D PS 5D S8 S1
16
17
18
19
20
T1 COM1
COM2
1F 1G 2F 2G 3F 3G 4F 4G F3 6C 6E 5C 5E S7 S2
T3
COM3
1E 1C 2E 2C 3E 3C 4E 4C F4 6G 6F 5G SF S6 S3
T2
COM4
1D P1 2D P2 3D P3 4D P4 P6 6B 6A 5B 5A S5 S4
T4
COM2
COM3
COM4
There are many segments present on the F1 LV Evaluation Platform LCD. To access
these segments, simply set the supplied #defines to ‘1’ or ‘0’.
FIGURE 5-11:
void display_volts(int v)
{
display_int(v);
DP3 = 0;
DP2 = 0;
S1 = 0;
S2 = 0;
AMPS = 0;
VOLT = 1;
KILO = 0;
OHMS = 0;
if (v < 0)
MINUS = 1;
else
MINUS = 0;
}
DS41614A-page 32
 2011 Microchip Technology Inc.
Hardware Libraries and Drivers
5.8
USING THE RTCC DRIVER
The RTC driver simply keeps track of seconds. The power-up initial value is ‘0’,
however, a function (rtcc_set) is provided to change that value. To keep the seconds
up-to-date, the function, rtcc_handler, must be called more frequently than the
defined value of CLOCKS_PER_SECOND. There are two options for the RTCC driver.
The first option is to use the Timer1 counter to provide a 1 Hz interrupt
(CLOCKS_PER_SECOND = 1). The second option is to use the LCD write-allowed
interrupt flag to provide a 128 Hz event (CLOCKS_PER_SECOND = 128). The two
choices are selected by defining use_lcdif or undefining use_lcdif.
5.8.1
RTCC Function Interface
5.8.1.1
rtcc_init
Initialize the RTCC function including Timer1, if required.
FIGURE 5-12:
System_initialization()
{
rtcc_init();
}
5.8.1.2
rtcc_handler
The rtcc_handler function must be called frequently to keep the internal seconds
counter accurate.
FIGURE 5-13:
System_interrupt_service_routine()
{
If(TMR1IF & TMR1IE)
{
TMR1IF = 0;
rtcc_handler();
}
}
5.8.1.3
rtcc_set
After system initialization, the seconds counter is cleared to ‘0’. The standard C
libraries equate 0 seconds to Midnight, Jan 1, 1970. That time has expired a long time
ago, so a new time in seconds can be configured with rtcc_set().
 2011 Microchip Technology Inc.
DS41614A-page 33
F1 LV Evaluation Platform User’s Guide
FIGURE 5-14:
#include <time.h>
Time_set() // set the time & date to 1 second after midnight, July 4, 2009
{
struct tm time_str;
time_t unix_time;
time_str.tm_year = 2009; // the year
time_str.tm_mon = 7;
// the month
time_str.tm_mday = 4;
// the day of the month
time_str.tm_hour = 0;
// the hour (0-23)
time_str.tm_min = 0;
// the minutes
time_str.tm_sec = 1;
// the seconds
time_str.tm_isdst = -1; // daylight savings time modifier
unix_time = mktime(&time_str);
rtcc_set(unix_time);
}
5.8.1.4
time
The standard C libraries require the application to supply the time function. This
function returns the current time_t value or loads a supplied time_t value. The
interrupts are saved and restored to make this function safe for use with interrupt driven
code.
5.9
USING THE MCP9800 DRIVER
The MCP9800 is an I2C temperature sensor. The MCP9800 driver provides a simple
interface to the features in the sensor.
5.9.1
MCP9800 Function Interface
5.9.1.1
mcp9800_init
This function configures the MCP9800 for 12-bit temperature, Continuous Conversion
mode. In this mode, the temperature is always ready to be read from the I2C interface.
FIGURE 5-15:
System_init()
{
i2c_init();
mcp9800_init();
}
5.9.1.2
mcp9800_get_temp
This function reads the current temperature and scales the result to degrees C * 10.
(24.3C is returned 243)
FIGURE 5-16:
Thermostat()
{
int temperature;
temperature = mcp9800_get_temp();
if(temperature > 260)
{
turn_on_air_conditioner();
}
}
DS41614A-page 34
 2011 Microchip Technology Inc.
F1 LV EVALUATION PLATFORM
USER’S GUIDE
Chapter 6. Troubleshooting
6.1
INTRODUCTION
There may come a time when you need to determine why your F1 LV Evaluation
Platform is not performing correctly. This chapter lists a few of the problems that can
prevent proper operation.
6.2
COMMON PROBLEMS
6.2.1
The board will not power up
Make sure the power supply jumper is populating the proper pins. Confirm the ISENSE,
J4, jumper is populated or an ammeter is connected. Then, go back and review
Chapter 2. “Getting Started” of this manual.
6.2.2
LCD is blank, but everything else works
The demo code in supplied with the F1 LV Evaluation Platform uses the Timer1
oscillator to drive the LCD. If the Timer1 oscillator is not oscillating, the LCD will remain
blank. Here are some steps to assure that the Timer1 oscillator is working properly.
1. Clean and dry the board especially around the components at the top right corner
of the PIC16LF1947.
2. Make sure no foreign material is shorting the crystal leads.
3. If you are using the RC0 and RC1 pins for some other function, you should
modify lcd_init to reconfigure the LCD peripheral for a different clock
source.
The Timer1 oscillator of the PIC16LF1947 is a very low-power design that can be easily
disrupted by stray leakage. In an actual application, Microchip recommends that the
crystal circuit be conformal coated to prevent leakage. Please review Application Note
AN1288, “Design Practices for Low-Power External Oscillators” for more information.
 2011 Microchip Technology Inc.
DS41614A-page 35
F1 LV Evaluation Platform User’s Guide
NOTES:
DS41614A-page 36
 2011 Microchip Technology Inc.
F1 LV EVALUATION PLATFORM
USER’S GUIDE
Chapter 7. Schematics
7.1
INTRODUCTION
To help understand the features of the F1 LV Evaluation Platform, the schematics are
included here.
 2011 Microchip Technology Inc.
DS41614A-page 37
F1 LV Evaluation Platform User’s Guide
7.1.1
F1 LV Evaluation Platform Schematic (1 of 4)
DS41614A-page 38
 2011 Microchip Technology Inc.
Schematics
7.1.2
F1 LV Evaluation Platform Schematic (2 of 4)
 2011 Microchip Technology Inc.
DS41614A-page 39
F1 LV Evaluation Platform User’s Guide
7.1.3
F1 LV Evaluation Platform Schematic (3 of 4)
DS41614A-page 40
 2011 Microchip Technology Inc.
Schematics
7.1.4
F1 LV Evaluation Platform Schematic (4 of 4)
 2011 Microchip Technology Inc.
DS41614A-page 41
F1 LV Evaluation Platform User’s Guide
NOTES:
DS41614A-page 42
 2011 Microchip Technology Inc.
F1 LV EVALUATION PLATFORM
USER’S GUIDE
Index
A
P
AC164110 ................................................................ 21
Ammeter .................................................................. 19
Documentation
Conventions ........................................................ 6
Layout ................................................................. 5
PIC® microcontrollers .............................................. 11
PIC16 series............................................................. 11
PIC16F1 Evaluation Kit ............................................ 11
PIC16F1 family......................................................... 11
PIC16LF1937 ........................................................... 11
PICkit ICSP™ programming capability interface...... 21
PICkit Serial ............................................................. 19
PICkit™ 2 ................................................................. 21
PICkit™ 3 ................................................................. 21
Platform Contents .................................................... 11
F1 LV Evaluation Platform Demo Board ........... 11
Powering with PICkit 3 ............................................. 16
JP2.................................................................... 16
PICkit ICSP connector ...................................... 16
Voltage.............................................................. 16
Programming and debugging................................... 12
E
R
Enhanced Mid-Range Microcontrollers .................... 11
Reading, Recommended ........................................... 7
Readme...................................................................... 7
REAL ICE™ In-circuit Emulator ............................... 21
B
BLDC Demo ............................................................. 25
C
Centigrade ............................................................... 19
Combined Demo ...................................................... 25
Common Problems .................................................. 35
Customer Notification Service.................................... 8
Customer Support ...................................................... 9
D
F
F1 LV Evaluation Platform ....................................... 11
F1 LV Evaluation Platform Schematic...................... 38
H
Hardware Features .................................................. 11
16-bit timers ...................................................... 11
32 MHz internal oscillator ................................. 11
CCPs ................................................................ 11
EEPROM .......................................................... 11
Enhanced USART ............................................ 11
LCD controller ................................................... 11
RAM .................................................................. 11
Hardware Libraries and Drivers ............................... 27
S
Supply Voltage ......................................................... 16
U
User Interface........................................................... 20
W
Warranty Registration ................................................ 7
WWW Address........................................................... 8
X
XLP Low Power........................................................ 11
I
ICSP pins ................................................................. 21
Internet Address......................................................... 8
L
LCD Display ............................................................. 20
LCD Function Interface ............................................ 31
lcd_display_digits.............................................. 31
lcd_display_on / lcd_display_off ....................... 31
lcd_init............................................................... 31
M
MCP9800 ................................................................. 11
Temperature sensor ......................................... 11
Microchip Internet Web Site ....................................... 8
 2011 Microchip Technology Inc.
DS41614A-page 43
Worldwide Sales and Service
AMERICAS
ASIA/PACIFIC
ASIA/PACIFIC
EUROPE
Corporate Office
2355 West Chandler Blvd.
Chandler, AZ 85224-6199
Tel: 480-792-7200
Fax: 480-792-7277
Technical Support:
http://www.microchip.com/
support
Web Address:
www.microchip.com
Asia Pacific Office
Suites 3707-14, 37th Floor
Tower 6, The Gateway
Harbour City, Kowloon
Hong Kong
Tel: 852-2401-1200
Fax: 852-2401-3431
India - Bangalore
Tel: 91-80-3090-4444
Fax: 91-80-3090-4123
India - New Delhi
Tel: 91-11-4160-8631
Fax: 91-11-4160-8632
Austria - Wels
Tel: 43-7242-2244-39
Fax: 43-7242-2244-393
Denmark - Copenhagen
Tel: 45-4450-2828
Fax: 45-4485-2829
India - Pune
Tel: 91-20-2566-1512
Fax: 91-20-2566-1513
France - Paris
Tel: 33-1-69-53-63-20
Fax: 33-1-69-30-90-79
Japan - Yokohama
Tel: 81-45-471- 6166
Fax: 81-45-471-6122
Germany - Munich
Tel: 49-89-627-144-0
Fax: 49-89-627-144-44
Atlanta
Duluth, GA
Tel: 678-957-9614
Fax: 678-957-1455
Boston
Westborough, MA
Tel: 774-760-0087
Fax: 774-760-0088
Chicago
Itasca, IL
Tel: 630-285-0071
Fax: 630-285-0075
Cleveland
Independence, OH
Tel: 216-447-0464
Fax: 216-447-0643
Dallas
Addison, TX
Tel: 972-818-7423
Fax: 972-818-2924
Detroit
Farmington Hills, MI
Tel: 248-538-2250
Fax: 248-538-2260
Indianapolis
Noblesville, IN
Tel: 317-773-8323
Fax: 317-773-5453
Los Angeles
Mission Viejo, CA
Tel: 949-462-9523
Fax: 949-462-9608
Santa Clara
Santa Clara, CA
Tel: 408-961-6444
Fax: 408-961-6445
Toronto
Mississauga, Ontario,
Canada
Tel: 905-673-0699
Fax: 905-673-6509
Australia - Sydney
Tel: 61-2-9868-6733
Fax: 61-2-9868-6755
China - Beijing
Tel: 86-10-8569-7000
Fax: 86-10-8528-2104
China - Chengdu
Tel: 86-28-8665-5511
Fax: 86-28-8665-7889
China - Chongqing
Tel: 86-23-8980-9588
Fax: 86-23-8980-9500
Korea - Seoul
Tel: 82-2-554-7200
Fax: 82-2-558-5932 or
82-2-558-5934
China - Hangzhou
Tel: 86-571-2819-3187
Fax: 86-571-2819-3189
Malaysia - Kuala Lumpur
Tel: 60-3-6201-9857
Fax: 60-3-6201-9859
China - Hong Kong SAR
Tel: 852-2401-1200
Fax: 852-2401-3431
Malaysia - Penang
Tel: 60-4-227-8870
Fax: 60-4-227-4068
China - Nanjing
Tel: 86-25-8473-2460
Fax: 86-25-8473-2470
Philippines - Manila
Tel: 63-2-634-9065
Fax: 63-2-634-9069
China - Qingdao
Tel: 86-532-8502-7355
Fax: 86-532-8502-7205
Singapore
Tel: 65-6334-8870
Fax: 65-6334-8850
China - Shanghai
Tel: 86-21-5407-5533
Fax: 86-21-5407-5066
Taiwan - Hsin Chu
Tel: 886-3-5778-366
Fax: 886-3-5770-955
China - Shenyang
Tel: 86-24-2334-2829
Fax: 86-24-2334-2393
Taiwan - Kaohsiung
Tel: 886-7-536-4818
Fax: 886-7-330-9305
China - Shenzhen
Tel: 86-755-8203-2660
Fax: 86-755-8203-1760
Taiwan - Taipei
Tel: 886-2-2500-6610
Fax: 886-2-2508-0102
China - Wuhan
Tel: 86-27-5980-5300
Fax: 86-27-5980-5118
Thailand - Bangkok
Tel: 66-2-694-1351
Fax: 66-2-694-1350
Italy - Milan
Tel: 39-0331-742611
Fax: 39-0331-466781
Netherlands - Drunen
Tel: 31-416-690399
Fax: 31-416-690340
Spain - Madrid
Tel: 34-91-708-08-90
Fax: 34-91-708-08-91
UK - Wokingham
Tel: 44-118-921-5869
Fax: 44-118-921-5820
China - Xian
Tel: 86-29-8833-7252
Fax: 86-29-8833-7256
China - Xiamen
Tel: 86-592-2388138
Fax: 86-592-2388130
China - Zhuhai
Tel: 86-756-3210040
Fax: 86-756-3210049
DS41614A-page 44
Korea - Daegu
Tel: 82-53-744-4301
Fax: 82-53-744-4302
08/02/11
 2011 Microchip Technology Inc.