AN_354 FT51A Standalone Demo Application

Application Note
AN_354
FT51A Standalone Demo
Application
Version 1.1
Issue Date: 2015-11-26
This document provides a guide for using the FT51A development
environment to read sensors and send results to the LCD screen on the FT51
EVM.
Use of FTDI devices in life support and/or safety applications is entirely at the user’s risk, and the
user agrees to defend, indemnify and hold FTDI harmless from any and all damages, claims, suits
or expense resulting from such use.
Future Technology Devices International Limited (FTDI)
Unit 1, 2 Seaward Place, Glasgow G41 1HH, United Kingdom
Tel.: +44 (0) 141 429 2777 Fax: + 44 (0) 141 429 2758
Web Site: http://ftdichip.com
Copyright © 2015 Future Technology Devices International Limited
Application Note
AN_354 FT51A Standalone Demo Application
V ers ion 1 .1
D oc ument Reference N o.: FT _001137
C learance N o.: FT DI# 4 2 8
Table of Contents
1 Introduction ............................................................ 3
1.1 Overview.......................................................................... 3
1.2 Features........................................................................... 3
1.3 Limitations ....................................................................... 3
1.4 Scope ............................................................................... 3
2 Standalone Demo Application Operation ................... 4
3 Stand-alone Demo Application Firmware .................. 5
3.1 Timer ............................................................................... 5
3.2 Sensor Reading Acquisition ............................................... 5
3.2.1
Force Sensor .......................................................................................................... 5
3.2.2
Heart Rate Sensor.................................................................................................. 6
3.2.3
Temperature Sensor............................................................................................... 6
4 Contact Information ................................................ 7
Appendix A – References ............................................. 8
Document References .............................................................. 8
Acronyms and Abbreviations .................................................... 8
Appendix B – List of Tables & Figures ........................... 9
List of Figures .......................................................................... 9
Appendix C – Revision History .................................... 10
2
P roduc t Page
D oc ument Feedback
C opyright © 2 0 15 Future T echnology D evices I nternational L imited
Application Note
AN_354 FT51A Standalone Demo Application
V ers ion 1 .1
D oc ument Reference N o.: FT _001137
C learance N o.: FT DI# 4 2 8
1 Introduction
This application note documents an example firmware project for the FT51A. The source code is
available in the “examples\AN_354_Standalone_Demo_Application” folder of the FT51A Software
Development Kit.
1.1 Overview
The standalone demo application firmware demonstrates data conversion using GPIO, ADC and
SPI, and ultimately displaying the data via I2C to the LCD screen on the FT51A EVM.
The example code also includes the DFU functionality from AN_344 FT51A DFU Sample.
Please refer to the following Application Notes which use different methods to display this data:


AN_347 FT51A Test and Measurement Sample
o displays data via USB TMC Class
AN_348 FT51A FT800 Sensors Sample
o displays data on a TFT via FTDI EVE Controller
1.2 Features
The standalone demo application example has the following features:
-
Open source firmware layered on the FT51A USB Library.
Reads data from a temperature sensor using the SPI Master interface.
Converts the analogue voltage from a force sensor to a digital reading.
Detects transitions on an analogue voltage input to make a simple heart rate monitor.
Reads switches connected to GPIO inputs to alternate between temperate, heart rate and
force screens.
Uses GPIO output pins to display backlight colours (Red, Green and Blue) on the LCD unit
Displays data via I2C on the LCD screen
1.3 Limitations
The firmware is designed for the FT51A EVM module.
1.4 Scope
The guide is intended for developers who are creating applications, extending FTDI provided
applications or implementing example applications for the FT51A.
In the reference of the FT51A, an “application” refers to firmware that runs on the FT51A;
“libraries” are source code provided by FTDI to help user, access specific hardware features of the
chip.
The FT51A Tools are currently only available for Microsoft Windows platform and are tested on
Windows 7 and Windows 8.1.
3
P roduc t Page
D oc ument Feedback
C opyright © 2 0 15 Future T echnology D evices I nternational L imited
Application Note
AN_354 FT51A Standalone Demo Application
V ers ion 1 .1
D oc ument Reference N o.: FT _001137
C learance N o.: FT DI# 4 2 8
2 Standalone Demo Application Operation
When the standalone demo application has been programmed into the flash of the FT51A MCU, the
application should look similar to Figure 2-1 below.
Figure 2-1 Stand-alone Demo running on Hardware
The LCD displays the data from the 3 sensors on the board:



