F1 EVALUATION PLATFORM
USERS GUIDE
2010 Microchip Technology Inc. DS41401B-page 19
Chapter 4. Demo Code
4.1 INTRODUCTION
The F1 Evaluation Platform demos are located at www.microchip.com/F1Eval. The
following demos are available:
1. I
2
C™ Demo
2. LCD Demo
3. BLDC Demo
4. Combined Demo
This chapter provides an overview to the functions provided by these demos.
4.2 I
2
C™ DEMO
The I
2
C demo reads the current temperature from the on-board MCP9800 I
2
C
temperature sensor. The I
2
C driver is used to extract the data. The resulting value is
converted to a PWM duty cycle and used to control the brightness of the LED D4. LED
D1 toggles at approximately 10 ms.
4.3 LCD DEMO
The LCD demo adds button, potentiometer, Real-Time Clock (RTC) and LCD support
to the I
2
C demo. The 32.768 kHz crystal is activated to maintain the Real-Time Clock
and to drive the LCD peripheral. An input driver is supplied to manage the button and
potentiometer. A state machine now controls the major features of the demo so that the
time, temperature and potentiometer value can be displayed on the LCD.
4.4 BLDC DEMO
The BLDC demo controls a sensorless, brushless DC motor connected to the PIC16F1
BLDC Expansion board (DM164130-2). Other motors can also be driven by making
appropriate modifications to the motor control parameters in the source code.
Refer to application note AN1305, “Sensorless 3-Phase Brushless Motor Control with
the PIC16FXXXfor detailed information regarding BLDC motor control.
4.5 COMBINED DEMO
The combined demo combines all the software from all the previous demos to show the
power of the PIC16LF1937. In this demo, the BLDC motor is seamlessly controlled
while displaying the time, temperature, potentiometer position or motor RPM/10. All
drivers are reused from the previous demos. The RTCC is driven from the LCD
peripheral.
The combined demo is preprogrammed in the F1 Evaluation Platform.
F1 Evaluation Platform User’s Guide
DS41401B-page 20 2010 Microchip Technology Inc.
NOTES:
F1 EVALUATION PLATFORM
USERS GUIDE
2010 Microchip Technology Inc. DS41401B-page 21
Chapter 5. Hardware Libraries and Drivers
5.1 INTRODUCTION
All of the demo code uses a common set of libraries to provide I
2
C, 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/F1Eval
.
5.2 I
2
C™ DRIVER
The I
2
C driver allows I
2
C 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 I
2
C and LCD demos configure the driver for interrupt mode. The Combined demo
polls the I
2
C handler within the MCP9800 driver.
5.3 MCP9800 DRIVER
The MCP9800 driver uses the I
2
C driver to get the current temperature. The
mcp9800_get_temp function is fully blocking, so once a request is queued, the driver
polls the I
2
C subsystem until the data is complete. If the I
2
C driver is operating without
interrupts, the mcp9800_get_temp function repeatedly calls the I2C_handler
function to process all the I
2
C events. If the I
2
C driver is operating with interrupts, the
mcp9800_get_temp function simply inserts an I2C_TRANSACTION_T into the I
2
C
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 3.5-digit LCD supplied with this demo board. It is
a good starting point for the LCD driver your unique application will require.

DM164130-1

Mfr. #:
Manufacturer:
Description:
F1 EVAL PLATFORM PIC16LF1937
Lifecycle:
New from this manufacturer.
Delivery:
DHL FedEx Ups TNT EMS
Payment:
T/T Paypal Visa MoneyGram Western Union

Products related to this Datasheet