Force Sensitive Resistor
Temperature Sensor
Heart Rate Sensor
SW1 (Previous) and SW2 (Next) allows the user to switch between each screen to display the
various data.
The user can touch the force sensitive resistor and see the varying force measured in Newtons.
The Force LED should also reflect the force applied.
If the user places a finger on the temperature sensor, the temperature should rise and is displayed
in °C (degrees Celsius).
To measure your heart rate, place a finger in between D1 and D2. The heartbeat LED should pulse
matching your pulse rate. Initially the display will show ‘Calculating’ before the rate in beats per
minute (bpm) is displayed.
The LCD screen’s background colour will also change depending on the levels of the data recorded.
4
P roduc t Page
D oc ument Feedback
C opyright © 2 0 15 Future T echnology D evices I nternational L imited
Application Note
AN_354 FT51A Standalone Demo Application
V ers ion 1 .1
D oc ument Reference N o.: FT _001137
C learance N o.: FT DI# 4 2 8
3 Stand-alone Demo Application Firmware
The standalone demo application firmware included in the example code demonstrates a
standalone test and measurement device.
The firmware uses the FT51A USB library, DFU library, SPI Master library, I2C library, general
config library and the IOMUX library. The IOMUX library is not used in the example code but is
included to allow further functionality to be added. A code module for the ADT7310 temperature
sensor (via the SPI Master library) is included.
DFU functionality is implemented as described in AN_344 DFU Sample.
The firmware is designed for the FT51A EVM module. It will use the force sensor, temperature
sensor and heart rate sensor. The force and heart rate sensors use an analogue voltage input
which is converted using the ADC features. The temperature sensor uses a n ADT7310 which is
connected to the FT51A via an SPI bus.
The DFU functionality is enabled but can be disabled by removing the associated code and DFU
library. Removing the DFU code will reduce the size of the compiled code by approximately 1600
bytes.
3.1 Timer
A timer is used to provide delays and time me asurements for implementing polling intervals.
The ms_timer timer is used to create general purpose delays, for instance when resetting the
temperature sensor, and checking the screen menu buttons.
The DFU also needs a millisecond timer to accurately return to the appIDLE state from the
appDETACH state. The dfu_timer() function in the DFU library, if enabled, should be called every
millisecond to enable this.
3.2 Sensor Reading Acquisition
Each sensor is read from the firmware’s main loop.
3.2.1
Force Sensor
A new ADC is triggered and the conversion will take place in the background and an interrupt
generated when it is complete.
IO_REG_INTERRUPTS_WRITE(IO_CELL_SAMPLE_0_7_1, MASK_IO_CELL_0_SAMPLE);
The ADC interrupt handler will update the force variable when the reading is complete:
// Determine the interrupt source.
IO_REG_GENERAL_READ(IO_CELL_INT_0_1, interrupt);
// FSR Output
if (interrupt & MASK_SD_CELL_0_INT)
{
IO_REG_GENERAL_READ(IO_CELL_0_ADC_DATA_L_1, sample_l);
IO_REG_GENERAL_READ(IO_CELL_0_ADC_DATA_U_1, sample_h);
force = ((sample_h << 8) | sample_l);
// Clear ADC interrupt register bit
IO_REG_GENERAL_WRITE(IO_CELL_INT_0_1, MASK_SD_CELL_0_INT);
}
5
P roduc t Page
D oc ument Feedback
C opyright © 2 0 15 Future T echnology D evices I nternational L imited
Application Note
AN_354 FT51A Standalone Demo Application
V ers ion 1 .1
D oc ument Reference N o.: FT _001137
3.2.2
C learance N o.: FT DI# 4 2 8
Heart Rate Sensor
A new ADC is triggered and the conversion will take place in the background and an interrupt
generated when it is complete.
IO_REG_GENERAL_WRITE(IO_CELL_SAMPLE_8_15_1, MASK_IO_CELL_10_SAMPLE);
The ADC interrupt handler will update the pulseSample variable when the reading is complete:
IO_REG_GENERAL_READ(IO_CELL_INT_1_1, interrupt);
// Pulse Rate
if (interrupt & MASK_SD_CELL_10_INT)
{
IO_REG_GENERAL_READ(IO_CELL_10_ADC_DATA_L_1, sample_l);
IO_REG_GENERAL_READ(IO_CELL_10_ADC_DATA_U_1, sample_h) ;
pulseSample = ((sample_h << 8) | sample_l);
// Clear ADC interrupt register bit
IO_REG_GENERAL_WRITE(IO_CELL_INT_1_1, MASK_SD_CELL_10_INT);
}
3.2.3
Temperature Sensor
An SPI bus is used to measure the temperature from an ADT7310 sensor connected to the SPI
Master interface. When the tempTimer reaches zero the timer is reset and an SPI Master read is
performed to the ADT3710. The library file “adt7310.c” implements the interface between the
temperature sensor and the application us ing the SPI Master bus.
// Read the temperature from the SPI Master
temperature = temperature_read();
6
P roduc t Page
D oc ument Feedback
C opyright © 2 0 15 Future T echnology D evices I nternational L imited
Application Note
AN_354 FT51A Standalone Demo Application
V ers ion 1 .1
D oc ument Reference N o.: FT _001137
C learance N o.: FT DI# 4 2 8
4 Contact Information
Head Office – Glasgow, UK
Branch Office – Tigard, Oregon, USA
Future Technology Devices International Limited
Unit 1, 2 Seaward Place, Centurion Business Park
Glasgow G41 1HH
United Kingdom
Tel: +44 (0) 141 429 2777
Fax: +44 (0) 141 429 2758
Future Technology Devices International Limited
(USA)
7130 SW Fir Loop
Tigard, OR 97223-8160
USA
Tel: +1 (503) 547 0988
Fax: +1 (503) 547 0987
E-mail (Sales)
E-mail (Support)
E-mail (General Enquiries)
[email protected]
[email protected]
[email protected]
E-Mail (Sales)
E-Mail (Support)
E-Mail (General Enquiries)
[email protected]
[email protected]
[email protected]
Branch Office – Taipei, Taiwan
Branch Office – Shanghai, China
Future Technology Devices International Limited
(Taiwan)
2F, No. 516, Sec. 1, NeiHu Road
Taipei 114
Taiwan , R.O.C.
Tel: +886 (0) 2 8791 3570
Fax: +886 (0) 2 8791 3576
Future Technology Devices International Limited
(C hina)
Room 1103, No. 666 West Huaihai Road,
Shanghai, 200052
C hina
Tel: +86 21 62351596
Fax: +86 21 62351595
E-mail (Sales)
E-mail (Support)
E-mail (General Enquiries)
E-mail (Sales)
E-mail (Support)
E-mail (General Enquiries)
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
Web Site
http://ftdichip.com
Distributor and Sales Representatives
Please visit the Sales Network page of the FTDI Web site for the contact details of our distributor(s) and sales
representative(s) in your country.
Sys tem and equipment manufacturers and des igners are responsible to ens ure that their s ystems, and any Future T ec hnology
D evic es I nternational L td (FT DI) devices inc orporated in their s ystems, meet all applicable s afety, regulatory and s ystem - level
performanc e requirements. A ll application-related information in this document (including application des c riptions , s ugges ted
FT D I devic es and other materials ) is provided for referenc e only. While FT D I has taken c are to as s ure it is ac c urate, this
information is s ubject to c ustomer c onfirmation, and FT D I dis c laims all liability for s ys tem des igns and for any applic ations
as s istance provided by FTD I. U se of FT DI devices in life s upport and/or s afety applications is entirely at the us er’s ris k, a nd the
us er agrees to defend, indemnify and hold harmles s FTDI from any and all damages , c laims , s uits or expens e res ulting from
s uc h us e. T his doc ument is s ubject to c hange without notic e. N o freedom to us e patents or other intellectual property rights is
implied by the public a tion of this doc ument. N either the whole nor any part of the information c ontained in, or the produc t
des c ribed in this doc ument, may be adapted or reproduc ed in any material or electronic form without the prior written c ons ent
of the c opyright holder. Future T ec hnology D evic es I nternational L td, U nit 1 , 2 Seaward P lac e, C enturion Bus ines s P ark,
G las gow G 4 1 1 H H , U nited Kingdom. Sc otland Regis tered C ompany N umber: SC 1 3 6 6 4 0
7
P roduc t Page
D oc ument Feedback
C opyright © 2 0 15 Future T echnology D evices I nternational L imited
Application Note
AN_354 FT51A Standalone Demo Application
V ers ion 1 .1
D oc ument Reference N o.: FT _001137
C learance N o.: FT DI# 4 2 8
Appendix A – References
Document References
FTDI MCU web page: http://www.ftdichip.com/MCU.html
AN_344 FT51A DFU Sample
AN_347 FT51A Test and Measurement Sample
AN_348 FT51A FT800 Sensors Sample
Acronyms and Abbreviations
Terms
Description
MTP
Multiple Time Program – non-volatile memory used to store program code
on the FT51A.
USB
Universal Serial Bus
8
P roduc t Page
D oc ument Feedback
C opyright © 2 0 15 Future T echnology D evices I nternational L imited
Application Note
AN_354 FT51A Standalone Demo Application
V ers ion 1 .1
D oc ument Reference N o.: FT _001137
C learance N o.: FT DI# 4 2 8
Appendix B – List of Tables & Figures
List of Figures
Figure 2-1 Stand-alone Demo running on Hardware ...................................................................... 4
9
P roduc t Page
D oc ument Feedback
C opyright © 2 0 15 Future T echnology D evices I nternational L imited
Application Note
AN_354 FT51A Standalone Demo Application
V ers ion 1 .1
D oc ument Reference N o.: FT _001137
C learance N o.: FT DI# 4 2 8
Appendix C – Revision History
Document Title:
AN_354 FT51A Standalone Demo Application
Document Reference No.:
FT_001137
Clearance No.:
FTDI# 428
Product Page:
http://www.ftdichip.com/FTProducts.htm
Document Feedback:
Send Feedback
Revision
Changes
Date
1.0
Initial Release
2014-12-12
1.1
Update FT51 references to FT51A
2015-11-26
10
P roduc t Page
D oc ument Feedback
C opyright © 2 0 15 Future T echnology D evices I nternational L imited