5.8.21.8 Files
Files
Name Description
smtp.h Module for Microchip TCP/IP Stack
smtp_config.h SMTP configuration file
Description
5.8.21.8.1 smtp.h
Simple Mail Transfer Protocol (SMTP) Client
Functions
Name Description
TCPIP_SMTP_ArrayPut Writes a series of bytes to the SMTP client.
TCPIP_SMTP_Flush Flushes the SMTP socket and forces all data to be sent.
TCPIP_SMTP_IsBusy Determines if the SMTP client is busy.
TCPIP_SMTP_IsPutReady Determines how much data can be written to the SMTP client.
TCPIP_SMTP_MailSend Initializes the message sending process.
TCPIP_SMTP_Put Writes a single byte to the SMTP client.
TCPIP_SMTP_PutIsDone Indicates that the on-the-fly message is complete.
TCPIP_SMTP_StringPut Writes a string to the SMTP client.
TCPIP_SMTP_UsageBegin Requests control of the SMTP client module.
TCPIP_SMTP_UsageEnd Releases control of the SMTP client module.
Macros
Name Description
SMTP_CONNECT_ERROR Connection to SMTP server failed
SMTP_RESOLVE_ERROR DNS lookup for SMTP server failed
SMTP_SUCCESS Message was successfully sent
Structures
Name Description
SMTP_CLIENT_MODULE_CONFIG This is type SMTP_CLIENT_MODULE_CONFIG.
5.8 TCP/IP Stack Library Help MPLAB Harmony Help SMTP TCP/IP Stack Library
5-3821
SMTP_POINTERS Configures the SMTP client to send a message
5.8.21.8.2 smtp_config.h
Simple Mail Transfer Protocol (SMTP) Configuration file
This file contains the SMTP module configuration options
Macros
Name Description
MAX_SMTP_CONNECTIONS Maximum number of SMTP connections allowed
SMTP_PORT Default port to use when unspecified
SMTP_SERVER_REPLY_TIMEOUT How long to wait before assuming the connection has been dropped (default
8 seconds)
5.8.22 SNMP TCP/IP Stack Library
5.8.22.1 Introduction
Simple Network Management Protocol (SNMP) TCP/IP Stack Library
for
Microchip Microcontrollers
This library provides the API of the SNMP TCP/IP Module that is available on the Microchip family of microcontrollers with a
convenient C language interface. It is a module that belongs to the TCP/IP stack.
Description
Note: This information was not available at time of release and will be added in a future release of MPLAB Harmony.
5.8.22.2 Release Notes
MPLAB Harmony Version: v0.70b SNMP TCP/IP Stack Library Version : 1.0 Release Date: 18Nov2013
New This Release:
This is the first release of the library. The interface can change in the beta and\or 1.0 release.
Known Issues:
Nothing to report in this release.
5.8.22.3 SW License Agreement
(c) 2013 Microchip Technology Inc.
Microchip licenses this software to you solely for use with Microchip products. The software is owned by Microchip and its
5.8 TCP/IP Stack Library Help MPLAB Harmony Help SNMP TCP/IP Stack Library
5-3822
licensors, and is protected under applicable copyright laws. All rights reserved.
SOFTWARE IS PROVIDED "AS IS" MICROCHIP EXPRESSLY DISCLAIMS ANY WARRANTY OF ANY KIND, WHETHER
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. IN NO EVENT SHALL MICROCHIP BE LIABLE FOR
ANY INCIDENTAL, SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, HARM TO
YOUR EQUIPMENT, COST OF PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY OR SERVICES, ANY CLAIMS
BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), ANY CLAIMS FOR INDEMNITY OR
CONTRIBUTION, OR OTHER SIMILAR COSTS.
To the fullest extent allowed by law, Microchip and its licensors liability shall not exceed the amount of fees, if any, that you have
paid directly to Microchip to use this software.
MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE TERMS.
5.8.22.4 Using the Library
This topic describes the basic architecture of the SNMP TCP/IP Stack Library and provides information and examples on how to
use it.
Interface Header File: snmp.h
The interface to the SNMP TCP/IP Stack library is defined in the "snmp.h" header file. This file is included by the "tcpip.h" file.
Any C language source (.c) file that uses the SNMP TCP/IP Stack library should include "tcpip.h".
Library File:
The SNMP TCPIP Stack library archive (.a) file installed with MPLAB Harmony.
Please refer to the MPLAB Harmony Overview for how the TCP/IP Stack interacts with the framework.
5.8.22.4.1 Abstraction Model
This library provides the API of the SNMP TCP/IP Module that is available on the Microchip family of microcontrollers with a
convenient C language interface. It is a module that belongs to the TCP/IP stack.
Description
SNMP Software Abstraction Block Diagram
Note: This image was not available at time of release and will be added in a future release of MPLAB Harmony.
5.8.22.4.2 Library Overview
The library interface routines are divided into various sub-sections, each of sub-section addresses one of the blocks or the
overall operation of the SNMP module.
Library Interface Section Description
SNMP Module Functions Routines to configure this module
SNMPv3 Module Functions Routines to configure this module
SNMP Application Functions Routines to configure an application
SNMPv3 Application Functions Routines to configure an application
SNMP Data Types and Constants This section provides various definitions describing this API
5.8 TCP/IP Stack Library Help MPLAB Harmony Help SNMP TCP/IP Stack Library
5-3823
SNMPv3 Data Types and Constants This section provides various definitions describing this API
5.8.22.5 Configuring the Library
Macros
Name Description
AUTH_LOCALIZED_PASSWORD_KEY_LEN SNMPv3 Authentication Localized passwed
key lenegth size
END_OF_SNMP_READ_COMMUNITIES ??
END_OF_SNMP_WRITE_COMMUNITIES ??
MY_DEFAULT_SNMP_IF For multi-homed hosts, the default SNMP
interface
NOTIFY_COMMUNITY_LEN Length of Community name array
OID_MAX_LEN Change this to match your OID string length.
PRIV_LOCALIZED_PASSWORD_KEY_LEN SNMPv3 Privacy Pasword key length size
SNMP_BIB_FILE_NAME Name of the bib file for snmp
SNMP_COMMUNITY_MAX_LEN This is the maximum length for community
string. Application must ensure that this
length is observed. SNMP module adds one
byte extra after
SNMP_COMMUNITY_MAX_LEN for adding
'0' NULL character.
SNMP_MAX_COMMUNITY_SUPPORT Specifying more strings than
SNMP_MAX_COMMUNITY_SUPPORT will
result in the later strings being ignored (but
still wasting program memory). Specifying
fewer strings is legal, as long as at least one
is present.
SNMP_MAX_MSG_SIZE SNMP MIN and MAX message 484 bytes in
size. As per RFC 3411
snmpEngineMaxMessageSize and RFC
1157 ( section 4- protocol specification ) and
implementation supports more than 484
whenever feasible.
SNMP_MAX_NON_REC_ID_OID Update the Non record id OID value which is
part of CustomSnmpDemo.c file
5.8 TCP/IP Stack Library Help MPLAB Harmony Help SNMP TCP/IP Stack Library
5-3824
SNMP_READ_COMMUNITIES Default SNMPv2C community names. These
can be overridden at run time if alternate
strings are present in external EEPROM or
Flash (actual strings coould be stored by the
TCPIP storage service. These strings are
case sensitive. An empty string means
disabled (not matchable). For application
security, these default community names
should not be used, but should all be
disabled to force the end user to select
unique community names. These defaults
are provided only to make it easier to start
development. Specifying more strings than
SNMP_MAX_COMMUNITY_SUPPORT will
result in the later strings being ignored (but
still wasting program memory). Specifying...
more
SNMP_TRAP_COMMUNITY_MAX_LEN_MEM_USE This macro will be used to avoid SNMP OID
memory buffer corruption
SNMP_WRITE_COMMUNITIES Default SNMPv2C community names. See
SNMP_READ_COMMUNITIES for more
information.
SNMPV3_AUTH_LOCALIZED_PASSWORD_KEY_LEN_MEM_USE SNMPv3 authentication localized Key length
for memory validation
SNMPV3_PRIV_LOCALIZED_PASSWORD_KEY_LEN_MEM_USE SNMPv3 privacy key length size for memory
validation
SNMPV3_TRAP_MSG_PROCESS_MODEL_DB This is macro
SNMPV3_TRAP_MSG_PROCESS_MODEL
_DB.
SNMPV3_TRAP_SECURITY_LEVEL_DB This is macro
SNMPV3_TRAP_SECURITY_LEVEL_DB.
SNMPV3_TRAP_SECURITY_MODEL_TYPE_DB This is macro
SNMPV3_TRAP_SECURITY_MODEL_TYPE
_DB.
SNMPV3_TRAP_USER_SECURITY_NAME_DB This is macro
SNMPV3_TRAP_USER_SECURITY_NAME
_DB.
SNMPV3_USER_AUTH_PASSWD_DB This is macro
SNMPV3_USER_AUTH_PASSWD_DB.
SNMPV3_USER_AUTH_TYPE_DB This is macro
SNMPV3_USER_AUTH_TYPE_DB.
SNMPV3_USER_PRIV_PASSWD_DB This is macro
SNMPV3_USER_PRIV_PASSWD_DB.
SNMPV3_USER_PRIV_TYPE_DB This is macro
SNMPV3_USER_PRIV_TYPE_DB.
SNMPV3_USER_SECURITY_NAME_DB This is macro
SNMPV3_USER_SECURITY_NAME_DB.
SNMPV3_USER_SECURITY_NAME_LEN_MEM_USE User security name length for memory
validation
SNMPV3_USM_MAX_USER Client configuration options
TRAP_COMMUNITY_MAX_LEN Maximum length of community name table
TRAP_TABLE_SIZE This table maintains list of intereseted
receivers who should receive notifications
when some interesting event occurs.
5.8 TCP/IP Stack Library Help MPLAB Harmony Help SNMP TCP/IP Stack Library
5-3825
USER_SECURITY_NAME_LEN SNMPv3 User Security Name length
Structures
Name Description
SNMP_NET_CONFIG SNMP Network Configuration structure typedef
Description
The configuration of the SNMP TCP/IP Stack Library is based on the file tcpip_config.h
This header file contains the configuration selection for the SNMP TCP/IP Stack Library. Based on the selections made, the
SNMP TCP/IP Stack Library will support or not support selected features. These configuration settings will apply to all instances
of the SNMP TCP/IP Stack Library.
This header can be placed anywhere; however, the path of this header needs to be present in the include search path for a
successful build. Refer to the Applications Overview section for more details.
5.8.22.5.1 AUTH_LOCALIZED_PASSWORD_KEY_LEN Macro
C
#define AUTH_LOCALIZED_PASSWORD_KEY_LEN (20)
Description
SNMPv3 Authentication Localized passwed key lenegth size
5.8.22.5.2 END_OF_SNMP_READ_COMMUNITIES Macro
C
#define END_OF_SNMP_READ_COMMUNITIES
Description
??
5.8.22.5.3 END_OF_SNMP_WRITE_COMMUNITIES Macro
C
#define END_OF_SNMP_WRITE_COMMUNITIES
Description
??
5.8.22.5.4 MY_DEFAULT_SNMP_IF Macro
C
#define MY_DEFAULT_SNMP_IF "PIC32INT"
Description
For multi-homed hosts, the default SNMP interface
5.8 TCP/IP Stack Library Help MPLAB Harmony Help SNMP TCP/IP Stack Library
5-3826
5.8.22.5.5 NOTIFY_COMMUNITY_LEN Macro
C
#define NOTIFY_COMMUNITY_LEN (SNMP_COMMUNITY_MAX_LEN)
Description
Length of Community name array
5.8.22.5.6 OID_MAX_LEN Macro
C
#define OID_MAX_LEN (18)
Description
Change this to match your OID string length.
5.8.22.5.7 PRIV_LOCALIZED_PASSWORD_KEY_LEN Macro
C
#define PRIV_LOCALIZED_PASSWORD_KEY_LEN (20)
Description
SNMPv3 Privacy Pasword key length size
5.8.22.5.8 SNMP_BIB_FILE_NAME Macro
C
#define SNMP_BIB_FILE_NAME "snmp.bib"
Description
Name of the bib file for snmp
5.8.22.5.9 SNMP_COMMUNITY_MAX_LEN Macro
C
#define SNMP_COMMUNITY_MAX_LEN (8u)
Description
This is the maximum length for community string. Application must ensure that this length is observed. SNMP module adds one
byte extra after SNMP_COMMUNITY_MAX_LEN for adding '0' NULL character.
5.8.22.5.10 SNMP_MAX_COMMUNITY_SUPPORT Macro
C
#define SNMP_MAX_COMMUNITY_SUPPORT (3u)
Description
Specifying more strings than SNMP_MAX_COMMUNITY_SUPPORT will result in the later strings being ignored (but still wasting
program memory). Specifying fewer strings is legal, as long as at least one is present.
5.8 TCP/IP Stack Library Help MPLAB Harmony Help SNMP TCP/IP Stack Library
5-3827
5.8.22.5.11 SNMP_MAX_MSG_SIZE Macro
C
#define SNMP_MAX_MSG_SIZE 484
Description
SNMP MIN and MAX message 484 bytes in size. As per RFC 3411 snmpEngineMaxMessageSize and RFC 1157 ( section 4-
protocol specification ) and implementation supports more than 484 whenever feasible.
5.8.22.5.12 SNMP_MAX_NON_REC_ID_OID Macro
C
#define SNMP_MAX_NON_REC_ID_OID 3
Description
Update the Non record id OID value which is part of CustomSnmpDemo.c file
5.8.22.5.13 SNMP_READ_COMMUNITIES Macro
C
#define SNMP_READ_COMMUNITIES {"public", "read", ""}
Description
Default SNMPv2C community names. These can be overridden at run time if alternate strings are present in external EEPROM
or Flash (actual strings coould be stored by the TCPIP storage service. These strings are case sensitive. An empty string means
disabled (not matchable). For application security, these default community names should not be used, but should all be
disabled to force the end user to select unique community names. These defaults are provided only to make it easier to start
development. Specifying more strings than SNMP_MAX_COMMUNITY_SUPPORT will result in the later strings being ignored
(but still wasting program memory). Specifying fewer strings is legal, as long as at least one is present. A string larger than
SNMP_COMMUNITY_MAX_LEN bytes will be ignored.
5.8.22.5.14 SNMP_TRAP_COMMUNITY_MAX_LEN_MEM_USE Macro
C
#define SNMP_TRAP_COMMUNITY_MAX_LEN_MEM_USE (8)
Description
This macro will be used to avoid SNMP OID memory buffer corruption
5.8.22.5.15 SNMP_WRITE_COMMUNITIES Macro
C
#define SNMP_WRITE_COMMUNITIES {"private", "write", "public"}
Description
Default SNMPv2C community names. See SNMP_READ_COMMUNITIES for more information.
5.8 TCP/IP Stack Library Help MPLAB Harmony Help SNMP TCP/IP Stack Library
5-3828
5.8.22.5.16 SNMPV3_AUTH_LOCALIZED_PASSWORD_KEY_LEN_MEM_USE
Macro
C
#define SNMPV3_AUTH_LOCALIZED_PASSWORD_KEY_LEN_MEM_USE (AUTH_LOCALIZED_PASSWORD_KEY_LEN+1)
Description
SNMPv3 authentication localized Key length for memory validation
5.8.22.5.17 SNMPV3_PRIV_LOCALIZED_PASSWORD_KEY_LEN_MEM_USE
Macro
C
#define SNMPV3_PRIV_LOCALIZED_PASSWORD_KEY_LEN_MEM_USE (PRIV_LOCALIZED_PASSWORD_KEY_LEN+1)
Description
SNMPv3 privacy key length size for memory validation
5.8.22.5.18 SNMPV3_TRAP_MSG_PROCESS_MODEL_DB Macro
C
#define SNMPV3_TRAP_MSG_PROCESS_MODEL_DB
{SNMPV3_MSG_PROCESSING_MODEL,SNMPV3_MSG_PROCESSING_MODEL,SNMPV3_MSG_PROCESSING_MODEL}
Description
This is macro SNMPV3_TRAP_MSG_PROCESS_MODEL_DB.
5.8.22.5.19 SNMPV3_TRAP_SECURITY_LEVEL_DB Macro
C
#define SNMPV3_TRAP_SECURITY_LEVEL_DB {AUTH_PRIV,AUTH_NO_PRIV,NO_AUTH_NO_PRIV}
Description
This is macro SNMPV3_TRAP_SECURITY_LEVEL_DB.
5.8.22.5.20 SNMPV3_TRAP_SECURITY_MODEL_TYPE_DB Macro
C
#define SNMPV3_TRAP_SECURITY_MODEL_TYPE_DB
{SNMPV3_USM_SECURITY_MODEL,SNMPV3_USM_SECURITY_MODEL,SNMPV3_USM_SECURITY_MODEL}
Description
This is macro SNMPV3_TRAP_SECURITY_MODEL_TYPE_DB.
5.8.22.5.21 SNMPV3_TRAP_USER_SECURITY_NAME_DB Macro
C
#define SNMPV3_TRAP_USER_SECURITY_NAME_DB {"microchip","SnmpAdmin","root"}
5.8 TCP/IP Stack Library Help MPLAB Harmony Help SNMP TCP/IP Stack Library
5-3829
Description
This is macro SNMPV3_TRAP_USER_SECURITY_NAME_DB.
5.8.22.5.22 SNMPV3_USER_AUTH_PASSWD_DB Macro
C
#define SNMPV3_USER_AUTH_PASSWD_DB {"auth12345","ChandlerUS",""}
Description
This is macro SNMPV3_USER_AUTH_PASSWD_DB.
5.8.22.5.23 SNMPV3_USER_AUTH_TYPE_DB Macro
C
#define SNMPV3_USER_AUTH_TYPE_DB {SNMPV3_HAMC_MD5,SNMPV3_HMAC_SHA1,SNMPV3_NO_HMAC_AUTH}
Description
This is macro SNMPV3_USER_AUTH_TYPE_DB.
5.8.22.5.24 SNMPV3_USER_PRIV_PASSWD_DB Macro
C
#define SNMPV3_USER_PRIV_PASSWD_DB {"priv12345","",""}
Description
This is macro SNMPV3_USER_PRIV_PASSWD_DB.
5.8.22.5.25 SNMPV3_USER_PRIV_TYPE_DB Macro
C
#define SNMPV3_USER_PRIV_TYPE_DB {SNMPV3_AES_PRIV,SNMPV3_NO_PRIV,SNMPV3_NO_PRIV}
Description
This is macro SNMPV3_USER_PRIV_TYPE_DB.
5.8.22.5.26 SNMPV3_USER_SECURITY_NAME_DB Macro
C
#define SNMPV3_USER_SECURITY_NAME_DB {"microchip","SnmpAdmin","root"}
Description
This is macro SNMPV3_USER_SECURITY_NAME_DB.
5.8.22.5.27 SNMPV3_USER_SECURITY_NAME_LEN_MEM_USE Macro
C
#define SNMPV3_USER_SECURITY_NAME_LEN_MEM_USE (USER_SECURITY_NAME_LEN+1)
5.8 TCP/IP Stack Library Help MPLAB Harmony Help SNMP TCP/IP Stack Library
5-3830
Description
User security name length for memory validation
5.8.22.5.28 SNMPV3_USM_MAX_USER Macro
C
#define SNMPV3_USM_MAX_USER 3
Description
Client configuration options
5.8.22.5.29 TRAP_COMMUNITY_MAX_LEN Macro
C
#define TRAP_COMMUNITY_MAX_LEN (SNMP_TRAP_COMMUNITY_MAX_LEN_MEM_USE+1)
Description
Maximum length of community name table
5.8.22.5.30 TRAP_TABLE_SIZE Macro
C
#define TRAP_TABLE_SIZE (2)
Description
This table maintains list of intereseted receivers who should receive notifications when some interesting event occurs.
5.8.22.5.31 USER_SECURITY_NAME_LEN Macro
C
#define USER_SECURITY_NAME_LEN (16)
Description
SNMPv3 User Security Name length
5.8.22.5.32 SNMP_NET_CONFIG Structure
C
typedef struct {
uint8_t readCommunity[SNMP_MAX_COMMUNITY_SUPPORT][SNMP_COMMUNITY_MAX_LEN+1];
uint8_t writeCommunity[SNMP_MAX_COMMUNITY_SUPPORT][SNMP_COMMUNITY_MAX_LEN+1];
uint32_t SnmpEngineBootRcrd;
} SNMP_NET_CONFIG;
Description
SNMP Network Configuration structure typedef
5.8 TCP/IP Stack Library Help MPLAB Harmony Help SNMP TCP/IP Stack Library
5-3831
Members
Members Description
uint8_t
readCommunity[SNMP_MAX_COMMUNITY_SUPPORT][SNMP_COMMUNITY_MAX_LEN+1];
SNMPv2C Read community
names
SNMP_COMMUNITY_MAX_LE
N
(8) + 1 null termination byte
uint8_t
writeCommunity[SNMP_MAX_COMMUNITY_SUPPORT][SNMP_COMMUNITY_MAX_LEN+1];
SNMPv2C Write community
names
SNMP_COMMUNITY_MAX_LE
N
(8) + 1 null termination byte
uint32_t SnmpEngineBootRcrd; SNMP Engine Boot Record
location
5.8.22.6 Building the Library
This section list the files that are available in the \src of the SNMP driver. It lists which files need to be included in the build based
on either a hardware feature present on the board or configuration option selected by the system.
5.8.22.7 Library Interface
SNMP Application Functions
Name Description
SNMPGetExactIndex To search for exact index node in case of a Sequence variable.
SNMPGetNextIndex To search for next index node in case of a Sequence variable.
SNMPGetVar Used to Get/collect OID variable information.
SNMPIsValidSetLen Validates the set variable data length to data type.
SNMPSendTrap Prepare, validate remote node which will receive trap and send trap pdu.
SNMPSetVar This routine Set the mib variable with the requested value.
SNMPValidateCommunity Validates community name for access control.
SNMP Data Types and Constants
Name Description
SNMP_END_OF_VAR This is macro SNMP_END_OF_VAR.
5.8 TCP/IP Stack Library Help MPLAB Harmony Help SNMP TCP/IP Stack Library
5-3832
SNMP_H FileName: SNMP.h Copyright © 2012 released Microchip
Technology Inc. All rights reserved.
Microchip licenses to you the right to use, modify, copy and
distribute Software only when embedded on a Microchip
microcontroller or digital signal controller that is integrated
into your product or third party product (pursuant to the
sublicense terms in the accompanying license agreement).
You should refer to the license agreement accompanying
this Software for additional information regarding your rights
and obligations.
SOFTWARE AND DOCUMENTATION ARE PROVIDED “AS
IS” WITHOUT WARRANTY OF ANY KIND, EITHER
EXPRESS OR IMPLIED, INCLUDING WITHOUT
LIMITATION, ANY WARRANTY OF MERCHANTABILITY,
TITLE, NON-INFRINGEMENT AND... more
SNMP_INDEX_INVALID This is macro SNMP_INDEX_INVALID.
SNMP_START_OF_VAR
SNMP_V1
SNMP_V2C This is macro SNMP_V2C.
SNMP_V3 This is macro SNMP_V3.
GENERIC_TRAP_NOTIFICATION_TYPE This is type GENERIC_TRAP_NOTIFICATION_TYPE.
IPV6_SNMP_TRAP_INFO This is type IPV6_SNMP_TRAP_INFO.
SNMP_BUFFER_DATA SNMPv1/v2c
SNMP_COMMUNITY_TYPE This is type SNMP_COMMUNITY_TYPE.
SNMP_ID This is the SNMP OID variable id. This id is assigned via
MIB file. Only dynamic and AgentID variables can contian
ID. MIB2BIB utility enforces this rules when BIB was
generated. typedef int SNMP_ID;
SNMP_INDEX This is type SNMP_INDEX.
SNMP_MODULE_CONFIG This is type SNMP_MODULE_CONFIG.
SNMP_NON_MIB_RECD_INFO This is type SNMP_NON_MIB_RECD_INFO.
SNMP_NOTIFY_INFO // the only if that runs SNMP
SNMP_PROCESSING_MEM_INFO_PTRS This is type SNMP_PROCESSING_MEM_INFO_PTRS.
SNMP_STACK_DCPT_STUB
SNMP_TRAP_INFO This is type SNMP_TRAP_INFO.
SNMP_TRAP_IP_ADDRESS_TYPE This is type SNMP_TRAP_IP_ADDRESS_TYPE.
SNMP_VAL This is type SNMP_VAL.
TCPIP_SNMP_DCPT TCPIP_STACK_USE_IPV6
TCPIP_SNMP_SM This is type TCPIP_SNMP_SM.
VENDOR_SPECIFIC_TRAP_NOTIFICATION_TYPE This is type
VENDOR_SPECIFIC_TRAP_NOTIFICATION_TYPE.
tIPV6_SNMP_TRAP_INFO This is type IPV6_SNMP_TRAP_INFO.
tSNMP_TRAP_INFO This is type SNMP_TRAP_INFO.
SNMP Module Functions
Name Description
TCPIP_SNMP_ClientGetNet
TCPIP_SNMP_DataCopyToProcessBuffer Copies uint8_t data to dynamically allocated memory buffer.
TCPIP_SNMP_EventNotifyGet To Get the IPv6 DHCP event notification.
TCPIP_SNMP_Notify Creates and Sends TRAP pdu.
5.8 TCP/IP Stack Library Help MPLAB Harmony Help SNMP TCP/IP Stack Library
5-3833
TCPIP_SNMP_NotifyIsReady Resolves given remoteHost IP address into MAC address.
TCPIP_SNMP_NotifyPrepare Collects trap notification info and send ARP to remote host.
TCPIP_SNMP_PacketProcStubPtrsGet Get SNMP packet processing memory pointer.
TCPIP_SNMP_ProcessBufferDataGet Reads uint8_t data from dynamically allocated memory buffer.
TCPIP_SNMP_ReadCommunityGet Get the readCommunity String with Snmp index.
TCPIP_SNMP_TrapTimeGet Get SNMP Trap UDP client open socket timeout.
TCPIP_SNMP_WriteCommunityGet Get the writeCommunity String with Snmp index.
SNMPv3 Application Functions
Name Description
SNMPv3ComputeHMACIpadOpadForAuthLoclzedKey Compute HMAC inner and outer pad for
authorization localized key.
SNMPv3USMAuthPrivPswdLocalization Convert Auth and Priv password to the localized
Key using SNMPEngineID.
TCPIP_SNMPv3_CmprTrapSecNameAndSecLvlWithUSMDb Routine to find the index of the user name in the
user data base table.
SNMPv3 Data Types and Constants
Name Description
SNMPV3_PROCESSING_MEM_INFO_PTRS SNMPv3 Processing Memory Pointers
SNMPV3_STACK_DCPT_STUB SNMPv3 Descriptor Structure Typedef
SNMPv3 Module Functions
Name Description
TCPIP_SNMPv3_Notify Creates and Sends SNMPv3 TRAP pdu.
TCPIP_SNMPV3_PacketProcStubPtrsGet Get SNMPv3 packet processing memory pointer.
Description
This section describes the Application Programming Interface (API) functions of the SNMP TCP/IP Stack.
Refer to each section for a detailed description.
5.8.22.7.1 SNMP Module Functions
5.8.22.7.1.1 TCPIP_SNMP_ClientGetNet Function
C
TCPIP_NET_HANDLE TCPIP_SNMP_ClientGetNet();
5.8.22.7.1.2 TCPIP_SNMP_DataCopyToProcessBuffer Function
C
bool TCPIP_SNMP_DataCopyToProcessBuffer(
uint8_t val,
SNMP_BUFFER_DATA * putbuf
);
Description
The SNMPv1 and v2c stack implementation uses dynamically allocated memory buffer for processing of request and response
packets. This routine copies the uint8_t data to the allocated buffer and updates the offset length couter.
5.8 TCP/IP Stack Library Help MPLAB Harmony Help SNMP TCP/IP Stack Library
5-3834
Preconditions
The SNMPv1 and v2c stack has sucessfully allocated dynamic memory buffer from the Heap
Parameters
Parameters Description
val uint8_t value to be written to the buffer
putbuf pointer to the dynamically allocated buffer to which the 'val' to be written
Return Values
Return Values Description
true if successfully write to the buffer
false failure in writing to the buffer
Remarks
This routine is used by the SNMP stack. If required to be used by the application code, valid pointers should be passed to this
routine.
5.8.22.7.1.3 TCPIP_SNMP_EventNotifyGet Function
C
IPV6_EVENT_TYPE TCPIP_SNMP_EventNotifyGet(
TCPIP_NET_HANDLE hNet
);
Description
This rutine is used to get the DHCP with IPv6 notication if the IPv6 unicast address is updated.
Preconditions
TCPIP_SNMP_Initialize() is called.
Parameters
Parameters Description
hNet Interface
Remarks
None.
5.8.22.7.1.4 TCPIP_SNMP_Notify Function
C
bool TCPIP_SNMP_Notify(
SNMP_ID var,
SNMP_VAL val,
SNMP_INDEX index
);
Description
This function creates SNMP V2 Trap PDU and sends it to previously specified remoteHost.
SNMP V1 trap pdu: | PDU-type | enterprise | agent-addr | generic-trap | specific-trap | | time-stamp | varbind-list |
The v1 enterprise is mapped directly to SNMPv2TrapOID.0
SNMP V2 trap pdu: version (0 or 1) | community | SNMP-PDU |pdu-type | request-id | error-status |err-index |varbinds
5.8 TCP/IP Stack Library Help MPLAB Harmony Help SNMP TCP/IP Stack Library
5-3835
The first two variables (in varbind-list) of snmpv2 are: sysUpTime.0 and SNMPv2TrapOID.0
Generic Trap OID is used as the varbind for authentication failure.
Preconditions
TCPIP_SNMP_NotifyIsReady() is already called and returned true.
Parameters
Parameters Description
var SNMP var ID that is to be used in notification
val Value of var. Only value of uint8_t, uint16_t or uint32_t can be sent.
index Index of var. If this var is a single,index would be 0, or else if this var Is a
sequence, index could be any value from 0 to 127
Return Values
Return Values Description
true if SNMP notification was successful sent. This does not guarantee that
remoteHost recieved it.
false Notification sent failed.
This would fail under following contions 1) Given SNMP_BIB_FILE does not exist in file system 2) Given var does not
exist. 3) Previously given agentID does not exist
4) Data type of given var is unknown possible if file system itself was corrupted.
Remarks
This would fail if there were not UDP socket to open.
5.8.22.7.1.5 TCPIP_SNMP_NotifyIsReady Function
C
bool TCPIP_SNMP_NotifyIsReady(
IP_MULTI_ADDRESS* remoteHost,
SNMP_TRAP_IP_ADDRESS_TYPE eTrapMultiAddressType
);
Description
This function resolves given remoteHost IP address into MAC address using ARP module. If remoteHost is not aviailable, this
function would never return true. Application must implement timeout logic to handle "remoteHost not avialable" situation.
Preconditions
TCPIP_SNMP_NotifyPrepare() is already called.
Parameters
Parameters Description
remoteHost Pointer to remote Host IP address
Return Values
Return Values Description
true If remoteHost IP address is resolved and TCPIP_SNMP_Notify may be called.
false If remoteHost IP address is not resolved.
Remarks
This would fail if there were not UDP socket to open.
5.8 TCP/IP Stack Library Help MPLAB Harmony Help SNMP TCP/IP Stack Library
5-3836
5.8.22.7.1.6 TCPIP_SNMP_NotifyPrepare Function
C
void TCPIP_SNMP_NotifyPrepare(
IP_MULTI_ADDRESS* remoteHost,
char* community,
uint8_t communityLen,
SNMP_ID agentIDVar,
uint8_t notificationCode,
uint32_t timestamp
);
Description
This function prepares SNMP module to send SNMP trap notification to remote host. It sends ARP request to remote host to
learn remote host MAC address.
Preconditions
TCPIP_SNMP_Initialize() is already called.
Parameters
Parameters Description
remoteHost pointer to remote Host IP address
community Community string to use to notify
communityLen Community string length
agentIDVar System ID to use identify this agent
notificaitonCode Notification Code to use
timestamp Notification timestamp in 100th of second.
Returns
None
Remarks
This is first of series of functions to complete SNMP notification.
5.8.22.7.1.7 TCPIP_SNMP_PacketProcStubPtrsGet Function
C
void TCPIP_SNMP_PacketProcStubPtrsGet(
SNMP_PROCESSING_MEM_INFO_PTRS * dynMemInfoPtr
);
Description
This function is used to get dynamic memory allocation pointer details which is used for SNMP packet processing.
Preconditions
TCPIP_SNMP_Initialize() is already called.
Parameters
Parameters Description
dynMemInfoPtr Dynamic memory pointer for packet processing
Remarks
None.
5.8 TCP/IP Stack Library Help MPLAB Harmony Help SNMP TCP/IP Stack Library
5-3837
5.8.22.7.1.8 TCPIP_SNMP_ProcessBufferDataGet Function
C
uint8_t TCPIP_SNMP_ProcessBufferDataGet(
SNMP_BUFFER_DATA getbuf,
uint16_t pos
);
Description
The SNMPstack implementation uses dynamically allocated memory buffer for processing of request and response packets. This
routine reads the uint8_t data from the allocated buffer at the positions (offset) provided.
Preconditions
The SNMPv1 and v2c stack has sucessfully allocated dynamic memory buffer from the Heap
Parameters
Parameters Description
getbuf Structure from where to read the data byte.
pos position in the buffer from which the data to be read
Return Values
Return Values Description
uint8_t 1 byte value read
Remarks
The read position offset is required to be provided every time the routine is called. This API do not increment the buffer read
offset automatically, everytime it is called.
5.8.22.7.1.9 TCPIP_SNMP_ReadCommunityGet Function
C
uint8_t* TCPIP_SNMP_ReadCommunityGet(
int index
);
Description
Get the readCommunity String with Snmp index.
Preconditions
_SNMP_ProcessVariables() is called.
Parameters
Parameters Description
index SNMP_MAX_COMMUNITY_SUPPORT.
Return Values
Return Values Description
uint8_t * unsigned char community string
Remarks
None.
5.8 TCP/IP Stack Library Help MPLAB Harmony Help SNMP TCP/IP Stack Library
5-3838
5.8.22.7.1.10 TCPIP_SNMP_TrapTimeGet Function
C
SYS_TICK TCPIP_SNMP_TrapTimeGet();
Description
This function returns a SYS_TICK time(snmpTrapTimer) which is used to timeout a SNMP TRAP notification for a HOST.
snmpTrapTimer is initialized when there is UDP client socket open either for a HOST IPv4 or IPv6 address.
Preconditions
TCPIP_SNMP_Initialize() is already called.
Remarks
None.
5.8.22.7.1.11 TCPIP_SNMP_WriteCommunityGet Function
C
uint8_t* TCPIP_SNMP_WriteCommunityGet(
int index
);
Description
Get the writeCommunity String with Snmp index.
Preconditions
_SNMP_ProcessVariables() is called.
Parameters
Parameters Description
index SNMP_MAX_COMMUNITY_SUPPORT.
Return Values
Return Values Description
uint8_t * unsigned char community string
Remarks
None.
5.8.22.7.2 SNMPv3 Module Functions
5.8.22.7.2.1 TCPIP_SNMPv3_Notify Function
C
bool TCPIP_SNMPv3_Notify(
SNMP_ID var,
SNMP_VAL val,
SNMP_INDEX index,
uint8_t targetIndex
);
Description
This function creates SNMPv3 trap PDU and sends it to previously specified remoteHost.
5.8 TCP/IP Stack Library Help MPLAB Harmony Help SNMP TCP/IP Stack Library
5-3839
Preconditions
TRAP event is triggered.
Parameters
Parameters Description
var SNMP var ID that is to be used in notification
val Value of var. Only value of uint8_t, uint16_t or uint32_t can be sent.
index Index of var. If this var is a single,index would be 0, or else if this var Is a
sequence, index could be any value from 0 to 127 targetIndex -index of the
'Snmpv3TrapConfigData' table's security user name for which the TRAP PDU
message header to constructed.
Return Values
Return Values Description
true if SNMP notification was successful sent. This does not guarantee that
remoteHost recieved it.
false Notification sent failed.
This would fail under following contions 1) Given SNMP_BIB_FILE does not exist in file system 2) Given var does not
exist. 3) Previously given agentID does not exist
4) Data type of given var is unknown only possible if file system itself was corrupted. SNMPV3_MSG_PRIV_FAIL
-encryption of the trap msg failed
SNMPV3_MSG_AUTH_FAIL HAMC of the trap msg failed
Remarks
None
5.8.22.7.2.2 TCPIP_SNMPV3_PacketProcStubPtrsGet Function
C
void TCPIP_SNMPV3_PacketProcStubPtrsGet(
SNMPV3_PROCESSING_MEM_INFO_PTRS * dynMemInfoPtr
);
Description
This function is used to get dynamic memory allocation pointer details which is used for SNMPv3 packet processing.
Preconditions
TCPIP_SNMP_Initialize() is already called.
Parameters
Parameters Description
dynMemInfoPtr Dynamic memory pointer for packet processing
Remarks
The source code for this routine is found in snmp.c, not snmpv3.c.
5.8.22.7.3 SNMP Application Functions
5.8 TCP/IP Stack Library Help MPLAB Harmony Help SNMP TCP/IP Stack Library
5-3840
5.8.22.7.3.1 SNMPGetExactIndex Function
C
bool SNMPGetExactIndex(
SNMP_ID var,
SNMP_INDEX * index
);
Description
This is a callback function called by SNMP module. SNMP user must implement this function in user application and provide
appropriate data when called. This function will only be called for OID variable of type sequence.
Preconditions
None
Parameters
Parameters Description
var Variable id as per mib.h (input)
index Index of variable (input)
Return Values
Return Values Description
true If the exact index value exists for given variable at given index.
false Otherwise.
Remarks
Only sequence index needs to be handled in this function.
5.8.22.7.3.2 SNMPGetNextIndex Function
C
bool SNMPGetNextIndex(
SNMP_ID var,
SNMP_INDEX* index
);
Description
This is a callback function called by SNMP module. SNMP user must implement this function in user application and provide
appropriate data when called. This function will only be called for OID variable of type sequence.
Preconditions
None
Parameters
Parameters Description
var Variable id whose value is to be returned
index Next Index of variable that should be transferred
Return Values
Return Values Description
true If a next index value exists for given variable at given index and index parameter
contains next valid index.
5.8 TCP/IP Stack Library Help MPLAB Harmony Help SNMP TCP/IP Stack Library
5-3841
false Otherwise.
Remarks
Only sequence index needs to be handled in this function.
5.8.22.7.3.3 SNMPGetVar Function
C
bool SNMPGetVar(
SNMP_ID var,
SNMP_INDEX index,
uint8_t* ref,
SNMP_VAL* val
);
Description
This is a callback function called by SNMP module. SNMP user must implement this function in user application and provide
appropriate data when called.
Preconditions
None
Parameters
Parameters Description
var Variable id whose value is to be returned
index Index of variable that should be transferred
ref Variable reference used to transfer multi-byte data It is always
SNMP_START_OF_VAR when very first byte is requested. Otherwise, use this as
a reference to keep track of multi-byte transfers.
val Pointer to up to 4 byte buffer. If var data type is uint8_t, transfer data in val->byte If
var data type is uint16_t, transfer data in val->word If var data type is uint32_t,
transfer data in val->dword If var data type is IP_ADDRESS, transfer data in
val->v[] or val->dword If var data type is COUNTER32, TIME_TICKS or
GAUGE32, transfer data in val->dword If var data type is ASCII_STRING or
OCTET_STRING transfer data in val->byte using multi-byte transfer mechanism.
Return Values
Return Values Description
true If a value exists for given variable at given index.
false Otherwise.
Remarks
None.
5.8.22.7.3.4 SNMPIsValidSetLen Function
C
bool SNMPIsValidSetLen(
SNMP_ID var,
uint8_t len,
uint8_t index
);
5.8 TCP/IP Stack Library Help MPLAB Harmony Help SNMP TCP/IP Stack Library
5-3842
Description
This routine is used to validate the dyanmic variable data length to the variable data type. It is used when SET request is
processed. This is a callback function called by module. User application must implement this function.
Preconditions
TCPIP_SNMP_ProcessSetVar() is called.
Parameters
Parameters Description
var Variable id whose value is to be set
len Length value that is to be validated.
Return Values
Return Values Description
true if given var can be set to given len
false if otherwise.
Remarks
This function will be called for only dynamic variables that are defined as ASCII_STRING and OCTET_STRING (i.e. data length
greater than 4 bytes)
5.8.22.7.3.5 SNMPSendTrap Function
C
void SNMPSendTrap();
Description
This function is used to send trap notification to previously configured ip address if trap notification is enabled. There are different
trap notification code. The current implementation sends trap for authentication failure (4).
Preconditions
If application defined event occurs to send the trap.
Returns
None.
Remarks
This is a callback function called by the application on certain predefined events. This routine only implemented to send a
authentication failure Notification-type macro with PUSH_BUTTON oid stored in MPFS. If the ARP is no resolved i.e. if
TCPIP_SNMP_NotifyIsReady() returns false, this routine times out in 5 seconds. This routine should be modified according to
event occured and should update corrsponding OID and notification type to the trap pdu.
5.8.22.7.3.6 SNMPSetVar Function
C
bool SNMPSetVar(
SNMP_ID var,
SNMP_INDEX index,
uint8_t ref,
SNMP_VAL val
);
5.8 TCP/IP Stack Library Help MPLAB Harmony Help SNMP TCP/IP Stack Library
5-3843
Description
This is a callback function called by module for the snmp SET request.User application must modify this function for the new
variables address.
Preconditions
TCPIP_SNMP_ProcessVariables() is called.
Parameters
Parameters Description
var Variable id whose value is to be set
ref Variable reference used to transfer multi-byte data 0 if first byte is set otherwise
nonzero value to indicate corresponding byte being set.
val Up to 4 byte data value. If var data type is uint8_t, variable value is in val->byte If
var data type is uint16_t, variable value is in val->word If var data type is uint32_t,
variable value is in val->dword. If var data type is IP_ADDRESS, COUNTER32, or
GAUGE32, value is in val->dword If var data type is OCTET_STRING,
ASCII_STRING value is in val->byte; multi-byte transfer will be performed to
transfer remaining bytes of data.
Return Values
Return Values Description
true if it is OK to set more byte(s).
false if otherwise.
Remarks
This function may get called more than once depending on number of bytes in a specific set request for given variable. only
dynamic read-write variables needs to be handled.
5.8.22.7.3.7 SNMPValidateCommunity Function
C
uint8_t SNMPValidateCommunity(
uint8_t* community
);
Description
This function validates the community name for the mib access to NMS. The snmp community name received in the request pdu
is validated for read and write community names. The agent gives an access to the mib variables only if the community matches
with the predefined values. This routine also sets a gloabal flag to send trap if authentication failure occurs.
Preconditions
TCPIP_SNMP_Initialize is already called.
Parameters
Parameters Description
community Pointer to community string as sent by NMS.
Returns
This routine returns the community validation result as READ_COMMUNITY or WRITE_COMMUNITY or INVALID_COMMUNITY
Remarks
This is a callback function called by module. User application must implement this function and verify that community matches
5.8 TCP/IP Stack Library Help MPLAB Harmony Help SNMP TCP/IP Stack Library
5-3844
with predefined value. This validation occurs for each NMS request.
5.8.22.7.4 SNMPv3 Application Functions
5.8.22.7.4.1 SNMPv3ComputeHMACIpadOpadForAuthLoclzedKey Function
C
void SNMPv3ComputeHMACIpadOpadForAuthLoclzedKey(
uint8_t userDBIndex
);
Description
This routine computes HMAC inner and outer pad strings for authorization localized key. RFC - 2104.
Preconditions
TCPIP_SNMPv3_Initialize() and ProcessVariabels() are called.
Parameters
Parameters Description
userDBIndex password storage poniter
Remarks
None
5.8.22.7.4.2 SNMPv3USMAuthPrivPswdLocalization Function
C
void SNMPv3USMAuthPrivPswdLocalization(
uint8_t userDBIndex
);
Description
This routine converts MD5 or SHA1 and AES privacy password key to localized key using snmpSngineID(RFC- 3414 - section 6).
Preconditions
TCPIP_SNMPv3_Initialize() and ProcessVariabels() are called.
Parameters
Parameters Description
userDBIndex authentication protocol type
Remarks
None
5.8.22.7.4.3 TCPIP_SNMPv3_CmprTrapSecNameAndSecLvlWithUSMDb Function
C
bool TCPIP_SNMPv3_CmprTrapSecNameAndSecLvlWithUSMDb(
uint8_t tragetIndex,
uint8_t userTrapSecLen,
uint8_t * userTrapSecurityName,
STD_BASED_SNMPV3_SECURITY_LEVEL securityLevel
);
5.8 TCP/IP Stack Library Help MPLAB Harmony Help SNMP TCP/IP Stack Library
5-3845
Description
There are two different data base tables defined with SNMPv3 stack, like 'UserInfoDataBase' and 'Snmpv3TrapConfigData'. This
routine is used to validte the trap user security level setting with SET request.
Preconditions
SET operation would be allowed if the USM security conditions and user security name in the request is matched to one of the
user security name stored in the usm user database.
Parameters
Parameters Description
userTrapSecLen user sec name length in the SET request
userTrapSecurityName pointer to user sec name in the SET request
securityLevel trap security level to be SET on the agent
Return Values
Return Values Description
true if the trap target user sec level setting is successful
FLASE If the SET failed due to non matching of the security parameters
Remarks
None.
5.8.22.7.5 SNMP Data Types and Constants
5.8.22.7.5.1 SNMP_END_OF_VAR Macro
C
#define SNMP_END_OF_VAR (0xff)
Description
This is macro SNMP_END_OF_VAR.
5.8.22.7.5.2 SNMP_H Macro
C
#define SNMP_H
Description
FileName: SNMP.h Copyright © 2012 released Microchip Technology Inc. All rights reserved.
Microchip licenses to you the right to use, modify, copy and distribute Software only when embedded on a Microchip
microcontroller or digital signal controller that is integrated into your product or third party product (pursuant to the sublicense
terms in the accompanying license agreement).
You should refer to the license agreement accompanying this Software for additional information regarding your rights and
obligations.
SOFTWARE AND DOCUMENTATION ARE PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS
OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE, NON-INFRINGEMENT
AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR
OBLIGATED UNDER CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR
5.8 TCP/IP Stack Library Help MPLAB Harmony Help SNMP TCP/IP Stack Library
5-3846
OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES INCLUDING BUT NOT
LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR
LOST DATA, COST OF PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY
THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
5.8.22.7.5.3 SNMP_INDEX_INVALID Macro
C
#define SNMP_INDEX_INVALID (0xff)
Description
This is macro SNMP_INDEX_INVALID.
5.8.22.7.5.4 SNMP_START_OF_VAR Macro
C
#define SNMP_START_OF_VAR (0)
5.8.22.7.5.5 SNMP_V1 Macro
C
#define SNMP_V1 (0)
5.8.22.7.5.6 SNMP_V2C Macro
C
#define SNMP_V2C (1)
Description
This is macro SNMP_V2C.
5.8.22.7.5.7 SNMP_V3 Macro
C
#define SNMP_V3 (3)
Description
This is macro SNMP_V3.
5.8.22.7.5.8 GENERIC_TRAP_NOTIFICATION_TYPE Enumeration
C
typedef enum {
COLD_START = 0x0,
WARM_START = 0x1,
LINK_DOWN = 0x2,
LINK_UP = 0x3,
AUTH_FAILURE = 0x4,
EGP_NEBOR_LOSS = 0x5,
ENTERPRISE_SPECIFIC = 0x6
} GENERIC_TRAP_NOTIFICATION_TYPE;
Description
This is type GENERIC_TRAP_NOTIFICATION_TYPE.
5.8 TCP/IP Stack Library Help MPLAB Harmony Help SNMP TCP/IP Stack Library
5-3847
5.8.22.7.5.9 IPV6_SNMP_TRAP_INFO Structure
C
typedef struct tIPV6_SNMP_TRAP_INFO {
uint8_t Size;
struct {
uint8_t communityLen;
char community[TRAP_COMMUNITY_MAX_LEN];
IPV6_ADDR IPv6Address;
struct {
unsigned int bEnabled : 1;
} Flags;
} table[TRAP_TABLE_SIZE];
} IPV6_SNMP_TRAP_INFO;
Description
This is type IPV6_SNMP_TRAP_INFO.
Members
Members Description
uint8_t communityLen; Community name length
char
community[TRAP_COMMUNITY_MAX_LEN];
Community name array
IPV6_ADDR IPv6Address; IPv6 address to which trap to be sent
unsigned int bEnabled : 1; Trap enabled flag
5.8.22.7.5.10 SNMP_BUFFER_DATA Structure
C
typedef struct {
uint8_t * head;
uint16_t length;
} SNMP_BUFFER_DATA;
Description
SNMPv1/v2c
5.8.22.7.5.11 SNMP_COMMUNITY_TYPE Enumeration
C
typedef enum {
READ_COMMUNITY = 1,
WRITE_COMMUNITY = 2,
INVALID_COMMUNITY = 3
} SNMP_COMMUNITY_TYPE;
Description
This is type SNMP_COMMUNITY_TYPE.
Members
Members Description
READ_COMMUNITY = 1 Read only community
WRITE_COMMUNITY = 2 Read write community
INVALID_COMMUNITY = 3 Community invalid
5.8 TCP/IP Stack Library Help MPLAB Harmony Help SNMP TCP/IP Stack Library
5-3848
5.8.22.7.5.12 SNMP_ID Type
C
typedef uint32_t SNMP_ID;
Description
This is the SNMP OID variable id. This id is assigned via MIB file. Only dynamic and AgentID variables can contian ID. MIB2BIB
utility enforces this rules when BIB was generated. typedef int SNMP_ID;
5.8.22.7.5.13 SNMP_INDEX Type
C
typedef uint8_t SNMP_INDEX;
Description
This is type SNMP_INDEX.
5.8.22.7.5.14 SNMP_MODULE_CONFIG Structure
C
typedef struct {
} SNMP_MODULE_CONFIG;
Description
This is type SNMP_MODULE_CONFIG.
5.8.22.7.5.15 SNMP_NON_MIB_RECD_INFO Structure
C
typedef struct {
uint8_t oidstr[16];
uint8_t version;
} SNMP_NON_MIB_RECD_INFO;
Description
This is type SNMP_NON_MIB_RECD_INFO.
5.8.22.7.5.16 SNMP_NOTIFY_INFO Structure
C
typedef struct {
char community[NOTIFY_COMMUNITY_LEN];
uint8_t communityLen;
SNMP_ID agentIDVar;
uint8_t notificationCode;
UDP_SOCKET socket;
TCPIP_UINT32_VAL timestamp;
SNMP_ID trapIDVar;
TCPIP_NET_HANDLE snmpTrapInf;
} SNMP_NOTIFY_INFO;
Description
// the only if that runs SNMP
5.8 TCP/IP Stack Library Help MPLAB Harmony Help SNMP TCP/IP Stack Library
5-3849
Members
Members Description
char
community[NOTIFY_COMMUNITY_LEN];
Community name array
uint8_t communityLen; Community name length
SNMP_ID agentIDVar; Agent id for trap identification
uint8_t notificationCode; Trap notification code
UDP_SOCKET socket; Udp socket number
TCPIP_UINT32_VAL timestamp; Time stamp for trap
SNMP_ID trapIDVar; SNMPV2 specific trap
TCPIP_NET_HANDLE snmpTrapInf; interface we use for the SNMP TRAP
5.8.22.7.5.17 SNMP_PROCESSING_MEM_INFO_PTRS Structure
C
typedef struct {
SNMP_STACK_DCPT_STUB* snmpStkDynMemStubPtr;
const void* snmpHeapMemHandler;
TCPIP_SNMP_DCPT* snmpDcptPtr;
} SNMP_PROCESSING_MEM_INFO_PTRS;
Description
This is type SNMP_PROCESSING_MEM_INFO_PTRS.
5.8.22.7.5.18 SNMP_STACK_DCPT_STUB Structure
C
typedef struct {
uint8_t gOIDCorrespondingSnmpMibID;
uint8_t gSetTrapSendFlag;
bool getZeroInstance;
uint8_t appendZeroToOID;
uint8_t gSendTrapFlag;
uint8_t gGenericTrapNotification;
uint8_t gSpecificTrapNotification;
SNMP_NOTIFY_INFO SNMPNotifyInfo;
SNMP_BUFFER_DATA outPduBufData;
SNMP_BUFFER_DATA trapPduOutBufData;
SNMP_NET_CONFIG snmpNetConfig;
} SNMP_STACK_DCPT_STUB;
Members
Members Description
SNMP_NOTIFY_INFO SNMPNotifyInfo; notify info for trap
5.8.22.7.5.19 SNMP_TRAP_INFO Structure
C
typedef struct tSNMP_TRAP_INFO {
uint8_t Size;
struct {
uint8_t communityLen;
char community[TRAP_COMMUNITY_MAX_LEN];
IPV4_ADDR IPAddress;
struct {
5.8 TCP/IP Stack Library Help MPLAB Harmony Help SNMP TCP/IP Stack Library
5-3850
unsigned int bEnabled : 1;
} Flags;
} table[TRAP_TABLE_SIZE];
} SNMP_TRAP_INFO;
Description
This is type SNMP_TRAP_INFO.
Members
Members Description
uint8_t communityLen; Community name length
char
community[TRAP_COMMUNITY_MAX_LEN];
Community name array
IPV4_ADDR IPAddress; IP address to which trap to be sent
unsigned int bEnabled : 1; Trap enabled flag
5.8.22.7.5.20 SNMP_TRAP_IP_ADDRESS_TYPE Enumeration
C
typedef enum {
IPV4_SNMP_TRAP = 1,
IPV6_SNMP_TRAP
} SNMP_TRAP_IP_ADDRESS_TYPE;
Description
This is type SNMP_TRAP_IP_ADDRESS_TYPE.
5.8.22.7.5.21 SNMP_VAL Union
C
typedef union {
uint32_t dword;
uint16_t word;
uint8_t byte;
uint8_t v[sizeof(uint32_t)];
} SNMP_VAL;
Description
This is type SNMP_VAL.
Members
Members Description
uint32_t dword; double word value
uint16_t word; word value
uint8_t byte; byte value
uint8_t v[sizeof(uint32_t)]; byte array
5.8.22.7.5.22 TCPIP_SNMP_DCPT Structure
C
typedef struct {
TCPIP_SNMP_SM sm;
UDP_SOCKET skt;
bool readFromSnmpBuf;
IPV6_HANDLE snmpIPV6Handler;
5.8 TCP/IP Stack Library Help MPLAB Harmony Help SNMP TCP/IP Stack Library
5-3851
IPV6_EVENT_TYPE ipv6EventType;
} TCPIP_SNMP_DCPT;
Description
TCPIP_STACK_USE_IPV6
Members
Members Description
TCPIP_SNMP_SM sm; current status
UDP_SOCKET skt; associated socket
5.8.22.7.5.23 TCPIP_SNMP_SM Enumeration
C
typedef enum {
SNMP_HOME = 0,
SNMP_LISTEN,
SNMP_PROCESS,
SNMP_PACKET_DISCARD
} TCPIP_SNMP_SM;
Description
This is type TCPIP_SNMP_SM.
5.8.22.7.5.24 VENDOR_SPECIFIC_TRAP_NOTIFICATION_TYPE Enumeration
C
typedef enum {
VENDOR_TRAP_DEFAULT = 0x0,
BUTTON_PUSH_EVENT = 0x1,
POT_READING_MORE_512 = 0x2
} VENDOR_SPECIFIC_TRAP_NOTIFICATION_TYPE;
Description
This is type VENDOR_SPECIFIC_TRAP_NOTIFICATION_TYPE.
5.8.22.7.6 SNMPv3 Data Types and Constants
5.8.22.7.6.1 SNMPV3_PROCESSING_MEM_INFO_PTRS Structure
C
typedef struct {
SNMPV3_STACK_DCPT_STUB * snmpv3StkProcessingDynMemStubPtr;
const void* snmpHeapMemHandler;
} SNMPV3_PROCESSING_MEM_INFO_PTRS;
Description
SNMPv3 Processing Memory Pointers
5.8.22.7.6.2 SNMPV3_STACK_DCPT_STUB Structure
C
typedef struct {
uint16_t UserInfoDataBaseIndx;
uint8_t SnmpEngineID[32];
5.8 TCP/IP Stack Library Help MPLAB Harmony Help SNMP TCP/IP Stack Library
5-3852
uint8_t SnmpEngnIDLength;
uint16_t SnmpMsgBufSeekPos;
uint16_t ScopedPduDataPos;
uint32_t SnmpEngineTimeOffset;
uint32_t SnmpEngineBoots;
TCPIP_UINT16_VAL UsmStatsEngineID;
TCPIP_UINT32_VAL AuthoritativeSnmpEngineBoots;
TCPIP_UINT32_VAL AuthoritativeSnmpEngnTime;
TCPIP_UINT32_VAL IncmngSnmpPduMsgID;
TCPIP_UINT32_VAL SnmpEngineTime;
TCPIP_UINT32_VAL SnmpEngnMaxMsgSize;
SNMPV3_REQUEST_WHOLEMSG InPduWholeMsgBuf;
SNMPV3_RESPONSE_WHOLEMSG OUTPduWholeMsgBuf;
SNMPV3_RESPONSE_WHOLEMSG TrapOUTPduWholeMsgBuf;
snmpV3TrapConfigDataBase Snmpv3TrapConfigData[SNMPV3_USM_MAX_USER];
SNMPV3MSGDATA ScopedPduRequstBuf;
SNMPV3MSGDATA ScopedPduRespnsBuf;
SNMPV3MSGDATA PduHeaderBuf;
SNMPV3MSGDATA TrapMsgHeaderBuf;
SNMPV3MSGDATA TrapScopdPduRespnsBuf;
dispatcherProcessPdu incomingPdu;
uint8_t SnmpSecurityLevel;
uint8_t SnmpRespnsSecrtyFlg;
uint8_t SnmpInMsgAuthParmStrng[12+1];
uint8_t SnmpInMsgAuthParamLen;
uint8_t snmpInMsgPrvParamStrng[8+1];
uint8_t SnmpInMsgPrivParmLen;
uint8_t SnmpOutMsgAuthParaStrng[12+1];
uint8_t SnmpOutMsgAuthParmLen;
uint8_t SnmpOutMsgPrvParmStrng[8+1];
uint8_t SnmpOutMsgPrivParmLen;
uint32_t SnmpEngnSecurityModel;
uint32_t SnmpEngnMsgProcessModel;
SecuritySysProcessIncomingMsg SecurtyPrimtvesOfIncmngPdu;
snmpV3EngnUserDataBase UserInfoDataBase[SNMPV3_USM_MAX_USER];
} SNMPV3_STACK_DCPT_STUB;
Description
SNMPv3 Descriptor Structure Typedef
Members
Members Description
uint8_t SnmpEngineID[32]; Reserving 32 bytes for the snmpEngineID as the octet string length can
vary form 5 to 32
uint32_t SnmpEngineBoots; The number of times that the SNMP engine has (re-)initialized itself
since snmpEngineID was last configured.
TCPIP_UINT32_VAL SnmpEngineTime; The number of seconds since the value of the SnmpEngineBoots
object last changed
snmpV3TrapConfigDataBase
Snmpv3TrapConfigData[SNMPV3_USM_MAX_USER];
snmv3 global database for trap table
uint32_t SnmpEngnSecurityModel; Maximum range (2^31-1), RFC3411
uint32_t SnmpEngnMsgProcessModel; Maximum range (2^31-1), RFC3411
5.8.22.8 Files
Files
Name Description
snmp.h
5.8 TCP/IP Stack Library Help MPLAB Harmony Help SNMP TCP/IP Stack Library
5-3853
snmp_config.h SNMP configuration file
snmpv3.h This is file snmpv3.h.
snmpv3_config.h SNMPv3 configuration file
Description
5.8.22.8.1 snmp.h
SNMP Defs for Microchip TCP/IP Stack
Enumerations
Name Description
GENERIC_TRAP_NOTIFICATION_TYPE This is type GENERIC_TRAP_NOTIFICATION_TYPE.
SNMP_COMMUNITY_TYPE This is type SNMP_COMMUNITY_TYPE.
SNMP_TRAP_IP_ADDRESS_TYPE This is type SNMP_TRAP_IP_ADDRESS_TYPE.
TCPIP_SNMP_SM This is type TCPIP_SNMP_SM.
VENDOR_SPECIFIC_TRAP_NOTIFICATION_TYPE This is type
VENDOR_SPECIFIC_TRAP_NOTIFICATION_TYPE.
Functions
Name Description
SNMPGetExactIndex To search for exact index node in case of a Sequence variable.
SNMPGetNextIndex To search for next index node in case of a Sequence variable.
SNMPGetVar Used to Get/collect OID variable information.
SNMPIsValidSetLen Validates the set variable data length to data type.
SNMPSendTrap Prepare, validate remote node which will receive trap and send trap
pdu.
SNMPSetVar This routine Set the mib variable with the requested value.
SNMPValidateCommunity Validates community name for access control.
TCPIP_SNMP_ClientGetNet
TCPIP_SNMP_DataCopyToProcessBuffer Copies uint8_t data to dynamically allocated memory buffer.
TCPIP_SNMP_EventNotifyGet To Get the IPv6 DHCP event notification.
TCPIP_SNMP_Notify Creates and Sends TRAP pdu.
TCPIP_SNMP_NotifyIsReady Resolves given remoteHost IP address into MAC address.
TCPIP_SNMP_NotifyPrepare Collects trap notification info and send ARP to remote host.
TCPIP_SNMP_PacketProcStubPtrsGet Get SNMP packet processing memory pointer.
TCPIP_SNMP_ProcessBufferDataGet Reads uint8_t data from dynamically allocated memory buffer.
TCPIP_SNMP_ReadCommunityGet Get the readCommunity String with Snmp index.
TCPIP_SNMP_TrapTimeGet Get SNMP Trap UDP client open socket timeout.
TCPIP_SNMP_WriteCommunityGet Get the writeCommunity String with Snmp index.
Macros
Name Description
SNMP_END_OF_VAR This is macro SNMP_END_OF_VAR.
5.8 TCP/IP Stack Library Help MPLAB Harmony Help SNMP TCP/IP Stack Library
5-3854
SNMP_H FileName: SNMP.h Copyright © 2012 released Microchip Technology Inc. All
rights reserved.
Microchip licenses to you the right to use, modify, copy and distribute Software
only when embedded on a Microchip microcontroller or digital signal controller that
is integrated into your product or third party product (pursuant to the sublicense
terms in the accompanying license agreement).
You should refer to the license agreement accompanying this Software for
additional information regarding your rights and obligations.
SOFTWARE AND DOCUMENTATION ARE PROVIDED “AS IS” WITHOUT
WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING
WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND... more
SNMP_INDEX_INVALID This is macro SNMP_INDEX_INVALID.
SNMP_START_OF_VAR
SNMP_V1
SNMP_V2C This is macro SNMP_V2C.
SNMP_V3 This is macro SNMP_V3.
Structures
Name Description
tIPV6_SNMP_TRAP_INFO This is type IPV6_SNMP_TRAP_INFO.
tSNMP_TRAP_INFO This is type SNMP_TRAP_INFO.
IPV6_SNMP_TRAP_INFO This is type IPV6_SNMP_TRAP_INFO.
SNMP_BUFFER_DATA SNMPv1/v2c
SNMP_MODULE_CONFIG This is type SNMP_MODULE_CONFIG.
SNMP_NON_MIB_RECD_INFO This is type SNMP_NON_MIB_RECD_INFO.
SNMP_NOTIFY_INFO // the only if that runs SNMP
SNMP_PROCESSING_MEM_INFO_PTRS This is type SNMP_PROCESSING_MEM_INFO_PTRS.
SNMP_STACK_DCPT_STUB
SNMP_TRAP_INFO This is type SNMP_TRAP_INFO.
TCPIP_SNMP_DCPT TCPIP_STACK_USE_IPV6
Types
Name Description
SNMP_ID This is the SNMP OID variable id. This id is assigned via MIB file. Only dynamic
and AgentID variables can contian ID. MIB2BIB utility enforces this rules when BIB
was generated. typedef int SNMP_ID;
SNMP_INDEX This is type SNMP_INDEX.
Unions
Name Description
SNMP_VAL This is type SNMP_VAL.
5.8.22.8.2 snmp_config.h
Simple Network Managment Protocol (SNMP) Configuration file
This file contains the SNMP module configuration options
5.8 TCP/IP Stack Library Help MPLAB Harmony Help SNMP TCP/IP Stack Library
5-3855
Macros
Name Description
END_OF_SNMP_READ_COMMUNITIES ??
END_OF_SNMP_WRITE_COMMUNITIES ??
MY_DEFAULT_SNMP_IF For multi-homed hosts, the default SNMP interface
NOTIFY_COMMUNITY_LEN Length of Community name array
OID_MAX_LEN Change this to match your OID string length.
SNMP_BIB_FILE_NAME Name of the bib file for snmp
SNMP_COMMUNITY_MAX_LEN This is the maximum length for community string.
Application must ensure that this length is observed. SNMP
module adds one byte extra after
SNMP_COMMUNITY_MAX_LEN for adding '0' NULL
character.
SNMP_MAX_COMMUNITY_SUPPORT Specifying more strings than
SNMP_MAX_COMMUNITY_SUPPORT will result in the
later strings being ignored (but still wasting program
memory). Specifying fewer strings is legal, as long as at
least one is present.
SNMP_MAX_MSG_SIZE SNMP MIN and MAX message 484 bytes in size. As per
RFC 3411 snmpEngineMaxMessageSize and RFC 1157 (
section 4- protocol specification ) and implementation
supports more than 484 whenever feasible.
SNMP_MAX_NON_REC_ID_OID Update the Non record id OID value which is part of
CustomSnmpDemo.c file
SNMP_READ_COMMUNITIES Default SNMPv2C community names. These can be
overridden at run time if alternate strings are present in
external EEPROM or Flash (actual strings coould be stored
by the TCPIP storage service. These strings are case
sensitive. An empty string means disabled (not matchable).
For application security, these default community names
should not be used, but should all be disabled to force the
end user to select unique community names. These defaults
are provided only to make it easier to start development.
Specifying more strings than
SNMP_MAX_COMMUNITY_SUPPORT will result in the
later strings being ignored (but still wasting program
memory). Specifying... more
SNMP_TRAP_COMMUNITY_MAX_LEN_MEM_USE This macro will be used to avoid SNMP OID memory buffer
corruption
SNMP_WRITE_COMMUNITIES Default SNMPv2C community names. See
SNMP_READ_COMMUNITIES for more information.
TRAP_COMMUNITY_MAX_LEN Maximum length of community name table
TRAP_TABLE_SIZE This table maintains list of intereseted receivers who should
receive notifications when some interesting event occurs.
Structures
Name Description
SNMP_NET_CONFIG SNMP Network Configuration structure typedef
5.8.22.8.3 snmpv3.h
This is file snmpv3.h.
5.8 TCP/IP Stack Library Help MPLAB Harmony Help SNMP TCP/IP Stack Library
5-3856
Functions
Name Description
SNMPv3ComputeHMACIpadOpadForAuthLoclzedKey Compute HMAC inner and outer pad for
authorization localized key.
SNMPv3USMAuthPrivPswdLocalization Convert Auth and Priv password to the localized
Key using SNMPEngineID.
TCPIP_SNMPv3_CmprTrapSecNameAndSecLvlWithUSMDb Routine to find the index of the user name in the
user data base table.
TCPIP_SNMPv3_Notify Creates and Sends SNMPv3 TRAP pdu.
TCPIP_SNMPV3_PacketProcStubPtrsGet Get SNMPv3 packet processing memory pointer.
Structures
Name Description
SNMPV3_PROCESSING_MEM_INFO_PTRS SNMPv3 Processing Memory Pointers
SNMPV3_STACK_DCPT_STUB SNMPv3 Descriptor Structure Typedef
5.8.22.8.4 snmpv3_config.h
Simple Network Managment Protocol (SNMPv3) Configuration file
This file contains the SNMPv3 module configuration options
Macros
Name Description
AUTH_LOCALIZED_PASSWORD_KEY_LEN SNMPv3 Authentication Localized passwed
key lenegth size
PRIV_LOCALIZED_PASSWORD_KEY_LEN SNMPv3 Privacy Pasword key length size
SNMPV3_AUTH_LOCALIZED_PASSWORD_KEY_LEN_MEM_USE SNMPv3 authentication localized Key length
for memory validation
SNMPV3_PRIV_LOCALIZED_PASSWORD_KEY_LEN_MEM_USE SNMPv3 privacy key length size for memory
validation
SNMPV3_TRAP_MSG_PROCESS_MODEL_DB This is macro
SNMPV3_TRAP_MSG_PROCESS_MODEL
_DB.
SNMPV3_TRAP_SECURITY_LEVEL_DB This is macro
SNMPV3_TRAP_SECURITY_LEVEL_DB.
SNMPV3_TRAP_SECURITY_MODEL_TYPE_DB This is macro
SNMPV3_TRAP_SECURITY_MODEL_TYPE
_DB.
SNMPV3_TRAP_USER_SECURITY_NAME_DB This is macro
SNMPV3_TRAP_USER_SECURITY_NAME
_DB.
SNMPV3_USER_AUTH_PASSWD_DB This is macro
SNMPV3_USER_AUTH_PASSWD_DB.
SNMPV3_USER_AUTH_TYPE_DB This is macro
SNMPV3_USER_AUTH_TYPE_DB.
SNMPV3_USER_PRIV_PASSWD_DB This is macro
SNMPV3_USER_PRIV_PASSWD_DB.
SNMPV3_USER_PRIV_TYPE_DB This is macro
SNMPV3_USER_PRIV_TYPE_DB.
5.8 TCP/IP Stack Library Help MPLAB Harmony Help SNMP TCP/IP Stack Library
5-3857
SNMPV3_USER_SECURITY_NAME_DB This is macro
SNMPV3_USER_SECURITY_NAME_DB.
SNMPV3_USER_SECURITY_NAME_LEN_MEM_USE User security name length for memory
validation
SNMPV3_USM_MAX_USER Client configuration options
USER_SECURITY_NAME_LEN SNMPv3 User Security Name length
5.8.23 SNTP TCP/IP Stack Library
5.8.23.1 Introduction
Simple Network Time Protocol (SNTP) TCP/IP Stack Library
for
Microchip Microcontrollers
This library provides the API of the SNTP TCP/IP Module that is available on the Microchip family of microcontrollers with a
convenient C language interface. It is a module that belongs to the TCP/IP stack.
Description
The SNTP module implements the Simple Network Time Protocol. The module (by default) updates its internal time every 10
minutes using a pool of public global time servers. It then calculates reference times on any call to SNTPGetUTCSeconds (see
page 458) using the internal Tick timer module.
The SNTP module is good for providing absolute time stamps. However, it should not be relied upon for measuring time
differences (especially small differences). The pool of public time servers is implemented using round-robin DNS, so each
update will come from a different server. Differing network delays and the fact that these servers are not verified implies that this
time could be non-linear. While it is deemed reliable, it is not guaranteed to be accurate.
The Tick module provides much better accuracy (since it is driven by a hardware clock) and resolution, and should be used for
measuring timeouts and other internal requirements.
Developers can change the value of NTP_SERVER ( see page 462) if they wish to always point to a preferred time server, or to
specify a region when accessing time servers. The default is to use the global pool.
5.8.23.2 Release Notes
MPLAB Harmony Version: v0.70b SNTP TCP/IP Stack Library Version : 1.0 Release Date: 18Nov2013
New This Release:
This is the first release of the library. The interface can change in the beta and\or 1.0 release.
Known Issues:
5.8 TCP/IP Stack Library Help MPLAB Harmony Help SNTP TCP/IP Stack Library
5-3858
Nothing to report in this release.
5.8.23.3 SW License Agreement
(c) 2013 Microchip Technology Inc.
Microchip licenses this software to you solely for use with Microchip products. The software is owned by Microchip and its
licensors, and is protected under applicable copyright laws. All rights reserved.
SOFTWARE IS PROVIDED "AS IS" MICROCHIP EXPRESSLY DISCLAIMS ANY WARRANTY OF ANY KIND, WHETHER
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. IN NO EVENT SHALL MICROCHIP BE LIABLE FOR
ANY INCIDENTAL, SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, HARM TO
YOUR EQUIPMENT, COST OF PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY OR SERVICES, ANY CLAIMS
BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), ANY CLAIMS FOR INDEMNITY OR
CONTRIBUTION, OR OTHER SIMILAR COSTS.
To the fullest extent allowed by law, Microchip and its licensors liability shall not exceed the amount of fees, if any, that you have
paid directly to Microchip to use this software.
MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE TERMS.
5.8.23.4 Using the Library
This topic describes the basic architecture of the SNTP TCP/IP Stack Library and provides information and examples on how to
use it.
Interface Header File: sntp.h
The interface to the SNTP TCP/IP Stack library is defined in the "sntp.h" header file. This file is included by the "tcpip.h" file. Any
C language source (.c) file that uses the SNTP TCP/IP Stack library should include "tcpip.h".
Library File:
The SNTP TCP/IP Stack library archive (.a) file installed with MPLAB Harmony.
Please refer to the MPLAB Harmony Overview for how the TCP/IP Stack interacts with the framework.
5.8.23.4.1 Abstraction Model
This library provides the API of the SNTP TCP/IP Module that is available on the Microchip family of microcontrollers with a
convenient C language interface. It is a module that belongs to the TCP/IP stack.
Description
SNTP Software Abstraction Block Diagram
Note: This image was not available at time of release and will be added in a future release of MPLAB Harmony.
5.8.23.4.2 Library Overview
The library interface routines are divided into various sub-sections, each of sub-section addresses one of the blocks or the
overall operation of the SNTP module.
5.8 TCP/IP Stack Library Help MPLAB Harmony Help SNTP TCP/IP Stack Library
5-3859
Library Interface Section Description
Functions Routines for configuring SNTP
Data Types and Constants This section provides various definitions describing this API
5.8.23.5 Configuring the Library
Macros
Name Description
NTP_DEFAULT_CONNECTION_TYPE The default connection type to use: IPv4/IPv6
NTP_DEFAULT_IF for multi-homed hosts, the default SNTP interface
NTP_EPOCH Reference Epoch to use. (default: 01-Jan-1970 00:00:00)
NTP_FAST_QUERY_INTERVAL Defines how long to wait to retry an update after a failure, seconds.
Updates may take up to 6 seconds to fail, so this 14 second delay is
actually only an 8-second retry.
NTP_MAX_RETRIES Number of retries to connect to the server
NTP_MAX_STRATUM The maximum acceptable NTP stratum number Should be less than 16
(unsynchronized server)
NTP_QUERY_INTERVAL Defines how frequently to resynchronize the date/time, seconds (default:
10 minutes)
NTP_REPLY_TIMEOUT Defines how long to wait before assuming the query has failed, seconds
NTP_SERVER These are normally available network time servers. The actual IP returned
from the pool will vary every minute so as to spread the load around
stratum 1 timeservers. For best accuracy and network overhead you
should locate the pool server closest to your geography, but it will still
work if you use the global pool.ntp.org address or choose the wrong one
or ship your embedded device to another geography.
NTP_SERVER_PORT Port for contacting NTP servers
NTP_TIME_STAMP_TMO elapsed time that qualifies a time stamp as stale normally it should be
correlated with NTP_QUERY_INTERVAL
NTP_VERSION The default NTP version to use (3 or 4)
Description
The configuration of the SNTP TCP/IP Stack Library is based on the file tcpip_config.h
This header file contains the configuration selection for the SNTP TCP/IP Stack Library. Based on the selections made, the
SNTP TCP/IP Stack Library will support or not support selected features. These configuration settings will apply to all instances
of the SNTP TCP/IP Stack Library.
This header can be placed anywhere; however, the path of this header needs to be present in the include search path for a
successful build. Refer to the Applications Overview section for more details.
5.8.23.5.1 NTP_DEFAULT_CONNECTION_TYPE Macro
C
#define NTP_DEFAULT_CONNECTION_TYPE (IP_ADDRESS_TYPE_IPV4)
Description
The default connection type to use: IPv4/IPv6
5.8 TCP/IP Stack Library Help MPLAB Harmony Help SNTP TCP/IP Stack Library
5-3860
5.8.23.5.2 NTP_DEFAULT_IF Macro
C
#define NTP_DEFAULT_IF "PIC32INT"
Description
for multi-homed hosts, the default SNTP interface
5.8.23.5.3 NTP_EPOCH Macro
C
#define NTP_EPOCH (86400ul * (365ul * 70ul + 17ul))
Description
Reference Epoch to use. (default: 01-Jan-1970 00:00:00)
5.8.23.5.4 NTP_FAST_QUERY_INTERVAL Macro
C
#define NTP_FAST_QUERY_INTERVAL (14ul)
Description
Defines how long to wait to retry an update after a failure, seconds. Updates may take up to 6 seconds to fail, so this 14 second
delay is actually only an 8-second retry.
5.8.23.5.5 NTP_MAX_RETRIES Macro
C
#define NTP_MAX_RETRIES (3)
Description
Number of retries to connect to the server
5.8.23.5.6 NTP_MAX_STRATUM Macro
C
#define NTP_MAX_STRATUM (15)
Description
The maximum acceptable NTP stratum number Should be less than 16 (unsynchronized server)
5.8.23.5.7 NTP_QUERY_INTERVAL Macro
C
#define NTP_QUERY_INTERVAL (10ul*60ul)
Description
Defines how frequently to resynchronize the date/time, seconds (default: 10 minutes)
5.8 TCP/IP Stack Library Help MPLAB Harmony Help SNTP TCP/IP Stack Library
5-3861
5.8.23.5.8 NTP_REPLY_TIMEOUT Macro
C
#define NTP_REPLY_TIMEOUT (6ul)
Description
Defines how long to wait before assuming the query has failed, seconds
5.8.23.5.9 NTP_SERVER Macro
C
#define NTP_SERVER "pool.ntp.org"
Description
These are normally available network time servers. The actual IP returned from the pool will vary every minute so as to spread
the load around stratum 1 timeservers. For best accuracy and network overhead you should locate the pool server closest to
your geography, but it will still work if you use the global pool.ntp.org address or choose the wrong one or ship your embedded
device to another geography.
5.8.23.5.10 NTP_SERVER_PORT Macro
C
#define NTP_SERVER_PORT (123ul)
Description
Port for contacting NTP servers
5.8.23.5.11 NTP_TIME_STAMP_TMO Macro
C
#define NTP_TIME_STAMP_TMO (11 * 60)
Description
elapsed time that qualifies a time stamp as stale normally it should be correlated with NTP_QUERY_INTERVAL
5.8.23.5.12 NTP_VERSION Macro
C
#define NTP_VERSION (4)
Description
The default NTP version to use (3 or 4)
5.8.23.6 Building the Library
This section list the files that are available in the \src of the SNTP driver. It lists which files need to be included in the build based
on either a hardware feature present on the board or configuration option selected by the system.
5.8 TCP/IP Stack Library Help MPLAB Harmony Help SNTP TCP/IP Stack Library
5-3862
5.8.23.7 Library Interface
Data Types and Constants
Name Description
SNTP_MODULE_CONFIG Placeholder for SNTP Module Configuration
SNTP_RESULT Provides a list of possible results for the SNTP module.
Functions
Name Description
TCPIP_SNTP_ConnectionInitiate Forces a connection to the NTP server
TCPIP_SNTP_ConnectionParamSet Sets the current SNTP connection parameters
TCPIP_SNTP_LastErrorGet Gets the last error code set in the NTP server
TCPIP_SNTP_TimeStampGet Gets the last valid timestamp obtained from an NTP server
TCPIP_SNTP_UTCSecondsGet Obtains the current time from the SNTP module.
Description
This section describes the Application Programming Interface (API) functions of the SNTP TCP/IP Stack.
Refer to each section for a detailed description.
5.8.23.7.1 Functions
5.8.23.7.1.1 TCPIP_SNTP_ConnectionInitiate Function
C
SNTP_RESULT TCPIP_SNTP_ConnectionInitiate();
Description
This function will start a conenction to the NTP server
Preconditions
TCP/IP Stack should have been initialized
Returns
SNTP_RES_OK - if the call succeded SNTP_RES_BUSY error code if the connection could not have been started
Remarks
None
5.8.23.7.1.2 TCPIP_SNTP_ConnectionParamSet Function
C
SNTP_RESULT TCPIP_SNTP_ConnectionParamSet(
TCPIP_NET_HANDLE netH,
IP_ADDRESS_TYPE ntpConnType
);
Description
This function sets the parameters for the next SNTP connections.
5.8 TCP/IP Stack Library Help MPLAB Harmony Help SNTP TCP/IP Stack Library
5-3863
Preconditions
TCP/IP Stack should have been initialized
Parameters
Parameters Description
netH new interface to use as default SNTP interface if 0, the current interface is not
changed
ntpConnType type of conenction to make: IPv4 or IPv6 if IP_ADDRESS_TYPE_ANY, the current
setting is not changed
Returns
SNTP_RES_OK - if the call succeded SNTP_RESULT error code otherwise
Remarks
None
5.8.23.7.1.3 TCPIP_SNTP_LastErrorGet Function
C
SNTP_RESULT TCPIP_SNTP_LastErrorGet();
Description
This function returns the last NTP error code and clears the current error code
Preconditions
TCP/IP Stack should have been initialized
Returns
the last error code encountered by the NTP module
Remarks
None
5.8.23.7.1.4 TCPIP_SNTP_TimeStampGet Function
C
SNTP_RESULT TCPIP_SNTP_TimeStampGet(
uint64_t* pTStamp,
SYS_TICK* pLastUpdate
);
Description
This function gets the last valid timestamp obtained from an NTP server
Preconditions
TCP/IP Stack should have been initialized
Parameters
Parameters Description
pTStamp pointer to a 64 bit buffer to store the last NTP timestamp could be NULL if the
timestamp not needed
pLastUpdate pointer to store the last time stamp update tick could be NULL if the update time
not needed
5.8 TCP/IP Stack Library Help MPLAB Harmony Help SNTP TCP/IP Stack Library
5-3864
Returns
SNTP_RES_OK - if the call succeded SNTP_RES_TSTAMP_STALE error code if there's no recent time stamp
Remarks
None
5.8.23.7.1.5 TCPIP_SNTP_UTCSecondsGet Function
C
uint32_t TCPIP_SNTP_UTCSecondsGet();
Description
This function obtains the current time as reported by the SNTP module. Use this value for absolute time stamping. The value
returned is (by default) the number of seconds since 01-Jan-1970 00:00:00.
Preconditions
TCP/IP Stack should have been initialized
Returns
The number of seconds since the Epoch. (Default 01-Jan-1970 00:00:00)
Remarks
Do not use this function for time difference measurements. The Tick module is more appropriate for those requirements.
5.8.23.7.2 Data Types and Constants
5.8.23.7.2.1 SNTP_MODULE_CONFIG Structure
C
typedef struct {
} SNTP_MODULE_CONFIG;
Description
Placeholder for SNTP Module Configuration
5.8.23.7.2.2 SNTP_RESULT Enumeration
C
typedef enum {
SNTP_RES_OK,
SNTP_RES_PROGRESS,
SNTP_RES_BUSY = -1,
SNTP_RES_TSTAMP_STALE = -2,
SNTP_RES_SKT_ERR = -3,
SNTP_RES_NTP_SERVER_TMO = -4,
SNTP_RES_NTP_VERSION_ERR = -5,
SNTP_RES_NTP_TSTAMP_ERR = -6,
SNTP_RES_NTP_SYNC_ERR = -7,
SNTP_RES_NTP_KOD_ERR = -8,
SNTP_RES_NTP_DNS_ERR = -9
} SNTP_RESULT;
Description
SNTP_RESULT Enumeration
5.8 TCP/IP Stack Library Help MPLAB Harmony Help SNTP TCP/IP Stack Library
5-3865
Provides a list of possible SNTP results.
Members
Members Description
SNTP_RES_OK the operation was successful
SNTP_RES_PROGRESS an NTP operation is in progress
SNTP_RES_BUSY = -1 module is busy
SNTP_RES_TSTAMP_STALE = -2 timestamp is stale, there's no recent timestamp
SNTP_RES_SKT_ERR = -3 NTP socket could not be opened
SNTP_RES_NTP_SERVER_TMO = -4 NTP server could not be accessed
SNTP_RES_NTP_VERSION_ERR = -5 wrong NTP version received
SNTP_RES_NTP_TSTAMP_ERR = -6 wrong NTP time stamp received
SNTP_RES_NTP_SYNC_ERR = -7 NTP time synchronization error
SNTP_RES_NTP_KOD_ERR = -8 an NTP KissOfDeath code has been received
SNTP_RES_NTP_DNS_ERR = -9 an NTP DNS error
Remarks
None
5.8.23.8 Files
Files
Name Description
sntp.h
sntp_config.h SNTP configuration file
Description
5.8.23.8.1 sntp.h
SNTP Client Module Header
Enumerations
Name Description
SNTP_RESULT Provides a list of possible results for the SNTP module.
Functions
Name Description
TCPIP_SNTP_ConnectionInitiate Forces a connection to the NTP server
TCPIP_SNTP_ConnectionParamSet Sets the current SNTP connection parameters
TCPIP_SNTP_LastErrorGet Gets the last error code set in the NTP server
TCPIP_SNTP_TimeStampGet Gets the last valid timestamp obtained from an NTP server
TCPIP_SNTP_UTCSecondsGet Obtains the current time from the SNTP module.
5.8 TCP/IP Stack Library Help MPLAB Harmony Help SNTP TCP/IP Stack Library
5-3866
Structures
Name Description
SNTP_MODULE_CONFIG Placeholder for SNTP Module Configuration
5.8.23.8.2 sntp_config.h
Network Time Protocol (SNTP) Configuration file
This file contains the SNTP module configuration options
Macros
Name Description
NTP_DEFAULT_CONNECTION_TYPE The default connection type to use: IPv4/IPv6
NTP_DEFAULT_IF for multi-homed hosts, the default SNTP interface
NTP_EPOCH Reference Epoch to use. (default: 01-Jan-1970 00:00:00)
NTP_FAST_QUERY_INTERVAL Defines how long to wait to retry an update after a failure, seconds.
Updates may take up to 6 seconds to fail, so this 14 second delay is
actually only an 8-second retry.
NTP_MAX_RETRIES Number of retries to connect to the server
NTP_MAX_STRATUM The maximum acceptable NTP stratum number Should be less than 16
(unsynchronized server)
NTP_QUERY_INTERVAL Defines how frequently to resynchronize the date/time, seconds (default:
10 minutes)
NTP_REPLY_TIMEOUT Defines how long to wait before assuming the query has failed, seconds
NTP_SERVER These are normally available network time servers. The actual IP returned
from the pool will vary every minute so as to spread the load around
stratum 1 timeservers. For best accuracy and network overhead you
should locate the pool server closest to your geography, but it will still
work if you use the global pool.ntp.org address or choose the wrong one
or ship your embedded device to another geography.
NTP_SERVER_PORT Port for contacting NTP servers
NTP_TIME_STAMP_TMO elapsed time that qualifies a time stamp as stale normally it should be
correlated with NTP_QUERY_INTERVAL
NTP_VERSION The default NTP version to use (3 or 4)
5.8.24 SSL TCP/IP Stack Library
5.8.24.1 Introduction
Secure Sockets Layer (SSL) TCP/IP Stack Library
for
Microchip Microcontrollers
This library provides the API of the SSL TCP/IP Module that is available on the Microchip family of microcontrollers with a
convenient C language interface. It is a module that belongs to the TCP/IP stack.
5.8 TCP/IP Stack Library Help MPLAB Harmony Help SSL TCP/IP Stack Library
5-3867
Description
The SSL module adds encryption support to the TCP layer by implementing the SSLv3 protocol. This protocol is the standard for
secure communications across the Internet, and prevents snooping or tampering of data as it travels across an untrusted
network. This implementation of SSL supports the RSA asymmetric encryption protocol and the ARCFOUR symmetric
encryption protocol.
To comply with US Export Control restrictions, the encryption portion of the SSL module must be purchased separately from
Microchip. The library of Data Encryption Routines (SW300052) is available for a nominal fee from microchipDirect.
Newer versions of the TCP/IP Stack include modifications to the SSL module to enable an expanded range of RSA key lengths.
This will allow the TCP/IP Stack to support a wider range of SSL client/servers. Because of these changes, you may need to
manually modify your copy of RSA.c or obtain an updated copy from microchipDirect. The following table enumerates which
cryptographic add-on is required for which stack version.
5.8.24.2 Release Notes
MPLAB Harmony Version: v0.70b SSL TCP/IP Stack Library Version : 1.0 Release Date: 18Nov2013
New This Release:
This is the first release of the library. The interface can change in the beta and\or 1.0 release.
Known Issues:
Nothing to report in this release.
5.8.24.3 SW License Agreement
(c) 2013 Microchip Technology Inc.
Microchip licenses this software to you solely for use with Microchip products. The software is owned by Microchip and its
licensors, and is protected under applicable copyright laws. All rights reserved.
SOFTWARE IS PROVIDED "AS IS" MICROCHIP EXPRESSLY DISCLAIMS ANY WARRANTY OF ANY KIND, WHETHER
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. IN NO EVENT SHALL MICROCHIP BE LIABLE FOR
ANY INCIDENTAL, SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, HARM TO
YOUR EQUIPMENT, COST OF PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY OR SERVICES, ANY CLAIMS
BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), ANY CLAIMS FOR INDEMNITY OR
CONTRIBUTION, OR OTHER SIMILAR COSTS.
To the fullest extent allowed by law, Microchip and its licensors liability shall not exceed the amount of fees, if any, that you have
paid directly to Microchip to use this software.
MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE TERMS.
5.8.24.4 Using the Library
This topic describes the basic architecture of the SSL TCP/IP Stack Library and provides information and examples on how to
use it.
Interface Header File: ssl.h
5.8 TCP/IP Stack Library Help MPLAB Harmony Help SSL TCP/IP Stack Library
5-3868
The interface to the SSL TCP/IP Stack library is defined in the "ssl.h" header file. This file is included by the "tcpip.h" file. Any C
language source (.c) file that uses the SSL TCP/IP Stack library should include "tcpip.h".
Library File:
The SSL TCP/IP Stack library archive (.a) file installed with MPLAB Harmony.
Please refer to the MPLAB Harmony Overview for how the TCP/IP Stack interacts with the framework.
5.8.24.4.1 Abstraction Model
This library provides the API of the SSL TCP/IP Module that is available on the Microchip family of microcontrollers with a
convenient C language interface. It is a module that belongs to the TCP/IP stack.
Description
SSL Software Abstraction Block Diagram
Note: This image was not available at time of release and will be added in a future release of MPLAB Harmony.
5.8.24.4.2 Library Overview
The library interface routines are divided into various sub-sections, each of sub-section addresses one of the blocks or the
overall operation of the SSL module.
Library Interface Section Description
Functions Routines for configuring SSL
Data Types and Constants This section provides various definitions describing this API
5.8.24.4.3 How the Library Works
5.8.24.4.3.1 SSL Client Support
An SSL client can be initiated by first opening a TCP connection, then calling TCPStartSSLSession to initiate the SSL
handshake process. The handshake uses the public key from the certificate provided by the server. Key lengths up to 1024 bits
are supported on all processors; key lengths up to 2048 bits are supported on PIC32 microcontrollers. The
SSL_RSA_CLIENT_SIZE macro in SSLClientSize.h sets the maximum certificate key length that your client should process.
#define SSL_RSA_CLIENT_SIZE (1024ul) // Size of Encryption Buffer (must be larger than key
size)
Once the handshake has started, call TCPSSLIsHandshaking ( see page 468) until it returns FALSE. This will indicate that the
handshake has completed and all traffic is now secured using 128-bit ARCFOUR encryption. If the handshake fails for any
reason, the TCP connection will automatically be terminated as required by the SSL protocol specification.
For faster performance, the SSL module caches security parameters for the most recently made connections. This allows quick
reconnections to the same node without the computational expense of another RSA handshake. By default, the two most recent
connections are cached, but this can be modified in TCPIPConfig.h.
SSL client support is already enabled for SMTP. When STACK_USE_SSL_CLIENT is defined, the SMTP module automatically
adds a field to SMTPClient ( see page 304) called UseSSL. That field controls whether or not the SMTP client module will
attempt to make an SSL connection before transmitting any data.
5.8 TCP/IP Stack Library Help MPLAB Harmony Help SSL TCP/IP Stack Library
5-3869
Note that TCP sockets using SSL may required an increase in TX/RX buffer size to support SSL. You can adjust the size of your
sockets using the TCP/IP Configuration Utility included with the stack.
5.8.24.4.3.2 SSL Server Support
To initiate an SSL server, first open a TCP socket for listening using TCPOpen ( see page 542). Then call TCPAddSSLListener (
see page 468) to listen ( see page 175) for incoming SSL connections on an alternate port. This allows a single socket to share
application-level resources and listen ( see page 175) for connections on two different ports. Connections occurring on the
originally opened port will proceed unsecured, while connections on the SSL port will first complete an SSL handshake to secure
the data.
If you application will not accept ( see page 169) unsecured traffic, simply open a non-secured socket on a free port number,
then verify that each incoming connection is secured (not on that port) by calling TCPIsSSL ( see page 469).
SSL server support is automatically enabled for HTTP2 when STACK_USE_SSL_SERVER is defined. By default, the HTTP2
module will then listen ( see page 175) for unsecured traffic on port 80 and secured connections on port 443.
This SSL server implementation supports key lengths up to 1024 bits on most PIC microcontrollers, and 2048 bits on PIC32
microcontrollers. The SSL_RSA_KEY_SIZE ( see page 471) macro in TCPIPConfig.h sets the server certificate key length.
// Bits in SSL RSA key. This parameter is used for SSL sever
// connections only.
#define SSL_RSA_KEY_SIZE (512ul)
Note that TCP sockets using SSL may required an increase in TX/RX buffer size to support SSL. You can adjust the size ofyour
sockets using the TCP/IP Configuration Utility included with the stack.
5.8.24.4.3.3 SSL Limitations
SSL was designed for desktop PCs with faster processors and significantly more resources than are available on an embedded
platform. A few compromises must be made in order to use SSL in a less resource-intensive manner.
The SSL client module does not perform any validation or verification of certificates. Doing so would require many root
certificates to be stored locally for verification, which is not feasible for memory-limited parts. This does not compromise security
once the connection has been established, but does not provide complete security against man-in-the-middle attacks. (This sort
of attack is uncommon and would be difficult to execute.)
Neither the SSL client nor the server can completely verify MACs before processing data. SSL records include a signature to
verify that messages were not modified in transit. This Message Authentication ( see page 89) Code, or MAC, is inserted after at
least every 16kB of traffic. (It usually is inserted much more frequently than that.) Without 16kB of RAM to buffer packets for
each socket, incoming data must be handed to the application layer before the MAC can be completely verified. Invalid MACs
will still cause the connection to terminate immediately, but by the time this is detected some bad data may have already
reached the application. Since the ARCFOUR cipher in use is a stream cipher, it would be difficult to exploit this in any
meaningful way. An attacker would not be able to control what data is actually modified or inserted, as doing so without
knowledge of the key would yield garbage. However, it is important to understand that incoming data is not completely verified
before being passed to the application.
5.8.24.4.4 Generating Server Certificates
The SSL certificates used by the TCP/IP Stack's SSL module are stored in the CustomSSLCert.c source file. The following
series of steps describe how to create the structures in CustomSSLCert.c using an SSL certificate.
1. Download and install the OpenSSL library. There are several third-party sites that offer SSL installers (e.g.
http://www.slproweb.com/products/Win32OpenSSL.html). Note that some distributions may not include all commands
specified by the OpenSSL documentation.
5.8 TCP/IP Stack Library Help MPLAB Harmony Help SSL TCP/IP Stack Library
5-3870
2. Open a console and change directory to the OpenSSL/bin folder.
3. If you don't have a key and certificate, you can generate them first. The following example console commands will generate a
a 512-bit key:
1. Generate the key: openssl genrsa -out 512bits.key 512
2. Generate the Certificate Signing Request (CSR). You will need to add additional information when prompted: openssl req
-new -key 512bits.key -out 512bits.csr
3. Generate the X.509 certificate if self-signing (or send the CSR to a Certificate Authority for signing): openssl x509 -req
-days 365 -in 512bits.csr -signkey 512bits.key -out 512bits.crt (note that if the -days option is not specified, the default
expiration time is 30 days)
4. For additional documentation, refer to http://www.openssl.org/docs/apps/openssl.html.
4. Parse your key file using the command: openssl.exe asn1parse -in "[directory containing your key]\512bits.key"
5. You should see a screen like this:
6. If you are not using an ENCX24J600 family device, then the last 5 integers displayed here are the SSL_P, SSL_Q, SSL_dP,
SSL_dQ, and SSL_qInv parameters, respectively. However, they are displayed here in big-endian format, and the Microchip
cryptographic library implementation requires parameters in little-endian format, so you will have to enter the parameters into
the C arrays in opposite order. For example, the INTEGER at offset 145:
145:d=1 h1=2 ;= 33 prim: INTEGER
:D777566780029FCD610200B66D89507D
915E3E5BDB6FAB0233B5DFA2E4081DF7
will be swapped in the CustomSSLCert.c file:
ROM BYTE SSL_P[] = {
0xF7 , 0x1D, 0x08, 0xE4, 0xA2, 0xDF, 0xB5, 0x33,
0x02, 0xAB, 0x6F, 0xDB, 0x5B, 0x3E, 0x5E, 0x91,
0x7D, 0x50, 0x89, 0x6D, 0xB6, 0x00, 0x02, 0x61,
0xCD, 0x9F, 0x02, 0x80, 0x67, 0x56, 0x77, 0xD7
};
7. If you are using an ENCX24J600 family device, then the second and fourth integers displayed here are the SSL_N and
SSL_D parameters, respectively. There is no need to do an endian format change for these parameters. For the example, the
expected SSL_N and SSL_D values are shown in the figure below:
8. Parse your X.509 certificate using the command: openssl.exe asn1parse -in "[directory containing your cert]\512bits.crt"
-out cert.bin
9. Open the cert.bin output file in a hex editor. For example, here is the default certificate information generated from 512bits.crt
given in the stack:
10. This information must be copied verbatim into the SSL_CERT [] array. Note that this is binary data (not a large integer) so it
does not get endian-swapped like the private key parameters.
ROM BYTE SSL_CERT[524] = {
0x30, 0x82, 0x02, 0x08, 0x30, 0x82, 0x01, 0xb2, 0x02, 0x09, 0x00, 0xa5, 0x6a, 0xea, 0x1a,
0xa9,
0x52, 0x9d, 0x1e, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01,
0x05,
0x05, 0x00, 0x30, 0x81, 0x8a, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13,
0x02,
0x55, 0x53, 0x31, 0x10, 0x30, 0x0e, 0x06, 0x03, 0x55, 0x04, 0x08, 0x13, 0x07, 0x41, 0x72,
0x69,
0x7a, 0x6f, 0x6e, 0x61, 0x31, 0x11, 0x30, 0x0f, 0x06, 0x03, 0x55, 0x04, 0x07, 0x13, 0x08,
0x43,
0x68, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x31, 0x23, 0x30, 0x21, 0x06, 0x03, 0x55, 0x04,
5.8 TCP/IP Stack Library Help MPLAB Harmony Help SSL TCP/IP Stack Library
5-3871
0x0a,
0x13, 0x1a, 0x4d, 0x69, 0x63, 0x72, 0x6f, 0x63, 0x68, 0x69, 0x70, 0x20, 0x54, 0x65, 0x63,
0x68,
0x6e, 0x6f, 0x6c, 0x6f, 0x67, 0x79, 0x2c, 0x20, 0x49, 0x6e, 0x63, 0x2e, 0x31, 0x1d, 0x30,
0x1b,
0x06, 0x03, 0x55, 0x04, 0x0b, 0x13, 0x14, 0x53, 0x53, 0x4c, 0x20, 0x44, 0x65, 0x6d, 0x6f,
0x20,
0x43, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x31, 0x12, 0x30, 0x10,
0x06,
0x03, 0x55, 0x04, 0x03, 0x13, 0x09, 0x6d, 0x63, 0x68, 0x70, 0x62, 0x6f, 0x61, 0x72, 0x64,
0x30,
0x1e, 0x17, 0x0d, 0x30, 0x37, 0x31, 0x30, 0x30, 0x39, 0x31, 0x38, 0x33, 0x37, 0x32, 0x37,
0x5a,
0x17, 0x0d, 0x31, 0x37, 0x31, 0x30, 0x30, 0x36, 0x31, 0x38, 0x33, 0x37, 0x32, 0x37, 0x5a,
0x30,
0x81, 0x8a, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x55, 0x53,
0x31,
0x10, 0x30, 0x0e, 0x06, 0x03, 0x55, 0x04, 0x08, 0x13, 0x07, 0x41, 0x72, 0x69, 0x7a, 0x6f,
0x6e,
0x61, 0x31, 0x11, 0x30, 0x0f, 0x06, 0x03, 0x55, 0x04, 0x07, 0x13, 0x08, 0x43, 0x68, 0x61,
0x6e,
0x64, 0x6c, 0x65, 0x72, 0x31, 0x23, 0x30, 0x21, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, 0x1a,
0x4d,
0x69, 0x63, 0x72, 0x6f, 0x63, 0x68, 0x69, 0x70, 0x20, 0x54, 0x65, 0x63, 0x68, 0x6e, 0x6f,
0x6c,
0x6f, 0x67, 0x79, 0x2c, 0x20, 0x49, 0x6e, 0x63, 0x2e, 0x31, 0x1d, 0x30, 0x1b, 0x06, 0x03,
0x55,
0x04, 0x0b, 0x13, 0x14, 0x53, 0x53, 0x4c, 0x20, 0x44, 0x65, 0x6d, 0x6f, 0x20, 0x43, 0x65,
0x72,
0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x31, 0x12, 0x30, 0x10, 0x06, 0x03, 0x55,
0x04,
0x03, 0x13, 0x09, 0x6d, 0x63, 0x68, 0x70, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x30, 0x5c, 0x30,
0x0d,
0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x4b,
0x00,
0x30, 0x48, 0x02, 0x41, 0x00, 0xaa, 0x96, 0xca, 0x97, 0xea, 0x27, 0xb0, 0xd7, 0xe9, 0x21,
0xd0,
0x40, 0xd4, 0x2c, 0x09, 0x5a, 0x2e, 0x3a, 0xe4, 0x12, 0x64, 0x2d, 0x4b, 0x1b, 0x92, 0xdf,
0x79,
0x68, 0x4e, 0x3c, 0x51, 0xf4, 0x43, 0x48, 0x0d, 0xf2, 0xc8, 0x50, 0x9b, 0x6e, 0xe5, 0xea,
0xfe,
0xef, 0xd9, 0x10, 0x41, 0x08, 0x14, 0xf9, 0x85, 0x49, 0xfc, 0x50, 0xd3, 0x57, 0x34, 0xdc,
0x3a,
0x0d, 0x79, 0xf8, 0xd3, 0x99, 0x02, 0x03, 0x01, 0x00, 0x01, 0x30, 0x0d, 0x06, 0x09, 0x2a,
0x86,
0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x05, 0x05, 0x00, 0x03, 0x41, 0x00, 0x18, 0x18, 0xfe,
0x8b,
0x2d, 0x0d, 0xf7, 0x0d, 0x65, 0x9d, 0x29, 0xec, 0xb3, 0x51, 0x6e, 0x3b, 0x93, 0xbb, 0x40,
0x1a,
0x0b, 0x34, 0x07, 0x63, 0x5e, 0x6a, 0x1c, 0x74, 0x59, 0xd4, 0x54, 0xd2, 0x1b, 0xf3, 0x31,
0xb7,
0x57, 0x4b, 0xa5, 0xe6, 0xe2, 0x35, 0xf7, 0xb3, 0x6a, 0x15, 0x6e, 0x3c, 0x93, 0x85, 0xb2,
0xca,
0xf5, 0x35, 0x00, 0xf4, 0x49, 0xe7, 0x00, 0x8a, 0x00, 0xd8, 0xe8, 0xcf
};
11. Update the SSL_CERT_LEN variable to contain the correct value.
5.8.24.5 Configuring the Library
Macros
Name Description
SSL_MAX_BUFFERS Max # of SSL buffers (2 per socket)
5.8 TCP/IP Stack Library Help MPLAB Harmony Help SSL TCP/IP Stack Library
5-3872
SSL_MAX_CONNECTIONS Maximum number of simultaneous connections via SSL
SSL_MAX_HASHES Max # of SSL hashes (2 per socket, plus 1 to avoid deadlock)
SSL_MAX_SESSIONS Max number of cached SSL sessions
SSL_MIN_SESSION_LIFETIME Minimum lifetime for SSL Sessions Sessions cannot be reallocated until this
much time (seconds) has elapsed
SSL_MULTIPLE_INTERFACES SSL on all interfaces in a multi-homed host set to 0 to work only on one
interface
SSL_RSA_CLIENT_SIZE Size of encryption buffer, must be at least as big as the key size
SSL_RSA_KEY_SIZE Bits in SSL RSA key. This parameter is used for SSL sever connections only.
The only valid value is 512 bits (768 and 1024 bits do not work at this time).
Note, however, that SSL client operations do currently work up to 1024 bit
RSA key length.
SSL_RSA_LIFETIME_EXTENSION Lifetime extension for RSA operations Sessions lifetime is extended by this
amount (seconds) when an RSA calculation is made
SSL_VERSION Moved from MicrochipIncludeTCPIP StackSSL.h
SSL_VERSION_HI SSL version number (high byte)
SSL_VERSION_LO SSL version number (low byte)
Description
The configuration of the SSL TCP/IP Stack Library is based on the file tcpip_config.h
This header file contains the configuration selection for the SSL TCP/IP Stack Library. Based on the selections made, the SSL
TCP/IP Stack Library will support or not support selected features. These configuration settings will apply to all instances of the
TCP/IP Stack SSL Library.
This header can be placed anywhere; however, the path of this header needs to be present in the include search path for a
successful build. Refer to the Applications Overview section for more details.
5.8.24.5.1 SSL_MAX_BUFFERS Macro
C
#define SSL_MAX_BUFFERS (4)
Description
Max # of SSL buffers (2 per socket)
5.8.24.5.2 SSL_MAX_CONNECTIONS Macro
C
#define SSL_MAX_CONNECTIONS (2)
Description
Maximum number of simultaneous connections via SSL
5.8.24.5.3 SSL_MAX_HASHES Macro
C
#define SSL_MAX_HASHES (5)
Description
Max # of SSL hashes (2 per socket, plus 1 to avoid deadlock)
5.8 TCP/IP Stack Library Help MPLAB Harmony Help SSL TCP/IP Stack Library
5-3873
5.8.24.5.4 SSL_MAX_SESSIONS Macro
C
#define SSL_MAX_SESSIONS (2)
Description
Max number of cached SSL sessions
5.8.24.5.5 SSL_MIN_SESSION_LIFETIME Macro
C
#define SSL_MIN_SESSION_LIFETIME (1ul)
Description
Minimum lifetime for SSL Sessions Sessions cannot be reallocated until this much time (seconds) has elapsed
5.8.24.5.6 SSL_MULTIPLE_INTERFACES Macro
C
#define SSL_MULTIPLE_INTERFACES 1
Description
SSL on all interfaces in a multi-homed host set to 0 to work only on one interface
5.8.24.5.7 SSL_RSA_CLIENT_SIZE Macro
C
#define SSL_RSA_CLIENT_SIZE (1024ul)
Description
Size of encryption buffer, must be at least as big as the key size
5.8.24.5.8 SSL_RSA_KEY_SIZE Macro
C
#define SSL_RSA_KEY_SIZE (1024ul)
Description
Bits in SSL RSA key. This parameter is used for SSL sever connections only. The only valid value is 512 bits (768 and 1024 bits
do not work at this time). Note, however, that SSL client operations do currently work up to 1024 bit RSA key length.
5.8.24.5.9 SSL_RSA_LIFETIME_EXTENSION Macro
C
#define SSL_RSA_LIFETIME_EXTENSION (8ul)
Description
Lifetime extension for RSA operations Sessions lifetime is extended by this amount (seconds) when an RSA calculation is made
5.8 TCP/IP Stack Library Help MPLAB Harmony Help SSL TCP/IP Stack Library
5-3874
5.8.24.5.10 SSL_VERSION Macro
C
#define SSL_VERSION (0x0300u) // Moved from Microchip\Include\TCPIP Stack\SSL.h
Description
Moved from MicrochipIncludeTCPIP StackSSL.h
5.8.24.5.11 SSL_VERSION_HI Macro
C
#define SSL_VERSION_HI (0x03u)
Description
SSL version number (high byte)
5.8.24.5.12 SSL_VERSION_LO Macro
C
#define SSL_VERSION_LO (0x00u)
Description
SSL version number (low byte)
5.8.24.6 Building the Library
This section list the files that are available in the \src of the SSL driver. It lists which files need to be included in the build based
on either a hardware feature present on the board or configuration option selected by the system.
5.8.24.7 Library Interface
Data Types and Constants
Name Description
SSL_MODULE_CONFIG SSL layer configuration/initialization
Functions
Name Description
TCPIP_TCP_SocketIsSecuredBySSL Determines if a TCP connection is secured with SSL.
TCPIP_TCPSSL_ClientBegin Begins an SSL client session.
TCPIP_TCPSSL_ClientStart Begins an SSL client session.
TCPIP_TCPSSL_HandshakeClear Clears the SSL handshake flag.
TCPIP_TCPSSL_ListenerAdd Listens for SSL connection on a specific port.
TCPIP_TCPSSL_ServerStart Begins an SSL server session.
TCPIP_TCPSSL_StillHandshaking Determines if an SSL session is still handshaking.
5.8 TCP/IP Stack Library Help MPLAB Harmony Help SSL TCP/IP Stack Library
5-3875
Description
This section describes the Application Programming Interface (API) functions of the SSL TCP/IP Stack.
Refer to each section for a detailed description.
5.8.24.7.1 Functions
5.8.24.7.1.1 TCPIP_TCP_SocketIsSecuredBySSL Function
C
bool TCPIP_TCP_SocketIsSecuredBySSL(
TCP_SOCKET hTCP
);
Description
Call this function to determine whether or not a TCP connection is secured with SSL.
Preconditions
TCP is initialized and hTCP is connected.
Parameters
Parameters Description
hTCP TCP connection to check
Return Values
Return Values Description
true Connection is secured via SSL
false Connection is not secured
5.8.24.7.1.2 TCPIP_TCPSSL_ClientBegin Function
C
bool TCPIP_TCPSSL_ClientBegin(
TCP_SOCKET hTCP,
uint8_t* host,
void * buffer,
uint8_t suppDataType
);
Description
This function escalates the current connection to an SSL secured connection by initiating an SSL client handshake.
Preconditions
TCP is initialized and hTCP is already connected.
Parameters
Parameters Description
hTCP TCP connection to secure
host Expected host name on certificate (currently ignored)
buffer Buffer for supplementary data return
suppDataType Type of supplementary data to copy
5.8 TCP/IP Stack Library Help MPLAB Harmony Help SSL TCP/IP Stack Library
5-3876
Return Values
Return Values Description
true an SSL connection was initiated
false Insufficient SSL resources (stubs) were available
Remarks
The host parameter is currently ignored and is not validated.
5.8.24.7.1.3 TCPIP_TCPSSL_ClientStart Function
C
bool TCPIP_TCPSSL_ClientStart(
TCP_SOCKET hTCP,
uint8_t* host
);
Description
This function escalates the current connection to an SSL secured connection by initiating an SSL client handshake.
Preconditions
TCP is initialized and hTCP is already connected.
Parameters
Parameters Description
hTCP TCP connection to secure
host Expected host name on certificate (currently ignored)
Return Values
Return Values Description
true an SSL connection was initiated
false Insufficient SSL resources (stubs) were available
Remarks
The host parameter is currently ignored and is not validated.
5.8.24.7.1.4 TCPIP_TCPSSL_HandshakeClear Function
C
void TCPIP_TCPSSL_HandshakeClear(
TCP_SOCKET hTCP
);
Description
This function clears the flag indicating that an SSL handshake is complete.
Preconditions
TCP is initialized and hTCP is connected.
Parameters
Parameters Description
hTCP TCP connection to set
5.8 TCP/IP Stack Library Help MPLAB Harmony Help SSL TCP/IP Stack Library
5-3877
Returns
None
Remarks
This function should never be called by an application. It is used only by the SSL module itself.
5.8.24.7.1.5 TCPIP_TCPSSL_ListenerAdd Function
C
bool TCPIP_TCPSSL_ListenerAdd(
TCP_SOCKET hTCP,
uint16_t port
);
Description
This function adds an additional listening port to a TCP connection. Connections made on this alternate port will be secured via
SSL.
Preconditions
TCP is initialized and hTCP is listening.
Parameters
Parameters Description
hTCP TCP connection to secure
port SSL port to listen on
Return Values
Return Values Description
true SSL port was added.
false The socket was not a listening socket.
5.8.24.7.1.6 TCPIP_TCPSSL_ServerStart Function
C
bool TCPIP_TCPSSL_ServerStart(
TCP_SOCKET hTCP
);
Description
This function sets up an SSL server session when a new connection is established on an SSL port.
Preconditions
TCP is initialized and hTCP is already connected.
Parameters
Parameters Description
hTCP TCP connection to secure
Return Values
Return Values Description
true an SSL connection was initiated
false Insufficient SSL resources (stubs) were available
5.8 TCP/IP Stack Library Help MPLAB Harmony Help SSL TCP/IP Stack Library
5-3878
5.8.24.7.1.7 TCPIP_TCPSSL_StillHandshaking Function
C
bool TCPIP_TCPSSL_StillHandshaking(
TCP_SOCKET hTCP
);
Description
Call this function after calling TCPIP_TCPSSL_ClientStart until false is returned. Then your application may continue with its
normal data transfer (which is now secured).
Preconditions
TCP is initialized and hTCP is connected.
Parameters
Parameters Description
hTCP TCP connection to check
Return Values
Return Values Description
true SSL handshake is still progressing
false SSL handshake has completed
5.8.24.7.2 Data Types and Constants
5.8.24.7.2.1 SSL_MODULE_CONFIG Structure
C
typedef struct {
} SSL_MODULE_CONFIG;
Description
SSL layer configuration/initialization
5.8.24.8 Files
Files
Name Description
ssl.h
ssl_config.h SSL configuration file
Description
5.8.24.8.1 ssl.h
SSLv3 Module Headers
5.8 TCP/IP Stack Library Help MPLAB Harmony Help SSL TCP/IP Stack Library
5-3879
Functions
Name Description
TCPIP_TCP_SocketIsSecuredBySSL Determines if a TCP connection is secured with SSL.
TCPIP_TCPSSL_ClientBegin Begins an SSL client session.
TCPIP_TCPSSL_ClientStart Begins an SSL client session.
TCPIP_TCPSSL_HandshakeClear Clears the SSL handshake flag.
TCPIP_TCPSSL_ListenerAdd Listens for SSL connection on a specific port.
TCPIP_TCPSSL_ServerStart Begins an SSL server session.
TCPIP_TCPSSL_StillHandshaking Determines if an SSL session is still handshaking.
Structures
Name Description
SSL_MODULE_CONFIG SSL layer configuration/initialization
5.8.24.8.2 ssl_config.h
Secure Sockets Layer (SSL) Configuration file
This file contains the SSL module configuration options
Macros
Name Description
SSL_MAX_BUFFERS Max # of SSL buffers (2 per socket)
SSL_MAX_CONNECTIONS Maximum number of simultaneous connections via SSL
SSL_MAX_HASHES Max # of SSL hashes (2 per socket, plus 1 to avoid deadlock)
SSL_MAX_SESSIONS Max number of cached SSL sessions
SSL_MIN_SESSION_LIFETIME Minimum lifetime for SSL Sessions Sessions cannot be reallocated until this
much time (seconds) has elapsed
SSL_MULTIPLE_INTERFACES SSL on all interfaces in a multi-homed host set to 0 to work only on one
interface
SSL_RSA_CLIENT_SIZE Size of encryption buffer, must be at least as big as the key size
SSL_RSA_KEY_SIZE Bits in SSL RSA key. This parameter is used for SSL sever connections only.
The only valid value is 512 bits (768 and 1024 bits do not work at this time).
Note, however, that SSL client operations do currently work up to 1024 bit
RSA key length.
SSL_RSA_LIFETIME_EXTENSION Lifetime extension for RSA operations Sessions lifetime is extended by this
amount (seconds) when an RSA calculation is made
SSL_VERSION Moved from MicrochipIncludeTCPIP StackSSL.h
SSL_VERSION_HI SSL version number (high byte)
SSL_VERSION_LO SSL version number (low byte)
5.8.25 TCP TCP/IP Stack Library
5.8 TCP/IP Stack Library Help MPLAB Harmony Help TCP TCP/IP Stack Library
5-3880
5.8.25.1 Introduction
Transmission Control Protocol (TCP) TCP/IP Stack Library
for
Microchip Microcontrollers
This library provides the API of the TCP TCP/IP Module that is available on the Microchip family of microcontrollers with a
convenient C language interface. It is a module that belongs to the TCP/IP stack.
Description
TCP is a standard transport layer protocol described in RFC 793. It provides reliable stream-based connections over unreliable
networks, and forms the foundation for HTTP, SMTP, and many other protocol standards.
5.8.25.2 Release Notes
MPLAB Harmony Version: v0.70b TCP TCP/IP Stack Library Version : 1.0 Release Date: 18Nov2013
New This Release:
This is the first release of the library. The interface can change in the beta and\or 1.0 release.
Known Issues:
Nothing to report in this release.
5.8.25.3 SW License Agreement
(c) 2013 Microchip Technology Inc.
Microchip licenses this software to you solely for use with Microchip products. The software is owned by Microchip and its
licensors, and is protected under applicable copyright laws. All rights reserved.
SOFTWARE IS PROVIDED "AS IS" MICROCHIP EXPRESSLY DISCLAIMS ANY WARRANTY OF ANY KIND, WHETHER
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. IN NO EVENT SHALL MICROCHIP BE LIABLE FOR
ANY INCIDENTAL, SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, HARM TO
YOUR EQUIPMENT, COST OF PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY OR SERVICES, ANY CLAIMS
BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), ANY CLAIMS FOR INDEMNITY OR
CONTRIBUTION, OR OTHER SIMILAR COSTS.
To the fullest extent allowed by law, Microchip and its licensors liability shall not exceed the amount of fees, if any, that you have
paid directly to Microchip to use this software.
MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE TERMS.
5.8.25.4 Using the Library
This topic describes the basic architecture of the TCP TCP/IP Stack Library and provides information and examples on how to
use it.
5.8 TCP/IP Stack Library Help MPLAB Harmony Help TCP TCP/IP Stack Library
5-3881
Interface Header File: tcp.h
The interface to the TCP TCP/IP Stack library is defined in the "tcp.h" header file. This file is included by the "tcpip.h" file. Any C
language source (.c) file that uses the TCP TCP/IP Stack library should include "tcpip.h".
Library File:
The TCP TCP/IP Stack library archive (.a) file installed with MPLAB Harmony.
Please refer to the MPLAB Harmony Overview for how the TCP/IP Stack interacts with the framework.
5.8.25.4.1 Abstraction Model
This library provides the API of the TCP TCP/IP Module that is available on the Microchip family of microcontrollers with a
convenient C language interface. It is a module that belongs to the TCP/IP stack.
Description
TCP Software Abstraction Block Diagram
This module provides software abstraction of the TCP module existent in any TCP/IP Stack implementation. It removes the
overhead of address resolution from all other modules in the stack.
Typical TCP Implementation
5.8.25.4.2 Library Overview
The library interface routines are divided into various sub-sections, each of sub-section addresses one of the blocks or the
overall operation of the TCP module.
Library Interface Section Description
Socket Management Functions Routines for Managing TCP Sockets
Transmit Data Transfer Functions Routines for Managing Outgoing Data Transmissions
5.8 TCP/IP Stack Library Help MPLAB Harmony Help TCP TCP/IP Stack Library
5-3882
Receive Data Transfer Functions Routines for Managing Incoming Data Transmissions
Data Types and Constants This section provides various definitions describing This API
5.8.25.4.3 How the Library Works
Connections made over TCP guarantee data transfer at the expense of throughput. Connections are made through a three-way
handshake process, ensuring a one-to-one connection. Remote nodes advertise how much data they are ready to receive, and
all data transmitted must be acknowledged. If a remote node fails to acknowledge the receipt of data, it is automatically
retransmitted. This ensures that network errors such as lost, corrupted, or out-of-order packets are automatically corrected.
To accomplish this, TCP must operate in a buffer. Once the transmit buffer is full, no more data can be sent until the remote
node has acknowledged receipt. For the Microchip TCP/IP Stack, the application must return to the main stack loop in order for
this to happen. Likewise, the remote node cannot transmit more data until the local device has acknowledged receipt and that
space is available in the buffer. When a local application needs to read more data, it must return to the main stack loop and wait
for a new packet to arrive.
5.8.25.4.3.1 Core Functionality
The TCP flow diagram below provides an overview for the use of the TCP module:
Sockets are opened using TCPOpen . This function can either open a listening socket to wait for client connections, or can make
a client connection to the remote node. The remote node can be specified by a host name string to be resolved in DNS, an IP
address, or a NODE_INFO struct containing previously resolved IP and MAC address information.
Once connected, applications can read and write data. On each entry, the application must verify that the socket is still
connected. For most applications a call to TCPIP_TCP_IsConnected will be sufficient, but TCPIP_TCP_WasReset may also be
used for listening sockets that may turn over quickly.
To write data, call TCPIP_TCP_PutIsReady to check how much space is available. Then, call any of the TCPIP_TCP_Put family
of functions to write data as space is vailable. Once complete, call TCPIP_TCP_Flush to transmit data immediately. Alternately,
return to the main stack loop. Data will be transmitted when either a) half of the transmit buffer becomes full or b) a delay time
has passed.
To read data, call TCPIP_TCP_GetIsReady to determine how many bytes are ready to be retrieved. Then use the
TCPIP_TCP_Get family of functions to read data from the socket, and/or the TCPIP_TCP_Find family of functions to locate data
in the buffer. When no more data remains, return to the main stack loop to wait for more data to arrive.
If the application needs to close the connection, call TCPIP_TCP_Disconnect, then return to the main stack loop and wait for the
5.8 TCP/IP Stack Library Help MPLAB Harmony Help TCP TCP/IP Stack Library
5-3883
remote node to acknowledge the disconnection. Client sockets will return to the idle state, while listening sockets will wait for a
new connection. For more information, refer to the GenericTCPClient or GenericTCPServer examples, or read the associated
RFC.
5.8.25.5 Configuring the Library
Macros
Name Description
LOCAL_TCP_PORT_END_NUMBER Last port number for randomized local port number selection
LOCAL_TCP_PORT_START_NUMBER First port number for randomized local port number selection Use the
dynamic port range defined by IANA consists of the 49152-65535
range and is meant for the selection of ephemeral ports (RFC 6056).
Adjust to your needs but stay within the IANA range
TCP_AUTO_TRANSMIT_TIMEOUT_VAL Timeout before automatically transmitting unflushed data, ms; Default
40 ms
TCP_CLOSE_WAIT_TIMEOUT Timeout for the CLOSE_WAIT state, ms
TCP_DELAYED_ACK_TIMEOUT Timeout for delayed-acknowledgement algorithm, ms
TCP_FIN_WAIT_2_TIMEOUT Timeout for FIN WAIT 2 state, ms
TCP_KEEP_ALIVE_TIMEOUT Timeout for keep-alive messages when no traffic is sent, ms
TCP_MAX_RETRIES Maximum number of retransmission attempts
TCP_MAX_SEG_SIZE_RX_LOCAL TCP Maximum Segment Size for RX (MSS). This value is advertised
during TCP connection establishment and the remote node should
obey it. The value has to be set in such a way to avoid IP layer
fragmentation from causing packet loss. However, raising its value can
enhance performance at the (small) risk of introducing incompatibility
with certain special remote nodes (ex: ones connected via a slow dial
up modem). On Ethernet networks the standard value is 1460. On
dial-up links, etc. the default values should be 536. Adjust these values
according to your network. The stack will use the local... more
TCP_MAX_SEG_SIZE_RX_NON_LOCAL Max segment size, non local
TCP_MAX_SEG_SIZE_TX TCP Maximum Segment Size for TX. The TX maximum segment size
is actually governed by the remote node's MSS option advertised
during connection establishment. However, if the remote node
specifies an unhandlably large MSS (ex: > Ethernet MTU), this define
sets a hard limit so that we don't cause any TX buffer overflows. If the
remote node does not advirtise a MSS option, all TX segments are
fixed at 536 bytes maximum.
TCP_MAX_SOCKETS The maximum number of sockets to create in the stack. When defining
TCP_MAX_SOCKETS take into account the number of interfaces the
stack is supporting
TCP_MAX_SYN_RETRIES Smaller than all other retries to reduce SYN flood DoS duration
TCP_MAX_UNACKED_KEEP_ALIVES Maximum number of keep-alive messages that can be sent without
receiving a response before automatically closing the connection
TCP_SOCKET_DEFAULT_RX_SIZE default socket Rx buffer size
TCP_SOCKET_DEFAULT_TX_SIZE default socket Tx buffer size
TCP_START_TIMEOUT_VAL TCP Timeout and retransmit numbers All timeouts in milliseconds
Timeout to retransmit unacked data, ms
TCP_TASK_TICK_RATE 5 ms default rate
TCP_WINDOW_UPDATE_TIMEOUT_VAL Timeout before automatically transmitting a window update due to a
TCPIP_TCP_Get() or TCPIP_TCP_ArrayGet() function call, ms
5.8 TCP/IP Stack Library Help MPLAB Harmony Help TCP TCP/IP Stack Library
5-3884
Description
The configuration of the TCP/IP TCP is based on the file sys_config.h
This header file contains the configuration selection for the TCP/IP TCP. Based on the selections made, the TCP/IP TCP will
support or not support selected features. These configuration settings will apply to all instances of the TCP/IP TCP.
This header can be placed anywhere; however, the path of this header needs to be present in the include search path for a
successful build. Refer to the Applications Overview section for more details.
5.8.25.5.1 LOCAL_TCP_PORT_END_NUMBER Macro
C
#define LOCAL_TCP_PORT_END_NUMBER (65535)
Description
Last port number for randomized local port number selection
5.8.25.5.2 LOCAL_TCP_PORT_START_NUMBER Macro
C
#define LOCAL_TCP_PORT_START_NUMBER (49152)
Description
First port number for randomized local port number selection Use the dynamic port range defined by IANA consists of the
49152-65535 range and is meant for the selection of ephemeral ports (RFC 6056). Adjust to your needs but stay within the IANA
range
5.8.25.5.3 TCP_AUTO_TRANSMIT_TIMEOUT_VAL Macro
C
#define TCP_AUTO_TRANSMIT_TIMEOUT_VAL (40ul)
Description
Timeout before automatically transmitting unflushed data, ms; Default 40 ms
5.8.25.5.4 TCP_CLOSE_WAIT_TIMEOUT Macro
C
#define TCP_CLOSE_WAIT_TIMEOUT (200ul)
Description
Timeout for the CLOSE_WAIT state, ms
5.8.25.5.5 TCP_DELAYED_ACK_TIMEOUT Macro
C
#define TCP_DELAYED_ACK_TIMEOUT (100ul)
Description
Timeout for delayed-acknowledgement algorithm, ms
5.8 TCP/IP Stack Library Help MPLAB Harmony Help TCP TCP/IP Stack Library
5-3885
5.8.25.5.6 TCP_FIN_WAIT_2_TIMEOUT Macro
C
#define TCP_FIN_WAIT_2_TIMEOUT (5000ul)
Description
Timeout for FIN WAIT 2 state, ms
5.8.25.5.7 TCP_KEEP_ALIVE_TIMEOUT Macro
C
#define TCP_KEEP_ALIVE_TIMEOUT (10000ul)
Description
Timeout for keep-alive messages when no traffic is sent, ms
5.8.25.5.8 TCP_MAX_RETRIES Macro
C
#define TCP_MAX_RETRIES (5u)
Description
Maximum number of retransmission attempts
5.8.25.5.9 TCP_MAX_SEG_SIZE_RX_LOCAL Macro
C
#define TCP_MAX_SEG_SIZE_RX_LOCAL (1460)
Description
TCP Maximum Segment Size for RX (MSS). This value is advertised during TCP connection establishment and the remote node
should obey it. The value has to be set in such a way to avoid IP layer fragmentation from causing packet loss. However, raising
its value can enhance performance at the (small) risk of introducing incompatibility with certain special remote nodes (ex: ones
connected via a slow dial up modem). On Ethernet networks the standard value is 1460. On dial-up links, etc. the default values
should be 536. Adjust these values according to your network. The stack will use the local value for local destination networks
and the default value for nonlocal networks.
5.8.25.5.10 TCP_MAX_SEG_SIZE_RX_NON_LOCAL Macro
C
#define TCP_MAX_SEG_SIZE_RX_NON_LOCAL (536) // Max segment size, non local
Description
Max segment size, non local
5.8 TCP/IP Stack Library Help MPLAB Harmony Help TCP TCP/IP Stack Library
5-3886
5.8.25.5.11 TCP_MAX_SEG_SIZE_TX Macro
C
#define TCP_MAX_SEG_SIZE_TX (1460u)
Description
TCP Maximum Segment Size for TX. The TX maximum segment size is actually governed by the remote node's MSS option
advertised during connection establishment. However, if the remote node specifies an unhandlably large MSS (ex: > Ethernet
MTU), this define sets a hard limit so that we don't cause any TX buffer overflows. If the remote node does not advirtise a MSS
option, all TX segments are fixed at 536 bytes maximum.
5.8.25.5.12 TCP_MAX_SOCKETS Macro
C
#define TCP_MAX_SOCKETS (10)
Description
The maximum number of sockets to create in the stack. When defining TCP_MAX_SOCKETS take into account the number of
interfaces the stack is supporting
5.8.25.5.13 TCP_MAX_SYN_RETRIES Macro
C
#define TCP_MAX_SYN_RETRIES (2u)
Description
Smaller than all other retries to reduce SYN flood DoS duration
5.8.25.5.14 TCP_MAX_UNACKED_KEEP_ALIVES Macro
C
#define TCP_MAX_UNACKED_KEEP_ALIVES (6u)
Description
Maximum number of keep-alive messages that can be sent without receiving a response before automatically closing the
connection
5.8.25.5.15 TCP_SOCKET_DEFAULT_RX_SIZE Macro
C
#define TCP_SOCKET_DEFAULT_RX_SIZE 512
Description
default socket Rx buffer size
5.8 TCP/IP Stack Library Help MPLAB Harmony Help TCP TCP/IP Stack Library
5-3887
5.8.25.5.16 TCP_SOCKET_DEFAULT_TX_SIZE Macro
C
#define TCP_SOCKET_DEFAULT_TX_SIZE 512
Description
default socket Tx buffer size
5.8.25.5.17 TCP_START_TIMEOUT_VAL Macro
C
#define TCP_START_TIMEOUT_VAL (1000ul)
Description
TCP Timeout and retransmit numbers All timeouts in milliseconds Timeout to retransmit unacked data, ms
5.8.25.5.18 TCP_TASK_TICK_RATE Macro
C
#define TCP_TASK_TICK_RATE (5) // 5 ms default rate
Description
5 ms default rate
5.8.25.5.19 TCP_WINDOW_UPDATE_TIMEOUT_VAL Macro
C
#define TCP_WINDOW_UPDATE_TIMEOUT_VAL (200ul)
Description
Timeout before automatically transmitting a window update due to a TCPIP_TCP_Get() or TCPIP_TCP_ArrayGet() function call,
ms
5.8.25.6 Building the Library
This section list the files that are available in the \src of the TCP driver. It lists which files need to be included in the build based
on either a hardware feature present on the board or configuration option selected by the system.
• tcp.c
5.8.25.7 Library Interface
Data Types and Constants
Name Description
TCPIP_TCP_FifoRxFullGet TCP Get Rx First In, First Out Full
TCPIP_TCP_FifoTxFreeGet TCP Get TX First In, First Out Free
TCP_ADJUST_FLAGS TCP Adjust Falgs
5.8 TCP/IP Stack Library Help MPLAB Harmony Help TCP TCP/IP Stack Library
5-3888
TCP_MODULE_CONFIG TCP layer configuration/initialization
TCP_OPTION_LINGER_DATA Linger options
TCP_PORT TCP Port
TCP_SOCKET TCP Socket
TCP_SOCKET_INFO TCP Socket Information
TCP_SOCKET_OPTION TCP Socket Option
INVALID_SOCKET The socket is invalid or could not be opened
Receive Data Transfer Functions
Name Description
TCPIP_TCP_ArrayFind Searches for a string in the TCP RX buffer.
TCPIP_TCP_ArrayGet Reads an array of data bytes from a TCP socket's receive FIFO. The data is
removed from the FIFO in the process.
TCPIP_TCP_ArrayPeek Reads a specified number of data bytes from the TCP RX FIFO without removing
them from the buffer.
TCPIP_TCP_Discard Discards any pending data in the TCP RX FIFO.
TCPIP_TCP_FifoSizeAdjust Adjusts the relative sizes of the RX and TX buffers.
TCPIP_TCP_Find Searches for a byte in the TCP RX buffer.
TCPIP_TCP_Get Retrieves a single byte to a TCP socket.
TCPIP_TCP_GetIsReady Determines how many bytes can be read from the TCP RX buffer.
TCPIP_TCP_Peek Peaks at one byte in the TCP RX FIFO without removing it from the buffer.
TCPIP_TCP_FifoRxFreeGet Determines how many bytes are free in the RX FIFO.
Socket Management Functions
Name Description
TCPIP_TCP_Bind Bind a socket to a local address This function is meant for unconnected server
and client sockets. It is similar to TCPIP_TCP_SocketNetSet() that assigns a
specific source interface for a socket. If localPort is 0 the stack will assign a unique
local port
TCPIP_TCP_ClientOpen Opens a TCP socket as a client.
TCPIP_TCP_Close Disconnects an open socket and destroys the socket handle, releasing the
associated resources.
TCPIP_TCP_Connect Connects a client socket.
TCPIP_TCP_Disconnect Disconnects an open socket.
TCPIP_TCP_IsConnected Determines if a socket has an established connection.
TCPIP_TCP_OptionsGet Allows getting the options for a socket like: current Rx/Tx buffer size, etc
TCPIP_TCP_OptionsSet Allows setting options to a socket like adjust Rx/Tx buffer size, etc
TCPIP_TCP_RemoteBind Bind a socket to a remote address This function is meant for unconnected server
and client sockets.
TCPIP_TCP_ServerOpen Opens a TCP socket as a server.
TCPIP_TCP_SocketInfoGet Obtains information about a currently open socket.
TCPIP_TCP_SocketNetGet Gets the MAC interface of an TCP socket
TCPIP_TCP_WasReset Self-clearing semaphore inidicating socket reset.
TCPIP_TCP_Abort Aborts a connection.
TCPIP_TCP_SocketNetSet Sets the interface for an TCP socket
5.8 TCP/IP Stack Library Help MPLAB Harmony Help TCP TCP/IP Stack Library
5-3889
Transmit Data Transfer Functions
Name Description
TCPIP_TCP_ArrayPut Writes an array from RAM to a TCP socket.
TCPIP_TCP_FifoTxFullGet Determines how many bytes are pending in the TCP TX FIFO.
TCPIP_TCP_Flush Immediately transmits all pending TX data.
TCPIP_TCP_Put Writes a single byte to a TCP socket.
TCPIP_TCP_PutIsReady Determines how much free space is available in the TCP TX buffer.
TCPIP_TCP_StringPut Writes a null-terminated string from RAM to a TCP socket. The null-terminator is
not copied to the socket.
Description
This section describes the Application Programming Interface (API) functions of the TCP TCP/IP Stack Library.
Refer to each section for a detailed description.
5.8.25.7.1 Socket Management Functions
5.8.25.7.1.1 TCPIP_TCP_Bind Function
C
bool TCPIP_TCP_Bind(
TCP_SOCKET hTCP,
IP_ADDRESS_TYPE addType,
TCP_PORT localPort,
IP_MULTI_ADDRESS* localAddress
);
Description
Sockets don't need specific binding, it is done automatically by the stack However, specific binding can be requested using these
functions. Works for both client and server sockets.
Preconditions
TCP socket should have been opened with TCPIP_TCP_ServerOpen()/TCPIP_TCP_ClientOpen()(). hTCP - valid socket
Parameters
Parameters Description
hTCP Socket to bind
addType The type of address being used. Example: IP_ADDRESS_TYPE_IPV4.
localPort Local port to use If 0, the stack will assign a unique local port
localAddress The local address to bind to. Could be NULL if the local address does not need to
be changed
Returns
True of success false otherwise
Remarks
The call should fail if the socket is already connected (both server and client sockets). However this is not currently implemented.
It is the user's responsibility to call this function only for sockets that are not connected. Changing the socket parameters while
the socket is connected will result in connection loss/unpredictable behavior.
5.8 TCP/IP Stack Library Help MPLAB Harmony Help TCP TCP/IP Stack Library
5-3890
5.8.25.7.1.2 TCPIP_TCP_ClientOpen Function
C
TCP_SOCKET TCPIP_TCP_ClientOpen(
IP_ADDRESS_TYPE addType,
TCP_PORT remotePort,
IP_MULTI_ADDRESS* remoteAddress
);
Description
Provides a unified method for opening TCP client sockets.
Sockets are dynamically allocated at stack initialization, and can be claimed with this function and freed using
TCPIP_TCP_Abort or TCPIP_TCP_Close.
Preconditions
TCP is initialized.
Parameters
Parameters Description
IP_ADDRESS_TYPE addType The type of address being used. Example: IP_ADDRESS_TYPE_IPV4.
TCP_PORT remotePort TCP port to connect to. The local port for client sockets will be automatically
picked by the TCP module.
IP_MULTI_ADDRESS* remoteAddress The remote address to be used. If 0 then the address is unspecified
Returns
INVALID_SOCKET - No sockets of the specified type were available to be opened. Otherwise - A TCP_SOCKET handle. Save
this handle and use it when calling all other TCP APIs.
Remarks
IP_ADDRESS_TYPE_ANY is not supported (not a valid type for client open)!
If the remoteAddress != 0 (and the address pointed by remoteAddress != 0) then the socket will immediately initiate a connection
to the remote host
If the remoteAddress is unspecified, then no connection is initiated. Client socket parameters can be se using
TCPIP_TCP_Bind(), TCPIP_TCP_RemoteBind(), etc. calls and then connection initiated by calling TCPIP_TCP_Connect().
5.8.25.7.1.3 TCPIP_TCP_Close Function
C
void TCPIP_TCP_Close(
TCP_SOCKET hTCP
);
Description
1. If the graceful option is set for the socket (default):
• a TCPIP_TCP_Disconnect will be tried. If the linger option is set (default) the TCPIP_TCP_Disconnect will try to send any
queued TX data before issuing FIN. If the FIN send operation fails or the socket is not connected the abort is generated.
2. If the graceful option is not set, or the previous step could not send the FIN: A TCPAbort() is called, sending a RST to the
remote node. Communication is closed, the socket is no longer valid and the associated resources are freed.
5.8 TCP/IP Stack Library Help MPLAB Harmony Help TCP TCP/IP Stack Library
5-3891
Preconditions
TCP socket should have been opened with TCPIP_TCP_ServerOpen()/TCPIP_TCP_ClientOpen()(). hTCP - valid socket
Parameters
Parameters Description
hTCP Handle to the socket to disconnect and close.
Returns
None
5.8.25.7.1.4 TCPIP_TCP_Connect Function
C
bool TCPIP_TCP_Connect(
TCP_SOCKET hTCP
);
Description
This function will try to initiate a connection on a client socket that's not connected yet. The client socket should have been
created with a call to TCPIP_TCP_ClientOpen having the remoteAddress set to 0;
Preconditions
TCP socket should have been opened with TCPIP_TCP_ClientOpen() with an unspecified address. hTCP - valid socket
Parameters
Parameters Description
hTCP Handle to the client socket to connect.
Returns
true is the call succeeded false otherwise
Remarks
the call will fail if the client socket has no remote host specified. Use TCPIP_TCP_RemoteBind() to specify a remote host
address for the client socket.
5.8.25.7.1.5 TCPIP_TCP_Disconnect Function
C
bool TCPIP_TCP_Disconnect(
TCP_SOCKET hTCP
);
Description
This function closes the TX side of a connection by sending a FIN (if currently connected) to the remote node of the connection.
If the socket has the linger option set (default), the queued TX data transmission will be attempted before sending the FIN. If the
linger option is off, the queued TX data will be discarded.
Please note that this call may fail in which case it can be re-issued.
Preconditions
TCP socket should have been opened with TCPIP_TCP_ServerOpen()/TCPIP_TCP_ClientOpen()(). hTCP - valid socket
5.8 TCP/IP Stack Library Help MPLAB Harmony Help TCP TCP/IP Stack Library
5-3892
Parameters
Parameters Description
hTCP Handle of the socket to disconnect.
Returns
true if the call succeeded false otherwise; that means that the notification could not be sent to the remote host. the call can be
re-issued at a later time if desired
Remarks
If the socket is using SSL, a CLOSE_NOTIFY record will be transmitted first to allow the SSL session to be resumed at a later
time.
5.8.25.7.1.6 TCPIP_TCP_IsConnected Function
C
bool TCPIP_TCP_IsConnected(
TCP_SOCKET hTCP
);
Description
This function determines if a socket has an established connection to a remote node. Call this function after calling
TCPIP_TCP_ServerOpen()/TCPIP_TCP_ClientOpen() to determine when the connection is set up and ready for use. This
function was historically used to check for disconnections, but TCPIP_TCP_WasReset is now a more appropriate solution.
Preconditions
TCP socket should have been opened with TCPIP_TCP_ServerOpen()/TCPIP_TCP_ClientOpen()(). hTCP - valid socket
Parameters
Parameters Description
hTCP The socket to check.
Return Values
Return Values Description
true The socket has an established connection to a remote node.
false The socket is not currently connected.
Remarks
A socket is said to be connected only if it is in the TCP_ESTABLISHED state. Sockets in the process of opening or closing will
return false.
5.8.25.7.1.7 TCPIP_TCP_OptionsGet Function
C
bool TCPIP_TCP_OptionsGet(
TCP_SOCKET hTCP,
TCP_SOCKET_OPTION option,
void* optParam
);
Description
Various options can be get at the socket level. This function provides compatibility with BSD implementations.
5.8 TCP/IP Stack Library Help MPLAB Harmony Help TCP TCP/IP Stack Library
5-3893
Preconditions
TCP socket should have been opened with TCPIP_TCP_ServerOpen()/TCPIP_TCP_ClientOpen()(). hTCP - valid socket
Parameters
Parameters Description
hTCP socket to get options for
option specific option to get
optParam pointer to an area that will receive the option value; this is option dependent the
size of the area has to be large enough to accomodate the specific option
TCP_OPTION_LINGER -- pointer to a TCP_OPTION_LINGER_DATA structure
TCP_OPTION_KEEPPALIVE -- not supported yet TCP_OPTION_RX_BUFF --
size of the new RX buffer TCP_OPTION_TX_BUFF -- size of the new TX buffer
TCP_OPTION_RX_TMO -- not supported yet TCP_OPTION_TX_TMO -- not
supported yet TCP_OPTION_NODELAY -- pointer to boolean to return current NO
DELAY status TCP_OPTION_EXCLUSIVE_ADDRESS -- not supported yet
Returns
true if success false otherwise
5.8.25.7.1.8 TCPIP_TCP_OptionsSet Function
C
bool TCPIP_TCP_OptionsSet(
TCP_SOCKET hTCP,
TCP_SOCKET_OPTION option,
void* optParam
);
Description
Various options can be set at the socket level. This function provides compatibility with BSD implementations.
Preconditions
TCP socket should have been opened with TCPIP_TCP_ServerOpen()/TCPIP_TCP_ClientOpen()(). hTCP - valid socket
Parameters
Parameters Description
hTCP socket to set options for
option specific option to be set
optParam the option value; this is option dependent TCP_OPTION_LINGER -- pointer to a
TCP_OPTION_LINGER_DATA structure TCP_OPTION_KEEPPALIVE -- not
supported yet TCP_OPTION_RX_BUFF -- size of the new RX buffer
TCP_OPTION_TX_BUFF -- size of the new TX buffer TCP_OPTION_RX_TMO --
not supported yet TCP_OPTION_TX_TMO -- not supported yet
TCP_OPTION_NODELAY -- boolean to enable/disable the NO DELAY
functionality TCP_OPTION_EXCLUSIVE_ADDRESS -- not supported yet
Returns
true if success false otherwise
5.8.25.7.1.9 TCPIP_TCP_RemoteBind Function
C
bool TCPIP_TCP_RemoteBind(
TCP_SOCKET hTCP,
5.8 TCP/IP Stack Library Help MPLAB Harmony Help TCP TCP/IP Stack Library
5-3894
IP_ADDRESS_TYPE addType,
TCP_PORT remotePort,
IP_MULTI_ADDRESS* remoteAddress
);
Description
Sockets don't need specific remote binding, they should accept connections on any incoming interface. Thus the binding is done
automatically by the stack. However, specific remote binding can be requested using these functions. For a server socket it can
be used to restrict accepting connections from a specific remote host. For a client socket it will just change the default binding
done when the socket was opened.
Preconditions
TCP socket should have been opened with TCPIP_TCP_ServerOpen()/TCPIP_TCP_ClientOpen()(). hTCP - valid socket
Parameters
Parameters Description
hTCP Socket to bind
addType The type of address being used. Example: IP_ADDRESS_TYPE_IPV4.
remotePort remote port to use Could be 0 if the remote port does not need to be changed
remoteAddress The remote address to bind to. Could be NULL if the remote address does not
need to be changed
Returns
True of success false otherwise
Remarks
The socket remote port is changed only if a non-zero remotePort value is passed. The socket remote host address is changed
only if a non-zero remoteAddress value is passed.
The call should fail if the socket is already connected (both server and client sockets). However this is not currently implemented.
It is the user's responsibility to call this function only for sockets that are not connected. Changing the socket parameters while
the socket is connected will result in connection loss/unpredictable behavior.
5.8.25.7.1.10 TCPIP_TCP_ServerOpen Function
C
TCP_SOCKET TCPIP_TCP_ServerOpen(
IP_ADDRESS_TYPE addType,
TCP_PORT localPort,
IP_MULTI_ADDRESS* localAddress
);
Description
Provides a unified method for opening TCP server sockets.
Sockets are statically/dynamically allocated on boot, and can be claimed with this function and freed using TCPIP_TCP_Close.
Preconditions
TCP is initialized.
Parameters
Parameters Description
IP_ADDRESS_TYPE addType The type of address being used. Example: IP_ADDRESS_TYPE_IPV4.
TCP_PORT localPort TCP port to listen on for connections.
5.8 TCP/IP Stack Library Help MPLAB Harmony Help TCP TCP/IP Stack Library
5-3895
IP_MULTI_ADDRESS* localAddress Local address to use.
Returns
INVALID_SOCKET - No sockets of the specified type were available to be opened. Otherwise - A TCP_SOCKET handle. Save
this handle and use it when calling all other TCP APIs.
5.8.25.7.1.11 TCPIP_TCP_SocketInfoGet Function
C
bool TCPIP_TCP_SocketInfoGet(
TCP_SOCKET hTCP,
TCP_SOCKET_INFO* pInfo
);
Description
Fills the provided TCP_SOCKET_INFO structure associated with this socket. This contains the NODE_INFO structure with IP
and MAC address (or gateway MAC) and the remote port.
Preconditions
TCP is initialized and the socket is connected.
Parameters
Parameters Description
hTCP The socket to check.
Returns
true if the call succeeded false if no such socket or the socket is not opened
5.8.25.7.1.12 TCPIP_TCP_SocketNetGet Function
C
TCPIP_NET_HANDLE TCPIP_TCP_SocketNetGet(
TCP_SOCKET hTCP
);
Description
This function returns the interface handle of an TCP socket
Preconditions
TCP socket should have been opened with _TCP_Open(). hTCP - valid socket
Parameters
Parameters Description
hTCP The TCP socket
Returns
the handle of the local interface this socket is bound to.
5.8.25.7.1.13 TCPIP_TCP_WasReset Function
C
bool TCPIP_TCP_WasReset(
TCP_SOCKET hTCP
5.8 TCP/IP Stack Library Help MPLAB Harmony Help TCP TCP/IP Stack Library
5-3896
);
Description
This function is a self-clearing semaphore indicating whether or not a socket has been disconnected since the previous call. This
function works for all possible disconnections: a call to TCPIP_TCP_Disconnect, a FIN from the remote node, or an
acknowledgement timeout caused by the loss of a network link. It also returns true after the first call to TCPIP_TCP_Initialize.
Applications should use this function to reset their state machines.
Preconditions
TCP is initialized.
Parameters
Parameters Description
hTCP The socket to check.
Return Values
Return Values Description
true The socket has been disconnected since the previous call.
false The socket has not been disconnected since the previous call.
5.8.25.7.1.14 TCPIP_TCP_Abort Function
C
void TCPIP_TCP_Abort(
TCP_SOCKET hTCP,
bool killSocket
);
Description
This function aborts a connection to a remote node by sending a RST (if currently connected). Any pending TX/RX data is
discarded.
A client socket will always be closed and the associated resources released. The socket cannot be used again after this call.
A server socket will abort the current connection:
• if killSocket == false the socket will remain listening
• if killSocket == true the socket will be closed and all associated resources released. The socket cannot be used again after
this call.
Preconditions
TCP socket should have been opened with TCPIP_TCP_ServerOpen()/TCPIP_TCP_ClientOpen()(). hTCP - valid socket
Parameters
Parameters Description
hTCP Handle to the socket to disconnect.
killSocket if true, it kills a server socket
Returns
None
5.8 TCP/IP Stack Library Help MPLAB Harmony Help TCP TCP/IP Stack Library
5-3897
5.8.25.7.1.15 TCPIP_TCP_SocketNetSet Function
C
bool TCPIP_TCP_SocketNetSet(
TCP_SOCKET hTCP,
TCPIP_NET_HANDLE hNet
);
Description
This function sets the network interface for an TCP socket
Preconditions
TCP socket should have been opened with _TCP_Open(). hTCP - valid socket
Parameters
Parameters Description
hTCP The TCP socket
hNet interface handle.
Returns
true if success false otherwise.
Remarks
None
5.8.25.7.2 Transmit Data Transfer Functions
5.8.25.7.2.1 TCPIP_TCP_ArrayPut Function
C
uint16_t TCPIP_TCP_ArrayPut(
TCP_SOCKET hTCP,
const uint8_t* Data,
uint16_t Len
);
Description
Writes an array from RAM to a TCP socket.
Preconditions
TCP is initialized.
Parameters
Parameters Description
hTCP The socket to which data is to be written.
data Pointer to the array to be written.
len Number of bytes to be written.
Returns
The number of bytes written to the socket. If less than len, the buffer became full or the socket is not conected.
5.8 TCP/IP Stack Library Help MPLAB Harmony Help TCP TCP/IP Stack Library
5-3898
5.8.25.7.2.2 TCPIP_TCP_FifoTxFullGet Function
C
uint16_t TCPIP_TCP_FifoTxFullGet(
TCP_SOCKET hTCP
);
Description
Determines how many bytes are pending in the TCP TX FIFO.
Preconditions
TCP is initialized.
Parameters
Parameters Description
hTCP The socket to check.
Returns
Number of bytes pending to be flushed in the TCP TX FIFO.
5.8.25.7.2.3 TCPIP_TCP_Flush Function
C
bool TCPIP_TCP_Flush(
TCP_SOCKET hTCP
);
Description
This function immediately transmits all pending TX data with a PSH flag. If this function is not called, data will automatically be
sent when either a) the TX buffer is half full or b) the TCP_AUTO_TRANSMIT_TIMEOUT_VAL (default: 40ms) has elapsed.
Preconditions
TCP is initialized and the socket is connected.
Parameters
Parameters Description
hTCP The socket whose data is to be transmitted.
Returns
None
Remarks
SSL application data is automatically flushed, so this function has no effect for SSL sockets.
5.8.25.7.2.4 TCPIP_TCP_Put Function
C
uint16_t TCPIP_TCP_Put(
TCP_SOCKET hTCP,
uint8_t byte
);
Description
Writes a single byte to a TCP socket.
5.8 TCP/IP Stack Library Help MPLAB Harmony Help TCP TCP/IP Stack Library
5-3899
Preconditions
TCP socket should have been opened with TCPIP_TCP_ServerOpen()/TCPIP_TCP_ClientOpen()(). hTCP - valid socket
Parameters
Parameters Description
hTCP The socket to which data is to be written.
byte The byte to write.
Return Values
Return Values Description
0 The byte was written to the transmit buffer.
1 The transmit buffer was full, or the socket is not connected.
Remarks
Note that the following function is inefficient. A buffered approach (TCPIP_TCP_ArrayPut) should be preferred
5.8.25.7.2.5 TCPIP_TCP_PutIsReady Function
C
uint16_t TCPIP_TCP_PutIsReady(
TCP_SOCKET hTCP
);
Description
Call this function to determine how many bytes can be written to the TCP TX buffer. If this function returns zero, the application
must return to the main stack loop before continuing in order to transmit more data.
Preconditions
TCP is initialized.
Parameters
Parameters Description
hTCP The socket to check.
Returns
The number of bytes available to be written in the TCP TX buffer.
5.8.25.7.2.6 TCPIP_TCP_StringPut Function
C
const uint8_t* TCPIP_TCP_StringPut(
TCP_SOCKET hTCP,
const uint8_t* Data
);
Description
Writes a null-terminated string from RAM to a TCP socket. The null-terminator is not copied to the socket.
Preconditions
TCP is initialized.
5.8 TCP/IP Stack Library Help MPLAB Harmony Help TCP TCP/IP Stack Library
5-3900
Parameters
Parameters Description
hTCP The socket to which data is to be written.
data Pointer to the string to be written.
Returns
Pointer to the byte following the last byte written to the socket. If this pointer does not dereference to a NUL byte, the buffer
became full or the socket is not connected.
Remarks
The return value of this function differs from that of TCPIP_TCP_ArrayPut. To write long strings in a single state, initialize the
*data pointer to the first byte, then call this function repeatedly (breaking to the main stack loop after each call) until the return
value dereferences to a NUL byte. Save the return value as the new starting *data pointer otherwise.
5.8.25.7.3 Receive Data Transfer Functions
5.8.25.7.3.1 TCPIP_TCP_ArrayFind Function
C
uint16_t TCPIP_TCP_ArrayFind(
TCP_SOCKET hTCP,
const uint8_t* cFindArray,
uint16_t wLen,
uint16_t wStart,
uint16_t wSearchLen,
bool bTextCompare
);
Description
This function finds the first occurrance of an array of bytes in the TCP RX buffer. It can be used by an application to abstract
searches out of their own application code. For increased efficiency, the function is capable of limiting the scope of search to a
specific range of bytes. It can also perform a case-insensitive search if required.
For example, if the buffer contains "I love PIC MCUs!" and the search array is "love" with a length of 4, a value of 2 will be
returned.
Preconditions
TCP is initialized.
Parameters
Parameters Description
hTCP The socket to search within.
cFindArray The array of bytes to find in the buffer.
wLen Length of cFindArray.
wStart Zero-indexed starting position within the buffer.
wSearchLen Length from wStart to search in the buffer.
bTextCompare true for case-insensitive text search, false for binary search
Return Values
Return Values Description
0xFFFF Search array not found
5.8 TCP/IP Stack Library Help MPLAB Harmony Help TCP TCP/IP Stack Library
5-3901
Otherwise Zero-indexed position of the first occurrance
Remarks
Since this function usually must transfer data from external storage to internal RAM for comparison, its performance degrades
significantly when the buffer is full and the array is not found. For better performance, try to search for characters that are
expected to exist or limit the scope of the search as much as possible. The HTTP module, for example, uses this function to
parse headers. However, it searches for newlines, then the separating colon, then reads the header name to RAM for final
comparison. This has proven to be significantly faster than searching for full header name strings outright.
5.8.25.7.3.2 TCPIP_TCP_ArrayGet Function
C
uint16_t TCPIP_TCP_ArrayGet(
TCP_SOCKET hTCP,
uint8_t* buffer,
uint16_t count
);
Description
Reads an array of data bytes from a TCP socket's receive FIFO. The data is removed from the FIFO in the process.
Preconditions
TCP is initialized.
Parameters
Parameters Description
hTCP The socket from which data is to be read.
buffer Pointer to the array to store data that was read.
len Number of bytes to be read.
Returns
The number of bytes read from the socket. If less than len, the RX FIFO buffer became empty or the socket is not conected.
5.8.25.7.3.3 TCPIP_TCP_ArrayPeek Function
C
uint16_t TCPIP_TCP_ArrayPeek(
TCP_SOCKET hTCP,
uint8_t * vBuffer,
uint16_t wLen,
uint16_t wStart
);
Description
Reads a specified number of data bytes from the TCP RX FIFO without removing them from the buffer. No TCP control actions
are taken as a result of this function (ex: no window update is sent to the remote node).
Preconditions
TCP is initialized.
Parameters
Parameters Description
hTCP The socket to peak from (read without removing from stream).
5.8 TCP/IP Stack Library Help MPLAB Harmony Help TCP TCP/IP Stack Library
5-3902
vBuffer Destination to write the peeked data bytes.
wLen Length of bytes to peak from the RX FIFO and copy to vBuffer.
wStart Zero-indexed starting position within the FIFO to start peeking from.
Remarks
None
5.8.25.7.3.4 TCPIP_TCP_Discard Function
C
uint16_t TCPIP_TCP_Discard(
TCP_SOCKET hTCP
);
Description
Discards any pending data in the TCP RX FIFO.
Preconditions
TCP is initialized.
Parameters
Parameters Description
hTCP The socket whose RX FIFO is to be cleared.
Returns
Number of bytes that have been discarded from the RX buffer.
5.8.25.7.3.5 TCPIP_TCP_FifoSizeAdjust Function
C
bool TCPIP_TCP_FifoSizeAdjust(
TCP_SOCKET hTCP,
uint16_t wMinRXSize,
uint16_t wMinTXSize,
TCP_ADJUST_FLAGS vFlags
);
Description
This function can be used to simultaneously adjust the sizes of the RX and TX FIFOs.
Adjusting the size of the TX/RX FIFO on the fly can allow for optimal transmission speed for one-sided application protocols. For
example, HTTP typically begins by receiving large amounts of data from the client, then switches to serving large amounts of
data back. Adjusting the FIFO at these points can increase performance in systems that have limited resources. Once the FIFOs
are adjusted, a window update is sent.
The TCP_ADJUST_FLAGS control the distribution of the remaining available space between the TX and RX FIFOs. If neither or
both of TCP_ADJUST_GIVE_REST_TO_TX and TCP_ADJUST_GIVE_REST_TO_RX are set, the function distributes the
remaining space (if any) equally. If the new requested FIFOs space is greater that the old existing FIFOs space the
TCP_ADJUST_GIVE_REST_TO_TX and TCP_ADJUST_GIVE_REST_TO_RX are ignored.
TCP_ADJUST_PRESERVE_RX and TCP_ADJUST_PRESERVE_TX request the preserving of the existing data. Existing data
can be preserved as long as the old data in the buffer does not exceed the capacity of the new buffer.
Preconditions
TCP is initialized.
5.8 TCP/IP Stack Library Help MPLAB Harmony Help TCP TCP/IP Stack Library
5-3903
Parameters
Parameters Description
hTCP The socket to be adjusted
wMinRXSize Minimum number of bytes for the RX FIFO
wMinTXSize Minimum number of bytes for the TX FIFO
vFlags If TCP_ADJUST_TX_ONLY or TCP_ADJUST_RX_ONLY are not set, then the TX
and RX bufferrs are evaluated together and any
5.8.25.7.3.6 TCPIP_TCP_Find Function
C
uint16_t TCPIP_TCP_Find(
TCP_SOCKET hTCP,
uint8_t cFind,
uint16_t wStart,
uint16_t wSearchLen,
bool bTextCompare
);
Description
This function finds the first occurrance of a byte in the TCP RX buffer. It can be used by an application to abstract searches out
of their own application code. For increased efficiency, the function is capable of limiting the scope of search to a specific range
of bytes. It can also perform a case-insensitive search if required.
For example, if the buffer contains "I love PIC MCUs!" and the cFind byte is ' ', a value of 1 will be returned.
Preconditions
TCP is initialized.
Parameters
Parameters Description
hTCP The socket to search within.
cFind The byte to find in the buffer.
wStart Zero-indexed starting position within the buffer.
wSearchLen Length from wStart to search in the buffer.
bTextCompare true for case-insensitive text search, false for binary search
Return Values
Return Values Description
0xFFFF Search array not found
Otherwise Zero-indexed position of the first occurrance
Remarks
Since this function usually must transfer data from external storage to internal RAM for comparison, its performance degrades
significantly when the buffer is full and the array is not found. For better performance, try to search for characters that are
expected to exist or limit the scope of the search as much as possible. The HTTP module, for example, uses this function to
parse headers. However, it searches for newlines, then the separating colon, then reads the header name to RAM for final
comparison. This has proven to be significantly faster than searching for full header name strings outright.
5.8 TCP/IP Stack Library Help MPLAB Harmony Help TCP TCP/IP Stack Library
5-3904
5.8.25.7.3.7 TCPIP_TCP_Get Function
C
uint16_t TCPIP_TCP_Get(
TCP_SOCKET hTCP,
uint8_t* byte
);
Description
Retrieves a single byte to a TCP socket.
Preconditions
TCP socket should have been opened with TCPIP_TCP_ServerOpen()/TCPIP_TCP_ClientOpen()(). hTCP - valid socket
Parameters
Parameters Description
hTCP The socket from which to read.
byte Pointer to location in which the read byte should be stored.
Return Values
Return Values Description
1 A byte was read from the buffer.
0 The buffer was empty, or the socket is not connected.
Remarks
Note that the following function is inefficient. A buffered approach (TCPIP_TCP_ArrayGet) should be preferred
5.8.25.7.3.8 TCPIP_TCP_GetIsReady Function
C
uint16_t TCPIP_TCP_GetIsReady(
TCP_SOCKET hTCP
);
Description
Call this function to determine how many bytes can be read from the TCP RX buffer. If this function returns zero, the application
must return to the main stack loop before continuing in order to wait for more data to arrive.
Preconditions
TCP is initialized.
Parameters
Parameters Description
hTCP The socket to check.
Returns
The number of bytes available to be read from the TCP RX buffer.
5.8.25.7.3.9 TCPIP_TCP_Peek Function
C
uint8_t TCPIP_TCP_Peek(
TCP_SOCKET hTCP,
5.8 TCP/IP Stack Library Help MPLAB Harmony Help TCP TCP/IP Stack Library
5-3905
uint16_t wStart
);
Description
Peaks at one byte in the TCP RX FIFO without removing it from the buffer.
Preconditions
TCP is initialized.
Parameters
Parameters Description
hTCP The socket to peak from (read without removing from stream).
wStart Zero-indexed starting position within the FIFO to peek from.
Remarks
Use the TCPIP_TCP_ArrayPeek() function to read more than one byte. It will perform better than calling TCPIP_TCP_Peek() in
a loop.
5.8.25.7.3.10 TCPIP_TCP_FifoRxFreeGet Function
C
uint16_t TCPIP_TCP_FifoRxFreeGet(
TCP_SOCKET hTCP
);
Description
Determines how many bytes are free in the RX FIFO.
Preconditions
TCP is initialized.
Parameters
Parameters Description
hTCP The socket to check.
Returns
The number of bytes free in the TCP RX FIFO. If zero, no additional data can be received until the application removes some
data using one of the TCPIP_TCP_Get family functions.
5.8.25.7.4 Data Types and Constants
5.8.25.7.4.1 TCPIP_TCP_FifoRxFullGet Macro
C
#define TCPIP_TCP_FifoRxFullGet(a) TCPIP_TCP_GetIsReady(a)
Description
Macro: TCPIP_TCP_FifoRxFullGet
Alias to TCPIP_TCP_GetIsReady provided for API completeness
5.8 TCP/IP Stack Library Help MPLAB Harmony Help TCP TCP/IP Stack Library
5-3906
5.8.25.7.4.2 TCPIP_TCP_FifoTxFreeGet Macro
C
#define TCPIP_TCP_FifoTxFreeGet(a) TCPIP_TCP_PutIsReady(a)
Description
Macro: TCPIP_TCP_FifoTxFreeGet(TCP_SOCKET hTCP)
Alias to TCPIP_TCP_PutIsReady provided for API completeness
Parameters
Parameters Description
hTCP The socket to check.
Returns
The number of bytes available to be written in the TCP TX buffer.
5.8.25.7.4.3 TCP_ADJUST_FLAGS Enumeration
C
typedef enum {
TCP_ADJUST_GIVE_REST_TO_RX = 0x01,
TCP_ADJUST_GIVE_REST_TO_TX = 0x02,
TCP_ADJUST_PRESERVE_RX = 0x04,
TCP_ADJUST_PRESERVE_TX = 0x08,
TCP_ADJUST_TX_ONLY = 0x10,
TCP_ADJUST_RX_ONLY = 0x20
} TCP_ADJUST_FLAGS;
Description
Enumeration: TCP_ADJUST_FLAGS
Adjust socket buffer sizes.
Members
Members Description
TCP_ADJUST_GIVE_REST_TO_RX =
0x01
Resize flag: extra bytes go to RX
TCP_ADJUST_GIVE_REST_TO_TX =
0x02
Resize flag: extra bytes go to TX
TCP_ADJUST_PRESERVE_RX = 0x04 Resize flag: attempt to preserve RX buffer
TCP_ADJUST_PRESERVE_TX = 0x08 Resize flag: attempt to preserve TX buffer
TCP_ADJUST_TX_ONLY = 0x10 Resize flag: adjust the TX buffer only
TCP_ADJUST_RX_ONLY = 0x20 Resize flag: adjust the RX buffer only
5.8.25.7.4.4 TCP_MODULE_CONFIG Structure
C
typedef struct {
int nSockets;
uint16_t sktTxBuffSize;
uint16_t sktRxBuffSize;
} TCP_MODULE_CONFIG;
5.8 TCP/IP Stack Library Help MPLAB Harmony Help TCP TCP/IP Stack Library
5-3907
Description
Structure: TCP_MODULE_CONFIG
TCP layer configuration/initialization
Members
Members Description
int nSockets; number of sockets to be created
uint16_t sktTxBuffSize; size of the socket tx buffer
uint16_t sktRxBuffSize; size of the socket rx buffer
5.8.25.7.4.5 TCP_OPTION_LINGER_DATA Structure
C
typedef struct {
bool lingerEnable;
bool gracefulEnable;
uint16_t lingerTmo;
} TCP_OPTION_LINGER_DATA;
Description
Structure: TCP_OPTION_LINGER_DATA
Linger options
Members
Members Description
bool lingerEnable; enable/disable linger; enabled by default for any socket
bool gracefulEnable; enable/disable graceful close; enabled by default for any socket
uint16_t lingerTmo; linger timeout in seconds (when enabled) this option is not supported yet
5.8.25.7.4.6 TCP_PORT Type
C
typedef uint16_t TCP_PORT;
Description
Type: TCP_PORT
TCP Port Number identifier
5.8.25.7.4.7 TCP_SOCKET Type
C
typedef int16_t TCP_SOCKET;
Description
Type: TCP_SOCKET
A TCP_SOCKET is stored as a single uint8_t
5.8 TCP/IP Stack Library Help MPLAB Harmony Help TCP TCP/IP Stack Library
5-3908
5.8.25.7.4.8 TCP_SOCKET_INFO Structure
C
typedef struct {
IP_ADDRESS_TYPE addressType;
IP_MULTI_ADDRESS remoteIPaddress;
IP_MULTI_ADDRESS localIPaddress;
TCP_PORT remotePort;
TCP_PORT localPort;
} TCP_SOCKET_INFO;
Description
Structure: TCP_SOCKET_INFO
Information about a socket
Members
Members Description
TCP_PORT remotePort; Port number associated with remote node
TCP_PORT localPort; local port number
5.8.25.7.4.9 TCP_SOCKET_OPTION Enumeration
C
typedef enum {
TCP_OPTION_LINGER,
TCP_OPTION_KEEPPALIVE,
TCP_OPTION_RX_BUFF,
TCP_OPTION_TX_BUFF,
TCP_OPTION_RX_TMO,
TCP_OPTION_TX_TMO,
TCP_OPTION_NODELAY,
TCP_OPTION_EXCLUSIVE_ADDRESS
} TCP_SOCKET_OPTION;
Description
Enumeration: TCP_SOCKET_OPTION
Socket options
Members
Members Description
TCP_OPTION_LINGER The LINGER option controls the action taken when unsent data is queued on a
socket and the socket is closed. The linger option can be turned on/off and the
timeout can be specified.
TCP_OPTION_KEEPPALIVE enable the use of keep-alive packets on TCP connections The option can be
turned on/off and the timeout can be specified
TCP_OPTION_RX_BUFF request different RX buffer size. Has to call TCPIP_TCP_OptionsGet to see the
exact space allocated
TCP_OPTION_TX_BUFF request different TX buffer size. Has to call TCPIP_TCP_OptionsGet to see the
exact space allocated
TCP_OPTION_RX_TMO specifies the RX timeout. If no data arrives in the specified timeout the socket is
closed
TCP_OPTION_TX_TMO specifies the TX timeout. If no data can be sent in the specified timeout the socket
is closed
TCP_OPTION_NODELAY enables the NO DELAY/Nagle algorithm functionality;
5.8 TCP/IP Stack Library Help MPLAB Harmony Help TCP TCP/IP Stack Library
5-3909
TCP_OPTION_EXCLUSIVE_ADDRESS enables a socket to be bound for exclusive access.
5.8.25.7.4.10 INVALID_SOCKET Macro
C
#define INVALID_SOCKET (-1) // The socket is invalid or could not be opened
Description
The socket is invalid or could not be opened
5.8.25.8 Files
Files
Name Description
tcp.h Transmission Control Protocol (TCP) Communications Layer API
tcp_config.h TCP configuration file
Description
5.8.25.8.1 tcp.h
• Provides reliable, handshaked transport of application stream oriented data with flow control
• Reference: RFC 793
Enumerations
Name Description
TCP_ADJUST_FLAGS TCP Adjust Falgs
TCP_SOCKET_OPTION TCP Socket Option
Functions
Name Description
TCPIP_TCP_Abort Aborts a connection.
TCPIP_TCP_ArrayFind Searches for a string in the TCP RX buffer.
TCPIP_TCP_ArrayGet Reads an array of data bytes from a TCP socket's receive FIFO. The data is
removed from the FIFO in the process.
TCPIP_TCP_ArrayPeek Reads a specified number of data bytes from the TCP RX FIFO without removing
them from the buffer.
TCPIP_TCP_ArrayPut Writes an array from RAM to a TCP socket.
TCPIP_TCP_Bind Bind a socket to a local address This function is meant for unconnected server
and client sockets. It is similar to TCPIP_TCP_SocketNetSet() that assigns a
specific source interface for a socket. If localPort is 0 the stack will assign a unique
local port
TCPIP_TCP_ClientOpen Opens a TCP socket as a client.
TCPIP_TCP_Close Disconnects an open socket and destroys the socket handle, releasing the
associated resources.
TCPIP_TCP_Connect Connects a client socket.
TCPIP_TCP_Discard Discards any pending data in the TCP RX FIFO.
5.8 TCP/IP Stack Library Help MPLAB Harmony Help TCP TCP/IP Stack Library
5-3910
TCPIP_TCP_Disconnect Disconnects an open socket.
TCPIP_TCP_FifoRxFreeGet Determines how many bytes are free in the RX FIFO.
TCPIP_TCP_FifoSizeAdjust Adjusts the relative sizes of the RX and TX buffers.
TCPIP_TCP_FifoTxFullGet Determines how many bytes are pending in the TCP TX FIFO.
TCPIP_TCP_Find Searches for a byte in the TCP RX buffer.
TCPIP_TCP_Flush Immediately transmits all pending TX data.
TCPIP_TCP_Get Retrieves a single byte to a TCP socket.
TCPIP_TCP_GetIsReady Determines how many bytes can be read from the TCP RX buffer.
TCPIP_TCP_IsConnected Determines if a socket has an established connection.
TCPIP_TCP_OptionsGet Allows getting the options for a socket like: current Rx/Tx buffer size, etc
TCPIP_TCP_OptionsSet Allows setting options to a socket like adjust Rx/Tx buffer size, etc
TCPIP_TCP_Peek Peaks at one byte in the TCP RX FIFO without removing it from the buffer.
TCPIP_TCP_Put Writes a single byte to a TCP socket.
TCPIP_TCP_PutIsReady Determines how much free space is available in the TCP TX buffer.
TCPIP_TCP_RemoteBind Bind a socket to a remote address This function is meant for unconnected server
and client sockets.
TCPIP_TCP_ServerOpen Opens a TCP socket as a server.
TCPIP_TCP_SocketInfoGet Obtains information about a currently open socket.
TCPIP_TCP_SocketNetGet Gets the MAC interface of an TCP socket
TCPIP_TCP_SocketNetSet Sets the interface for an TCP socket
TCPIP_TCP_StringPut Writes a null-terminated string from RAM to a TCP socket. The null-terminator is
not copied to the socket.
TCPIP_TCP_WasReset Self-clearing semaphore inidicating socket reset.
Macros
Name Description
INVALID_SOCKET The socket is invalid or could not be opened
TCPIP_TCP_FifoRxFullGet TCP Get Rx First In, First Out Full
TCPIP_TCP_FifoTxFreeGet TCP Get TX First In, First Out Free
Structures
Name Description
TCP_MODULE_CONFIG TCP layer configuration/initialization
TCP_OPTION_LINGER_DATA Linger options
TCP_SOCKET_INFO TCP Socket Information
Types
Name Description
TCP_PORT TCP Port
TCP_SOCKET TCP Socket
File Name
tcp.h
Company
Microchip Technology Incorporated
5.8 TCP/IP Stack Library Help MPLAB Harmony Help TCP TCP/IP Stack Library
5-3911
5.8.25.8.2 tcp_config.h
Transmission Control Protocol (TCP) Configuration file
This file contains the TCP module configuration options
Macros
Name Description
LOCAL_TCP_PORT_END_NUMBER Last port number for randomized local port number selection
LOCAL_TCP_PORT_START_NUMBER First port number for randomized local port number selection Use the
dynamic port range defined by IANA consists of the 49152-65535
range and is meant for the selection of ephemeral ports (RFC 6056).
Adjust to your needs but stay within the IANA range
TCP_AUTO_TRANSMIT_TIMEOUT_VAL Timeout before automatically transmitting unflushed data, ms; Default
40 ms
TCP_CLOSE_WAIT_TIMEOUT Timeout for the CLOSE_WAIT state, ms
TCP_DELAYED_ACK_TIMEOUT Timeout for delayed-acknowledgement algorithm, ms
TCP_FIN_WAIT_2_TIMEOUT Timeout for FIN WAIT 2 state, ms
TCP_KEEP_ALIVE_TIMEOUT Timeout for keep-alive messages when no traffic is sent, ms
TCP_MAX_RETRIES Maximum number of retransmission attempts
TCP_MAX_SEG_SIZE_RX_LOCAL TCP Maximum Segment Size for RX (MSS). This value is advertised
during TCP connection establishment and the remote node should
obey it. The value has to be set in such a way to avoid IP layer
fragmentation from causing packet loss. However, raising its value can
enhance performance at the (small) risk of introducing incompatibility
with certain special remote nodes (ex: ones connected via a slow dial
up modem). On Ethernet networks the standard value is 1460. On
dial-up links, etc. the default values should be 536. Adjust these values
according to your network. The stack will use the local... more
TCP_MAX_SEG_SIZE_RX_NON_LOCAL Max segment size, non local
TCP_MAX_SEG_SIZE_TX TCP Maximum Segment Size for TX. The TX maximum segment size
is actually governed by the remote node's MSS option advertised
during connection establishment. However, if the remote node
specifies an unhandlably large MSS (ex: > Ethernet MTU), this define
sets a hard limit so that we don't cause any TX buffer overflows. If the
remote node does not advirtise a MSS option, all TX segments are
fixed at 536 bytes maximum.
TCP_MAX_SOCKETS The maximum number of sockets to create in the stack. When defining
TCP_MAX_SOCKETS take into account the number of interfaces the
stack is supporting
TCP_MAX_SYN_RETRIES Smaller than all other retries to reduce SYN flood DoS duration
TCP_MAX_UNACKED_KEEP_ALIVES Maximum number of keep-alive messages that can be sent without
receiving a response before automatically closing the connection
TCP_SOCKET_DEFAULT_RX_SIZE default socket Rx buffer size
TCP_SOCKET_DEFAULT_TX_SIZE default socket Tx buffer size
TCP_START_TIMEOUT_VAL TCP Timeout and retransmit numbers All timeouts in milliseconds
Timeout to retransmit unacked data, ms
TCP_TASK_TICK_RATE 5 ms default rate
TCP_WINDOW_UPDATE_TIMEOUT_VAL Timeout before automatically transmitting a window update due to a
TCPIP_TCP_Get() or TCPIP_TCP_ArrayGet() function call, ms
5.8 TCP/IP Stack Library Help MPLAB Harmony Help Telnet TCP/IP Stack Library
5-3912
5.8.26 Telnet TCP/IP Stack Library
5.8.26.1 Introduction
Telnet TCP/IP Stack Library
for
Microchip Microcontrollers
This library provides the API of the Telnet TCP/IP Module that is available on the Microchip family of microcontrollers with a
convenient C language interface. It is a module that belongs to the TCP/IP stack.
Description
Telnet provides bidirectional, interactive communication between two nodes on the Internet or on a Local Area Network. The
sTelnet code included with Microchip's TCP/IP stack is a demonstration of the structure of a Telnet application. This demo
begins by listening for a Telnet connection. When a client attempts to make one, the demo will prompt the client for a username
and password, and if the correct one is provided, will output and periodically refresh several values obtained from the demo
board.
There are several changes that you may need to make to Telnet.c and/or Telnet.h to suit your application. All of the Telnet Public
members can be re-defined in the application-specific section of TCPIPConfig.h. You may also wish to change some of the
Telnet Internal Member strings, located in Telnet.c, to more accurately reflect your application. You will also need to modify the
TelnetTask ( see page 574) function to include the functionality you'd like. You may insert or change states in TelnetTask ( see
page 574) as needed.
5.8.26.2 Release Notes
MPLAB Harmony Version: v0.70b Telnet TCP/IP Stack Library Version : 1.0 Release Date: 18Nov2013
New This Release:
This is the first release of the library. The interface can change in the beta and\or 1.0 release.
Known Issues:
Nothing to report in this release.
5.8.26.3 SW License Agreement
(c) 2013 Microchip Technology Inc.
Microchip licenses this software to you solely for use with Microchip products. The software is owned by Microchip and its
licensors, and is protected under applicable copyright laws. All rights reserved.
SOFTWARE IS PROVIDED "AS IS" MICROCHIP EXPRESSLY DISCLAIMS ANY WARRANTY OF ANY KIND, WHETHER
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
5.8 TCP/IP Stack Library Help MPLAB Harmony Help Telnet TCP/IP Stack Library
5-3913
FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. IN NO EVENT SHALL MICROCHIP BE LIABLE FOR
ANY INCIDENTAL, SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, HARM TO
YOUR EQUIPMENT, COST OF PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY OR SERVICES, ANY CLAIMS
BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), ANY CLAIMS FOR INDEMNITY OR
CONTRIBUTION, OR OTHER SIMILAR COSTS.
To the fullest extent allowed by law, Microchip and its licensors liability shall not exceed the amount of fees, if any, that you have
paid directly to Microchip to use this software.
MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE TERMS.
5.8.26.4 Using the Library
This topic describes the basic architecture of the Telnet TCP/IP Stack Library and provides information and examples on how to
use it.
Interface Header File: telnet.h
The interface to the Telnet TCP/IP Stack library is defined in the "telnet.h" header file. This file is included by the "tcpip.h" file.
Any C language source (.c) file that uses the Telnet TCP/IP Stack library should include "tcpip.h".
Library File:
The Telnet TCP/IP Stack library archive (.a) file installed with MPLAB Harmony.
Please refer to the MPLAB Harmony Overview for how the TCP/IP Stack interacts with the framework.
5.8.26.4.1 Abstraction Model
This library provides the API of the Telnet TCP/IP Module that is available on the Microchip family of microcontrollers with a
convenient C language interface. It is a module that belongs to the TCP/IP stack.
Description
Telnet Software Abstraction Block Diagram
Note: This image was not available at time of release and will be added in a future release of MPLAB Harmony.
5.8.26.4.2 Library Overview
The library interface routines are divided into various sub-sections, each of sub-section addresses one of the blocks or the
overall operation of the Telnet module.
Library Interface Section Description
Data Types and Constants This section provides various definitions describing this API
5.8.26.5 Configuring the Library
Macros
Name Description
MAX_TELNET_CONNECTIONS Maximum number of Telnet connections
TELNET_PASSWORD Default Telnet password
5.8 TCP/IP Stack Library Help MPLAB Harmony Help Telnet TCP/IP Stack Library
5-3914
TELNET_PORT Unsecured Telnet port
TELNET_USERNAME Default Telnet user name
TELNETS_PORT SSL Secured Telnet port (ignored if TCPIP_STACK_USE_SSL_SERVER is
undefined)
Description
The configuration of the Telnet TCP/IP Stack Library is based on the file tcpip_config.h
This header file contains the configuration selection for the Telnet TCP/IP Stack Library. Based on the selections made, the
Telnet TCP/IP Stack Library will support or not support selected features. These configuration settings will apply to all instances
of the Telnet TCP/IP Stack Library.
This header can be placed anywhere; however, the path of this header needs to be present in the include search path for a
successful build. Refer to the Applications Overview section for more details.
5.8.26.5.1 MAX_TELNET_CONNECTIONS Macro
C
#define MAX_TELNET_CONNECTIONS (2u)
Description
Maximum number of Telnet connections
5.8.26.5.2 TELNET_PASSWORD Macro
C
#define TELNET_PASSWORD "microchip"
Description
Default Telnet password
5.8.26.5.3 TELNET_PORT Macro
C
#define TELNET_PORT 23
Description
Unsecured Telnet port
5.8.26.5.4 TELNET_USERNAME Macro
C
#define TELNET_USERNAME "admin"
Description
Default Telnet user name
5.8 TCP/IP Stack Library Help MPLAB Harmony Help Telnet TCP/IP Stack Library
5-3915
5.8.26.5.5 TELNETS_PORT Macro
C
#define TELNETS_PORT 992
Description
SSL Secured Telnet port (ignored if TCPIP_STACK_USE_SSL_SERVER is undefined)
5.8.26.6 Building the Library
This section list the files that are available in the \src of the Telnet driver. It lists which files need to be included in the build based
on either a hardware feature present on the board or configuration option selected by the system.
5.8.26.7 Library Interface
Data Types and Constants
Name Description
TELNET_MODULE_CONFIG Telnet Configuration structure placeholder
Description
There are no user accessible functions in this interface. There is only a place holder for Telnet module configuration.
5.8.26.7.1 Data Types and Constants
5.8.26.7.1.1 TELNET_MODULE_CONFIG Structure
C
typedef struct {
} TELNET_MODULE_CONFIG;
Description
Telnet Configuration structure placeholder
5.8.26.8 Files
Files
Name Description
telnet.h
telnet_config.h Configuration file
Description
5.8 TCP/IP Stack Library Help MPLAB Harmony Help Telnet TCP/IP Stack Library
5-3916
5.8.26.8.1 telnet.h
Telnet Server Module for Microchip TCP/IP Stack
-Listens on TCP Port 23
Structures
Name Description
TELNET_MODULE_CONFIG Telnet Configuration structure placeholder
5.8.26.8.2 telnet_config.h
Telnet Configuration file
This file contains the Telnet module configuration options
Macros
Name Description
MAX_TELNET_CONNECTIONS Maximum number of Telnet connections
TELNET_PASSWORD Default Telnet password
TELNET_PORT Unsecured Telnet port
TELNET_USERNAME Default Telnet user name
TELNETS_PORT SSL Secured Telnet port (ignored if TCPIP_STACK_USE_SSL_SERVER is
undefined)
5.8.27 TFTP TCP/IP Stack Library
5.8.27.1 Introduction
Trivial File Transfer Protocol (TFTP) TCP/IP Stack Library
for
Microchip Microcontrollers
This library provides the API of the TFTP TCP/IP Module that is available on the Microchip family of microcontrollers with a
convenient C language interface. It is a module that belongs to the TCP/IP stack.
Description
The Trivial File Transfer Protocol provides unreliable upload and download services to applications connected to the
UDP-based TFTP server.
5.8.27.2 Release Notes
MPLAB Harmony Version: v0.70b TFTP TCP/IP Stack Library Version : 1.0 Release Date: 18Nov2013
5.8 TCP/IP Stack Library Help MPLAB Harmony Help TFTP TCP/IP Stack Library
5-3917
New This Release:
This is the first release of the library. The interface can change in the beta and\or 1.0 release.
Known Issues:
Nothing to report in this release.
5.8.27.3 SW License Agreement
(c) 2013 Microchip Technology Inc.
Microchip licenses this software to you solely for use with Microchip products. The software is owned by Microchip and its
licensors, and is protected under applicable copyright laws. All rights reserved.
SOFTWARE IS PROVIDED "AS IS" MICROCHIP EXPRESSLY DISCLAIMS ANY WARRANTY OF ANY KIND, WHETHER
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. IN NO EVENT SHALL MICROCHIP BE LIABLE FOR
ANY INCIDENTAL, SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, HARM TO
YOUR EQUIPMENT, COST OF PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY OR SERVICES, ANY CLAIMS
BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), ANY CLAIMS FOR INDEMNITY OR
CONTRIBUTION, OR OTHER SIMILAR COSTS.
To the fullest extent allowed by law, Microchip and its licensors liability shall not exceed the amount of fees, if any, that you have
paid directly to Microchip to use this software.
MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE TERMS.
5.8.27.4 Using the Library
This topic describes the basic architecture of the TFTP TCP/IP Stack Library and provides information and examples on how to
use it.
Interface Header File: tftpc.h
The interface to the TFTP TCP/IP Stack library is defined in the "tftpc.h" header file. This file is included by the "tcpip.h" file. Any
C language source (.c) file that uses the tftpc.h TCP/IP Stack library should include "tcpip.h".
Library File:
The TFTP TCP/IP Stack library archive (.a) file installed with MPLAB Harmony.
Please refer to the MPLAB Harmony Overview for how the TCP/IP Stack interacts with the framework.
5.8.27.4.1 Abstraction Model
This library provides the API of the TFTP TCP/IP Module that is available on the Microchip family of microcontrollers with a
convenient C language interface. It is a module that belongs to the TCP/IP stack.
Description
TFTP Software Abstraction Block Diagram
5.8 TCP/IP Stack Library Help MPLAB Harmony Help TFTP TCP/IP Stack Library
5-3918
5.8.27.4.2 Library Overview
The library interface routines are divided into various sub-sections, each of sub-section addresses one of the blocks or the
overall operation of the TFTP module.
Library Interface Section Description
General Functions This section provides general interface routines to TFTP
Data Types and Constants This section provides various definitions describing this API
5.8 TCP/IP Stack Library Help MPLAB Harmony Help TFTP TCP/IP Stack Library
5-3919
5.8.27.5 Configuring the Library
Macros
Name Description
TFTP_ARP_TIMEOUT_VAL Number of seconds to wait before declaring TIMEOUT error on Put, seconds
TFTP_BLOCK_SIZE The size of a TFTP block - 512 bytes
TFTP_BLOCK_SIZE_MSB The MSB of the TFTP_BLOCK_SIZE
TFTP_CLIENT_PORT The TFTP Client port - a unique port on this device
TFTP_GET_TIMEOUT_VAL Number of seconds to wait before declaring TIMEOUT error on Get, seconds.
TFTP_MAX_RETRIES Number of attempts before declaring TIMEOUT error.
TFTP_SERVER_PORT The TFTP Server Port
Description
The configuration of the TFTP TCP/IP Stack Library is based on the file tcpip_config.h
This header file contains the configuration selection for the TFTP TCP/IP Stack Library. Based on the selections made, the TFTP
TCP/IP Stack Library will support or not support selected features. These configuration settings will apply to all instances of the
TFTP TCP/IP Stack Library.
This header can be placed anywhere; however, the path of this header needs to be present in the include search path for a
successful build. Refer to the Applications Overview section for more details.
5.8.27.5.1 TFTP_ARP_TIMEOUT_VAL Macro
C
#define TFTP_ARP_TIMEOUT_VAL (3ul)
Description
Number of seconds to wait before declaring TIMEOUT error on Put, seconds
5.8.27.5.2 TFTP_BLOCK_SIZE Macro
C
#define TFTP_BLOCK_SIZE (0x200L)
Description
The size of a TFTP block - 512 bytes
5.8.27.5.3 TFTP_BLOCK_SIZE_MSB Macro
C
#define TFTP_BLOCK_SIZE_MSB (0x02u)
Description
The MSB of the TFTP_BLOCK_SIZE
5.8 TCP/IP Stack Library Help MPLAB Harmony Help TFTP TCP/IP Stack Library
5-3920
5.8.27.5.4 TFTP_CLIENT_PORT Macro
C
#define TFTP_CLIENT_PORT 65352L
Description
The TFTP Client port - a unique port on this device
5.8.27.5.5 TFTP_GET_TIMEOUT_VAL Macro
C
#define TFTP_GET_TIMEOUT_VAL (3ul)
Description
Number of seconds to wait before declaring TIMEOUT error on Get, seconds.
5.8.27.5.6 TFTP_MAX_RETRIES Macro
C
#define TFTP_MAX_RETRIES (3u)
Description
Number of attempts before declaring TIMEOUT error.
5.8.27.5.7 TFTP_SERVER_PORT Macro
C
#define TFTP_SERVER_PORT (69L)
Description
The TFTP Server Port
5.8.27.6 Building the Library
This section list the files that are available in the \src of the TFTP driver. It lists which files need to be included in the build based
on either a hardware feature present on the board or configuration option selected by the system.
5.8.27.7 Library Interface
Data Types and Constants
Name Description
TFTP_UPLOAD_COMPLETE Status codes for TCPIP_TFTP_UploadStatusGet() function. Zero
means upload success, >0 means working and <0 means fatal
error.
TFTP_UPLOAD_CONNECT This is macro TFTP_UPLOAD_CONNECT.
TFTP_UPLOAD_CONNECT_TIMEOUT This is macro TFTP_UPLOAD_CONNECT_TIMEOUT.
5.8 TCP/IP Stack Library Help MPLAB Harmony Help TFTP TCP/IP Stack Library
5-3921
TFTP_UPLOAD_GET_DNS This is macro TFTP_UPLOAD_GET_DNS.
TFTP_UPLOAD_HOST_RESOLVE_TIMEOUT This is macro TFTP_UPLOAD_HOST_RESOLVE_TIMEOUT.
TFTP_UPLOAD_RESOLVE_HOST This is macro TFTP_UPLOAD_RESOLVE_HOST.
TFTP_UPLOAD_SEND_DATA This is macro TFTP_UPLOAD_SEND_DATA.
TFTP_UPLOAD_SEND_FILENAME This is macro TFTP_UPLOAD_SEND_FILENAME.
TFTP_UPLOAD_SERVER_ERROR This is macro TFTP_UPLOAD_SERVER_ERROR.
TFTP_UPLOAD_WAIT_FOR_CLOSURE This is macro TFTP_UPLOAD_WAIT_FOR_CLOSURE.
TFTPClose Macro: void TFTPClose(void)
Closes TFTP client socket.
TFTPGetError Macro: uint16_t TFTPGetError(void)
Returns previously saved error code.
TFTPIsFileOpenReady Macro: bool TFTPIsFileOpenReady(void)
Checks to see if it is okay to send TFTP file open request to
remote server.
TFTP_ACCESS_ERROR Standard error codes as defined by TFTP spec. Use to decode
value retuned by TFTPGetError().
TFTP_CHUNK_DESCRIPTOR This is type TFTP_CHUNK_DESCRIPTOR.
TFTP_FILE_MODE File open mode as used by TFTPFileOpen().
TFTP_RESULT Enum. of results returned by most of the TFTP functions.
Functions
Name Description
TCPIP_TFTP_DataByteGet This is function TCPIP_TFTP_DataByteGet.
TCPIP_TFTP_DataBytePut This is function TCPIP_TFTP_DataBytePut.
TCPIP_TFTP_DataIsGetReady This is function TCPIP_TFTP_DataIsGetReady.
TCPIP_TFTP_FileClose This is function TCPIP_TFTP_FileClose.
TCPIP_TFTP_FileIsClosed This is function TCPIP_TFTP_FileIsClosed.
TCPIP_TFTP_FileIsOpen This is function TCPIP_TFTP_FileIsOpen.
TCPIP_TFTP_FragRAMFileUploadToHost This is function TCPIP_TFTP_FragRAMFileUploadToHost.
TCPIP_TFTP_IsOpen This is function TCPIP_TFTP_IsOpen.
TCPIP_TFTP_IsReadyForPut This is function TCPIP_TFTP_IsReadyForPut.
TCPIP_TFTP_Open This is function TCPIP_TFTP_Open.
TCPIP_TFTP_RAMFileUploadToHost This is function TCPIP_TFTP_RAMFileUploadToHost.
TCPIP_TFTP_UploadStatusGet This is function TCPIP_TFTP_UploadStatusGet.
TFTPOpenFile This is function TFTPOpenFile.
Description
This section describes the Application Programming Interface (API) functions of the TFTP TCP/IP Stack.
Refer to each section for a detailed description.
5.8.27.7.1 Functions
5.8.27.7.1.1 TCPIP_TFTP_DataByteGet Function
C
uint8_t TCPIP_TFTP_DataByteGet();
5.8 TCP/IP Stack Library Help MPLAB Harmony Help TFTP TCP/IP Stack Library
5-3922
Description
This is function TCPIP_TFTP_DataByteGet.
5.8.27.7.1.2 TCPIP_TFTP_DataBytePut Function
C
void TCPIP_TFTP_DataBytePut(
uint8_t c
);
Description
This is function TCPIP_TFTP_DataBytePut.
5.8.27.7.1.3 TCPIP_TFTP_DataIsGetReady Function
C
TFTP_RESULT TCPIP_TFTP_DataIsGetReady();
Description
This is function TCPIP_TFTP_DataIsGetReady.
5.8.27.7.1.4 TCPIP_TFTP_FileClose Function
C
void TCPIP_TFTP_FileClose();
Description
This is function TCPIP_TFTP_FileClose.
5.8.27.7.1.5 TCPIP_TFTP_FileIsClosed Function
C
TFTP_RESULT TCPIP_TFTP_FileIsClosed();
Description
This is function TCPIP_TFTP_FileIsClosed.
5.8.27.7.1.6 TCPIP_TFTP_FileIsOpen Function
C
TFTP_RESULT TCPIP_TFTP_FileIsOpen();
Description
This is function TCPIP_TFTP_FileIsOpen.
5.8.27.7.1.7 TCPIP_TFTP_FragRAMFileUploadToHost Function
C
void TCPIP_TFTP_FragRAMFileUploadToHost(
const uint8_t * vRemoteHost,
const uint8_t * vFilename,
TFTP_CHUNK_DESCRIPTOR * vFirstChunkDescriptor
);
5.8 TCP/IP Stack Library Help MPLAB Harmony Help TFTP TCP/IP Stack Library
5-3923
Description
This is function TCPIP_TFTP_FragRAMFileUploadToHost.
5.8.27.7.1.8 TCPIP_TFTP_IsOpen Function
C
TFTP_RESULT TCPIP_TFTP_IsOpen();
Description
This is function TCPIP_TFTP_IsOpen.
5.8.27.7.1.9 TCPIP_TFTP_IsReadyForPut Function
C
TFTP_RESULT TCPIP_TFTP_IsReadyForPut();
Description
This is function TCPIP_TFTP_IsReadyForPut.
5.8.27.7.1.10 TCPIP_TFTP_Open Function
C
void TCPIP_TFTP_Open(
IPV4_ADDR * host
);
Description
This is function TCPIP_TFTP_Open.
5.8.27.7.1.11 TCPIP_TFTP_RAMFileUploadToHost Function
C
void TCPIP_TFTP_RAMFileUploadToHost(
const uint8_t * vRemoteHost,
const uint8_t * vFilename,
uint8_t * vData,
uint16_t wDataLength
);
Description
This is function TCPIP_TFTP_RAMFileUploadToHost.
5.8.27.7.1.12 TCPIP_TFTP_UploadStatusGet Function
C
int8_t TCPIP_TFTP_UploadStatusGet();
Description
This is function TCPIP_TFTP_UploadStatusGet.
5.8 TCP/IP Stack Library Help MPLAB Harmony Help TFTP TCP/IP Stack Library
5-3924
5.8.27.7.1.13 TFTPOpenFile Function
C
void TFTPOpenFile(
const uint8_t * fileName,
TFTP_FILE_MODE mode
);
Description
This is function TFTPOpenFile.
5.8.27.7.2 Data Types and Constants
5.8.27.7.2.1 TFTP_UPLOAD_COMPLETE Macro
C
#define TFTP_UPLOAD_COMPLETE 0
Description
Status codes for TCPIP_TFTP_UploadStatusGet() function. Zero means upload success, >0 means working and <0 means fatal
error.
5.8.27.7.2.2 TFTP_UPLOAD_CONNECT Macro
C
#define TFTP_UPLOAD_CONNECT 3
Description
This is macro TFTP_UPLOAD_CONNECT.
5.8.27.7.2.3 TFTP_UPLOAD_CONNECT_TIMEOUT Macro
C
#define TFTP_UPLOAD_CONNECT_TIMEOUT -2
Description
This is macro TFTP_UPLOAD_CONNECT_TIMEOUT.
5.8.27.7.2.4 TFTP_UPLOAD_GET_DNS Macro
C
#define TFTP_UPLOAD_GET_DNS 1
Description
This is macro TFTP_UPLOAD_GET_DNS.
5.8.27.7.2.5 TFTP_UPLOAD_HOST_RESOLVE_TIMEOUT Macro
C
#define TFTP_UPLOAD_HOST_RESOLVE_TIMEOUT -1
5.8 TCP/IP Stack Library Help MPLAB Harmony Help TFTP TCP/IP Stack Library
5-3925
Description
This is macro TFTP_UPLOAD_HOST_RESOLVE_TIMEOUT.
5.8.27.7.2.6 TFTP_UPLOAD_RESOLVE_HOST Macro
C
#define TFTP_UPLOAD_RESOLVE_HOST 2
Description
This is macro TFTP_UPLOAD_RESOLVE_HOST.
5.8.27.7.2.7 TFTP_UPLOAD_SEND_DATA Macro
C
#define TFTP_UPLOAD_SEND_DATA 5
Description
This is macro TFTP_UPLOAD_SEND_DATA.
5.8.27.7.2.8 TFTP_UPLOAD_SEND_FILENAME Macro
C
#define TFTP_UPLOAD_SEND_FILENAME 4
Description
This is macro TFTP_UPLOAD_SEND_FILENAME.
5.8.27.7.2.9 TFTP_UPLOAD_SERVER_ERROR Macro
C
#define TFTP_UPLOAD_SERVER_ERROR -3
Description
This is macro TFTP_UPLOAD_SERVER_ERROR.
5.8.27.7.2.10 TFTP_UPLOAD_WAIT_FOR_CLOSURE Macro
C
#define TFTP_UPLOAD_WAIT_FOR_CLOSURE 6
Description
This is macro TFTP_UPLOAD_WAIT_FOR_CLOSURE.
5.8.27.7.2.11 TFTPClose Macro
C
#define TFTPClose(void) TCPIP_UDP_Close(_tftpSocket)
Description
Macro: void TFTPClose(void)
Closes TFTP client socket.
5.8 TCP/IP Stack Library Help MPLAB Harmony Help TFTP TCP/IP Stack Library
5-3926
Preconditions
TCPIP_TFTP_Open is already called and TCPIP_TFTP_IsOpen() returned TFTP_OK.
Returns
None
Side Effects
None
Remarks
Once closed, application must do TCPIP_TFTP_Open to perform any new TFTP operations.
If TFTP server does not change during application life-time, one may not need to call TFTPClose and keep TFTP socket open.
5.8.27.7.2.12 TFTPGetError Macro
C
#define TFTPGetError (_tftpError)
Description
Macro: uint16_t TFTPGetError(void)
Returns previously saved error code.
Preconditions
One of the TFTP function returned with TFTP_ERROR result.
Returns
Error code as returned by remote server. Application may use TFTP_ACCESS_ERROR enum. to decode standard error code.
Side Effects
None
Remarks
None
5.8.27.7.2.13 TFTPIsFileOpenReady Macro
C
#define TFTPIsFileOpenReady UDPIsPutReady(_tftpSocket)
Description
Macro: bool TFTPIsFileOpenReady(void)
Checks to see if it is okay to send TFTP file open request to remote server.
Preconditions
TCPIP_TFTP_Open is already called and TCPIP_TFTP_IsOpen() returned TFTP_OK.
Returns
true, if it is ok to call TFTPOpenFile() false, if otherwise.
Side Effects
None
5.8 TCP/IP Stack Library Help MPLAB Harmony Help TFTP TCP/IP Stack Library
5-3927
Remarks
None
5.8.27.7.2.14 TFTP_ACCESS_ERROR Type
C
typedef enum _TFTP_ACCESS_ERROR TFTP_ACCESS_ERROR;
Description
Standard error codes as defined by TFTP spec. Use to decode value retuned by TFTPGetError().
5.8.27.7.2.15 TFTP_CHUNK_DESCRIPTOR Structure
C
typedef struct {
uint8_t * vDataPointer;
uint16_t wDataLength;
} TFTP_CHUNK_DESCRIPTOR;
Description
This is type TFTP_CHUNK_DESCRIPTOR.
5.8.27.7.2.16 TFTP_FILE_MODE Type
C
typedef enum _TFTP_FILE_MODE TFTP_FILE_MODE;
Description
File open mode as used by TFTPFileOpen().
5.8.27.7.2.17 TFTP_RESULT Type
C
typedef enum _TFTP_RESULT TFTP_RESULT;
Description
Enum. of results returned by most of the TFTP functions.
5.8.27.8 Files
Files
Name Description
tftpc.h
tftpc_config.h (TFTP) Configuration file
Description
5.8 TCP/IP Stack Library Help MPLAB Harmony Help TFTP TCP/IP Stack Library
5-3928
5.8.27.8.1 tftpc.h
TFTP Client module for Microchip TCP/IP Stack
Functions
Name Description
TCPIP_TFTP_DataByteGet This is function TCPIP_TFTP_DataByteGet.
TCPIP_TFTP_DataBytePut This is function TCPIP_TFTP_DataBytePut.
TCPIP_TFTP_DataIsGetReady This is function TCPIP_TFTP_DataIsGetReady.
TCPIP_TFTP_FileClose This is function TCPIP_TFTP_FileClose.
TCPIP_TFTP_FileIsClosed This is function TCPIP_TFTP_FileIsClosed.
TCPIP_TFTP_FileIsOpen This is function TCPIP_TFTP_FileIsOpen.
TCPIP_TFTP_FragRAMFileUploadToHost This is function TCPIP_TFTP_FragRAMFileUploadToHost.
TCPIP_TFTP_IsOpen This is function TCPIP_TFTP_IsOpen.
TCPIP_TFTP_IsReadyForPut This is function TCPIP_TFTP_IsReadyForPut.
TCPIP_TFTP_Open This is function TCPIP_TFTP_Open.
TCPIP_TFTP_RAMFileUploadToHost This is function TCPIP_TFTP_RAMFileUploadToHost.
TCPIP_TFTP_UploadStatusGet This is function TCPIP_TFTP_UploadStatusGet.
TFTPOpenFile This is function TFTPOpenFile.
Macros
Name Description
TFTP_MAX_RETRIES Number of attempts before declaring TIMEOUT error.
TFTP_UPLOAD_COMPLETE Status codes for TCPIP_TFTP_UploadStatusGet() function. Zero
means upload success, >0 means working and <0 means fatal
error.
TFTP_UPLOAD_CONNECT This is macro TFTP_UPLOAD_CONNECT.
TFTP_UPLOAD_CONNECT_TIMEOUT This is macro TFTP_UPLOAD_CONNECT_TIMEOUT.
TFTP_UPLOAD_GET_DNS This is macro TFTP_UPLOAD_GET_DNS.
TFTP_UPLOAD_HOST_RESOLVE_TIMEOUT This is macro TFTP_UPLOAD_HOST_RESOLVE_TIMEOUT.
TFTP_UPLOAD_RESOLVE_HOST This is macro TFTP_UPLOAD_RESOLVE_HOST.
TFTP_UPLOAD_SEND_DATA This is macro TFTP_UPLOAD_SEND_DATA.
TFTP_UPLOAD_SEND_FILENAME This is macro TFTP_UPLOAD_SEND_FILENAME.
TFTP_UPLOAD_SERVER_ERROR This is macro TFTP_UPLOAD_SERVER_ERROR.
TFTP_UPLOAD_WAIT_FOR_CLOSURE This is macro TFTP_UPLOAD_WAIT_FOR_CLOSURE.
TFTPClose Macro: void TFTPClose(void)
Closes TFTP client socket.
TFTPGetError Macro: uint16_t TFTPGetError(void)
Returns previously saved error code.
TFTPIsFileOpenReady Macro: bool TFTPIsFileOpenReady(void)
Checks to see if it is okay to send TFTP file open request to
remote server.
Structures
Name Description
TFTP_CHUNK_DESCRIPTOR This is type TFTP_CHUNK_DESCRIPTOR.
5.8 TCP/IP Stack Library Help MPLAB Harmony Help TFTP TCP/IP Stack Library
5-3929
Types
Name Description
TFTP_ACCESS_ERROR Standard error codes as defined by TFTP spec. Use to decode value retuned by
TFTPGetError().
TFTP_FILE_MODE File open mode as used by TFTPFileOpen().
TFTP_RESULT Enum. of results returned by most of the TFTP functions.
5.8.27.8.2 tftpc_config.h
Trivial File Transfer Protocol (TFTP) Configuration file
This file contains the TFTP module configuration options
Macros
Name Description
TFTP_ARP_TIMEOUT_VAL Number of seconds to wait before declaring TIMEOUT error on Put, seconds
TFTP_BLOCK_SIZE The size of a TFTP block - 512 bytes
TFTP_BLOCK_SIZE_MSB The MSB of the TFTP_BLOCK_SIZE
TFTP_CLIENT_PORT The TFTP Client port - a unique port on this device
TFTP_GET_TIMEOUT_VAL Number of seconds to wait before declaring TIMEOUT error on Get, seconds.
TFTP_SERVER_PORT The TFTP Server Port
5.8.28 UDP TCP/IP Stack Library
5.8.28.1 Introduction
UDP TCP/IP Stack Library
for
Microchip Microcontrollers
This library provides the API of the UDP TCP/IP Module that is available on the Microchip family of microcontrollers with a
convenient C language interface. It is a module that belongs to the TCP/IP stack.
Description
UDP is a standard transport layer protocol described in RFC 768. It provides fast but unreliable data-gram based transfers
over networks, and forms the foundation SNTP, SNMP, DNS, and many other protocol standards.
5.8.28.2 Release Notes
MPLAB Harmony Version: v0.70b UDP TCP/IP Stack Library Version : 1.0 Release Date: 18Nov2013
New This Release:
5.8 TCP/IP Stack Library Help MPLAB Harmony Help UDP TCP/IP Stack Library
5-3930
This is the first release of the library. The interface can change in the beta and\or 1.0 release.
Known Issues:
Nothing to report in this release.
5.8.28.3 SW License Agreement
(c) 2013 Microchip Technology Inc.
Microchip licenses this software to you solely for use with Microchip products. The software is owned by Microchip and its
licensors, and is protected under applicable copyright laws. All rights reserved.
SOFTWARE IS PROVIDED "AS IS" MICROCHIP EXPRESSLY DISCLAIMS ANY WARRANTY OF ANY KIND, WHETHER
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. IN NO EVENT SHALL MICROCHIP BE LIABLE FOR
ANY INCIDENTAL, SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, HARM TO
YOUR EQUIPMENT, COST OF PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY OR SERVICES, ANY CLAIMS
BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), ANY CLAIMS FOR INDEMNITY OR
CONTRIBUTION, OR OTHER SIMILAR COSTS.
To the fullest extent allowed by law, Microchip and its licensors liability shall not exceed the amount of fees, if any, that you have
paid directly to Microchip to use this software.
MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE TERMS.
5.8.28.4 Using the Library
This topic describes the basic architecture of the UDP TCP/IP Stack Library and provides information and examples on how to
use it.
Interface Header File: udp.h
The interface to the UDP TCP/IP Stack library is defined in the "udp.h" header file. This file is included by the "tcpip.h" file. Any C
language source (.c) file that uses the UDP TCP/IP Stack library should include "tcpip.h".
Library File:
The UDP TCPIP Stack library archive (.a) file installed with MPLAB Harmony.
Please refer to the MPLAB Harmony Overview for how the TCP/IP Stack interacts with the framework.
5.8.28.4.1 Abstraction Model
This library provides the API of the UDP TCP/IP Module that is available on the Microchip family of microcontrollers with a
convenient C language interface. It is a module that belongs to the TCP/IP stack.
Description
UDP Software Abstraction Block Diagram
This module provides software abstraction of the UDP module existent in any TCP/IP Stack implementation. It removes the
overhead of address resolution from all other modules in the stack.
5.8 TCP/IP Stack Library Help MPLAB Harmony Help UDP TCP/IP Stack Library
5-3931
Typical UDP Implementation
5.8.28.4.2 Library Overview
The library interface routines are divided into various sub-sections, each of sub-section addresses one of the blocks or the
overall operation of the UDP module.
Library Interface Section Description
Socket Management Functions Routines for Managing UDP Sockets
Transmit Data Transfer Functions Routines for Managing Outgoing Data Transmissions
Receive Data Transfer Functions Routines for Managing Incoming Data Transmissions
Data Types and Constants This section provides various definitions describing This API
5.8.28.4.3 How the Library Works
Connections over UDP should be thought of as data-gram based transfers. Each packet is a separate entity, the application
should expect some packets to arrive out-of-order or even fail to reach the destination node. This is in contrast to TCP, in which
the connection is thought of as a stream and network errors are automatically corrected. These tradeoffs in reliability are made
for an increase in throughput. In general, UDP transfers operate 2 to 3 times faster than those made over TCP.
Since UDP is packet-oriented, each packet must be dealt with in its entirety by your application before returning to the main
stack loop. When a packet is received, your application will be called to handle it. This packet will no longer be available the next
time your application is called, so you must either perform all necessary processing or copy the data elsewhere before returning.
When transmitting a packet, your application must build and transmit the complete packet in one cycle.
5.8.28.4.3.1 Core Functionality
The UDP flow diagram below provides an overview for the use of the UDP module:
Note: This image was not available at time of release and will be added in a future release of MPLAB Harmony.
Sockets are opened using UDPOpen. This function can either open a listening socket to wait for incoming segments, or can
make a client connection to a remote node. When making a client connection, you will need to perform any required DNS and/or
ARP resolution using those modules directly before invoking UDPOpen.
5.8 TCP/IP Stack Library Help MPLAB Harmony Help UDP TCP/IP Stack Library
5-3932
Once the socket is opened, you can immediately begin transmitting data. To transmit a segment, call UDPIsPutReady to
determine how many bytes can be written and to designate a currently active socket. Then, use any of the TCPIP_UDP_Put
family of functions to write data to the socket. Once all data has been written, call TCPIP_UDP_Flush to build and transmit the
packet. This sequence must be accomplished all in one step. If your application returns to the main stack loop after calling
TCPIP_UDP_Put but before calling TCPIP_UDP_Flush, the data may be lost or the module may behave unpredictably.
5.8.28.5 Configuring the Library
Macros
Name Description
UDP_LOCAL_PORT_END_NUMBER Last port number for randomized local port number selection
UDP_LOCAL_PORT_START_NUMBER The dynamic port range defined by IANA consists of the
49152-65535 range and is meant for the selection of ephemeral
ports (RFC 6056). Adjust to your needs but stay within the IANA
range First port number for randomized local port number selection
UDP_MAX_SOCKETS global number of UDP sockets created dynamically
UDP_SOCKET_DEFAULT_TX_QUEUE_LIMIT the maximum number of packets that can be queued by an UDP
socket at a certain time. For sockets that need to transfer a lot of
data (iperf, for example), especially on slow conenctions this limit
prevents running out of memory because the MAC transfer cannot
keep up with the UDP packet allocation rate imposed by the
aapplication. Adjust depending on the
UDP_SOCKET_DEFAULT_TX_SIZE, the connection speed and
the amount of memory available to the stack.
UDP_SOCKET_DEFAULT_TX_SIZE default socket Tx buffer size
UDP_SOCKET_POOL_BUFFER_SIZE size of the buffers in the UDP pool any UDP socket that is enabled
to use the pool and has the TX size <= than this size can use a
buffer from the pool
UDP_SOCKET_POOL_BUFFERS use 0 to disable the feature
UDP_USE_RX_CHECKSUM check incoming packets to have proper checksum
UDP_USE_TX_CHECKSUM This slows UDP TX performance by nearly 50%, except when
using the ENCX24J600, which has a super fast DMA and incurs
virtually no speed pentalty.
Description
The configuration of the UDP TCP/IP Stack Library is based on the file sys_config.h
This header file contains the configuration selection for the UP TCP/IP Stack Library. Based on the selections made, the UDP
TCP/IP Stack Library will support or not support selected features. These configuration settings will apply to all instances of the
UDP TCP/IP Stack Library.
This header can be placed anywhere; however, the path of this header needs to be present in the include search path for a
successful build. Refer to the Applications Overview section for more details.
5.8.28.5.1 UDP_LOCAL_PORT_END_NUMBER Macro
C
#define UDP_LOCAL_PORT_END_NUMBER (65535)
Description
Last port number for randomized local port number selection
5.8 TCP/IP Stack Library Help MPLAB Harmony Help UDP TCP/IP Stack Library
5-3933
5.8.28.5.2 UDP_LOCAL_PORT_START_NUMBER Macro
C
#define UDP_LOCAL_PORT_START_NUMBER (49152)
Description
The dynamic port range defined by IANA consists of the 49152-65535 range and is meant for the selection of ephemeral ports
(RFC 6056). Adjust to your needs but stay within the IANA range First port number for randomized local port number selection
5.8.28.5.3 UDP_MAX_SOCKETS Macro
C
#define UDP_MAX_SOCKETS (10)
Description
global number of UDP sockets created dynamically
5.8.28.5.4 UDP_SOCKET_DEFAULT_TX_QUEUE_LIMIT Macro
C
#define UDP_SOCKET_DEFAULT_TX_QUEUE_LIMIT 3
Description
the maximum number of packets that can be queued by an UDP socket at a certain time. For sockets that need to transfer a lot
of data (iperf, for example), especially on slow conenctions this limit prevents running out of memory because the MAC transfer
cannot keep up with the UDP packet allocation rate imposed by the aapplication. Adjust depending on the
UDP_SOCKET_DEFAULT_TX_SIZE, the connection speed and the amount of memory available to the stack.
5.8.28.5.5 UDP_SOCKET_DEFAULT_TX_SIZE Macro
C
#define UDP_SOCKET_DEFAULT_TX_SIZE 512
Description
default socket Tx buffer size
5.8.28.5.6 UDP_SOCKET_POOL_BUFFER_SIZE Macro
C
#define UDP_SOCKET_POOL_BUFFER_SIZE 512 // size of the buffers in the UDP pool
Description
size of the buffers in the UDP pool any UDP socket that is enabled to use the pool and has the TX size <= than this size can use
a buffer from the pool
5.8 TCP/IP Stack Library Help MPLAB Harmony Help UDP TCP/IP Stack Library
5-3934
5.8.28.5.7 UDP_SOCKET_POOL_BUFFERS Macro
C
#define UDP_SOCKET_POOL_BUFFERS 4 // use 0 to disable the feature
Description
use 0 to disable the feature
5.8.28.5.8 UDP_USE_RX_CHECKSUM Macro
C
#define UDP_USE_RX_CHECKSUM
Description
check incoming packets to have proper checksum
5.8.28.5.9 UDP_USE_TX_CHECKSUM Macro
C
#define UDP_USE_TX_CHECKSUM
Description
This slows UDP TX performance by nearly 50%, except when using the ENCX24J600, which has a super fast DMA and incurs
virtually no speed pentalty.
5.8.28.6 Building the Library
This section list the files that are available in the \src of the UDP driver. It lists which files need to be included in the build based
on either a hardware feature present on the board or configuration option selected by the system.
• udp.c
5.8.28.7 Library Interface
Data Types and Constants
Name Description
INVALID_UDP_SOCKET Indicates a UDP socket that is not valid
TCPIP_UDP_IsOpened backward compatibility call
UDP_MODULE_CONFIG UDP layer configuration/initialization
UDP_PORT Stores a UDP Port Number
UDP_SOCKET Provides a handle to a UDP Socket
UDP_SOCKET_BCAST_TYPE This is type UDP_SOCKET_BCAST_TYPE.
UDP_SOCKET_INFO Information about a socket
UDP_SOCKET_OPTION UDP socket options
5.8 TCP/IP Stack Library Help MPLAB Harmony Help UDP TCP/IP Stack Library
5-3935
Receive Data Transfer Functions
Name Description
TCPIP_UDP_Discard Discards any remaining RX data from a UDP socket.
TCPIP_UDP_Get Reads a byte from the UDP socket.
TCPIP_UDP_GetIsReady Determines how many bytes can be read from the UDP socket.
TCPIP_UDP_RxOffsetSet Moves the pointer within the RX buffer.
Socket Management Functions
Name Description
TCPIP_UDP_BcastIPV4AddressSet Sets the broadcast IP address of a socket Allows an UDP socket to send
broadcasts.
TCPIP_UDP_Bind Bind a socket to a local address and port. This function is meant for client
sockets. It assigns a specific source address and port for a socket.
TCPIP_UDP_ClientOpen Opens a UDP socket as a client.
TCPIP_UDP_Close Closes a UDP socket and frees the handle.
TCPIP_UDP_DestinationIPAddressSet Sets the destination IP address of a socket
TCPIP_UDP_IsConnected Determines if a socket has an established connection.
TCPIP_UDP_OptionsGet Allows getting the options for a socket like: current Rx/Tx buffer size, etc
TCPIP_UDP_OptionsSet Allows setting options to a socket like adjust Rx/Tx buffer size, etc
TCPIP_UDP_RemoteBind Bind a socket to a remote address This function is meant for server
sockets.
TCPIP_UDP_ServerOpen Opens a UDP socket as a server.
TCPIP_UDP_SocketInfoGet Points handle at socket unfo for socket hUDP
TCPIP_UDP_SocketNetGet Gets the network interface of an UDP socket
TCPIP_UDP_SocketNetSet Sets the network interface for an UDP socket
TCPIP_UDP_SourceIPAddressSet Sets the source IP address of a socket
TCPIP_UDP_TxOffsetSet Moves the pointer within the TX buffer.
Transmit Data Transfer Functions
Name Description
TCPIP_UDP_ArrayGet Reads an array of bytes from the UDP socket.
TCPIP_UDP_Flush Transmits all pending data in a UDP socket.
TCPIP_UDP_Put Writes a byte to the UDP socket.
TCPIP_UDP_StringPut Writes null-terminated string to the UDP socket.
TCPIP_UDP_TxCountGet Returns the amount of bytes written into the UDP socket.
TCPIP_UDP_TxPutIsReady Determines how many bytes can be written to the UDP socket.
TCPIP_UDP_ArrayPut Writes an array of bytes to the UDP socket.
UDPIsPutReady Determines how many bytes can be written to the UDP socket.
Description
This section describes the Application Programming Interface (API) functions of the UDP TCP/IP Stack Library.
Refer to each section for a detailed description.
5.8.28.7.1 Socket Management Functions
5.8 TCP/IP Stack Library Help MPLAB Harmony Help UDP TCP/IP Stack Library
5-3936
5.8.28.7.1.1 TCPIP_UDP_BcastIPV4AddressSet Function
C
bool TCPIP_UDP_BcastIPV4AddressSet(
UDP_SOCKET s,
UDP_SOCKET_BCAST_TYPE bcastType,
TCPIP_NET_HANDLE hNet
);
Description
It sets the broadcast address for the socket
Preconditions
UDP initialized UDP socket should have been opened with TCPIP_UDP_ServerOpen()/TCPIP_UDP_ClientOpen()(). s - valid
socket
Parameters
Parameters Description
s the UDP socket
bcastType Type of broadcast
hNet handle of an interface to use for the network directed broadcast Not used for
network limited broadcast
Returns
True if success False otherwise
Remarks
This function allows changing of the destination IPv4 address dynamically.
However, the call will fail if the socket was previously set to broadcast using the TCPIP_UDP_OptionsSet call.
TCPIP_UDP_OptionsSet takes precedence.
5.8.28.7.1.2 TCPIP_UDP_Bind Function
C
bool TCPIP_UDP_Bind(
UDP_SOCKET hUDP,
IP_ADDRESS_TYPE addType,
UDP_PORT localPort,
IP_MULTI_ADDRESS* localAddress
);
Description
Sockets don't need specific binding, it is done automatically by the stack However, specific binding can be requested using these
functions. Works for both client and server sockets.
Preconditions
UDP socket should have been opened with TCPIP_UDP_ServerOpen()/TCPIP_UDP_ClientOpen()(). hUDP - valid socket
Parameters
Parameters Description
hUDP The socket to bind.
addType The type of address being used. Example: IP_ADDRESS_TYPE_IPV4.
localPort The local port to bind to.
5.8 TCP/IP Stack Library Help MPLAB Harmony Help UDP TCP/IP Stack Library
5-3937
localAddress Local address to use.
Returns
True if success False otherwise
Remarks
If localAddress == 0 the local address of the socket won't be changed.
If localPort is 0 the stack will assign a unique local port
5.8.28.7.1.3 TCPIP_UDP_ClientOpen Function
C
UDP_SOCKET TCPIP_UDP_ClientOpen(
IP_ADDRESS_TYPE addType,
UDP_PORT remotePort,
IP_MULTI_ADDRESS* remoteAddress
);
Description
Provides a unified method for opening UDP client sockets.
Preconditions
UDP is initialized.
Parameters
Parameters Description
IP_ADDRESS_TYPE addType The type of address being used. Example: IP_ADDRESS_TYPE_IPV4.
UDP_PORT remotePort The remote UDP port to which a connection should be made. The local port for
client sockets will be automatically picked by the UDP module.
IP_MULTI_ADDRESS* remoteAddress The remote address to connect to.
Returns
INVALID_SOCKET - No sockets of the specified type were available to be opened.
Otherwise - A UDP_SOCKET handle. Save this handle and use it when calling all other UDP APIs.
Remarks
IP_ADDRESS_TYPE_ANY is not supported!
5.8.28.7.1.4 TCPIP_UDP_Close Function
C
void TCPIP_UDP_Close(
UDP_SOCKET hUDP
);
Description
Closes a UDP socket and frees the handle. Call this function to release a socket and return it to the pool for use by future
communications.
Preconditions
UDP socket should have been opened with TCPIP_UDP_ServerOpen()/TCPIP_UDP_ClientOpen()(). hUDP - valid socket
5.8 TCP/IP Stack Library Help MPLAB Harmony Help UDP TCP/IP Stack Library
5-3938
Parameters
Parameters Description
hUDP The socket handle to be released.
Returns
None
5.8.28.7.1.5 TCPIP_UDP_DestinationIPAddressSet Function
C
bool TCPIP_UDP_DestinationIPAddressSet(
UDP_SOCKET s,
IP_ADDRESS_TYPE addType,
IP_MULTI_ADDRESS* remoteAddress
);
Description
• It sets the IP destination address This allows changing the destination IPv4 address dynamically.
Preconditions
UDP initialized UDP socket should have been opened with TCPIP_UDP_ServerOpen()/TCPIP_UDP_ClientOpen()(). s - valid
socket remoteAddress - valid address pointer
Parameters
Parameters Description
s the UDP socket
addType Type of address: IPv4/IPv6
remoteAddress pointer to an address to use
Returns
true if success false otherwise
Remarks
The call will fail if the socket was previously set to broadcast using the TCPIP_UDP_OptionsSet call. TCPIP_UDP_OptionsSet
takes precedence.
The call will fail if remoteAddress is 0. The destination IP address will not be changed.
5.8.28.7.1.6 TCPIP_UDP_IsConnected Function
C
bool TCPIP_UDP_IsConnected(
UDP_SOCKET hUDP
);
Description
This function determines if a socket has an established connection to a remote node . Call this function after calling
TCPIP_UDP_ServerOpen()/TCPIP_UDP_ClientOpen() to determine when the connection is set up and ready for use.
Preconditions
UDP socket should have been opened with TCPIP_UDP_ServerOpen()/TCPIP_UDP_ClientOpen()(). hUDP - valid socket
5.8 TCP/IP Stack Library Help MPLAB Harmony Help UDP TCP/IP Stack Library
5-3939
Parameters
Parameters Description
hUDP The socket to check.
Return Values
Return Values Description
true The socket has been opened and ARP has been resolved.
false The socket is not currently connected.
Remarks
None
5.8.28.7.1.7 TCPIP_UDP_OptionsGet Function
C
bool TCPIP_UDP_OptionsGet(
UDP_SOCKET hUDP,
UDP_SOCKET_OPTION option,
void* optParam
);
Description
Various options can be get at the socket level. This function provides compatibility with BSD implementations.
Preconditions
UDP socket should have been opened with TCPIP_UDP_ServerOpen()/TCPIP_UDP_ClientOpen()(). hUDP - valid socket
Parameters
Parameters Description
hUDP socket to get options for
option specific option to get
optParam pointer to an area that will receive the option value; this is option dependent the
size of the area has to be large enough to accomodate the specific option
UDP_OPTION_STRICT_PORT -- pointer to boolean
UDP_OPTION_STRICT_NET -- pointer to boolean UDP_OPTION_BROADCAST
-- UDP_SOCKET_BCAST_TYPE UDP_OPTION_BUFFER_POOL -- pointer to
boolean UDP_OPTION_TX_BUFF -- pointer to a 16 bit value to receive bytes of
the TX buffer UDP_OPTION_TX_QUEUE_LIMIT -- pointer to an 8 bit value to
receive the TX queue limit
Returns
true if success false otherwise
5.8.28.7.1.8 TCPIP_UDP_OptionsSet Function
C
bool TCPIP_UDP_OptionsSet(
UDP_SOCKET hUDP,
UDP_SOCKET_OPTION option,
void* optParam
);
Description
Various options can be set at the socket level. This function provides compatibility with BSD implementations.
5.8 TCP/IP Stack Library Help MPLAB Harmony Help UDP TCP/IP Stack Library
5-3940
Preconditions
UDP socket should have been opened with TCPIP_UDP_ServerOpen()/TCPIP_UDP_ClientOpen()(). hUDP - valid socket
Parameters
Parameters Description
hUDP socket to set options for
option specific option to be set
optParam the option value; this is option dependent UDP_OPTION_STRICT_PORT --
boolean enable/disable UDP_OPTION_STRICT_NET -- boolean enable/disable
UDP_OPTION_BROADCAST -- UDP_SOCKET_BCAST_TYPE
UDP_OPTION_BUFFER_POOL -- boolean enable/disable
Returns
true if success false otherwise
Remarks
changing the UDP_OPTION_BUFFER_POOL will discard the data in the current socket buffer UDP_OPTION_TX_BUFF -- 16
bit value in bytes of the TX buffer
the UDP_OPTION_TX_BUFF will discard the data in the current socket buffer UDP_OPTION_TX_QUEUE_LIMIT -- 8 bit value
of the TX queue limit
5.8.28.7.1.9 TCPIP_UDP_RemoteBind Function
C
bool TCPIP_UDP_RemoteBind(
UDP_SOCKET hUDP,
IP_ADDRESS_TYPE addType,
UDP_PORT remotePort,
IP_MULTI_ADDRESS* remoteAddress
);
Description
Sockets don't need specific remote binding, they should accept connections on any incoming interface. Thus the binding is done
automatically by the stack. However, specific binding can be requested using these functions. For a server socket it can be used
to restrict accepting connections from a specific remote host. For a client socket it will just change the default binding done when
the socket was opened. TBD: the call should fail if the socket is already bound to an interface (a server socket is connected or a
client socket already sent the data on an interface). Implementation pending
Preconditions
UDP socket should have been opened with TCPIP_UDP_ServerOpen()/TCPIP_UDP_ClientOpen()(). hUDP - valid socket
Parameters
Parameters Description
hUDP The socket to bind.
addType The type of address being used. Example: IP_ADDRESS_TYPE_IPV4.
remotePort The remote port to bind to.
remoteAddress Remote address to use.
Returns
True if success False otherwise
5.8 TCP/IP Stack Library Help MPLAB Harmony Help UDP TCP/IP Stack Library
5-3941
Remarks
If remoteAddress == 0 the remote address of the socket won't be changed. The remote port is always changed, even if
remotePort == 0.
5.8.28.7.1.10 TCPIP_UDP_ServerOpen Function
C
UDP_SOCKET TCPIP_UDP_ServerOpen(
IP_ADDRESS_TYPE addType,
UDP_PORT localPort,
IP_MULTI_ADDRESS* localAddress
);
Description
Provides a unified method for opening UDP server sockets.
Preconditions
UDP is initialized.
Parameters
Parameters Description
IP_ADDRESS_TYPE addType The type of address being used. Example: IP_ADDRESS_TYPE_IPV4.
UDP_PORT localPort UDP port on which to listen for connections
IP_MULTI_ADDRESS* localAddress Local address to use. Can be NULL if any incoming interface will do.
Returns
INVALID_SOCKET - No sockets of the specified type were available to be opened.
Otherwise - A UDP_SOCKET handle. Save this handle and use it when calling all other UDP APIs.
5.8.28.7.1.11 TCPIP_UDP_SocketInfoGet Function
C
bool TCPIP_UDP_SocketInfoGet(
UDP_SOCKET hUDP,
UDP_SOCKET_INFO* pInfo
);
Preconditions
UDP socket should have been opened with TCPIP_UDP_ServerOpen()/TCPIP_UDP_ClientOpen()(). hUDP - valid socket
Parameters
Parameters Description
UDP_SOCKET hUDP Socket to obtain info for.
UDP_SOCKET_INFO* pInfo pointer to reference info location.
5.8.28.7.1.12 TCPIP_UDP_SocketNetGet Function
C
TCPIP_NET_HANDLE TCPIP_UDP_SocketNetGet(
UDP_SOCKET hUDP
);
5.8 TCP/IP Stack Library Help MPLAB Harmony Help UDP TCP/IP Stack Library
5-3942
Description
This function returns the interface handle of an UDP socket
Preconditions
UDP socket should have been opened with TCPIP_UDP_ServerOpen()/TCPIP_UDP_ClientOpen()(). hUDP - valid socket
Parameters
Parameters Description
hUDP The UDP socket
Returns
IHandle of the interface that socket currently uses.
5.8.28.7.1.13 TCPIP_UDP_SocketNetSet Function
C
bool TCPIP_UDP_SocketNetSet(
UDP_SOCKET hUDP,
TCPIP_NET_HANDLE hNet
);
Description
This function sets the network interface for an UDP socket
Preconditions
UDP socket should have been opened with TCPIP_UDP_ServerOpen()/TCPIP_UDP_ClientOpen()(). hUDP - valid socket
Parameters
Parameters Description
hUDP The UDP socket
hNet interface handle
Returns
true if success false otherwise.
Remarks
An invalid hNet can be passed (0) so that the current socket network interface selection will be cleared
5.8.28.7.1.14 TCPIP_UDP_SourceIPAddressSet Function
C
bool TCPIP_UDP_SourceIPAddressSet(
UDP_SOCKET s,
IP_ADDRESS_TYPE addType,
IP_MULTI_ADDRESS* localAddress
);
Description
• It sets the IP source address This allows changing the source IPv4 address dynamically.
Preconditions
UDP initialized UDP socket should have been opened with TCPIP_UDP_ServerOpen()/TCPIP_UDP_ClientOpen()(). s - valid
socket localAddress - valid address pointer
5.8 TCP/IP Stack Library Help MPLAB Harmony Help UDP TCP/IP Stack Library
5-3943
Parameters
Parameters Description
s the UDP socket
addType Type of address: IPv4/IPv6
localAddress pointer to an address to use
Returns
true if success false otherwise
Remarks
The call will fail if localAddress is 0. The source IP address will not be changed.
5.8.28.7.1.15 TCPIP_UDP_TxOffsetSet Function
C
bool TCPIP_UDP_TxOffsetSet(
UDP_SOCKET hUDP,
uint16_t wOffset,
bool relative
);
Description
This function allows the write location within the TX buffer to be specified. Future calls to TCPIP_UDP_Put,
TCPIP_UDP_ArrayPut, TCPIP_UDP_StringPut, etc will write data from the indicated location.
Preconditions
UDP socket should have been opened with TCPIP_UDP_ServerOpen()/TCPIP_UDP_ClientOpen()(). hUDP - valid socket
Parameters
Parameters Description
hUDP UDP socket handle
wOffset Offset in the UDP packet data payload to move the write pointer.
relative if true, the wOffset is added to the current write pointer. else the wOffset is from
the beginning of the UDP buffer
Returns
true if the offset is a valid one false otherwise
5.8.28.7.2 Transmit Data Transfer Functions
5.8.28.7.2.1 TCPIP_UDP_ArrayGet Function
C
uint16_t TCPIP_UDP_ArrayGet(
UDP_SOCKET hUDP,
uint8_t * cData,
uint16_t wDataLen
);
Description
This function reads an array of bytes from the UDP socket, while decrementing the remaining bytes available.
TCPIP_UDP_GetIsReady could be used before calling this function to get the numberof the available bytes in the socket.
5.8 TCP/IP Stack Library Help MPLAB Harmony Help UDP TCP/IP Stack Library
5-3944
Preconditions
UDP socket should have been opened with TCPIP_UDP_ServerOpen()/TCPIP_UDP_ClientOpen()(). hUDP - valid socket
Parameters
Parameters Description
hUDP UDP socket handle
cData The buffer to receive the bytes being read. If NULL, the bytes are simply discarded
without being written anywhere (effectively skips over the bytes in the RX buffer,
although if you need to skip a lot of data, seeking using the
TCPIP_UDP_RxOffsetSet() will be more efficient).
wDateLen Number of bytes to be read from the socket.
Returns
The number of bytes successfully read from the UDP buffer. If this value is less than wDataLen, then the buffer was emptied and
no more data is available.
5.8.28.7.2.2 TCPIP_UDP_Flush Function
C
uint16_t TCPIP_UDP_Flush(
UDP_SOCKET hUDP
);
Description
This function builds a UDP packet with the pending TX data and marks it for transmission over the network interface. There is no
UDP state machine to send the socket data automatically. The UDP socket client must call this function to actually send the data
over the network.
Preconditions
UDP socket should have been opened with TCPIP_UDP_ServerOpen()/TCPIP_UDP_ClientOpen()(). hUDP - valid socket
Parameters
Parameters Description
hUDP UDP socket handle
Returns
The number of bytes that currently were in the socket TX buffer and have been flushed.
Remarks
Note that unlike TCPIP_TCP_Flush, TCPIP_UDP_Flush must be called before returning to the main stack loop. There is no auto
transmit for UDP segments.
5.8.28.7.2.3 TCPIP_UDP_Put Function
C
uint16_t TCPIP_UDP_Put(
UDP_SOCKET hUDP,
uint8_t v
);
Description
This function writes a single byte to the UDP socket, while incrementing the buffer length. TCPIP_UDP_TxPutIsReady could be
used before calling this function to verify that there is room in the socket buffer.
5.8 TCP/IP Stack Library Help MPLAB Harmony Help UDP TCP/IP Stack Library
5-3945
Preconditions
UDP socket should have been opened with TCPIP_UDP_ServerOpen()/TCPIP_UDP_ClientOpen()(). hUDP - valid socket
Parameters
Parameters Description
hUDP UDP socket handle
v The byte to be loaded into the transmit buffer.
Return Values
Return Values Description
1 The byte was successfully written to the socket.
0 The transmit buffer is already full and so the write failed.
Remarks
The following function is very inefficient. A buffered approach (TCPIP_UDP_ArrayPut) should be preferred
5.8.28.7.2.4 TCPIP_UDP_StringPut Function
C
const uint8_t* TCPIP_UDP_StringPut(
UDP_SOCKET hUDP,
const uint8_t * strData
);
Description
This function writes a null-terminated string to the UDP socket while incrementing the buffer length. TCPIP_UDP_TxPutIsReady
could be used before calling this function to verify that there is room in the socket buffer.
Preconditions
UDP socket should have been opened with TCPIP_UDP_ServerOpen()/TCPIP_UDP_ClientOpen()(). hUDP - valid socket
Parameters
Parameters Description
hUDP UDP socket handle
cData Pointer to the string to be written to the socket.
Returns
A pointer to the byte following the last byte written. Note that this is different than the TCPIP_UDP_ArrayPut functions. If this
pointer does not dereference to a NULL byte, then the buffer became full and the input data was truncated.
5.8.28.7.2.5 TCPIP_UDP_TxCountGet Function
C
uint16_t TCPIP_UDP_TxCountGet(
UDP_SOCKET hUDP
);
Description
This function returns the amount of bytes written into the UDP socket,
Preconditions
UDP socket should have been opened with TCPIP_UDP_ServerOpen()/TCPIP_UDP_ClientOpen()(). hUDP - valid socket
5.8 TCP/IP Stack Library Help MPLAB Harmony Help UDP TCP/IP Stack Library
5-3946
Parameters
Parameters Description
hUDP UDP socket handle
5.8.28.7.2.6 TCPIP_UDP_TxPutIsReady Function
C
uint16_t TCPIP_UDP_TxPutIsReady(
UDP_SOCKET hUDP,
unsigned short count
);
Description
This function determines how many bytes can be written to the specified UDP socket.
Preconditions
UDP socket should have been opened with TCPIP_UDP_ServerOpen()/TCPIP_UDP_ClientOpen()(). hUDP - valid socket
Parameters
Parameters Description
hUDP UDP socket handle
count Number of bytes requested
Returns
The number of bytes that can be written to this socket.
Remarks
The function won't increase the size of the UDP TX buffer. If this is needed use TCPIP_UDP_OptionsSet(). The count variable is
not used.
5.8.28.7.2.7 TCPIP_UDP_ArrayPut Function
C
uint16_t TCPIP_UDP_ArrayPut(
UDP_SOCKET hUDP,
const uint8_t * cData,
uint16_t wDataLen
);
Description
This function writes an array of bytes to the UDP socket, while incrementing the buffer length. TCPIP_UDP_TxPutIsReady could
be used before calling this function to verify that there is room in the socket buffer.
Preconditions
UDP socket should have been opened with TCPIP_UDP_ServerOpen()/TCPIP_UDP_ClientOpen()(). hUDP - valid socket
Parameters
Parameters Description
cData The array to write to the socket.
wDateLen Number of bytes from cData to be written.
Returns
The number of bytes successfully placed in the UDP transmit buffer. If this value is less than wDataLen, then the buffer became
5.8 TCP/IP Stack Library Help MPLAB Harmony Help UDP TCP/IP Stack Library
5-3947
full and the input was truncated.
5.8.28.7.2.8 UDPIsPutReady Function
C
uint16_t UDPIsPutReady(
UDP_SOCKET hUDP
);
Description
This function determines how many bytes can be written to the specified UDP socket.
Preconditions
UDP socket should have been opened with TCPIP_UDP_ServerOpen()/TCPIP_UDP_ClientOpen()(). hUDP - valid socket
Parameters
Parameters Description
hUDP UDP socket handle
Returns
The number of bytes that can be written to this socket.
Remarks
The function is similar to the TCPIP_UDP_TxPutIsReady and maintained for backward compatibility.
5.8.28.7.3 Receive Data Transfer Functions
5.8.28.7.3.1 TCPIP_UDP_Discard Function
C
void TCPIP_UDP_Discard(
UDP_SOCKET hUDP
);
Description
This function discards any remaining received data in the UDP socket.
Preconditions
UDP socket should have been opened with TCPIP_UDP_ServerOpen()/TCPIP_UDP_ClientOpen()(). hUDP - valid socket
Parameters
Parameters Description
hUDP socket handle
Returns
None
Remarks
It is safe to call this function more than is necessary. If no data is available, this function does nothing.
5.8 TCP/IP Stack Library Help MPLAB Harmony Help UDP TCP/IP Stack Library
5-3948
5.8.28.7.3.2 TCPIP_UDP_Get Function
C
uint16_t TCPIP_UDP_Get(
UDP_SOCKET hUDP,
uint8_t * v
);
Description
This function reads a single byte from the UDP socket, while decrementing the remaining buffer length.
TCPIP_UDP_GetIsReady could be used before calling this function to get the number of bytes available in the socket.
Preconditions
UDP socket should have been opened with TCPIP_UDP_ServerOpen()/TCPIP_UDP_ClientOpen()(). hUDP - valid socket
Parameters
Parameters Description
hUDP socket handle
v The buffer to receive the data being read.
Return Values
Return Values Description
1 A byte was successfully read
0 No data remained in the read buffer or invalid socket
Remarks
The following function is very inefficient. A buffered approach (TCPIP_UDP_ArrayGet) should be preferred
5.8.28.7.3.3 TCPIP_UDP_GetIsReady Function
C
uint16_t TCPIP_UDP_GetIsReady(
UDP_SOCKET hUDP
);
Description
This function determines if bytes can be read from the specified UDP socket.
Preconditions
UDP socket should have been opened with TCPIP_UDP_ServerOpen()/TCPIP_UDP_ClientOpen()(). hUDP - valid socket
Parameters
Parameters Description
hUDP UDP socket handle
Returns
The number of bytes that can be read from this socket.
5.8.28.7.3.4 TCPIP_UDP_RxOffsetSet Function
C
void TCPIP_UDP_RxOffsetSet(
UDP_SOCKET hUDP,
5.8 TCP/IP Stack Library Help MPLAB Harmony Help UDP TCP/IP Stack Library
5-3949
uint16_t rOffset
);
Description
This function allows the read location within the RX buffer to be specified. Future calls to TCPIP_UDP_Get and
TCPIP_UDP_ArrayGet will read data from the indicated location forward.
Preconditions
UDP socket should have been opened with TCPIP_UDP_ServerOpen()/TCPIP_UDP_ClientOpen()(). hUDP - valid socket
Parameters
Parameters Description
hUDP UDP socket handle
wOffset Offset from beginning of UDP packet data payload to place the read pointer.
Returns
None
5.8.28.7.4 Data Types and Constants
5.8.28.7.4.1 INVALID_UDP_SOCKET Macro
C
#define INVALID_UDP_SOCKET (-1) // Indicates a UDP socket that is not valid
Description
Indicates a UDP socket that is not valid
5.8.28.7.4.2 TCPIP_UDP_IsOpened Macro
C
#define TCPIP_UDP_IsOpened(s) TCPIP_UDP_IsConnected(s)
Description
backward compatibility call
5.8.28.7.4.3 UDP_MODULE_CONFIG Structure
C
typedef struct {
uint16_t nSockets;
uint16_t sktTxBuffSize;
uint16_t poolBuffers;
uint16_t poolBufferSize;
} UDP_MODULE_CONFIG;
Description
UDP layer configuration/initialization
Members
Members Description
uint16_t nSockets; number of sockets to be created
5.8 TCP/IP Stack Library Help MPLAB Harmony Help UDP TCP/IP Stack Library
5-3950
uint16_t sktTxBuffSize; size of the socket tx buffer
uint16_t poolBuffers; number of buffers in the pool; 0 if none
uint16_t poolBufferSize; size of the buffers in the pool; all equal
5.8.28.7.4.4 UDP_PORT Type
C
typedef uint16_t UDP_PORT;
Description
Stores a UDP Port Number
5.8.28.7.4.5 UDP_SOCKET Type
C
typedef int16_t UDP_SOCKET;
Description
Provides a handle to a UDP Socket
5.8.28.7.4.6 UDP_SOCKET_BCAST_TYPE Enumeration
C
typedef enum {
UDP_BCAST_NONE,
UDP_BCAST_NETWORK_LIMITED,
UDP_BCAST_NETWORK_DIRECTED
} UDP_SOCKET_BCAST_TYPE;
Description
This is type UDP_SOCKET_BCAST_TYPE.
Members
Members Description
UDP_BCAST_NONE no broadcast
UDP_BCAST_NETWORK_LIMITED network limited broadcast
UDP_BCAST_NETWORK_DIRECTED network directed broadcast
5.8.28.7.4.7 UDP_SOCKET_INFO Structure
C
typedef struct {
IP_ADDRESS_TYPE addressType;
IP_MULTI_ADDRESS remoteIPaddress;
IP_MULTI_ADDRESS localIPaddress;
UDP_PORT remotePort;
UDP_PORT localPort;
} UDP_SOCKET_INFO;
Description
Information about a socket
5.8 TCP/IP Stack Library Help MPLAB Harmony Help UDP TCP/IP Stack Library
5-3951
Members
Members Description
UDP_PORT remotePort; Port number associated with remote node
UDP_PORT localPort; local port number
5.8.28.7.4.8 UDP_SOCKET_OPTION Enumeration
C
typedef enum {
UDP_OPTION_STRICT_PORT,
UDP_OPTION_STRICT_NET,
UDP_OPTION_BROADCAST,
UDP_OPTION_BUFFER_POOL,
UDP_OPTION_TX_BUFF,
UDP_OPTION_TX_QUEUE_LIMIT
} UDP_SOCKET_OPTION;
Description
UDP socket options
Members
Members Description
UDP_OPTION_STRICT_PORT When connection is done the socket stores the remote host local port. If option is
enabled the remote host local port is always checked to match the initial one. If
disabled the remote host local port is not checked. Disabled by default on a socket
server. Enabled by default on a client socket.
UDP_OPTION_STRICT_NET When connection is done the socket stores th enetwork interface the connection
occurred on. If option is enabled the socket accepts data only from the interface
that matches the initial connection. If disabled the socket receives data from any
remote host irrespective of the interface on which the packet arrived. Disabled by
default on a socket server. Enabled by default on a client socket.
UDP_OPTION_BROADCAST Enables the Broadcast transmission by the socket
UDP_OPTION_BUFFER_POOL Enables the socket to use the private UDP buffers pool. The size of the TX buffer
has to be less than the size of the buffers in the pool
UDP_OPTION_TX_BUFF request different TX buffer size. Has to call TCPIP_UDP_OptionsGet to see the
exact space allocated
UDP_OPTION_TX_QUEUE_LIMIT Sets the maximum number of packets that can be queued/allocated by an UDP
socket at a certain time. For sockets that need to transmit a lot of data (iperf client,
for example), especially on slow conenctions this limit prevents running out of
memory because the MAC transfer cannot keep up with the UDP packet allocation
rate imposed by the aapplication. Adjust depending on the size of the UDP TX
buffer, the connection speed and the amount of memory available to the stack.
5.8.28.8 Files
Files
Name Description
udp.h
udp_config.h UDP onfiguration file
Description
5.8 TCP/IP Stack Library Help MPLAB Harmony Help UDP TCP/IP Stack Library
5-3952
5.8.28.8.1 udp.h
UDP Module Defs for Microchip TCP/IP Stack
Enumerations
Name Description
UDP_SOCKET_BCAST_TYPE This is type UDP_SOCKET_BCAST_TYPE.
UDP_SOCKET_OPTION UDP socket options
Functions
Name Description
TCPIP_UDP_ArrayGet Reads an array of bytes from the UDP socket.
TCPIP_UDP_ArrayPut Writes an array of bytes to the UDP socket.
TCPIP_UDP_BcastIPV4AddressSet Sets the broadcast IP address of a socket Allows an UDP socket to send
broadcasts.
TCPIP_UDP_Bind Bind a socket to a local address and port. This function is meant for client
sockets. It assigns a specific source address and port for a socket.
TCPIP_UDP_ClientOpen Opens a UDP socket as a client.
TCPIP_UDP_Close Closes a UDP socket and frees the handle.
TCPIP_UDP_DestinationIPAddressSet Sets the destination IP address of a socket
TCPIP_UDP_Discard Discards any remaining RX data from a UDP socket.
TCPIP_UDP_Flush Transmits all pending data in a UDP socket.
TCPIP_UDP_Get Reads a byte from the UDP socket.
TCPIP_UDP_GetIsReady Determines how many bytes can be read from the UDP socket.
TCPIP_UDP_IsConnected Determines if a socket has an established connection.
TCPIP_UDP_OptionsGet Allows getting the options for a socket like: current Rx/Tx buffer size, etc
TCPIP_UDP_OptionsSet Allows setting options to a socket like adjust Rx/Tx buffer size, etc
TCPIP_UDP_Put Writes a byte to the UDP socket.
TCPIP_UDP_RemoteBind Bind a socket to a remote address This function is meant for server
sockets.
TCPIP_UDP_RxOffsetSet Moves the pointer within the RX buffer.
TCPIP_UDP_ServerOpen Opens a UDP socket as a server.
TCPIP_UDP_SocketInfoGet Points handle at socket unfo for socket hUDP
TCPIP_UDP_SocketNetGet Gets the network interface of an UDP socket
TCPIP_UDP_SocketNetSet Sets the network interface for an UDP socket
TCPIP_UDP_SourceIPAddressSet Sets the source IP address of a socket
TCPIP_UDP_StringPut Writes null-terminated string to the UDP socket.
TCPIP_UDP_TxCountGet Returns the amount of bytes written into the UDP socket.
TCPIP_UDP_TxOffsetSet Moves the pointer within the TX buffer.
TCPIP_UDP_TxPutIsReady Determines how many bytes can be written to the UDP socket.
UDPIsPutReady Determines how many bytes can be written to the UDP socket.
Macros
Name Description
INVALID_UDP_SOCKET Indicates a UDP socket that is not valid
TCPIP_UDP_IsOpened backward compatibility call
5.8 TCP/IP Stack Library Help MPLAB Harmony Help UDP TCP/IP Stack Library
5-3953
Structures
Name Description
UDP_MODULE_CONFIG UDP layer configuration/initialization
UDP_SOCKET_INFO Information about a socket
Types
Name Description
UDP_PORT Stores a UDP Port Number
UDP_SOCKET Provides a handle to a UDP Socket
5.8.28.8.2 udp_config.h
User Datagram Protocol (UDP) Configuration file
This file contains the UDP module configuration options
Macros
Name Description
UDP_LOCAL_PORT_END_NUMBER Last port number for randomized local port number selection
UDP_LOCAL_PORT_START_NUMBER The dynamic port range defined by IANA consists of the
49152-65535 range and is meant for the selection of ephemeral
ports (RFC 6056). Adjust to your needs but stay within the IANA
range First port number for randomized local port number selection
UDP_MAX_SOCKETS global number of UDP sockets created dynamically
UDP_SOCKET_DEFAULT_TX_QUEUE_LIMIT the maximum number of packets that can be queued by an UDP
socket at a certain time. For sockets that need to transfer a lot of
data (iperf, for example), especially on slow conenctions this limit
prevents running out of memory because the MAC transfer cannot
keep up with the UDP packet allocation rate imposed by the
aapplication. Adjust depending on the
UDP_SOCKET_DEFAULT_TX_SIZE, the connection speed and
the amount of memory available to the stack.
UDP_SOCKET_DEFAULT_TX_SIZE default socket Tx buffer size
UDP_SOCKET_POOL_BUFFER_SIZE size of the buffers in the UDP pool any UDP socket that is enabled
to use the pool and has the TX size <= than this size can use a
buffer from the pool
UDP_SOCKET_POOL_BUFFERS use 0 to disable the feature
UDP_USE_RX_CHECKSUM check incoming packets to have proper checksum
UDP_USE_TX_CHECKSUM This slows UDP TX performance by nearly 50%, except when
using the ENCX24J600, which has a super fast DMA and incurs
virtually no speed pentalty.
5.8.29 Zeroconf TCP/IP Stack Library
5.8 TCP/IP Stack Library Help MPLAB Harmony Help Zeroconf TCP/IP Stack Library
5-3954
5.8.29.1 Introduction
Zero Configuration (Zeroconf) TCP/IP Stack Library
for
Microchip Microcontrollers
This library provides the API of the Zero Conf TCP/IP Module that is available on the Microchip family of microcontrollers with a
convenient C language interface. It is a module that belongs to the TCP/IP stack.
Description
Zero configuration (Zeroconf), provides a mechanism to ease the configuration of a device on a network. It also provides for a
more human-like naming convention, instead of relying on IP addresses alone. Zeroconf also goes by the names Bonjour
(Apple) and Avahi (Linux), and is an IETF standard.
5.8.29.2 Release Notes
MPLAB Harmony Version: v0.70b Zero Conf TCP/IP Stack Library Version : 1.0 Release Date: 18Nov2013
New This Release:
This is the first release of the library. The interface can change in the beta and\or 1.0 release.
Known Issues:
Nothing to report in this release.
5.8.29.3 SW License Agreement
(c) 2013 Microchip Technology Inc.
Microchip licenses this software to you solely for use with Microchip products. The software is owned by Microchip and its
licensors, and is protected under applicable copyright laws. All rights reserved.
SOFTWARE IS PROVIDED "AS IS" MICROCHIP EXPRESSLY DISCLAIMS ANY WARRANTY OF ANY KIND, WHETHER
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. IN NO EVENT SHALL MICROCHIP BE LIABLE FOR
ANY INCIDENTAL, SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, HARM TO
YOUR EQUIPMENT, COST OF PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY OR SERVICES, ANY CLAIMS
BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), ANY CLAIMS FOR INDEMNITY OR
CONTRIBUTION, OR OTHER SIMILAR COSTS.
To the fullest extent allowed by law, Microchip and its licensors liability shall not exceed the amount of fees, if any, that you have
paid directly to Microchip to use this software.
MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE TERMS.
5.8.29.4 Using the Library
This topic describes the basic architecture of the Zeroconf TCP/IP Stack Library and provides information and examples on how
to use it.
5.8 TCP/IP Stack Library Help MPLAB Harmony Help Zeroconf TCP/IP Stack Library
5-3955
Interface Header Files: zero_conf_helper.h, zero_conf_link_local.h, and zero_conf_multicast_dns.h
The interface to the Zeroconf TCP/IP Stack library is defined in the "zero_conf_helper.h", "zero_conf_link_local.h", and
"zero_conf_multicast_dns.h" header files. This file is included by the "tcpip.h" file. Any C language source (.c) file that uses the
Zeroconf TCP/IP Stack library should include "tcpip.h".
Library File:
The Zeroconf TCP/IP Stack library archive (.a) file installed with MPLAB Harmony.
Please refer to the MPLAB Harmony Overview for how the TCP/IP Stack interacts with the framework.
5.8.29.4.1 Abstraction Model
This library provides the API of the Zeroconf TCP/IP Module that is available on the Microchip family of microcontrollers with a
convenient C language interface. It is a module that belongs to the TCP/IP stack.
Description
Zero Conf Software Abstraction Block
Note: This image was not available at time of release and will be added in a future release of MPLAB Harmony.
5.8.29.4.2 Library Overview
The library interface routines are divided into various sub-sections, each of sub-section addresses one of the blocks or the
overall operation of the Zeroconf module.
Library Interface Section Description
Multicast DNS Functions This section provides multicast DNS interface routines to Zeroconf
Link Local Functions This section provides Link Local interface routines to Zeroconf
Data Types and Constants This section provides various definitions describing this API
5.8.29.4.3 Core Functionality
5.8.29.4.3.1 Enabling
Zeroconf can be enabled by setting the following two defines in TCPIPConfig.h:
• STACK_USE_ZEROCONF_LINK_LOCAL
• STACK_USE_ZEROCONF_MDNS_SD
Currently, the use of Zeroconf is limited to the W-iFi demo applications (and the MRF24WB0M module). Future versions of the
stack should enable Zeroconf support across all Ethernet solutions.
5.8.29.4.3.2 Link Local (Zeroconf)
The first component of Zeroconf is the ability to self-assign an IP address to each member of a network. Normally, a DHCP
server would handle such situations. However, in cases where no DHCP server exists, Zeroconf enabled devices negotiate
unique IP addresses amongst themselves.
5.8 TCP/IP Stack Library Help MPLAB Harmony Help Zeroconf TCP/IP Stack Library
5-3956
5.8.29.4.3.3 mDNS
The second component of Zeroconf is the ability to self-assign human-readable hostnames for themselves. Multicast DNS
provides a local network the ability to have the features of a DNS server. Users can use easily remembered hostnames to
accesses the devices on the network. In the event that devices elect to use the same hostname, as in the IP address resolution,
each of the devices will auto-negotiate new names for themselves (usually by appending a number to the end of the name).
5.8.29.4.3.4 Service Discovery
The last component of Zeroconf is service discovery. All Zeroconf devices can broadcast what services they provide. For
instance, a printer can broadcast that it has printing services available. A thermostat can broadcast that it has an HVAC control
service. Other interested parties on the network who are looking for certain services can then see a list of devices that have the
capability of providing the service, and connect directly to it. This further eliminates the need to know whether something exists
on a network (and what it's IP or hostname is). As an end-user, all you would need to do is query the network if a certain service
exists, and easily connect to it.
5.8.29.4.3.5 Demonstration
The demo, when enabled, shows all three items above working together. Each development kit in the network assumes the
hostname of MCHPBOARD-x.local, where x is an incrementing number from 1 (only in the case where multiple kits are
programmed for the network). Each board will broadcast it's service, which is the DemoWebServer.
5.8.29.4.3.6 Zeroconf Enabled Environments
All Apple products have Zeroconf enabled by default. On Windows, you'll need to download the Safari web browser, and during
the install, enable support for Bonjour. Note that in the Safari browser, you can browse and see a list of all Bonjour enabled
devices, and click through to them automatically.
5.8.29.5 Configuring the Library
The configuration of the Zeroconf TCP/IP Stack Library is based on the file tcpip_config.h
This header file contains the configuration selection for the Zeroconf TCP/IP Stack Library. Based on the selections made, the
Zeroconf TCP/IP Stack Library will support or not support selected features. These configuration settings will apply to all
instances of the Zeroconf TCP/IP Stack Library.
This header can be placed anywhere; however, the path of this header needs to be present in the include search path for a
successful build. Refer to the Applications Overview section for more details.
5.8.29.6 Building the Library
This section list the files that are available in the \src of the Zeroconf driver. It lists which files need to be included in the build
based on either a hardware feature present on the board or configuration option selected by the system.
5.8 TCP/IP Stack Library Help MPLAB Harmony Help Zeroconf TCP/IP Stack Library
5-3957
5.8.29.7 Library Interface
Data Types and Constants
Name Description
MDNSD_ERR_CODE void DisplayHostName(uint8_t *HostName);
ZCLL_MODULE_CONFIG Placeholder for Zero Configuration Link Layer module configuration.
Link Local Functions
Name Description
TCPIP_ZCLL_Disable disables the ZCLL on an interface
TCPIP_ZCLL_Enable enables ZCLL on an interface
TCPIP_ZCLL_IsEnabled returns true if ZCLL is currently enabled on that interface
Multicast DNS Functions
Name Description
TCPIP_MDNS_ServiceDeregister DNS-Service Discovery API for end-user to De-register a
service-advertisement, which was previously registered with
TCPIP_MDNS_ServiceRegister API.
TCPIP_MDNS_ServiceRegister DNS-Service Discovery API for end-users to register a service-advertisement.
The service is associated with all interfaces.
TCPIP_MDNS_ServiceUpdate DNS-Service Discovery API for end-user to update the service -advertisement,
which was previously registered with TCPIP_MDNS_ServiceRegister
Description
This section describes the Application Programming Interface (API) functions of the Zeroconf TCP/IP Stack.
Refer to each section for a detailed description.
5.8.29.7.1 Multicast DNS Functions
5.8.29.7.1.1 TCPIP_MDNS_ServiceDeregister Function
C
MDNSD_ERR_CODE TCPIP_MDNS_ServiceDeregister(
TCPIP_NET_HANDLE netH
);
Description
This API is used by end-user application to de-register DNS-Service Discovery on a local network. When this gets invoked by
end-user DNS-SD stack sends out Good-Bye packets to update all peer machines that service will no longer be present. All peer
machines remove the corresponding entry from Browser list.
This is the last API that needs to be invoked by end-user application to free-up the DNS-SD stack for some other app.
Preconditions
TCPIP_MDNS_ServiceRegister must be invoked before this call.
Parameters
Parameters Description
netH handle of the network to be de-registered
5.8 TCP/IP Stack Library Help MPLAB Harmony Help Zeroconf TCP/IP Stack Library
5-3958
Returns
MDNSD_ERR_CODE - Returns Error-code to indicate registration is success or not. 1) MDNSD_SUCCESS - returns on
success of call 2) MDNSD_ERR_INVAL - When the input parameters are invalid or if the API is invoked in invalid state
5.8.29.7.1.2 TCPIP_MDNS_ServiceRegister Function
C
MDNSD_ERR_CODE TCPIP_MDNS_ServiceRegister(
TCPIP_NET_HANDLE netH,
const char * srv_name,
const char * srv_type,
uint16_t port,
const uint8_t * txt_record,
uint8_t auto_rename,
void (*call_back)(char *name, MDNSD_ERR_CODE err, void *context),
void * context
);
Description
DNS-Service Discovery APIs
************************************************************
This API is used by end-user application to announce its service on local network. All peer machines that are compliant with
Multicast-DNS & DNS-Service Discovery protocol can detect the announcement and lists out an entry in Service-Browser list.
End-User selects an entry to connect to this service. So ultimately this is an aid to end-user to discover any service of interest on
a local network.
This is the first API that needs to be invoked by end-user application. Presently Multicast-DNS & Service-discovery stack
supports only single service-advertisement. Once the application wants to terminate the service it has to invoke
TCPIP_MDNS_ServiceDeregister() API to free-up the DNS-SD stack for some other application.
Preconditions
None
Parameters
Parameters Description
netH handle of the network to be registered
srv_name Service Name, which is being advertised
srv_type For a HTTP-Service its "_http._tcp.local"
_http is application protocol preceeded with under-score
_tcp is lower-layer protocol on which service runs
local is to represent service is on local-network
For a iTunes Music Sharing "_daap._tcp.local" For a Priniting Service
"_ipp._tcp.local" Refer to http://www.dns-sd.org/ServiceTypes.html for more
service types
port Port number on which service is running
txt_len For additional information about service like default page (eg "index.htm") for
HTTP-service. Length of such additional information
txt_record String of additional information (eg "index.htm") for HTTP-service.
auto_rename A flag to indicate DNS-SD stack, whether to rename the service automatically or
not. If this is set to '0' Callback parameter will be used to indicate the conflict error
and user has to select different name and re-register with this API. If this is set to
'1' service-name will be automatically renamed with numerical suffix.
5.8 TCP/IP Stack Library Help MPLAB Harmony Help Zeroconf TCP/IP Stack Library
5-3959
callback Callback function, which is user-application defined.
This callback gets invoked on completion of
service
advertisement. If an service name-conflit error is detected and auto_rename is set
to '0' callback gets invoked with MDNSD_ERR_CONFLICT as error-code.
context Opaque context (pointer to opaque data), which needs to be used in callback
function.
Returns
MDNSD_ERR_CODE - Returns Error-code to indicate registration is success or not. 1) MDNSD_SUCCESS - returns on
success of call 2) MDNSD_ERR_BUSY - When already some other service is being advertised using this DNS-SD stack 3)
MDNSD_ERR_INVAL - Invalid Parameter
5.8.29.7.1.3 TCPIP_MDNS_ServiceUpdate Function
C
MDNSD_ERR_CODE TCPIP_MDNS_ServiceUpdate(
TCPIP_NET_HANDLE netH,
uint16_t port,
const uint8_t * txt_record
);
Description
This API is used by end-user application to update its service which was previously registered. With this API end-user app
update the port number on which the service is running. It can update the additional information of service. For example: the
default page can be updated to new page and corresponding page name can be input to this API to update all peer machines.
The modified service will be announced with new contents on local network.
This is an optional API and hsould be invoked only if it is necessary.
Preconditions
TCPIP_MDNS_ServiceRegister must be invoked before this call.
Parameters
Parameters Description
netH handle of the network to perform the service update
port Port number on which service is running
txt_record String of additional information (eg "index.htm") for HTTP-service.
Returns
MDNSD_ERR_CODE - Returns Error-code to indicate registration is success or not. 1) MDNSD_SUCCESS - returns on
success of call 2) MDNSD_ERR_INVAL - When the input parameters are invalid or if the API is invoked in invalid state
5.8.29.7.2 Link Local Functions
5.8.29.7.2.1 TCPIP_ZCLL_Disable Function
C
bool TCPIP_ZCLL_Disable(
TCPIP_NET_HANDLE hNet
);
Description
disables the ZCLL on an interface
5.8 TCP/IP Stack Library Help MPLAB Harmony Help Zeroconf TCP/IP Stack Library
5-3960
5.8.29.7.2.2 TCPIP_ZCLL_Enable Function
C
bool TCPIP_ZCLL_Enable(
TCPIP_NET_HANDLE hNet
);
Description
enables ZCLL on an interface
5.8.29.7.2.3 TCPIP_ZCLL_IsEnabled Function
C
bool TCPIP_ZCLL_IsEnabled(
TCPIP_NET_HANDLE hNet
);
Description
returns true if ZCLL is currently enabled on that interface
5.8.29.7.3 Data Types and Constants
5.8.29.7.3.1 MDNSD_ERR_CODE Enumeration
C
typedef enum {
MDNSD_SUCCESS = 0,
MDNSD_ERR_BUSY = 1,
MDNSD_ERR_CONFLICT = 2,
MDNSD_ERR_INVAL = 3
} MDNSD_ERR_CODE;
Description
void DisplayHostName(uint8_t *HostName);
Members
Members Description
MDNSD_ERR_BUSY = 1 Already Being used for another Service
MDNSD_ERR_CONFLICT = 2 Name Conflict
MDNSD_ERR_INVAL = 3 Invalid Parameter
5.8.29.7.3.2 ZCLL_MODULE_CONFIG Structure
C
typedef struct {
} ZCLL_MODULE_CONFIG;
Description
Placeholder for Zero Configuration Link Layer module configuration.
5.8 TCP/IP Stack Library Help MPLAB Harmony Help Zeroconf TCP/IP Stack Library
5-3961
5.8.29.8 Files
Files
Name Description
zero_conf_link_local.h
zero_conf_multicast_dns.h This is file zero_conf_multicast_dns.h.
Description
5.8.29.8.1 zero_conf_link_local.h
Zero Confiruation (Zeroconf) IPV4 Link Local Addressing Module for Microchip TCP/IP Stack
Functions
Name Description
TCPIP_ZCLL_Disable disables the ZCLL on an interface
TCPIP_ZCLL_Enable enables ZCLL on an interface
TCPIP_ZCLL_IsEnabled returns true if ZCLL is currently enabled on that interface
Structures
Name Description
ZCLL_MODULE_CONFIG Placeholder for Zero Configuration Link Layer module configuration.
5.8.29.8.2 zero_conf_multicast_dns.h
This is file zero_conf_multicast_dns.h.
Enumerations
Name Description
MDNSD_ERR_CODE void DisplayHostName(uint8_t *HostName);
Functions
Name Description
TCPIP_MDNS_ServiceDeregister DNS-Service Discovery API for end-user to De-register a
service-advertisement, which was previously registered with
TCPIP_MDNS_ServiceRegister API.
TCPIP_MDNS_ServiceRegister DNS-Service Discovery API for end-users to register a service-advertisement.
The service is associated with all interfaces.
TCPIP_MDNS_ServiceUpdate DNS-Service Discovery API for end-user to update the service -advertisement,
which was previously registered with TCPIP_MDNS_ServiceRegister
5.8 TCP/IP Stack Library Help MPLAB Harmony Help Zeroconf TCP/IP Stack Library
5-3962
5.9 USB Library Help
5.9.1 USB Device Library - Getting Started
5.9.1.1 Introduction
Provides an introduction to the MPLAB Harmony USB Device Library
Description
The MPLAB Harmony USB Device Library (referred to as the USB Device Library) provides embedded application developers
with a framework to design and develop a wide variety of USB Devices. A choice of Full Speed only or Full Speed and Hi-Speed
USB operations are available, depending on the selected PIC32 microcontroller. The USB Device Library facilitates development
of standard USB devices through function drivers that implement standard USB Device class specification. Custom USB devices
can also be implemented via a Generic Function driver. The USB Device Library is modular, thus allowing application developers
to readily design composite USB devices. The USB Device Library is a part of the MPLAB Harmony installation and is
accompanied by demonstration applications that highlight library usage. These demonstrations can also be modified or updated
to build custom applications. The USB Device Library also features the following:
- Support for different USB device classes (CDC, Audio, HID, MSC and Generic)
- Supports multiple instance of the same class in a composite device
- Supports multiple configurations at different speeds
- Supports full speed and high speed operation
- Supports multiple USB peripherals (allows multiple device stacks)
- Modular and Layered architecture
- Supports deferred control transfer responses.
- Completely non-blocking
- Supports both polled and interrupt operation.
- Works readily in an RTOS environment.
This document serves as getting started guide and provides information on the following:
- USB Device Stack Architecture
- USB Device Library - Application Interaction
- Creating your own USB device
Note: This document assumes that the reader is familiar with the USB 2.0 specification (available at www.usbif.org). While the
document, for the sake completeness, does cover certain aspects of the USB 2.0 protocol, it is recommended that the reader
5.9 USB Library Help MPLAB Harmony Help USB Device Library - Getting Started
5-3963
refer to the specification for a complete description of USB operation.
5.9.1.2 Release Notes
MPLAB Harmony Version: v0.70b Release Date: 18Nov2013
New This Release:
Nothing to report in this release.
Known Issues:
• USB Device Stack:
• Limited USB chapter 9 testing performed on HID and MSD function drivers.
• The stack has not been tested for USB Interoperability.
• The USB Device Stack has not been tested with a Real Time Operating System.
• Attach/Detach behavior has been tested in a limited capacity.
• The device stack only supports interrupt mode operation. Polled mode operation will be added in a future release.
• While running the device stack on PIC32MZ microcontroller, the stack requires 3 seconds to initialize. This is due to a
hardware issue with PIC32MZ USB module.
• Device stack operation has been tested with Windows XP and Windows 7 OS based PC USB Host.
• The USB_DEVICE_ResumeStart() and USB_DEVICE_ResumeStop() functions are not implemented.
• USB Host Stack:
• The host Stack has not been tested with a Real Time Operating System.
• Attach/Detach behavior has been tested in a limited capacity.
• The host stack only supports interrupt mode operation. Polled mode operation will be added in a future release.
• While running the host stack on PIC32MZ microcontroller, the stack requires 3 seconds to initialize. This is due to a
hardware issue with PIC32MZ USB module. The 3 second delay is implemented using a while loop. This will replaced with
System Timer services in the next release.
• MSD Host has been tested with a limited number of commercially available USB Flash Drives.
• MSD Host and the USB Host Layer have not been tested for read/write throughput. This will be done in a future release.
• Host stack has not been tested with low speed devices.
• The PIC32MZ host layer performs direct access of Timer 2 peripheral SFR, for its timing requirements. This will be
replaced with Harmony System Timer services in the next release of the host stack.
• USB_HOST_DeviceSuspend() and the USB_HOST_DeviceResume() functions are not implemented.
5.9.1.2.1 Previous Versions
5.9.1.2.1.1 v0.51b
Release notes for version 0.51b of the MPLAB Harmony USB Stack.
Description
New features in this release:
5.9 USB Library Help MPLAB Harmony Help USB Device Library - Getting Started
5-3964
• Added Device Stack support for Mass Storage device class.
• Added Device Stack support for Audio Device class.
• Added demonstration applications for Audio and Mass Storage Device classes.
• Added support for PIC32MZ devices and High Speed operation.
• HID Basic Demonstration application tested for USB 2.0 chapter-9 conformance.
• MSD Basic Demonstration application tested for USB2.0 chapter-9 conformance.
• First Release of Host Layer and CDC Host Driver along with a demonstration application.
Limitations and Known Issues:
The following are the known issues in this release. These issues will be fixed in the subsequent releases of the MPLAB Harmony
USB Stack.
• The USB device stack is tested with Windows environment only. Performance and working of the device stack is not tested
with other OS environments.
• The stack is not thoroughly tested for inter operability with other USB devices when connected to hub along with other devices.
• All demos are tested in dynamic interrupt mode only.
• Limited testing is done with hub.
• Limited testing is done with RTOS.
• APIs may change in subsequent releases and are not final.
• PIC32MZ USB Driver supports only on instance of the USB peripheral.
• The Mass Storage Device Class demonstration application works with Windows XP OS only.
• The Audio Speaker demo may not restart audio playback if the playback is paused from the PC.
• The CDC Host layer has been in tested in a limited capacity.
• PIC32MZ and Hi-Speed USB support is tested with CDC and HID device classes only.
• HID Keyboard demonstration application does not receive output report from PC USB host.
5.9.1.2.1.2 v0.51.02b
Release notes for the current version of the MPLAB Harmony USB Stack
Description
New features in this release:
• Updated documentation to include a Getting Started with USB Device Library.
• Updated the documentation for CDC and HID Function Drivers. Improved code size and RAM requirement of the demos.
• The following issues from the v0.51b are fixed in this release
• HID Keyboard demonstration application does not receive output report from PC USB host.
• The Audio Speaker demo may not restart audio playback if the playback is paused from the PC.
• The Mass Storage Device Class demonstration application works with Windows XP OS only. The demo now works with
Windows 7.
Limitations and Known Issues:
The following are the known issues in this release. These issues will be fixed in the subsequent releases of the MPLAB Harmony
USB Stack.
• The USB device stack is tested with Windows environment only. Performance and working of the device stack is not tested
with other OS environments.
5.9 USB Library Help MPLAB Harmony Help USB Device Library - Getting Started
5-3965
• The stack is not thoroughly tested for inter operability with other USB devices when connected to hub along with other devices.
• All demos are tested in dynamic interrupt mode only.
• Limited testing is done with hub. Limited testing is done with RTOS.
• Audio Speaker demo may not work with all USB Hosts. This has been observed with faster PC Hosts.
• APIs are not final and may change in subsequent releases.
• PIC32MZ USB Driver supports only on instance of the USB peripheral.
• The CDC Host layer has been in tested in a limited capacity.
• PIC32MZ and Hi-Speed USB support is tested with CDC and HID device classes only.
• Polling operation is not implemented
• Static USB Controller Driver is not available.
5.9.1.3 SW License Agreement
(c) 2013 Microchip Technology Inc.
Microchip licenses this software to you solely for use with Microchip products. The software is owned by Microchip and its
licensors, and is protected under applicable copyright laws. All rights reserved.
SOFTWARE IS PROVIDED "AS IS" MICROCHIP EXPRESSLY DISCLAIMS ANY WARRANTY OF ANY KIND, WHETHER
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. IN NO EVENT SHALL MICROCHIP BE LIABLE FOR
ANY INCIDENTAL, SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, HARM TO
YOUR EQUIPMENT, COST OF PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY OR SERVICES, ANY CLAIMS
BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), ANY CLAIMS FOR INDEMNITY OR
CONTRIBUTION, OR OTHER SIMILAR COSTS.
To the fullest extent allowed by law, Microchip and its licensors liability shall not exceed the amount of fees, if any, that you have
paid directly to Microchip to use this software.
MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE TERMS.
5.9.1.4 USB Device Library Architecture
Describes the USB Device Library Architecture.
Description
The USB Device Library features a modular and layered architecture. This is shown in figure 1.
5.9 USB Library Help MPLAB Harmony Help USB Device Library - Getting Started
5-3966
Figure 1: USB Device Library Architecture
As seen in figure 1, the USB Device Library consists of the 3 major components
1. The USB Controller Driver (USBCD) manages the state of the USB peripheral and provides the Device Layer with structured
data access methods to the USB. It also provides the device layer with USB events. The USBCD is a MPLAB Harmony driver
and uses the Harmony framework components (the USB peripheral Library, the Interrupt System Service) for its operation. It
supports only one client per instance of the USB Peripheral. This client would typically be the Device Layer. In case of multiple
USB peripherals, the USBCD can manage multiple USB peripherals, each being accessed by one client. The driver is accessed
exclusively by the Device Layer in the USB Device Layer Architecture. It is initialized by the Device Layer (when the Device
Layer is initialized) and in case of polling operation, it's Tasks routine is called by the Device Layer. The USBCD provides
functions to
- enable, disable and stall endpoints
- schedule USB transfers.
- attach or detach the device
- control resume signalling
2. The Device Layer responds to the enumeration requests issued by the USB host. It has exclusive access to an instance of
the USBCD and Endpoint 0 which is the control endpoint. When the host issues a class specific control transfer request, the
Device Layer will analyze the setup packet of the control transfer and will route the control transfer to the appropriate function
driver. The Device Layer must be initialized with the following data:
- Master Descriptor Table: This is a table of all the configuration descriptors and string descriptors.
- Function Driver Registration Table : This table contains information about the function drivers in the application
- USBCD initialization information: This specifies the USB peripheral interrupt, the USB Peripheral instance and sleep mode
operation options.
The Device Layer initializes all function drivers that are registered with it when it receives a Set Configuration (for a supported
configuration) from the host. It de-initializes the function drivers when a USB reset event occurs. It initializes the USBCD, opens
it and registers a event handler to receive USB events. The Device Layer can also be opened by the application (the application
5.9 USB Library Help MPLAB Harmony Help USB Device Library - Getting Started
5-3967
becomes a client to the Device Layer). The application can then receive bus and device events and respond to control transfer
requests. The Device Layer provides events to the application such as device configured or device reset. The application must
then respond appropriately to these events.
3. The Function Drivers implements various USB device classes as per the class specification. The USB Device Library
architecture can support multiple instances of a function driver. An example would be a USB CDC device that emulates 2 serial
ports. Function drivers provide an abstracted and an easy to use interface to the application. The application must register an
event handler with the function driver to receive function driver events and must respond to some of these events with control
transfer read/write functions. Function driver access the bus through the Device Layer.
5.9.1.5 USB Device Library - Application Interaction
Describes how the application must interact with the USB Device Stack
Description
Figure 2 highlights the steps that the application must follow in order to use the USB Device Library.
Figure 2: Application Interaction with Device Layer
The application must first initialize the Device Layer. As a part of the Device Layer initialization process, the Device Layer
initialization structure must be defined which in turn requires the following data structures to be designed
- The master descriptor table
- The function driver registration table
Figure 3 shows a pictorial representation of the data that forms the Device Layer initialization structure. Additional information on
Device Layer initialization is available in the Device Layer Help File.
Figure 3. Device Layer Initialization
After successful initialization of the device layer, the application can open the device layer and register a device layer event
handler. The device layer event handler receives device level events such as device configured, device de-configured, device
reset and device suspended. The device configured event and de-configured event are important. The application can use the
device deconfigured event to re-initialize its internal state machine. When the application receives a device configured event, it
must register event handlers for each function driver that is relevant to the configuration that was set. The function driver event
handler registration must be done in the device configured event context because the device layer acknowledges the set
configuration request from the host when it exits the device configured event handler context. The application at this point should
be ready to respond to function driver events which require application intervention.
Note: Not registering the function driver event handler in the device layer device configured event could cause the device to not
5.9 USB Library Help MPLAB Harmony Help USB Device Library - Getting Started
5-3968
respond to the host requests and hence be non-compliant.
Once configured, the device is now ready to serve it intended function on the USB. The application interacts with the device layer
and function drivers through API function and event handlers. The application must be aware of function driver events which
require application response. For example, the USB_DEVICE_CDC_EVENT_SET_LINE_CODING event from the CDC Function
Driver requires the application to respond with a USB_DEVICE_CDC_ControlRead() function. This function provides the buffer
to accept the line coding parameters that the host will be provide in the data stage of the Set Line Coding control transfer. Figure
4 shows the application interaction with device layer and function driver after the device has been configured.
Figure 4: Application - Device Layer Interaction after device configuration
In figure 4, the application should have registered the device layer event handler before attaching the device on the bus. It
should have registered the function driver event handler before exiting the device configured - device layer event. The
application will then receive function driver instance specific events via the function driver event handlers.
Deferring Control Transfer Responses:
Some function driver events require the application to respond to the data stage and/or the status stage of the function driver
(class) specific control transfer associated with the event. The application responds to the data stage by specifying a buffer that
either contains the data that needs to sent to host (control read) or will contain the data that host sends to the device (control
write). In case of a control write, the application may wish to inspect the data which was received from the host and the
acknowledge or stall the status stage of the control transfer. In such cases, it is possible that the application may not be ready
within the function driver event handler context, with data that needs to be sent in the control read transfer or the success/ failure
decision in response to the control write transfer. Performing extended processing or waiting for external hardware within the
function driver event handler context is not recommended as USB 2.0 specification places restrictions on the control transfer
response time.
In cases where the application is not ready to respond to control transfer requests within the function driver event handler
context, the USB Device Library provides the option of deferring the response to the event. The application can respond to the
control transfer request out of function driver event handler context. The function driver generates a control transfer handle,
which the application must use while responding to the function driver event outside the event handler context. The application
must still observe the USB 2.0 specification control transfer timing requirements while responding to the control transfer.
Deferring the response in such a manner provides the application with flexibility to analyze the control transfer without affecting
the dynamic response of the device.
5.9 USB Library Help MPLAB Harmony Help USB Device Library - Getting Started
5-3969
5.9.1.6 Creating Your Own USB Device
Describes how to create a USB device with MPLAB Harmony USB Device Library
Description
The first step in creating a USB device is identifying if the desired device function fits into any of the standard USB device class
functions. Using standard USB classes may be advantageous as major operating systems feature ready Host driver support for
standard USB devices. The application may however not wish to tolerate the overhead associated with standard USB device
class protocols, in which case, a custom USB device can be implemented. A custom USB device can be implemented by using
the Generic Device function driver in the USB Device Library, but these devices will requires development of host drivers for their
operation. Having identified the device class to be used, the following approaches are available for developing a USB device by
using the USB Device Library.
1. Use the available library demonstration applications. The USB Device Library release package contains a set of demo
applications which are representative of common USB devices. These can be modified easily to include application specific
initialization and application logic. The application logic must be non-blocking and could be implemented as a state machine.
- The application specific initialization can be called in the SYS_Initialize() function (in the sys_init.c file). The SYS_Initialize is
called when the device comes out of power on reset.
- The application logic can be called in the SYS_Tasks() function (in the sys_tasks.c file). The application logic can interact with
the function driver and the device layer by using relevant API calls.
- The application logic can track device events by processing the events in the application USB device event handler function
(APP_USBDeviceEventHandler() function in app.c).
2. Build a USB Device Library application from scratch. In a case where the available demo applications do not meet the
end application requirements, a USB device can be created by building a USB Device Library application from scratch. Figure 5
shows a flowchart for the steps that need to be followed to do this.
Figure 5: Steps to create a USB Device Library Application
Step 1:
Create a MPLAB Project and add the required USB Device Library file to the project. The following files are needed to build the a
USB Device Library project
5.9 USB Library Help MPLAB Harmony Help USB Device Library - Getting Started
5-3970
- system_config.h - This file should contain the compile time configuration macros for the Function Driver, Device Layer and
Controller Driver. Refer to the "Configuring the Library" section in the documentation
- usb_device.c - This is the device layer implementation
- drv_usb.c and drv_usb_device.c - These files implement the USB device mode Controller Driver.
- sys_int_pic32.c and plib_int_pic32.c - These files implement the system interrupt service that is required by the USBCD.
- function driver implementation files - This depends on the USB device function being implemented. The "Using the Library"
section in the function driver specific help file provides more details on the files to be included while using the function driver.
- Application specific files - These file will implement the application logic
Step 2:
Setup the fuse configuration bits to enable PLL. The code snippets below can be used to do this for PIC32MX and PIC32MZ
processors
/*************************************************************
* The following code snippet shows the USB PLL related
* fuse configuration bits for PIC32MX processors. A 8MHz
* external crystal/oscillator is assumed.
***************************************************************/
#pragma config UPLLEN = ON /* Enable USB PLL */
#pragma config UPLLIDIV = DIV_2 /* USB PLL input divider */
/*************************************************************
* The following code snippet shows the USB PLL related
* fuse configuration bits for PIC32MZ processors. A 24MHz
* external crystal/oscillator is assumed.
***************************************************************/
#pragma config UPLLFSEL = FREQ_24MHZ // USB PLL Input Frequency Selection
#pragma config UPLLEN = ON
Step 3:
Design the USB Device, Configuration and Class specific descriptors that are required for successful enumeration of the USB
device. These should comply with the USB 2.0 specification. Class Specific descriptors should comply with the class
specifications. The device and configuration descriptors should be added to the Master Descriptor Table. A Function Driver
Registration Table should be created and registered with the Device Layer. The function driver registration table associates
instance of a function driver with a Device Layer instance. Refer to "Setting up Master Descriptor Table" and "Function Driver
Registration" in the Device Layer help file for more information.
Step 4:
The application should create a Device Layer Event Handler which will handle all the events generated by the Device Layer. The
following code snippet shows a list of all possible events that are generated by the Device Layer. The code snippet can be used
in the application and updated to meet the application requirements. Refer to "Device Events" in the Device Layer documentation
for more details on the Device Layer Event Handling.
void APP_USBDeviceEventHandler(USB_DEVICE_EVENT event, USB_DEVICE_EVENT_DATA * eventData)
{
switch(event)
{
case USB_DEVICE_EVENT_RESET:
break;
case USB_DEVICE_EVENT_DECONFIGURED:
break;
case USB_DEVICE_EVENT_CONFIGURED:
break;
case USB_DEVICE_EVENT_SUSPENDED:
break;
case USB_DEVICE_EVENT_RESUMED:
break;
5.9 USB Library Help MPLAB Harmony Help USB Device Library - Getting Started
5-3971
case USB_DEVICE_EVENT_ATTACHED:
break;
case USB_DEVICE_EVENT_DETACHED:
break;
case USB_DEVICE_EVENT_ERROR:
break;
default:
break;
}
}
Step 5:
The application should create a Function Driver Event Handler which will handle all the events generated by the Function Driver.
Refer to "Event Handling" section in the applicable function driver documentation for more details on the Function Driver Event
Handling.
Step 6:
If the application intends to operate the USB Device Library in polling mode, the a interrupt service routine is not required. If the
application intends to operate in interrupt mode, a USB Interrupt Handler should be defined as shown here:
/* Use this for PIC32MX */
void __ISR ( _USB_1_VECTOR ) _InterruptHandler_USB_stub ( void )
{
DRV_USB_Tasks_ISR((SYS_MODULE_OBJ)0);
}
/* Use this for PIC32MZ */
void __ISR ( _USB_VECTOR,ipl4 ) _InterruptHandler_USB_stub ( void )
{
DRV_USB_Tasks_ISR((SYS_MODULE_OBJ)0);
}
Step 7:
The application should create a while(1) loop that continuously updates the USB Device Layer State machine and the application
state machine. This requires the application state machine to be non-blocking.
/* This while(1) loop will continuously update Device Layer State machine
* and the application state machine */
while(1)
{
USB_DEVICE_Tasks(deviceLayerObject);
APP_Tasks();
}
Step 8:
If interrupt based operation is needed, the interrupts need to be enabled first. The application should then initialize and open the
device layer. When the device layer is opened successfully, a device layer event handler can be registered. The device can then
be attached on the bus. Refer to the "Initializing the Library" section in the USB Device Layer documentation for more details on
initializing the USB Device Layer
/* Initialize the interrupt system */
SYS_INT_Initialize();
/* Initialize the global interrupts */
SYS_INT_Enable();
SYS_INT_VectorPrioritySet(INT_VECTOR_USB, INT_PRIORITY_LEVEL3);
SYS_INT_VectorSubprioritySet(INT_VECTOR_USB, INT_SUBPRIORITY_LEVEL3);
/* Initialize the USB device layer */
deviceLayerObject = USB_DEVICE_Initialize (USB_DEVICE_INDEX_0 ,
5.9 USB Library Help MPLAB Harmony Help USB Device Library - Getting Started
5-3972
( SYS_MODULE_INIT* ) & usbDevInitData);
/* check if the object returned by the device layer is valid */
SYS_ASSERT((SYS_MODULE_OBJ_INVALID != deviceLayerObject), "Invalid USB DEVICE object");
/* Open an instance of the device layer */
appData.deviceHandle = USB_DEVICE_Open( USB_DEVICE_INDEX_0,
DRV_IO_INTENT_READWRITE );
/* Register a callback with device layer to get
* event notification (for end point 0) */
USB_DEVICE_EventCallBackSet(appData.deviceHandle, APP_USBDeviceEventHandler);
/* Attach the device */
USB_DEVICE_Attach(appData.deviceHandle);
5.9.1.7 USB Device Stack Migration Guide
5.9.1.7.1 Introduction
This topic provides information for migrating from USB Device from MLA to MPLAB Harmony.
5.9.1.7.2 Source Files to Include
This topic provides information on the source files to be included when migrating from USB device projects from MLA to MPLAB
Harmony.
Description
The following table lists the source files that must be included for MLA based and MPLAB Harmony based USB device projects.
In MLA there is no separate controller driver implementation. Both enumeration functionality and controller driver is implemented
in usb_device.c file. In MPLAB Harmony USB Device Stack, the controller driver is implemented in drv_usb.c and
drv_usb_device.c files and enumeration functionality is implemented in usb_device.c file.
MLA MPLAB Harmony Description
usb_device.c usb_device.c In MLA, this file contains enumeration functionality and controller
driver implementations.
In MPLAB Harmony, this file implements enumeration
functionality only.
usb_function_xxx.c
(Where xxx stands for
function driver name like
hid, msd, etc.)
usb_device_xxx.c
(Where xxx stands for function
driver name like hid, msd, etc.)
Contains all function driver implementations.
usb_descriptors.c system_config.c Contains USB stack configurations
N/A drv_usb.c and drv_usb_device.c USB peripheral driver implementation.
5.9.1.7.3 Initializing the USB Device Stack
This topic provides initialization information when migrating a USB device project from MLA to MPLAB Harmony.
5.9 USB Library Help MPLAB Harmony Help USB Device Library - Getting Started
5-3973
Description
In MLA, initializing the USB device stack consists of calling USB functions in the sequence shown in the following flow chart.
USBDeviceInit() function will initialize the USB Device stack. USBDeviceAttach() function will attach the device to bus.
USBDeviceTasks() function will run the stack task routine.
In MPLAB Harmony USB Device Stack, initializing the USB device stack consists of calling USB functions in the sequence
shown in the following chart.
The USB_DEVICE_Initialize() function will initialize the USB device stack. On successful initialization, this function returns a valid
system object. USB_DEVICE_Open() returns a client handle to the application. The application must use this client handle for
any further communication with the USB device stack. USB_DEVICE_Attach() function attaches the device to USB bus.
USB_DEVICE_Tasks() will run the task routine of the stack.
5.9.1.7.4 Configuring the Stack
This topic provides stack configuration information when migrating from a USB device project from MLA to MPLAB Harmony.
5.9 USB Library Help MPLAB Harmony Help USB Device Library - Getting Started
5-3974
Description
To configure the stack in MLA, USB descriptors have to be defined in the usb_descriptors.c file. The configuration is done in
usb_config.h. Where as in MPLAB Harmony, USB descriptors are defined in system_config.c. The MPLAB Harmony USB
Device Stack configuration is done in system_config.h. Apart from descriptors, user also will have to define a function registration
table and a master descriptor table in system_config.c. Refer to USB device help file of MPLAB Harmony for more information on
the function registration table and the master descriptor table.
5.9.1.7.5 Event Handling
This topic provides event handling information when migrating a USB device project from MLA to MPLAB Harmony.
Description
In MLA, user will have to handle events inside USER_USB_CALLBACK_EVENT_HANDLER function. Whereas in case of
MPLAB Harmony, user application client will have to register an event handler with the USB device stack using
USB_DEVICE_EventCallBackSet() function. All USB bus events are then forwarded to this user registered event handler
function. In case of multi client environment, it is possible for each client to register its own event handler with the USB stack.
This allows each application clients to individually manage the events separately. Following code snippet shows an example of
registering the event handler in case of MPAB Harmony stack using USB_DEVICE_EventCallBackSet() function. In the following
code snippet, APP_UsbDeviceEventCallBack() function is the application event handler.
The following code snippet shows the implementation of APP_UsbDeviceEventCallBack function.
5.9.1.7.6 Initializing and Communicating with the Endpoint
This topic provides endpoint initialization and communication information when migrating a USB device project from MLA to
MPLAB Harmony.
5.9 USB Library Help MPLAB Harmony Help USB Device Library - Getting Started
5-3975
Description
In MLA, user application will have to explicitly initialize the required endpoints and can directly read and write to the endpoints.
The following code snippet shows how MLA initializes the endpoints in event handler when the device is configured.
In case of MPLAB Harmony the user application has no direct access to endpoints. USB device layer initializes the endpoint and
any communication to endpoint must happen through function driver APIs. The USB device layer initializes the endpoint based
on the information provided by the user in the configurations descriptor. The USB device layer does this by parsing the
descriptors table at run time. So the user does not have to explicitly enable or disable the endpoint.
5.9.1.7.7 Handling Endpoint 0 (EP0) Packets
This topic provides information for handling Endpoint 0 packets when migrating a USB device project from MLA to MPLAB
Harmony.
Description
Standard device requests are handled by device stack in both MLA and MPLAB Harmony. The difference lies in handling class
specific requests. In MLA, the class specific requests are forwarded to the application as EP0 events and application forwards
them to appropriate function driver. The following code snippet shows how application forwards them to appropriate function
driver in the event handler.
In the case of MPLAB Harmony USB Device Stack, EP0 events are generated from appropriate function driver as meaningful
events. For example the HID function driver in MPLAB harmony parses the EP0 packet to generate events like
USB_DEVICE_HID_EVENT_GET_IDLE, USB_DEVICE_HID_EVENT_SET_REPORT and
USB_DEVICE_HID_EVENT_SET_IDLE etc.
5.9 USB Library Help MPLAB Harmony Help USB Device Library - Getting Started
5-3976
The following code snippet shows how the event handler callback is registered with the HID function driver using
USB_DEVICE_HID_EventHandlerSet() function.
The following code snippet shows the implementation of the HID event handler function in the application. Note how the HID
function driver converts EP0 requests to meaningful format for the application.
5.9.2 USB Audio Device Library
5.9.2.1 Introduction
Introduces the MPLAB Harmony USB Device Audio Library.
Description
This library provides a high-level abstraction of the Universal Serial Bus (USB) Audio Device Class function driver that is part of
the MPLAB Harmony USB stack with a convenient C language interface. This library supports revision 1.0 of the USB Audio
specification release by the USB Implementers forum.
The Audio Device Class Definition applies to all devices or functions embedded in composite devices that are used to
manipulate audio, voice, and sound-related functionality. This includes both audio data (analog and digital) and the functionality
that is used to directly control the audio environment, such as Volume and Tone Control. Audio device can also MIDI Data
stream through USB.
USB Audio is used with many applications related to voice telephony, audio playback, and recording eg:- Speaker, Microphone,
5.9 USB Library Help MPLAB Harmony Help USB Audio Device Library
5-3977
Mixer etc.
The MPLAB Harmony USB Device Audio library offers services to the application to interact and respond to the host requests.
The MPLAB Harmony USB Device Audio library is also referred to as Audio function driver in this document.
5.9.2.2 Release Notes
MPLAB Harmony Version: v0.70b USB Audio Device Library Version : 0.01 Alpha Release Date: 18Nov2013
This is the first release of the library. The interface can change in the beta and\or 1.0 release.
New This Release:
Nothing to report in this release.
Known Issues:
Nothing to report in this release.
5.9.2.3 SW License Agreement
(c) 2013 Microchip Technology Inc.
Microchip licenses this software to you solely for use with Microchip products. The software is owned by Microchip and its
licensors, and is protected under applicable copyright laws. All rights reserved.
SOFTWARE IS PROVIDED "AS IS" MICROCHIP EXPRESSLY DISCLAIMS ANY WARRANTY OF ANY KIND, WHETHER
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. IN NO EVENT SHALL MICROCHIP BE LIABLE FOR
ANY INCIDENTAL, SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, HARM TO
YOUR EQUIPMENT, COST OF PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY OR SERVICES, ANY CLAIMS
BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), ANY CLAIMS FOR INDEMNITY OR
CONTRIBUTION, OR OTHER SIMILAR COSTS.
To the fullest extent allowed by law, Microchip and its licensors liability shall not exceed the amount of fees, if any, that you have
paid directly to Microchip to use this software.
MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE TERMS.
5.9.2.4 Library Architecture
Provides an Architectural Overview of the Audio Function Driver.
Description
The USB Audio function driver offers various services to a USB Audio device to communicate with the host by abstracting USB
specification details. It must be used along with the USB Device layer and USB controller to communicate with the USB host.
Figure 1 shows a block diagram representation of the MPLAB Harmony USB Architecture and where the USB Audio Function
Driver is placed.
5.9 USB Library Help MPLAB Harmony Help USB Audio Device Library
5-3978
Figure 1: USB Device Audio Function Driver
The USB controller driver takes the responsibility of managing the USB peripheral on the device. The USB device layer handles
the device enumeration etc. The Audio function driver receives The USB Device layer forwards all Audio specific control
transfers to the Audio Function Driver. The Audio Function Driver interprets the control transfers and requests application's
intervention through event handlers and well defined set of API. The application must respond to the Audio events either in or out
of the event handler. The application must interact directly with the Audio Function Driver to send/receive data and Audio Control
data.
5.9.2.5 Using the Library
5.9.2.5.1 Files to Include
Describes which files to include in project while using the Audio Function Driver.
Description
Table 2 shows the files that must be included in the project in order to use the Audio Function Driver. These files are located in
the framework folder of the MPLAB Harmony installation. It is assumed that the Device Layer files ( and the files needed by the
Device Layer) are already included in the project.
Filename Description
\framework\usb\src\dynamic\usb_device_audio.c This file contains all of functions, macros, definitions, variables, datatypes,
etc. that are required for usage with the USB device Audio function driver.
\framework\usb\usb_device_audio.h Must be included in every source file that needs to invoke Audio function
driver API.
system_config.h User created file which contains the Audio function driver configuration.
5.9 USB Library Help MPLAB Harmony Help USB Audio Device Library
5-3979
Table 2: Files to be included in USB Audio Device Project.
5.9.2.5.2 Initializing the Library
Describes how Audio function driver is initialized.
Description
The Audio function driver instance for a USB device configuration is initialized by the Device Layer when the configuration is set
by the host. This process does not require application intervention. Each instance of the Audio function driver should be
registered with the Device layer through the Device Layer Function Driver Registration Table. The Audio function driver does not
require a initialization data structure.The funcDriverInit member of the function driver registration table entry for the Audio
function driver instance should be set to NULL. The audioFuncDriver object is a global object provided by the Audio function
driver and points to the Audio function driver - Device Layer interface functions which are required by the Device Layer. The
code snippet below shows an example of how multiple instances of Audio Function driver can registered with the Device Layer.
/* This code snippet shows an example of how an Audio function
* driver instances can be registered with the Device Layer
* via the Device Layer Function Driver Registration Table.
* In this case Device Configuration 1 consists of one Audio
* function driver instance. */
const USB_DEVICE_FUNC_REGISTRATION_TABLE funcRegistrationTable[1] =
{
{
.speed = USB_SPEED_FULL|USB_SPEED_HIGH, // Supported speed
.configurationValue = 1, // To be initialized for Configuration 1
.interfaceNumber = 0, // Starting interface number.
.numberOfInterfaces = 2, // Number of interfaces in this instance
.funcDriverIndex = 0, // Function Driver instance index is 0
.funcDriverInit = NULL, // Function Driver does not need
initialization data structure
.driver = &audioFuncDriver // Pointer to Function Driver - Device
Layer interface functions
},
};
The sequence for initializing the USB Audio Function driver is depicted in the Figure 2.
5.9 USB Library Help MPLAB Harmony Help USB Audio Device Library
5-3980
Figure 2. USB Audio function driver Initialization
1. Call set of APIs to initialize USB Device Layer. Refer USB Device Layer documentation for details about these APIs.
2. The Device Layer provides a callback to the application for any USB Device events like attached, powered, configured etc.
The application should receive a callback with an event USB_DEVICE_EVENT_CONFIGURED to proceed.
3. Once the Device Layer is configured the application needs to register callback functions with USB Audio function driver to
receive Audio Control transfers and also other audio function driver events. Now the application can use audio function driver
APIs to communicate with USB Host.
5.9.2.5.3 Event Handling
Describes Audio function driver event handler registration and event handling.
Description
Registering Audio Function Driver callback functions:
While creating USB Audio Device based application, an event handler must be registered with the Device Layer (the Device
Layer Event Handler) and every Audio function driver instance (Audio Function Driver Event Handler). The application needs to
register two callback functions with Audio function driver
1. For receiving Audio Control Requests from Host like Volume Control, Mute Control etc.
2. For handling other events from Audio function driver. eg:- Data Write Complete or Data Read Complete
The callback functions should be registered before the USB device layer acknowledges the SET CONFIGURATION request
from the USB Host. In order to ensure this, the callback functions should be set in the USB_DEVICE_EVENT_CONFIGURED
event that is generated by the device layer. The code example below shows an example of how this can be done.
/* This a sample Application Device Layer Event Handler
* Note how the Audio Function Driver callback functions
* APP_AudioEntitySettingsCallback() and APP_AudioEventCallback()
* are registered in the USB_DEVICE_EVENT_CONFIGURED event. */
void APP_USBDeviceEventCallBack ( USB_DEVICE_EVENT event,
USB_DEVICE_EVENT_DATA * eventData )
5.9 USB Library Help MPLAB Harmony Help USB Audio Device Library
5-3981
{
switch ( event )
{
case USB_DEVICE_EVENT_RESET:
case USB_DEVICE_EVENT_DECONFIGURED:
// USB device is reset or device is deconfigured.
// This means that USB device layer is about to deininitialize
// all function drivers.
break;
case USB_DEVICE_EVENT_CONFIGURED:
/* check the configuration */
if ( eventData->eventConfigured.configurationValue == 1)
{
/* Register the callback function for handling Audio Control requests.*/
USB_DEVICE_AUDIO_RegisterCallBacks (USB_DEVICE_CDC_INDEX_0 ,
APP_AudioEntitySettingsCallback ,
USB_DEVICE_AUDIO_CALLBACK_ENTITY_SETTINGS );
/* Register the callback function for handling Audio function driver Events*/
USB_DEVICE_AUDIO_RegisterCallBacks (USB_DEVICE_CDC_INDEX_0 ,
APP_AudioEventCallback ,
USB_DEVICE_AUDIO_CALLBACK_EVENTS );
/* mark that set configuration is complete */
appData.isConfigured = true;
}
break;
case USB_DEVICE_EVENT_SUSPENDED:
break;
case USB_DEVICE_EVENT_RESUMED:
case USB_DEVICE_EVENT_ATTACHED:
case USB_DEVICE_EVENT_DETACHED:
case USB_DEVICE_EVENT_ERROR:
default:
break;
}
}
Handling Audio Control Requests:
The audio function driver notifies the application by calling the provided callback function, whenever an Audio Control request is
received from USB Host. Below example shows how to handle Audio Control request.
// This code example shows handling Audio Control requests. The below handles a Mute request
(both SET
GET) received from USB Host.
//The below are ID of each terminal/Unit in the USB audio function.
//Device makes these IDs known to Host through USB descriptors
// if that terminal/unit is present in this USB audio device application.
#define APP_ID_INPUT_TERMINAL 0x01
#define APP_ID_OUTPUT_TERMINAL 0x02
#define APP_ID_MIXER_UNIT 0x03
#define APP_ID_SELECTOR_UNIT 0x04
#define APP_ID_FEATURE_UNIT 0x05
5.9 USB Library Help MPLAB Harmony Help USB Audio Device Library
5-3982
#define APP_ID_PROCESSING_UNIT 0x06
#define APP_ID_EXTENSION_UNIT 0x07
int APP_AudioEntitySettingsCallback
(
USB_DEVICE_AUDIO_INDEX iAudio ,
uintptr_t controlHandle,
SETUP_PKT *setupPkt
)
{
int8_t err=-1;
USB_AUDIO_CONTROL_INTERFACE_REQUEST* controlRequest;
controlRequest = (USB_AUDIO_CONTROL_INTERFACE_REQUEST*) setupPkt;
switch(controlRequest->entityID)
{
case APP_ID_INPUT_TERMINAL:
case APP_ID_OUTPUT_TERMINAL:
err = APP_TerminalRequestHandler (controlRequest);
break;
case APP_ID_FEATURE_UNIT:
err = APP_FeatureUnitRequestHandler (iAudio, controlHandle, controlRequest);
break;
case APP_ID_MIXER_UNIT:
case APP_ID_SELECTOR_UNIT:
case APP_ID_PROCESSING_UNIT:
case APP_ID_EXTENSION_UNIT:
default:
//This USB Audio Speaker application does not support any other control request
// received for other unit from Host. So Stall if any other request recieved from
Host.
USB_DEVICE_ControlStatus(appData.usbDevHandle,
controlHandle,USB_DEVICE_CONTROL_STATUS_STALL);
break;
}//end of switch(controlRequest->entityID)
return err;
}//end of function APP_AudioEntitySettingsCallback
int APP_FeatureUnitRequestHandler
(
USB_DEVICE_AUDIO_INDEX iAudio ,
uintptr_t controlHandle,
USB_AUDIO_CONTROL_INTERFACE_REQUEST* controlRequest
)
{
USB_AUDIO_FEATURE_CONTROL_REQUEST* featureRequest;
featureRequest = (USB_AUDIO_FEATURE_CONTROL_REQUEST*) controlRequest;
int8_t err = 0;
switch(featureRequest->controlSelector)
{
case USB_AUDIO_FEATURE_UNIT_CONTROL_SELECTOR_MUTE_CONTROL:
{
if (featureRequest->bRequest == USB_AUDIO_CLASS_SPECIFIC_REQUEST_CODE_SET_CUR )
{
//A control write transfer recived from Host. Now recieve data from Host.
USB_DEVICE_ControlReceive(appData.usbDevHandle, controlHandle,(uint8_t *)
&DACMute, 1 );
}
else if(featureRequest->bRequest == USB_AUDIO_CLASS_SPECIFIC_REQUEST_CODE_GET_CUR)
{
/*Handle Get request*/
USB_DEVICE_ControlSend(appData.usbDevHandle, controlHandle, (uint8_t
*)&DACMute, 1 );
5.9 USB Library Help MPLAB Harmony Help USB Audio Device Library
5-3983
}
else
{
USB_DEVICE_ControlStatus( appData.usbDevHandle, controlHandle,
USB_DEVICE_CONTROL_STATUS_STALL);
}
}
break;
case USB_AUDIO_FEATURE_UNIT_CONTROL_SELECTOR_VOLUME_CONTROL:
case USB_AUDIO_FEATURE_UNIT_CONTROL_SELECTOR_BASS_CONTROL:
case USB_AUDIO_FEATURE_UNIT_CONTROL_SELECTOR_MID_CONTROL:
case USB_AUDIO_FEATURE_UNIT_CONTROL_SELECTOR_TREBLE_CONTROL:
case USB_AUDIO_FEATURE_UNIT_CONTROL_SELECTOR_GRAPHIC_EQUALIZER_CONTROL:
case USB_AUDIO_FEATURE_UNIT_CONTROL_SELECTOR_AUTOMATIC_GAIN_CONTROL:
case USB_AUDIO_FEATURE_UNIT_CONTROL_SELECTOR_DELAY_CONTROL:
case USB_AUDIO_FEATURE_UNIT_CONTROL_SELECTOR_BASS_BOOST_CONTROL:
case USB_AUDIO_FEATURE_UNIT_CONTROL_SELECTOR_LOUDNESS_CONTROL:
case USB_AUDIO_FEATURE_UNIT_CONTROL_SELECTOR_FU_CONTROL_UNDEFINED:
default:
//This USB Audio Speaker application does not support any other feature unit
request
// from Host. So Stall if any other feature unit request recieved from Host.
USB_DEVICE_ControlStatus (appData.usbDevHandle,controlHandle,
USB_DEVICE_CONTROL_STATUS_STALL);
break;
} // end of switch(featureRequest->controlSelector)
return err;
} //end of function APP_FeatureUnitRequestHandler
Handling Audio function driver events :
The audio function driver events are discussed at USB_DEVICE_AUDIO_EVENT Enumeration.
5.9.2.5.4 Transferring Data
Describes how to send/receive data to/from USB Host using this USB Audio function driver.
Description
The USB Audio function driver offers API to send, receive data.
Receiving Data :
USB_DEVICE_AUDIO_Read Function can be used to schedule a data read from the USB Host. Whenever there is data
available from Host, the USB audio function driver calls back USB audio event handler with an event
USB_DEVICE_AUDIO_EVENT_READ_COMPLETE. User can take necessary actions once the data is received like playback
the audio samples through a CODEC and/or schedule next read request for audio samples.
Sending Data :
USB_DEVICE_AUDIO_Write Function can be used to schedule a data send to the Host. The data will be send to Host,
whenever it is ready to receive. Once the data send is complete the audio function driver callsback USB audio event handler with
a event USB_DEVICE_AUDIO_EVENT_WRITE_COMPLETE. User can take necessary action once the data write is complete
like schedule next data write, etc.
5.9 USB Library Help MPLAB Harmony Help USB Audio Device Library
5-3984
5.9.2.6 Configuring the Library
Describes how to configure the Audio Function Driver.
Description
The application designer must specify the following configuration parameters while using the Audio Function Driver. The
configuration macros that implement these parameters must be located in the system_config.h file in the application project and
a compiler include path (to point to the folder that contains this file) should be specified.
Configuration Macro Name Description Comments
USB_DEVICE_AUDIO_INSTANCES_NUMBER Number of Audio
Function Driver
Instances in the
application
This macro defines the number of instances of the
Audio Function Driver. For example, if the application
needs to implement two instances of the Audio
Function Driver on one USB Device, the macro should
USB_DEVICE_AUDIO_INSTANCES_NUMBER be
set to 2. Note that implementing a USB Device that
features multiple Audio interfaces requires appropriate
USB configuration descriptors.
USB_DEVICE_AUDIO_QUEUE_SIZE Audio Function
Driver Buffer Queue
size
This macro defines the Audio function driver internal
buffer queue. The choice of this parameter defines the
readiness of the function driver to respond
successfully to read and write requests. The queue is
shared by
USB_DEVICE_AUDIO_INSTANCES_NUMBER
number of Audio instances. A buffer in the queue is
allocated to a read, write or a serial state notification
request. In a simple application, that does not require
buffer queuing and serial state notification, the
USB_DEVICE_AUDIO_QUEUE_SIZE macro can be
set to 2. In a case where higher throughput is
required, this parameter should be set to a higher
value. Note that increasing the queue size requires
more RAM.
5.9.2.7 Library Interface
Data Types and Constants
Name Description
USB_DEVICE_AUDIO_EVENT_RESPONSE_NONE USB Device Audio Function Driver
Event Handler Response Type None.
USB_DEVICE_AUDIO_TRANSFER_HANDLE_INVALID USB Device Audio Function Driver
Invalid Transfer Handle Definition.
USB_DEVICE_AUDIO_CONTROL_TRANSFER_HANDLE USB Device Audio Function Driver
Control Transfer Handle
USB_DEVICE_AUDIO_EP_INSTANCE This is type
USB_DEVICE_AUDIO_EP_INSTAN
CE.
USB_DEVICE_AUDIO_EVENT USB Device Audio Function Driver
Control Transfer Status
5.9 USB Library Help MPLAB Harmony Help USB Audio Device Library
5-3985
USB_DEVICE_AUDIO_EVENT_DATA_READ_COMPLETE USB Device Audio Function Driver
Read and Write Complete Event
Data.
USB_DEVICE_AUDIO_EVENT_DATA_WRITE_COMPLETE USB Device Audio Function Driver
Read and Write Complete Event
Data.
USB_DEVICE_AUDIO_EVENT_HANDLER USB Device Audio Event Handler
Function Pointer Type.
USB_DEVICE_AUDIO_EVENT_RESPONSE USB Device Audio Function Driver
Event Callback Response Type
USB_DEVICE_AUDIO_INDEX USB Device Audio Function Driver
Index
USB_DEVICE_AUDIO_INSTANCE This is type
USB_DEVICE_AUDIO_INSTANCE.
USB_DEVICE_AUDIO_INSTANCE_STATE This is type
USB_DEVICE_AUDIO_INSTANCE_
STATE.
USB_DEVICE_AUDIO_INTERFACE_COLLECTION This is type
USB_DEVICE_AUDIO_INTERFACE
_COLLECTION.
USB_DEVICE_AUDIO_INTERFACE_INFO This is type
USB_DEVICE_AUDIO_INTERFACE
_INFO.
USB_DEVICE_AUDIO_INTERFACE_TYPE This is type
USB_DEVICE_AUDIO_INTERFACE
_TYPE.
USB_DEVICE_AUDIO_IRP_OBJECT USB Device Audio Function Driver
IRP object.
USB_DEVICE_AUDIO_RESULT USB Device Audio Function Driver
USB Device Audio Result
enumeration.
USB_DEVICE_AUDIO_STREAMING_INTERFACE This is type
USB_DEVICE_AUDIO_STREAMING
_INTERFACE.
USB_DEVICE_AUDIO_STREAMING_INTERFACE_ALTERNATE_SETTING This is type
USB_DEVICE_AUDIO_STREAMING
_INTERFACE_ALTERNATE_SETTI
NG.
USB_DEVICE_AUDIO_TRANSFER_HANDLE USB Device Audio Function Driver
Transfer Handle Definition.
Functions
Name Description
USB_DEVICE_AUDIO_ControlReceive This function allows the application to respond to the Audio function
driver specific control transfer requests. It allows the application to
receive data from the host in the data stage of the control transfer.
USB_DEVICE_AUDIO_ControlSend This function allows the application to respond to the Audio function
driver specific control transfer requests. It allows the application to send
data to the host in the data stage of the control transfer.
USB_DEVICE_AUDIO_ControlStatus This function allows the application to complete the status stage of the
the Audio Function Driver specific control transfer request.
USB_DEVICE_AUDIO_EventHandlerSet This function registers an event handler for the specified Audio function
driver instance.
5.9 USB Library Help MPLAB Harmony Help USB Audio Device Library
5-3986
USB_DEVICE_AUDIO_Read This function requests a data read from the USB Device Audio Function
Driver Layer.
USB_DEVICE_AUDIO_Write This function requests a data write to the USB Device Audio Function
Driver Layer.
Description
This section describes the Application Programming Interface (API) functions of the USB Device Audio Library
Refer to each section for a detailed description.
5.9.2.7.1 Functions
5.9.2.7.1.1 USB_DEVICE_AUDIO_ControlReceive Function
C
USB_DEVICE_AUDIO_RESULT USB_DEVICE_AUDIO_ControlReceive(
USB_DEVICE_AUDIO_INDEX instanceIndex,
USB_DEVICE_AUDIO_CONTROL_TRANSFER_HANDLE controlTransferHandle,
void * data,
size_t size
);
Description
This function allows the application to respond to the Audio function driver specific control transfer requests. It allows the
application to receive data from the host in the data stage of the control transfer.
For example,when the Host wants to set current Volume settings to Device, the Host first sends a SETUP packet to the Device
indicating that it intedns to set Volume. After receving the SETUP packet the Device should be prepared to recieve cuurent
Volume from Host. Application should make use of USB_DEVICE_AUDIO_ControlReceive() function to receive data from the
Host in such cases. The function can be called in the Audio Function Driver event handler or can be called outside the event
handler. Calling this function outside the event handler defers the response to the event. This allows the application to prepare
the data buffer out of the event handler context, especially if the data buffer to receive the data is not readily available. Note
however, that there are timing considerations when responding to the control transfer. Exceeding the response time will cause
the host to cancel the control transfer and may cause USB host to reject the device. The application must use the control transfer
handle that was generated along with the event as the controlTransferHandle.
Preconditions
This function should only be called in response to a Audio function driver event that requires a control transfer response.
Parameters
Parameters Description
instance USB Device Audio Function Driver instance.
controlTransferHandle Control Transfer handle for the control transfer.
data Data buffer to receive the data stage of the control transfer.
size size (in bytes) of the data to sent.
Returns
USB_DEVICE_AUDIO_RESULT_ERROR_CONTROL_TRANSFER_FAILED - The request was not successful because the
USB host cancelled the control transfer.
USB_DEVICE_AUDIO_RESULT_OK - The request was successful.
5.9 USB Library Help MPLAB Harmony Help USB Audio Device Library
5-3987
Example
// ------------------------------------------------------------------
// In this example, the application receives current Mute info
// with in the event handler. The application uses the
// USB_DEVICE_AUDIO_ControlReceive() function to do this.
// ------------------------------------------------------------------
uint8_t DACMute = 1; // Holds the status of Mute Control
USB_DEVICE_AUDIO_EVENT_RESPONSE USBDeviceAudioEventHandler
(
USB_DEVICE_AUDIO_INDEX instanceIndex,
USB_DEVICE_AUDIO_EVENT event,
USB_DEVICE_AUDIO_CONTROL_TRANSFER_HANDLE controlTransferHandle,
USB_DEVICE_AUDIO_EVENT_DATA * pData,
uintptr_t userData
)
{
switch(event)
{
case USB_DEVICE_AUDIO_EVENT_ENTITY_SETTINGS_RECEIVED:
//In this example we have received a Set Mute request from the Host.
// Typcast the recived data into interface request.
controlRequest = (USB_AUDIO_CONTROL_INTERFACE_REQUEST*) pData;
//check entity ID (Note: Entity IDs are specified in the USB device descriptor.
switch(controlRequest->entityID)
{
case APP_ID_FEATURE_UNIT :
featureRequest = (USB_AUDIO_FEATURE_CONTROL_REQUEST*)pData;
switch(featureRequest->controlSelector)
{
case USB_AUDIO_FCS_MUTE_CONTROL:
{
if(featureRequest->bRequest == USB_AUDIO_CSRC_SET_CUR)
{
//A control write transfer recived from Host. Now recieve data
from Host.
USB_DEVICE_AUDIO_ControlReceive(iAudio, controlHandle,(uint8_t *)
&DACMute, 1 );
}
}
break;
}
break;
}
break;
case USB_DEVICE_AUDIO_EVENT_CONTROL_TRANSFER_RECEIVED:
USB_DEVICE_ControlStatus(appData.usbDevHandle,controlTransferHandle,
USB_DEVICE_CONTROL_STATUS_OK );
if (appData.currentInterfaceAlternateSetting == 1)
AK4953ADACMute(pCodecHandle, DACMute);
break;
}Remarks: None.
5.9.2.7.1.2 USB_DEVICE_AUDIO_ControlSend Function
C
USB_DEVICE_AUDIO_RESULT USB_DEVICE_AUDIO_ControlSend(
USB_DEVICE_AUDIO_INDEX instanceIndex,
USB_DEVICE_AUDIO_CONTROL_TRANSFER_HANDLE controlTransferHandle,
void * data,
size_t size
);
5.9 USB Library Help MPLAB Harmony Help USB Audio Device Library
5-3988
Description
This function allows the application to respond to the Audio function driver specific control transfer requests. It allows the
application to send data to the host in the data stage of the control transfer. For example, if the Host requests current Volume
settings to Device, then the Device needs to send a control transfer data to the Host. The function can be called in the Audio
Function Driver event handler or can be called outside the event handler. Calling this function outside the event handler defers
the response to the event. This allows the application to prepare the response data out of the event handler context, especially if
the data is not readily available. Note however, that there are timing considerations when responding to the control transfer.
Exceeding the response time will cause the host to cancel the control transfer and may cause USB host to reject the device. The
application must use the control transfer handle that was generated along with the event as the controlTransferHandle.
Preconditions
This function should only be called in response to a Audio function driver event that requires a control transfer response.
Parameters
Parameters Description
instance USB Device Audio Function Driver instance.
controlTransferHandle Control Transfer handle for the control transfer.
data Data that represents the data stage of the control transfer.
size size (in bytes) of the data to sent.
Returns
USB_DEVICE_AUDIO_RESULT_ERROR_CONTROL_TRANSFER_FAILED - The request was not successful because the
USB host cancelled the control transfer.
USB_DEVICE_AUDIO_RESULT_OK - The request was successful.
Example
// ------------------------------------------------------------------
// In this example, the application responds to am Audio Control request
// with in the event handler. The application uses the
// USB_DEVICE_AUDIO_ControlSend() function to do this.
// ------------------------------------------------------------------
uint8_t DACMute = 1; // Holds the status of Mute Control
USB_DEVICE_AUDIO_EVENT_RESPONSE USBDeviceAudioEventHandler
(
USB_DEVICE_AUDIO_INDEX instanceIndex,
USB_DEVICE_AUDIO_EVENT event,
USB_DEVICE_AUDIO_CONTROL_TRANSFER_HANDLE controlTransferHandle,
USB_DEVICE_AUDIO_EVENT_DATA * pData,
uintptr_t userData
)
{
switch(event)
{
case USB_DEVICE_AUDIO_EVENT_ENTITY_SETTINGS_RECEIVED:
//In this example we have received a Get Mute request from the Host.
// Typcast the recived data into interface request.
controlRequest = (USB_AUDIO_CONTROL_INTERFACE_REQUEST*) pData;
//check entity ID (Note: Entity IDs are specified in the USB device descriptor.
switch(controlRequest->entityID)
{
case APP_ID_FEATURE_UNIT :
featureRequest = (USB_AUDIO_FEATURE_CONTROL_REQUEST*)pData;
switch(featureRequest->controlSelector)
{
case USB_AUDIO_FCS_MUTE_CONTROL:
5.9 USB Library Help MPLAB Harmony Help USB Audio Device Library
5-3989
{
if(featureRequest->bRequest == USB_AUDIO_CSRC_GET_CUR)
{
// In this case, the application should send the current mute
// status to the host. The application must send the
// USB_DEVICE_AUDIO_ControlSend() function to send the data.
USB_DEVICE_AUDIO_ControlSend(iAudio, controlHandle, (uint8_t
*)&DACMute, 1 );
}
}
break;
}
break;
}
break;
}
Remarks: None.
5.9.2.7.1.3 USB_DEVICE_AUDIO_ControlStatus Function
C
USB_DEVICE_AUDIO_RESULT USB_DEVICE_AUDIO_ControlStatus(
USB_DEVICE_AUDIO_INDEX instanceIndex,
USB_DEVICE_AUDIO_CONTROL_TRANSFER_HANDLE controlTransferHandle,
USB_DEVICE_AUDIO_CONTROL_STATUS status
);
Description
This function allows the application to complete the status stage of the the Audio Function Driver specific control transfer
request. The application can either accept the data stage or stall it. Calling this function with status set to
USB_DEVICE_AUDIO_CONTROL_STATUS_OK will acknowledge the status stage of the control transfer. The control transfer
can be stalled by setting the status parameter to USB_DEVICE_AUDIO_CONTROL_STATUS_STALL. The function can be
called in the Audio Function Driver event handler or can be called outside the event handler. Calling this function outside the
event handler defers the response to the event. This allows the application to analyze the event response outside the event
handler. Note however, that there are timing considerations when responding to the control transfer. Exceeding the response
time will cause the host to cancel the control transfer and may cause USB host to reject the device. The application must use the
control transfer handle that was generated along with the event as the controlTransferHandle. The application must be aware of
events and associated control transfers that do or do not require data stages. Incorrect usage of the
USB_DEVICE_AUDIO_ControlStatus() function could cause the device function to be non-compliant.
Preconditions
This function should only be called in response to a Audio function driver event that requires a control transfer response.
Parameters
Parameters Description
instance USB Device Audio Function Driver instance.
controlTransferHandle Control Transfer handle for the control transfer.
status Set to USB_DEVICE_AUDIO_CONTROL_STATUS_OK to acknowledge the
control transfer. Set to USB_DEVICE_AUDIO_CONTROL_STATUS_STALL to
stall the transfer.
Returns
USB_DEVICE_AUDIO_RESULT_ERROR_CONTROL_TRANSFER_FAILED - The request was not successful because the
USB host cancelled the control transfer.
USB_DEVICE_AUDIO_RESULT_OK - The request was successful.
5.9 USB Library Help MPLAB Harmony Help USB Audio Device Library
5-3990
Example
Remarks: None.
5.9.2.7.1.4 USB_DEVICE_AUDIO_EventHandlerSet Function
C
USB_DEVICE_AUDIO_RESULT USB_DEVICE_AUDIO_EventHandlerSet(
USB_DEVICE_AUDIO_INDEX iAudio,
USB_DEVICE_AUDIO_EVENT_HANDLER eventHandler,
uintptr_t context
);
Description
This function registers a event handler for the specified Audio function driver instance. This function should be called by the
client when it receives a SET CONFIGURATION event from the device layer. A event handler must be registered for function
driver to respond to function driver specific commands. If the event handler is not registered, the device layer will stall function
driver specific commands and the USB device may not function.
Preconditions
This function should be called when the function driver has been initialized as a result of a set configuration.
Parameters
Parameters Description
instance Instance of the Audio Function Driver.
eventHandler A pointer to event handler function.
context Application specific context that is returned in the event handler.
Returns
USB_DEVICE_AUDIO_RESULT_OK - The operation was successful
USB_DEVICE_AUDIO_RESULT_ERROR_INSTANCE_INVALID - The specified instance does not exist.
USB_DEVICE_AUDIO_RESULT_ERROR_INVALID_HANDLER - The eventHandler parameter is NULL
Remarks
None.
Example
// This code snippet shows an example registering an event handler. Here
// the application specifies the context parameter as a pointer to an
// application object (appObject) that should be associated with this
// instance of the Audio function driver.
USB_DEVICE_AUDIO_RESULT result;
USB_DEVICE_AUDIO_EVENT_RESPONSE APP_USBDeviceAUDIOEventHandler
(
USB_DEVICE_AUDIO_INDEX instanceIndex ,
USB_DEVICE_AUDIO_EVENT event ,
USB_DEVICE_AUDIO_CONTROL_TRANSFER_HANDLE controlTransferHandle
void* pData, uintptr_t context
)
{
// Event Handling comes here
switch(event)
{
...
}
5.9 USB Library Help MPLAB Harmony Help USB Audio Device Library
5-3991
return(USB_DEVICE_AUDIO_EVENT_RESPONSE_NONE);
}
result = USB_DEVICE_AUDIO_EventHandlerSet ( 0 ,&APP_EventHandler, (uintptr_t) &appObject);
if(USB_DEVICE_AUDIO_RESULT_OK != result)
{
SYS_ASSERT ( false , "invalid event handler function" );
}
5.9.2.7.1.5 USB_DEVICE_AUDIO_Read Function
C
USB_DEVICE_AUDIO_RESULT USB_DEVICE_AUDIO_Read(
USB_DEVICE_AUDIO_INDEX iAudio,
USB_DEVICE_AUDIO_TRANSFER_HANDLE* transferHandle,
uint8_t interfaceNum,
void * data,
size_t size
);
Description
This function requests a data read from the USB Device Audio Function Driver Layer. The function places a requests with driver,
the request will get serviced as data is made available by the USB Host. A handle to the request is returned in the
transferHandle parameter. The termination of the request is indicated by the
USB_DEVICE_AUDIO_EVENT_READ_COMPLETE event. The amount of data read and the transfer handle associated with the
request is returned along with the event. The transfer handle expires when event handler for the
USB_DEVICE_AUDIO_EVENT_READ_COMPLETE exits. If the read request could not be accepted, the function returns an
error code and transferHandle will contain the value USB_DEVICE_AUDIO_TRANSFER_HANDLE_INVALID.
Preconditions
The function driver should have been configured.
Parameters
Parameters Description
instance USB Device Audio Function Driver instance.
transferHandle Pointer to a USB_DEVICE_AUDIO_TRANSFER_HANDLE type of variable. This
variable will contain the transfer handle in case the read request was successful.
interfaceNum The USB Audio streaming interface number on which read request is to placed.
data pointer to the data buffer where read data will be stored.
size Size of the data buffer. Refer to the description section for more details on how the
size affects the transfer.
Returns
USB_DEVICE_AUDIO_RESULT_OK - The read request was successful. transferHandle contains a valid transfer handle.
USB_DEVICE_AUDIO_RESULT_ERROR_TRANSFER_QUEUE_FULL - internal request queue is full. The write request could
not be added.
USB_DEVICE_AUDIO_RESULT_ERROR_TRANSFER_SIZE_INVALID - The specified transfer size was not a mulitple of
endpoint size or is 0.
USB_DEVICE_AUDIO_RESULT_ERROR_INSTANCE_NOT_CONFIGURED - The specified instance is not configured yet.
USB_DEVICE_AUDIO_RESULT_ERROR_INSTANCE_INVALID - The specified instance was not provisioned in the application
5.9 USB Library Help MPLAB Harmony Help USB Audio Device Library
5-3992
and is invalid.
Remarks
None
Example
// Shows an example of how to read. This assumes that
// driver was opened successfully.
USB_DEVICE_AUDIO_INDEX iAudio;
USB_DEVICE_AUDIO_TRANSFER_HANDLE transferHandle;
unit8_t interfaceNumber;
unit8_t rxBuffer[192];
USB_DEVICE_AUDIO_RESULT readRequestResult;
iAudio = 0; //specify the Audio Function driver instance number.
interfaceNumber = 1; //Specify the Audio Streaming interface number.
readRequestResult = USB_DEVICE_AUDIO_Read
(
iAudio,
&transferHandle,
interfaceNumber,
&rxBuffer,
192
);
if(USB_DEVICE_AUDIO_RESULT_OK != readRequestResult)
{
//Do Error handling here
}
// The completion of the read request will be indicated by the
// USB_DEVICE_AUDIO_EVENT_READ_COMPLETE event.
5.9.2.7.1.6 USB_DEVICE_AUDIO_Write Function
C
USB_DEVICE_AUDIO_RESULT USB_DEVICE_AUDIO_Write(
USB_DEVICE_AUDIO_INDEX iAudio,
USB_DEVICE_AUDIO_TRANSFER_HANDLE* transferHandle,
uint8_t interfaceNum,
void * data,
size_t size
);
Description
This function requests a data write to the USB Device Audio Function Driver Layer. The function places a requests with driver,
the request will get serviced as data is requested by the USB Host. A handle to the request is returned in the transferHandle
parameter. The termination of the request is indicated by the USB_DEVICE_AUDIO_EVENT_WRITE_COMPLETE event. The
amount of data written and the transfer handle associated with the request is returned along with the event in writeCompleteData
member of the pData parameter in the event handler.
The transfer handle expires when event handler for the USB_DEVICE_AUDIO_EVENT_WRITE_COMPLETE exits. If the read
request could not be accepted, the function returns an error code and transferHandle will contain the value
USB_DEVICE_AUDIO_TRANSFER_HANDLE_INVALID.
Preconditions
The function driver should have been configured.
Parameters
Parameters Description
instance USB Device Audio Function Driver instance.
5.9 USB Library Help MPLAB Harmony Help USB Audio Device Library
5-3993
transferHandle Pointer to a USB_DEVICE_AUDIO_TRANSFER_HANDLE type of variable. This
variable will contain the transfer handle in case the write request was successful.
interfaceNum The USB Audio streaming interface number on which the write request is to
placed.
data pointer to the data buffer contains the data to be written.
size Size of the data buffer. Refer to the description section for more details on how the
size affects the transfer.
Returns
USB_DEVICE_AUDIO_RESULT_OK - The read request was successful. transferHandle contains a valid transfer handle.
USB_DEVICE_AUDIO_RESULT_ERROR_TRANSFER_QUEUE_FULL - internal request queue is full. The write request could
not be added.
USB_DEVICE_AUDIO_RESULT_ERROR_TRANSFER_SIZE_INVALID - The specified transfer size was not a mulitple of
endpoint size or is 0.
USB_DEVICE_AUDIO_RESULT_ERROR_INSTANCE_NOT_CONFIGURED - The specified instance is not configured yet.
USB_DEVICE_AUDIO_RESULT_ERROR_INSTANCE_INVALID - The specified instance was not provisioned in the application
and is invalid.
Remarks
None
Example
// Shows an example of how to write. This assumes that
// driver was opened successfully.
USB_DEVICE_AUDIO_INDEX iAudio;
USB_DEVICE_AUDIO_TRANSFER_HANDLE transferHandle;
unit8_t interfaceNumber;
unit8_t txBuffer[192];
USB_DEVICE_AUDIO_RESULT writeRequestResult;
iAudio = 0; //specify the Audio Function driver instance number.
interfaceNumber = 1; //Specify the Audio Streaming interface number.
writeRequestResult = USB_DEVICE_AUDIO_Write
(
iAudio,
&transferHandle,
interfaceNumber,
&txBuffer
192
);
if(USB_DEVICE_AUDIO_RESULT_OK != writeRequestResult)
{
//Do Error handling here
}
// The completion of the write request will be indicated by the
// USB_DEVICE_AUDIO_EVENT_Write_COMPLETE event.
5.9.2.7.2 Data Types and Constants
5.9.2.7.2.1 USB_DEVICE_AUDIO_EVENT_RESPONSE_NONE Macro
C
#define USB_DEVICE_AUDIO_EVENT_RESPONSE_NONE
5.9 USB Library Help MPLAB Harmony Help USB Audio Device Library
5-3994
Description
USB Device Audio Function Driver Event Handler Response None
This is the definition of the Audio Function Driver Event Handler Response Type none.
Remarks
Intentionally defined to be empty.
5.9.2.7.2.2 USB_DEVICE_AUDIO_TRANSFER_HANDLE_INVALID Macro
C
#define USB_DEVICE_AUDIO_TRANSFER_HANDLE_INVALID ((USB_DEVICE_AUDIO_TRANSFER_HANDLE)(-1))
Description
USB Device Audio Function Driver Invalid Transfer Handle Definition
This definition defines a USB Device Audio Function Driver Invalid Transfer Handle. A Invalid Transfer Handle is returned by the
USB_DEVICE_Audio_Write() and USB_DEVICE_Audio_Read() functions when the request was not successful.
Remarks
None.
5.9.2.7.2.3 USB_DEVICE_AUDIO_CONTROL_TRANSFER_HANDLE Type
C
typedef USB_DEVICE_CONTROL_TRANSFER_HANDLE USB_DEVICE_AUDIO_CONTROL_TRANSFER_HANDLE;
Description
USB Device Audio Function Driver Control Transfer Handle
This is returned by the Audio function driver event handler and should be used by the application while responding to Audio
function driver control transfer requests.
Remarks
None.
5.9.2.7.2.4 USB_DEVICE_AUDIO_EP_INSTANCE Structure
C
typedef struct {
uint8_t epAddr;
uint16_t epMaxPacketSize;
USB_DEVICE_AUDIO_IRP_OBJECT irpObject[USB_DEVICE_AUDIO_QUEUE_SIZE];
} USB_DEVICE_AUDIO_EP_INSTANCE;
Description
This is type USB_DEVICE_AUDIO_EP_INSTANCE.
Members
Members Description
uint8_t epAddr; End point address
uint16_t epMaxPacketSize; End point maximum payload
USB_DEVICE_AUDIO_IRP_OBJECT
irpObject[USB_DEVICE_AUDIO_QUEUE_SIZE];
IRP object Q per end point
5.9 USB Library Help MPLAB Harmony Help USB Audio Device Library
5-3995
5.9.2.7.2.5 USB_DEVICE_AUDIO_EVENT Enumeration
C
typedef enum {
USB_DEVICE_AUDIO_EVENT_WRITE_COMPLETE,
USB_DEVICE_AUDIO_EVENT_READ_COMPLETE,
USB_DEVICE_AUDIO_EVENT_INTERAFCE_ALTERNATE_SETTING,
USB_DEVICE_AUDIO_EVENT_CONTROL_TRANSFER_RECEIVED,
USB_DEVICE_AUDIO_EVENT_CONTROL_TRANSFER_SENT,
USB_DEVICE_AUDIO_EVENT_ENTITY_SETTINGS_RECEIVED
} USB_DEVICE_AUDIO_EVENT;
Description
USB Device Audio Function Driver Control Transfer Status
This flag is used along with the USB_DEVICE_AUDIO_ControlStatus() function to indicate success or failure of an Audio class
specific control transfer request.
Members
Members Description
USB_DEVICE_AUDIO_EVENT_WRITE_COMPLETE This event occurs when a write operation scheduled by
calling the USB_DEVICE_AUDIO_Write() function has
completed. The pData member in the event handler will
point to
USB_DEVICE_AUDIO_EVENT_WRITE_COMPLETE_
DATA
type.
USB_DEVICE_AUDIO_EVENT_READ_COMPLETE This event occurs when a read operation scheduled by
calling the USB_DEVICE_AUDIO_Read() function has
completed. The pData member in the event handler will
point to
USB_DEVICE_AUDIO_EVENT_READ_COMPLETE_D
ATA
type.
USB_DEVICE_AUDIO_EVENT_INTERAFCE_ALTERNATE_SETTING USB spec allows Devices to have multiple alternate
settings for the same interface. This event occurs when
Host trying set an alternate setting for an interface
present in this audio function. The callback function
USB_DEVICE_AUDIO_EVENT_CALLBACK also
sends Interface Number and Alternate setting number
when this event occurs. An application need to take
necessary action based on the interface alternate
setting.
USB_DEVICE_AUDIO_EVENT_CONTROL_TRANSFER_RECEIVED This event occurs when the data stage of a control
write transfer has completed. This would occur after the
application would respond with a
USB_DEVICE_ControlReceive() function to a control
write request from Host. This event notifies the
application that the data is recived from Host and is
available at the location passed by the
USB_DEVICE_ControlReceive() function. The
application should respond to Host with Zero Length
Packet by calling USB_DEVICE_ControlStatus()
function.
5.9 USB Library Help MPLAB Harmony Help USB Audio Device Library
5-3996
USB_DEVICE_AUDIO_EVENT_CONTROL_TRANSFER_SENT This event occurs when the data stage of a control read
transfer has completed. This event would occur after
the application uses the USB_DEVICE_ControlSend()
function to respond to an entity request recived from
Host.
Remarks
None.
5.9.2.7.2.6 USB_DEVICE_AUDIO_EVENT_DATA_READ_COMPLETE Structure
C
typedef struct {
USB_DEVICE_AUDIO_TRANSFER_HANDLE handle;
uint16_t length;
} USB_DEVICE_AUDIO_EVENT_DATA_WRITE_COMPLETE, USB_DEVICE_AUDIO_EVENT_DATA_READ_COMPLETE;
Description
USB Device Audio Function Driver Read and Write Complete Event Data.
This data type defines the data structure returned by the driver along with USB_DEVICE_AUDIO_EVENT_READ_COMPLETE
and USB_DEVICE_AUDIO_EVENT_WRITE_COMPLETE events.
Members
Members Description
5.9.2.7.2.7 USB_DEVICE_AUDIO_EVENT_DATA_WRITE_COMPLETE Structure
C
typedef struct {
USB_DEVICE_AUDIO_TRANSFER_HANDLE handle;
uint16_t length;
} USB_DEVICE_AUDIO_EVENT_DATA_WRITE_COMPLETE, USB_DEVICE_AUDIO_EVENT_DATA_READ_COMPLETE;
Description
USB Device Audio Function Driver Read and Write Complete Event Data.
This data type defines the data structure returned by the driver along with USB_DEVICE_AUDIO_EVENT_READ_COMPLETE
and USB_DEVICE_AUDIO_EVENT_WRITE_COMPLETE events.
Members
Members Description
5.9.2.7.2.8 USB_DEVICE_AUDIO_EVENT_HANDLER Type
C
typedef USB_DEVICE_AUDIO_EVENT_RESPONSE (*
USB_DEVICE_AUDIO_EVENT_HANDLER)(USB_DEVICE_AUDIO_INDEX iAudio , USB_DEVICE_AUDIO_EVENT event ,
USB_DEVICE_AUDIO_CONTROL_TRANSFER_HANDLE controlTransferHandle, void * pData, uintptr_t
context);
Description
USB Device Audio Event Handler Function Pointer Type.
This data type defines the required function signature USB Device Audio Function Driver event handling callback function. The
application must register a pointer to an Audio Function Driver events handling function who's function signature (parameter and
return value types) match the types specified by this function pointer in order to receive event call backs from the Audio Function
5.9 USB Library Help MPLAB Harmony Help USB Audio Device Library
5-3997
Driver. The function driver will invoke this function with event relevant parameters. The description of the event handler function
parameters is given here.
instanceIndex - Instance index of the Audio Function Driver that generated the event.
event - Type of event generated.
controlTransferHandle - Control Transfer Handle for Audio function driver events that require application response. The
application should use this handle when the USB Audio Device Control Transfer functions to respond to the events.
pData - This parameter should be type casted to a event specific pointer type based on the event that has occurred. Refer to the
USB_DEVICE_AUDIO_EVENT enumeration description for more details.
context - Value identifying the context of the application that registered the event handling function.
Remarks
None.
5.9.2.7.2.9 USB_DEVICE_AUDIO_EVENT_RESPONSE Type
C
typedef void USB_DEVICE_AUDIO_EVENT_RESPONSE;
Description
USB Device Audio Function Driver Event Handler Response Type
This is the return type of the Audio Function Driver event handler.
Remarks
None.
5.9.2.7.2.10 USB_DEVICE_AUDIO_INDEX Type
C
typedef uintptr_t USB_DEVICE_AUDIO_INDEX;
Description
USB Device Audio Function Driver Index
This uniquely identifies a Audio Function Driver instance.
Remarks
None.
5.9.2.7.2.11 USB_DEVICE_AUDIO_INSTANCE Structure
C
typedef struct {
USB_DEVICE_HANDLE devLayerHandle;
USB_DEVICE_AUDIO_INDEX audioIndex;
USB_DEVICE_AUDIO_INTERFACE_COLLECTION infCollection;
USB_DEVICE_AUDIO_INSTANCE_STATE state;
USB_DEVICE_AUDIO_EVENT_HANDLER appEventCallBack;
uintptr_t userData;
} USB_DEVICE_AUDIO_INSTANCE;
Description
This is type USB_DEVICE_AUDIO_INSTANCE.
5.9 USB Library Help MPLAB Harmony Help USB Audio Device Library
5-3998
Members
Members Description
USB_DEVICE_HANDLE devLayerHandle; device layer instance associated with this function driver instance
USB_DEVICE_AUDIO_INDEX audioIndex; instance index
USB_DEVICE_AUDIO_INSTANCE_STATE
state;
Current state of the function driver instance
USB_DEVICE_AUDIO_EVENT_HANDLER
appEventCallBack;
Application callback
uintptr_t userData; Application user data
5.9.2.7.2.12 USB_DEVICE_AUDIO_INSTANCE_STATE Enumeration
C
typedef enum {
USB_DEVICE_AUDIO_INSTANCE_NOT_INITIALIZED = 0,
USB_DEVICE_AUDIO_INSTANCE_INITIALIZED,
USB_DEVICE_AUDIO_INSTANCE_OPENED,
USB_DEVICE_AUDIO_INSTANCE_CLOSED
} USB_DEVICE_AUDIO_INSTANCE_STATE;
Description
This is type USB_DEVICE_AUDIO_INSTANCE_STATE.
5.9.2.7.2.13 USB_DEVICE_AUDIO_INTERFACE_COLLECTION Structure
C
typedef struct {
uint8_t bControlInterfaceNum;
uint8_t numStreamingInf;
uint16_t bcdADC;
USB_DEVICE_AUDIO_EP_INSTANCE intEp[1];
bool isIntEpExists;
USB_DEVICE_AUDIO_STREAMING_INTERFACE streamInf[USB_DEVICE_AUDIO_MAX_STREAMING_INTERFACES];
} USB_DEVICE_AUDIO_INTERFACE_COLLECTION;
Description
This is type USB_DEVICE_AUDIO_INTERFACE_COLLECTION.
Members
Members Description
uint8_t bControlInterfaceNum; control interface number
uint8_t numStreamingInf; number of streaming interfaces
uint16_t bcdADC; Audio spec in BCD 0x100 or 0x200
USB_DEVICE_AUDIO_EP_INSTANCE
intEp[1];
optional interrupt ep info
bool isIntEpExists; presence or absence of the interrupt EP
5.9.2.7.2.14 USB_DEVICE_AUDIO_INTERFACE_INFO Structure
C
typedef struct {
uint8_t interfaceNumber;
uint8_t interfaceAlternateSettting;
} USB_DEVICE_AUDIO_INTERFACE_INFO;
5.9 USB Library Help MPLAB Harmony Help USB Audio Device Library
5-3999
Description
This is type USB_DEVICE_AUDIO_INTERFACE_INFO.
5.9.2.7.2.15 USB_DEVICE_AUDIO_INTERFACE_TYPE Enumeration
C
typedef enum {
USB_DEVICE_AUDIO_INTERFACE_STREAM_UNDEFINED = 0,
USB_DEVICE_AUDIO_INTERFACE_STREAM_AUDIO,
USB_DEVICE_AUDIO_INTERFACE_STREAM_MIDI,
USB_DEVICE_AUDIO_INTERFACE_FEEDBACK
} USB_DEVICE_AUDIO_INTERFACE_TYPE;
Description
This is type USB_DEVICE_AUDIO_INTERFACE_TYPE.
5.9.2.7.2.16 USB_DEVICE_AUDIO_IRP_OBJECT Structure
C
typedef struct {
USB_DEVICE_IRP irp;
USB_DEVICE_AUDIO_INDEX iAudio;
} USB_DEVICE_AUDIO_IRP_OBJECT;
Description
USB Device Audio Function Driver IRP object.
IRP object used by the Audio to service application requests.
Remarks
None.
5.9.2.7.2.17 USB_DEVICE_AUDIO_RESULT Enumeration
C
typedef enum {
USB_DEVICE_AUDIO_RESULT_OK,
USB_DEVICE_AUDIO_RESULT_ERROR_TRANSFER_SIZE_INVALID,
USB_DEVICE_AUDIO_RESULT_ERROR_TRANSFER_QUEUE_FULL,
USB_DEVICE_AUDIO_RESULT_ERROR_INSTANCE_INVALID,
USB_DEVICE_AUDIO_RESULT_ERROR_INSTANCE_NOT_CONFIGURED,
USB_DEVICE_AUDIO_RESULT_ERROR_INVALID_HANDLER,
USB_DEVICE_AUDIO_RESULT_ERROR_CONTROL_TRANSFER_FAILED,
USB_DEVICE_AUDIO_RESULT_ERROR_INVALID_INTERFACE_ID,
USB_DEVICE_AUDIO_RESULT_ERROR_INVALID_BUFFER
} USB_DEVICE_AUDIO_RESULT;
Description
USB Device Audio Function Driver USB Device Audio Result enumeration.
This enumeration lists the possible USB Device Audio Function Driver operation results. These values are returned by the
USB_DEVICE_AUDIO_Write() and USB_DEVICE_AUDIO_Read() functions.
Members
Members Description
USB_DEVICE_AUDIO_RESULT_OK The operation was successful
5.9 USB Library Help MPLAB Harmony Help USB Audio Device Library
5-4000
USB_DEVICE_AUDIO_RESULT_ERROR_TRANSFER_SIZE_INVALID The transfer size is invalid. Refer to the
description of the read or write function for more
details
USB_DEVICE_AUDIO_RESULT_ERROR_TRANSFER_QUEUE_FULL The transfer queue is full and no new transfers
can be scheduled
USB_DEVICE_AUDIO_RESULT_ERROR_INSTANCE_INVALID The specified instance is not provisioned in the
system
USB_DEVICE_AUDIO_RESULT_ERROR_INSTANCE_NOT_CONFIGURED The specified instance is not configured yet
USB_DEVICE_AUDIO_RESULT_ERROR_INVALID_HANDLER The event handler provided is NULL
USB_DEVICE_AUDIO_RESULT_ERROR_CONTROL_TRANSFER_FAILED The control transfer was aborted
USB_DEVICE_AUDIO_RESULT_ERROR_INVALID_INTERFACE_ID Interface number passed to the read or write
function is invalid.
Remarks
None.
5.9.2.7.2.18 USB_DEVICE_AUDIO_STREAMING_INTERFACE Structure
C
typedef struct {
uint8_t interfaceNum;
USB_DEVICE_AUDIO_INTERFACE_TYPE infType;
uint8_t activeSetting;
USB_DEVICE_AUDIO_STREAMING_INTERFACE_ALTERNATE_SETTING
alterntSetting[USB_DEVICE_AUDIO_MAX_ALTERNATE_SETTING];
} USB_DEVICE_AUDIO_STREAMING_INTERFACE;
Description
This is type USB_DEVICE_AUDIO_STREAMING_INTERFACE.
Members
Members Description
uint8_t interfaceNum; interface number
uint8_t activeSetting; currently active alternate setting
5.9.2.7.2.19 USB_DEVICE_AUDIO_STREAMING_INTERFACE_ALTERNATE_SETTING
Structure
C
typedef struct {
uint8_t numEndPoints;
USB_DEVICE_AUDIO_EP_INSTANCE isoDataEp;
USB_DEVICE_AUDIO_EP_INSTANCE isoSyncEp;
} USB_DEVICE_AUDIO_STREAMING_INTERFACE_ALTERNATE_SETTING;
Description
This is type USB_DEVICE_AUDIO_STREAMING_INTERFACE_ALTERNATE_SETTING.
Members
Members Description
uint8_t numEndPoints; number of end-points in this interface
USB_DEVICE_AUDIO_EP_INSTANCE
isoDataEp;
end points associated with this interface
5.9 USB Library Help MPLAB Harmony Help USB Audio Device Library
5-4001
5.9.2.7.2.20 USB_DEVICE_AUDIO_TRANSFER_HANDLE Type
C
typedef uintptr_t USB_DEVICE_AUDIO_TRANSFER_HANDLE;
Description
USB Device Audio Function Driver Transfer Handle Definition
This definition defines a USB Device Audio Function Driver Transfer Handle. A Transfer Handle is owned by the application but
its value is modified by the USB_DEVICE_AUDIO_Write() and USB_DEVICE_AUDIO_Read() functions. The transfer handle is
valid for the life time of the transfer and expires when the transfer related event had occurred.
Remarks
None.
5.9.2.8 Files
Files
Name Description
usb_device_audio.h USB Device AUDIO function Driver Interface
Description
5.9.2.8.1 usb_device_audio.h
USB DEVICE AUDIO Function Driver Interface
This file describes the USB Device AUDIO Function Driver interface.
Enumerations
Name Description
USB_DEVICE_AUDIO_EVENT USB Device Audio Function Driver Control Transfer Status
USB_DEVICE_AUDIO_INSTANCE_STATE This is type USB_DEVICE_AUDIO_INSTANCE_STATE.
USB_DEVICE_AUDIO_INTERFACE_TYPE This is type USB_DEVICE_AUDIO_INTERFACE_TYPE.
USB_DEVICE_AUDIO_RESULT USB Device Audio Function Driver USB Device Audio Result
enumeration.
Functions
Name Description
USB_DEVICE_AUDIO_ControlReceive This function allows the application to respond to the Audio function
driver specific control transfer requests. It allows the application to
receive data from the host in the data stage of the control transfer.
USB_DEVICE_AUDIO_ControlSend This function allows the application to respond to the Audio function
driver specific control transfer requests. It allows the application to send
data to the host in the data stage of the control transfer.
USB_DEVICE_AUDIO_ControlStatus This function allows the application to complete the status stage of the
the Audio Function Driver specific control transfer request.
USB_DEVICE_AUDIO_EventHandlerSet This function registers an event handler for the specified Audio function
driver instance.
5.9 USB Library Help MPLAB Harmony Help USB Audio Device Library
5-4002
USB_DEVICE_AUDIO_Read This function requests a data read from the USB Device Audio Function
Driver Layer.
USB_DEVICE_AUDIO_Write This function requests a data write to the USB Device Audio Function
Driver Layer.
Macros
Name Description
USB_DEVICE_AUDIO_EVENT_RESPONSE_NONE USB Device Audio Function Driver Event Handler
Response Type None.
USB_DEVICE_AUDIO_TRANSFER_HANDLE_INVALID USB Device Audio Function Driver Invalid Transfer
Handle Definition.
Structures
Name Description
USB_DEVICE_AUDIO_EP_INSTANCE This is type
USB_DEVICE_AUDIO_EP_INSTAN
CE.
USB_DEVICE_AUDIO_EVENT_DATA_READ_COMPLETE USB Device Audio Function Driver
Read and Write Complete Event
Data.
USB_DEVICE_AUDIO_EVENT_DATA_WRITE_COMPLETE USB Device Audio Function Driver
Read and Write Complete Event
Data.
USB_DEVICE_AUDIO_INSTANCE This is type
USB_DEVICE_AUDIO_INSTANCE.
USB_DEVICE_AUDIO_INTERFACE_COLLECTION This is type
USB_DEVICE_AUDIO_INTERFACE
_COLLECTION.
USB_DEVICE_AUDIO_INTERFACE_INFO This is type
USB_DEVICE_AUDIO_INTERFACE
_INFO.
USB_DEVICE_AUDIO_IRP_OBJECT USB Device Audio Function Driver
IRP object.
USB_DEVICE_AUDIO_STREAMING_INTERFACE This is type
USB_DEVICE_AUDIO_STREAMING
_INTERFACE.
USB_DEVICE_AUDIO_STREAMING_INTERFACE_ALTERNATE_SETTING This is type
USB_DEVICE_AUDIO_STREAMING
_INTERFACE_ALTERNATE_SETTI
NG.
Types
Name Description
USB_DEVICE_AUDIO_CONTROL_TRANSFER_HANDLE USB Device Audio Function Driver Control Transfer
Handle
USB_DEVICE_AUDIO_EVENT_HANDLER USB Device Audio Event Handler Function Pointer
Type.
USB_DEVICE_AUDIO_EVENT_RESPONSE USB Device Audio Function Driver Event Callback
Response Type
USB_DEVICE_AUDIO_INDEX USB Device Audio Function Driver Index
USB_DEVICE_AUDIO_TRANSFER_HANDLE USB Device Audio Function Driver Transfer Handle
Definition.
5.9 USB Library Help MPLAB Harmony Help USB Audio Device Library
5-4003
File Name
usb_device_audio.h
Company
Microchip Technology Incorporated
5.9.3 USB Device Layer Library
5.9.3.1 Introduction
Introduces the MPLAB Harmony USB Device Layer
Description
The USB device layer library is part of the USB device stack that is available for the Microchip family of microcontrollers. This
library has a dependency on the USB device driver to interact with the USB peripheral and therefore cannot operate
independently. Within the USB device stack, the USB device layer is basically responsible for enumeration and performing
control transfers. The USB device library implementation adheres to USB Device Framework of chapter-9 of USB specification
2.0.
In the USB device stack, the device layer features the following:
• Supports both USB Full-Speed and Hi-Speed operation
• Based on a modular and event driven architecture
• Supports the PIC32MX and PIC32MZ families of microcontrollers
• Supports composite USB devices
• Contains function drivers to implement the following type of device classes:
• CDC-ACM
• MSD
• Generic
• Audio
• HID
• Supports non-blocking operation and is RTOS friendly
• Designed to integrate readily with other Harmony Middleware
• Supports both interrupt and polling operation
5.9.3.2 Release Notes
MPLAB Harmony Version: v0.70b USB Device Layer Library Version : 0.01 Alpha Release Date: 18Nov2013
New This Release:
This is the first release of the library. The interface can change in the beta and\or 1.0 release.
5.9 USB Library Help MPLAB Harmony Help USB Device Layer Library
5-4004
Known Issues:
• Limited USB chapter 9 testing performed on HID and MSD function drivers.
• The stack has not been tested for USB Interoperability.
• The USB Device Stack has not been tested with a Real Time Operating System.
• Attach/Detach behavior has been tested in a limited capacity.
• The device stack only supports interrupt mode operation. Polled mode operation will be added in a future release.
• While running the device stack on PIC32MZ microcontroller, the stack requires 3 seconds to initialize. This is due to a
hardware issue with PIC32MZ USB module.
• Device stack operation has been tested with Windows XP and Windows 7 OS based PC USB Host.
5.9.3.3 SW License Agreement
(c) 2013 Microchip Technology Inc.
Microchip licenses this software to you solely for use with Microchip products. The software is owned by Microchip and its
licensors, and is protected under applicable copyright laws. All rights reserved.
SOFTWARE IS PROVIDED "AS IS" MICROCHIP EXPRESSLY DISCLAIMS ANY WARRANTY OF ANY KIND, WHETHER
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. IN NO EVENT SHALL MICROCHIP BE LIABLE FOR
ANY INCIDENTAL, SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, HARM TO
YOUR EQUIPMENT, COST OF PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY OR SERVICES, ANY CLAIMS
BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), ANY CLAIMS FOR INDEMNITY OR
CONTRIBUTION, OR OTHER SIMILAR COSTS.
To the fullest extent allowed by law, Microchip and its licensors liability shall not exceed the amount of fees, if any, that you have
paid directly to Microchip to use this software.
MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE TERMS.
5.9.3.4 Using the Library
5.9.3.4.1 Abstraction Model
Describes the Abstraction Model of the USB Device Layer.
Description
The block diagram shows USB device layer interaction with USB controller driver, function drivers, user application and the
system.
5.9 USB Library Help MPLAB Harmony Help USB Device Layer Library
5-4005
USB Device Layer Software Abstraction Block Diagram
System Interaction
The system is responsible for initializing and de-initializing the device layer. It is also responsible for calling the USB device layer
task routine.
Function driver interaction
The USB device layer interacts with a function driver for following reasons.
• Device layer initializes the function driver when device is configured by the host. This can happen when host issues a set
configuration request to the device. The device layer initializes only those function drivers that are valid for the selected
configuration.
• Device layer de-initializes the function driver when host issues a bus reset or when device is detached from the host or when
host unconfigures the device by setting configuration value to 0.
• The function driver task routines are run by the device layer. This means that function driver tasks runs at the same priority as
device layer task.
• The device layer forwards class/interface specific setup requests from host to function drivers for processing. The function
drivers can use device layer APIs to read data stage from endpoint 0 or write data stage to endpoint 0.
All of the above interactions are initiated by the device layer and hence it is required for a function driver to register a set of
standard APIs with the device layer for initializing/de-initializing the function driver, for handling control transfers and for running
the task routines. Registering of these callback functions with the device layer is compile time option and is done using function
driver registration table. Function driver registration is explained in the subsequent sections of this help file.
User application ( client ) interaction
User application clients can register a callback function with the device layer to get USB device events. Apart from device
events, the clients can interact with USB device layer to know other status like USB speed and remote wakeup status.
5.9 USB Library Help MPLAB Harmony Help USB Device Layer Library
5-4006
5.9.3.4.2 Library Overview
Provides an overview of the USB Device Layer Library
Description
The USB device layer mainly interacts with system, its clients and function drivers as shown in USB Device Layer Software
Abstraction Block Diagram. Hence the interfaces provided by the USB device layer can be broadly be classified as shown in the
below table. Please refer to section "Library Interface" for more information on APIs, data types and constants.
Library Interface Section Description
System Interaction Functions Provides system module interfaces, device initialization, de-initialization,
re-initialization and task functions
Client Core Functions Provides function to register callbacks, mechanism to pass events to clients
and functions to know the status.
Driver Interaction Functions Provides function driver level interfaces for handling event callbacks and
performing control transfers
5.9.3.5 How the Library Works
5.9.3.5.1 Files to Include
Describes which files to include in project while using the USB Device Layer
Description
Table 1 shows the files that must be included in the project in order to use the USB Device Layer. These files are located in the
framework folder of the MPLAB Harmony installation. It is assumed that the USB Driver files are already included in the project.
Filename Description
\framework\usb\src\dynamic\usb_device.c Contains the USB Device Layer Implementation.
\framework\usb\usb_device.h Must included in every source file that needs to invoke USB Device Layer API.
system_config.h User created file which contains the USB Device Layer Configuration MAcors.
Table 1: Files to be included in USB Device Project
5.9.3.5.2 Initializing the Library
Describes how the USB Device Layer must be initialized
Description
Following are the components that a user must initialize and register with the USB device stack for the proper operation of the
stack.
• Descriptors
• Master descriptor table
• Function registration table
5.9 USB Library Help MPLAB Harmony Help USB Device Layer Library
5-4007
The subsequent sections of this help file explains how these components must be initialized using code examples.
The flow chart shows the steps that has to be followed by the system and clients to initialize the USB device layer. The system
initializes the USB device layer. After system initializes the device layer, clients can open handle to device layer, setup callback
into the device layer and start capturing the events from the device layer.
Flowchart showing the sequence for initializing the USB device layer
The following code example shows the system side initialization sequence.
Example:
SYS_MODULE_OBJ usbDeviceObj;
DRV_HANDLE usbDevHandle;
// System module initialization
deviceLayerInit.moduleInit.value = SYS_MODULE_POWER_RUN_FULL;
// Identifies peripheral (PLIB-level) ID
deviceLayerInit.usbID = USB_ID_1;
// Boolean flag: true -> Stop USB module in Idle Mode
deviceLayerInit.stopInIdle = false;
// Boolean flag: true -> Suspend USB in Sleep Mode
deviceLayerInit.suspendInSleep = false;
// Interrupt Source for USB module
deviceLayerInit.interruptSource = INT_SOURCE_USB_1;
// Number of function drivers registered to this instance of the
USB device layer
deviceLayerInit.registeredFuncCount = 1;
// Function driver table registered to this instance of the USB device layer
deviceLayerInit.registeredFunctions = funcRegistrationTable;
// Pointer to USB Descriptor structure
deviceLayerInit.usbMasterDescriptor = &usbMasterDescriptor;
// USB operation spee.
deviceLayerInit.deviceSpeed = USB_SPEED_HIGH;
// USB device initialization
usbDeviceObj = USB_DEVICE_Initialize(USB_DEVICE_INDEX_0, &deviceLayerInit);
5.9 USB Library Help MPLAB Harmony Help USB Device Layer Library
5-4008
if (SYS_MODULE_OBJ_INVALID == usbDriverObj)
{
// Handle error
}
while(1)
{
// Call device layer task
USB_DEVICE_Tasks( usbDeviceObj );
}
The following code example shows how a client can open an handle to device layer and use the same.
Example:
void clientIntialize( void )
{
DRV_HANDLE usbDevHandle;
// Open the device layer.
usbDevHandle = USB_DEVICE_Open( USB_DEVICE_INDEX_0 );
if(DRV_HANDLE_INVALID == usbDevHandle)
{
// Handle error
}
// Register a callback with device layer to get event notification (for end point 0)
USB_DEVICE_EventCallBackSet(usbDevHandle, usbDeviceEventCallBack); // Where
usbDeviceEventCallBack is a callback function
// that must be
provided by the client
}
void usbDeviceEventCallBack( USB_DEVICE_EVENTS events, USB_DEVICE_EVENT_DATA * eventData )
{
// Handle all device layer events here.
switch( event )
{
case USB_DEVICE_EVENT_RESET:
case USB_DEVICE_EVENT_DECONFIGURED:
/* Bus reset is detected or device is unconfigured */
/* TODO: Add user code here. */
break;
case USB_DEVICE_EVENT_CONFIGURED:
if( eventData->eventConfigured.configurationValue == 1 )
{
/* The device is in configured state */
/* TODO: Add user code here. */
}
break;
case USB_DEVICE_EVENT_SUSPENDED:
/* Device is suspended */
/* TODO: Add user code here. */
break;
case USB_DEVICE_EVENT_RESUMED:
case USB_DEVICE_EVENT_ATTACHED:
case USB_DEVICE_EVENT_DETACHED:
case USB_DEVICE_EVENT_ERROR:
default:
break;
5.9 USB Library Help MPLAB Harmony Help USB Device Layer Library
5-4009
}
}
5.9.3.5.2.1 Descriptors
A USB device reports its attributes to host using descriptors that are defined in chapter 9 of USB Specification, Revision 2.0. The
user must initialize device descriptor, configurations descriptor, string descriptors and device qualifier descriptor using static
tables. If the device supports dual speeds then there can be two sets of these descriptors, one for for full speed and another for
high speed. These descriptors are then registered to the USB device stack using master descriptor table.
The following code example shows how the descriptors are initialized in system_config.c file using static tables. Refer to Master
Descriptor Table to know how to register these descriptors into USB device stack.
/* Example USB descriptors for a MSD device */
/* Device Descriptor Table */
const USB_DEVICE_DESCRIPTOR deviceDescriptor =
{
0x12, // Size of this descriptor in bytes
USB_DESCRIPTOR_DEVICE, // DEVICE descriptor type
0x0110, // USB Spec Release Number in BCD format
0x00, // Class Code
0x00, // Subclass code
0x00, // Protocol code
USB_DEVICE_EP0_BUFFER_SIZE, // Max packet size for EP0, see usbcfg.h
0x04D8, // Vendor ID
0x0009, // Product ID: mass storage device demo
0x0001, // Device release number in BCD format
0x01, // Manufacturer string index
0x02, // Product string index
0x03, // Device serial number string index
0x01 // Number of possible configurations
};
/* Configurations Descriptor Table */
const uint8_t configDescriptor[] =
{
/* Configuration Descriptor */
9, // Size of this descriptor in bytes
USB_DESCRIPTOR_CONFIGURATION, // CONFIGURATION descriptor type
0x20,0x00, // Total length of data for this cfg
1, // Number of interfaces in this cfg
1, // Index value of this configuration
0, // Configuration string index
USB_ATTRIBUTE_DEFAULT | USB_ATTRIBUTE_SELF_POWERED, // Attributes, see usbdefs_std_dsc.h
50, // Max power consumption (2X mA)
/* Interface Descriptor */
9, // Size of this descriptor in bytes
USB_DESCRIPTOR_INTERFACE, // INTERFACE descriptor type
0, // Interface Number
0, // Alternate Setting Number
2, // Number of endpoints in this intf
USB_DEVICE_MSD_INTF, // Class code
USB_DEVICE_MSD_INTF_SUBCLASS, // Subclass code
USB_DEVICE_MSD_PROTOCOL, // Protocol code
0, // Interface string index
/* Endpoint Descriptor */
7,
USB_DESCRIPTOR_ENDPOINT,
0x01 | USB_EP_DIRECTION_IN,
USB_TRANSFER_TYPE_BULK,
MSD_IN_EP_SIZE,
5.9 USB Library Help MPLAB Harmony Help USB Device Layer Library
5-4010
0x00,
0x00,
7,
USB_DESCRIPTOR_ENDPOINT,
0x01 | USB_EP_DIRECTION_OUT,
USB_TRANSFER_TYPE_BULK,
MSD_OUT_EP_SIZE,
0x00,
0x00
};
/* String descriptors Table */
/* Language code string descriptor */
const struct
{
uint8_t bLength;
uint8_t bDscType;
uint16_t string[1];
} sd000 =
{
sizeof(sd000),
USB_DESCRIPTOR_STRING,
{ 0x0409 }
};
/* Manufacturer string descriptor */
const struct
{
const uint8_t bLength;
uint8_t bDscType;
uint16_t string[25];
} sd001 =
{
sizeof(sd001),
USB_DESCRIPTOR_STRING,
{
'M','i','c','r','o','c','h','i','p',' ',
'T','e','c','h','n','o','l','o','g','y',' ','I','n','c','.'
}
};
/* Product string descriptor */
const struct
{
const uint8_t bLength;
uint8_t bDscType;
uint16_t string[22];
} sd002 =
{
sizeof(sd002),
USB_DESCRIPTOR_STRING,
{
'S','i','m','p','l','e',' ','M','S','D',' ',
'D','e','v','i','c','e',' ','D','e','m','o'
}
};
/* Serial number string descriptor. Note: This should be unique for each unit
built on the assembly line. Plugging in two units simultaneously with the
same serial number into a single machine can cause problems. Additionally, not
all hosts support all character values in the serial number string. The MSD
Bulk Only Transport (BOT) specs v1.0 restrict the serial number to consist only
of ASCII characters "0" through "9" and capital letters "A" through "F". */
5.9 USB Library Help MPLAB Harmony Help USB Device Layer Library
5-4011
const struct
{
uint8_t bLength;
uint8_t bDscType;
uint16_t string[12];
} sd003 =
{
sizeof(sd003),USB_DESCRIPTOR_STRING,
{'1','2','3','4','5','6','7','8','9','9','9','9'}
};
5.9.3.5.2.2 Master Descriptor Table
Master Descriptor Table is a static table that holds collection of pointers that points to USB descriptors. User will have to initialize
the master descriptor table and must register it with the USB device stack. During the device enumeration the stack uses these
information from the Master Descriptor Table to respond to the setup requests from the host. Following code example shows
how to set up the Master Descriptor Table. The Master Descriptor Table must then be registered with the USB device stack while
initializing the USB device layer. Refer to Initializing the Data Structure to know how it can be registered with the USB device
stack.
/* Array of string descriptors */
/* Refer to Descriptors section to see how the
string descriptors sd000 to sd003 are defined */
const uint8_t *const USB_SD_Ptr[4]=
{
(const uint8_t *const)&sd000,
(const uint8_t *const)&sd001,
(const uint8_t *const)&sd002,
(const uint8_t *const)&sd003
};
/* Array of full speed config descriptors */
/* Refer to Descriptors section to see how the
configurations descriptor configDescriptor[] is defined */
const uint8_t *const fullSpeedConfigDescSet[1] =
{
(const uint8_t *const)&configDescriptor[0]
};
/* Initialize the master descriptor table */
const USB_MASTER_DESCRIPTOR usbMasterDescriptor =
{
/* Low/Full speed device descriptor */
/* Refer to Descriptors section to see how deviceDescriptor
is initialized */
(uint8_t *)&deviceDescriptor ,
/* Total number of low/full speed configurations available */
sizeof( fullSpeedConfigDescSet )/sizeof( uint8_t* ) ,
/* Pointer to array of low/full speed configurations descriptors */
( USB_DEVICE_CONFIG_DESCS_PTR )&fullSpeedConfigDescSet[0] ,
/* High speed device descriptor. Not supported in this example
and is set to NULL.*/
NULL,
/* Total number of high speed configurations available.
5.9 USB Library Help MPLAB Harmony Help USB Device Layer Library
5-4012
Zero for this example */
0,
/* Pointer to array of high speed configurations descriptors.
Not supported in this example*/
NULL,
/* Total number of string descriptors available */
sizeof( USB_SD_Ptr )/sizeof( uint8_t* ),
/* Pointer to array of string descriptors */
(USB_DEVICE_STRING_DESCS_PTR)USB_SD_Ptr,
/* Pointer to full speed dev qualifier. Not supported in this
example */
NULL,
/* Pointer to high speed dev qualifier. Not supported in this
example*/
NULL,
};
5.9.3.5.2.3 Functions Registeration Table
This section explains how function drivers can be registered with the USB device layer using Function Registration Table.
Function Registration Table is a static table and must be configured at compile time. It contains mapping of function driver
instance to USB speed and configuration. This table helps the USB device layer to initialize the appropriate function driver for a
configuration value and device speed selected by the host.
Following code example shows how to build a function registration table.
/* This is a code example that registers MSD function
driver to the USB device stack*/
#define MSD_INDEX 0
const USB_DEVICE_FUNC_REGISTRATION_TABLE funcRegistrationTable[1] =
{
{
/* Speed: Indicating both full/high speeds here
will make the device stack to load MSD function driver
for both the speeds */
USB_SPEED_FULL | USB_SPEED_HIGH,
/* Configuration value */
1,
/* InterfaceNumber */
0,
/* Total number of interfaces in this driver */
1,
/* Instance Index of the MSD function driver that will be loaded
for this configuration value and speed */
MSD_INDEX,
/* MSD initialization data structure. See MSD documentation for this structure */
(void*)&msdInit,
/* Pointer to the structure that contains collection of MSD driver function pointers.
The USB device stack calls out these MSD functions appropriately */
(USB_DEVICE_FUNCTION_DRIVER*) &msdFunctionDriver
}
5.9 USB Library Help MPLAB Harmony Help USB Device Layer Library
5-4013
};
5.9.3.5.2.4 Initializing the Data Structure
This section explains about the USB device initialization data structure. Before initializing this data structure user must keep the
descriptors table, master descriptor table and function registration table ready and initialized. This structure maps these static
tables to an instance of USB device layer and provides a mechanism to register these static tables with the USB device layer.
Pointer to this initialization structure is then passed to USB device layer using USB_DEVICE_Initialize() function. Following code
example shows how to initialize this structure and register the same with the USB device stack.
/* USB Device initialization data structure */
const USB_DEVICE_INIT usbDevInitData =
{
/* System module initialization */
{SYS_MODULE_POWER_RUN_FULL},
/* Identifies peripheral (PLIB-level) ID */
USB_ID_1,
/* Stop in idle */
false,
/* Stop in sleep */
false,
/* Interrupt source */
INT_SOURCE_USB_1,
/* Number of functions registered to this instance of the
USB device layer. See Function Registration Table section of this help file.
We are registering on */
(sizeof(funcRegistrationTable)/sizeof(USB_DEVICE_FUNC_REGISTRATION_TABLE)),
/* Function driver table registered to this instance of the USB device layer*/
(USB_DEVICE_FUNC_REGISTRATION_TABLE*)funcRegistrationTable,
/* Pointer to Master Descriptor structure.
See Master Descriptor Table section of this help file. */
(USB_MASTER_DESCRIPTOR*)&usbMasterDescriptor
};
/* This is an example that shows how the device initialization structure
is registered with USB_DEVICE_Initialize() */
typedef struct
{
/* device layer object returned by device layer init function */
SYS_MODULE_OBJ usbDevObject;
/* Controller driver object returned by controller driver init function */
SYS_MODULE_OBJ usbCDObject;
} APP_DRV_OBJECTS;
typedef struct
{
/* device layer handle returned by device layer open function */
DRV_HANDLE usbDevHandle;
} APP_DATA;
/* Application objects */
APP_DRV_OBJECTS appDrvObject;
5.9 USB Library Help MPLAB Harmony Help USB Device Layer Library
5-4014
/* Application data */
APP_DATA appData =
{
/* device layer handle */
DRV_HANDLE_INVALID
};
void SYS_Initialize ( void )
{
/* Set up cache and wait states for
* maximum performance. */
SYSTEMConfigPerformance(80000000);
/* Initialize the BSP */
BSP_Initialize( );
/* Initialize the USB device layer.
Note the registration of initialization data structure with the USB
device layer */
appDrvObject.usbDevObject = USB_DEVICE_Initialize (USB_DEVICE_INDEX_0 ,
( SYS_MODULE_INIT* ) & usbDevInitData);
/* check if the object returned by the device layer is valid */
SYS_ASSERT((SYS_MODULE_OBJ_INVALID != appDrvObject.usbDevObject),
"Invalid USB DEVICE object");
/* open an instance of the device layer */
appData.usbDevHandle = USB_DEVICE_Open( USB_DEVICE_INDEX_0, 0 );
/* Register a callback with device layer to get event notification
(for end point 0) */
USB_DEVICE_EventCallBackSet(appData.usbDevHandle,
APP_UsbDeviceEventCallBack);
/* Enable USB device layer */
USB_DEVICE_Attach(appData.usbDevHandle);
/* Initialize the Application */
APP_Initialize ( );
/* Initializethe interrupt system */
SYS_INT_Initialize();
/* set priority for USB interrupt source */
SYS_INT_VectorPrioritySet(INT_VECTOR_USB, INT_PRIORITY_LEVEL3);
/* set sub-priority for USB interrupt source */
SYS_INT_VectorSubprioritySet(INT_VECTOR_USB, INT_SUBPRIORITY_LEVEL3);
/* Initialize the global interrupts */
SYS_INT_Enable();
}
5.9.3.5.3 Device Events
Describes the USB Device Layer Events
Description
The device layer generates following events. The application clients can capture these events by registering a callback function
into the device layer using USB_DEVICE_EventCallBackSet() function.
5.9 USB Library Help MPLAB Harmony Help USB Device Layer Library
5-4015
Events Description
USB_DEVICE_EVENT_RESET USB bus reset occurred. This event is an indication to the application client that
device layer has de-initialized the function drivers. For application client, this event
means that USB device has moved to default state and any further communication
with the function drivers must be stopped.
USB_DEVICE_EVENT_SUSPENDED This event is an indication to the application client that device is suspended and it
can put the device to power-down mode if required.
USB_DEVICE_EVENT_RESUMED Event that indicates that device has resumed from suspended state.
USB_DEVICE_EVENT_ERROR This event is an indication to the application client that an error occurred on the
USB bus.
USB_DEVICE_EVENT_SOF This event is generated for every new start of frame. Application client can use this
SOF event for general time based house keeping activities.
USB_DEVICE_EVENT_DETACHED This event is an indication to the application client that the device is detached from
the host and device layer is about to de-initialize the function drivers. For
application client, this event means that it has to stop any further interactions with
the function driver.
USB_DEVICE_EVENT_DECONFIGURED This event is generated when the USB host unconfigures the device by configuring
the device to configuration value 0.
USB_DEVICE_EVENT_CONFIGURED This event is generated when the device is configured by the host. The device
layer loads all the function drivers applicable to that configuration and application
client can interact with function drivers.
USB_DEVICE_EVENT_ATTACHED Device is attached to the USB, but is not powered.
The following code example shows how the application clients can register callback function with the to capture these events
Example:
void SYS_Initialize( void )
{
/* Add user initialization code here */
/* Register a callback with device layer to get event notification (for end point 0) */
USB_DEVICE_EventCallBackSet(appData.usbDevHandle, APP_UsbDeviceEventCallBack);
/* Enable the device */
USB_DEVICE_Attach(appData.usbDevHandle);
}
void APP_UsbDeviceEventCallBack( USB_DEVICE_EVENT event, USB_DEVICE_EVENT_DATA * pEventData )
{
switch( event )
{
case USB_DEVICE_EVENT_RESET:
case USB_DEVICE_EVENT_DECONFIGURED:
/* USB device is reset or device is deconfigured. */
/* Add user code here */
break;
case USB_DEVICE_EVENT_CONFIGURED:
/* Device is configured */
/* Check the configuration value */
if(pEventData->eventConfigured.configurationValue == 1)
5.9 USB Library Help MPLAB Harmony Help USB Device Layer Library
5-4016
{
/* Host selected configuration value 1 */
}
break;
case USB_DEVICE_EVENT_SUSPENDED:
/* Add user's code here to handle USB bus suspend event */
break;
case USB_DEVICE_EVENT_RESUMED:
case USB_DEVICE_EVENT_ERROR:
case USB_DEVICE_EVENT_SOF:
case USB_DEVICE_EVENT_DETACHED:
case USB_DEVICE_EVENT_ATTACHED:
default:
break;
}
}
5.9.3.5.4 Developing Vendor-specific Function Drivers
This topic describes the development of vendor-specific function drivers.
Description
This section is important for the users who wish to develop their own function drivers. This section covers the interface between
the function driver and USB device layer. The framework explains how the USB device layer manages function driver through a
set of callbacks.
Framework showing the interaction between Function Driver and Device Layer
The USB device layer manages the function driver using a set of standard callout functions. A function driver must implement
these callout functions as described in the following paragraphs. The pointer to these callout functions must be packed in
USB_DEVICE_FUNCTION_DRIVER structure and pointer to this structure must be registered with the USB device layer using
function registration table.
InitializeByDescriptor()
Device layer initializes a function driver by calling this function when host issues a set configuration request. This function is
called multiple times by the device layer for every descriptor that is found under the interface owned by the function driver. The
function driver must implement appropriate logic to configure itself for each descriptor. This function is called from with in the
interrupt context. Therefore the function driver design must ensure that the execution time of this function is short.
The example code for initializeByDescriptor() is shown below.
5.9 USB Library Help MPLAB Harmony Help USB Device Layer Library
5-4017
/******************************************************************************
Function:
void USB_DEVICE_MYCLASS_InitializeByDescriptorType ( SYS_MODULE_INDEX iFunctionDriver,
SYS_MODULE_INDEX iDriver,
SYS_MODULE_INDEX iUsbDevice,
void* funcDriverInit ,
uint8_t* pConfigDesc )
Summary:
USB Device MYCLASS function driver initialization. The device layer calls this function to
initialize the function driver based on the descriptor found (from the configurations
descriptor).
Precondition:
None.
Parameters:
iFunctionDriver : Function driver instance index.
usbDeviceHandle : USB device handle for communicating with the USB device layer.
funcDriverInit : Pointer to function driver init data structure. User can have his own
function driver init data structure and can register the same in the
function registration table.
intfNumber : The interface number the descriptor identified
by descriptorType belongs to.
altSetting : The alternate setting of the descriptor that is identified
by descriptorType belongs to.
pDescriptor : Pointer to the descriptor. This can point to interface descriptor
or endpoint descriptor or any class specific descriptor based on the
descriptorType.
Returns:
None.
Remarks:
None
*/
void USB_DEVICE_MYCLASS_InitializeByDescriptorType(SYS_MODULE_INDEX iFunctionDriver,
DRV_HANDLE usbDeviceHandle,
void* funcDriverInit, uint8_t intfNumber, uint8_t
altSetting,
uint8_t descriptorType, uint8_t * pDescriptor)
{
USB_ENDPOINT endpoint;
USB_ENDPOINT_DESCRIPTOR endpointDescriptor
switch(descriptorType )
{
case USB_DESCRIPTOR_ENDPOINT:
// Get the endpoint
endpointDescriptor = (USB_ENDPOINT_DESCRIPTOR *)pDescriptor;
// Enable endpoint.
USB_DEVICE_EndpointEnable(usbDeviceHandle, endpointDescriptor->endpoint,
endpointDescriptor->transferType,
endpointDescriptor->wMaxPacketSize);
break;
case USB_DESCRIPTOR_INTERFACE:
// Do interface specific initialization here.
5.9 USB Library Help MPLAB Harmony Help USB Device Layer Library
5-4018
break;
default:
// Handle class specific descriptor.
break;
}
}
DeInitialize()
Device layer de-initializes a function driver by calling this callout function when host issues a USB bus reset or when host
deconfigures the device by selecting configuration value as 0. In the DeInitialize() function, user must implement functionalities to
close endpoints and cancel the IRPs owned by that particular function driver. This callout function is called from with in the
interrupt context. Therefore the design must ensure that the execution time of this callout function is short.
The example code for DeInitialize() is shown below.
/******************************************************************************
Function:
void USB_DEVICE_MYCLASS_DeInitialize( SYS_MODULE_INDEX iFunctionDriver )
Summary:
Deinitializes an instance of the MYCLASS.
Description:
Parameters:
iFunctionDriver - function driver index
Returns:
None.
*/
static void USB_DEVICE_MYCLASS_DeInitialize( SYS_MODULE_INDEX iFunctionDriver )
{
/* Cancel all IRPs on the endpoint/s used by
MYCLASS function driver */
USB_DEVICE_IRPCancelAll( usbDeviceHandle, endpoint );
/* Disable endpoints used by this function driver */
USB_DEVICE_EndpointDisable( usbDeviceHandle, endpoint );
}
ControlTransferNotification()
Only standard setup packets whose recipient is device/endpoint is supported by the device layer. All other types of setup packet
targeted to interface/class is forwarded to appropriate function driver using "controlTransferNotification()" callout function. Setup
packets with "other" as recipient is discarded by the device layer and and a STALL is generated on the control endpoint. In this
callout function, the function driver has to parse the setup packet. If the request is supported, function driver can initiate data
stage by using USB_DEVICE_ControlSend/USB_DEVICE_ControlReceive functions . If the request is not supported, function
driver can stall the control endpoints by using USB_DEVICE_ControlStatus function. This callout function is called from with in
the interrupt context. Therefore the design must ensure that the execution time of this callout function is short. This is not a
mandatory callout function and can be set to NULL if a function driver does not support class specific setup request.
/******************************************************************************
Function:
void USB_DEVICE_MYCLASS_ControlTransferHandler(
USB_DEVICE_CONTROL_TRANSFER_HANDLE controlHandle,
SYS_MODULE_INDEX iFunctionDriver,
USB_DEVICE_CONTROL_TRANSFER_EVENT controlEvent,
5.9 USB Library Help MPLAB Harmony Help USB Device Layer Library
5-4019
void * pEventData )
Summary:
Handles all MYCLASS related control transfers.
Description:
Parameters:
controlHandle - Control Handle
iFunctionDriver - Function driver index
controlEvent - Control transfer event
pEventData - Pointer to event related data
Returns:
None.
*/
void USB_DEVICE_MYCLASS_ControlTransferHandler(
USB_DEVICE_CONTROL_TRANSFER_HANDLE controlHandle,
SYS_MODULE_INDEX iFunctionDriver,
USB_DEVICE_CONTROL_TRANSFER_EVENT controlEvent,
USB_DEVICE_CONTROL_TRANSFER_EVENT_DATA * pEventData )
{
USB_DEVICE_HID_INSTANCE *hidThisInstance;
SETUP_PKT * setupPkt = pEventData->setupRequest;
USB_DEVICE_HID_EVENT_DATA eventData;
hidThisInstance = &gUsbDeviceHidInstance[iHID] ;
if( controlEvent == USB_DEVICE_CONTROL_SETUP_REQUEST )
{
/* Setup request is received */
if( setupPkt->bmRequestType & SETUP_RECIPIENT_INTERFACE)
{
/* Handle interface specific requests here */
/* Use USB_DEVICE_ControlSend, USB_DEVICE_ControlReceive or
USB_DEVICE_ControlStatus functions appropriately to respond to
setup packet */
}
else if( ( setupPkt->bmRequestType & SETUP_TYPE_CLASS ) &&
( hidThisInstance->appCallBack != NULL ) )
{
/* Handle class specific requests here */
/* Use USB_DEVICE_ControlSend, USB_DEVICE_ControlReceive or
USB_DEVICE_ControlStatus functions appropriately to respond to
setup packet */
}
}
else if ( controlEvent == USB_DEVICE_CONTROL_DATA_RECEIVED )
{
/* Data stage is received. Handle the data */
/* Use USB_DEVICE_ControlStatus functions appropriately to respond to
data stage */
}
else if ( controlEvent == USB_DEVICE_CONTROL_DATA_SENT )
{
/* Data stage is sent */
/* This is just a success event. If required inform the same to
application clients here. */
}
}
5.9 USB Library Help MPLAB Harmony Help USB Device Layer Library
5-4020
Tasks()
All function driver tasks are called from with in the device layer tasks. Device layer can call function driver task routine using this
function driver provided callout function. With in this callout function, a function driver can implement its task specific routines.
This is not a mandatory callback function. Set this callout function to NULL if it is not supported by the function driver.
/******************************************************************************
Function:
void USB_DEVICE_MYCLASS_Tasks ( SYS_MODULE_INDEX iFunctionDriver )
Summary:
This function handles the main MSD state machine.
Description:
Precondition:
None.
Parameters:
iFunctionDriver : Function driver index.
Returns:
None.
Remarks:
None
*/
void USB_DEVICE_MYCLASS_Tasks ( SYS_MODULE_INDEX iFunctionDriver )
{
/* Perform all function driver tasks here */
}
Registering the callout functions
To register the above callout functions with the device layer, create a static table of type USB_DEVICE_FUNCTION_DRIVER
structure with pointers to callout functions. The structure must then be registered to USB device layer using function registration
table. Here is the code snippet that shows the same.
/* Make a table of USB_DEVICE_FUNCTION_DRIVER with pointers to callout functions */
const USB_DEVICE_FUNCTION_DRIVER myclassDriver = {
/* MYCLASS init function */
.initializeByDescriptor = USB_DEVICE_MYCLASS_InitializeByDescriptorType ,
/* MYCLASS de-init function */
.deInitialize = USB_DEVICE_MYCLASS_Deinitialization ,
/* MYCLASS set-up packet handler */
.controlTransferNotification = USB_DEVICE_MYCLASS_ControlTransferHandler ,
/* MYCALSS tasks function */
.tasks = USB_DEVICE_MYCLASS_Tasks
};
/* Using the function registration table register MYCLASS driver with USB device stack */
const USB_DEVICE_FUNC_REGISTRATION_TABLE funcRegistrationTable[1] =
{
{
// Speed
USB_SPEED_FULL | USB_SPEED_HIGH,
// Configuration value
1,
// interface number of MYCLASS
5.9 USB Library Help MPLAB Harmony Help USB Device Layer Library
5-4021
0,
// number of interfaces in MYCLASS
1,
// instance index of MYCLASS
0,
// MYCLASS data init structure. This structure is class specific data structure
// that will be passed as funcDriverInit parameter to
// USB_DEVICE_MYCLASS_InitializeByDescriptorType()
&myclassInit,
// My class driver structure having pointers to all the callouts
&myclassDriver
}
};
5.9.3.5.5 Library Configuration
Describes how to configure the USB Device Library
Macros
Name Description
USB_DEVICE_MAX_CLIENTS Sets the maximum possible number of clients an instance of the USB
device can open using USB_DEVICE_Open.
USB_DEVICE_MAX_FUNCTION_DRIVER Sets the maximum number of function drivers at a time that are
supported by an instance of the USB device layer.
USB_DEVICE_MAX_INSTANCES Sets the maximum possible number of instances of the USB device
that can be instantiated by using USB_DEVICE_Initialize() routine.
Description
The application designer must specify the following configuration parameters while using the USB Device Library. The
configuration macros that implement these parameters must be located in the system_config.h file in the application project and
a compiler include path (to point to the folder that contains this file) should be specified.
Configuration Macro Name Description Comments
USB_DEVICE_MAX_INSTANCES Sets the maximum
possible number of
instances of the USB
device that can be
instantiated by using
USB_DEVICE_Initialize()
routine.
In case of microcontrollers with more than one USB peripheral,
the value of this constant can be increased to support more
than one instances of USB device layer. The static
implementation supports only one instance. Setting the value of
this constant to > 1 has no effect on static implementations.
Only in dynamic implementations of the USB device layer this
value can be set > 1. The USB device layer has to support at
least one instance. Therefore, ensure that the value of this
constant is set to > 0.Increasing the instance count consumes
RAM and can lead to performance degradation.
USB_DEVICE_MAX_CLIENTS Sets the maximum
possible number of
clients an instance of the
USB device can open
using
USB_DEVICE_Open.
If multiple clients need USB device layer services, user can set
the value of this constant to > 1. The value of this macro must
not be set to zero. Each instance of the USB device layer must
support at least one client. Therefore, set the value to at least 1.
The static single client implementation of the USB device layer
supports only one client. Therefore, increasing the value of this
constant > 1 has no effect in static single client implementation.
Increasing the client count consumes RAM and can lead to
performance degradation.
5.9 USB Library Help MPLAB Harmony Help USB Device Layer Library
5-4022
5.9.3.5.5.1 USB_DEVICE_MAX_CLIENTS Macro
C
#define USB_DEVICE_MAX_CLIENTS 1
Description
If multiple clients need USB device layer services, user can set the value of this constant to > 1.
Remarks
The value of this macro must not be set to zero. Each instance of the USB device layer must support at least one client.
Therefore, set the value to at least 1.
The static single client implementaion of the USB device layer supports only one client. Therefore, increasing the value of this
constant > 1 has no effect in static single client implementation.
Increase the client count consumes RAM and can lead to performance degradation.
5.9.3.5.5.2 USB_DEVICE_MAX_FUNCTION_DRIVER Macro
C
#define USB_DEVICE_MAX_FUNCTION_DRIVER 3
Description
This constant sets the maximum number of function drivers that are loaded by a USB device instance for a configuration set by
the USB host.
Remarks
None.
5.9.3.5.5.3 USB_DEVICE_MAX_INSTANCES Macro
C
#define USB_DEVICE_MAX_INSTANCES 1
Description
In case of microcontrollers with more than one USB peripheral, the value of this constant can be increased to support more than
one instances of USB device layer.
Remarks
The static implementation supports only one instance. Setting the value of this constant to > 1 has no effect on static
implementations. Only in dynamic implementations of the USB device layer this value can be set > 1.
The USB device layer has to support at least one instance. Therefore, ensure that the value of this constant is set to > 0.
Increasing the instance count consumes RAM and can lead to performance degradation.
5.9.3.6 Library Interface
Data Types and Constants
Name Description
USB_DEVICE_INDEX_0 USB device layer index definitions.
USB_DEVICE_INDEX_1 This is macro USB_DEVICE_INDEX_1.
5.9 USB Library Help MPLAB Harmony Help USB Device Layer Library
5-4023
USB_DEVICE_INDEX_2 This is macro USB_DEVICE_INDEX_2.
USB_DEVICE_INDEX_3 This is macro USB_DEVICE_INDEX_3.
USB_DEVICE_INDEX_4 This is macro USB_DEVICE_INDEX_4.
USB_DEVICE_INDEX_5 This is macro USB_DEVICE_INDEX_5.
USB_DEVICE_INDEX_COUNT Number of valid USB Device Layer indices
USB_DEVICE_CALLBACK Pointer to a USB Device Layer callback function data
type for bus events.
USB_DEVICE_CONFIG_DESCS_PTR Pointer to an array that contains pointer to configuration
descriptors.
USB_DEVICE_CONTROL_STATUS This enumerated data-type identifies the status stage of
control transfer.
USB_DEVICE_CONTROL_TRANSFER_CALLBACK
USB_DEVICE_CONTROL_TRANSFER_EVENT This datatype defines the different control transfer events.
USB_DEVICE_CONTROL_TRANSFER_EVENT_DATA USB device control transfer event data.
USB_DEVICE_CONTROL_TRANSFER_HANDLE Data type of USB device control transfer handle.
USB_DEVICE_CONTROL_TRANSFER_RESULT Enumerated data type identifying results of a control
transfer.
USB_DEVICE_EVENT Enumerated data-type identifying the bus events that has
occurred in the USB device layer.
USB_DEVICE_EVENT_DATA Data assosciated with USB bus events.
USB_DEVICE_EVENT_DATA_CONFIGURED Data-type that holds the data related to USB device
configured event.
USB_DEVICE_FUNC_REGISTRATION_TABLE A function driver has to be registered with the USB device
layer using this structure.
USB_DEVICE_FUNCTION_DRIVER A function driver has to expose standard APIs to device
layer using following structure.
USB_DEVICE_HANDLE Data type for USB device handle.
USB_DEVICE_INIT This structure has to be initialized by the
system/application and must be passed as parameter to
USB_DEVICE_Initialize().
USB_DEVICE_POWER_STATE Enumerated data type that identifies if the device is self
powered or bus powered .
USB_DEVICE_REMOTE_WAKEUP_STATUS Enumerated data type that identifies if the remote wakeup
status of the device.
USB_DEVICE_STATE Standard USB device states as described in Chapter-9 of
USB 2.0 Specification.
USB_DEVICE_STRING_DESCS_PTR Pointer to an array that contains pointer to string
descriptors.
USB_MASTER_DESCRIPTOR Global USB descriptor structure containing pointers to
standard USB descriptor structures.
USB_DEVICE_ENDPOINT_TABLE_SIZE This is macro USB_DEVICE_ENDPOINT_TABLE_SIZE.
USB_DEVICE_HANDLE_INVALID Macro that defines the value of invalid device handle.
Client Core Functions
Name Description
USB_DEVICE_Open Opens the specified USB device layer instance and returns a handle to
it.
USB_DEVICE_ControlReceive Receives data stage of the control transfer from host to device.
USB_DEVICE_ControlSend Sends data stage of the control transfer from device to host.
USB_DEVICE_Attach This function will attach the device to the USB.
5.9 USB Library Help MPLAB Harmony Help USB Device Layer Library
5-4024
USB_DEVICE_Detach This function will detach the device from the USB.
USB_DEVICE_Status Provides the current status of the USB device layer
USB_DEVICE_ClientStatus Gets the current client-specific status of the USB device layer.
USB_DEVICE_ResumeStart This function will start the resume signalling.
USB_DEVICE_ResumeStop This function will stop the resume signalling.
USB_DEVICE_GetDeviceSpeed Informs the client of the current operation speed of the USB bus.
USB_DEVICE_GetDeviceState Returns the current state of the USB device.
USB_DEVICE_GetConfigurationValue Informs the client of the current USB device configuration set by the
USB host.
USB_DEVICE_RemoteWakeupIsEnabled Gets the "Remote wakeup" status of the device.
USB_DEVICE_PowerStateSet Sets power state of the device.
Driver Interaction Functions
Name Description
USB_DEVICE_ControlStatus Initiates status stage of the control transfer.
USB_DEVICE_EndpointEnable This function enables a endpoint for the specified direction and endpoint size.
USB_DEVICE_EndpointIsEnabled This function returns the enable/ disable status of the specified endpoint and
direction.
USB_DEVICE_EndpointIsStalled This function returns the stall status of the specified endpoint and direction.
USB_DEVICE_EndpointStall This function stalls an endpoint in the specified direction.
USB_DEVICE_EndpointStallClear This function clears the stall on an endpoint in the specified direction.
USB_DEVICE_IRPCancelAll This function cancels all IRPs that are queued and in progress at the specified
endpoint.
USB_DEVICE_IRPSubmit This function submits a I/O Request Packet (IRP) for processing to the USB
Driver.
System Interaction Functions
Name Description
USB_DEVICE_Deinitialize Deinitializes the specified instance of the USB device layer.
USB_DEVICE_Close Closes an opened handle to an instance of the USB device layer.
USB_DEVICE_Initialize Creates and initializes an instance of the USB device layer.
USB_DEVICE_ControlEventCallBackSet Client can register its call-back function into the device layer to get
control transfer events.
USB_DEVICE_Reinitialize Reinitializes the USB device layer
USB_DEVICE_EndpointDisable This function disables an endpoint.
USB_DEVICE_EventCallBackSet Client can register its call-back function into the device layer.
USB_DEVICE_Tasks USB Device layer calls all other function driver tasks in this function. It
also generates and forwards events to its clients.
Description
This section describes the Application Programming Interface (API) functions of the USB device layer library
Refer to each section for a detailed description.
5.9.3.6.1 System Interaction Functions
5.9 USB Library Help MPLAB Harmony Help USB Device Layer Library
5-4025
5.9.3.6.1.1 USB_DEVICE_Deinitialize Function
C
void USB_DEVICE_Deinitialize(
SYS_MODULE_OBJ usbDeviceObj
);
Description
This function deinitializes the specified instance of the USB device layer, disabling its operation (and any hardware) and
invalidates all of the internal data.
Preconditions
Function USB_DEVICE_Initialize must have been called before calling this routine and a valid SYS_MODULE_OBJ must have
been returned.
Parameters
Parameters Description
object USB device layer object handle, returned by USB_DEVICE_Initialize
Returns
None.
Remarks
Once the Initialize operation has been called, the Deinitialize operation must be called before the Initialize operation can be
called again.
Example
5.9.3.6.1.2 USB_DEVICE_Close Function
C
void USB_DEVICE_Close(
USB_DEVICE_HANDLE usbDeviceHandle
);
Description
This function closes an opened handle to an instance of the USB device layer, invalidating the handle.
Preconditions
The USB_DEVICE_Initialize function must have been called for the specified device layer instance. USB_DEVICE_Open must
have been called to obtain a valid opened device handle.
Parameters
Parameters Description
handle A valid open-instance handle, returned from USB_DEVICE_Open
Returns
None
Remarks
After calling this routine, the handle passed in "usbDevHandle" must not be used with any of the remaining driver routines. A
new handle must be obtained by calling USB_DEVICE_Open() before the client may use the device layer again.
5.9 USB Library Help MPLAB Harmony Help USB Device Layer Library
5-4026
Example
USB_DEVICE_HANDLE usbDeviceHandle;
// Before opening a handle, USB device must have been initialized
// by calling USB_DEVICE_Initialize().
usbDeviceHandle = USB_DEVICE_Open( USB_DEVICE_INDEX_0 );
if(USB_DEVICE_HANDLE_INVALID == usbDeviceHandle)
{
//Failed to open handle.
}
.................
.................
// User's code
.................
.................
// Close handle
USB_DEVICE_Close( usbDevHandle );
5.9.3.6.1.3 USB_DEVICE_Initialize Function
C
SYS_MODULE_OBJ USB_DEVICE_Initialize(
const SYS_MODULE_INDEX instanceIndex,
const SYS_MODULE_INIT * const init
);
Description
This function initializes an instance of USB device layer, making it ready for clients to open and use it. The number of instances
is limited by the value of macro USB_DEVICE_MAX_INSTANCES.
Preconditions
None.
Parameters
Parameters Description
instanceIndex In case of microcontrollers with multiple USB peripherals, user can create multiple
instances of USB device layer. Parameter instanceIndex identifies this instance.
init Pointer to a data structure containing any data necessary to initialize the USB
device layer
Returns
If successful, returns a valid handle to a device layer object. Otherwise, it returns SYS_MODULE_OBJ_INVALID.
Remarks
This routine must be called before any other USB Device Layer routine is called and after the initialization of USB Device Driver.
This routine should only be called once during system initialization.
Example
USB_DEVICE_INIT deviceLayerInit;
SYS_MODULE_OBJ usbDeviceObj;
// System module initialization
deviceLayerInit.moduleInit.value = SYS_MODULE_POWER_RUN_FULL;
// Identifies peripheral (PLIB-level) ID
deviceLayerInit.usbID = USB_ID_1;
// Boolean flag: true -> Stop USB module in Idle Mode
deviceLayerInit.stopInIdle = false;
5.9 USB Library Help MPLAB Harmony Help USB Device Layer Library
5-4027
// Boolean flag: true -> Suspend USB in Sleep Mode
deviceLayerInit.suspendInSleep = false;
// Interrupt Source for USB module
deviceLayerInit.interruptSource = INT_SOURCE_USB_1;
// Number of function drivers registered to this instance of the
USB device layer
deviceLayerInit.registeredFuncCount = 1;
// Function driver table registered to this instance of the USB device layer
deviceLayerInit.registeredFunctions = funcRegistrationTable;
// Pointer to USB Descriptor structure
deviceLayerInit.usbMasterDescriptor = &usbMasterDescriptor;
// USB device initialization
usbDeviceObj = USB_DEVICE_Initialize(USB_DEVICE_INDEX_0, &deviceLayerInit);
if (SYS_MODULE_OBJ_INVALID == usbDeviceObj)
{
// Handle error
}
5.9.3.6.1.4 USB_DEVICE_ControlEventCallBackSet Function
C
USB_ERROR USB_DEVICE_ControlEventCallBackSet(
USB_DEVICE_HANDLE usbDeviceHandle,
const USB_DEVICE_CONTROL_TRANSFER_CALLBACK callBackFunc
);
Description
The USB Device Layer notifies the control transfer events to the client by calling callBackFunc.
Preconditions
The device layer must have been initialized by calling USB_DEVICE_Initialize and a valid handle to the instance must have been
obtained by calling USB_DEVICE_Open.
Parameters
Parameters Description
usbDeviceHandle Pointer to the device layer handle that is returned from USB_DEVICE_Open
callBackFunc Pointer to the control transfer event handler. The device layer notifies the client
about control transfer event by calling this function.
Returns
Returns USB_ERROR_NONE if successful.
Remarks
None.
Example
5.9.3.6.1.5 USB_DEVICE_Reinitialize Function
C
void USB_DEVICE_Reinitialize(
SYS_MODULE_OBJ usbDeviceObj,
const SYS_MODULE_INIT * const init
);
Description
This function reinitializes the USB device layer.
5.9 USB Library Help MPLAB Harmony Help USB Device Layer Library
5-4028
Preconditions
USB device driver and USB device layer must have been initialized.
Parameters
Parameters Description
usbDeviceObj Driver object handle, returned by USB_DEVICE_Initialize
init Pointer to a data structure containing any data necessary to reinitialize the USB
device layer.
Returns
None
Remarks
This function can be called multiple times to reinitialize the USB device layer.
This operation reinitializes all the module variables of the USB device layer associated with the instance specified by the
parameter "usbDeviceObj".
Example
USB_DEVICE_INIT deviceLayerInit;
// System module initialization
deviceLayerInit.moduleInit.value = SYS_MODULE_POWER_RUN_FULL;
// Identifies peripheral (PLIB-level) ID
deviceLayerInit.usbID = USB_ID_1;
// Boolean flag: true -> Stop USB module in Idle Mode
deviceLayerInit.stopInIdle = false;
// Boolean flag: true -> Suspend USB in Sleep Mode
deviceLayerInit.suspendInSleep = false;
// Interrupt Source for USB module
deviceLayerInit.interruptSource = INT_SOURCE_USB_1;
// Number of function drivers registered to this instance of the
USB device layer
deviceLayerInit.registeredFuncCount = 1;
// Function driver table registered to this instance of the USB device layer
deviceLayerInit.registeredFunctions = funcRegistrationTable;
// Pointer to USB Descriptor structure
deviceLayerInit.usbMasterDescriptor = &usbMasterDescriptor;
// USB device initialization
usbDeviceObj = USB_DEVICE_Initialize(USB_DEVICE_INDEX_0, &deviceLayerInit);
if (SYS_MODULE_OBJ_INVALID == usbDeviceObj)
{
}
// Do something here.
// Re-initialize if required.
// System module initialization
deviceLayerInit.moduleInit.value = SYS_MODULE_POWER_RUN_FULL;
// Identifies peripheral (PLIB-level) ID
deviceLayerInit.usbID = USB_ID_1;
// Boolean flag: true -> Stop USB module in Idle Mode
deviceLayerInit.stopInIdle = false;
// Boolean flag: true -> Suspend USB in Sleep Mode
deviceLayerInit.suspendInSleep = false;
// Interrupt Source for USB module
deviceLayerInit.interruptSource = INT_SOURCE_USB_1;
// Number of function drivers registered to this instance of the
5.9 USB Library Help MPLAB Harmony Help USB Device Layer Library
5-4029
USB device layer
deviceLayerInit.registeredFuncCount = 1;
// Function driver table registered to this instance of the USB device layer
deviceLayerInit.registeredFunctions = funcRegistrationTable;
// Pointer to USB Descriptor structure
deviceLayerInit.usbMasterDescriptor = &usbMasterDescriptor;
USB_DEVICE_ReInitialize(USB_DEVICE_INDEX_0, &deviceLayerInit);
5.9.3.6.1.6 USB_DEVICE_EndpointDisable Function
C
USB_ERROR USB_DEVICE_EndpointDisable(
USB_DEVICE_HANDLE usbDeviceHandle,
USB_ENDPOINT endpointAndDirection
);
Description
This function disables an endpoint. If the endpoint type is control type then both directions are disabled. For non-control
endpoints, the function disables one direction at a time.
Preconditions
Client handle should be valid.
Parameters
Parameters Description
usbDeviceHandle USB device handle returned by USB_DEVICE_Open().
endpointAndDirection Specifies the endpoint and direction.
Returns
USB_ERROR_NONE - The endpoint was successfully enabled. USB_ERROR_DEVICE_ENDPOINT_INVALID - If the endpoint
that is being accessed is is out of the valid endpoint defined for this driver instance.
Remarks
This function must not be called by the application clients. Application has no access to modify the endpoint features.
Example
// This code snippet shows an example of how to disable
// a control endpoint. Note that the direction parameter is ignored.
// For a control endpoinnt, both the directions are disabled.
handle = USB_DEVICE_Open(USB_DEVICE_INDEX_0);
USB_ENDPOINT ep;
ep.endpoint = 0;
ep.direction = USB_DATA_DIRECTION_DEVICE_TO_HOST;
USB_DEVICE_EndpointDisable(handle, ep );
// This code snippet shows an example of how to disable a BULK IN
// endpoint
USB_ENDPOINT ep;
ep.endpoint = 1;
ep.direction = USB_DATA_DIRECTION_DEVICE_TO_HOST;
USB_DEVICE_EndpointDisable(handle, ep );
5.9 USB Library Help MPLAB Harmony Help USB Device Layer Library
5-4030
5.9.3.6.1.7 USB_DEVICE_EventCallBackSet Function
C
USB_ERROR USB_DEVICE_EventCallBackSet(
USB_DEVICE_HANDLE usbDeviceHandle,
const USB_DEVICE_CALLBACK callBackFunc
);
Description
The USB Device Layer notifies the event to the client by calling callBackFunc.
Preconditions
The device layer must have been initialized by calling USB_DEVICE_Initialize and a valid handle to the instance must have been
obtained by calling USB_DEVICE_Open.
Parameters
Parameters Description
usbDeviceHandle Pointer to the device layer handle that is returned from USB_DEVICE_Open
callBackFunc Pointer to the call back function. The device layer calls notifies the client about bus
event by calling this function.
Returns
Returns USB_ERROR_NONE if successful.
Remarks
None.
Example
5.9.3.6.1.8 USB_DEVICE_Tasks Function
C
void USB_DEVICE_Tasks(
SYS_MODULE_OBJ object
);
Description
This function must be periodically called by the user application. The USB Device layer calls all other function driver tasks in this
function. It also generates and forwards events to its clients.
Preconditions
Device layer must have been initialized by calling USB_DEVICE_Initialize.
Parameters
Parameters Description
devLayerObj Pointer to the Device Layer Object that is returned from USB_DEVICE_Initialize
Returns
none.
Remarks
This function must be called only after the device layer is initialized by calling function USB_DEVICE_Initialize.
Example
5.9 USB Library Help MPLAB Harmony Help USB Device Layer Library
5-4031
5.9.3.6.2 Client Core Functions
5.9.3.6.2.1 USB_DEVICE_Open Function
C
USB_DEVICE_HANDLE USB_DEVICE_Open(
const SYS_MODULE_INDEX instanceIndex,
const DRV_IO_INTENT intent
);
Description
This function opens the USB device layer instance specified by instance index and provides a handle that must be provided to all
other client-level operations to identify the caller and the instance of the USB device layer. The number of handles a client can
open is limited by the value set to USB_DEVICE_MAX_CLIENTS.
Preconditions
This function must be called after USB device driver initialization and after the initialization of USB Device Layer.
Parameters
Parameters Description
instanceIndex USB device layer instance index
intent Zero or more of the values from the enumeration DRV_IO_INTENT ORed together
to indicate the intended use of the driver
Returns
If successful, returns a valid handle to a device layer object. Otherwise, it returns SYS_MODULE_OBJ_INVALID.
Remarks
This routine must be called after USB device driver initialization and after the initialization of USB Device Layer. This routine
should be called only once during system initialization.
Example
USB_DEVICE_HANDLE usbDeviceHandle;
// Before opening a handle, USB device must have been initialized
// by calling USB_DEVICE_Initialize().
usbDeviceHandle = USB_DEVICE_Open( USB_DEVICE_INDEX_0, DRV_IO_INTENT_BLOCKING );
if(USB_DEVICE_HANDLE_INVALID == usbDeviceHandle)
{
//Failed to open handle.
}
5.9.3.6.2.2 USB_DEVICE_ControlReceive Function
C
USB_DEVICE_CONTROL_TRANSFER_RESULT USB_DEVICE_ControlReceive(
USB_DEVICE_HANDLE usbDeviceHandle,
USB_DEVICE_CONTROL_TRANSFER_HANDLE controlXferHandle,
void * data,
size_t length
);
Preconditions
Client handle should be valid.
5.9 USB Library Help MPLAB Harmony Help USB Device Layer Library
5-4032
Parameters
Parameters Description
usbDeviceHandle USB device handle returned by USB_DEVICE_Open().
controlXferHandle Control transfer handle that is returned by bus event callback function.
data Pointer to buffer that holds data.
length Size in bytes.
Returns
USB_DEVICE_CONTROL_TRANSFER_RESULT_FAILED - If control transfer is failed due to host aborting the previous control
transfer.
USB_DEVICE_CONTROL_TRANSFER_RESULT_SUCCESS - Control endpoint is successfully armed with data buffer.
Example
5.9.3.6.2.3 USB_DEVICE_ControlSend Function
C
USB_DEVICE_CONTROL_TRANSFER_RESULT USB_DEVICE_ControlSend(
USB_DEVICE_HANDLE usbDeviceHandle,
USB_DEVICE_CONTROL_TRANSFER_HANDLE controlXferHandle,
void * data,
size_t length
);
Preconditions
Client handle should be valid.
Parameters
Parameters Description
usbDeviceHandle USB device handle returned by USB_DEVICE_Open().
controlXferHandle Control transfer handle that is returned by the in bus event callback function.
data Pointer to buffer that holds data.
length Size in bytes.
Returns
USB_DEVICE_CONTROL_TRANSFER_RESULT_FAILED - If control transfer is failed due to host aborting the previous control
transfer.
USB_DEVICE_CONTROL_TRANSFER_RESULT_SUCCESS - Control endpoint is successfully armed with data buffer.
Example
5.9.3.6.2.4 USB_DEVICE_Attach Function
C
void USB_DEVICE_Attach(
USB_DEVICE_HANDLE usbDeviceHandle
);
Description
This function will attach the device to the USB. It does this by enabling the pull up resistors on the D+ or D- lines. This function
should be called when the USB device layer is ready to receive communication from the host (typically after all initialization is
complete).
5.9 USB Library Help MPLAB Harmony Help USB Device Layer Library
5-4033
Preconditions
Client handle should be valid.
Parameters
Parameters Description
usbDeviceHandle Client's USB device layer handle (returned from USB_DEVICE_Open)
Returns
None.
Remarks
None.
Example
USB_DEVICE_INIT deviceLayerInit;
SYS_MODULE_OBJ usbDeviceObj;
USB_DEVICE_HANDLE usbDeviceHandle;
// System module initialization
deviceLayerInit.moduleInit.value = SYS_MODULE_POWER_RUN_FULL;
// Identifies peripheral (PLIB-level) ID
deviceLayerInit.usbID = USB_ID_1;
// Boolean flag: true -> Stop USB module in Idle Mode
deviceLayerInit.stopInIdle = false;
// Boolean flag: true -> Suspend USB in Sleep Mode
deviceLayerInit.suspendInSleep = false;
// Interrupt Source for USB module
deviceLayerInit.interruptSource = INT_SOURCE_USB_1;
// Number of function drivers registered to this instance of the
USB device layer
deviceLayerInit.registeredFuncCount = 1;
// Function driver table registered to this instance of the USB device layer
deviceLayerInit.registeredFunctions = funcRegistrationTable;
// Pointer to USB Descriptor structure
deviceLayerInit.usbMasterDescriptor = &usbMasterDescriptor;
// USB device initialization
usbDeviceObj = USB_DEVICE_Initialize(USB_DEVICE_INDEX_0, &deviceLayerInit);
if (SYS_MODULE_OBJ_INVALID == usbDeviceObj)
{
// Handle error
}
// Get an handle to the USB device layer.
usbDeviceHandle = USB_DEVICE_Open( USB_DEVICE_INDEX_0,
DRV_IO_INTENT_BLOCKING );
if(USB_DEVICE_HANDLE_INVALID == usbDeviceHandle)
{
// Failed to open handle.
// Handle error.
}
// Now, connect device to USB
USB_DEVICE_Attach(usbDeviceHandle);
5.9.3.6.2.5 USB_DEVICE_Detach Function
C
void USB_DEVICE_Detach(
5.9 USB Library Help MPLAB Harmony Help USB Device Layer Library
5-4034
USB_DEVICE_HANDLE usbDeviceHandle
);
Description
This function will detach the device from the USB. It does this by disabling the pull up resistors on the D+ or D- lines. This
function should be called when the application wants to disconnect the device from the bus (typically to implement a soft detach
or switch to host mode operation).
Preconditions
Client handle should be valid.
Parameters
Parameters Description
usbDeviceHandle Client's driver handle (returned from USB_DEVICE_Open)
Returns
None.
Remarks
None.
Example
USB_DEVICE_HANDLE usbDeviceHandle;
// Detach the device from the USB
USB_DEVICE_Detach( usbDeviceHandle );
5.9.3.6.2.6 USB_DEVICE_Status Function
C
SYS_STATUS USB_DEVICE_Status(
SYS_MODULE_OBJ object
);
Description
This function provides the current status of the USB device layer.
Preconditions
The USB_DEVICE_Initialize function must have been called before calling this function.
Parameters
Parameters Description
object Driver object handle, returned from USB_DEVICE_Initialize
Returns
SYS_STATUS_READY - Indicates that the device is busy with a previous system level operation and cannot start another
Remarks
Any value greater than SYS_STATUS_READY is also a normal running state in which the device is ready to accept new
operations.
SYS_STATUS_BUSY - Indicates that the device is busy with a previous system level operation and cannot start another
SYS_STATUS_UNINITIALIZED - Indicates that the device has never been initialized
SYS_STATUS_ERROR - Indicates that the device is in an error state
5.9 USB Library Help MPLAB Harmony Help USB Device Layer Library
5-4035
Any value less than SYS_STATUS_ERROR is also an error state.
None.
Example
SYS_MODULE_OBJ object; // Returned from DRV_USB_Initialize
SYS_STATUS status;
status = USB_DEVICE_Status(object);
if (SYS_STATUS_ERROR >= status)
{
// Handle error
}
5.9.3.6.2.7 USB_DEVICE_ClientStatus Function
C
DRV_CLIENT_STATUS USB_DEVICE_ClientStatus(
USB_DEVICE_HANDLE usbDevHandle
);
Description
This function gets the client-specfic status of the USB device layer associated with the specified handle.
Preconditions
The USB_DEVICE_Initialize function must have been called. USB_DEVICE_Open must have been called to obtain a valid
opened device handle.
Parameters
Parameters Description
handle A valid open instance handle, returned from USB_DEVICE_Open
Returns
A value of enum type DRV_CLIENT_STATUS describing the current status of the USB device layer.
Remarks
None.
Example
5.9.3.6.2.8 USB_DEVICE_ResumeStart Function
C
void USB_DEVICE_ResumeStart(
USB_DEVICE_HANDLE usbDeviceHandle
);
Preconditions
Client handle should be valid.
Parameters
Parameters Description
usbDeviceHandle Client's driver handle (returned from USB_DEVICE_Open)
Returns
None.
5.9 USB Library Help MPLAB Harmony Help USB Device Layer Library
5-4036
Remarks
None.
Example
5.9.3.6.2.9 USB_DEVICE_ResumeStop Function
C
void USB_DEVICE_ResumeStop(
USB_DEVICE_HANDLE usbDeviceHandle
);
Preconditions
Client handle should be valid.
Parameters
Parameters Description
usbDeviceHandle Client's driver handle (returned from USB_DEVICE_Open)
Returns
None.
Remarks
None.
Example
5.9.3.6.2.10 USB_DEVICE_GetDeviceSpeed Function
C
USB_SPEED USB_DEVICE_GetDeviceSpeed(
USB_DEVICE_HANDLE usbDeviceHandle
);
Description
The USB device stack supports both high speed and full speed operations. This function returns the current operation speed of
the USB bus.
Preconditions
The USB device layer must have been initialized and a valid handle to USB device layer must have been opened.
Parameters
Parameters Description
usbDeviceHandle Pointer to device layer handle that is returned from USB_DEVICE_Open
Returns
USB_SPEED_LOW - USB module is at low speed
USB_SPEED_FULL - USB module is at full speed
USB_SPEED_HIGH - USB module is at high speed
Remarks
This function must be called only after the device layer is initialized and opened by calling USB_DEVICE_Initialize and
USB_DEVICE_Open.
5.9 USB Library Help MPLAB Harmony Help USB Device Layer Library
5-4037
Example
5.9.3.6.2.11 USB_DEVICE_GetDeviceState Function
C
USB_DEVICE_STATE USB_DEVICE_GetDeviceState(
USB_DEVICE_HANDLE usbDeviceHandle
);
Description
This function returns the current state of the USB device, as described in Chapter 9 of USB 2.0 Specification.
Preconditions
The USB device layer must have been initialized and opened before calling this function.
Parameters
Parameters Description
usbDeviceHandle Pointer to the device layer handle that is returned from USB_DEVICE_Open
Returns
USB_DEVICE_STATE_DETACHED - Device is not in any of the known states
USB_DEVICE_STATE_ATTACHED - Device is attached to the USB, but is not powered
USB_DEVICE_STATE_POWERED - Device is attached to the USB and powered, but has not been reset
USB_DEVICE_STATE_DEFAULT - Device is attached to the USB and powered and has been reset, but has not been assigned
a unique address
USB_DEVICE_STATE_ADDRESS - Device is attached to the USB, powered, has been reset, and a unique device address has
been assigned
USB_DEVICE_STATE_CONFIGURED - Device is attached to the USB, powered, has been reset, has a unique address, is
configured, and is not suspended
USB_DEVICE_STATE_SUSPENDED - Device is, at minimum, attached to the USB and is powered and has not seen bus
activity for 3 ms. The device is still in addresed state.
Remarks
This function must be called only after the device layer is initialized and opened by calling USB_DEVICE_Initialize and
USB_DEVICE_Open.
Example
USB_DEVICE_STATE usbDevState;
// Get USB Device State.
usbDevState = USB_DEVICE_GetDeviceState( usbDeviceHandle );
switch(usbDevState)
{
case USB_DEVICE_STATE_ATTACHED:
// Add code here
break;
case USB_DEVICE_STATE_POWERED:
// Add code here
break;
default:
5.9 USB Library Help MPLAB Harmony Help USB Device Layer Library
5-4038
break;
}
5.9.3.6.2.12 USB_DEVICE_GetConfigurationValue Function
C
uint8_t USB_DEVICE_GetConfigurationValue(
USB_DEVICE_HANDLE usbDeviceHandle
);
Description
This function returns the current active USB device configuration.
Preconditions
The USB Device Layer must have been initialized and opened before calling this function.
Parameters
Parameters Description
usbDeviceHandle Pointer to the Device Layer Handle that is returned from USB_DEVICE_Open
Returns
Present active configuration.
Remarks
This function must be called only after the device layer is initialized and opened by calling USB_DEVICE_Initialize and
USB_DEVICE_Open.
Example
5.9.3.6.2.13 USB_DEVICE_RemoteWakeupIsEnabled Function
C
USB_DEVICE_REMOTE_WAKEUP_STATUS USB_DEVICE_RemoteWakeupIsEnabled(
USB_DEVICE_HANDLE usbDeviceHandle
);
Preconditions
Client handle should be valid.
Parameters
Parameters Description
usbDeviceHandle USB device handle returned by USB_DEVICE_Open().
Returns
USB_DEVICE_REMOTE_WAKEUP_ENABLED - Remote wakeup is enabled. USB_DEVICE_REMOTE_WAKEUP_DISABLED -
Remote wakeup is disabled.
Example
5.9.3.6.2.14 USB_DEVICE_PowerStateSet Function
C
void USB_DEVICE_PowerStateSet(
USB_DEVICE_HANDLE usbDeviceHandle,
USB_DEVICE_POWER_STATE powerState
);
5.9 USB Library Help MPLAB Harmony Help USB Device Layer Library
5-4039
Description
Application clients can use this function to set the power state of the device. A USB device can be bus powered ot self powered.
Preconditions
Client handle should be valid.
Parameters
Parameters Description
usbDeviceHandle USB device handle returned by USB_DEVICE_Open().
powerState USB_DEVICE_POWER_STATE_BUS_POWERED/
USB_DEVICE_POWER_STATE_SELF_POWERED
Returns
None.
Example
5.9.3.6.3 Driver Interaction Functions
5.9.3.6.3.1 USB_DEVICE_ControlStatus Function
C
USB_DEVICE_CONTROL_TRANSFER_RESULT USB_DEVICE_ControlStatus(
USB_DEVICE_HANDLE usbDeviceHandle,
USB_DEVICE_CONTROL_TRANSFER_HANDLE controlTransferHandle,
USB_DEVICE_CONTROL_STATUS status
);
Preconditions
Client handle should be valid.
Parameters
Parameters Description
usbDeviceHandle USB device handle returned by USB_DEVICE_Open().
controlTransferHandle Control transfer handle that is returned by bus event callback function.
status USB_DEVICE_CONTROL_STATUS_SEND_ZLP/
USB_DEVICE_CONTROL_STATUS_STALL
Returns
USB_DEVICE_CONTROL_TRANSFER_RESULT_FAILED - If control transfer is failed due to host aborting the previous control
transfer.
USB_DEVICE_CONTROL_TRANSFER_RESULT_SUCCESS - Control endpoint is successfully armed with data buffer.
Example
5.9.3.6.3.2 USB_DEVICE_EndpointEnable Function
C
USB_ERROR USB_DEVICE_EndpointEnable(
USB_DEVICE_HANDLE usbDeviceHandle,
USB_ENDPOINT endpointAndDirection,
USB_TRANSFER_TYPE transferType,
uint16_t endpointSize
5.9 USB Library Help MPLAB Harmony Help USB Device Layer Library
5-4040
);
Description
This function enables a endpoint for the specified direction and endpoint size. The function will enable the endpoint for
communication in one direction at a time. It must be called twice if the endpoint is required to communicate in both the directions,
except for control endpoints. If the endpoint type is a control endpoint, the endpoint is always bi-directional and the function
needs to be called only once. The size of the endpoint must match the wMaxPacketSize reported in the endpoint descriptor for
this endpoint. The function does not check if the endpoint is already in use. It is the client's responsibility to make sure that a
endpoint is not accidently re-used.
Preconditions
Client handle should be valid.
Parameters
Parameters Description
usbDeviceHandle USB device handle returned by USB_DEVICE_Open().
endpointAndDirection Specifies the endpoint and direction.
transferType Should be USB_TRANSFER_TYPE_CONTROL for control endpoint,
USB_TRANSFER_TYPE_BULK for bulk endpoint,
USB_TRANSFER_TYPE_INTERRUPT for interrupt endpoint and
USB_TRANSFER_TYPE_ISOCHRONOUS for isochronous endpoint.
endpointSize Maximum size (in bytes) of the endpoint as reported in the endpoint descriptor.
Returns
USB_ERROR_NONE - The endpoint was successfully enabled. USB_ERROR_DEVICE_ENDPOINT_INVALID - If the endpoint
that is being accessed is is out of the valid endpoint defined for this driver instance.
Remarks
None.
Example
// This code snippet shows an example of how to enable endpoint
// 0 for control transfers. Note that for a control endpoint, the
// direction parameter is ignored. A control endpoint is always
// bi-directional. Endpoint sizeis 64 bytes.
USB_ENDPOINT ep;
handle = USB_DEVICE_Open(USB_DEVICE_INDEX_0);
ep.endpoint = 0;
ep.direction = USB_DATA_DIRECTION_DEVICE_TO_HOST;
USB_DEVICE_EndpointEnable(handle, ep, USB_TRANSFER_TYPE_CONTROL, 64);
// This code snippet shows an example of how to set up a endpoint
// for BULK IN transfer. For an IN transfer, data moves from device
// to host. In this example, endpoint 1 is enabled. The maximum
// packet size is 64.
USB_ENDPOINT ep;
ep.endpoint = 1;
ep.direction = USB_DATA_DIRECTION_DEVICE_TO_HOST;
USB_DEVICE_EndpointEnable(handle, ep, USB_TRANSFER_TYPE_BULK, 64);
// If endpoint 1 must also be set up for BULK OUT, then the enable
// function must be called again, as shown here.
5.9 USB Library Help MPLAB Harmony Help USB Device Layer Library
5-4041
ep.endpoint = 1;
ep.direction = USB_DATA_DIRECTION_HOST_TO_DEVICE;
USB_DEVICE_EndpointEnable(handle, ep, USB_TRANSFER_TYPE_BULK, 64);
5.9.3.6.3.3 USB_DEVICE_EndpointIsEnabled Function
C
bool USB_DEVICE_EndpointIsEnabled(
USB_DEVICE_HANDLE usbDeviceHandle,
USB_ENDPOINT endpointAndDirection
);
Description
This function returns the enable/ disable status of the specified endpoint and direction.
Preconditions
Client handle should be valid.
Parameters
Parameters Description
usbDeviceHandle USB device handle returned by USB_DEVICE_Open().
endpointAndDirection Specifies the endpoint and direction.
Returns
Returns true if the endpoint is enabled, false otherwise.
Remarks
This function must not be called by the application clients. Application has no access to read the endpoint features.
Example
// This code snippet shows an example of how the
// USB_DEVICE_EndpointIsEnabled() function can be used to obtain the
// status of the endpoint 1 and IN direction.
USB_ENDPOINT ep;
ep.endpoint = 1;
ep.direction = USB_DATA_DIRECTION_DEVICE_TO_HOST;
if(DRV_USB_ENDPOINT_STATE_DISABLED ==
USB_DEVICE_EndpointIsEnabled(handle, ep))
{
// Endpoint is disabled. Enaable endpoint.
USB_DEVICE_EndpointEnable(handle, ep, USB_ENDPOINT_TYPE_BULK, 64);
}
5.9.3.6.3.4 USB_DEVICE_EndpointIsStalled Function
C
bool USB_DEVICE_EndpointIsStalled(
USB_DEVICE_HANDLE usbDeviceHandle,
USB_ENDPOINT endpoint
);
Description
This function returns the stall status of the specified endpoint and direction.
5.9 USB Library Help MPLAB Harmony Help USB Device Layer Library
5-4042
Preconditions
Client handle should be valid.
Parameters
Parameters Description
usbDeviceHandle USB device handle returned by USB_DEVICE_Open().
endpointAndDirection Specifies the endpoint and direction.
Returns
Returns true if endpoint is stalled, false otherwise.
Remarks
This function must not be called by the application clients. Application has no access to read the endpoint features.
Example
// This code snippet shows an example of how the
// USB_DEVICE_EndpointIsStalled() function can be used to obtain the
// stall status of the endpoint 1 and IN direction.
USB_ENDPOINT ep;
ep.endpoint = 1;
ep.direction = USB_DATA_DIRECTION_DEVICE_TO_HOST;
if(true == USB_DEVICE_EndpointIsStalled (handle, ep))
{
// Endpoint stall is enabled. Clear the stall.
USB_DEVICE_EndpointStallClear(handle, ep);
}
5.9.3.6.3.5 USB_DEVICE_EndpointStall Function
C
USB_ERROR USB_DEVICE_EndpointStall(
USB_DEVICE_HANDLE usbDeviceHandle,
USB_ENDPOINT endpointAndDirection
);
Description
This function stalls an endpoint in the specified direction.
Preconditions
Client handle should be valid.
Parameters
Parameters Description
usbDeviceHandle USB device handle returned by USB_DEVICE_Open().
endpointAndDirection Specifies the endpoint and direction.
Returns
USB_ERROR_NONE - The endpoint was successfully enabled. USB_ERROR_DEVICE_ENDPOINT_INVALID - If the endpoint
that is being accessed is is out of the valid endpoint defined for this driver instance.
5.9 USB Library Help MPLAB Harmony Help USB Device Layer Library
5-4043
Remarks
This function must not be called by the application clients. Application has no access to modify the endpoint features.
Example
// This code snippet shows an example of how to stall an endpoint. In
// this case , endpoint 1 IN direction is stalled.
USB_ENDPOINT ep;
ep.endpoint = 1;
ep.direction = USB_DATA_DIRECTION_DEVICE_TO_HOST;
USB_DEVICE_EndpointStall(handle, ep);
5.9.3.6.3.6 USB_DEVICE_EndpointStallClear Function
C
USB_ERROR USB_DEVICE_EndpointStallClear(
USB_DEVICE_HANDLE usbDeviceHandle,
USB_ENDPOINT endpointAndDirection
);
Description
This function clears the stall on an endpoint in the specified direction.
Preconditions
Client handle should be valid.
Parameters
Parameters Description
usbDeviceHandle USB device handle returned by USB_DEVICE_Open().
endpointAndDirection Specifies the endpoint and direction.
Returns
USB_ERROR_NONE - The endpoint was successfully enabled. USB_ERROR_DEVICE_ENDPOINT_INVALID - If the endpoint
that is being accessed is is out of the valid endpoint defined for this driver instance.
Remarks
This function must not be called by the application clients. Application has no access to modify the endpoint features.
Example
// This code snippet shows an example of how to clear a stall. In this
// example. the stall on endpoint 1 IN direction is cleared.
USB_ENDPOINT ep;
ep.endpoint = 1;
ep.direction = USB_DATA_DIRECTION_DEVICE_TO_HOST;
USB_DEVICE_EndpointStallClear(handle, ep);
5.9.3.6.3.7 USB_DEVICE_IRPCancelAll Function
C
USB_ERROR USB_DEVICE_IRPCancelAll(
USB_DEVICE_HANDLE usbDeviceHandle,
USB_ENDPOINT endpointAndDirection
);
5.9 USB Library Help MPLAB Harmony Help USB Device Layer Library
5-4044
Description
This function cancels all IRPs that are queued and in progress at the specified endpoint. The driver checks if IRPs are to be
cancelled at two instances; when it has called the IRP callback and is ready to proccess the next IRP in the queue and when it is
ready to process the next transaction in the the current IRP. It is recommended that this function be called in the IRP callback of
the IRP that just completed as this ensures that an IRP in progress is not cancelled. Cancelling an IRP that is progress may
cause disturbance to the USB host firmware. Cancelling the IRP from any other location, other than a IRP callback could cause
an IRP that is in progress to get cancelled.
Preconditions
Client handle should be valid.
Parameters
Parameters Description
usbDeviceHandle USB device handle returned by USB_DEVICE_Open().
endpointAndDirection Specifies the endpoint and direction.
Returns
USB_ERROR_NONE - The endpoint was successfully enabled. USB_ERROR_DEVICE_ENDPOINT_INVALID - If the endpoint
that is being accessed is is out of the valid endpoint defined for this driver instance.
Remarks
This function must not be called by the application clients. Application has no access modify the IRPs.
Example
// This code snippet shows an exampl of how to cancel all IRPs.
void MyIRPCallback(USB_DEVICE_IRP * irp)
{
// Check if this is setup command
if(irp->status == USB_DEVICE_IRP_STATUS_SETUP)
{
if(IsSetupCommandSupported(irp->data) == false)
{
// This means that this setup command is not
// supported. Stall the endpoint.
USB_DEVICE_IRPCancelAll(handle, ep);
USB_DEVICE_EndpointStall(handle, ep);
}
}
}
5.9.3.6.3.8 USB_DEVICE_IRPSubmit Function
C
USB_ERROR USB_DEVICE_IRPSubmit(
USB_DEVICE_HANDLE usbDeviceHandle,
USB_ENDPOINT endpointAndDirection,
USB_DEVICE_IRP * irp
);
Description
This function submits a I/O Request Packet (IRP) for processing to the USB Driver. The IRP allows a client to send and receive
data from the USB Host. The data will sent or received through the specified endpoint. The direction of the data transfer is
indicated by the direction flag in the endpointAndDirection structure. Submitting an IRP arms the endpoint to either send data to
5.9 USB Library Help MPLAB Harmony Help USB Device Layer Library
5-4045
or receive data from the host. If an IRP is under progress on the endpoint, then the subsequent IRP submit operation will result
in the IRPs getting queued. The contents of the IRP should not be changed till the IRP has been processed.
Particular attention should be paid to the size parameter of IRP. The following should be noted:
• The size parameter while sending data to the host can be less than, greater than, equal to or be an exact multiple of
maximum packet size for the endpoint. The maximum packet size for the endpoint determines the number of transactions
required to process the IRP.
• If the size parameter while sending data to the host is less than maximum packet size, the transfer will complete in one
transaction.
• If the size parameter while sending data to the host is greater than maximum packet size, the IRP will be processed in
mulitple transactions.
• If the size parameter while sending data to the host is equal to or an exact multiple of the maximum packet size, the client can
optionally ask the driver to send a Zero Length packet by specifying the USB_DEVICE_IRP_FLAG_SEND_ZLP flag as the
flag parameter.
• The size parameter while receiving data from the host must be an exact multiple of the maximum packet size of the endpoint.
If this is not the case, the driver will return a USB_DEVICE_IRP_SUBMIT_RESULT_INVALID_SIZE result. If while processing
the IRP, the driver receives less than maximum packet size or a ZLP from the host, the driver considers the IRP as
processed. The size paramter at this point contains the actual amount of data received from the host.
Preconditions
Client handle should be valid.
Parameters
Parameters Description
usbDeviceHandle USB device handle returned by USB_DEVICE_Open().
endpointAndDirection Specifies the endpoint and direction.
irp Pointer to the USB_DEVICE_IRP structure.
Returns
USB_ERROR_NONE - if the IRP was submitted successful. USB_ERROR_IRP_SIZE_INVALID - if the size parameter of the
IRP is not correct. USB_ERROR_IRP_QUEUE_FULL - if the driver IRP queue is full.
Remarks
This function must not be called by the application clients. Application must not submit IRP directly.
Example
// The following code snippet shows an example of how to schedule a
// IRP to send data from device to host. Assume that max packet size
// is 64 and endpoint is 1.
USB_ENDPOINT ep;
USB_DEVICE_IRP irp;
ep.direction = USB_DATA_DIRECTION_DEVICE_TO_HOST;
ep.endpoint = 1;
irp.data = myDataBufferToSend;
irp.size = 130;
irp.flags = USB_DEVICE_IRP_FLAG_NONE;
irp.callback = MyIRPCompletionCallback;
irp.referenceData = (uintptr_t)&myDeviceLayerObj;
if (USB_DEVICE_IRPSubmit(handle, ep, irp)
!= USB_ERROR_NONE)
{
5.9 USB Library Help MPLAB Harmony Help USB Device Layer Library
5-4046
// This means there was an error.
}
else
{
// The status of the IRP can be checked.
while(irp.status != USB_DEVICE_IRP_STATUS_COMPLETED)
{
// Wait or run a task routine.
}
}
// The following code snippet shows how the client can request
// the driver to send a ZLP when the size is an exact multiple of
// end point size.
irp.data = myDataBufferToSend;
irp.size = 128;
irp.flags = USB_DEVICE_IRP_FLAG_SEND_ZLP;
irp.callback = MyIRPCompletionCallback;
irp.referenceData = (uintptr_t)&myDeviceLayerObj;
// Note that while receiving data from the host, the size should
// be an exact multiple maximum packet size of the endpoint. In the
// example below, the USB_DEVICE_IRPSubmit() function will
// return a USB_DEVICE_IRP_SUBMIT_RESULT_INVALID_SIZE value.
ep.direction = USB_DATA_DIRECTION_HOST_TO_DEVICE;
ep.endpoint = 1;
irp.data = myDataBufferToSend;
irp.size = 60; // THIS SIZE IS NOT CORRECT
irp.flags = USB_DEVICE_IRP_FLAG_NONE;
irp.callback = MyIRPCompletionCallback;
irp.referenceData = (uintptr_t)&myDeviceLayerObj;
5.9.3.6.4 Data Types and Constants
5.9.3.6.4.1 USB_DEVICE_INDEX_0 Macro
C
#define USB_DEVICE_INDEX_0 0
Description
USB Device Layer Index Numbers
These constants provide USB device layer index definitions.
Remarks
These constants should be used in place of hard-coded numeric literals.
These values should be passed into the USB_DEVICE_Initialize and USB_DEVICE_Open routines to identify the device layer
instance in use.
5.9.3.6.4.2 USB_DEVICE_INDEX_1 Macro
C
#define USB_DEVICE_INDEX_1 1
Description
This is macro USB_DEVICE_INDEX_1.
5.9 USB Library Help MPLAB Harmony Help USB Device Layer Library
5-4047
5.9.3.6.4.3 USB_DEVICE_INDEX_2 Macro
C
#define USB_DEVICE_INDEX_2 2
Description
This is macro USB_DEVICE_INDEX_2.
5.9.3.6.4.4 USB_DEVICE_INDEX_3 Macro
C
#define USB_DEVICE_INDEX_3 3
Description
This is macro USB_DEVICE_INDEX_3.
5.9.3.6.4.5 USB_DEVICE_INDEX_4 Macro
C
#define USB_DEVICE_INDEX_4 4
Description
This is macro USB_DEVICE_INDEX_4.
5.9.3.6.4.6 USB_DEVICE_INDEX_5 Macro
C
#define USB_DEVICE_INDEX_5 5
Description
This is macro USB_DEVICE_INDEX_5.
5.9.3.6.4.7 USB_DEVICE_INDEX_COUNT Macro
C
#define USB_DEVICE_INDEX_COUNT _USB_DEVICE_EXISTS
Description
USB Device Layer Module Index Count
This constant identifies number of valid USB device layer indices.
Remarks
This constant should be used in place of hard-coded numeric literals.
This value is derived from part-specific header files defined as part of the peripheral libraries.
5.9.3.6.4.8 USB_DEVICE_CALLBACK Type
C
typedef void (* USB_DEVICE_CALLBACK)(USB_DEVICE_EVENT event, USB_DEVICE_EVENT_DATA *
eventData);
5.9 USB Library Help MPLAB Harmony Help USB Device Layer Library
5-4048
Description
USB Device Layer Callback Function Pointer
This is the data type of the callback function that will be called by the USB device layer when there is a bus event from USB
device layer.
Remarks
A USB Device Layer callback function must have the following function signature:
void MyCallBack ( USB_DEVICE_EVENT event, USB_DEVICE_EVENT_DATA * eventData );
Where, "event" indicates an event on the USB device layer, and "MyCallBack" can be any name desired as the function is called
through the pointer.
5.9.3.6.4.9 USB_DEVICE_CONFIG_DESCS_PTR Type
C
typedef uint8_t** USB_DEVICE_CONFIG_DESCS_PTR;
Description
Configuration descriptors pointer
5.9.3.6.4.10 USB_DEVICE_CONTROL_STATUS Enumeration
C
typedef enum {
USB_DEVICE_CONTROL_STATUS_OK,
USB_DEVICE_CONTROL_STATUS_ERROR
} USB_DEVICE_CONTROL_STATUS;
Description
Control transfer status stage
Members
Members Description
USB_DEVICE_CONTROL_STATUS_OK Control transfer is supported. Send ZLP in the status stage.
USB_DEVICE_CONTROL_STATUS_ERROR Control transfer is not supported. Stall control endpoint.
Remarks
Also see, USB_DEVICE_ControlStatus
5.9.3.6.4.11 USB_DEVICE_CONTROL_TRANSFER_CALLBACK Type
C
typedef void (* USB_DEVICE_CONTROL_TRANSFER_CALLBACK)(USB_DEVICE_CONTROL_TRANSFER_HANDLE
handle, USB_DEVICE_CONTROL_TRANSFER_EVENT event, USB_DEVICE_CONTROL_TRANSFER_EVENT_DATA *
eventData);
Description
USB Device Layer control transfer callback Function Pointer
This is the data type of the callback function that will be called by the USB device layer when there is a control transfer event
from USB device layer.
5.9 USB Library Help MPLAB Harmony Help USB Device Layer Library
5-4049
Remarks
A USB Device Layer callback function must have the following function signature:
void MyCallBack ( USB_DEVICE_EVENT event, USB_DEVICE );
Where, "event" indicates an event on the USB device layer, and "MyCallBack" can be any name desired as the function is called
through the pointer.
5.9.3.6.4.12 USB_DEVICE_CONTROL_TRANSFER_EVENT Enumeration
C
typedef enum {
USB_DEVICE_CONTROL_TRANSFER_ABORTED,
USB_DEVICE_CONTROL_DATA_RECEIVED,
USB_DEVICE_CONTROL_SETUP_REQUEST,
USB_DEVICE_CONTROL_DATA_SENT = 3
} USB_DEVICE_CONTROL_TRANSFER_EVENT;
Description
USB Device control transfer events
Members
Members Description
USB_DEVICE_CONTROL_TRANSFER_ABORTED Previous control transfer was aborted.
USB_DEVICE_CONTROL_DATA_RECEIVED Control transfer data stage was completed
USB_DEVICE_CONTROL_SETUP_REQUEST A setup packet was received and control transfer is in setup stage
USB_DEVICE_CONTROL_DATA_SENT = 3 Control transfer data stage transmit is complete
Remarks
None.
5.9.3.6.4.13 USB_DEVICE_CONTROL_TRANSFER_EVENT_DATA Union
C
typedef union {
USB_SETUP_PACKET * setupRequest;
} USB_DEVICE_CONTROL_TRANSFER_EVENT_DATA;
Description
USB Device control transfer event data.
Members
Members Description
USB_SETUP_PACKET * setupRequest; Data associated with USB_DEVICE_CONTROL_SETUP_REQUEST
Remarks
None.
5.9.3.6.4.14 USB_DEVICE_CONTROL_TRANSFER_HANDLE Type
C
typedef uintptr_t USB_DEVICE_CONTROL_TRANSFER_HANDLE;
5.9 USB Library Help MPLAB Harmony Help USB Device Layer Library
5-4050
Description
Data type of control transfer handle.
This is the data type of the handle that must be used by the application client for all control transfers.
Remarks
Also see, USB_DEVICE_ControlSend USB_DEVICE_ControlReceive USB_DEVICE_ControlStatus
5.9.3.6.4.15 USB_DEVICE_CONTROL_TRANSFER_RESULT Enumeration
C
typedef enum {
USB_DEVICE_CONTROL_TRANSFER_RESULT_FAILED,
USB_DEVICE_CONTROL_TRANSFER_RESULT_SUCCESS
} USB_DEVICE_CONTROL_TRANSFER_RESULT;
Description
These enumerated values are the possible return values for control transfer operation.
Members
Members Description
USB_DEVICE_CONTROL_TRANSFER_RESULT_FAILED Control transfer failed. This could be because the control
transfer handle is no more valid since the control transfer was
aborted by host by sending a new setup packet
USB_DEVICE_CONTROL_TRANSFER_RESULT_SUCCESS Control transfer was successful
Remarks
Also see, USB_DEVICE_ControlSend USB_DEVICE_ControlReceive USB_DEVICE_ControlStatus
5.9.3.6.4.16 USB_DEVICE_EVENT Enumeration
C
typedef enum {
USB_DEVICE_EVENT_RESET,
USB_DEVICE_EVENT_SUSPENDED,
USB_DEVICE_EVENT_RESUMED,
USB_DEVICE_EVENT_ERROR,
USB_DEVICE_EVENT_SOF,
USB_DEVICE_EVENT_DETACHED,
USB_DEVICE_EVENT_DECONFIGURED,
USB_DEVICE_EVENT_CONFIGURED,
USB_DEVICE_EVENT_ATTACHED
} USB_DEVICE_EVENT;
Description
Datatype that identifies the event that is active in the USB device layer.
Members
Members Description
USB_DEVICE_EVENT_RESET USB bus reset occurred. This event is an indication to the application client that
device layer is about to de-initialize the function drivers. For application client, this
event means that it has to close any open handles to function drivers
USB_DEVICE_EVENT_SUSPENDED This event is an indication to the application client that device is suspended and it
can put the device to power-down mode if required.
USB_DEVICE_EVENT_RESUMED This event indicates that device has resumed from suspended state.
5.9 USB Library Help MPLAB Harmony Help USB Device Layer Library
5-4051
USB_DEVICE_EVENT_ERROR This event is an indication to the application client that an error occurred on the
USB bus
5.9.3.6.4.17 USB_DEVICE_EVENT_DATA Union
C
typedef union {
USB_DEVICE_EVENT_DATA_CONFIGURED eventConfigured;
} USB_DEVICE_EVENT_DATA;
Members
Members Description
USB_DEVICE_EVENT_DATA_CONFIGURED
eventConfigured;
Data related to configured event
Remarks
Also see USB_DEVICE_CALLBACK
5.9.3.6.4.18 USB_DEVICE_EVENT_DATA_CONFIGURED Structure
C
typedef struct {
uint8_t configurationValue;
USB_SPEED speed;
} USB_DEVICE_EVENT_DATA_CONFIGURED;
Members
Members Description
uint8_t configurationValue; Configuration value selected by the host
USB_SPEED speed; USB speed at which the device is connected to host
Remarks
Also see USB_DEVICE_EVENT_DATA USB_DEVICE_CALLBACK
5.9.3.6.4.19 USB_DEVICE_FUNC_REGISTRATION_TABLE Structure
C
typedef struct {
USB_SPEED speed;
uint8_t configurationValue;
uint8_t interfaceNumber;
uint8_t numberOfInterfaces;
SYS_MODULE_INDEX funcDriverIndex;
void* funcDriverInit;
USB_DEVICE_FUNCTION_DRIVER* driver;
} USB_DEVICE_FUNC_REGISTRATION_TABLE;
Description
Global USB Device function registration structure
Members
Members Description
USB_SPEED speed; Type of speed (high, full or low speed)
uint8_t configurationValue; Configuration Value to which the function driver has to be tied
5.9 USB Library Help MPLAB Harmony Help USB Device Layer Library
5-4052
uint8_t interfaceNumber; Interface number to which this function driver has to be tied
uint8_t numberOfInterfaces; Number of interfaces used by the function
SYS_MODULE_INDEX funcDriverIndex; Function driver instance index
void* funcDriverInit; Pointer to a structure that contains function driver initialization data
USB_DEVICE_FUNCTION_DRIVER*
driver;
Pinter to a standard structure that exposes function driver APIs to USB device
layer
5.9.3.6.4.20 USB_DEVICE_FUNCTION_DRIVER Structure
C
typedef struct {
void (* initializeByDescriptor)(SYS_MODULE_INDEX funcDriverIndex, USB_DEVICE_HANDLE
usbDeviceHandle, void* funcDriverInit, uint8_t interfaceNumber, uint8_t alternateSetting,
uint8_t descriptorType, uint8_t * pDescriptor);
void (* deInitialize)(SYS_MODULE_INDEX funcDriverIndex);
void (* controlTransferNotification)(USB_DEVICE_CONTROL_TRANSFER_HANDLE controlHandle,
SYS_MODULE_INDEX index, USB_DEVICE_CONTROL_TRANSFER_EVENT controlEvent,
USB_DEVICE_CONTROL_TRANSFER_EVENT_DATA * controlEventData);
void (* tasks)(SYS_MODULE_INDEX funcDriverIndex);
} USB_DEVICE_FUNCTION_DRIVER;
Description
USB function driver structure
All function drivers (including vendor specific ones) must provide callback functions to USB device layer in the format specified
by this structure. The USB device layer calls these callback functions at the time of appropriate event.
Members
Members Description
void (* initializeByDescriptor)(SYS_MODULE_INDEX funcDriverIndex,
USB_DEVICE_HANDLE usbDeviceHandle, void* funcDriverInit, uint8_t
interfaceNumber, uint8_t alternateSetting, uint8_t descriptorType, uint8_t *
pDescriptor);
Initialize gets called by the Device layer when it
recieves set configuration event. The device
layer will initialize a function driver for every
descriptor. Based on the descriptor type the
function driver has to initialize itself.
void (* deInitialize)(SYS_MODULE_INDEX funcDriverIndex); deInit gets called when the device layer detects
a device dettach, change in configuration or ob
USB bus reset.
void (*
controlTransferNotification)(USB_DEVICE_CONTROL_TRANSFER_HANDLE
controlHandle, SYS_MODULE_INDEX index,
USB_DEVICE_CONTROL_TRANSFER_EVENT controlEvent,
USB_DEVICE_CONTROL_TRANSFER_EVENT_DATA * controlEventData);
This function will be called by the device layer
when there is a interface specific setup packet
request
void (* tasks)(SYS_MODULE_INDEX funcDriverIndex); Function driver Tasks
Remarks
Even the vendor specific function drivers must provide callback functions in this format.
5.9.3.6.4.21 USB_DEVICE_HANDLE Type
C
typedef uintptr_t USB_DEVICE_HANDLE;
Description
Data type for USB device handle.
5.9 USB Library Help MPLAB Harmony Help USB Device Layer Library
5-4053
The data type of the handle that is returned from USB_DEVICE_Open function.
Remarks
None.
5.9.3.6.4.22 USB_DEVICE_INIT Structure
C
typedef struct {
SYS_MODULE_INIT moduleInit;
unsigned int usbID;
bool stopInIdle;
bool suspendInSleep;
INT_SOURCE interruptSource;
void * endpointTable;
uint16_t registeredFuncCount;
USB_DEVICE_FUNC_REGISTRATION_TABLE * registeredFunctions;
USB_MASTER_DESCRIPTOR * usbMasterDescriptor;
USB_SPEED deviceSpeed;
} USB_DEVICE_INIT;
Description
USB Device Initialization Structure
Members
Members Description
SYS_MODULE_INIT moduleInit; System module initialization
unsigned int usbID; Identifies peripheral (PLIB-level) ID
bool stopInIdle; Boolean flag: true -> Stop USB module in Idle Mode
bool suspendInSleep; Boolean flag: true -> Suspend USB in Sleep Mode
INT_SOURCE interruptSource; Interrupt Source for USB module
void * endpointTable; Endpoint Table Buffer
uint16_t registeredFuncCount; Number of function drivers registered to this instance of the USB device layer
USB_DEVICE_FUNC_REGISTRATION_TABLE
* registeredFunctions;
Function driver table registered to this instance of the USB device layer
USB_MASTER_DESCRIPTOR *
usbMasterDescriptor;
Pointer to USB Descriptor structure
USB_SPEED deviceSpeed; Speed at which this device speed should operate
Remarks
Also see, USB_DEVICE_Initialization
5.9.3.6.4.23 USB_DEVICE_POWER_STATE Enumeration
C
typedef enum {
USB_DEVICE_POWER_STATE_BUS_POWERED,
USB_DEVICE_POWER_STATE_SELF_POWERED
} USB_DEVICE_POWER_STATE;
Description
Power state
5.9 USB Library Help MPLAB Harmony Help USB Device Layer Library
5-4054
Members
Members Description
USB_DEVICE_POWER_STATE_BUS_POWERED Device is bus powered
USB_DEVICE_POWER_STATE_SELF_POWERED Device is self powered
Remarks
Also see, USB_DEVICE_PowerStateSet
5.9.3.6.4.24 USB_DEVICE_REMOTE_WAKEUP_STATUS Enumeration
C
typedef enum {
USB_DEVICE_REMOTE_WAKEUP_DISABLED,
USB_DEVICE_REMOTE_WAKEUP_ENABLED
} USB_DEVICE_REMOTE_WAKEUP_STATUS;
Description
Remote wakeup status
Members
Members Description
USB_DEVICE_REMOTE_WAKEUP_DISABLED Remote wakeup is disabled
USB_DEVICE_REMOTE_WAKEUP_ENABLED Remote wakeup is enabled
Remarks
Also see, USB_DEVICE_RemoteWakeupIsEnabled
5.9.3.6.4.25 USB_DEVICE_STATE Enumeration
C
typedef enum {
USB_DEVICE_STATE_DETACHED,
USB_DEVICE_STATE_ATTACHED,
USB_DEVICE_STATE_POWERED,
USB_DEVICE_STATE_DEFAULT,
USB_DEVICE_STATE_ADDRESSED,
USB_DEVICE_STATE_CONFIGURED,
USB_DEVICE_STATE_SUSPENDED
} USB_DEVICE_STATE;
Description
USB device states as described in chapter-9 of USB 2.0 specification
This data type identifies the USB Device States.
Members
Members Description
USB_DEVICE_STATE_DETACHED Device is not in any of the known USB states
USB_DEVICE_STATE_ATTACHED Device is in attached state
USB_DEVICE_STATE_POWERED Device is in powered state
USB_DEVICE_STATE_DEFAULT Device is in default state
USB_DEVICE_STATE_ADDRESSED Device is in addressed state
USB_DEVICE_STATE_CONFIGURED Device is in configured state
5.9 USB Library Help MPLAB Harmony Help USB Device Layer Library
5-4055
USB_DEVICE_STATE_SUSPENDED Device is in suspended state
Remarks
The USB specification doesn't define the state of a device when it is detached from the USB. The
USB_DEVICE_STATE_DETACHED is not the standard state, but is required to indicate the user, that the device is not in any of
the known states.
5.9.3.6.4.26 USB_DEVICE_STRING_DESCS_PTR Type
C
typedef uint8_t** USB_DEVICE_STRING_DESCS_PTR;
Description
String descriptors pointer
5.9.3.6.4.27 USB_MASTER_DESCRIPTOR Structure
C
typedef struct {
uint8_t* ptrDeviceDescriptor;
uint8_t configDescriptorCount;
USB_DEVICE_CONFIG_DESCS_PTR ptrConfigDescriptor;
uint8_t* ptrHighSpeedDeviceDescriptor;
uint8_t highSpeedConfigDescriptorCount;
USB_DEVICE_CONFIG_DESCS_PTR ptrHighSpeedConfigDescriptor;
uint8_t stringDescCount;
USB_DEVICE_STRING_DESCS_PTR ptrStringDesc;
uint8_t* ptrFullSpeedDeviceQualifier;
uint8_t* ptrHighSpeedDeviceQualifier;
} USB_MASTER_DESCRIPTOR;
Description
Global USB Descriptor Structure.
Members
Members Description
uint8_t* ptrDeviceDescriptor; Pointer to standard device descriptor (for low/full speed)
uint8_t configDescriptorCount; Total number configurations available (for low/full speed)
USB_DEVICE_CONFIG_DESCS_PTR
ptrConfigDescriptor;
Pointer to array of configurations descriptor pointers (for low/full speed)
uint8_t* ptrHighSpeedDeviceDescriptor; Pointer to array of high speed standard Device descriptor. Assign this to NULL if
not supported.
uint8_t highSpeedConfigDescriptorCount; Total number of high speed configurations available. Set this to zero if not
supported
USB_DEVICE_CONFIG_DESCS_PTR
ptrHighSpeedConfigDescriptor;
Pointer to array of high speed configurations descriptor pointers. Set this to NULL
if not supported
uint8_t stringDescCount; Total number of string descriptors available (common to all speeds)
USB_DEVICE_STRING_DESCS_PTR
ptrStringDesc;
Pointer to array of string Descriptor pointers (common to all speeds)
uint8_t* ptrFullSpeedDeviceQualifier; Pointer to full speed device_qualifier descriptor. Device responds with this
descriptor when it is operating at high speed
uint8_t* ptrHighSpeedDeviceQualifier; Pointer to high speed device_qualifier descriptor. Device responds with this
descriptor when it is operating at full speed
5.9 USB Library Help MPLAB Harmony Help USB Device Layer Library
5-4056
5.9.3.6.4.28 USB_DEVICE_ENDPOINT_TABLE_SIZE Macro
C
#define USB_DEVICE_ENDPOINT_TABLE_SIZE (DRV_USB_ENDPOINTS_NUMBER *
DRV_USB_ENDPOINT_TABLE_ENTRY_SIZE)
Description
This is macro USB_DEVICE_ENDPOINT_TABLE_SIZE.
5.9.3.6.4.29 USB_DEVICE_HANDLE_INVALID Macro
C
#define USB_DEVICE_HANDLE_INVALID ((USB_DEVICE_HANDLE)(-1))
Description
USB Device Layer invalid handle
5.9.3.7 Files
Files
Name Description
usb_device.h USB Device Layer Interface Header
usb_device_config_template.h USB device configuration template header file.
Description
5.9.3.7.1 usb_device.h
USB Device Layer Interface Definition
This header file contains the function prototypes and definitions of the data types and constants that make up the interface to the
USB device layer.
Enumerations
Name Description
USB_DEVICE_CONTROL_STATUS This enumerated data-type identifies the status stage of control
transfer.
USB_DEVICE_CONTROL_TRANSFER_EVENT This datatype defines the different control transfer events.
USB_DEVICE_CONTROL_TRANSFER_RESULT Enumerated data type identifying results of a control transfer.
USB_DEVICE_EVENT Enumerated data-type identifying the bus events that has
occurred in the USB device layer.
USB_DEVICE_POWER_STATE Enumerated data type that identifies if the device is self
powered or bus powered .
USB_DEVICE_REMOTE_WAKEUP_STATUS Enumerated data type that identifies if the remote wakeup
status of the device.
USB_DEVICE_STATE Standard USB device states as described in Chapter-9 of USB
2.0 Specification.
5.9 USB Library Help MPLAB Harmony Help USB Device Layer Library
5-4057
Functions
Name Description
USB_DEVICE_Attach This function will attach the device to the USB.
USB_DEVICE_ClientStatus Gets the current client-specific status of the USB device layer.
USB_DEVICE_Close Closes an opened handle to an instance of the USB device layer.
USB_DEVICE_ControlEventCallBackSet Client can register its call-back function into the device layer to get
control transfer events.
USB_DEVICE_ControlReceive Receives data stage of the control transfer from host to device.
USB_DEVICE_ControlSend Sends data stage of the control transfer from device to host.
USB_DEVICE_ControlStatus Initiates status stage of the control transfer.
USB_DEVICE_Deinitialize Deinitializes the specified instance of the USB device layer.
USB_DEVICE_Detach This function will detach the device from the USB.
USB_DEVICE_EndpointDisable This function disables an endpoint.
USB_DEVICE_EndpointEnable This function enables a endpoint for the specified direction and endpoint
size.
USB_DEVICE_EndpointIsEnabled This function returns the enable/ disable status of the specified endpoint
and direction.
USB_DEVICE_EndpointIsStalled This function returns the stall status of the specified endpoint and
direction.
USB_DEVICE_EndpointStall This function stalls an endpoint in the specified direction.
USB_DEVICE_EndpointStallClear This function clears the stall on an endpoint in the specified direction.
USB_DEVICE_EventCallBackSet Client can register its call-back function into the device layer.
USB_DEVICE_GetConfigurationValue Informs the client of the current USB device configuration set by the
USB host.
USB_DEVICE_GetDeviceSpeed Informs the client of the current operation speed of the USB bus.
USB_DEVICE_GetDeviceState Returns the current state of the USB device.
USB_DEVICE_Initialize Creates and initializes an instance of the USB device layer.
USB_DEVICE_IRPCancelAll This function cancels all IRPs that are queued and in progress at the
specified endpoint.
USB_DEVICE_IRPSubmit This function submits a I/O Request Packet (IRP) for processing to the
USB Driver.
USB_DEVICE_Open Opens the specified USB device layer instance and returns a handle to
it.
USB_DEVICE_PowerStateSet Sets power state of the device.
USB_DEVICE_Reinitialize Reinitializes the USB device layer
USB_DEVICE_RemoteWakeupIsEnabled Gets the "Remote wakeup" status of the device.
USB_DEVICE_ResumeStart This function will start the resume signalling.
USB_DEVICE_ResumeStop This function will stop the resume signalling.
USB_DEVICE_Status Provides the current status of the USB device layer
USB_DEVICE_Tasks USB Device layer calls all other function driver tasks in this function. It
also generates and forwards events to its clients.
Macros
Name Description
USB_DEVICE_ENDPOINT_TABLE_SIZE This is macro USB_DEVICE_ENDPOINT_TABLE_SIZE.
USB_DEVICE_HANDLE_INVALID Macro that defines the value of invalid device handle.
USB_DEVICE_INDEX_0 USB device layer index definitions.
5.9 USB Library Help MPLAB Harmony Help USB Device Layer Library
5-4058
USB_DEVICE_INDEX_1 This is macro USB_DEVICE_INDEX_1.
USB_DEVICE_INDEX_2 This is macro USB_DEVICE_INDEX_2.
USB_DEVICE_INDEX_3 This is macro USB_DEVICE_INDEX_3.
USB_DEVICE_INDEX_4 This is macro USB_DEVICE_INDEX_4.
USB_DEVICE_INDEX_5 This is macro USB_DEVICE_INDEX_5.
USB_DEVICE_INDEX_COUNT Number of valid USB Device Layer indices
Structures
Name Description
USB_DEVICE_EVENT_DATA_CONFIGURED Data-type that holds the data related to USB device configured
event.
USB_DEVICE_FUNC_REGISTRATION_TABLE A function driver has to be registered with the USB device layer
using this structure.
USB_DEVICE_FUNCTION_DRIVER A function driver has to expose standard APIs to device layer
using following structure.
USB_DEVICE_INIT This structure has to be initialized by the system/application and
must be passed as parameter to USB_DEVICE_Initialize().
USB_MASTER_DESCRIPTOR Global USB descriptor structure containing pointers to standard
USB descriptor structures.
Types
Name Description
USB_DEVICE_CALLBACK Pointer to a USB Device Layer callback function data type
for bus events.
USB_DEVICE_CONFIG_DESCS_PTR Pointer to an array that contains pointer to configuration
descriptors.
USB_DEVICE_CONTROL_TRANSFER_CALLBACK
USB_DEVICE_CONTROL_TRANSFER_HANDLE Data type of USB device control transfer handle.
USB_DEVICE_HANDLE Data type for USB device handle.
USB_DEVICE_STRING_DESCS_PTR Pointer to an array that contains pointer to string descriptors.
Unions
Name Description
USB_DEVICE_CONTROL_TRANSFER_EVENT_DATA USB device control transfer event data.
USB_DEVICE_EVENT_DATA Data assosciated with USB bus events.
File Name
usb_device.h
Company
Microchip Technology Inc.
5.9.3.7.2 usb_device_config_template.h
USB Device Layer Compile Time Options
This file contains USB device layer compile time options (macros) that are to be configured by the user. This file is a template file
and must be used as an example only. This file must not be directly included in the project.
5.9 USB Library Help MPLAB Harmony Help USB Device Layer Library
5-4059
Macros
Name Description
USB_DEVICE_MAX_CLIENTS Sets the maximum possible number of clients an instance of the USB
device can open using USB_DEVICE_Open.
USB_DEVICE_MAX_FUNCTION_DRIVER Sets the maximum number of function drivers at a time that are
supported by an instance of the USB device layer.
USB_DEVICE_MAX_INSTANCES Sets the maximum possible number of instances of the USB device
that can be instantiated by using USB_DEVICE_Initialize() routine.
File Name
usb_device_config_template.h
Company
Microchip Technology Inc.
5.9.4 USB Device CDC Library
5.9.4.1 Introduction
Introduces the MPLAB Harmony USB Device CDC Library
Description
The MPLAB Harmony USB Device CDC library provides a high-level abstraction of the Universal Serial Bus (USB)
Communications Device Class (CDC). This function driver is a part of the MPLAB Harmony USB Device stack. The library offers
a convenient C language interface and supports revision 1.2 of the USB CDC specification release.
The USB Communications Device Class (or USB CDC) is a composite Universal Serial Bus device class. The communications
device class is primarily used for
• Telecommunication Devices (analog modems, ISDN terminal adapters, digital telephones, and analog phones)
• Networking Devices (ADSL modems, cable modems and Ethernet cross-over cables.
USB CDC specification, and associated subclass specifications, do not attempt to redefine existing standards for connection and
control of communications services. The Communications Class defines mechanisms for a device and host to identify which
existing protocols to use. Where possible, existing data formats are used and the transport of these formats are merely enabled
by the USB through the definition of the appropriate descriptors, interfaces, and requests.
The MPLAB Harmony USB Device CDC library (also referred to as CDC function driver in this document) offers services to the
application to interact and respond to the host requests.
5.9.4.2 Release Notes
MPLAB Harmony Version: v0.70b USB Device CDC Library Version : 0.01 Alpha Release Date: 18Nov2013
New This Release:
This is the first release of the library. The interface can change in the beta and\or 1.0 release.
5.9 USB Library Help MPLAB Harmony Help USB Device CDC Library
5-4060
Known Issues:
Nothing to report in this release.
5.9.4.3 SW License Agreement
(c) 2013 Microchip Technology Inc.
Microchip licenses this software to you solely for use with Microchip products. The software is owned by Microchip and its
licensors, and is protected under applicable copyright laws. All rights reserved.
SOFTWARE IS PROVIDED "AS IS" MICROCHIP EXPRESSLY DISCLAIMS ANY WARRANTY OF ANY KIND, WHETHER
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. IN NO EVENT SHALL MICROCHIP BE LIABLE FOR
ANY INCIDENTAL, SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, HARM TO
YOUR EQUIPMENT, COST OF PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY OR SERVICES, ANY CLAIMS
BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), ANY CLAIMS FOR INDEMNITY OR
CONTRIBUTION, OR OTHER SIMILAR COSTS.
To the fullest extent allowed by law, Microchip and its licensors liability shall not exceed the amount of fees, if any, that you have
paid directly to Microchip to use this software.
MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE TERMS.
5.9.4.4 Library Architecture
5.9.4.4.1 Abstraction Model
Provides an Architectural Overview of the CDC Function Driver.
Description
The CDC Function Driver offers services to a USB CDC device to communicate with the host by abstracting the USB
specification details. It must be used along with the USB Device layer and USB controller to communicate with the USB host.
Figure 1 shows a block diagram representation of the MPLAB Harmony USB Architecture and where the USB CDC Function
Driver is placed.
5.9 USB Library Help MPLAB Harmony Help USB Device CDC Library
5-4061
Figure 1: USB CDC Function Driver
The USB controller driver takes the responsibility of managing the USB peripheral on the device. The USB device layer handles
the device enumeration etc. The USB Device layer forwards all CDC specific control transfers to the CDC Function Driver. The
CDC Function Driver ACM sub-layer interprets the control transfers and requests application's intervention through event
handlers and well defined set of API. The application must register a event handler with the CDC function driver in the Device
Layer Set Configuration Event. While the application must respond to the CDC ACM events, it can do this either in the event
handler or out of it. The application interacts directly with the CDC Function Driver to send/receive data and to send serial state
notifications.
As per the CDC specification,a USB CDC device is a collection of following interfaces.
- Communication Interface (Device Management) on endpoint 0
- Communication Interface (Notification) on an interrupt endpoint. This is optional
- Data Interface (either a bulk or isochronous endpoint). This is optional.
5.9 USB Library Help MPLAB Harmony Help USB Device CDC Library
5-4062
Figure 2: CDC Function Driver Architecture
Figure 2 shows the architecture of the CDC Function Driver. The device management on end point zero is handled by the device
library(class specific requests are routed to the CDC function driver by USB Device Layer). So an instance of CDC function
driver actually consists of a data interface and a notification interface. The library is implemented in two .c files. The
usb_device_cdc.c file implements the CDC data and serial state notification. The usb_device_cdc_acm.c file implements the
control transfer interpretation and and event generation.
5.9.4.4.2 Abstract Control Model (ACM)
Describes the various ACM commands supported by this CDC Function Driver Implementation
Description
One of the basic supported models for communication by CDC is POTS (Plain Old Telephone Service). The POTS model is for
devices that communicate via ordinary phone lines and generic COM port devices. The USB CDC specification refers to this
basic model as PSTN (Public Switched Telephone Network).
Depending on the amount of data processing the device is responsible for POTS/PSTN is divided into several models. The
processing of data can include modulation, demodulation, error correction and data compression.
Of the supported PSTN models, this CDC function driver implements Abstract Control Model (ACM). In the ACM the device
handles modulation, demodulation and handles V.25ter (AT) commands. This model (ACM) also supports requests and
notifications to get and set R-232 status, control and asynchronous port part parameters. Virtual COM port devices use Abstract
Control Model.
The following sections describe the management requests and notifications supported by the CDC ACM function driver.
5.9 USB Library Help MPLAB Harmony Help USB Device CDC Library
5-4063
Management Requests:
The host requests/sends some information in the form of management requests on the bi-directional end-point 0. Table 1 shows
shows the CDC specification ACM sub class management requests and how these request are handled by the CDC Function
Driver.
Request Code Required/Optional Comments
SEND_ENCAPSULATED_COMMAND Required Implemented by CDC Function Driver ACM layer. This request is
stalled.
GET_ENCAPSULATED_RESPONSE Required Implemented by CDC Function Driver ACM layer. This request is
stalled.
SET_COMM_FEATURE Optional Not Implemented
GET_COMM_FEATURE Optional Not Implemented
CLEAR_COMM_FEATURE Optional Not Implemented
SET_LINE_CODING Optional Implemented by CDC Function Driver ACM layer. Requires
application response
GET_LINE_CODING Optional Implemented by CDC Function Driver ACM layer. Requires
application response
SET_CONTROL_LINE_STATE Optional Implemented by CDC Function Driver ACM layer. Requires
application response
SEND_BREAK Optional Implemented by CDC Function Driver ACM layer. Requires
application response
Table 1: CDC ACM management requests and CDC Function Driver support status.
5.9.4.5 Using the Library
5.9.4.5.1 Files to Include
Describes which files to include in project while using the CDC Function Driver
Description
Table 2 shows the files that must be included in the project in order to use the CDC Function Driver. These files are located in
the framework folder of the MPLAB Harmony installation. It is assumed that the Device Layer files ( and the files needed by the
Device Layer) are already included in the project.
Filename Description
\framework\usb\src\dynamic\usb_device_cdc.c Contains the CDC data and serial notification transfer functions
implementation.
\framework\usb\src\dynamic\usb_device_cdc_acm.c Implements the control transfer interpretation and and event generation of
CDC-ACM events.
\framework\usb\usb_device_cdc.h Must included in every source file that needs to invoke CDC function
driver API.
system_config.h User created file which contains the CDC function driver configuration.
5.9 USB Library Help MPLAB Harmony Help USB Device CDC Library
5-4064
Table 2: Files to be included in USB CDC Device Project.
5.9.4.5.2 Library Configuration
Describes how to configure the CDC Function Driver
Description
The application designer must specify the following configuration parameters while using the CDC Function Driver. The
configuration macros that implement these parameters must be located in the system_config.h file in the application project and
a compiler include path (to point to the folder that contains this file) should be specified.
Configuration Macro Name Description Comments
USB_DEVICE_CDC_INSTANCES_NUMBER Number of
CDC
Function
Driver
Instances
in the
application
This macro defines the number of instances of the CDC Function
Driver. For example, if the application needs to implement two
instances of the CDC Function Driver (to create two COM ports)
on one USB Device, the macro should be set to 2. Note that
implementing a USB Device that features multiple CDC interfaces
requires appropriate USB configuration descriptors.
USB_DEVICE_CDC_QUEUE_SIZE CDC
Function
Driver
Buffer
Combined
Queue size
This macro defines the number of entries in all queues in all
instances of the CDC function driver. This value can be obtained
by adding up the read and write queue sizes of each CDC
Function driver instance. In a simple single instance USB CDC
device application, that does not require buffer queuing and serial
state notification, the USB_DEVICE_CDC_QUEUE_SIZE macro
can be set to 2. Consider a case with two CDC function driver
instances, CDC 1 has a read queue size of 2 and write queue size
of 3, CDC 2 has a read queue size of 4 and write queue size of 1,
this macro should be set to 10 (2 +3 + 4 + 1).
5.9.4.5.3 Library Initialization
Describes how the CDC Function Driver is initialized.
Description
The CDC function driver instance for a USB device configuration is initialized by the Device Layer when the configuration is set
by the host. This process does not require application intervention. Each instance of the CDC function driver should be
registered with the Device layer through the Device Layer Function Driver Registration Table. The CDC function driver does not
require a initialization data structure.The funcDriverInit member of the function driver registration table entry for the CDC function
driver instance should be set to NULL. The cdcFuncDriver object is a global object provided by the CDC function driver and
points to the CDC function driver - Device Layer interface functions which are required by the Device Layer. The code snippet
below shows an example of how multiple instances of CDC Function driver can registered with the Device Layer.
/* This code snippet shows an example of how two CDC function
* driver instances can be registered with the Device Layer
* via the Device Layer Function Driver Registration Table.
* In this case Device Configuration 1 consists of two CDC
* function driver instances. */
/* Define the CDC intialization data structure for CDC instance 0.
* Set read queue size to 2 and write queue size to 3 */
const USB_DEVICE_CDC_INIT cdcInit0 = {.queueSizeRead = 2, .queueSizeWrite = 3};
5.9 USB Library Help MPLAB Harmony Help USB Device CDC Library
5-4065
/* Define the CDC intialization data structure for CDC instance 1.
* Set read queue size to 4 and write queue size to 1 */
const USB_DEVICE_CDC_INIT cdcInit1 = {.queueSizeRead = 4, .queueSizeWrite = 1};
const USB_DEVICE_FUNC_REGISTRATION_TABLE funcRegistrationTable[2] =
{
/* This is the first instance of the CDC Function Driver */
{
.speed = USB_SPEED_FULL|USB_SPEED_HIGH, // Supported speed
.configurationValue = 1, // To be initialized for Configuration 1
.interfaceNumber = 0, // Starting interface number.
.numberOfInterfaces = 2, // Number of interfaces in this instance
.funcDriverIndex = 0, // Function Driver instance index is 0
.funcDriverInit = &cdcInit0, // Function Driver initialization data structure
.driver = &cdcFuncDriver // Pointer to Function Driver - Device Layer interface
functions
},
/* This is the second instance of the CDC Function Driver */
{
.speed = USB_SPEED_FULL|USB_SPEED_HIGH, // Supported speed
.configurationValue = 1, // To be initialized for Configuration 1
.interfaceNumber = 2, // Starting interface number.
.numberOfInterfaces = 2, // Number of interfaces in this instance
.funcDriverIndex = 1, // Function Driver instance index is 1
.funcDriverInit = &cdcInit1, // Function Driver initialization data structure
.driver = &cdcFuncDriver // Pointer to Function Driver - Device Layer interface
functions
},
};
5.9.4.5.4 Event Handling
Describes CDC function driver event handler registration and event handling.
Description
Registering a CDC Function Driver Event Handler:
While creating a USB CDC Device based application, an event handler must be registered with the Device Layer (the Device
Layer Event Handler) and every CDC function driver instance (CDC Function Driver Event Handler). The CDC function driver
event handler receives CDC and CDC ACM events. This event handler should be registered before the USB device layer
acknowledges the SET CONFIGURATION request from the USB Host. In order to ensure this, the event handler should be set in
the USB_DEVICE_EVENT_CONFIGURED event that is generated by the device layer. While registering the CDC function driver
event handler, the CDC function driver allows the application to also pass a application context object. This object gets
associated with the instance of the CDC function driver and is returned by the CDC function driver when a CDC function driver
event occurs. The code example below shows an example of how this can be done.
/* This a sample Application Device Layer Event Handler
* Note how the CDC Function Driver event handler APP_USBDeviceCDCEventHandler()
* is registered in the USB_DEVICE_EVENT_CONFIGURED event. The appData
* object that is passed in the USB_DEVICE_CDC_EventHandlerSet()
* function will be returned as the userData parameter in the
* when the APP_USBDeviceCDCEventHandler() function is invoked */
void APP_USBDeviceEventCallBack ( USB_DEVICE_EVENT event,
USB_DEVICE_EVENT_DATA * eventData )
{
switch ( event )
{
case USB_DEVICE_EVENT_RESET:
case USB_DEVICE_EVENT_DECONFIGURED:
5.9 USB Library Help MPLAB Harmony Help USB Device CDC Library
5-4066
// USB device is reset or device is deconfigured.
// This means that USB device layer is about to deininitialize
// all function drivers.
break;
case USB_DEVICE_EVENT_CONFIGURED:
/* check the configuration */
if ( eventData->eventConfigured.configurationValue == 1)
{
/* Register the CDC Device application event handler here.
* Note how the appData object pointer is passed as the
* user data */
USB_DEVICE_CDC_EventHandlerSet(USB_DEVICE_CDC_INDEX_0,
APP_USBDeviceCDCEventHandler, (uintptr_t)&appData);
/* mark that set configuration is complete */
appData.isConfigured = true;
}
break;
case USB_DEVICE_EVENT_SUSPENDED:
break;
case USB_DEVICE_EVENT_RESUMED:
case USB_DEVICE_EVENT_ATTACHED:
case USB_DEVICE_EVENT_DETACHED:
case USB_DEVICE_EVENT_ERROR:
default:
break;
}
}
CDC Function Driver Events:
The CDC Function Driver generates events that the application must respond. Some of these events are management requests
communicated through control transfers. The application must therefore complete the control transfer. Based on the generated
event, the application may be required to:
• Respond with a USB_DEVICE_CDC_ControlSend() function which is completes the data stage of a Control Read Transfer.
• Respond with a USB_DEVICE_CDC_ControlReceive() function which provisions the data stage of a Control Write Transfer.
• Respond with a USB_DEVICE_CDC_ControlStatus() function which completes the handshake stage of the Control Transfer.
The application can either STALL or Acknowledge the handshake stage via the USB_DEVICE_CDC_ControlStatus() function.
• Analyze the pData member of the event handler and check for event specific data. This data member should be type cast to
an event specific data type. The table below shows the event and the data type to use while type casting. Note that the pData
member is not required for all events
CDC Function Driver Event Related pData type
USB_DEVICE_CDC_EVENT_SET_LINE_CODING Not Applicable
USB_DEVICE_CDC_EVENT_GET_LINE_CODING Not Applicable
USB_DEVICE_CDC_EVENT_SET_CONTROL_LINE_STATE USB_DEVICE_CDC_EVENT_DATA_SET_CON
TROL_LINE_STATE
*
5.9 USB Library Help MPLAB Harmony Help USB Device CDC Library
5-4067
USB_DEVICE_CDC_EVENT_SEND_BREAK USB_DEVICE_CDC_EVENT_DATA_SEND_BR
EAK
*
USB_DEVICE_CDC_EVENT_WRITE_COMPLETE USB_DEVICE_CDC_EVENT_DATA_WRITE_C
OMPLETE
*
USB_DEVICE_CDC_EVENT_READ_COMPLETE USB_DEVICE_CDC_EVENT_DATA_READ_C
OMPLETE
*
USB_DEVICE_CDC_EVENT_SERIAL_STATE_NOTIFICATION_COMPLETE USB_DEVICE_CDC_EVENT_DATA_SERIAL_S
TATE_NOTIFICATION_COMPLETE
*
USB_DEVICE_CDC_EVENT_CONTROL_TRANSFER_DATA_SENT Not Applicable
USB_DEVICE_CDC_EVENT_CONTROL_TRANSFER_DATA_RECEIVED Not Applicable
The possible CDC Function Driver events are described here along with the required application response, event specific data
and likely follow up function driver event:
1. USB_DEVICE_CDC_EVENT_SET_LINE_CODING
Application Response: This event occurs when the host issues a SET LINE CODING command. The application must provide a
USB_DEVICE_CDC_EVENT_DATA_SET_LINE_CODING data structure to the device layer to receive the line coding data that
the host will provide. The application must provide the buffer by calling the USB_DEVICE_CDC_ControlReceive() function either
in the event handler or in the application (outside of the event handler function). The application must use the
controlTransferHandle parameter provided in the event while calling USB_DEVICE_CDC_ControlReceive() function. The
application can use the USB_DEVICE_CDC_EVENT_CONTROL_TRANSFER_DATA_SENT event to track completion of the
command.
Event Specific Data (pData): The pData parameter will be NULL.
Likely Follow-up event: This event will likely be followed by the
USB_DEVICE_CDC_EVENT_CONTROL_TRANSFER_DATA_RECEIVED event. This indicates that the data was received
successfully. The application must either acknowledge or stall the handshake stage of the control transfer by calling
USB_DEVICE_ControlStatus() function with USB_DEVICE_CONTROL_STATUS_OK or
USB_DEVICE_CONTROL_STATUS_ERROR flag respectively.
2. USB_DEVICE_CDC_EVENT_GET_LINE_CODING
Application Response: This event occurs when the host issues a GET LINE CODING command. The application must provide a
USB_DEVICE_CDC_EVENT_DATA_GET_LINE_CODING data structure to the device layer that contains the line coding data
that to be provided to the host. The application must provide the buffer by calling the USB_DEVICE_CDC_ControlSend()
function either in the event handler or in the application (outside of the event handler function). The application must use the
controlTransferHandle parameter provided in the event while calling USB_DEVICE_CDC_ControlSend() function. The size of the
buffer is indicated by the length parameter. The application can use the
USB_DEVICE_CDC_EVENT_CONTROL_TRANSFER_DATA_SENT event to track completion of the command.
Event Specific Data (pData): The pData parameter will be NULL.
Likely Follow-up event: This event will likely be followed by the
USB_DEVICE_CDC_EVENT_CONTROL_TRANSFER_DATA_SENT event. This indicates that the data was sent to the host
successfully. The application must acknowledge the handshake stage of the control transfer by calling
USB_DEVICE_CDC_ControlStatus() function with USB_DEVICE_CONTROL_STATUS_OK flag.
3. USB_DEVICE_CDC_EVENT_SET_CONTROL_LINE_STATE
5.9 USB Library Help MPLAB Harmony Help USB Device CDC Library
5-4068
Application Response: This event occurs when the host issues a SET CONTROL LINE STATE command. . The application can
then use the USB_DEVICE_CDC_ControlStatus() function to indicate acceptance of rejection of the command. The
USB_DEVICE_CDC_ControlStatus() function can be called from the event handler or in the application (out of the event handler
context). The application should use the controlTransferHandle while calling the USB_DEVICE_ControlStatus() function.
Event Specific Data (pData): The application must interpret the pData parameter as a pointer to a
USB_DEVICE_CDC_EVENT_DATA_SET_CONTROL_LINE_STATE data type that contains the control line state data.
Likely Follow-up event: None.
4. USB_DEVICE_CDC_EVENT_SEND_BREAK
Application Response: This event occurs when the host issues a SEND BREAK command. The application can then use the
USB_DEVICE_CDC_ControlStatus() function to indicate acceptance of rejection of the command. The
USB_DEVICE_CDC_ControlStatus() function can be called from the event handler or in the application (out of the event handler
context). The application should use the controlTransferHandle while calling the USB_DEVICE_CDC_ControlStatus() function.
Event Specific Data (pData): The application must interpret the pData parameter as a pointer to a
USB_DEVICE_CDC_EVENT_DATA_SEND_BREAK data type that contains the break duration data.
Likely Follow-up event: None.
5. USB_DEVICE_CDC_EVENT_WRITE_COMPLETE
Application Response: This event occurs when a write operation scheduled by calling the USB_DEVICE_CDC_Write() function
has completed. This event does not require the application to respond with any function calls..
Event Specific Data (pData): The pData member in the event handler will point to
USB_DEVICE_CDC_EVENT_DATA_WRITE_COMPLETE type.
Likely Follow-up event: None.
6. USB_DEVICE_CDC_EVENT_READ_COMPLETE
Application Response: This event occurs when a read operation scheduled by calling the USB_DEVICE_CDC_Read() function
has completed. This event does not require the application to respond with any function calls..
Event Specific Data (pData): The pData member in the event handler will point to
USB_DEVICE_CDC_EVENT_DATA_READ_COMPLETE type.
Likely Follow-up event: None.
7. USB_DEVICE_CDC_EVENT_SERIAL_STATE_NOTIFICATION_COMPLETE
Application Response: This event occurs when a serial state notfication send scheduled by calling the
USB_DEVICE_CDC_SerialStateNotificationSend() function has completed. This event does not require the application to
respond with any function calls..
Event Specific Data (pData): The pData member in the event handler will point to
USB_DEVICE_CDC_EVENT_DATA_SERIAL_STATE_NOTIFICATION_COMPLETE type.
Likely Follow-up event: None.
8. USB_DEVICE_CDC_EVENT_CONTROL_TRANSFER_DATA_SENT
Application Response: This event occurs when the data stage of a control read transfer has completed in response to the
USB_DEVICE_CDC_ControlSend() function (in the USB_DEVICE_CDC_EVENT_GET_LINE_CODING event). The application
must acknowledge the handshake stage of the control transfer by calling USB_DEVICE_CDC_ControlStatus() function with
USB_DEVICE_CONTROL_STATUS_OK flag.
Event Specific Data (pData): The pData parameter will be NULL.
5.9 USB Library Help MPLAB Harmony Help USB Device CDC Library
5-4069
Likely Follow-up event: None.
9. USB_DEVICE_CDC_EVENT_CONTROL_TRANSFER_DATA_RECEIVED
Application Response: This event occurs when the data stage of a control write transfer has completed in response to the
USB_DEVICE_CDC_ControlReceive() function (in the USB_DEVICE_CDC_EVENT_SET_LINE_CODING event). The
application must either acknowledge or stall the handshake stage of the control transfer by calling
USB_DEVICE_CDC_ControlStatus() function with USB_DEVICE_CONTROL_STATUS_OK or
USB_DEVICE_CONTROL_STATUS_ERROR flag respectively.
Event Specific Data (pData): The pData parameter will be NULL.
Likely Follow-up event: None.
CDC Function Driver Event Handling:
The following code snippet shows an example event handling scheme. The application always returns from the event handler
with a USB_DEVICE_CDC_EVENT_RESPONSE_NONE value.
// This code example shows all CDC Function Driver possible events
// and a possible scheme for handling these events. In this case
// event responses are not deferred.
USB_DEVICE_CDC_EVENT_DATA_SET_LINE_CODING_DATA setLineCodingData;
USB_DEVICE_CDC_EVENT_DATA_GET_LINE_CODING_DATA getLineCodingData;
USB_DEVICE_CDC_EVENT_DATA_SET_CONTROL_LINE_STATE_DATA controlLineStateData;
USB_DEVICE_CDC_EVENT_DATA_SEND_BREAK_DATA breakData;
USB_DEVICE_CDC_EVENT_RESPONSE USBDeviceCDCEventHandler
(
USB_DEVICE_CDC_INDEX instanceIndex,
USB_DEVICE_CDC_EVENT event,
uintptr_t controlTransferHandle,
void * data,
uintptr_t userData
)
{
switch(event)
{
case USB_DEVICE_CDC_EVENT_SET_LINE_CODING:
// In this case, the application should read the line coding
// data that is sent by the host.
USB_DEVICE_CDC_ControlReceive(usbDeviceHandle, controlTransferHandle
&setLineCodingData,
sizeof(USB_DEVICE_CDC_EVENT_DATA_SET_LINE_CODING));
break;
case USB_DEVICE_CDC_EVENT_GET_LINE_CODING:
// In this case, the application should send the line coding
// data to the host.
USB_DEVICE_CDC_ControlSend(usbDeviceHandle, controlTransferHandle
&getLineCodingData,
sizeof(USB_DEVICE_CDC_EVENT_DATA_GET_LINE_CODING));
break;
case USB_DEVICE_CDC_EVENT_SET_CONTROL_LINE_STATE:
// In this case, pData will point to a
// USB_DEVICE_CDC_EVENT_DATA_SET_CONTROL_LINE_STATtype data object that
// will contain the control line state data sent by the host.
5.9 USB Library Help MPLAB Harmony Help USB Device CDC Library
5-4070
controlLineStateData.dtr =
((USB_DEVICE_CDC_EVENT_DATA_SET_CONTROL_LINE_STATE *)pData)->dtr;
controlLineStateData.carrier =
((USB_DEVICE_CDC_EVENT_DATA_SET_CONTROL_LINE_STATE *)pData)->carrier;
USB_DEVICE_CDC_ControlStatus(usbDeviceHandle, controlTransferHandle,
USB_DEVICE_CONTROL_STATUS_OK);
break;
case USB_DEVICE_CDC_EVENT_SEND_BREAK:
// In this case, pData will point to a
// USB_DEVICE_CDC_EVENT_SEND_BREAK_DATA type data object that
// will contain the break duration sent by the host.
breakData.duration = ((USB_DEVICE_CDC_EVENT_DATA_SEND_BREAK *)pData)->duration;
USB_DEVICE_CDC_ControlStatus(usbDeviceHandle, controlTransferHandle,
USB_DEVICE_CONTROL_STATUS_OK);
break;
case USB_DEVICE_CDC_EVENT_CONTROL_TRANSFER_DATA_SENT:
case USB_DEVICE_CDC_EVENT_CONTROL_TRANSFER_DATA_RECEIVED:
// This means that the data stage is complete. The data in
// setLineCodingData is valid or data in getLineCodingData was
// sent to the host. The application can now decide whether it
// supports this data. It is not mandatory to do this in the
// event handler.
USB_DEVICE_ControlStatus(usbDeviceHandle, controlTransferHandle,
USB_DEVICE_CONTROL_STATUS_OK);
case USB_DEVICE_CDC_EVENT_WRITE_COMPLETE:
// This means USB_DEVICE_CDC_Write() operation completed.
// The pData member will point to a
// USB_DEVICE_CDC_EVENT_DATA_WRITE_COMPLETE type of data.
break;
case USB_DEVICE_CDC_EVENT_READ_COMPLETE:
// This means USB_DEVICE_CDC_Read() operation completed.
// The pData member will point to a
// USB_DEVICE_CDC_EVENT_DATA_READ_COMPLETE type of data.
break;
case USB_DEVICE_CDC_EVENT_SERIAL_STATE_NOTIFICATION_COMPLETE:
// This means USB_DEVICE_CDC_SerialStateNotification() operation
// completed. The pData member will point to a
// USB_DEVICE_CDC_EVENT_DATA_SERIAL_STATE_NOTIFICATION_COMPLETE type of data.
break;
default:
break;
}
return(USB_DEVICE_CDC_EVENT_RESPONSE_NONE);
}
Refer to the USB_DEVICE_CDC_EVENT enumeration for more details on each event.
5.9 USB Library Help MPLAB Harmony Help USB Device CDC Library
5-4071
5.9.4.5.5 Sending Data
Describes how to send data to the CDC Host.
Description
The application may need to send data or serial state notification to the USB CDC Host. This is done by using the
USB_DEVICE_CDC_Write() and USB_DEVICE_CDC_SerialStateNotificationSend() functions respectively.
1. Sending data to the USB Host:
The application can send data to the host by using the USB_DEVICE_CDC_Write() function. This function returns a transfer
handler that allows the application to track the read request. The request is completed when the host as requested for the data.
The completion of the write transfer is indicated by USB_DEVICE_CDC_EVENT_WRITE_COMPLETE event. A write request
could fail if the function driver instance transfer queue is full.
The USB_DEVICE_CDC_Write() function also allows the application to send data to the host without ending the transfer. This is
done by specifying the USB_DEVICE_CDC_TRANSFER_FLAGS_DATA_PENDING flag. The application can use this option
when the data to be sent is not readily available or when the application is memory constrained. The combination of the transfer
flag and the transfer size affects how the function driver sends the data to the host.
a. If size is a multiple of maxPacketSize (the IN endpoint size) and flag is set as
USB_DEVICE_CDC_TRANSFER_FLAGS_DATA_COMPLETE, the write function will append a Zero Length Packet (ZLP) to
complete the transfer.
b. If size is a multiple of maxPacketSize and flag is set as USB_DEVICE_CDC_TRANSFER_FLAGS_MORE_DATA_PENDING,
the write function will not append a ZLP and hence will not complete the transfer.
c. If size is greater than but not a multiple of maxPacketSize and flags is set as
USB_DEVICE_CDC_TRANSFER_FLAGS_DATA_COMPLETE, the write function schedules (length/maxPacketSize) packets
and one packet for the residual data.
d. If size is greater than but not a multiple of maxPacketSize and flags is set as
USB_DEVICE_CDC_TRANSFER_FLAGS_MORE_DATA_PENDING, the write function schedules (size/maxPacketSize)
packets only.
e. If size is less than maxPacketSize and flag is set as USB_DEVICE_CDC_TRANSFER_FLAGS_DATA_COMPLETE, the write
function schedules one packet.
f. If size is less than maxPacketSize and flag is set as USB_DEVICE_CDC_TRANSFER_FLAGS_MORE_DATA_PENDING, the
write function returns an error code and sets the transferHandle parameter to
USB_DEVICE_CDC_TRANSFER_HANDLE_INVALID.
The following code snippet explains this in more detail:
// Below is a set of examples showing various conditions trying to
// send data with the USB_DEVICE_CDC_Write() command.
//
// This assumes that driver was opened successfully.
// Assume maxPacketSize is 64.
USB_DEVICE_CDC_TRANSFER_HANDLE transferHandle;
USB_DEVICE_CDC_RESULT writeRequestHandle;
USB_DEVICE_CDC_INDEX instance;
//-------------------------------------------------------
// In this example we want to send 34 bytes only.
writeRequestResult = USB_DEVICE_CDC_Write(instance,
&transferHandle, data, 34,
5.9 USB Library Help MPLAB Harmony Help USB Device CDC Library
5-4072
USB_DEVICE_CDC_TRANSFER_FLAGS_DATA_COMPLETE);
if(USB_DEVICE_CDC_RESULT_OK != writeRequestResult)
{
//Do Error handling here
}
//-------------------------------------------------------
// In this example we want to send 64 bytes only.
// This will cause a ZLP to be sent.
writeRequestResult = USB_DEVICE_CDC_Write(instance,
&transferHandle, data, 64,
USB_DEVICE_CDC_TRANSFER_FLAGS_DATA_COMPLETE);
if(USB_DEVICE_CDC_RESULT_OK != writeRequestResult)
{
//Do Error handling here
}
//-------------------------------------------------------
// This example will return an error because size is less
// than maxPacketSize and the flag indicates that more
// data is pending.
writeRequestResult = USB_DEVICE_CDC_Write(instanceHandle,
&transferHandle, data, 32,
USB_DEVICE_CDC_TRANSFER_FLAGS_MORE_DATA_PENDING);
//-------------------------------------------------------
// In this example we want to place a request for a 70 byte transfer.
// The 70 bytes will be sent out in a 64 byte transaction and a 6 byte
// transaction completing the transfer.
writeRequestResult = USB_DEVICE_CDC_Write(instanceHandle,
&transferHandle, data, 70,
USB_DEVICE_CDC_TRANSFER_FLAGS_DATA_COMPLETE);
if(USB_DEVICE_CDC_RESULT_OK != writeRequestResult)
{
//Do Error handling here
}
//-------------------------------------------------------
// In this example we want to place a request for a 70 bytes to be sent
// but that we don't end the transfer as more data is coming. 64 bytes
// of the 70 will be sent out and the USB_DEVICE_CDC_EVENT_WRITE_COMPLETE
// with 64 bytes. This indicates that the extra 6 bytes weren't
// sent because it would cause the end of the transfer. Thus the
// user needs add these 6 bytes back to the buffer for the next group
// of data that needs to be sent out.
writeRequestResult = USB_DEVICE_CDC_Write(instanceHandle,
&transferHandle, data, 70,
USB_DEVICE_CDC_TRANSFER_FLAGS_MORE_DATA_PENDING);
if(USB_DEVICE_CDC_RESULT_OK != writeRequestResult)
{
//Do Error handling here
}
// The completion of the write request will be indicated by the
// USB_DEVICE_CDC_EVENT_WRITE_COMPLETE event.
2. Sending a serial state notification:
The application can send a Serial State Notification by using the USB_DEVICE_CDC_SerialStateSend() function. his function
5.9 USB Library Help MPLAB Harmony Help USB Device CDC Library
5-4073
returns a transfer handler that allows the application to track the read request. The request is completed when the host as
requested for the data. The completion of the transfer is
USB_DEVICE_CDC_EVENT_SERIAL_STATE_NOTIFICATION_COMPLETE event. A request could fail if the function driver
transfer queue is full. The following code snippet shows an example of how this can be done.
USB_DEVICE_CDC_INDEX instanceIndex;
USB_DEVICE_CDC_TRANSFER_HANDLE transferHandle;
USB_DEVICE_CDC_SERIAL_STATE_NOTIFICATION_DATA notificationData;
// This application function could possibly update the notificationData
// data structure.
APP_UpdateNotificationData(¬ificationData);
// Now send the updated notification data to the host.
result = USB_DEVICE_CDC_SerialStateDataSend(instanceIndex, &transferHandle,
¬ificationData);
if(USB_DEVICE_CDC_RESULT_OK != result)
{
// Error handling here
}
5.9.4.5.6 Receiving Data
Describes how the CDC device can read data from the Host.
Description
The application can receive data from the host by using the USB_DEVICE_CDC_Read() function. This function returns a
transfer handler that allows the application to track the read request. The request is completed when the host sends the required
amount or less than required amount of data. The application must make sure that it allocates a buffer size that is at least the
size or a multiple of the receive endpoint size. The return value of the function indicates the success of the request. A read
request could fail if the function driver transfer queue is full. The completion of the read transfer is
USB_DEVICE_CDC_EVENT_READ_COMPLETE event. The request completes based on the amount of the data that was
requested and size of the transaction initiated by the host.
a. If the size parameter is not a multiple of maxPacketSize or is 0, the function returns
USB_DEVICE_CDC_TRANSFER_HANDLE_INVALID in transferHandle and returns
USB_DEVICE_CDC_RESULT_ERROR_TRANSFER_SIZE_INVALID as a return value.
b. If the size parameter is a multiple of maxPacketSize and the host send less than maxPacketSize data in any transaction, the
transfer completes and the function driver will issue a USB_DEVICE_CDC_EVENT_READ_COMPLETE event along with the
USB_DEVICE_CDC_EVENT_READ_COMPLETE_DATA data structure.
c. If the size parameter is a multiple of maxPacketSize and the host sends maxPacketSize amount of data, and total data
received does not exceed size, then the function driver will wait for the next packet.
The following code snippet shows an example if the USB_DEVICE_CDC_Read() function:
// Shows an example of how to read. This assumes that
// driver was opened successfully.
USB_DEVICE_CDC_TRANSFER_HANDLE transferHandle;
USB_DEVICE_CDC_RESULT readRequestResult;
USB_DEVICE_CDC_HANDLE instanceHandle;
readRequestResult = USB_DEVICE_CDC_Read(instanceHandle,
&transferHandle, data, 128);
if(USB_DEVICE_CDC_RESULT_OK != readRequestResult)
5.9 USB Library Help MPLAB Harmony Help USB Device CDC Library
5-4074
{
//Do Error handling here
}
// The completion of the read request will be indicated by the
// USB_DEVICE_CDC_EVENT_READ_COMPLETE event.
5.9.4.6 Library Interface
Data Types and Constants
Name Description
USB_DEVICE_CDC_CONTROL_TRANSFER_HANDLE USB Device CDC Function
Driver Control Transfer
Handle
USB_DEVICE_CDC_EVENT USB Device CDC Function
Driver Control Transfer
Status
USB_DEVICE_CDC_EVENT_DATA_GET_LINE_CODING USB Device CDC Event Get
Line Coding Data Type.
USB_DEVICE_CDC_EVENT_DATA_READ_COMPLETE USB Device CDC Function
Driver Read and Write
Complete Event Data.
USB_DEVICE_CDC_EVENT_DATA_SEND_BREAK USB Device CDC Event Set
Break Data Type.
USB_DEVICE_CDC_EVENT_DATA_SERIAL_STATE_NOTIFICATION_COMPLETE USB Device CDC Function
Driver Read and Write
Complete Event Data.
USB_DEVICE_CDC_EVENT_DATA_SET_CONTROL_LINE_STATE USB Device CDC Event Set
Line Coding Data Type.
USB_DEVICE_CDC_EVENT_DATA_SET_LINE_CODING USB Device CDC Event Set
Line Coding Data Type.
USB_DEVICE_CDC_EVENT_DATA_WRITE_COMPLETE USB Device CDC Function
Driver Read and Write
Complete Event Data.
USB_DEVICE_CDC_EVENT_HANDLER USB Device CDC Event
Handler Function Pointer
Type.
USB_DEVICE_CDC_EVENT_RESPONSE USB Device CDC Function
Driver Event Callback
Response Type
USB_DEVICE_CDC_INDEX USB Device CDC Function
Driver Index
USB_DEVICE_CDC_INIT USB Device CDC Function
Driver Initialization Data
Structure
USB_DEVICE_CDC_RESULT USB Device CDC Function
Driver USB Device CDC
Result enumeration.
USB_DEVICE_CDC_SERIAL_STATE_NOTIFICATION_DATA USB Device Serial State
Notification Data Type.
USB_DEVICE_CDC_TRANSFER_FLAGS USB Device CDC Function
Driver Transfer Flags
5.9 USB Library Help MPLAB Harmony Help USB Device CDC Library
5-4075
USB_DEVICE_CDC_TRANSFER_HANDLE USB Device CDC Function
Driver Transfer Handle
Definition.
USB_DEVICE_CDC_EVENT_RESPONSE_NONE USB Device CDC Function
Driver Event Handler
Response Type None.
USB_DEVICE_CDC_TRANSFER_HANDLE_INVALID USB Device CDC Function
Driver Invalid Transfer
Handle Definition.
Functions
Name Description
USB_DEVICE_CDC_ControlReceive This function allows the application to respond to the CDC
function driver specific control transfer requests. It allows the
application to receive data from the host in the data stage of the
control transfer.
USB_DEVICE_CDC_ControlSend This function allows the application to respond to the CDC
function driver specific control transfer requests. It allows the
application to send data to the host in the data stage of the
control transfer.
USB_DEVICE_CDC_ControlStatus This function allows the application to complete the status stage
of the the CDC Function Driver specific control transfer request.
USB_DEVICE_CDC_EventHandlerSet This function registers a event handler for the specified CDC
function driver instance.
USB_DEVICE_CDC_Read This function requests a data read from the USB Device CDC
Function Driver Layer.
USB_DEVICE_CDC_SerialStateNotificationSend This function schedules a request to send serial state notification
to the host.
USB_DEVICE_CDC_Write This function requests a data write to the USB Device CDC
Function Driver Layer.
Description
5.9.4.6.1 Functions
5.9.4.6.1.1 USB_DEVICE_CDC_ControlReceive Function
C
USB_DEVICE_CDC_RESULT USB_DEVICE_CDC_ControlReceive(
USB_DEVICE_CDC_INDEX instanceIndex,
USB_DEVICE_CDC_CONTROL_TRANSFER_HANDLE controlTransferHandle,
void * data,
size_t size
);
Description
This function allows the application to respond to the CDC function driver specific control transfer requests. It allows the
application to receive data from the host in the data stage of the control transfer. For example, the
USB_DEVICE_CDC_EVENT_DATA_SET_LINE_CODING event requires a control transfer response. The function can be
called in the CDC Function Driver event handler or can be called outside the event handler. Calling this function outside the
event handler defers the response to the event. This allows the application to prepare the data buffer out of the event handler
context, especially if the data buffer to receive the data is not readily available. Note however, that there are timing
5.9 USB Library Help MPLAB Harmony Help USB Device CDC Library
5-4076
considerations when responding to the control transfer. Exceeding the response time will cause the host to cancel the control
transfer and may cause USB host to reject the device. The application must use the control transfer handle that was generated
along with the event as the controlTransferHandle.
Preconditions
This function should only be called in response to a CDC function driver event that requires a control transfer response.
Parameters
Parameters Description
instance USB Device CDC Function Driver instance.
controlTransferHandle Control Transfer handle for the control transfer.
data Data buffer to receive the data stage of the control transfer.
size size (in bytes) of the data to sent.
Returns
USB_DEVICE_CDC_RESULT_ERROR_CONTROL_TRANSFER_FAILED - The request was not successful because the USB
host cancelled the control transfer.
USB_DEVICE_CDC_RESULT_OK - The request was successful.
Remarks
None.
Example
// ------------------------------------------------------------------
// In this example, the application responds to the SET LINE CODING
// with in the event handler. The application uses the
// USB_DEVICE_CDC_ControlReceive() function to do this.
// ------------------------------------------------------------------
USB_DEVICE_CDC_EVENT_DATA_SET_LINE_CODING setLineCodingData;
USB_DEVICE_CDC_CONTROL_TRANSFER_HANDLE controlTransferHandle;
USB_DEVICE_CDC_EVENT_RESPONSE USBDeviceCDCEventHandler
(
USB_DEVICE_CDC_INDEX instanceIndex,
USB_DEVICE_CDC_EVENT event,
USB_DEVICE_CDC_CONTROL_TRANSFER_HANDLE controlTransferHandle,
void * pData,
uintptr_t userData
)
{
switch(event)
{
case USB_DEVICE_CDC_EVENT_SET_LINE_CODING:
// In this case, the application should receive the line coding
// data from the host. The application must use the
// USB_DEVICE_CDC_ControlReceive() function to receive the data.
USB_DEVICE_CDC_ControlReceive(instanceIndex, controlTransferHandle
&setLineCodingData,
sizeof(USB_DEVICE_CDC_EVENT_DATA_SET_LINE_CODING));
break;
}
}
// --------------------------------------------------------------------
// In this example, the application defers the response to the
// event. This is done by calling the USB_DEVICE_CDC_ControlReceive()
5.9 USB Library Help MPLAB Harmony Help USB Device CDC Library
5-4077
// function after the event handler exits.
// --------------------------------------------------------------------
USB_DEVICE_CDC_EVENT_DATA_SET_LINE_CODING setLineCodingData;
USB_DEVICE_CDC_CONTROL_TRANSFER_HANDLE thisControlTransferHandle;
bool sendLineCodingToHost;
USB_DEVICE_CDC_EVENT_RESPONSE USBDeviceCDCEventHandler
(
USB_DEVICE_CDC_INDEX instanceIndex,
USB_DEVICE_CDC_EVENT event,
USB_DEVICE_CDC_CONTROL_TRANSFER_HANDLE controlTransferHandle,
void * pData,
uintptr_t userData
)
{
switch(event)
{
case USB_DEVICE_CDC_EVENT_SET_LINE_CODING:
// In this case, the application should send the line coding
// data to the host. The application must responds to the
// event outside the event handler because the data buffer is
// not available.
thisControlTransferHandle = controlTransferHandle;
getLineCodingFromHost = true;
break;
}
}
if(getLineCodingFromHost)
{
// The application allocates a buffer using an arbitrary function
// Note that this happens after the event handler exits.
setLineCoding = AllocateMemoryBuffer();
USB_DEVICE_CDC_ControlReceive(instanceIndex, thisControlTransferHandle
&setLineCodingData,
sizeof(USB_DEVICE_CDC_EVENT_DATA_SET_LINE_CODING));
}
5.9.4.6.1.2 USB_DEVICE_CDC_ControlSend Function
C
USB_DEVICE_CDC_RESULT USB_DEVICE_CDC_ControlSend(
USB_DEVICE_CDC_INDEX instanceIndex,
USB_DEVICE_CDC_CONTROL_TRANSFER_HANDLE controlTransferHandle,
void * data,
size_t size
);
Description
This function allows the application to respond to the CDC function driver specific control transfer requests. It allows the
application to send data to the host in the data stage of the control transfer. For example, the
USB_DEVICE_CDC_EVENT_GET_LINE_CODING event requires a control transfer response. The function can be called in the
CDC Function Driver event handler or can be called outside the event handler. Calling this function outside the event handler
defers the response to the event. This allows the application to prepare the response data out of the event handler context,
especially if the data is not readily available. Note however, that there are timing considerations when responding to the control
transfer. Exceeding the response time will cause the host to cancel the control transfer and may cause USB host to reject the
5.9 USB Library Help MPLAB Harmony Help USB Device CDC Library
5-4078
device. The application must use the control transfer handle that was generated along with the event as the
controlTransferHandle.
Preconditions
This function should only be called in response to a CDC function driver event that requires a control transfer response.
Parameters
Parameters Description
instance USB Device CDC Function Driver instance.
controlTransferHandle Control Transfer handle for the control transfer.
data Data that represents the data stage of the control transfer.
size size (in bytes) of the data to sent.
Returns
USB_DEVICE_CDC_RESULT_ERROR_CONTROL_TRANSFER_FAILED - The request was not successful because the USB
host cancelled the control transfer.
USB_DEVICE_CDC_RESULT_OK - The request was successful.
Remarks
None.
Example
// ------------------------------------------------------------------
// In this example, the application responds to the GET LINE CODING
// with in the event handler. The application uses the
// USB_DEVICE_CDC_ControlSend() function to do this.
// ------------------------------------------------------------------
USB_DEVICE_CDC_EVENT_DATA_GET_LINE_CODING getLineCodingData;
USB_DEVICE_CDC_CONTROL_TRANSFER_HANDLE controlTransferHandle;
USB_DEVICE_CDC_EVENT_RESPONSE USBDeviceCDCEventHandler
(
USB_DEVICE_CDC_INDEX instanceIndex,
USB_DEVICE_CDC_EVENT event,
USB_DEVICE_CDC_CONTROL_TRANSFER_HANDLE controlTransferHandle,
void * pData,
uintptr_t userData
)
{
switch(event)
{
case USB_DEVICE_CDC_EVENT_GET_LINE_CODING:
// In this case, the application should send the line coding
// data to the host. The application must use the
// USB_DEVICE_CDC_ControlSend() function to send the data.
USB_DEVICE_CDC_ControlSend(instanceIndex, controlTransferHandle
&getLineCodingData,
sizeof(USB_DEVICE_CDC_EVENT_DATA_GET_LINE_CODING));
break;
}
}
// --------------------------------------------------------------------
// In this example, the application defers the response to the
// event. This is done by calling the USB_DEVICE_CDC_ControlSend()
// function after the event handler exits.
// --------------------------------------------------------------------
5.9 USB Library Help MPLAB Harmony Help USB Device CDC Library
5-4079
USB_DEVICE_CDC_EVENT_DATA_GET_LINE_CODING getLineCodingData;
USB_DEVICE_CDC_CONTROL_TRANSFER_HANDLE thisControlTransferHandle;
bool sendLineCodingToHost;
USB_DEVICE_CDC_EVENT_RESPONSE USBDeviceCDCEventHandler
(
USB_DEVICE_CDC_INDEX instanceIndex,
USB_DEVICE_CDC_EVENT event,
USB_DEVICE_CDC_CONTROL_TRANSFER_HANDLE controlTransferHandle,
void * pData,
uintptr_t userData
)
{
switch(event)
{
case USB_DEVICE_CDC_EVENT_GET_LINE_CODING:
// In this case, the application should send the line coding
// data to the host. The application does not call
// USB_DEVICE_CDC_ControlSend() function
// in the event handler, because it does not have the line
// coding data ready.
thisControlTransferHandle = controlTransferHandle;
sendLineCodingToHost = true;
break;
}
}
// This is outside the event handler.
if(sendLineCodingToHost)
{
// The application fetches the line coding from the
// an EEPROM.
GetLineCodingFromEEPROM(&getLineCoding);
USB_DEVICE_CDC_ControlSend(instanceIndex, thisControlTransferHandle
&getLineCodingData,
sizeof(USB_DEVICE_CDC_EVENT_DATA_GET_LINE_CODING));
}
5.9.4.6.1.3 USB_DEVICE_CDC_ControlStatus Function
C
USB_DEVICE_CDC_RESULT USB_DEVICE_CDC_ControlStatus(
USB_DEVICE_CDC_INDEX instanceIndex,
USB_DEVICE_CDC_CONTROL_TRANSFER_HANDLE controlTransferHandle,
USB_DEVICE_CDC_CONTROL_STATUS status
);
Description
This function allows the application to complete the status stage of the the CDC Function Driver specific control transfer request.
The application can either accept the data stage or stall it. Calling this function with status set to
USB_DEVICE_CDC_CONTROL_STATUS_OK will acknowledge the status stage of the control transfer. The control transfer can
be stalled by setting the status parameter to USB_DEVICE_CDC_CONTROL_STATUS_ERROR. The function can be called in
the CDC Function Driver event handler or can be called outside the event handler. Calling this function outside the event handler
defers the response to the event. This allows the application to analyze the event response outside the event handler. Note
however, that there are timing considerations when responding to the control transfer. Exceeding the response time will cause
the host to cancel the control transfer and may cause USB host to reject the device. The application must use the control transfer
5.9 USB Library Help MPLAB Harmony Help USB Device CDC Library
5-4080
handle that was generated along with the event as the controlTransferHandle. The application must be aware of events and
associated control transfers that do or do not require data stages. Incorrect usage of the USB_DEVICE_CDC_ControlStatus()
function could cause the device function to be non-compliant.
Preconditions
This function should only be called in response to a CDC function driver event that requires a control transfer response.
Parameters
Parameters Description
instance USB Device CDC Function Driver instance.
controlTransferHandle Control Transfer handle for the control transfer.
status Set to USB_DEVICE_CDC_CONTROL_STATUS_OK to acknowledge the control
transfer. Set to USB_DEVICE_CDC_CONTROL_STATUS_ERROR to stall the
transfer.
Returns
USB_DEVICE_CDC_RESULT_ERROR_CONTROL_TRANSFER_FAILED - The request was not successful because the USB
host cancelled the control transfer.
USB_DEVICE_CDC_RESULT_OK - The request was successful.
Remarks
None.
Example
// ------------------------------------------------------------------
// In this code example, the application responds to the the
// SEND BREAK event in the event handler.
// ------------------------------------------------------------------
USB_DEVICE_CDC_EVENT_DATA_SEND_BREAK * sendBreakData;
USB_DEVICE_CDC_EVENT_RESPONSE USBDeviceCDCEventHandler
(
USB_DEVICE_CDC_INDEX instanceIndex,
USB_DEVICE_CDC_EVENT event,
USB_DEVICE_CDC_CONTROL_TRANSFER_HANDLE controlTransferHandle,
void * pData,
uintptr_t userData
)
{
switch(event)
{
case USB_DEVICE_CDC_EVENT_SEND_BREAK:
// The application can check if the break duration is supported.
sendBreakData = (USB_DEVICE_CDC_EVENT_DATA_SEND_BREAK *)pData;
if(IsBreakDurationSupported(sendBreakData->duration))
{
USB_DEVICE_CDC_ControlStatus(instanceIndex,
controlTransferHandle, USB_DEVICE_CDC_CONTROL_STATUS_OK);
}
else
{
// If the break duration is not supported the application
// can stall it.
USB_DEVICE_CDC_ControlStatus(instanceIndex,
controlTransferHandle, USB_DEVICE_CDC_CONTROL_STATUS_ERROR);
5.9 USB Library Help MPLAB Harmony Help USB Device CDC Library
5-4081
}
break;
}
}
// --------------------------------------------------------------------
// In this example, the application defers the response to the
// SEND BREAK event. The application responds to the event
// after the event handler exits.
// --------------------------------------------------------------------
USB_DEVICE_CDC_CONTROL_TRANSFER_HANDLE thisControlTransferHandle;
USB_DEVICE_CDC_EVENT_DATA_SEND_BREAK * sendBreakData;
uint16_t breakDuration;
bool sendBreakEvent;
USB_DEVICE_CDC_EVENT_RESPONSE USBDeviceCDCEventHandler
(
USB_DEVICE_CDC_INDEX instanceIndex,
USB_DEVICE_CDC_EVENT event,
USB_DEVICE_CDC_CONTROL_TRANSFER_HANDLE controlTransferHandle,
void * pData,
uintptr_t userData
)
{
switch(event)
{
case USB_DEVICE_CDC_EVENT_SEND_BREAK:
// Get the break duration.
sendBreakData = (USB_DEVICE_CDC_EVENT_DATA_SEND_BREAK *)pData;
breakDuration = sendBreakData->duration
sendBreakEvent = true;
break;
}
}
if(sendBreakData)
{
// The application checks if the duration is supported
// Note that this occurs after the event handler has exited.
if(IsBreakDurationSupported(breakDuration))
{
USB_DEVICE_CDC_ControlStatus(instanceIndex,
controlTransferHandle, USB_DEVICE_CDC_CONTROL_STATUS_OK);
}
else
{
// If the break duration is not supported the application
// can stall it.
USB_DEVICE_CDC_ControlStatus(instanceIndex,
controlTransferHandle, USB_DEVICE_CDC_CONTROL_STATUS_ERROR);
}
}
5.9.4.6.1.4 USB_DEVICE_CDC_EventHandlerSet Function
C
USB_DEVICE_CDC_RESULT USB_DEVICE_CDC_EventHandlerSet(
USB_DEVICE_CDC_INDEX instanceIndex,
USB_DEVICE_CDC_EVENT_HANDLER eventHandler,
5.9 USB Library Help MPLAB Harmony Help USB Device CDC Library
5-4082
uintptr_t context
);
Description
This function registers a event handler for the specified CDC function driver instance. This function should be called by the client
when it receives a SET CONFIGURATION event from the device layer. A event handler must be registered for function driver to
respond to function driver specific commands. If the event handler is not registered, the device layer will stall function driver
specific commands and the USB device may not function.
Preconditions
This function should be called when the function driver has been initialized as a result of a set configuration.
Parameters
Parameters Description
instance Instance of the CDC Function Driver.
eventHandler A pointer to event handler function.
context Application specific context that is returned in the event handler.
Returns
USB_DEVICE_CDC_RESULT_OK - The operation was successful
USB_DEVICE_CDC_RESULT_ERROR_INSTANCE_INVALID - The specified instance does not exist.
USB_DEVICE_CDC_RESULT_ERROR_PARAMETER_INVALID - The eventHandler parameter is NULL
Remarks
None.
Example
// This code snippet shows an example registering an event handler. Here
// the application specifies the context parameter as a pointer to an
// application object (appObject) that should be associated with this
// instance of the CDC function driver.
USB_DEVICE_CDC_RESULT result;
USB_DEVICE_CDC_EVENT_RESPONSE APP_USBDeviceCDCEventHandler
(
USB_DEVICE_CDC_INDEX instanceIndex ,
USB_DEVICE_CDC_EVENT event ,
USB_DEVICE_CDC_CONTROL_TRANSFER_HANDLE controlTransferHandle
void* pData, uintptr_t context
)
{
// Event Handling comes here
switch(event)
{
...
}
return(USB_DEVICE_CDC_EVENT_RESPONSE_NONE);
}
result = USB_DEVICE_CDC_EventHandlerSet ( 0 ,&APP_EventHandler, (uintptr_t) &appObject);
if(USB_DEVICE_CDC_RESULT_OK != result)
{
SYS_ASSERT ( false , "invalid event handler function" );
}
5.9 USB Library Help MPLAB Harmony Help USB Device CDC Library
5-4083
5.9.4.6.1.5 USB_DEVICE_CDC_Read Function
C
USB_DEVICE_CDC_RESULT USB_DEVICE_CDC_Read(
USB_DEVICE_CDC_INDEX instanceIndex,
USB_DEVICE_CDC_TRANSFER_HANDLE * transferHandle,
void * data,
size_t size
);
Description
This function requests a data read from the USB Device CDC Function Driver Layer. The function places a requests with driver,
the request will get serviced as data is made available by the USB Host. A handle to the request is returned in the
transferHandle parameter. The termination of the request is indicated by the USB_DEVICE_CDC_EVENT_READ_COMPLETE
event. The amount of data read and the transfer handle associated with the request is returned along with the event in the pData
parameter of the event handler. The transfer handle expires when event handler for the
USB_DEVICE_CDC_EVENT_READ_COMPLETE exits. If the read request could not be accepted, the function returns an error
code and transferHandle will contain the value USB_DEVICE_CDC_TRANSFER_HANDLE_INVALID.
If the size parameter is not a multiple of maxPacketSize or is 0, the function returns
USB_DEVICE_CDC_TRANSFER_HANDLE_INVALID in transferHandle and returns an error code as a return value. If the size
parameter is a multiple of maxPacketSize and the host send less than maxPacketSize data in any transaction, the transfer
completes and the function driver will issue a USB_DEVICE_CDC_EVENT_READ_COMPLETE event along with the
USB_DEVICE_CDC_EVENT_READ_COMPLETE_DATA data structure. If the size parameter is a multiple of maxPacketSize
and the host sends maxPacketSize amount of data, and total data received does not exceed size, then the function driver will
wait for the next packet.
Preconditions
The function driver should have been configured.
Parameters
Parameters Description
instance USB Device CDC Function Driver instance.
transferHandle Pointer to a USB_DEVICE_CDC_TRANSFER_HANDLE type of variable. This
variable will contain the transfer handle in case the read request was successful.
data pointer to the data buffer where read data will be stored.
size Size of the data buffer. Refer to the description section for more details on how the
size affects the transfer.
Returns
USB_DEVICE_CDC_RESULT_OK - The read request was successful. transferHandle contains a valid transfer handle.
USB_DEVICE_CDC_RESULT_ERROR_TRANSFER_QUEUE_FULL - internal request queue is full. The write request could not
be added.
USB_DEVICE_CDC_RESULT_ERROR_TRANSFER_SIZE_INVALID - The specified transfer size was not a mulitple of endpoint
size or is 0.
USB_DEVICE_CDC_RESULT_ERROR_INSTANCE_NOT_CONFIGURED - The specified instance is not configured yet.
USB_DEVICE_CDC_RESULT_ERROR_INSTANCE_INVALID - The specified instance was not provisioned in the application
and is invalid.
Remarks
None.
5.9 USB Library Help MPLAB Harmony Help USB Device CDC Library
5-4084
Example
// Shows an example of how to read. This assumes that
// driver was opened successfully.
USB_DEVICE_CDC_TRANSFER_HANDLE transferHandle;
USB_DEVICE_CDC_RESULT readRequestResult;
USB_DEVICE_CDC_HANDLE instanceHandle;
readRequestResult = USB_DEVICE_CDC_Read(instanceHandle,
&transferHandle, data, 128);
if(USB_DEVICE_CDC_RESULT_OK != readRequestResult)
{
//Do Error handling here
}
// The completion of the read request will be indicated by the
// USB_DEVICE_CDC_EVENT_READ_COMPLETE event.
5.9.4.6.1.6 USB_DEVICE_CDC_SerialStateNotificationSend Function
C
USB_DEVICE_CDC_RESULT USB_DEVICE_CDC_SerialStateNotificationSend(
USB_DEVICE_CDC_INDEX instanceIndex,
USB_DEVICE_CDC_TRANSFER_HANDLE * transferHandle,
USB_DEVICE_CDC_SERIAL_STATE_NOTIFICATION_DATA * notificationData
);
Description
This function places a request to send serial state notificatin data to the host. The function will place the request with the driver,
the request will get serviced when the data is requested by the USB host. A handle to the request is returned in the
transferHandle parameter. The termination of the request is indicated by the
USB_DEVICE_CDC_EVENT_SERIAL_STATE_NOTIFICATION_COMPLETE event. The amount of data transmitted and the
transfer handle associated with the request is returned along with the event in the serialStateNotificationCompleteData member
of pData paramter of the event handler. The transfer handle expires when the event handler for the
USB_DEVICE_CDC_EVENT_SERIAL_STATE_NOTIFICATION_COMPLETE event exits. If the send request could not be
accepted, the function returns an error code and transferHandle will contain the value
USB_DEVICE_CDC_TRANSFER_HANDLE_INVALID.
Preconditions
The function driver should have been configured
Parameters
Parameters Description
instance USB Device CDC Function Driver instance.
transferHandle Pointer to a output only variable that will contain transfer handle.
notificationData USB_DEVICE_CDC_SERIAL_STATE_NOTIFICATION_DATA type of notification
data to be sent to the host.
Returns
USB_DEVICE_CDC_RESULT_OK - The request was successful. transferHandle contains a valid transfer handle.
USB_DEVICE_CDC_RESULT_ERROR_TRANSFER_QUEUE_FULL - Internal request queue is full. The request could not be
added.
USB_DEVICE_CDC_RESULT_ERROR_INSTANCE_NOT_CONFIGURED - The specified instance is not configured yet.
USB_DEVICE_CDC_RESULT_ERROR_INSTANCE_INVALID - The specified instance was not provisioned in the application
5.9 USB Library Help MPLAB Harmony Help USB Device CDC Library
5-4085
and is invalid.
Remarks
None.
Example
USB_DEVICE_CDC_SERIAL_STATE_NOTIFICATION_DATA notificationData;
// This application function could possibly update the notificationData
// data structure.
APP_UpdateNotificationData(¬ificationData);
// Now send the updated notification data to the host.
result = USB_DEVICE_CDC_SerialStateNotificationSend
(instanceIndex, &transferHandle, ¬ificationData);
if(USB_DEVICE_CDC_RESULT_OK != result)
{
// Error handling here. The transferHandle will contain
// USB_DEVICE_CDC_TRANSFER_HANDLE_INVALID in this case.
}
5.9.4.6.1.7 USB_DEVICE_CDC_Write Function
C
USB_DEVICE_CDC_RESULT USB_DEVICE_CDC_Write(
USB_DEVICE_CDC_INDEX instanceIndex,
USB_DEVICE_CDC_TRANSFER_HANDLE * transferHandle,
const void * data,
size_t size,
USB_DEVICE_CDC_TRANSFER_FLAGS flags
);
Description
This function requests a data write to the USB Device CDC Function Driver Layer. The function places a requests with driver, the
request will get serviced as data is requested by the USB Host. A handle to the request is returned in the transferHandle
parameter. The termination of the request is indicated by the USB_DEVICE_CDC_EVENT_WRITE_COMPLETE event. The
amount of data written and the transfer handle associated with the request is returned along with the event in writeCompleteData
member of the pData parameter in the event handler. The transfer handle expires when event handler for the
USB_DEVICE_CDC_EVENT_WRITE_COMPLETE exits. If the read request could not be accepted, the function returns an error
code and transferHandle will contain the value USB_DEVICE_CDC_TRANSFER_HANDLE_INVALID.
The behavior of the write request depends on the flags and size parameter. If the application intends to send more data in a
request, then it should use the USB_DEVICE_CDC_TRANSFER_FLAGS_MORE_DATA_PENDING flag. If there is no more
data to be sent in the request, the application must use the USB_DEVICE_CDC_EVENT_WRITE_COMPLETE flag. This is
explained in more detail here:
• If size is a multiple of maxPacketSize and flag is set as
USB_DEVICE_CDC_TRANSFER_FLAGS_DATA_COMPLETE, the write function will append a Zero Length Packet (ZLP) to
complete the transfer.
• If size is a multiple of maxPacketSize and flag is set as
USB_DEVICE_CDC_TRANSFER_FLAGS_MORE_DATA_PENDING, the write function will not append a ZLP and hence will
5.9 USB Library Help MPLAB Harmony Help USB Device CDC Library
5-4086
not complete the transfer.
• If size is greater than but not a multiple of maxPacketSize and
flags is set as USB_DEVICE_CDC_TRANSFER_FLAGS_DATA_COMPLETE, the write function schedules
(length/maxPacketSize) packets and one packet for the residual data.
• If size is greater than but not a multiple of maxPacketSize and flags is
set as USB_DEVICE_CDC_TRANSFER_FLAGS_MORE_DATA_PENDING, the write function schedules (size/maxPacketSize)
packets only.
• If size is less than maxPacketSize and flag is set as
USB_DEVICE_CDC_TRANSFER_FLAGS_DATA_COMPLETE, the write function schedules one packet.
• If size is less than maxPacketSize and flag is set as
USB_DEVICE_CDC_TRANSFER_FLAGS_MORE_DATA_PENDING, the write function returns an error code and sets the
transferHandle parameter to USB_DEVICE_CDC_TRANSFER_HANDLE_INVALID.
Completion of the write transfer is indicated by the USB_DEVICE_CDC_EVENT_WRITE_COMPLETE event. The amount of
data written along with the transfer handle is returned along with the event.
Preconditions
The function driver should have been configured.
Parameters
Parameters Description
instance USB Device CDC Function Driver instance.
transferHandle Pointer to a USB_DEVICE_CDC_TRANSFER_HANDLE type of variable. This
variable will contain the transfer handle in case the write request was successful.
data pointer to the data buffer that contains the data to written.
size Size of the data buffer. Refer to the description section for more details on how the
size affects the transfer.
flags Flags that indicate whether the transfer should continue or end. Refer to the
description for more details.
Returns
USB_DEVICE_CDC_RESULT_OK - The write request was successful. transferHandle contains a valid transfer handle.
USB_DEVICE_CDC_RESULT_ERROR_TRANSFER_QUEUE_FULL - internal request queue is full. The write request could not
be added.
USB_DEVICE_CDC_RESULT_ERROR_TRANSFER_SIZE_INVALID - The specified transfer size and flag parameter are invalid.
USB_DEVICE_CDC_RESULT_ERROR_INSTANCE_NOT_CONFIGURED - The specified instance is not configured yet.
USB_DEVICE_CDC_RESULT_ERROR_INSTANCE_INVALID - The specified instance was not provisioned in the application
and is invalid.
Remarks
None.
5.9 USB Library Help MPLAB Harmony Help USB Device CDC Library
5-4087
Example
// Below is a set of examples showing various conditions trying to
// send data with the Write() command.
//
// This assumes that driver was opened successfully.
// Assume maxPacketSize is 64.
USB_DEVICE_CDC_TRANSFER_HANDLE transferHandle;
USB_DEVICE_CDC_RESULT writeRequestHandle;
USB_DEVICE_CDC_INDEX instance;
//-------------------------------------------------------
// In this example we want to send 34 bytes only.
writeRequestResult = USB_DEVICE_CDC_Write(instance,
&transferHandle, data, 34,
USB_DEVICE_CDC_TRANSFER_FLAGS_DATA_COMPLETE);
if(USB_DEVICE_CDC_RESULT_OK != writeRequestResult)
{
//Do Error handling here
}
//-------------------------------------------------------
// In this example we want to send 64 bytes only.
// This will cause a ZLP to be sent.
writeRequestResult = USB_DEVICE_CDC_Write(instance,
&transferHandle, data, 64,
USB_DEVICE_CDC_TRANSFER_FLAGS_DATA_COMPLETE);
if(USB_DEVICE_CDC_RESULT_OK != writeRequestResult)
{
//Do Error handling here
}
//-------------------------------------------------------
// This example will return an error because size is less
// than maxPacketSize and the flag indicates that more
// data is pending.
writeRequestResult = USB_DEVICE_CDC_Write(instanceHandle,
&transferHandle, data, 32,
USB_DEVICE_CDC_TRANSFER_FLAGS_MORE_DATA_PENDING);
//-------------------------------------------------------
// In this example we want to place a request for a 70 byte transfer.
// The 70 bytes will be sent out in a 64 byte transaction and a 6 byte
// transaction completing the transfer.
writeRequestResult = USB_DEVICE_CDC_Write(instanceHandle,
&transferHandle, data, 70,
USB_DEVICE_CDC_TRANSFER_FLAGS_DATA_COMPLETE);
if(USB_DEVICE_CDC_RESULT_OK != writeRequestResult)
{
//Do Error handling here
}
//-------------------------------------------------------
// In this example we want to place a request for a 70 bytes to be sent but
// that we don't end the transfer as more data is coming. 64 bytes of the
// 70 will be sent out and the USB_DEVICE_CDC_EVENT_WRITE_COMPLETE with 64
// bytes. This indicates that the extra 6 bytes weren't sent because it
// would cause the end of the transfer. Thus the user needs add these 6
5.9 USB Library Help MPLAB Harmony Help USB Device CDC Library
5-4088
// bytes back to the buffer for the next group of data that needs to be sent
// out.
writeRequestResult = USB_DEVICE_CDC_Write(instanceHandle,
&transferHandle, data, 70,
USB_DEVICE_CDC_TRANSFER_FLAGS_MORE_DATA_PENDING);
if(USB_DEVICE_CDC_RESULT_OK != writeRequestResult)
{
//Do Error handling here
}
// The completion of the write request will be indicated by the
// USB_DEVICE_CDC_EVENT_WRITE_COMPLETE event.
5.9.4.6.2 Data Types and Constants
5.9.4.6.2.1 USB_DEVICE_CDC_CONTROL_TRANSFER_HANDLE Type
C
typedef USB_DEVICE_CONTROL_TRANSFER_HANDLE USB_DEVICE_CDC_CONTROL_TRANSFER_HANDLE;
Description
USB Device CDC Function Driver Control Transfer Handle
This is returned by the CDC function driver event handler and should be used by the application while responding to CDC
function driver control transfer requests.
Remarks
None.
5.9.4.6.2.2 USB_DEVICE_CDC_EVENT Enumeration
C
typedef enum {
USB_DEVICE_CDC_EVENT_SET_LINE_CODING,
USB_DEVICE_CDC_EVENT_GET_LINE_CODING,
USB_DEVICE_CDC_EVENT_SET_CONTROL_LINE_STATE,
USB_DEVICE_CDC_EVENT_SEND_BREAK,
USB_DEVICE_CDC_EVENT_WRITE_COMPLETE,
USB_DEVICE_CDC_EVENT_READ_COMPLETE,
USB_DEVICE_CDC_EVENT_SERIAL_STATE_NOTIFICATION_COMPLETE,
USB_DEVICE_CDC_EVENT_CONTROL_TRANSFER_DATA_SENT,
USB_DEVICE_CDC_EVENT_CONTROL_TRANSFER_DATA_RECEIVED
} USB_DEVICE_CDC_EVENT;
Description
USB Device CDC Function Driver Control Transfer Status
This flag is used along with the USB_DEVICE_CDC_ControlStatus() function to indicate success or failure of a CDC class
specific control transfer request.
5.9 USB Library Help MPLAB Harmony Help USB Device CDC Library
5-4089
Members
Members Description
USB_DEVICE_CDC_EVENT_SET_LINE_CODING This event occurs when the host issues a SET
LINE CODING command. The application must
provide a
USB_DEVICE_CDC_EVENT_DATA_SET_LINE
_CODING
data structure to the device layer to receive the
line coding data that the host will provide. The
application must provide the buffer by calling the
USB_DEVICE_CDC_ControlReceive() function
either in the event handler or in the application
(outside the event handler function). The
application must use the controlTransferHandle
parameter provided in the event while calling
USB_DEVICE_CDC_ControlReceive() function.
The pData parameter will be NULL. The
application can use the
USB_DEVICE_CDC_EVENT_CONTROL_TRAN
SFER_DATA_RECEIVED
event to track completion of the command.
USB_DEVICE_CDC_EVENT_GET_LINE_CODING This event occurs when the host issues a GET
LINE CODING command. The application must
provide a
USB_DEVICE_CDC_EVENT_DATA_GET_LINE
_CODING
data structure to the device layer that contains
the line coding data to be provided to the host.
The application must provide the buffer by
calling the USB_DEVICE_CDC_ControlSend()
function either in the event handler or in the
application (outside the event handler function).
The application must use the
controlTransferHandle parameter provided in the
event while calling
USB_DEVICE_CDC_ControlSend() function.
The size of the buffer is indicated by the length
parameter. The application can use the
USB_DEVICE_CDC_EVENT_CONTROL_TRAN
SFER_DATA_SENT
event to track completion of the command.
USB_DEVICE_CDC_EVENT_SET_CONTROL_LINE_STATE This event occurs when the host issues a SET
CONTROL LINE STATE command. The
application must interpret the pData parameter
as
USB_DEVICE_CDC_EVENT_DATA_SET_CON
TROL_LINE_STATE
pointer type. This data structure contains the
control line state data. The application can then
use the USB_DEVICE_CDC_ControlStatus()
function to indicate acceptance or rejection of
the command. The
USB_DEVICE_CDC_ControlStatus() function
can be called from the event handler or in the
application (out of the event handler context).
The application should use the
controlTransferHandle while calling the
USB_DEVICE_CDC_ControlStatus() function.
5.9 USB Library Help MPLAB Harmony Help USB Device CDC Library
5-4090
USB_DEVICE_CDC_EVENT_SEND_BREAK This event occurs when the host issues a SEND
BREAK command. The application must
interpret the pData parameter as a
USB_DEVICE_CDC_EVENT_SEND_BREAK_D
ATA
pointer type. This data structure contains the
break duration data. The application can then
use the USB_DEVICE_CDC_ControlStatus()
function to indicate acceptance of rejection of
the command. The
USB_DEVICE_CDC_ControlStatus() function
can be called from the event handler or in the
application (out of the event handler context).
The application should use the
controlTransferHandle while calling the
USB_DEVICE_CDC_ControlStatus() function.
USB_DEVICE_CDC_EVENT_WRITE_COMPLETE This event occurs when a write operation
scheduled by calling the
USB_DEVICE_CDC_Write() function has
completed. The pData parameter should be
interpreted as a
USB_DEVICE_CDC_EVENT_DATA_WRITE_C
OMPLETE
pointer type. This will contain the transfer handle
associated with the completed write transfer and
the amount of data written.
USB_DEVICE_CDC_EVENT_READ_COMPLETE This event occurs when a read operation
scheduled by calling the
USB_DEVICE_CDC_Read() function has
completed. The pData parameter should be
interpreted as a
USB_DEVICE_CDC_EVENT_DATA_READ_CO
MPLETE
pointer type. This will contain the transfer handle
associated with the completed read transfer and
the amount of data read.
USB_DEVICE_CDC_EVENT_SERIAL_STATE_NOTIFICATION_COMPLETE This event occurs when a serial state notification
scheduled using the
USB_DEVICE_CDC_SerialDataSend() function,
was sent to the host. The pData parameter
should be interpreted as a
USB_DEVICE_CDC_EVENT_DATA_SERIAL_S
TATE_NOTIFICATION_COMPLETE
pointer type and will contain the transfer handle
associated with the completed send transfer and
the amount of data sent.
USB_DEVICE_CDC_EVENT_CONTROL_TRANSFER_DATA_SENT This event occurs when the data stage of a
control read transfer has completed. This event
would occur after the application uses the
USB_DEVICE_CDC_ControlSend() function to
respond to the
USB_DEVICE_CDC_EVENT_GET_LINE_CODI
NG
event.
5.9 USB Library Help MPLAB Harmony Help USB Device CDC Library
5-4091
USB_DEVICE_CDC_EVENT_CONTROL_TRANSFER_DATA_RECEIVED This event occurs when the data stage of a
control write transfer has completed. This would
occur after the application would respond with a
USB_DEVICE_CDC_ControlReceive() function
to the
USB_DEVICE_CDC_EVENT_SET_LINE_CODI
NG_EVENT
and the data has been received.
Remarks
None.
5.9.4.6.2.3 USB_DEVICE_CDC_EVENT_DATA_GET_LINE_CODING Type
C
typedef USB_CDC_LINE_CODING USB_DEVICE_CDC_EVENT_DATA_GET_LINE_CODING;
Description
USB Device CDC Event Get Line Coding Data Type.
This type defines the data type of the data that the user needs to respond with as a result of a
USB_DEVICE_CDC_EVENT_GET_LINE_CODING event. This data is sent to the host via the USB_DEVICE_ControlWrite()
function.
The valid values for the members of this structure are defined in table 17 of the PSTN120.pdf document. This document is part
of the CDC specification download available on the USB.org website:
http://www.usb.org/developers/devclass_docs/CDC1.2_WMC1.1_012011.zip
Remarks
None.
5.9.4.6.2.4 USB_DEVICE_CDC_EVENT_DATA_READ_COMPLETE Structure
C
typedef struct {
USB_DEVICE_CDC_TRANSFER_HANDLE handle;
size_t length;
} USB_DEVICE_CDC_EVENT_DATA_WRITE_COMPLETE, USB_DEVICE_CDC_EVENT_DATA_READ_COMPLETE,
USB_DEVICE_CDC_EVENT_DATA_SERIAL_STATE_NOTIFICATION_COMPLETE;
Description
USB Device CDC Function Driver Read and Write Complete Event Data.
This data type defines the data structure returned by the driver along with USB_DEVICE_CDC_EVENT_READ_COMPLETE and
USB_DEVICE_CDC_EVENT_WRITE_COMPLETE events.
Members
Members Description
5.9.4.6.2.5 USB_DEVICE_CDC_EVENT_DATA_SEND_BREAK Structure
C
typedef struct {
uint16_t duration;
} USB_DEVICE_CDC_EVENT_DATA_SEND_BREAK;
5.9 USB Library Help MPLAB Harmony Help USB Device CDC Library
5-4092
Description
USB Device CDC Event Set Break Data Type.
This defines the data type of the data generated to the CDC event handler on a USB_DEVICE_CDC_EVENT_SEND_BREAK
event.
The SEND_BREAK command is described in section 6.3.13 of the PSTN120.pdf document. This document is part of the CDC
specification download available on the USB.org website:
http://www.usb.org/developers/devclass_docs/CDC1.2_WMC1.1_012011.zip
Remarks
None.
5.9.4.6.2.6 USB_DEVICE_CDC_EVENT_DATA_SERIAL_STATE_NOTIFICATION_COMPLETE
Structure
C
typedef struct {
USB_DEVICE_CDC_TRANSFER_HANDLE handle;
size_t length;
} USB_DEVICE_CDC_EVENT_DATA_WRITE_COMPLETE, USB_DEVICE_CDC_EVENT_DATA_READ_COMPLETE,
USB_DEVICE_CDC_EVENT_DATA_SERIAL_STATE_NOTIFICATION_COMPLETE;
Description
USB Device CDC Function Driver Read and Write Complete Event Data.
This data type defines the data structure returned by the driver along with USB_DEVICE_CDC_EVENT_READ_COMPLETE and
USB_DEVICE_CDC_EVENT_WRITE_COMPLETE events.
Members
Members Description
5.9.4.6.2.7 USB_DEVICE_CDC_EVENT_DATA_SET_CONTROL_LINE_STATE Type
C
typedef USB_CDC_CONTROL_LINE_STATE USB_DEVICE_CDC_EVENT_DATA_SET_CONTROL_LINE_STATE;
Description
USB Device CDC Event Set Control Line State Data Type.
This defines the data type of the data that should be provided to the function driver via the
USB_DEVICE_CDC_ControlReceive() function when the function driver generates
USB_DEVICE_CDC_EVENT_SET_CONTROL_LINE_STATE event.
Remarks
None.
5.9.4.6.2.8 USB_DEVICE_CDC_EVENT_DATA_SET_LINE_CODING Type
C
typedef USB_CDC_LINE_CODING USB_DEVICE_CDC_EVENT_DATA_SET_LINE_CODING;
Description
USB Device CDC Event Set Line Coding Data Type.
5.9 USB Library Help MPLAB Harmony Help USB Device CDC Library
5-4093
This defines the data type of the data generated to the CDC event handler on a
USB_DEVICE_CDC_EVENT_SET_LINE_CODING event.
The valid values for the members of this structure are defined in table 17 of the PSTN120.pdf document. This document is part
of the CDC specification download available on the USB.org website:
http://www.usb.org/developers/devclass_docs/CDC1.2_WMC1.1_012011.zip
Remarks
None.
5.9.4.6.2.9 USB_DEVICE_CDC_EVENT_DATA_WRITE_COMPLETE Structure
C
typedef struct {
USB_DEVICE_CDC_TRANSFER_HANDLE handle;
size_t length;
} USB_DEVICE_CDC_EVENT_DATA_WRITE_COMPLETE, USB_DEVICE_CDC_EVENT_DATA_READ_COMPLETE,
USB_DEVICE_CDC_EVENT_DATA_SERIAL_STATE_NOTIFICATION_COMPLETE;
Description
USB Device CDC Function Driver Read and Write Complete Event Data.
This data type defines the data structure returned by the driver along with USB_DEVICE_CDC_EVENT_READ_COMPLETE and
USB_DEVICE_CDC_EVENT_WRITE_COMPLETE events.
Members
Members Description
5.9.4.6.2.10 USB_DEVICE_CDC_EVENT_HANDLER Type
C
typedef USB_DEVICE_CDC_EVENT_RESPONSE (* USB_DEVICE_CDC_EVENT_HANDLER)(USB_DEVICE_CDC_INDEX
instanceIndex, USB_DEVICE_CDC_EVENT event, USB_DEVICE_CDC_CONTROL_TRANSFER_HANDLE
controlTransferHandle, void * pData, uintptr_t context);
Description
USB Device CDC Event Handler Function Pointer Type.
This data type defines the required function signature of the USB Device CDC Function Driver event handling callback function.
The application must register a pointer to a CDC Function Driver events handling function who's function signature (parameter
and return value types) match the types specified by this function pointer in order to receive event call backs from the CDC
Function Driver. The function driver will invoke this function with event relevant parameters. The description of the event handler
function parameters is given here.
instanceIndex - Instance index of the CDC Function Driver that generated the event.
event - Type of event generated.
controlTransferHandle - Control Transfer Handle for CDC function driver events that require application response. The
application should use this handle when calling the USB CDC Device Control Transfer functions to respond to the events.
pData - This parameter should be type casted to a event specific pointer type based on the event that has occurred. Refer to the
USB_DEVICE_CDC_EVENT enumeration description for more details.
context - Value identifying the context of the application that was registered along with the event handling function.
Remarks
None.
5.9 USB Library Help MPLAB Harmony Help USB Device CDC Library
5-4094
5.9.4.6.2.11 USB_DEVICE_CDC_EVENT_RESPONSE Type
C
typedef void USB_DEVICE_CDC_EVENT_RESPONSE;
Description
USB Device CDC Function Driver Event Handler Response Type
This is the return type of the CDC Function Driver event handler.
Remarks
None.
5.9.4.6.2.12 USB_DEVICE_CDC_INDEX Type
C
typedef uintptr_t USB_DEVICE_CDC_INDEX;
Description
USB Device CDC Function Driver Index
This uniquely identifies a CDC Function Driver instance.
Remarks
None.
5.9.4.6.2.13 USB_DEVICE_CDC_INIT Structure
C
typedef struct {
size_t queueSizeRead;
size_t queueSizeWrite;
size_t queueSizeSerialStateNotification;
} USB_DEVICE_CDC_INIT;
Description
USB Device CDC Function Driver Initialization Data Structure
This data structure must be defined for every instance of the CDC function driver. It is passed to the CDC function driver, by the
Device Layer, at the time of initialization. The funcDriverInit member of the Device Layer Function Driver registration table entry
must point to this data structure for an instance of the CDC function driver.
Members
Members Description
5.9.4.6.2.14 USB_DEVICE_CDC_RESULT Enumeration
C
typedef enum {
USB_DEVICE_CDC_RESULT_OK,
USB_DEVICE_CDC_RESULT_ERROR_TRANSFER_SIZE_INVALID,
USB_DEVICE_CDC_RESULT_ERROR_TRANSFER_QUEUE_FULL,
USB_DEVICE_CDC_RESULT_ERROR_INSTANCE_INVALID,
USB_DEVICE_CDC_RESULT_ERROR_INSTANCE_NOT_CONFIGURED,
USB_DEVICE_CDC_RESULT_ERROR_PARAMETER_INVALID,
USB_DEVICE_CDC_RESULT_ERROR_CONTROL_TRANSFER_FAILED
5.9 USB Library Help MPLAB Harmony Help USB Device CDC Library
5-4095
} USB_DEVICE_CDC_RESULT;
Description
USB Device CDC Function Driver USB Device CDC Result enumeration.
This enumeration lists the possible USB Device CDC Function Driver operation results. These values are returned by USB
Device CDC Library functions.
Members
Members Description
USB_DEVICE_CDC_RESULT_OK The operation was successful
5.9.4.6.2.15 USB_DEVICE_CDC_SERIAL_STATE_NOTIFICATION_DATA Type
C
typedef USB_CDC_SERIAL_STATE USB_DEVICE_CDC_SERIAL_STATE_NOTIFICATION_DATA;
Description
USB Device CDC Serial State Notification Data Type.
This defines the data type for the CDC Serial State. This data is sent to the host over the CDC notification interface.
Remarks
None.
5.9.4.6.2.16 USB_DEVICE_CDC_TRANSFER_FLAGS Enumeration
C
typedef enum {
USB_DEVICE_CDC_TRANSFER_FLAGS_DATA_COMPLETE,
USB_DEVICE_CDC_TRANSFER_FLAGS_MORE_DATA_PENDING
} USB_DEVICE_CDC_TRANSFER_FLAGS;
Description
USB Device CDC Transfer Flags
These flags are used to indicate status of the pending data while sending data to the host by using the
USB_DEVICE_CDC_Write() function.
Members
Members Description
USB_DEVICE_CDC_TRANSFER_FLAGS_DATA_COMPLETE This flag indicates there is no further data to be sent in
this transfer and that the transfer should end. If the size
of the transfer is a multiple of the maximum packet size
for related endpoint configuration, the function driver will
send a zero length packet to indicate end of the transfer
to the host.
5.9 USB Library Help MPLAB Harmony Help USB Device CDC Library
5-4096
USB_DEVICE_CDC_TRANSFER_FLAGS_MORE_DATA_PENDING This flag indicates there is more data to be sent in this
transfer. If the size of the transfer is a multiple of the
maximum packet size for the related endpoint
configuration, the function driver will not send a zero
length packet. If the size of the transfer is greater than
(but not a multiple of) the maximum packet size, the
function driver will only send maximum packet size
amount of data. If the size of the transfer is greater than
endpoint size but not an exact multiple of endpoint size,
only the closest endpoint size multiple bytes of data will
be sent. This flag should not be specified if the size of the
transfer is less than maximum packet size.
Remarks
The relevance of the specified flag depends on the size of the buffer. Refer to the individual flag descriptions for more details.
5.9.4.6.2.17 USB_DEVICE_CDC_TRANSFER_HANDLE Type
C
typedef uintptr_t USB_DEVICE_CDC_TRANSFER_HANDLE;
Description
USB Device CDC Function Driver Transfer Handle Definition
This definition defines a USB Device CDC Function Driver Transfer Handle. A Transfer Handle is owned by the application but
its value is modified by the USB_DEVICE_CDC_Write(), USB_DEVICE_CDC_Read() and the
USB_DEVICE_CDC_SerialStateDataSend functions. The transfer handle is valid for the life time of the transfer and expires
when the transfer related event had occurred.
Remarks
None.
5.9.4.6.2.18 USB_DEVICE_CDC_EVENT_RESPONSE_NONE Macro
C
#define USB_DEVICE_CDC_EVENT_RESPONSE_NONE
Description
USB Device CDC Function Driver Event Handler Response None
This is the definition of the CDC Function Driver Event Handler Response Type none.
Remarks
Intentionally defined to be empty.
5.9.4.6.2.19 USB_DEVICE_CDC_TRANSFER_HANDLE_INVALID Macro
C
#define USB_DEVICE_CDC_TRANSFER_HANDLE_INVALID ((USB_DEVICE_CDC_TRANSFER_HANDLE)(-1))
Description
USB Device CDC Function Driver Invalid Transfer Handle Definition
This definition defines a USB Device CDC Function Driver Invalid Transfer Handle. A Invalid Transfer Handle is returned by the
USB_DEVICE_CDC_Write(), USB_DEVICE_CDC_Read() and the USB_DEVICE_CDC_SerialStateNotificationSend() functions
5.9 USB Library Help MPLAB Harmony Help USB Device CDC Library
5-4097
when the request was not successful.
Remarks
None.
5.9.4.7 Files
Files
Name Description
usb_device_cdc.h USB Device CDC Function Driver Interface
Description
5.9.4.7.1 usb_device_cdc.h
USB Device CDC Function Driver Interface
This file describes the USB Device CDC Function Driver interface.
Enumerations
Name Description
USB_DEVICE_CDC_EVENT USB Device CDC Function Driver Control Transfer Status
USB_DEVICE_CDC_RESULT USB Device CDC Function Driver USB Device CDC Result
enumeration.
USB_DEVICE_CDC_TRANSFER_FLAGS USB Device CDC Function Driver Transfer Flags
Functions
Name Description
USB_DEVICE_CDC_ControlReceive This function allows the application to respond to the CDC
function driver specific control transfer requests. It allows the
application to receive data from the host in the data stage of the
control transfer.
USB_DEVICE_CDC_ControlSend This function allows the application to respond to the CDC
function driver specific control transfer requests. It allows the
application to send data to the host in the data stage of the
control transfer.
USB_DEVICE_CDC_ControlStatus This function allows the application to complete the status stage
of the the CDC Function Driver specific control transfer request.
USB_DEVICE_CDC_EventHandlerSet This function registers a event handler for the specified CDC
function driver instance.
USB_DEVICE_CDC_Read This function requests a data read from the USB Device CDC
Function Driver Layer.
USB_DEVICE_CDC_SerialStateNotificationSend This function schedules a request to send serial state notification
to the host.
USB_DEVICE_CDC_Write This function requests a data write to the USB Device CDC
Function Driver Layer.
5.9 USB Library Help MPLAB Harmony Help USB Device CDC Library
5-4098
Macros
Name Description
USB_DEVICE_CDC_EVENT_RESPONSE_NONE USB Device CDC Function Driver Event Handler Response
Type None.
USB_DEVICE_CDC_TRANSFER_HANDLE_INVALID USB Device CDC Function Driver Invalid Transfer Handle
Definition.
Structures
Name Description
USB_DEVICE_CDC_EVENT_DATA_READ_COMPLETE USB Device CDC Function
Driver Read and Write
Complete Event Data.
USB_DEVICE_CDC_EVENT_DATA_SEND_BREAK USB Device CDC Event Set
Break Data Type.
USB_DEVICE_CDC_EVENT_DATA_SERIAL_STATE_NOTIFICATION_COMPLETE USB Device CDC Function
Driver Read and Write
Complete Event Data.
USB_DEVICE_CDC_EVENT_DATA_WRITE_COMPLETE USB Device CDC Function
Driver Read and Write
Complete Event Data.
USB_DEVICE_CDC_INIT USB Device CDC Function
Driver Initialization Data
Structure
Types
Name Description
USB_DEVICE_CDC_CONTROL_TRANSFER_HANDLE USB Device CDC Function Driver Control
Transfer Handle
USB_DEVICE_CDC_EVENT_DATA_GET_LINE_CODING USB Device CDC Event Get Line Coding
Data Type.
USB_DEVICE_CDC_EVENT_DATA_SET_CONTROL_LINE_STATE USB Device CDC Event Set Line Coding
Data Type.
USB_DEVICE_CDC_EVENT_DATA_SET_LINE_CODING USB Device CDC Event Set Line Coding
Data Type.
USB_DEVICE_CDC_EVENT_HANDLER USB Device CDC Event Handler Function
Pointer Type.
USB_DEVICE_CDC_EVENT_RESPONSE USB Device CDC Function Driver Event
Callback Response Type
USB_DEVICE_CDC_INDEX USB Device CDC Function Driver Index
USB_DEVICE_CDC_SERIAL_STATE_NOTIFICATION_DATA USB Device Serial State Notification Data
Type.
USB_DEVICE_CDC_TRANSFER_HANDLE USB Device CDC Function Driver Transfer
Handle Definition.
Company
Microchip Technology Incorporated
FileName: usb_device_cdc.h
5.9 USB Library Help MPLAB Harmony Help USB Generic Device Library
5-4099
5.9.5 USB Generic Device Library
5.9.5.1 Introduction
Introduces the MPLAB Harmony USB Generic Device Library.
Description
The USB Generic Device library provides a framework to develop custom or vendor class USB device applications . The library
supports all USB transfer types (control, bulk, interrupt, isochronous) along with endpoint management functions. The USB
device generic library implementation supports USB specification 2.0. Following figure illustrates how Generic Device Library fits
into the MPLAB Harmony USB Device Stack architecture .
Figure: MPLAB Harmony USB Device library architecture
This USB Generic Device Library offers services to the application to interact and respond to the host requests. USB Generic
Device library is also referred to as Generic function driver in this document.
5.9.5.2 Release Notes
MPLAB Harmony Version: v0.70b USB Generic Device Library Version : 0.01 Alpha Release Date: 18Nov2013
New This Release:
This is the first release of the library. The interface can change in the beta and\or 1.0 release.
5.9 USB Library Help MPLAB Harmony Help USB Generic Device Library
5-4100
Known Issues:
Nothing to report in this release.
5.9.5.3 SW License Agreement
(c) 2013 Microchip Technology Inc.
Microchip licenses this software to you solely for use with Microchip products. The software is owned by Microchip and its
licensors, and is protected under applicable copyright laws. All rights reserved.
SOFTWARE IS PROVIDED "AS IS" MICROCHIP EXPRESSLY DISCLAIMS ANY WARRANTY OF ANY KIND, WHETHER
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. IN NO EVENT SHALL MICROCHIP BE LIABLE FOR
ANY INCIDENTAL, SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, HARM TO
YOUR EQUIPMENT, COST OF PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY OR SERVICES, ANY CLAIMS
BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), ANY CLAIMS FOR INDEMNITY OR
CONTRIBUTION, OR OTHER SIMILAR COSTS.
To the fullest extent allowed by law, Microchip and its licensors liability shall not exceed the amount of fees, if any, that you have
paid directly to Microchip to use this software.
MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE TERMS.
5.9.5.4 Library Architecture
5.9.5.4.1 Library Overview
Provides an overview of the Generic Device function driver.
Description
The Generic Device function driver overview diagram is shown below.
5.9 USB Library Help MPLAB Harmony Help USB Generic Device Library
5-4101
Figure: USB DEVICE GENERIC Library Overview diagram
A Generic function driver instance is a collection of Generic USB interfaces.
The device management on end point zero is handled by the device library(vendor class specific requests are routed to the
Generic function driver by device library).
The library interface routines are divided into various sub-sections, each of sub-section addresses one of the blocks or the
overall operation of the USB DEVICE Generic module.
Library Interface Section Description
Client Setup Details Opening an instance of the USB Generic function driver, registering
callback with the USB Generic function driver and closing an instance of
the USB Generic function driver.
Client Data Handling Details read/write to/from the host
Client Subclass Specific Details the supported sub class specific management requests and
notification.
5.9 USB Library Help MPLAB Harmony Help USB Generic Device Library
5-4102
5.9.5.4.2 Abstraction Model
Provides an architectural overview of the USB Generic Device function driver.
Description
The USB Generic Device function driver offers various services to a vendor specific class USB device to communicate with the
host by abstracting USB specification details. The USB Generic Device function driver with USB DEVICE layer and USB
controller driver forms the basic library entity using which the device can communicate with the USB host.The basic software
architecture into which Generic function driver fits into is depicted in the following diagram.
Figure: USB DEVICE Generic Software Abstraction Block Diagram
Vendor specific functions have to register a set of standard APIs with the generic library. This library calls these APIs as call
back function at run time. For example, vendor specific tasks function routine is called when USB device generic function driver
receives vendor specific transfer from a USB host. All generic function driver tasks are called from the task routine of USB device
layer. so here maximum performance of the device can be achieved with this library.
The USB controller driver takes the responsibility of managing the USB peripheral on the device. The USB device layer handles
the device enumeration etc. For more details about the USB controller driver and USB device layer library kindly refer to the
corresponding documents.
5.9 USB Library Help MPLAB Harmony Help USB Generic Device Library
5-4103
5.9.5.5 Using the Library
5.9.5.5.1 Files to Include
Describes which files to include in the project to use the Generic Device Function Driver.
Description
The following table shows the files that must be included in the project in order to use the Generic Function Driver. These files
are located in the framework folder of the MPLAB Harmony installation. It is assumed that the Device Layer files ( and the files
needed by the Device Layer) are already included in the project. A path to the framework folder in the Harmony installation
should be added to the project include search path.
Filename Description
\framework\usb\src\usb_device_generic.c Contains the implementation of the Generic device function driver.
\framework\usb\usb_device_generic.h Must be included in every file that needs to invoke the Generic device function driver
API
system_config.h User created file which contains the Generic device function driver configuration.
5.9.5.5.2 Library Configuration
Describes how to configure the Generic Function Driver.
Description
The configuration of the USB Generic Device Function Driver is contained in system_config.h These configuration settings will
apply to all instances of the USB Generic Device Function Driver. This header can be placed anywhere; however, the path of this
header needs to be present in the include search path for a successful build. Refer to the Applications Overview section for more
details.
This section explains the data structures that need to be setup by the application to use the Generic function driver. For setting
data relevant for other modules (device layer and controller driver) kindly refer to the respective module documentation.
Constants:
USB_DEVICE_GEN_DRIVER_MAX_INSTANCES: The maximum number of Generic function driver instances to be supported.
The valid values are greater than or equal to 1. this constant is not defined the default value taken by the Generic function driver
is 1.
Data structures:
The application should form structure USB_DEVICE_GEN_DRIVER_INIT_INSTANCE. The structure takes pointers to the
following functions.
- A vendor defined initialize function that is called by the device layer when it initializes the generic function driver. This will
happen when the device layer process a SET CONFIGURATION command from the host.
- A vendor defined de-initialize function that is called by the device layer when it de-initializes the generic function driver. This will
happen when the device layer process a reset event or is required to change the configuration by the host.
- A vendor defined Setup packet handler. This function is called by the device layer when it needs to pass class specific control
5.9 USB Library Help MPLAB Harmony Help USB Generic Device Library
5-4104
transfer to the generic function driver.
- A vendor specified tasks functions. This is called periodically by the device layer. This function can maintain a vendor device
state machine.
The application needs to define an array of USB_DEVICE_GEN_DRIVER_MAX_INSTANCES(defined by the application in
system_config.h) such structures. For example, if the application needs two instances of the Generic Device, then the size of this
array should be two.
Example: Creating the USB_DEVICE_GEN_DRIVER_INIT_INSTANCE structure.
USB_DEVICE_GEN_DRIVER_INIT_INSTANCE genUsbInitInstance[] =
{
{
.vendorSpecificInitialize = APP_Initialize,
.vendorSpecificDeInitialize = APP_DeInitialize,
.vendorSpecificSetupPacketHandler = APP_SetupPacketHandler,
.tasks = APP_Tasks
}
};
5.9.5.5.3 Client Setup
Note: To invoke any of the client setup routines listed in this section the device should be in configured state. Any
attempts invoking the client setup routines before the configured state will result in graceful exit.
Before using any of the USB Generic function driver services it needs to be setup once in the application.
Setting up the USB Generic function driver involves
1. Opening an instance of the USB Generic function driver.
2. Registering callback with the USB Generic function driver.
3. Closing an instance of the USB Generic function driver.
Opening an Instance of the USB GENERIC function driver:
Before attempting to use any of the USB Generic function driver services an instance of it needs to be opened by the application.
An instance of USB Generic function driver is defined as a group of minimum interfaces that constitute a Generic USB device.
To open an instance of USB Generic function driver application should call the function USB_DEVICE_GEN_DRIVER_Open.
Example: Opening a USB Generic instance
// Client Handle
DRV_HANDLE genHandle;
// open Generic USB device function driver instance 0
genHandle = USB_DEVICE_GEN_DRIVER_Open ( 0 );
// Check the validity of the handle returned
if(DRV_HANDLE_INVALID == genHandle)
{
\ Handle the error
}
Registering callback with the USB GENERIC function driver:
USB Generic function driver will inform the status of various events (both management and data) to the application using a
callback function registered with the USB Generic function driver.
This callback function should be registered with the function driver before expecting any event notifications.
There are three sources of generating events
5.9 USB Library Help MPLAB Harmony Help USB Generic Device Library
5-4105
• Data transmission request ( USB_DEVICE_GEN_DRIVER_CALLBACK_TX_ )
• Data reception request ( USB_DEVICE_GEN_DRIVER_CALLBACK_RX )
• Management Requests ( USB_DEVICE_GEN_DRIVER_CALLBACK_MANAGEMENT )
Each of these requests will result in the generation of events of type USB_DEVICE_GEN_DRIVER_CALLBACK_TYPE
For a detailed list of events go through the above enum data type.
To register a callback with the Generic function driver application should first define a function of the signature
USB_DEVICE_GEN_DRIVER_CALLBACK_EVENT.
Once defined it can be registered with the Generic function driver using the function
USB_DEVICE_GEN_DRIVER_RegisterCallBack.
Example: Registering an application callback with the Generic function driver
// Application callback to handle relevant events.
void app_gen_CallBack ( SYS_MODULE_INDEX funcDriverIndex,
USB_DEVICE_GEN_DRIVER_CALLBACK_TYPE callback,
USB_DEVICE_GEN_DRIVER_CALLBACK_EVENT event)
{
switch (callback)
{
case USB_DEVICE_GEN_DRIVER_CALLBACK_TX:
break;
case USB_DEVICE_GEN_DRIVER_CALLBACK_RX:
break;
case USB_DEVICE_GEN_DRIVER_CALLBACK_MANAGEMENT:
break;
default:
break;
}
}
int main ()
{
DRV_HANDLE genHandle;
USB_ERROR_STATUS err;
// open the Generic USB device driver instance 0 ( or what ever is applicable)
genHandle = USB_DEVICE_GEN_DRIVER_Open ( 0 );
err = USB_DEVICE_GEN_DRIVER_RegisterCallBack (genHandle,app_gen_CallBack );
if(err)
{
//handle error
}
// app code
// Occurrance of any event of type USB_DEVICE_GEN_DRIVER_CALLBACK_EVENT results in
// calling of the registered application callback
return 0;
}
Closing an Instance of the USB Generic function driver:
5.9 USB Library Help MPLAB Harmony Help USB Generic Device Library
5-4106
If at all the application wants to close an opened Generic function driver instance it can do so by calling the function
USB_DEVICE_GEN_DRIVER_Close. The application should pass the client handle it received with opened the Generic function
driver instance as the parameter. If the close is successful 0 is returned by the Generic to indicate success.
Example: Closing a Generic USB instance
// Return status
USB_ERROR_STATUS status;
// Close Generic USB device driver instance 0
status = USB_DEVICE_GEN_DRIVER_Close(0);
if(USB_ERROR_INVALID_HANDLE ==status)
{
// Generic USB device function driver instance 0 is either not opened/initialized yet
}
else if(status == USB_ERROR_OK)
{
// Generic USB device function driver instance 0 is successfully closed.
// app code
}
Before closing the Generic function driver instance the application should be aware of the following
1. Once an instance of the Generic function driver is closed the application cannot write to or read from the data end points(if
driven by Generic function driver).
2. The application will not get any event notifications .
INITIAL SETUP:
Before invoking any of the services offered by the Generic function driver following steps should have been completed
1. Certain key data structures need to be setup(initialized) by the application.
2. Certain system functions belonging to the MPLAB Harmony USB Device library should have been called.
3. The device should be in configured state.
The setup of the key data structures is explained in the Configuring the Library section. The following section focuses on the key
system functions that need to be called by the application before using Generic function driver.
The following diagram explains the sequence of system functions (belonging to the MPLAB Harmony USB Device library only)
invocations.
5.9 USB Library Help MPLAB Harmony Help USB Generic Device Library
5-4107
Figure: System Initialization
Example: System initialization
// Populate USB Controller driver init data
usbInitData.usbID = USB_ID_1;
usbInitData.usbModuleSetup.OpMode = USB_OPMODE_DEVICE;
usbInitData.usbModuleSetup.ppMode = USB_PING_PONG_MODE_SELECTION;
usbInitData.usbModuleSetup.StopInIdle = false;
usbInitData.usbModuleSetup.SuspendInSleep = false;
// Initialize the USB Control driver
driverObjectHandle = DRV_USB_Initialize(DRV_USB_INDEX_0, (SYS_MODULE_INIT*)&usbInitData);
if (SYS_MODULE_OBJ_INVALID == driverObjectHandle)
{
// Handle error
}
// NOTE: USB controller driver is opened by both device layer and function driver and not by
the application.
// Populate USB Device layer init data
deviceLayerInit.moduleInit.value = SYS_MODULE_POWER_RUN_FULL;
deviceLayerInit.usbDriverIndex = DRV_USB_INDEX_0;
deviceLayerInit.usbMasterDescriptor = (USB_MASTER_DESCRIPTOR*)&usbMasterDescriptor;
deviceLayerInit.registeredFuncCount = 1;
deviceLayerInit.registeredFunctions =
(USB_DEVICE_FUNC_REGISTRATION_TABLE*)funcRegistrationTable;
5.9 USB Library Help MPLAB Harmony Help USB Generic Device Library
5-4108
// Initialize the USB device layer
usbDeviceObj = USB_DEVICE_Initialize( USB_DEVICE_INDEX_0, (SYS_MODULE_INIT*)&deviceLayerInit );
// Open the device layer.
usbDevHandle = USB_DEVICE_Open( USB_DEVICE_INDEX_0 );
// Register a callback with device layer to get event notification (for end point 0)
USB_DEVICE_EventCallBackSet(usbDevHandle, usbDeviceEventCallBack);
The following example provides a complete Generic function driver setup. This example do not use separate functions to do
activities like system initialization, Generic function driver setup etc for the sake of clarity. It is recommended to use separate
functions to have a structured view of the project.
// Application callback to handle relevant events.
void app_gen_CallBack ( SYS_MODULE_INDEX funcDriverIndex,
USB_DEVICE_GEN_DRIVER_CALLBACK_TYPE callback,
USB_DEVICE_GEN_DRIVER_CALLBACK_EVENT event)
{
switch (callback)
{
case USB_DEVICE_GEN_DRIVER_CALLBACK_TX:
break;
case USB_DEVICE_GEN_DRIVER_CALLBACK_RX:
break;
case USB_DEVICE_GEN_DRIVER_CALLBACK_MANAGEMENT:
break;
default:
break;
}
}
// Device event callback of the application.
// This will be registered with the device layer
// during the system initialization.
void usbDeviceEventCallBack(USB_DEVICE_EVENTS events)
{
if(events.setConfiguration)
{
// Device is configured.
// Initialize function drivers.
isConfigured = true;
///////////////// Generic function driver Setup- Begin//////////////////////
DRV_HANDLE genHandle;
USB_ERROR_STATUS err;
// open the Generic USB device driver instance 0 ( or what ever is applicable)
genHandle = USB_DEVICE_GEN_DRIVER_Open ( 0 );
err = USB_DEVICE_GEN_DRIVER_RegisterCallBack (genHandle,app_gen_CallBack );
if(err)
{
//handle error
}
///////////////// Generic function driver Setup- End//////////////////////
}
}
int main ()
{
5.9 USB Library Help MPLAB Harmony Help USB Generic Device Library
5-4109
// Device layer Init structure
USB_DEVICE_INIT deviceLayerInit;
// objects for Controller driver and device layer (returned by init routines)
SYS_MODULE_OBJ driverObjectHandle, usbDeviceObj;
// Client handle
DRV_HANDLE genHandle;
// Client handle for device layer
DRV_HANDLE usbDevHandle;
// USB controller driver init data
DRV_USB_INIT usbInitData;
///////////////// system initialization- Begin//////////////////////
// Populate USB Controller driver init data
usbInitData.usbID = USB_ID_1;
usbInitData.usbModuleSetup.OpMode = USB_OPMODE_DEVICE;
usbInitData.usbModuleSetup.ppMode = USB_PING_PONG_MODE_SELECTION;
usbInitData.usbModuleSetup.StopInIdle = false;
usbInitData.usbModuleSetup.SuspendInSleep = false;
// Initialize the USB Control driver
driverObjectHandle = DRV_USB_Initialize(DRV_USB_INDEX_0, (SYS_MODULE_INIT*)&usbInitData);
if (SYS_MODULE_OBJ_INVALID == driverObjectHandle)
{
// Handle error
}
// NOTE: USB controller driver is opened by both device layer and
// function driver and not by the application.
// Populate USB Device layer init data
deviceLayerInit.moduleInit.value = SYS_MODULE_POWER_RUN_FULL;
deviceLayerInit.usbDriverIndex = DRV_USB_INDEX_0;
deviceLayerInit.usbMasterDescriptor = (USB_MASTER_DESCRIPTOR*)&usbMasterDescriptor;
deviceLayerInit.registeredFuncCount = 1;
deviceLayerInit.registeredFunctions =
(USB_DEVICE_FUNC_REGISTRATION_TABLE*)funcRegistrationTable;
// Initialize the USB device layer
usbDeviceObj = USB_DEVICE_Initialize( USB_DEVICE_INDEX_0, (SYS_MODULE_INIT*)&deviceLayerInit
);
// Open the device layer.
usbDevHandle = USB_DEVICE_Open( USB_DEVICE_INDEX_0 );
// Register a callback with device layer to get event notification (for end point 0)
USB_DEVICE_EventCallBackSet(usbDevHandle, usbDeviceEventCallBack);
///////////////// system initialization- End//////////////////////
// the application body
while(1)
{
// Device layer task
USB_DEVICE_Tasks(usbDeviceObj);
// Check if the enumeration is complete
if(isConfigured)
{
// Start calling application tasks
}
}
5.9 USB Library Help MPLAB Harmony Help USB Generic Device Library
5-4110
return 0;
}
5.9.5.5.4 Client Data Handling
The USB Generic function driver provides APIs to handle data to/from the host. The following section provides the usage of
these APIs.
The data transfer in the Generic function driver happens over the end points with all the type of transfer modes (BULK,
ISOCHRONOUS, INTERRUPT) at both direction of IN and OUT.
The following sections focus on the data transmission over the end points .
The read and write naming conventions used for the data handling APIs are from the device point of view. So
USB_DEVICE_GEN_DRIVER_ReadEp function is a request to the MPLAB Harmony USB Device library to get data available
from the host. Similarly USB_DEVICE_GEN_DRIVER_WriteEp function is a request to make data available to the host.
Generic USB Buffer Objects:
In order place a read/write request with the Generic function driver the application should first create a buffer object of the type
USB_DEVICE_GEN_DRIVER_DATA_BUFFER_OBJECT. It is recommended to create separate buffer objects for read and
write operations. A USB_DEVICE_GEN_DRIVER_DATA_BUFFER_OBJECT contains a pointer to the data buffer, length of the
buffer and transfer count. The transfer count is updated by the Generic function driver (after the read/write request is submitted)
to indicate the actual amount of data transferred to/from the host.
Example: Generic USB DATA Buffer Object Creation
// buffer for read operation of size 64 bytes
uint8_t inBuffer[64];
// define and initialize the buffer object
USB_DEVICE_GEN_DRIVER_DATA_BUFFER_OBJECT inBufferObject = {(uint8_t*)&inBuffer, 64, 0};
Read From the Host:
As explained above the application should make use of the API USB_DEVICE_GEN_DRIVER_ReadEp to get data from the
host. Before placing a read request with the Generic function driver the application should get the pipeHandle using
USB_DEVICE_GEN_DRIVER_GetPipeHandle . If the received is valid , applicatio has to check if it can place the next read
request. This status can be obtained using the API USB_DEVICE_GEN_DRIVER_TxRx_StatusGet. If this API returns
USB_DEVICE_GEN_DRIVER_INSTANCE_RX_READY then the application can place a request for a read operation. If the
received status is anything else then the application should poll until the receive status is ready. The following example shows
the usage of read request.
Example: Data Read Request
#define APP_USB_DEVICE_GEN_DRIVER_FUNC_INDEX 0
// create buffer
uint8_t outBuffer[64];
uint8_t datalen = 64;
uint8_t epNum = 1;
dirn = USB_DEVICE_GEN_DRIVER_EP_IN_INDEX; //OUT:(0x00) or IN: 0x01)
DRV_HANDLE genHandle,pipeHandle;
USB_ERROR_STATUS genErr;
//create the buffer object with datalength 64
USB_DEVICE_GEN_DRIVER_DATA_BUFFER_OBJECT readBufferObject = {&outBuffer, 64, 0};
5.9 USB Library Help MPLAB Harmony Help USB Generic Device Library
5-4111
// open the Generic USB device driver instance 0 ( or what ever is applicable)
genHandle = USB_DEVICE_GEN_DRIVER_Open ( APP_USB_DEVICE_GEN_DRIVER_FUNC_INDEX );
if(USB_DEVICE_GEN_DRIVER_RegisterCallBack (genHandle,app_gen_CallBack ))
{
//handle error
}
//Get the pipe handle for the endpoint
pipeHandle = USB_DEVICE_GEN_DRIVER_GetPipeHandle(genHandle, epNum, dirn))
if ( DRV_HANDLE_INVALID == pipeHandle)
{
//The request was not successful
}
//Got the pipe handle for the endpoint
//Pass the pipe handle to USB_DEVICE_GEN_DRIVER_ReadEp
genErr = USB_DEVICE_GEN_DRIVER_ReadEp( pipeHandle,&readBufferObject);
if(USB_ERROR_OK != genErr)
{
//Read request is not accepted.
}
If the application has registered a callback function with the Generic function driver then any events related to the read request
will be informed to the application via this callback. In the callback the application can check whether all of the data requested is
received. The following example shows this.
Example: Data Read Request with application callback
#define APP_USB_DEVICE_GEN_DRIVER_FUNC_INDEX 0
// Application callback to handle relevant events.
void app_gen_CallBack ( SYS_MODULE_INDEX funcDriverIndex,
USB_DEVICE_GEN_DRIVER_CALLBACK_TYPE callback,
USB_DEVICE_GEN_DRIVER_CALLBACK_EVENT event)
{
switch (callback)
{
case USB_DEVICE_GEN_DRIVER_CALLBACK_TX:
break;
case USB_DEVICE_GEN_DRIVER_CALLBACK_RX:
if (readBufferObject.transferCount == readBufferObject.dataLen)
{
//entire data is read from the host.
}
else
{
//some of the data is not read.
//get some logic in place to handle this
}
break;
case USB_DEVICE_GEN_DRIVER_CALLBACK_MANAGEMENT:
break;
default:
break;
}
}
5.9 USB Library Help MPLAB Harmony Help USB Generic Device Library
5-4112
int main ()
{
// create buffer
uint8_t outBuffer[64];
uint8_t datalen = 64;
uint8_t epNum = 1;
dirn = USB_DEVICE_GEN_DRIVER_EP_OUT_INDEX; //OUT:(0x00) or IN: 0x01)
DRV_HANDLE genHandle;
USB_ERROR_STATUS genErr;
DRVHANDLE pipeHandle;
//create the buffer object with datalength 64
USB_DEVICE_GEN_DRIVER_DATA_BUFFER_OBJECT readBufferObject = {&outBuffer, 64, 0};
// open the Generic USB device driver instance 0 ( or what ever is applicable)
genHandle = USB_DEVICE_GEN_DRIVER_Open ( 0 );
if(USB_DEVICE_GEN_DRIVER_RegisterCallBack (genHandle,app_gen_CallBack ))
{
//handle error
}
//Get the pipe handle for the endpoint
pipeHandle = USB_DEVICE_GEN_DRIVER_GetPipeHandle(genHandle, epNum, dirn))
if ( DRV_HANDLE_INVALID == pipeHandle)
{
//The request was not successful
}
//we got the pipe handle for the endpoint
//Pass the pipe handle to USB_DEVICE_GEN_DRIVER_ReadEp
genErr = USB_DEVICE_GEN_DRIVER_ReadEp( pipeHandle,&readBufferObject);
if(USB_ERROR_OK == genErr)
{
//read request is accepted
//if app callback is registered, rest needs to be handled
//in the appcallback, which is called by the Generic USB device function
//driver when it is intimated by the device layer about
//the transfer.
}
else
{
// something wrong in the read request
// handle the error case
switch ( genErr )
{
case USB_ERROR_INVALID_HANDLE:
break;
case USB_ERROR_INVALID_BUFFER:
break;
case USB_ERROR_BUSY:
break;
}
}
return 0;
}
5.9 USB Library Help MPLAB Harmony Help USB Generic Device Library
5-4113
The read request code flow can be better understood with the following diagram.
5.9 USB Library Help MPLAB Harmony Help USB Generic Device Library
5-4114
5.9 USB Library Help MPLAB Harmony Help USB Generic Device Library
5-4115
Write to the Host:
The application should make use of the API USB_DEVICE_GEN_DRIVER_WriteEp to get transfer data to the host. Before
placing a write request with the Generic function driver the application should the application should get the pipeHandle using
USB_DEVICE_GEN_DRIVER_GetPipeHandle . If the received is valid , application has tocheck if it can place the next write
request. This status can be obtained using the API USB_DEVICE_GEN_DRIVER_TxRx_StatusGet. If this API returns
USB_DEVICE_GEN_DRIVER_INSTANCE_TX_READY then the application can place a request for a write operation. If the
received status is anything else then the application should poll until the transmit status is ready.The following example shows
the usage of read request.
Example: Data Read Request
#define APP_USB_DEVICE_GEN_DRIVER_FUNC_INDEX 0
// create buffer. Assuming data end-point max packet size is 64 bytes.
uint8_t inBuffer[64] ;
uint8_t datalen = 64;
uint8_t epNum = 1;
uint8_t dirn = USB_DEVICE_GEN_DRIVER_EP_IN_INDEX;// OUT :0x00 or IN : 0x01
DRV_HANDLE pipeHandle,genHandle;
//create the buffer object with datalength 64
USB_DEVICE_GEN_DRIVER_DATA_BUFFER_OBJECT writeBufferObject = {&inBuffer, 64, 0};
//open the Generic USB device driver instance 0 ( or what ever is applicable)
genHandle = USB_DEVICE_GEN_DRIVER_DRIVER_Open (APP_USB_DEVICE_GEN_DRIVER_FUNC_INDEX);
if(USB_DEVICE_GEN_DRIVER_DRIVER_RegisterCallBacks (genHandle,app_gen_CallBack ))
{
//handle error
}
//Get the pipe handle for the endpoint
pipeHandle = USB_DEVICE_GEN_DRIVER_GetPipeHandle(genHandle, epNum, dirn))
if ( DRV_HANDLE_INVALID == pipeHandle)
{
//The request was not successful.
}
//we got the pipe handle for the endpoint
//Pass the pipe handle to USB_DEVICE_GEN_DRIVER_WriteEp
genErr = USB_DEVICE_GEN_DRIVER_WriteEp( pipeHandle,&writeBufferObject);
if(USB_ERROR_OK != genErr)
{
//write request is not accepted
}
If the application has registered a callback function with the Generic function driver then any events related to the write request
will be informed to the application via this callback. In the callback the application can check whether all of the data requested is
transmitted. The following example shows this.
Example: Data Read Request with application callback
#define APP_USB_DEVICE_GEN_DRIVER_FUNC_INDEX 0
// Application callback to handle relevant events.
void app_gen_CallBack ( SYS_MODULE_INDEX funcDriverIndex,
USB_DEVICE_GEN_DRIVER_CALLBACK_TYPE callback,
USB_DEVICE_GEN_DRIVER_CALLBACK_EVENT event)
5.9 USB Library Help MPLAB Harmony Help USB Generic Device Library
5-4116
{
switch (callback)
{
case USB_DEVICE_GEN_DRIVER_CALLBACK_TX:
if (writeBufferObject.transferCount == writeBufferObject.dataLen)
{
//entire data is written to host.
}
else
{
//some of the data is not sent to the host.
//think and get some logic in place to handle this
}
break;
case USB_DEVICE_GEN_DRIVER_CALLBACK_RX:
break;
case USB_DEVICE_GEN_DRIVER_CALLBACK_MANAGEMENT:
break;
default:
break;
}
}
int main ()
{
// create buffer. Assuming data end-point max packet size is 64 bytes.
uint8_t inBuffer[64] ;
uint8_t datalen = 64;
uint8_t epNum = 1;
uint8_t dirn = USB_DEVICE_GEN_DRIVER_EP_OUT_INDEX;// OUT :0x00 or IN : 0x01
DRV_HANDLE pipeHandle,genHandle;
//create the buffer object with datalength 64
USB_DEVICE_GEN_DRIVER_DATA_BUFFER_OBJECT writeBufferObject = {&inBuffer, 64, 0};
//open the Generic USB device driver instance 0 ( or what ever is applicable)
genHandle = USB_DEVICE_GEN_DRIVER_DRIVER_Open ( 0 );
if(USB_DEVICE_GEN_DRIVER_DRIVER_RegisterCallBacks (genHandle,app_gen_CallBack ))
{
//handle error
}
//Get the pipe handle for the endpoint
pipeHandle = USB_DEVICE_GEN_DRIVER_GetPipeHandle(genHandle, epNum, dirn))
if ( DRV_HANDLE_INVALID == pipeHandle)
{
//The request was not successful.
}
//we got the pipe handle for the endpoint
//Pass the pipe handle to USB_DEVICE_GEN_DRIVER_WriteEp
genErr = USB_DEVICE_GEN_DRIVER_WriteEp( pipeHandle,&writeBufferObject);
if(USB_ERROR_OK != genErr)
{
//write request is not accepted
5.9 USB Library Help MPLAB Harmony Help USB Generic Device Library
5-4117
}
return 0;
}
The write request code flow can be better understood with the following diagram.
5.9 USB Library Help MPLAB Harmony Help USB Generic Device Library
5-4118
5.9 USB Library Help MPLAB Harmony Help USB Generic Device Library
5-4119
5.9.5.5.5 Client Subclass Specific
This section details the vendor specific sub-class specific requests and notifications handled by the Generic function driver.
5.9.5.6 Library Interface
Data Types and Constants
Name Description
USB_DEVICE_GENERIC_EVENT This is type
USB_DEVICE_GENERIC
_EVENT.
USB_DEVICE_GENERIC_EVENT_DATA Union that holds event
data for different generic
driver events.
USB_DEVICE_GENERIC_EVENT_DATA_CONTROL_TRANSFER_SETUP_REQUEST The data-type that holds
the event data
associated with
USB_DEVICE_GENERIC
_EVENT_DATA_CONTR
OL_TRANSFER_SETUP
_REQUEST
event.
USB_DEVICE_GENERIC_EVENT_DATA_ENDPOINT_READ_COMPLETE The data-type that holds
the event data
associated with
USB_DEVICE_GENERIC
_EVENT_ENDPOINT_R
EAD_COMPLETE
event.
USB_DEVICE_GENERIC_EVENT_DATA_ENDPOINT_WRITE_COMPLETE The data-type that holds
the event data
associated with
USB_DEVICE_GENERIC
_EVENT_ENDPOINT_W
RITE_COMPLETE
event.
USB_DEVICE_GENERIC_EVENT_HANDLER The data-type that
defines the signature of
the event callback
function.
USB_DEVICE_GENERIC_EVENT_RESPONSE The return type of the
application callback
function.
USB_DEVICE_GENERIC_INDEX Data-type for USB
device generic driver
index.
USB_DEVICE_GENERIC_RESULT The enumerated
data-type that idnetifies
the possible result of an
operation.
5.9 USB Library Help MPLAB Harmony Help USB Generic Device Library
5-4120
USB_DEVICE_GENERIC_TRANSFER_FLAG Enumerated data-type
that identifies the USB
device generic function
driver's transfer flag.
USB_DEVICE_GENERIC_TRANSFER_HANDLE Data-type of the generic
driver transfer handle.
Functions
Name Description
USB_DEVICE_GENERIC_EndpointIsEnabled This function returns true if the requested endpoint is enabled.
USB_DEVICE_GENERIC_EndpointRead Reads data received from host on the requested endpoint.
USB_DEVICE_GENERIC_EndpointStall This function stalls the requested endpoint.
USB_DEVICE_GENERIC_EndpointStallClear Clears STALL on the endpoint.
USB_DEVICE_GENERIC_EndpointStallStatusGet USB Generic function driver library function that returns true if
STALL is enabled on the endpoint.
USB_DEVICE_GENERIC_EndpointWrite This function allows the application client to transfer data from
device to host on the requested endpoint.
USB_DEVICE_GENERIC_EventHandlerSet This function allows the application client to register event
handler callback with the generic function driver library.
Description
This section describes the Application Programming Interface (API) functions of the USB Generic Device Library.
Refer to each section for a detailed description.
5.9.5.6.1 Functions
5.9.5.6.1.1 USB_DEVICE_GENERIC_EndpointIsEnabled Function
C
bool USB_DEVICE_GENERIC_EndpointIsEnabled(
USB_DEVICE_GENERIC_INDEX iGEN,
USB_ENDPOINT endpoint
);
Preconditions
USB device layer be initialized.
Parameters
Parameters Description
iGEN USB generic driver function driver instance ID.
endpoint endpoint address.
Returns
true if endpoint is enabled.
Remarks
None.
Example
5.9 USB Library Help MPLAB Harmony Help USB Generic Device Library
5-4121
5.9.5.6.1.2 USB_DEVICE_GENERIC_EndpointRead Function
C
USB_DEVICE_GENERIC_RESULT USB_DEVICE_GENERIC_EndpointRead(
USB_DEVICE_GENERIC_INDEX iGEN,
USB_DEVICE_GENERIC_TRANSFER_HANDLE * transferHandle,
USB_ENDPOINT endpoint,
uint8_t * buffer,
size_t bufferSize
);
Preconditions
USB device layer be initialized.
Parameters
Parameters Description
iGEN USB generic function driver instance ID.
transferHandle Pointer to transfer handle.
endpoint endpoint address
buffer Buffer pointer
bufferSize Buffer size
Returns
See USB_DEVICE_GENERIC_RESULT.
Remarks
None.
Example
5.9.5.6.1.3 USB_DEVICE_GENERIC_EndpointStall Function
C
USB_DEVICE_GENERIC_RESULT USB_DEVICE_GENERIC_EndpointStall(
USB_DEVICE_GENERIC_INDEX iGEN,
USB_ENDPOINT endpoint
);
Preconditions
USB device layer must be initialized.
Parameters
Parameters Description
iGEN USB device generic function driver instance ID.
endpoint Endpoint address.
Returns
See USB_DEVICE_GENERIC_RESULT
Remarks
None.
5.9 USB Library Help MPLAB Harmony Help USB Generic Device Library
5-4122
Example
5.9.5.6.1.4 USB_DEVICE_GENERIC_EndpointStallClear Function
C
USB_DEVICE_GENERIC_RESULT USB_DEVICE_GENERIC_EndpointStallClear(
USB_DEVICE_GENERIC_INDEX iGEN,
USB_ENDPOINT endpoint
);
Preconditions
USB device layer be initialized.
Parameters
Parameters Description
iGEN Generic driver instance index.
endpoint Endpoint address for which the stall has to be cleared.
Returns
See USB_DEVICE_GENERIC_RESULT.
Remarks
None.
Example
5.9.5.6.1.5 USB_DEVICE_GENERIC_EndpointStallStatusGet Function
C
bool USB_DEVICE_GENERIC_EndpointStallStatusGet(
USB_DEVICE_GENERIC_INDEX iGEN,
USB_ENDPOINT endpoint
);
Preconditions
USB device layer be initialized.
Parameters
Parameters Description
iGEN USB generic function driver instance ID.
endpoint endpoint address.
Returns
true if endpoint is stalled.
Remarks
None.
Example
5.9 USB Library Help MPLAB Harmony Help USB Generic Device Library
5-4123
5.9.5.6.1.6 USB_DEVICE_GENERIC_EndpointWrite Function
C
USB_DEVICE_GENERIC_RESULT USB_DEVICE_GENERIC_EndpointWrite(
USB_DEVICE_GENERIC_INDEX iGEN,
USB_DEVICE_GENERIC_TRANSFER_HANDLE * transferHandle,
USB_ENDPOINT endpoint,
uint8_t * buffer,
size_t bufferSize,
USB_DEVICE_GENERIC_TRANSFER_FLAG flags
);
Preconditions
USB device layer be initialized.
Parameters
Parameters Description
iGEN USB generic function driver instance ID.
transferHandle Pointer to transfer handle.
endpoint endpoint address
buffer Buffer pointer
bufferSize Buffer size
flags Flag that specifies this function whether to end the transfer with a short packet or
not.
Returns
See USB_DEVICE_GENERIC_RESULT.
Remarks
None.
Example
5.9.5.6.1.7 USB_DEVICE_GENERIC_EventHandlerSet Function
C
USB_DEVICE_GENERIC_RESULT USB_DEVICE_GENERIC_EventHandlerSet(
USB_DEVICE_GENERIC_INDEX iGEN,
USB_DEVICE_GENERIC_EVENT_HANDLER eventHandler,
uintptr_t userData
);
Preconditions
USB device layer be initialized.
Parameters
Parameters Description
instanceIndex USB Generic function driver instance ID.
eventHandler Pointer to application event handler callback function.
Returns
See USB_DEVICE_GENERIC_RESULT.
5.9 USB Library Help MPLAB Harmony Help USB Generic Device Library
5-4124
Remarks
None.
Example
5.9.5.6.2 Data Types and Constants
5.9.5.6.2.1 USB_DEVICE_GENERIC_EVENT Enumeration
C
typedef enum {
USB_DEVICE_GENERIC_EVENT_CONTROL_TRANSFER_SETUP_REQUEST,
USB_DEVICE_GENERIC_EVENT_CONTROL_TRANSFER_DATA_RECEIVED,
USB_DEVICE_GENERIC_EVENT_CONTROL_TRANSFER_DATA_SENT,
USB_DEVICE_GENERIC_EVENT_CONTROL_TRANSFER_ABORTED,
USB_DEVICE_GENERIC_EVENT_ENDPOINT_WRITE_COMPLETE,
USB_DEVICE_GENERIC_EVENT_ENDPOINT_READ_COMPLETE
} USB_DEVICE_GENERIC_EVENT;
Description
This is type USB_DEVICE_GENERIC_EVENT.
Members
Members Description
USB_DEVICE_GENERIC_EVENT_CONTROL_TRANSFER_SETUP_REQUEST Control transfer data stage is received from
host to device
USB_DEVICE_GENERIC_EVENT_CONTROL_TRANSFER_DATA_RECEIVED Control transfer data stage is received from
host to device
USB_DEVICE_GENERIC_EVENT_CONTROL_TRANSFER_DATA_SENT Control transfer data stage is transmitted
from device to host
5.9.5.6.2.2 USB_DEVICE_GENERIC_EVENT_DATA Union
C
typedef union {
USB_DEVICE_GENERIC_EVENT_DATA_ENDPOINT_WRITE_COMPLETE endpointWriteComplete;
USB_DEVICE_GENERIC_EVENT_DATA_ENDPOINT_READ_COMPLETE endpointReadComplete;
USB_DEVICE_GENERIC_EVENT_DATA_CONTROL_TRANSFER_SETUP_REQUEST * ptrSetupRequest;
} USB_DEVICE_GENERIC_EVENT_DATA;
Description
Event Data.
Members
Members Description
USB_DEVICE_GENERIC_EVENT_DATA_ENDPOINT_WRITE_COMPLETE
endpointWriteComplete;
Data associated with
USB_DEVICE_GENERIC_EVENT_E
NDPOINT_WRITE_COMPLETE
event
USB_DEVICE_GENERIC_EVENT_DATA_ENDPOINT_READ_COMPLETE
endpointReadComplete;
Data associated with
USB_DEVICE_GENERIC_EVENT_E
NDPOINT_READ_COMPLETE
event
5.9 USB Library Help MPLAB Harmony Help USB Generic Device Library
5-4125
USB_DEVICE_GENERIC_EVENT_DATA_CONTROL_TRANSFER_SETUP_REQUEST
* ptrSetupRequest;
Data associated with
USB_DEVICE_GENERIC_EVENT_D
ATACONTROL
Remarks
None.
5.9.5.6.2.3
USB_DEVICE_GENERIC_EVENT_DATA_CONTROL_TRANSFER_SETUP_REQUEST
Structure
C
typedef struct {
uint8_t bmRequestType;
uint8_t bRequest;
uint16_t wValue;
uint16_t wIndex;
uint16_t wLength;
} USB_DEVICE_GENERIC_EVENT_DATA_CONTROL_TRANSFER_SETUP_REQUEST;
Description
Data assocated with USB_DEVICE_GENERIC_EVENT_DATA_CONTROL_TRANSFER_SETUP_REQUEST event.
Members
Members Description
uint8_t bmRequestType; Format of setup packet from table 9-2 of USB 2.0 spec
Remarks
None.
5.9.5.6.2.4 USB_DEVICE_GENERIC_EVENT_DATA_ENDPOINT_READ_COMPLETE
Structure
C
typedef struct {
unsigned int dataSize;
uint8_t * data;
USB_DEVICE_IRP_STATUS status;
USB_DEVICE_GENERIC_TRANSFER_HANDLE transferHandle;
} USB_DEVICE_GENERIC_EVENT_DATA_ENDPOINT_READ_COMPLETE;
Description
Data assocated with USB_DEVICE_GENERIC_EVENT_ENDPOINT_READ_COMPLETE event.
Members
Members Description
unsigned int dataSize; data size received
uint8_t * data; Pointer to data buffer
USB_DEVICE_IRP_STATUS status; Status
USB_DEVICE_GENERIC_TRANSFER_HANDLE
transferHandle;
Transfer handle
Remarks
None.
5.9 USB Library Help MPLAB Harmony Help USB Generic Device Library
5-4126
5.9.5.6.2.5 USB_DEVICE_GENERIC_EVENT_DATA_ENDPOINT_WRITE_COMPLETE
Structure
C
typedef struct {
unsigned int dataSize;
uint8_t * data;
USB_DEVICE_IRP_STATUS status;
USB_DEVICE_GENERIC_TRANSFER_HANDLE transferHandle;
} USB_DEVICE_GENERIC_EVENT_DATA_ENDPOINT_WRITE_COMPLETE;
Description
Data assocated with USB_DEVICE_GENERIC_EVENT_ENDPOINT_WRITE_COMPLETE event.
Members
Members Description
unsigned int dataSize; data size transmitted
uint8_t * data; Pointer to data buffer
USB_DEVICE_IRP_STATUS status; Status
USB_DEVICE_GENERIC_TRANSFER_HANDLE
transferHandle;
Transfer handle
Remarks
None.
5.9.5.6.2.6 USB_DEVICE_GENERIC_EVENT_HANDLER Type
C
typedef USB_DEVICE_GENERIC_EVENT_RESPONSE (*
USB_DEVICE_GENERIC_EVENT_HANDLER)(USB_DEVICE_GENERIC_INDEX instanceIndex,
USB_DEVICE_CONTROL_TRANSFER_HANDLE controlTransferHandle, USB_DEVICE_GENERIC_EVENT event,
USB_DEVICE_GENERIC_EVENT_DATA * eventData, uintptr_t userData);
Description
USB device generic function driver event handle.
The application provided event callback function must be of this data-type.
Remarks
None.
5.9.5.6.2.7 USB_DEVICE_GENERIC_EVENT_RESPONSE Type
C
typedef void USB_DEVICE_GENERIC_EVENT_RESPONSE;
Description
Return type of the application callback function.
Remarks
Also see, USB_DEVICE_GENERIC_EVENT_HANDLER
5.9 USB Library Help MPLAB Harmony Help USB Generic Device Library
5-4127
5.9.5.6.2.8 USB_DEVICE_GENERIC_INDEX Type
C
typedef SYS_MODULE_INDEX USB_DEVICE_GENERIC_INDEX;
Description
Data-type for USB device generic driver index.
Remarks
None.
5.9.5.6.2.9 USB_DEVICE_GENERIC_RESULT Enumeration
C
typedef enum {
USB_DEVICE_GENERIC_RESULT_QUEUE_FULL,
USB_DEVICE_GENERIC_RESULT_OK,
USB_DEVICE_GENERIC_RESULT_ENDPOINT_NOT_CONFIGURED,
USB_DEVICE_GENERIC_RESULT_PARAMETER_INVALID
} USB_DEVICE_GENERIC_RESULT;
Description
Possible results of Generic Driver operations.
Members
Members Description
USB_DEVICE_GENERIC_RESULT_QUEUE_FULL Queue is full
USB_DEVICE_GENERIC_RESULT_OK No Error
USB_DEVICE_GENERIC_RESULT_ENDPOINT_NOT_CONFIGURED Endpoint not configured
USB_DEVICE_GENERIC_RESULT_PARAMETER_INVALID One or more parameter/s of the function is invalid
Remarks
None.
5.9.5.6.2.10 USB_DEVICE_GENERIC_TRANSFER_FLAG Enumeration
C
typedef enum {
USB_DEVICE_GENERIC_TRANSFER_FLAG_NONE,
USB_DEVICE_GENERIC_TRANSFER_FLAG_DATA_COMPLETE
} USB_DEVICE_GENERIC_TRANSFER_FLAG;
Description
USB device generic function driver transfer flags.
Members
Members Description
USB_DEVICE_GENERIC_TRANSFER_FLAG_NONE Transfer flag that specifies no special request
USB_DEVICE_GENERIC_TRANSFER_FLAG_DATA_COMPLETE Transfer flag that specifies the generic driver to complete
the transfer
Remarks
Also see, USB_DEVICE_GENERIC_EndpointWrite
5.9 USB Library Help MPLAB Harmony Help USB Generic Device Library
5-4128
5.9.5.6.2.11 USB_DEVICE_GENERIC_TRANSFER_HANDLE Type
C
typedef uintptr_t USB_DEVICE_GENERIC_TRANSFER_HANDLE;
Description
Generic driver transfer handle.
Remarks
Also see, USB_DEVICE_GENERIC_EndpointRead USB_DEVICE_GENERIC_EndpointWrite
5.9.5.7 Files
Files
Name Description
usb_device_generic.h Generic USB device function driver header
Description
5.9.5.7.1 usb_device_generic.h
Generic USB device function driver header file
Generic USB device function driver header file
Enumerations
Name Description
USB_DEVICE_GENERIC_EVENT This is type USB_DEVICE_GENERIC_EVENT.
USB_DEVICE_GENERIC_RESULT The enumerated data-type that idnetifies the possible result of an
operation.
USB_DEVICE_GENERIC_TRANSFER_FLAG Enumerated data-type that identifies the USB device generic
function driver's transfer flag.
Functions
Name Description
USB_DEVICE_GENERIC_EndpointIsEnabled This function returns true if the requested endpoint is enabled.
USB_DEVICE_GENERIC_EndpointRead Reads data received from host on the requested endpoint.
USB_DEVICE_GENERIC_EndpointStall This function stalls the requested endpoint.
USB_DEVICE_GENERIC_EndpointStallClear Clears STALL on the endpoint.
USB_DEVICE_GENERIC_EndpointStallStatusGet USB Generic function driver library function that returns true if
STALL is enabled on the endpoint.
USB_DEVICE_GENERIC_EndpointWrite This function allows the application client to transfer data from
device to host on the requested endpoint.
USB_DEVICE_GENERIC_EventHandlerSet This function allows the application client to register event
handler callback with the generic function driver library.
5.9 USB Library Help MPLAB Harmony Help USB Generic Device Library
5-4129
Structures
Name Description
USB_DEVICE_GENERIC_EVENT_DATA_CONTROL_TRANSFER_SETUP_REQUEST The data-type that holds
the event data
associated with
USB_DEVICE_GENERIC
_EVENT_DATA_CONTR
OL_TRANSFER_SETUP
_REQUEST
event.
USB_DEVICE_GENERIC_EVENT_DATA_ENDPOINT_READ_COMPLETE The data-type that holds
the event data
associated with
USB_DEVICE_GENERIC
_EVENT_ENDPOINT_R
EAD_COMPLETE
event.
USB_DEVICE_GENERIC_EVENT_DATA_ENDPOINT_WRITE_COMPLETE The data-type that holds
the event data
associated with
USB_DEVICE_GENERIC
_EVENT_ENDPOINT_W
RITE_COMPLETE
event.
Types
Name Description
USB_DEVICE_GENERIC_EVENT_HANDLER The data-type that defines the signature of the event callback
function.
USB_DEVICE_GENERIC_EVENT_RESPONSE The return type of the application callback function.
USB_DEVICE_GENERIC_INDEX Data-type for USB device generic driver index.
USB_DEVICE_GENERIC_TRANSFER_HANDLE Data-type of the generic driver transfer handle.
Unions
Name Description
USB_DEVICE_GENERIC_EVENT_DATA Union that holds event data for different generic driver events.
File Name
usb_device_generic.h
Company
Microchip Technology Inc.
5.9.6 USB HID Device Library
5.9 USB Library Help MPLAB Harmony Help USB HID Device Library
5-4130
5.9.6.1 Introduction
Introduces the MPLAB Harmony USB Device HID Library
Description
This library provides a high-level abstraction of the Human Interface Devices (HID) class under the Universal Serial Bus (USB)
communication with a convenient C language interface. This library supports revision 1.11 of the USB HID specification release
by the USB Implementers forum. This library is part of the MPLAB Harmony USB Device stack.
USB Human Interface Devices class (or USB HID) supports class of devices that are used by humans to control the operation of
computer systems. The HID class of devices include a wide variety of human interface, data indicator, data feedback devices
with various types of outputs directed to the end user. Some common examples of HID class devices include:
• Keyboards
• Pointing devices such as standard mouse, joysticks, trackballs
• Front-panel controls like knobs, switches, buttons, sliders
• Controls found on telephony, gaming or simulation devices like steering wheels, rudder pedals, dial pads
• Data devices such as bar-code scanners, thermometers, analyzers
The USB Device HID library ( also referred to as HID function driver in this document) offers services to the application to
interact and respond to the host requests. Additional information about the HID class can be obtained from the HID specification
available www.usbif.org.
5.9.6.2 Release Notes
MPLAB Harmony Version: v0.70b USB HID Device Library Version : 0.01 Alpha Release Date: 18Nov2013
New This Release:
This is the first release of the library. The interface can change in the beta and\or 1.0 release.
Known Issues:
Nothing to report in this release.
5.9.6.3 SW License Agreement
(c) 2013 Microchip Technology Inc.
Microchip licenses this software to you solely for use with Microchip products. The software is owned by Microchip and its
licensors, and is protected under applicable copyright laws. All rights reserved.
SOFTWARE IS PROVIDED "AS IS" MICROCHIP EXPRESSLY DISCLAIMS ANY WARRANTY OF ANY KIND, WHETHER
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. IN NO EVENT SHALL MICROCHIP BE LIABLE FOR
ANY INCIDENTAL, SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, HARM TO
YOUR EQUIPMENT, COST OF PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY OR SERVICES, ANY CLAIMS
BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), ANY CLAIMS FOR INDEMNITY OR
CONTRIBUTION, OR OTHER SIMILAR COSTS.
To the fullest extent allowed by law, Microchip and its licensors liability shall not exceed the amount of fees, if any, that you have
5.9 USB Library Help MPLAB Harmony Help USB HID Device Library
5-4131
paid directly to Microchip to use this software.
MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE TERMS.
5.9.6.4 Library Architecture
5.9.6.4.1 Architecture Overview
Provides an Architectural Overview of the HID Function Driver
Description
The HID Function Driver offers services to a USB HID device to communicate with the host by abstracting the HID specification
details. It must be used along with the USB Device layer and USB controller to communicate with the USB host. Figure 1 shows
a block diagram representation of the MPLAB Harmony USB Architecture and where the USB HID Function Driver is placed.
Figure 1: USB HID Function Driver
The HID function driver together with USB Device layer and USB controller driver forms the basic library entity through which a
HID device can communicate with the USB host. The USB controller driver takes the responsibility of managing the USB
peripheral on the device. The USB device layer handles the device enumeration etc. The USB Device layer forwards all HID
specific control transfers to the HID Function Driver. The HID Function Driver interprets the control transfers and requests
application's intervention through event handlers and well defined set of API. The application must register a event handler with
the HID function driver in the Device Layer Set Configuration Event. While the application must respond to the HID function
driver events, it can do this either in the event handler or out of it. The application interacts with HID Function Driver routines to
send and receive HID reports over the USB.
5.9 USB Library Help MPLAB Harmony Help USB HID Device Library
5-4132
Figure 2 : Architecture of the HID function driver.
Figure 2 shows the architecture of the HID function Driver. The function driver maintains the state of each instance. It receives
HID class specific control transfers from the Device Layer. Class specific control transfers that require application response are
forwarded to the application as function driver events. Depending on the type of device, the HID function driver can use the
control endpoint and/or interrupt endpoints for data transfers. The HID device exchanges data with host through data objects
called reports. The report data format is described by the HID report descriptor which is provided to the host when requested.
Refer to the HID specification available www.usb.org for more details on the USB HID device class and how reports descriptors
can be created. The HID function driver allows report descriptors to be specified for every instance. This allow the application to
implement a composite HID device.
5.9.6.5 Using the Library
5.9.6.5.1 Files to Include
Describes which files to include in project while using the HID Function Driver
Description
Table 1 shows the files that must be included in the project in order to use the HID Function Driver. These files are located in the
5.9 USB Library Help MPLAB Harmony Help USB HID Device Library
5-4133
framework folder of the MPLAB Harmony installation. It is assumed that the Device Layer files ( and the files needed by the
Device Layer) are already included in the project.
Filename Description
\framework\usb\src\dynamic\usb_device_hid.c Contains the HID Control Interface and Data Interface management routines
\framework\usb\usb_device_hid.h Must included in every source file that needs to invoke HID function driver API.
system_config.h User created file which contains the HID function driver configuration.
Table 1: Files to be included in USB CDC Device Project.
5.9.6.5.2 Library Configuration
Describes how to configure the HID Function Driver
Description
The following configuration parameters must be defined while using the HID Function Driver. The configuration macros that
implement these parameters must be located in the system_config.h file in the application project and a compiler include path (to
point to the folder that contains this file) should be specified.
Configuration Macro Name Description Comments
USB_DEVICE_HID_MAX_INSTANCES Number of
HID
Function
Driver
Instances
in the
application
This macro defines the number of instances of the HID Function Driver.
For example, if the application needs to implement two instances of the
HID Function Driver (for example to create a mouse + keyboard device)
on one USB Device, the macro
USB_DEVICE_HID_INSTANCES_NUMBER should be set to 2. Note
that implementing a USB Device that features multiple HID interfaces
requires appropriate USB configuration descriptors.
USB_DEVICE_HID_QUEUE_SIZE HID
Function
Driver
Buffer
Queue
Combined
size
This macro defines the number of entries in all queues in all instances
of the HID function driver. This value can be obtained by adding up the
read and write queue sizes of each HID Function driver instance. In a
simple single instance USB HID device application, that does not
require buffer queuing , the
USB_DEVICE_HID_QUEUE_DEPTH_COMBINED macro can be set to
2. Consider a case with two HIDfunction driver instances, CDC 1 has a
read queue size of 2 and write queue size of 3, HID 2 has a read queue
size of 4 and write queue size of 1, this macro should be set to 10 (2 +3
+ 4 + 1).
5.9.6.5.3 Library Initialization
Describes how the HID Function Driver is initialized.
Description
The HID function driver instance for a USB device configuration is initialized by the Device Layer when the configuration is set by
the host. This process does not require application intervention. Each instance of the HID function driver should be registered
with the Device layer through the Device Layer Function Driver Registration Table. The HID function driver requires a
initialization data structure that contains details about the report descriptor associated with the specific instance of the HID
function driver. The hidFuncDriver object is a global object provided by the HID function driver and points to the HID function
driver - Device Layer interface functions which are required by the Device Layer. The code snippet below shows an example of
how a HID function driver instance (implementing a USB HID Mouse) can be registered with the Device Layer.
5.9 USB Library Help MPLAB Harmony Help USB HID Device Library
5-4134
/* This code snippet shows an example of registering a HID function driver
* with the Device Layer. While registering the function driver, an initialization
* data structure must be specified. In this example, hidInit is the HID function
* driver initialization data structure. */
/* This hid_rpt01 report descriptor describes a 3 button 2
* axis mouse pointing device */
const uint8_t hid_rpt01[]=
{
0x06, 0x00, 0xFF, // Usage Page = 0xFF00 (Vendor Defined Page 1)
0x09, 0x01, // Usage (Vendor Usage 1)
0xA1, 0x01, // Collection (Application)
0x19, 0x01, // Usage Minimum
0x29, 0x40, // Usage Maximum //64 input usages total (0x01 to 0x40)
0x15, 0x01, // Logical Minimum (data bytes in the report may have minimum value =
0x00)
0x25, 0x40, // Logical Maximum (data bytes in the report may have maximum value =
0x00FF = unsigned 255)
0x75, 0x08, // Report Size: 8-bit field size
0x95, 0x40, // Report Count: Make sixty-four 8-bit fields (the next time the
parser hits an "Input", "Output", or "Feature" item)
0x81, 0x00, // Input (Data, Array, Abs): Instantiates input packet fields based
on the above report size, count, logical min/max, and usage.
0x19, 0x01, // Usage Minimum
0x29, 0x40, // Usage Maximum //64 output usages total (0x01 to 0x40)
0x91, 0x00, // Output (Data, Array, Abs): Instantiates output packet fields.
Uses same report size and count as "Input" fields, since
nothing // new or different was specified to the
parser since the "Input" item.
0xC0 // End Collection
};
/* HID Function Driver Initialization data structure. This
* contains the size of the report descriptor and a pointer
* to the report descriptor. If there are multiple HID instances
* each with different report descriptors, then multiple such data
* structures may be needed */
USB_DEVICE_HID_INITIALIZATION hidInit =
{
sizeof(hid_rpt01),
(uint8_t *)&hid_rpt01
};
/* The HID function driver instance is now registered with
* device layer through the function driver registration
* table. */
const USB_DEVICE_FUNC_REGISTRATION_TABLE funcRegistrationTable[1] =
{
{
.speed = USB_SPEED_FULL|USB_SPEED_HIGH, // Supported speed
.configurationValue = 1, // To be initialized for Configuration 1
.interfaceNumber = 0, // Starting interface number
.numberOfInterfaces = 1, // Number of Interfaces
.funcDriverIndex = 0, // Function Driver instance index is 0
.funcDriverInit = &hidInit, // Function Driver Initialization
.driver = &hidFuncDriver // Pointer to the function driver - Device
Layer Interface functions
}
};
5.9.6.5.4 Event Handling
Describes HID function driver event handler registration and event handling.
5.9 USB Library Help MPLAB Harmony Help USB HID Device Library
5-4135
Description
Registering a HID Function Driver Event Handler:
While creating USB HID Device based application, an event handler must be registered with the Device Layer (the Device Layer
Event Handler) and every HID function driver instance (HID Function Driver Event Handler). The HID function driver event
handler receives HID events. This event handler should be registered before the USB device layer acknowledges the SET
CONFIGURATION request from the USB Host. In order to ensure this, the event handler should be set in the
USB_DEVICE_EVENT_CONFIGURED event that is generated by the device layer. While registering the HID function driver
event handler, the HID function driver allows the application to also pass a data object in the event handler register function. This
data object gets associated with the instance of the HID function driver and is returned by the HID function driver when a HID
function driver event occurs. The code example below shows an example of how this can be done.
/* This a sample Application Device Layer Event Handler
* Note how the HID Function Driver event handler APP_USBDeviceHIDEventHandler()
* is registered in the USB_DEVICE_EVENT_CONFIGURED event. The appData
* object that is passed in the USB_DEVICE_HID_EventHandlerSet()
* function will be returned as the userData parameter in the
* when the APP_USBDeviceHIDEventHandler() function is invoked */
void APP_USBDeviceEventCallBack ( USB_DEVICE_EVENT event,
USB_DEVICE_EVENT_DATA * eventData )
{
switch ( event )
{
case USB_DEVICE_EVENT_RESET:
case USB_DEVICE_EVENT_DECONFIGURED:
// USB device is reset or device is deconfigured.
// This means that USB device layer is about to deininitialize
// all function drivers.
break;
case USB_DEVICE_EVENT_CONFIGURED:
/* check the configuration */
if ( eventData->eventConfigured.configurationValue == 1)
{
/* Register the HID Device application event handler here.
* Note how the appData object pointer is passed as the
* user data */
USB_DEVICE_HID_EventHandlerSet(USB_DEVICE_HID_INDEX_0,
APP_USBDeviceHIDEventHandler, (uintptr_t)&appData);
/* mark that set configuration is complete */
appData.isConfigured = true;
}
break;
case USB_DEVICE_EVENT_SUSPENDED:
break;
case USB_DEVICE_EVENT_RESUMED:
case USB_DEVICE_EVENT_ATTACHED:
case USB_DEVICE_EVENT_DETACHED:
case USB_DEVICE_EVENT_ERROR:
default:
break;
}
5.9 USB Library Help MPLAB Harmony Help USB HID Device Library
5-4136
}
HID Function Driver Events:
The HID Function Driver generates events that the application must respond to. Some of these events are control requests
communicated through control transfers. The application must therefore complete the control transfer. Based on the generated
event, the application may be required to:
• Respond with a USB_DEVICE_ControlSend() function which completes the data stage of a Control Read Transfer.
• Respond with a USB_DEVICE_ControlReceive() function which provisions the data stage of a Control Write Transfer.
• Respond with a USB_DEVICE_ControlStatus() function which completes the handshake stage of the Control Transfer. The
application can either STALL or Acknowledge the handshake stage via the USB_DEVICE_ControlStatus() function.
• Analyze the pData member of the event handler and check for event specific data.
The possible HID Function Driver events are described here along with the required application response, event specific data
and likely follow up function driver event:
1. USB_DEVICE_HID_EVENT_CONTROL_GET_REPORT
Application Response: This event is generated when the HID host is requesting for a report over the control interface. The
application must provide the report by calling the USB_DEVICE_ControlSend() function either in the event handler or in the
application (outside of the event handler function). The application must use the controlTransferHandle parameter provided in
the event while calling USB_DEVICE_ControlSend() function. The application can use the
USB_DEVICE_HID_EVENT_CONTROL_TRANSFER_DATA_SENT event to track completion of the command.
Event Specific Data (eventData): The getReport member of the eventData data structure will contain the details about the
requested report.
Likely Follow-up event: This event will likely be followed by the
USB_DEVICE_HID_EVENT_CONTROL_TRANSFER_DATA_SENT event. This indicates that the data was sent to the host
successfully. The application must acknowledge the handshake stage of the control transfer by calling
USB_DEVICE_ControlStatus() function with the USB_DEVICE_CONTROL_STATUS_SEND_ZLP flag.
2. USB_DEVICE_HID_EVENT_CONTROL_SET_REPORT
Application Response: This event is generated when the HID host wants to send a report over the control interface. The
application must provide a buffer to receive the report by calling the USB_DEVICE_ControlReceive() function either in the event
handler or in the application (outside of the event handler function). The application must use the controlTransferHandle
parameter provided in the event while calling USB_DEVICE_ControlReceive() function. The application can use the
USB_DEVICE_HID_EVENT_CONTROL_TRANSFER_DATA_RECEIVED event to track completion of the command.
Event Specific Data (eventData): The setReport member of the eventData data structure will contain the details about the report
that the host intends to send.
Likely Follow-up event: This event will likely be followed by the
USB_DEVICE_HID_EVENT_CONTROL_TRANSFER_DATA_RECEIVED event. This indicates that the data was received
successfully. The application must either acknowledge or stall the handshake stage of the control transfer by calling
USB_DEVICE_ControlStatus() function with USB_DEVICE_CONTROL_STATUS_SEND_ZLP or
USB_DEVICE_CONTROL_STATUS_STALL flag respectively.
3. USB_DEVICE_HID_EVENT_CONTROL_GET_IDLE
Application Response: This event is generated when the HID host wants to read the current idle rate for the specified report. The
application must provide the idle rate through the USB_DEVICE_ControlSend() function either in the event handler or in the
application (outside of the event handler function). The application must use the controlTransferHandle parameter provided in
the event while calling USB_DEVICE_ControlSend() function. The application can use the
USB_DEVICE_HID_EVENT_CONTROL_TRANSFER_DATA_SENT event to track completion of the command.
5.9 USB Library Help MPLAB Harmony Help USB HID Device Library
5-4137
Event Specific Data (eventData): The getIdle member of the eventData data structure will contain the details about the report for
which the idle rate is requested.
Likely Follow-up event: This event will likely be followed by the
USB_DEVICE_HID_EVENT_CONTROL_TRANSFER_DATA_SENT event. This indicates that the data was sent to the host
successfully. The application must acknowledge the handshake stage of the control transfer by calling
USB_DEVICE_ControlStatus() function with the USB_DEVICE_CONTROL_STATUS_SEND_ZLP flag.
4. USB_DEVICE_HID_EVENT_CONTROL_SET_IDLE
Application Response: This event is generated when the HID host sends a Set Idle request to the device . The application must
inspect the eventData and determine if the idle rate is to be supported. The application must either acknowledge (if the idle rate
is supported) or stall the handshake stage of the control transfer (if the idle rate is not supported) by calling
USB_DEVICE_ControlStatus() function with USB_DEVICE_CONTROL_STATUS_SEND_ZLP or
USB_DEVICE_CONTROL_STATUS_STALL flag respectively.
Event Specific Data (eventData): The setIdle member of the eventData data structure will contain the details about the report for
which the idle rate should be set and the idle duration.
Likely Follow-up event: None.
5. USB_DEVICE_HID_EVENT_CONTROL_SET_PROTOCOL
Application Response: This event is generated when the HID host sends a Set Protocol request to the device . The application
must inspect the eventData and determine if the protocol is to be supported. The application must either acknowledge (if the
protocol is supported) or stall the handshake stage of the control transfer (if the protocol is not supported) by calling
USB_DEVICE_ControlStatus() function with USB_DEVICE_CONTROL_STATUS_SEND_ZLP or
USB_DEVICE_CONTROL_STATUS_STALL flag respectively.
Event Specific Data (eventData): The setProtocol member of the eventData data structure will contain the details about the
protocol to switch to.
Likely Follow-up event: None.
6. USB_DEVICE_HID_EVENT_CONTROL_GET_PROTOCOL
Application Response: This event is generated when the HID host issues a Get Protocol Request. The application must provide
the current protocol through the USB_DEVICE_ControlSend() function either in the event handler or in the application (outside of
the event handler function). The application must use the controlTransferHandle parameter provided in the event while calling
USB_DEVICE_ControlSend() function. The application can use the
USB_DEVICE_HID_EVENT_CONTROL_TRANSFER_DATA_SENT event to track completion of the command.
Event Specific Data (eventData): None.
Likely Follow-up event: This event will likely be followed by the
USB_DEVICE_HID_EVENT_CONTROL_TRANSFER_DATA_SENT event. This indicates that the data was sent to the host
successfully. The application must acknowledge the handshake stage of the control transfer by calling
USB_DEVICE_ControlStatus() function with the USB_DEVICE_CONTROL_STATUS_SEND_ZLP flag.
7. USB_DEVICE_HID_EVENT_CONTROL_SET_DESCRIPTOR
Application Response: This event is generated when the HID host issues a Set Descriptor request. The application must provide
a buffer to receive the descriptor through the USB_DEVICE_ControlReceive() function either in the event handler or in the
application (outside of the event handler function). The application must use the controlTransferHandle parameter provided in
the event while calling USB_DEVICE_ControlReceive() function. The application can use the
USB_DEVICE_HID_EVENT_CONTROL_TRANSFER_DATA_RECEIVED event to track completion of the command.
Event Specific Data: None
5.9 USB Library Help MPLAB Harmony Help USB HID Device Library
5-4138
Likely Follow-up event: This event will likely be followed by the
USB_DEVICE_HID_EVENT_CONTROL_TRANSFER_DATA_RECEIVED event. This indicates that the data was received
successfully. The application must either acknowledge or stall the handshake stage of the control transfer by calling
USB_DEVICE_ControlStatus() function with USB_DEVICE_CONTROL_STATUS_SEND_ZLP or
USB_DEVICE_CONTROL_STATUS_STALL flag respectively.
8. USB_DEVICE_HID_EVENT_REPORT_SENT
Application Response: This event occurs when a report send operation scheduled by calling the
USB_DEVICE_HID_ReportSend() function has completed. This event does not require the application to respond with any
function calls..
Event Specific Data (pData): The reportSent member of the eventData data structure will contains details about the report send
operation.
Likely Follow-up event: None.
9. USB_DEVICE_HID_EVENT_REPORT_RECEIVED
Application Response: This event occurs when a report receive operation scheduled by calling the
USB_DEVICE_HID_ReportReceive() function has completed. This event does not require the application to respond with any
function calls..
Event Specific Data (pData): The reportReceived member of the eventData data structure will contains details about the report
receive operation.
Likely Follow-up event: None
10. USB_DEVICE_HID_EVENT_CONTROL_TRANSFER_DATA_SENT
Application Response: This event occurs when the data stage of a control read transfer has completed in response to the
USB_DEVICE_ControlSend() function. The application must acknowledge the handshake stage of the control transfer by calling
USB_DEVICE_ControlStatus() function with USB_DEVICE_CONTROL_STATUS_SEND_ZLP flag.
Event Specific Data (pData): None.
Likely Follow-up event: None.
11. USB_DEVICE_HID_EVENT_CONTROL_TRANSFER_DATA_RECEIVED
Application Response: This event occurs when the data stage of a control write transfer has completed in response to the
USB_DEVICE_ControlReceive() function. The application must either acknowledge or stall the handshake stage of the control
transfer by calling USB_DEVICE_ControlStatus() function with USB_DEVICE_CONTROL_STATUS_SEND_ZLP or
USB_DEVICE_CONTROL_STATUS_STALL flag respectively.
Event Specific Data (pData): None
Likely Follow-up event: None.
12. USB_DEVICE_HID_EVENT_CONTROL_TRANSFER_ABORTED
Application Response: This event occurs when the a control transfer request is aborted by the host. The application can use this
event to update its HID class specific control transfer state machine.
Event Specific Data (pData): None
Likely Follow-up event: None.
5.9.6.5.5 Sending a Report
Describes how to send a report.
5.9 USB Library Help MPLAB Harmony Help USB HID Device Library
5-4139
Description
The USB HID device sends data to the HID host as reports. The HID device application should use the
USB_DEVICE_HID_ReportSend() function to send the report. This function returns a transfer handler that allows the application
to track the read request. The request is completed when the host as requested for the data. A report send request could fail if
the function driver instance transfer queue is full. The completion of the write transfer is indicated by
USB_DEVICE_HID_EVENT_REPORT_SENT event. The transfer handle and the amount of data sent is returned in the
reportSent member of the eventData data structure along with the event.
The following code snippet shows an example of how USB HID Mouse application sends a report to the host.
/* In this code example, the application uses the
* USB_HID_MOUSE_ReportCreate to create the mouse report
* and then uses the USB_DEVICE_HID_ReportSend() function
* to send the report */
USB_HID_MOUSE_ReportCreate(appData.xCoordinate, appData.yCoordinate,
appData.mouseButton, &appData.mouseReport);
/* Send the mouse report. */
USB_DEVICE_HID_ReportSend(appData.hidInstance,
&appData.reportTransferHandle, (uint8_t*)&appData.mouseReport,
sizeof(USB_HID_MOUSE_REPORT));
5.9.6.5.6 Receiving a Report
Describes how to receive a report
Description
The application can receive a report from the host by using the USB_DEVICE_HID_ReportReceive() function. This function
returns a transfer handler that allows the application to track the read request. The request is completed when the host sends the
report. The application must make sure that it allocates a buffer size that is at least the size of the report. The return value of the
function indicates the success of the request. A read request could fail if the function driver transfer queue is full. The completion
of the read transfer is USB_DEVICE_HID_EVENT_REPORT_RECEIVED event. The reportReceived member of the eventData
data structure contains details about the received report. The following code snippet shows an example of how a USB HID
Keyboard can schedule a receive report operation to get the keyboard LED status.
/* The following code snippet shows how the
* USB HID Keyboard application schedules a
* receive report operation to receive the
* keyboard output report from the host. This
* report contains the keyboard LED status. The
* size of the report is 1 byte */
result = USB_DEVICE_HID_ReportReceive(appData.hidInstance,
&appData.receiveTransferHandle,
(uint8_t *)&appData.keyboardOutputReport,1);
if(USB_DEVICE_HID_RESULT_OK != result)
{
/* Do error handling here */
}
5.9 USB Library Help MPLAB Harmony Help USB HID Device Library
5-4140
5.9.6.6 Library Interface
Data Types and Constants
Name Description
USB_DEVICE_HID_CONTROL_STATUS USB Device HID Function Driver Control Transfer
Status
USB_DEVICE_HID_CONTROL_TRANSFER_HANDLE USB Device HID Function Driver Control Transfer
Handle
USB_DEVICE_HID_EVENT USB Device HID Function Driver Events
USB_DEVICE_HID_EVENT_DATA_GET_IDLE USB Device HID Get Idle Event Data Type.
USB_DEVICE_HID_EVENT_DATA_GET_PROTOCOL USB Device HID Get Protocol Event Data Type.
USB_DEVICE_HID_EVENT_DATA_GET_REPORT USB Device HID Get Report Event Data Type.
USB_DEVICE_HID_EVENT_DATA_REPORT_RECEIVED USB Device HID Report Received Event Data Type.
USB_DEVICE_HID_EVENT_DATA_REPORT_SENT USB Device HID Report Sent Event Data Type.
USB_DEVICE_HID_EVENT_DATA_SET_DESCRIPTOR USB Device HID Set Descriptor Event Data Type.
USB_DEVICE_HID_EVENT_DATA_SET_IDLE USB Device HID Set Idle Event Data Type.
USB_DEVICE_HID_EVENT_DATA_SET_PROTOCOL USB Device HID Set Protocol Event Data Type.
USB_DEVICE_HID_EVENT_DATA_SET_REPORT USB Device HID Set Report Event Data Type.
USB_DEVICE_HID_EVENT_HANDLER USB Device HID Event Handler Function Pointer Type.
USB_DEVICE_HID_EVENT_RESPONSE USB Device HID Function Driver Event Callback
Response Type
USB_DEVICE_HID_INDEX USB device HID Function Driver Index.
USB_DEVICE_HID_INIT USB Device HID Function Driver Initialization Data
Structure
USB_DEVICE_HID_RESULT USB Device HID Function Driver USB Device HID
Result enumeration.
USB_DEVICE_HID_TRANSFER_HANDLE USB Device HID Function Driver Transfer Handle
Definition.
USB_DEVICE_HID_EVENT_RESPONSE_NONE USB Device HID Function Driver Event Handler
Response Type None.
USB_DEVICE_HID_INSTANCES_NUMBER Specifies the number of HID instances.
USB_DEVICE_HID_QUEUE_DEPTH_COMINED DOM-IGONORE-BEGIN
USB_DEVICE_HID_TRANSFER_HANDLE_INVALID USB Device HID Function Driver Invalid Transfer
Handle Definition.
Functions
Name Description
USB_DEVICE_HID_ControlReceive This function allows the application to respond to the HID function driver
specific control transfer requests. It allows the application to receive data
from the host in the data stage of the control transfer.
USB_DEVICE_HID_ControlSend This function allows the application to respond to the HID function driver
specific control transfer requests. It allows the application to send data to
the host in the data stage of the control transfer.
USB_DEVICE_HID_ControlStatus This function allows the application to complete the status stage of the the
HID Function Driver specific control transfer request.
USB_DEVICE_HID_EventHandlerSet This function registers a event handler for the specified HID function driver
instance.
5.9 USB Library Help MPLAB Harmony Help USB HID Device Library
5-4141
USB_DEVICE_HID_ReportReceive This function submits the buffer to HID function driver library to receive a
report from host to device.
USB_DEVICE_HID_ReportSend This function submits the buffer to HID function driver library to send a
report from device to host.
Description
This section describes the Application Programming Interface (API) functions of the USB Device HID library.
Refer to each section for a detailed description.
5.9.6.6.1 Functions
5.9.6.6.1.1 USB_DEVICE_HID_ControlReceive Function
C
USB_DEVICE_HID_RESULT USB_DEVICE_HID_ControlReceive(
USB_DEVICE_HID_INDEX instanceIndex,
USB_DEVICE_HID_CONTROL_TRANSFER_HANDLE controlTransferHandle,
void * data,
size_t size
);
Description
This function allows the application to respond to the HID function driver specific control transfer requests. It allows the
application to receive data from the host in the data stage of the control transfer. For example, the
USB_DEVICE_HID_EVENT_DATA_SET_REPORT event requires a control transfer response. The function can be called in the
HID Function Driver event handler or can be called outside the event handler. Calling this function outside the event handler
defers the response to the event. This allows the application to prepare the data buffer out of the event handler context,
especially if the data buffer to receive the daya is not readily available. Note however, that there are timing considerations when
responding to the control transfer. Exceeding the response time will cause the host to cancel the control transfer and may cause
USB host to reject the device. The application must use the control transfer handle that was generated along with the event as
the controlTransferHandle.
Preconditions
This function should only be called in response to a HID function driver event that requires a control transfer response.
Parameters
Parameters Description
instance USB Device HID Function Driver instance.
controlTransferHandle Control Transfer handle for the control transfer.
data Data buffer to receive the data stage of the control transfer.
size size (in bytes) of the data to sent.
Returns
USB_DEVICE_HID_RESULT_ERROR_CONTROL_TRANSFER_FAILED - The request was not successful because the USB
host cancelled the control transfer.
USB_DEVICE_HID_RESULT_OK - The request was successful.
Remarks
None.
5.9 USB Library Help MPLAB Harmony Help USB HID Device Library
5-4142
Example
// ------------------------------------------------------------------
// In this example, the application responds to the SET REPORT command with
// in the event handler. The application uses the
// USB_DEVICE_HID_ControlReceive() function to do this.
// ------------------------------------------------------------------
USB_DEVICE_HID_EVENT_DATA_SET_REPORT * setReportEventData;
USB_DEVICE_HID_CONTROL_TRANSFER_HANDLE controlTransferHandle;
uint8_t someReport[128];
USB_DEVICE_HID_EVENT_RESPONSE USBDeviceHIDEventHandler
(
USB_DEVICE_HID_INDEX instanceIndex,
USB_DEVICE_HID_EVENT event,
USB_DEVICE_HID_CONTROL_TRANSFER_HANDLE controlTransferHandle,
void * pData,
uintptr_t userData
)
{
switch(event)
{
case USB_DEVICE_HID_EVENT_SET_REPORT:
// In this case, the application should receive the report
// data from the host. The application must use the
// USB_DEVICE_HID_ControlReceive() function to receive the data.
setReportEventData = (USB_DEVICE_HID_EVENT_DATA_SET_REPORT *) pData;
USB_DEVICE_HID_ControlReceive(instanceIndex, controlTransferHandle
someReport, setReportEventData->reportSize);
break;
}
}
// --------------------------------------------------------------------
// In this example, the application defers the response to the
// event. This is done by calling the USB_DEVICE_HID_ControlReceive()
// function out side the event handler.
// --------------------------------------------------------------------
USB_DEVICE_HID_EVENT_DATA_SET_REPORT setReportEventData;
USB_DEVICE_HID_CONTROL_TRANSFER_HANDLE thisControlTransferHandle;
bool receiveReportFromHost;
uint8_t * someReport;
USB_DEVICE_HID_EVENT_RESPONSE USBDeviceHIDEventHandler
(
USB_DEVICE_HID_INDEX instanceIndex,
USB_DEVICE_HID_EVENT event,
USB_DEVICE_HID_CONTROL_TRANSFER_HANDLE controlTransferHandle,
void * pData,
uintptr_t userData
)
{
switch(event)
{
case USB_DEVICE_HID_EVENT_SET_LINE_CODING:
// In this case, the application should send the line coding
// data to the host. The application must responds to the
// event outside the event handler because the data buffer is
// not available.
setReportEventData = (USB_DEVICE_HID_EVENT_DATA_GET_REPORT *)pData;
5.9 USB Library Help MPLAB Harmony Help USB HID Device Library
5-4143
thisControlTransferHandle = controlTransferHandle;
receiveReportFromHost = true;
break;
}
}
// This is outside the event handler.
if(receiveReportFromHost)
{
// The application allocates a buffer using an arbitrary function
setReport = AllocateMemoryBuffer();
USB_DEVICE_HID_ControlReceive(instanceIndex, thisControlTransferHandle
setReport, setReportEventData->reportSize);
}
5.9.6.6.1.2 USB_DEVICE_HID_ControlSend Function
C
USB_DEVICE_HID_RESULT USB_DEVICE_HID_ControlSend(
USB_DEVICE_HID_INDEX instanceIndex,
USB_DEVICE_HID_CONTROL_TRANSFER_HANDLE controlTransferHandle,
void * data,
size_t size
);
Description
This function allows the application to respond to the HID function driver specific control transfer requests. It allows the
application to send data to the host in the data stage of the control transfer. For example, the
USB_DEVICE_HID_EVENT_DATA_REPORT_SENT event requires a control transfer response. The function can be called in
the HID Function Driver event handler or can be called outside the event handler. Calling this function outside the event handler
defers the response to the event. This allows the application to prepare the response data out of the event handler context,
especially if the data is not readily available. Note however, that there are timing considerations when responding to the control
transfer. Exceeding the response time will cause the host to cancel the control transfer and may cause USB host to reject the
device. The application must use the control transfer handle that was generated along with the event as the
controlTransferHandle.
Preconditions
This function should only be called in response to a HID function driver event that requires a control transfer response.
Parameters
Parameters Description
instance USB Device HID Function Driver instance.
controlTransferHandle Control Transfer handle for the control transfer.
data Data that represents the data stage of the control transfer.
size size (in bytes) of the data to sent.
Returns
USB_DEVICE_HID_RESULT_ERROR_CONTROL_TRANSFER_FAILED - The request was not successful because the USB
host cancelled the control transfer.
USB_DEVICE_HID_RESULT_OK - The request was successful.
Remarks
None.
5.9 USB Library Help MPLAB Harmony Help USB HID Device Library
5-4144
Example
// ------------------------------------------------------------------
// In this example, the application responds to the GET REPORT
// with in the event handler. The application uses the
// USB_DEVICE_HID_ControlSend() function to do this.
// ------------------------------------------------------------------
USB_DEVICE_HID_EVENT_DATA_GET_REPORT * getReportEventData;
USB_DEVICE_HID_CONTROL_TRANSFER_HANDLE controlTransferHandle;
uint8_t someReport[128];
USB_DEVICE_HID_EVENT_RESPONSE USBDeviceHIDEventHandler
(
USB_DEVICE_HID_INDEX instanceIndex,
USB_DEVICE_HID_EVENT event,
USB_DEVICE_HID_CONTROL_TRANSFER_HANDLE controlTransferHandle,
void * pData,
uintptr_t userData
)
{
switch(event)
{
case USB_DEVICE_HID_EVENT_GET_REPORT:
// In this case, the application should send the report
// to the host. The application must use the
// USB_DEVICE_HID_ControlSend() function to send the data.
getReportEventData = (USB_DEVICE_HID_EVENT_DATA_GET_REPORT *)pData;
USB_DEVICE_HID_ControlSend(instanceIndex, controlTransferHandle
someReport,
getReportEventData->reportSize);
break;
}
}
// --------------------------------------------------------------------
// In this example, the application defers the response to the
// event. This is done by calling the USB_DEVICE_HID_ControlSend()
// function out side the event handler.
// --------------------------------------------------------------------
USB_DEVICE_HID_EVENT_DATA_GET_REPORT * getReportEventData;
USB_DEVICE_HID_CONTROL_TRANSFER_HANDLE controlTransferHandle;
uint8_t someReport[128];
bool sendReportToHost;
USB_DEVICE_HID_EVENT_RESPONSE USBDeviceHIDEventHandler
(
USB_DEVICE_HID_INDEX instanceIndex,
USB_DEVICE_HID_EVENT event,
USB_DEVICE_HID_CONTROL_TRANSFER_HANDLE controlTransferHandle,
void * pData,
uintptr_t userData
)
{
switch(event)
{
case USB_DEVICE_HID_EVENT_GET_REPORT:
// In this case, the application should send the report
// data to the host. The application does not call this function
// in the event handler, because it does not have the report
// data ready.
5.9 USB Library Help MPLAB Harmony Help USB HID Device Library
5-4145
getReportEventData = (USB_DEVICE_HID_EVENT_DATA_GET_REPORT *)pData;
thisControlTransferHandle = controlTransferHandle;
sendReportToHost = true;
break;
}
}
// This is outside the event handler.
if(sendReportToHost)
{
// The application fetches the report coding from the
// an EEPROM.
GetReportFromEEPROM(someReport);
USB_DEVICE_HID_ControlSend(instanceIndex, controlTransferHandle
someReport,
getReportEventData->reportSize);
}
5.9.6.6.1.3 USB_DEVICE_HID_ControlStatus Function
C
USB_DEVICE_HID_RESULT USB_DEVICE_HID_ControlStatus(
USB_DEVICE_HID_INDEX instanceIndex,
USB_DEVICE_HID_CONTROL_TRANSFER_HANDLE controlTransferHandle,
USB_DEVICE_HID_CONTROL_STATUS status
);
Description
This function allows the application to complete the status stage of the the HID Function Driver specific control transfer request.
The application can either accept the data stage or stall it. Calling this function with status set to
USB_DEVICE_HID_CONTROL_STATUS_OK will acknowledge the status stage of the control transfer. The control transfer can
be stalled by setting the status parameter to USB_DEVICE_HID_CONTROL_STATUS_ERROR. The function can be called in
the HID Function Driver event handler or can be called outside the event handler. Calling this function outside the event handler
defers the response to the event. This allows the application to analyze the event response outside the event handler. Note
however, that there are timing considerations when responding to the control transfer. Exceeding the response time will cause
the host to cancel the control transfer and may cause USB host to reject the device. The application must use the control transfer
handle that was generated along with the event as the controlTransferHandle. The application must be aware of events and
associated control transfers that do or do not require data stages. Incorrect usage of the USB_DEVICE_HID_ControlStatus()
function could cause the device function to be non-compliant.
Preconditions
This function should only be called in response to a HID function driver event that requires a control transfer response.
Parameters
Parameters Description
instance USB Device HID Function Driver instance.
controlTransferHandle Control Transfer handle for the control transfer.
status Set to USB_DEVICE_HID_CONTROL_STATUS_OK to acknowledge the control
transfer. Set to USB_DEVICE_HID_CONTROL_STATUS_ERROR to stall the
transfer.
Returns
USB_DEVICE_HID_RESULT_ERROR_CONTROL_TRANSFER_FAILED - The request was not successful because the USB
5.9 USB Library Help MPLAB Harmony Help USB HID Device Library
5-4146
host cancelled the control transfer.
USB_DEVICE_HID_RESULT_OK - The request was successful.
Remarks
None.
Example
// ------------------------------------------------------------------
// In this code example, the application responds to the the
// SET IDLE event in the event handler.
// ------------------------------------------------------------------
USB_DEVICE_HID_EVENT_DATA_SET_IDLE * setIdleEventData;
USB_DEVICE_HID_EVENT_RESPONSE USBDeviceHIDEventHandler
(
USB_DEVICE_HID_INDEX instanceIndex,
USB_DEVICE_HID_EVENT event,
USB_DEVICE_HID_CONTROL_TRANSFER_HANDLE controlTransferHandle,
void * pData,
uintptr_t userData
)
{
switch(event)
{
case USB_DEVICE_HID_EVENT_SET_IDLE:
// The application can check if the break duration is supported.
setIdleEventData = (USB_DEVICE_HID_EVENT_DATA_SET_IDLE *)pData;
if(IsDurationSupported(setIdleEventData->duration))
{
USB_DEVICE_HID_ControlStatus(instanceIndex,
controlTransferHandle, USB_DEVICE_HID_CONTROL_STATUS_OK);
}
else
{
// If the duration is not supported the application
// can stall it.
USB_DEVICE_HID_ControlStatus(instanceIndex,
controlTransferHandle, USB_DEVICE_HID_CONTROL_STATUS_ERROR);
}
break;
...
}
return(USB_DEVICE_HID_EVENT_RESPONSE_NONE);
}
// --------------------------------------------------------------------
// In this example, the application defers the response to the
// SET IDLE event. The application responds to the event in
// outside the event handler.
// --------------------------------------------------------------------
USB_DEVICE_HID_CONTROL_TRANSFER_HANDLE thisControlTransferHandle;
USB_DEVICE_HID_EVENT_DATA_SET_IDLE * setIdleEventData;
uint8_t duration;
bool setIdleEvent;
USB_DEVICE_HID_EVENT_RESPONSE USBDeviceHIDEventHandler
(
USB_DEVICE_HID_INDEX instanceIndex,
5.9 USB Library Help MPLAB Harmony Help USB HID Device Library
5-4147
USB_DEVICE_HID_EVENT event,
USB_DEVICE_HID_CONTROL_TRANSFER_HANDLE controlTransferHandle,
void * pData,
uintptr_t userData
)
{
switch(event)
{
case USB_DEVICE_HID_EVENT_SEND_BREAK:
// Get the idle duration.
setIdleEventData = (USB_DEVICE_HID_EVENT_DATA_SET_IDLE *)pData;
duration = setIdleEventData->duration;
setIdleEvent = true;
break;
...
}
return(USB_DEVICE_HID_EVENT_RESPONSE_NONE);
}
// This is outside the event handler.
if(setIdleEvent)
{
// The application checks if the duration is supported
if(IsDurationSupported(setIdleEventData->duration))
{
USB_DEVICE_HID_ControlStatus(instanceIndex,
controlTransferHandle, USB_DEVICE_HID_CONTROL_STATUS_OK);
}
else
{
// If the duration is not supported the application
// can stall it.
USB_DEVICE_HID_ControlStatus(instanceIndex,
controlTransferHandle, USB_DEVICE_HID_CONTROL_STATUS_ERROR);
}
}
5.9.6.6.1.4 USB_DEVICE_HID_EventHandlerSet Function
C
USB_DEVICE_HID_RESULT USB_DEVICE_HID_EventHandlerSet(
USB_DEVICE_HID_INDEX instanceIndex,
USB_DEVICE_HID_EVENT_HANDLER eventHandler,
uintptr_t context
);
Description
This function registers a event handler for the specified HID function driver instance. This function should be called by the client
when it receives a SET CONFIGURATION event from the device layer. A event handler must be registered for function driver to
respond to function driver specific commands. If the event handler is not registered, the device layer will stall function driver
specific commands and the USB device may not function.
Preconditions
This function should be called when the function driver has been initialized as a result of a set configuration.
5.9 USB Library Help MPLAB Harmony Help USB HID Device Library
5-4148
Parameters
Parameters Description
instance Instance of the HID Function Driver.
eventHandler A pointer to event handler function.
context Application specific context that is returned in the event handler.
Returns
USB_DEVICE_HID_RESULT_OK - The operation was successful USB_DEVICE_HID_RESULT_ERROR_INSTANCE_INVALID
- The specified instance does not exist. USB_DEVICE_HID_RESULT_ERROR_PARAMETER_INVALID - The eventHandler
parameter is NULL
Remarks
None.
Example
// This code snippet shows an example registering an event handler. Here
// the application specifies the context parameter as a pointer to an
// application object (appObject) that should be associated with this
// instance of the HID function driver.
USB_DEVICE_HID_RESULT result;
USB_DEVICE_HID_EVENT_RESPONSE APP_USBDeviceHIDEventHandler
(
USB_DEVICE_HID_INDEX instanceIndex,
USB_DEVICE_HID_EVENT event,
USB_DEVICE_HID_CONTROL_TRANSFER_HANDLE controlTransferHandle,
void * pData,
uintptr_t context
)
{
// Event Handling comes here
switch(event)
{
...
}
return(USB_DEVICE_HID_EVENT_RESPONSE_NONE);
}
result = USB_DEVICE_HID_EventHandlerSet ( 0 ,&APP_EventHandler, (uintptr_t) &appObject);
if(USB_DEVICE_HID_RESULT_OK != result)
{
SYS_ASSERT ( false , "Error while registering event handler" );
}
5.9.6.6.1.5 USB_DEVICE_HID_ReportReceive Function
C
USB_DEVICE_HID_RESULT USB_DEVICE_HID_ReportReceive(
USB_DEVICE_HID_INDEX iHID,
USB_DEVICE_HID_TRANSFER_HANDLE * handle,
void * buffer,
size_t size
);
Description
This function submits the buffer to HID function driver library to receive a report from host to device. On completion of the
5.9 USB Library Help MPLAB Harmony Help USB HID Device Library
5-4149
transfer the library generates USB_DEVICE_HID_EVENT_REPORT_RECEIVED event to the application. A handle to the
request is passed in the transferHandle parameter. The transfer handle expires when event handler for the
USB_DEVICE_HID_EVENT_REPORT_RECEIVED exits. If the receive request could not be accepted, the function returns an
error code and transferHandle will contain the value USB_DEVICE_HID_TRANSFER_HANDLE_INVALID.
Preconditions
USB device layer must be initialized.
Parameters
Parameters Description
iHID HID instance index.
transferHandle HID transfer handle.
buffer Pointer to buffer where the received report has to be received stored.
size Buffer size.
Returns
USB_DEVICE_HID_RESULT_OK - The receive request was successful. transferHandle contains a valid transfer handle.
USB_DEVICE_HID_RESULT_ERROR_TRANSFER_QUEUE_FULL - internal request queue is full. The receive request could
not be added.
USB_DEVICE_HID_RESULT_ERROR_INSTANCE_NOT_CONFIGURED - The specified instance is not configured yet.
USB_DEVICE_HID_RESULT_ERROR_INSTANCE_INVALID - The specified instance was not provisioned in the application
and is invalid.
Remarks
None.
Example
USB_DEVICE_HID_TRANSFER_HANDLE hidTransferHandle;
USB_DEVICE_HID_RESULT result;
// Register APP_HIDEventHandler function
USB_DEVICE_HID_EventHandlerSet( USB_DEVICE_HID_INDEX_0 ,
APP_HIDEventHandler );
// Prepare report and request HID to send the report.
result = USB_DEVICE_HID_ReportReceive( USB_DEVICE_HID_INDEX_0,
&hidTransferHandle ,
&appReport[0], sizeof(appReport));
if( result != USB_DEVICE_HID_RESULT_OK)
{
//Handle error.
}
//Implementation of APP_HIDEventHandler
USB_DEVICE_HIDE_EVENT_RESPONSE APP_HIDEventHandler
{
USB_DEVICE_HID_INDEX instanceIndex,
USB_DEVICE_HID_EVENT event,
USB_DEVICE_HID_CONTROL_TRANSFER_HANDLE controlTransferHandle,
void * pData,
uintptr_t context
}
{
USB_DEVICE_HID_EVENT_DATA_REPORT_RECEIVED reportReceivedEventData;
5.9 USB Library Help MPLAB Harmony Help USB HID Device Library
5-4150
// Handle HID events here.
switch (event)
{
case USB_DEVICE_HID_EVENT_REPORT_RECEIVED:
if( (reportReceivedEventData->reportSize == sizeof(appReport)
&& reportReceivedEventData->report == &appReport[0])
{
// Previous transfer was complete.
}
break;
....
}
}
5.9.6.6.1.6 USB_DEVICE_HID_ReportSend Function
C
USB_DEVICE_HID_RESULT USB_DEVICE_HID_ReportSend(
USB_DEVICE_HID_INDEX iHID,
USB_DEVICE_HID_TRANSFER_HANDLE * handle,
void * buffer,
size_t size
);
Description
This function places a request to send a HID report with the USB Device HID Function Driver Layer. The function places a
requests with driver, the request will get serviced when report is requested by the USB Host. A handle to the request is returned
in the transferHandle parameter. The termination of the request is indicated by the
USB_DEVICE_HID_EVENT_REPORT_SENT event. The amount of data sent, a pointer to the report and the transfer handle
associated with the request is returned along with the event in the pData parameter of the event handler. The transfer handle
expires when event handler for the USB_DEVICE_HID_EVENT_REPORT_SENT exits. If the send request could not be
accepted, the function returns an error code and transferHandle will contain the value
USB_DEVICE_HID_TRANSFER_HANDLE_INVALID.
Preconditions
USB device layer must be initialized.
Parameters
Parameters Description
instance USB Device HID Function Driver instance.
transferHandle Pointer to a USB_DEVICE_HID_TRANSFER_HANDLE type of variable. This
variable will contain the transfer handle in case the send request was successful.
data pointer to the data buffer containing the report to be sent.
size Size (in bytes) of the report to be sent.
Returns
USB_DEVICE_HID_RESULT_OK - The send request was successful. transferHandle contains a valid transfer handle.
USB_DEVICE_HID_RESULT_ERROR_TRANSFER_QUEUE_FULL - Internal request queue is full. The send request could not
be added.
USB_DEVICE_HID_RESULT_ERROR_INSTANCE_NOT_CONFIGURED - The specified instance is not configured yet.
USB_DEVICE_HID_RESULT_ERROR_INSTANCE_INVALID - The specified instance was not provisioned in the application
and is invalid.
Remarks
None.
5.9 USB Library Help MPLAB Harmony Help USB HID Device Library
5-4151
Example
USB_DEVICE_HID_TRANSFER_HANDLE hidTransferHandle;
USB_DEVICE_HID_RESULT result;
// Register APP_HIDEventHandler function
USB_DEVICE_HID_EventHandlerSet( USB_DEVICE_HID_INDEX_0 ,
APP_HIDEventHandler );
// Prepare report and request HID to send the report.
result = USB_DEVICE_HID_ReportSend( USB_DEVICE_HID_INDEX_0,
&hidTransferHandle ,
&appReport[0], sizeof(appReport));
if( result != USB_DEVICE_HID_RESULT_OK)
{
//Handle error.
}
//Implementation of APP_HIDEventHandler
USB_DEVICE_HIDE_EVENT_RESPONSE APP_HIDEventHandler
{
USB_DEVICE_HID_INDEX instanceIndex,
USB_DEVICE_HID_EVENT event,
USB_DEVICE_HID_CONTROL_TRANSFER_HANDLE controlTransferHandle,
void * pData,
uintptr_t context
}
{
USB_DEVICE_HID_EVENT_DATA_REPORT_SENT * reportSentEventData;
// Handle HID events here.
switch (event)
{
case USB_DEVICE_HID_EVENT_REPORT_SENT:
reportSentEventData = (USB_DEVICE_HID_EVENT_REPORT_SENT *)pData;
if(reportSentEventData->reportSize == sizeof(appReport))
{
// The report was sent completely.
}
break;
....
}
return(USB_DEVICE_HID_EVENT_RESPONSE_NONE);
}
5.9.6.6.2 Data Types and Constants
5.9.6.6.2.1 USB_DEVICE_HID_CONTROL_STATUS Enumeration
C
typedef enum {
USB_DEVICE_HID_CONTROL_STATUS_OK,
USB_DEVICE_HID_CONTROL_STATUS_ERROR
} USB_DEVICE_HID_CONTROL_STATUS;
Description
USB Device HID Function Driver Control Transfer Status
5.9 USB Library Help MPLAB Harmony Help USB HID Device Library
5-4152
This flag is used along with the USB_DEVICE_HID_ControlStatus() function to indicate success or failure of a HID class specific
control transfer request.
Members
Members Description
USB_DEVICE_HID_CONTROL_STATUS_OK The application must use this flag when the data received through the
USB_DEVICE_HID_ControlReceive() function was accepted. Using this
flag causes the status stage of the associated control transfer to be
completed.
USB_DEVICE_HID_CONTROL_STATUS_ERROR The application must use this flag when the control request was not
supported or the data received using the
USB_DEVICE_HID_ControlReceive() function was not accepted. Using
this flag causes the status stage of the associated control transfer to be
stalled.
Remarks
None.
5.9.6.6.2.2 USB_DEVICE_HID_CONTROL_TRANSFER_HANDLE Type
C
typedef USB_DEVICE_CONTROL_TRANSFER_HANDLE USB_DEVICE_HID_CONTROL_TRANSFER_HANDLE;
Description
USB Device HID Function Driver Control Transfer Handle
This is returned by the HID function driver event handler and should be used by the application while responding to HID function
driver control transfer requests.
Remarks
None.
5.9.6.6.2.3 USB_DEVICE_HID_EVENT Enumeration
C
typedef enum {
USB_DEVICE_HID_EVENT_CONTROL_TRANSFER_DATA_RECEIVED,
USB_DEVICE_HID_EVENT_CONTROL_TRANSFER_DATA_SENT,
USB_DEVICE_HID_EVENT_CONTROL_TRANSFER_ABORTED,
USB_DEVICE_HID_EVENT_GET_REPORT,
USB_DEVICE_HID_EVENT_GET_IDLE,
USB_DEVICE_HID_EVENT_GET_PROTOCOL,
USB_DEVICE_HID_EVENT_SET_REPORT,
USB_DEVICE_HID_EVENT_SET_IDLE,
USB_DEVICE_HID_EVENT_SET_PROTOCOL,
USB_DEVICE_HID_EVENT_SET_DESCRIPTOR,
USB_DEVICE_HID_EVENT_REPORT_SENT,
USB_DEVICE_HID_EVENT_REPORT_RECEIVED
} USB_DEVICE_HID_EVENT;
Description
USB Device HID Function Driver Events
These events are specific to the USB Device HID Function Driver instance. Each event description contains details about the
parameters passed with event. The contents of pData depends on the generated event.
Events that are associated with the HID Function Driver Specific Control Transfers require application response and will be
5.9 USB Library Help MPLAB Harmony Help USB HID Device Library
5-4153
generated along with a HID Control Transfer Handle. This allows the application to respond to the HID function driver control
transfer requests. The application should respond to these events by using the USB_DEVICE_HID_ControlReceive(),
USB_DEVICE_HID_ControlSend() and USB_DEVICE_HID_ControlStatus() functions.
Calling the USB_DEVICE_HID_ControlStatus() function with a USB_DEVICE_HID_CONTROL_STATUS_ERROR will stall the
control transfer request. The application would do this if the control transfer request is not supported. Calling the
USB_DEVICE_HID_ControlStatus() function with a USB_DEVICE_HID_CONTROL_STATUS_OK will complete the status stage
of the control transfer request. The application would do this if the control transfer request is supported
The following code snippet shows an example of a possible event handling scheme.
// This code example shows all HID Function Driver events and a possible
// scheme for handling these events. In this example event responses are not
// deferred.
USB_DEVICE_HID_EVENT_RESPONSE USB_AppHIDEventHandler
(
USB_DEVICE_HID_INDEX instanceIndex,
USB_DEVICE_HID_EVENT event,
USB_DEVICE_HID_CONTROL_TRANSFER_HANDLE controlTransferHandle,
void * pData,
uintptr_t userData
)
{
USB_DEVICE_HID_EVENT_DATA_GET_REPORT * getReportEventData;
USB_DEVICE_HID_EVENT_DATA_GET_PROTOCOL currentProtocol;
USB_DEVICE_HID_EVENT_DATA_SET_PROTOCOL * setProtocolEventData;
USB_DEVICE_HID_EVENT_DATA_SET_IDLE * setIdleEventData;
USB_DEVICE_HID_EVENT_DATA_GET_IDLE * getIdleEventData;
USB_DEVICE_HID_EVENT_DATA_SET_DESCRIPTOR * setDescriptorEventData;
USB_DEVICE_HID_EVENT_DATA
USB_DEVICE_HID_EVENT_DATA_SET_REPORT * setReportEventData;
uint8_t idleRate;
uint8_t someHIDReport[128];
uint8_t someHIDDescriptor[128];
switch(event)
{
case USB_DEVICE_HID_EVENT_GET_REPORT:
// In this case, pData should be interpreted as a
// USB_DEVICE_HID_EVENT_DATA_GET_REPORT pointer. The application
// must send the requested report by using the
// USB_DEVICE_HID_ControlSend() function.
getReportEventData = (USB_DEVICE_HID_EVENT_DATA_GET_REPORT *)pData;
USB_DEVICE_HID_ControlSend(instanceIndex, controlTransferHandle,
someHIDReport, getReportEventData->reportLength);
break;
case USB_DEVICE_HID_EVENT_GET_PROTOCOL:
// In this case, pData will be NULL. The application
// must send the current protocol to the host by using
// the USB_DEVICE_HID_ControlSend() function.
USB_DEVICE_HID_ControlSend(instanceIndex, controlTransferHandle,
¤tProtocol,
sizeof(USB_DEVICE_HID_EVENT_DATA_GET_PROTOCOL));
break;
case USB_DEVICE_HID_EVENT_GET_IDLE:
5.9 USB Library Help MPLAB Harmony Help USB HID Device Library
5-4154
// In this case, pData will be a
// USB_DEVICE_HID_EVENT_DATA_GET_IDLE pointer type. The application
// must send the current idle rate to the host by using
// the USB_DEVICE_HID_ControlSend() function.
getLineCodingData = (USB_DEVICE_HID_EVENT_DATA_GET_IDLE *) pData;
USB_DEVICE_HID_ControlSend(instanceIndex, controlTransferHandle,
¤tIdleRate, 1);
break;
case USB_DEVICE_HID_EVENT_SET_REPORT:
// In this case, pData should be interpreted as a
// USB_DEVICE_HID_EVENT_DATA_SET_REPORT type pointer. The
// application can analyze the request and then obtain the
// report by using the USB_DEVICE_HID_ControlReceive() function.
setReportEventData = (USB_DEVICE_HID_EVENT_DATA_SET_REPORT *)pData;
USB_DEVICE_HID_ControlReceive(instanceIndex, controlTransferHandle
someHIDReport, setReportEventData->reportLength);
break;
case USB_DEVICE_HID_EVENT_SET_PROTOCOL:
// In this case, pData should be interpreted as a
// USB_DEVICE_HID_EVENT_DATA_SET_PROTOCOL type pointer. The
// application can analyze the data and decide to stall
// or accept the setting. This shows an example of accepting
// the protocol setting.
setProtocolEventData = (USB_DEVICE_HID_EVENT_DATA_SET_PROTOCOL *)pData;
USB_DEVICE_HID_ControlStatus(instanceIndex, controlTransferHandle,
USB_DEVICE_HID_CONTROL_STATUS_OK);
break;
case USB_DEVICE_HID_EVENT_SET_IDLE:
// In this case, pData should be interpreted as a
// USB_DEVICE_HID_EVENT_DATA_SET_IDLE type pointer. The
// application can analyze the data and decide to stall
// or accept the setting. This shows an example of accepting
// the protocol setting.
setIdleEventData = (USB_DEVICE_HID_EVENT_DATA_SET_IDLE *)pData;
USB_DEVICE_HID_ControlStatus(instanceIndex, controlTransferHandle,
USB_DEVICE_HID_CONTROL_STATUS_OK);
break;
case USB_DEVICE_HID_EVENT_SET_DESCRIPTOR:
// In this case, the pData should be interpreted as a
// USB_DEVICE_HID_EVENT_DATA_SET_DESCRIPTOR type pointer. The
// application can analyze the request and then obtain the
// descriptor by using the USB_DEVICE_HID_ControlReceive() function.
setDescriptorEventData = (USB_DEVICE_HID_EVENT_DATA_SET_REPORT *)pData;
USB_DEVICE_HID_ControlReceive(instanceIndex, controlTransferHandle
someHIDReport, setReportEventData->reportLength);
break;
case USB_DEVICE_HID_EVENT_CONTROL_TRANSFER_DATA_RECEIVED:
5.9 USB Library Help MPLAB Harmony Help USB HID Device Library
5-4155
// In this case, control transfer data was received. The
// application can inspect that data and then stall the
// handshake stage of the control transfer or accept it
// (as shown here).
USB_DEVICE_HID_ControlStatus(instanceIndex, controlTransferHandle
USB_DEVICE_HID_CONTROL_STATUS_OK);
break;
case USB_DEVICE_HID_EVENT_CONTROL_TRANSFER_DATA_SENT:
// This means that control transfer data was sent. The
// application would typically acknowledge the handshake
// stage of the control transfer.
USB_DEVICE_HID_ControlStatus(instanceIndex, controlTransferHandle,
USB_DEVICE_HID_CONTROL_STATUS_OK);
break;
case USB_DEVICE_HID_EVENT_CONTROL_TRANSFER_ABORTED:
// This is an indication only event. The application must
// reset any HID control transfer related tasks when it receives
// this event.
break;
case USB_DEVICE_HID_EVENT_REPORT_RECEIVED:
// This means a HID report receive request has completed.
// The pData member should be interpreted as a
// USB_DEVICE_HID_EVENT_DATA_REPORT_RECEIVED pointer type.
break;
case USB_DEVICE_HID_EVENT_REPORT_SENT:
// This means a HID report send request has completed.
// The pData member should be interpreted as a
// USB_DEVICE_HID_EVENT_DATA_REPORT_SENT pointer type.
break;
}
return(USB_DEVICE_HID_EVENT_RESPONSE_NONE);
}
Members
Members Description
USB_DEVICE_HID_EVENT_CONTROL_TRANSFER_DATA_RECEIVED This event occurs when the data stage of a control
write transfer has completed. This event would occur
after the application uses the
USB_DEVICE_HID_ControlReceive() function to
respond to a HID Function Driver Control Transfer
Event that requires data to be received from the
host. The pData parameter will be NULL.
5.9 USB Library Help MPLAB Harmony Help USB HID Device Library
5-4156
USB_DEVICE_HID_EVENT_CONTROL_TRANSFER_DATA_SENT This event occurs when the data stage of a control
read transfer has completed. This event would occur
after the application uses the
USB_DEVICE_HID_ControlSend() function to
respond to a HID Function Driver Control Transfer
Event that requires data to be sent to the host. The
pData parameter will be NULL
USB_DEVICE_HID_EVENT_CONTROL_TRANSFER_ABORTED This event occurs when an ongoing control transfer
was aborted. The application must stop any remaing
activities on control transfers
USB_DEVICE_HID_EVENT_GET_REPORT This event occurs when the host issues a GET
REPORT command. The application must interpret
the pData parameter as
USB_DEVICE_HID_EVENT_DATA_GET_REPORT
pointer type. If the report request is supported, the
application must send the report to the host by using
the USB_DEVICE_HID_ControlSend() function
either in the event handler or after the event handler
routine has returned. The application can track the
completion of the request by using the
USB_DEVICE_HID_EVENT_CONTROL_TRANSFE
R_DATA_SENT
event. If the report request is not supported, the
application must stall the request by calling the
USB_DEVICE_HID_ControlStatus() function with a
USB_DEVICE_HID_CONTROL_STATUS_ERROR
flag.
USB_DEVICE_HID_EVENT_GET_IDLE This event occurs when the host issues a GET IDLE
command. The pData parameter will be a
USB_DEVICE_HID_EVENT_DATA_GET_IDLE
pointer type. If the request is supported, the
application must send the idle rate to the host by
calling the USB_DEVICE_HID_ControlSend()
function. This function can be called either in the
event handler or after the event handler routine has
returned. The application can track the completion of
the request by using the
USB_DEVICE_HID_EVENT_CONTROL_TRANSFE
R_DATA_SENT
event. If the request is not supported, the application
must stall the request by calling the
USB_DEVICE_HID_ControlStatus() function with a
USB_DEVICE_HID_CONTROL_STATUS_ERROR
flag.
5.9 USB Library Help MPLAB Harmony Help USB HID Device Library
5-4157
USB_DEVICE_HID_EVENT_GET_PROTOCOL This event occurs when the host issues a GET
PROTOCOL command. The pData parameter will be
NULL. If the request is supported, the application
must send a
USB_DEVICE_HID_EVENT_DATA_GET_PROTOC
OL
data type object, containing the current protocol, to
the host by calling the
USB_DEVICE_HID_ControlSend() function. This
function can be called either in the event handler or
after the event handler routine has returned. The
application can track the completion of the request
by using the
USB_DEVICE_HID_EVENT_CONTROL_TRANSFE
R_DATA_SENT
event. If the request is not supported, the application
must stall the request by calling the
USB_DEVICE_HID_ControlStatus() function with a
USB_DEVICE_HID_CONTROL_STATUS_ERROR
flag.
USB_DEVICE_HID_EVENT_SET_REPORT This event occurs when the host issues a SET
REPORT command. The application must interpret
the pData parameter as a
USB_DEVICE_HID_EVENT_DATA_SET_REPORT
pointer type. If the report request is supported, the
application must provide a buffer, to recevie the
report, to the host by calling the
USB_DEVICE_HID_ControlReceive() function either
in the event handler or after the event handler
routine has returned. The application can track the
completion of the request by using the
USB_DEVICE_HID_EVENT_CONTROL_TRANSFE
R_DATA_RECEIVED
event. If the report request is not supported, the
application must stall the request by calling the
USB_DEVICE_HID_ControlStatus() function with a
USB_DEVICE_HID_CONTROL_STATUS_ERROR
flag.
USB_DEVICE_HID_EVENT_SET_IDLE This event occurs when the host issues a SET IDLE
command. The pData parameter will be
USB_DEVICE_HID_EVENT_DATA_SET_IDLE
pointer type. The application can analyze the idle
duration and acknowledge or reject the setting by
calling the USB_DEVICE_HID_ControlStatus()
function. This function can be called in the event
handler or after the event handler exits. If application
can reject the request by calling the
USB_DEVICE_HID_ControlStatus() function with a
USB_DEVICE_HID_CONTROL_STATUS_ERROR
flag. It can accept the request by calling this function
with USB_DEVICE_HID_CONTROL_STATUS_OK
flag.
5.9 USB Library Help MPLAB Harmony Help USB HID Device Library
5-4158
USB_DEVICE_HID_EVENT_SET_PROTOCOL This event occurs when the host issues a SET
PROTOCOL command. The pData parameter will be
NULL. If the request is supported, the application
must provide a
USB_DEVICE_HID_EVENT_DATA_SET_PROTOC
OL
data type object to receive the current protocol from
the host by calling the
USB_DEVICE_HID_ControlReceive() function. This
function can be called either in the event handler or
after the event handler routine has returned. The
application can track the completion of the request
by using the
USB_DEVICE_HID_EVENT_CONTROL_TRANSFE
R_DATA_RECEIVED
event. If the request is not supported, the application
must stall the request by calling the
USB_DEVICE_HID_ControlStatus() function with a
USB_DEVICE_HID_CONTROL_STATUS_ERROR
flag.
USB_DEVICE_HID_EVENT_SET_DESCRIPTOR This event occurs when the host issues a SET
DESCRIPTOR command. The pData parameter will
be a
USB_DEVICE_HID_EVENT_DATA_SET_DESCRIP
TOR
type pointer. If the request is supported, the
application must provide a buffer to receive the
descriptor from the host by calling the
USB_DEVICE_HID_ControlReceive() function. This
function can be called either in the event handler or
after the event handler routine has returned. The
application can track the completion of the request
by using the
USB_DEVICE_HID_EVENT_CONTROL_TRANSFE
R_DATA_RECEIVED
event. If the request is not supported, the application
must stall the request by calling the
USB_DEVICE_HID_ControlStatus() function with a
USB_DEVICE_HID_CONTROL_STATUS_ERROR
flag.
USB_DEVICE_HID_EVENT_REPORT_SENT This event indicates that
USB_DEVICE_HID_ReportSend() function
completed a report transfer on interrupt endpoint
from host to device. The pData parameter will be a
USB_DEVICE_HID_EVENT_DATA_REPORT_SENT
type.
USB_DEVICE_HID_EVENT_REPORT_RECEIVED This event indicates that
USB_DEVICE_HID_ReportReceive() function
completed a report transfer on interrupt endpoint
from device to host. The pData parameter will be a
USB_DEVICE_HID_EVENT_DATA_REPORT_REC
EIVED
type
Remarks
Some of the events allow the application to defer responses. This allows the application some time to obtain the response data
rather than having to respond to the event immediately. Note that a USB host will typically wait for event response for a finite
5.9 USB Library Help MPLAB Harmony Help USB HID Device Library
5-4159
time duration before timing out and cancelling the event and associated transactions. Even when deferring response, the
application must respond promptly if such timeouts have to be avoided.
5.9.6.6.2.4 USB_DEVICE_HID_EVENT_DATA_GET_IDLE Structure
C
typedef struct {
uint8_t reportID;
} USB_DEVICE_HID_EVENT_DATA_GET_IDLE;
Description
USB Device HID Get Idle Event Data Type.
This defines the data type of the data generated to the HID event handler on a USB_DEVICE_HID_EVENT_SET_REPORT
event.
Members
Members Description
uint8_t reportID; Report ID of the report of which idle rate is requested.
Remarks
None.
5.9.6.6.2.5 USB_DEVICE_HID_EVENT_DATA_GET_PROTOCOL Structure
C
typedef struct {
USB_HID_PROTOCOL_CODE protocol;
} USB_DEVICE_HID_EVENT_DATA_GET_PROTOCOL;
Description
USB Device HID Get Protocol Event Data Type.
This defines the data type of the data to be sent to the host in response to USB_DEVICE_HID_EVENT_GET_PROTOCOL
event. The data should be sent to the host by calling the USB_DEVICE_HID_ControlSend() function.
Remarks
None.
5.9.6.6.2.6 USB_DEVICE_HID_EVENT_DATA_GET_REPORT Structure
C
typedef struct {
uint8_t reportType;
uint8_t reportID;
uint16_t reportLength;
} USB_DEVICE_HID_EVENT_DATA_GET_REPORT;
Description
USB Device HID Get Report Event Data Type.
This defines the data type of the data generated to the HID event handler on a USB_DEVICE_HID_EVENT_GET_REPORT
event.
5.9 USB Library Help MPLAB Harmony Help USB HID Device Library
5-4160
Members
Members Description
uint8_t reportType; Report type
uint8_t reportID; Report ID
uint16_t reportLength; Report Length
Remarks
None.
5.9.6.6.2.7 USB_DEVICE_HID_EVENT_DATA_REPORT_RECEIVED Structure
C
typedef struct {
USB_DEVICE_HID_TRANSFER_HANDLE handle;
size_t length;
} USB_DEVICE_HID_EVENT_DATA_REPORT_RECEIVED;
Description
USB Device HID Report Received Event Data Type.
This defines the data type of the data generated to the HID event handler on a
USB_DEVICE_HID_EVENT_REPORT_RECEIVED event.
Members
Members Description
USB_DEVICE_HID_TRANSFER_HANDLE
handle;
Transfer handle
size_t length; Report size received
Remarks
None.
5.9.6.6.2.8 USB_DEVICE_HID_EVENT_DATA_REPORT_SENT Structure
C
typedef struct {
USB_DEVICE_HID_TRANSFER_HANDLE handle;
size_t length;
} USB_DEVICE_HID_EVENT_DATA_REPORT_SENT;
Description
USB Device HID Report Sent Event Data Type.
This defines the data type of the data generated to the HID event handler on a USB_DEVICE_HID_EVENT_REPORT_SENT
event.
Members
Members Description
USB_DEVICE_HID_TRANSFER_HANDLE
handle;
Transfer handle
size_t length; Report size transmitted
5.9 USB Library Help MPLAB Harmony Help USB HID Device Library
5-4161
Remarks
None.
5.9.6.6.2.9 USB_DEVICE_HID_EVENT_DATA_SET_DESCRIPTOR Structure
C
typedef struct {
uint8_t descriptorType;
uint8_t descriptorIndex;
uint16_t descriptorLength;
} USB_DEVICE_HID_EVENT_DATA_SET_DESCRIPTOR;
Description
USB Device HID Set Descriptor Event Data Type.
This defines the data type of the data generated to the HID event handler on a USB_DEVICE_HID_EVENT_SET_DESCRIPTOR
event.
Members
Members Description
uint8_t descriptorType; Descriptor Type
uint8_t descriptorIndex; Descriptor Index
uint16_t descriptorLength; Descriptor Length
Remarks
None.
5.9.6.6.2.10 USB_DEVICE_HID_EVENT_DATA_SET_IDLE Structure
C
typedef struct {
uint8_t duration;
uint8_t reportID;
} USB_DEVICE_HID_EVENT_DATA_SET_IDLE;
Description
USB Device HID Set Idle Event Data Type.
This defines the data type of the data generated to the HID event handler on a USB_DEVICE_HID_EVENT_SET_IDLE event.
Members
Members Description
uint8_t duration; Idle duration
uint8_t reportID; Report ID
Remarks
None.
5.9.6.6.2.11 USB_DEVICE_HID_EVENT_DATA_SET_PROTOCOL Structure
C
typedef struct {
USB_HID_PROTOCOL_CODE protocol;
} USB_DEVICE_HID_EVENT_DATA_SET_PROTOCOL;
5.9 USB Library Help MPLAB Harmony Help USB HID Device Library
5-4162
Description
USB Device HID Set Protocol Event Data Type.
This defines the data type of the data generated to the HID event handler on a USB_DEVICE_HID_EVENT_SET_PROTOCOL
event.
Remarks
None.
5.9.6.6.2.12 USB_DEVICE_HID_EVENT_DATA_SET_REPORT Structure
C
typedef struct {
uint8_t reportType;
uint8_t reportID;
uint16_t reportLength;
} USB_DEVICE_HID_EVENT_DATA_SET_REPORT;
Description
USB Device HID Set Report Event Data Type.
This defines the data type of the data generated to the HID event handler on a USB_DEVICE_HID_EVENT_SET_REPORT
event.
Members
Members Description
uint8_t reportType; Report type
uint8_t reportID; Report ID
uint16_t reportLength; Report Length
Remarks
None.
5.9.6.6.2.13 USB_DEVICE_HID_EVENT_HANDLER Type
C
typedef USB_DEVICE_HID_EVENT_RESPONSE (* USB_DEVICE_HID_EVENT_HANDLER)(USB_DEVICE_HID_INDEX
instanceIndex, USB_DEVICE_HID_EVENT event, USB_DEVICE_HID_CONTROL_TRANSFER_HANDLE
controlTransferHandle, void * pData, uintptr_t context);
Description
USB Device HID Event Handler Function Pointer Type.
This data type defines the required function signature of the USB Device HID Function Driver event handling callback function.
The application must register a pointer to a HID Function Driver events handling function who's function signature (parameter
and return value types) match the types specified by this function pointer in order to receive event call backs from the HID
Function Driver. The function driver will invoke this function with event relevant parameters. The description of the event handler
function parameters is given here.
instanceIndex - Instance index of the HID Function Driver that generated the event.
event - Type of event generated.
controlTransferHandle - Control Transfer Handle for HID function driver events that require application response. The application
should use this handle when calling the USB HID Device Control Transfer functions to respond to the events.
5.9 USB Library Help MPLAB Harmony Help USB HID Device Library
5-4163
pData - This parameter should be type casted to a event specific pointer type based on the event that has occurred. Refer to the
USB_DEVICE_HID_EVENT enumeration description for more details.
context - Value identifying the context of the application that registered the event handling function.
Remarks
None.
5.9.6.6.2.14 USB_DEVICE_HID_EVENT_RESPONSE Type
C
typedef void USB_DEVICE_HID_EVENT_RESPONSE;
Description
USB Device HID Function Driver Event Handler Response Type
This is the return type of the HID Function Driver event handler.
Remarks
None.
5.9.6.6.2.15 USB_DEVICE_HID_INDEX Type
C
typedef uintptr_t USB_DEVICE_HID_INDEX;
Description
USB Device HID Driver Index Numbers
This uniquely identifies a HID Function Driver instance.
Remarks
None.
5.9.6.6.2.16 USB_DEVICE_HID_INIT Structure
C
typedef struct {
size_t hidReportDescriptorSize;
void * hidReportDescriptor;
size_t queueSizeReportSend;
size_t queueSizeReportReceive;
} USB_DEVICE_HID_INIT;
Description
USB Device HID Function Driver Initialization Data Structure
This data structure must be defined for every instance of the HID function driver. It is passed to the HID function driver, by the
Device Layer, at the time of initialization. The funcDriverInit member of the Device Layer Function Driver registration table entry
must point to this data structure for an instance of the HID function driver.
Members
Members Description
size_t hidReportDescriptorSize; Size of the HID report descriptor
void * hidReportDescriptor; Pointer to HID report descriptor
5.9 USB Library Help MPLAB Harmony Help USB HID Device Library
5-4164
size_t queueSizeReportSend; Report send queue size
size_t queueSizeReportReceive; Report receive queue size
Remarks
None.
5.9.6.6.2.17 USB_DEVICE_HID_RESULT Enumeration
C
typedef enum {
USB_DEVICE_HID_RESULT_OK,
USB_DEVICE_HID_RESULT_ERROR_TRANSFER_QUEUE_FULL,
USB_DEVICE_HID_RESULT_ERROR_INSTANCE_NOT_CONFIGURED,
USB_DEVICE_HID_RESULT_ERROR_INSTANCE_INVALID
} USB_DEVICE_HID_RESULT;
Description
USB Device HID Function Driver USB Device HID Result enumeration.
This enumeration lists the possible USB Device HID Function Driver operation results. These values USB Device HID Library
functions.
Members
Members Description
USB_DEVICE_HID_RESULT_OK The operation was successful
5.9.6.6.2.18 USB_DEVICE_HID_TRANSFER_HANDLE Type
C
typedef uintptr_t USB_DEVICE_HID_TRANSFER_HANDLE;
Description
USB Device HID Function Driver Transfer Handle Definition
This definition defines a USB Device HID Function Driver Transfer Handle. A Transfer Handle is owned by the application but its
value is modified by the USB_DEVICE_HID_ReportSend() and USB_DEVICE_HID_ReportReceive() functions. The transfer
handle is valid for the life time of the transfer and expires when the transfer related event has occurred.
Remarks
None.
5.9.6.6.2.19 USB_DEVICE_HID_EVENT_RESPONSE_NONE Macro
C
#define USB_DEVICE_HID_EVENT_RESPONSE_NONE
Description
USB Device HID Function Driver Event Handler Response None
This is the definition of the HID Function Driver Event Handler Response Type none.
Remarks
Intentionally defined to be empty.
5.9 USB Library Help MPLAB Harmony Help USB HID Device Library
5-4165
5.9.6.6.2.20 USB_DEVICE_HID_INSTANCES_NUMBER Macro
C
#define USB_DEVICE_HID_INSTANCES_NUMBER
Description
USB Device HID Maximum Number of Instances
This macro defines the number of instances of the HID Function Driver. For example, if the application needs to implement two
instances of the HID Function Driver (to create composite device) on one USB Device, the macro should be set to 2. Note that
implementing a USB Device that features multiple HID interfaces requires appropriate USB configuration descriptors.
Remarks
None.
5.9.6.6.2.21 USB_DEVICE_HID_QUEUE_DEPTH_COMINED Macro
C
#define USB_DEVICE_HID_QUEUE_DEPTH_COMINED
Description
DOM-IGONORE-BEGIN
5.9.6.6.2.22 USB_DEVICE_HID_TRANSFER_HANDLE_INVALID Macro
C
#define USB_DEVICE_HID_TRANSFER_HANDLE_INVALID ((USB_DEVICE_HID_TRANSFER_HANDLE)(-1))
Description
USB Device HID Function Driver Invalid Transfer Handle Definition
This definition defines a USB Device HID Function Driver Invalid Transfer Handle. A Invalid Transfer Handle is returned by the
USB_DEVICE_HID_ReportReceive() and USB_DEVICE_HID_ReportSend() functions when the request was not successful.
Remarks
None.
5.9.6.7 Files
Files
Name Description
usb_device_hid.h USB HID Function Driver
usb_device_hid_config_template..h USB device HID class configuration definitions template,
Description
5.9.6.7.1 usb_device_hid.h
USB HID Function Driver
5.9 USB Library Help MPLAB Harmony Help USB HID Device Library
5-4166
USB HID Function Driver
Enumerations
Name Description
USB_DEVICE_HID_CONTROL_STATUS USB Device HID Function Driver Control Transfer Status
USB_DEVICE_HID_EVENT USB Device HID Function Driver Events
USB_DEVICE_HID_RESULT USB Device HID Function Driver USB Device HID Result enumeration.
Functions
Name Description
USB_DEVICE_HID_ControlReceive This function allows the application to respond to the HID function driver
specific control transfer requests. It allows the application to receive data
from the host in the data stage of the control transfer.
USB_DEVICE_HID_ControlSend This function allows the application to respond to the HID function driver
specific control transfer requests. It allows the application to send data to
the host in the data stage of the control transfer.
USB_DEVICE_HID_ControlStatus This function allows the application to complete the status stage of the the
HID Function Driver specific control transfer request.
USB_DEVICE_HID_EventHandlerSet This function registers a event handler for the specified HID function driver
instance.
USB_DEVICE_HID_ReportReceive This function submits the buffer to HID function driver library to receive a
report from host to device.
USB_DEVICE_HID_ReportSend This function submits the buffer to HID function driver library to send a
report from device to host.
Macros
Name Description
USB_DEVICE_HID_EVENT_RESPONSE_NONE USB Device HID Function Driver Event Handler Response
Type None.
USB_DEVICE_HID_TRANSFER_HANDLE_INVALID USB Device HID Function Driver Invalid Transfer Handle
Definition.
Structures
Name Description
USB_DEVICE_HID_EVENT_DATA_GET_IDLE USB Device HID Get Idle Event Data Type.
USB_DEVICE_HID_EVENT_DATA_GET_PROTOCOL USB Device HID Get Protocol Event Data Type.
USB_DEVICE_HID_EVENT_DATA_GET_REPORT USB Device HID Get Report Event Data Type.
USB_DEVICE_HID_EVENT_DATA_REPORT_RECEIVED USB Device HID Report Received Event Data Type.
USB_DEVICE_HID_EVENT_DATA_REPORT_SENT USB Device HID Report Sent Event Data Type.
USB_DEVICE_HID_EVENT_DATA_SET_DESCRIPTOR USB Device HID Set Descriptor Event Data Type.
USB_DEVICE_HID_EVENT_DATA_SET_IDLE USB Device HID Set Idle Event Data Type.
USB_DEVICE_HID_EVENT_DATA_SET_PROTOCOL USB Device HID Set Protocol Event Data Type.
USB_DEVICE_HID_EVENT_DATA_SET_REPORT USB Device HID Set Report Event Data Type.
USB_DEVICE_HID_INIT USB Device HID Function Driver Initialization Data
Structure
Types
Name Description
USB_DEVICE_HID_CONTROL_TRANSFER_HANDLE USB Device HID Function Driver Control Transfer Handle
USB_DEVICE_HID_EVENT_HANDLER USB Device HID Event Handler Function Pointer Type.
5.9 USB Library Help MPLAB Harmony Help USB HID Device Library
5-4167
USB_DEVICE_HID_EVENT_RESPONSE USB Device HID Function Driver Event Callback
Response Type
USB_DEVICE_HID_INDEX USB device HID Function Driver Index.
USB_DEVICE_HID_TRANSFER_HANDLE USB Device HID Function Driver Transfer Handle
Definition.
Company
Microchip Technology Inc.
FileName: usb_hid_function_driver.h
5.9.6.7.2 usb_device_hid_config_template..h
USB Device HID Class Configuration Definitions for the Template
These definitions statically define the device HID Class mode of operation.
Macros
Name Description
USB_DEVICE_HID_INSTANCES_NUMBER Specifies the number of HID instances.
USB_DEVICE_HID_QUEUE_DEPTH_COMINED DOM-IGONORE-BEGIN
File Name
usb_device_hid_config_template.h
Company
Microchip Technology Inc.
5.9.7 USB MSD Device Library
5.9.7.1 Introduction
USB Mass Storage Device (MSD) Class Library for Microchip Microcontrollers
This library provides a high-level abstraction of USB Mass Storage Device (MSD) function driver with a convenient C language
interface. This library supports USB Mass Storage Class Bulk-Only Transport, Revision 1.0 from USB Implementers Forum.
Description
The mass storage device class function driver library enables the developers to add mass storage functionality to a device. This
library along with USB device stack and a required media driver can be used to build devices like USB thumb drive and card
readers.
5.9 USB Library Help MPLAB Harmony Help USB MSD Device Library
5-4168
5.9.7.2 Release Notes
MPLAB Harmony Version: v0.70b USB MSD Device Library Version : 0.01 Alpha Release Date: 18Nov2013
New This Release:
This is the first release of the library. The interface can change in the beta and\or 1.0 release.
Known Issues:
Nothing to report in this release.
5.9.7.3 SW License Agreement
(c) 2013 Microchip Technology Inc.
Microchip licenses this software to you solely for use with Microchip products. The software is owned by Microchip and its
licensors, and is protected under applicable copyright laws. All rights reserved.
SOFTWARE IS PROVIDED "AS IS" MICROCHIP EXPRESSLY DISCLAIMS ANY WARRANTY OF ANY KIND, WHETHER
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. IN NO EVENT SHALL MICROCHIP BE LIABLE FOR
ANY INCIDENTAL, SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, HARM TO
YOUR EQUIPMENT, COST OF PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY OR SERVICES, ANY CLAIMS
BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), ANY CLAIMS FOR INDEMNITY OR
CONTRIBUTION, OR OTHER SIMILAR COSTS.
To the fullest extent allowed by law, Microchip and its licensors liability shall not exceed the amount of fees, if any, that you have
paid directly to Microchip to use this software.
MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE TERMS.
5.9.7.4 Using the Library
5.9.7.4.1 Abstraction Model
The basic software architecture into which USB mass storage device class function driver fits into is depicted in the following
diagram.
5.9 USB Library Help MPLAB Harmony Help USB MSD Device Library
5-4169
The system makes no direct calls to MSD function driver. It is the USB device layer that initializes and deinitializes the MSD
function driver. The MSD function driver is initialized when host configures the device. It is deinitialized when device exits the
configured state. The device exits the configured state when device is detached from the host or if host issues a bus reset to the
device or if host changes the device configuration to a new value. The MSD function driver task is called from with in the USB
device layer task. This means that MSD function driver task runs at the same priority level as USB device layer task. So, the user
has to register the MSD function driver with USB device layer to allow the USB device layer to make calls to MSD function driver
callback functions at runtime. This registration can be done using compile time configuration.
The system does the media driver initialization and is responsible for calling the media driver tasks. The MSD function driver
interacts with media driver at runtime to perform sector read, write and erase by calling the media driver callback functions. This
requires for the user to register the media driver with the MSD function driver using compile time configuration.
The subsequent sections of this help document describes how to register the MSD function driver and media driver with USB
device layer and MSD function driver respectively.
5.9.7.4.2 How the Library Works
5.9.7.4.2.1 System Interaction
5.9 USB Library Help MPLAB Harmony Help USB MSD Device Library
5-4170
The above figure shows the system interaction required for MSD function driver. The system has to initialize the media driver
and the USB device layer. There are no direct calls the system has to make to initialize the MSD function driver. The USB device
layer initializes and deinitializes the MSD function driver appropriately at runtime. The system is also responsible for calling the
media driver tasks if applicable.
5.9.7.4.2.2 Object Initialization
Each instance of MSD function driver must be initialized by an object of data type USB_DEVICE_MSD_INIT at compile time. If
there are more than one instance of MSD function driver, then user must create multiple objects of this data type. The Init Object
is then linked to an instance of MSD function driver by adding its pointer to the function driver registration table (Refer to section
"Registering MSD function driver").
The MSD Init Object contains following data about an instance of MSD.
1. Interface number.
2. Bulk-IN endpoint address
3. Bulk-OUT endpoint address
4. Size of the endpoint
5. Number of logical units (LUN) supported by the particular instance of MSD.
6. One or more media driver instance number depending on the number of logical units supported. This is the media driver with
which the particular logical unit will interact.
7. One or more inquiry response structure depending on the number of logical units supported.
8. Pointers to one or more sets of media driver callback functions depending on the number of logical units supported.
The device layer passes the Init Object to MSD function driver when it initializes the function driver.
The following code example shows how to initialize the MSD using Init Object.
const USB_DEVICE_MSD_INIT msdInit =
{
0, /* Interface number */
5.9 USB Library Help MPLAB Harmony Help USB MSD Device Library
5-4171
1, /* Bulk IN endpoint */
1, /* Bulk OUT endpoint */
64, /* Size of the bulk endpoint */
1, /* Number of logical unit (LUN) */
{
/* Begin first LUN info */
{
/* Media driver instance number */
USB_DEVICE_MDD_INTFLASH_INDEX,
/* Inquiry response for the first logical unit */
{
0x00, /* peripheral device is connected, direct access block device */
0x80, /* removable media */
0x04, /* version = 00=> does not conform to any standard, 4=> SPC-2 */
0x02, /* response is in format specified by SPC-2 */
0x20, /* n-4 = 36-4=32= 0x20 */
0x00, /* sccs etc.*/
0x00, /* bque=1 and cmdque=0,indicates simple queuing 00 is obsolete
but as in case of other device, we are just using 00. */
0x00, /* 00 obsolete, 0x80 for basic task queuing */
{
'M','i','c','r','o','c','h','p'
},
/* this is the T10 assigned Vendor ID */
{
'M','a','s','s',' ','S','t','o','r','a','g','e',' ',' ',' ',' '
},
{
'0','0','0','1'
}
},
/* MDD function callback pointers for first loical uint */
{
&USB_DEVICE_MDD_INTFLASH_Status,
&USB_DEVICE_MDD_INTFLASH_Open,
&USB_DEVICE_MDD_INTFLASH_ReadCapacity,
&USB_DEVICE_MDD_INTFLASH_ReadSectorSize ,
&USB_DEVICE_MDD_INTFLASH_MediaDetect,
&USB_DEVICE_MDD_INTFLASH_SectorRead,
&USB_DEVICE_MDD_INTFLASH_WriteProtectState,
&USB_DEVICE_MDD_INTFLASH_SectorWrite
}
}
}/* End of first LUN info */
{ /* Start of second LUN info */
} /* End of second LUN info */
};
5.9.7.4.2.3 MSD Function Driver Registration
The MSD function driver is registered with the USB device layer using the function registration table structure. The following
code example shows how the MSD function driver can be registered with the USB device layer using function registration table.
The structure variable msdFunctionDriver contains pointers to MSD function driver callbacks.
Example:
5.9 USB Library Help MPLAB Harmony Help USB MSD Device Library
5-4172
/* The device layer invokes the MSD function driver if the speed is full speed
and the host selects configuration value as 1 */
funcRegistrationTable[1] =
{
{
/* Speed
USB_SPEED_FULL,
/* Configuration value */
1,
/* Interface number */
0,
/* Number of interfaces */
1,
/* MSD instance index */
USBMSD_FUNC_INDEX,
/* MSD driver init object */
(void*)&msdInit,
/* MSD driver */
&msdFunctionDriver
}
};
5.9.7.4.2.4 Media Driver Registration
The MSD function driver makes call to media driver functions at runtime to perform sector erase, read and write operations.
Therefore, the user must register the pointers to media driver callback functions with the MSD function driver . This has to be
done at compile time while initializing the Init Object. Refer to the code example shown in the "Init Object" section for more
information.
5.9.7.5 Library Interface
This section describes the configuration options provided by the MSD function driver to the system and the available data types.
Refer to each section for a detailed description.
5.9.7.5.1 System Configuration Functions
Macros
Name Description
USB_DEVICE_MSD_MAX_INSTANCES This constant sets maximum possible number of instances of USB
device MSD function driver that can be instantiated by using
USB_DEVICE_MSD_Initialize() routine.
USB_DEVICE_MSD_MAX_LUN This constant sets maximum possible number of Logical Unit an
instance of MSD can support.
USB_DEVICE_MSD_MAX_SECTOR_SIZE This constant defines the max possible media sector size supported
by the MSD.
Description
5.9 USB Library Help MPLAB Harmony Help USB MSD Device Library
5-4173
5.9.7.5.1.1 USB_DEVICE_MSD_MAX_INSTANCES Macro
C
#define USB_DEVICE_MSD_MAX_INSTANCES 1
Remarks
The static implementation supports only one instance. Setting the value of this constant to > 1 has no effect on static
implementations. Only in dynamic implementation of USB device MSD function driver this value can be set > 1.
USB device MSD function driver has to support atleast one instance. Hence, make sure the value of this constant is set to > 0.
Increasing the instance count consumes RAM and can lead to performance degradation.
5.9.7.5.1.2 USB_DEVICE_MSD_MAX_LUN Macro
C
#define USB_DEVICE_MSD_MAX_LUN 1
Description
This constant sets maximum possible number of Logical Unit (LUN) an instance of MSD can support.
Remarks
The value of this macro must not be set to zero. Each instance of USB MSDfunction driver can support atleast one LUN. Hence
set the value to atleast 1.
5.9.7.5.1.3 USB_DEVICE_MSD_MAX_SECTOR_SIZE Macro
C
#define USB_DEVICE_MSD_MAX_SECTOR_SIZE 512
Description
If there are two logical units (LUNs), one that supports sector size 512 bytes and then the other one that supports 1024 bytes,
then set the value of this macro to 1024.
Remarks
none.
5.9.7.5.2 Data Types and Constants
Macros
Name Description
USB_DEVICE_MSD_INTF MSD Interface Class Code
USB_DEVICE_MSD_INTF_SUBCLASS Only scsi transparent is supported.
USB_DEVICE_MSD_PROTOCOL MSD Interface Class Protocol Codes
Structures
Name Description
USB_DEVICE_MSD_MEDIA_FUNCTIONS This structure contains all the media driver callback function
pointers. The MSD driver makes call to these function pointers at run
time to know the status of the media and to read and write the media.
USB_DEVICE_MSD_INIT This structure contains required parameters for MSD initialization.
5.9 USB Library Help MPLAB Harmony Help USB MSD Device Library
5-4174
USB_DEVICE_MSD_INQUIRY_RESPONSE Inquiry response structure.
USB_DEVICE_MSD_MEDIA_INIT_DATA This structure holds media related data of a particular logical unit.
Description
5.9.7.5.2.1 USB_DEVICE_MSD_INTF Macro
C
#define USB_DEVICE_MSD_INTF 0x08
Description
MSD Interface Class Code
5.9.7.5.2.2 USB_DEVICE_MSD_INTF_SUBCLASS Macro
C
#define USB_DEVICE_MSD_INTF_SUBCLASS 0x06 // Only scsi transparent is supported.
Description
Only scsi transparent is supported.
5.9.7.5.2.3 USB_DEVICE_MSD_PROTOCOL Macro
C
#define USB_DEVICE_MSD_PROTOCOL 0x50
Description
MSD Interface Class Protocol Codes
5.9.7.5.2.4 USB_DEVICE_MSD_MEDIA_FUNCTIONS Structure
C
struct USB_DEVICE_MSD_MEDIA_FUNCTIONS {
SYS_STATUS (* mediaInitState)(SYS_MODULE_OBJ objIndex);
DRV_HANDLE (* open)(const SYS_MODULE_INDEX index, const DRV_IO_INTENT intent);
void (* close)(DRV_HANDLE hClient);
uint32_t (* readCapacity)(DRV_HANDLE drvHandle);
uint32_t (* readSectorSize)(DRV_HANDLE drvHandle);
bool (* mediaDetect)(DRV_HANDLE drvHandle);
bool (* sectorRead)(DRV_HANDLE drvHandle, uint32_t sector_addr, uint8_t * buffer, void *
refHandle, MEDIA_OP_CMPLT_CB callBack);
uint8_t (* writeProtectState)(DRV_HANDLE drvHandle);
bool (* sectorWrite)(DRV_HANDLE drvHandle, uint32_t sector_addr, uint8_t* buffer, void *
refHandle, MEDIA_OP_CMPLT_CB callBack);
};
Description
The user must provide the callback function address of the media at compile time. MSD driver calls these function during run
time to perform media operation or to know the media status.
5.9 USB Library Help MPLAB Harmony Help USB MSD Device Library
5-4175
Members
Members Description
SYS_STATUS (*
mediaInitState)(SYS_MODULE_OBJ
objIndex);
Media init state.
DRV_HANDLE (* open)(const
SYS_MODULE_INDEX index, const
DRV_IO_INTENT intent);
Function pointer to the MediaInitialize() function of the physical media being used.
void (* close)(DRV_HANDLE hClient); Function pointer for closing the physical media.
uint32_t (* readCapacity)(DRV_HANDLE
drvHandle);
Function pointer to the ReadCapacity() function of the physical media being used.
uint32_t (* readSectorSize)(DRV_HANDLE
drvHandle);
Function pointer to the ReadSectorSize() function of the physical media being
used.
bool (* mediaDetect)(DRV_HANDLE
drvHandle);
Function pointer to the MediaDetect() function of the physical media being used.
bool (* sectorRead)(DRV_HANDLE
drvHandle, uint32_t sector_addr, uint8_t *
buffer, void * refHandle,
MEDIA_OP_CMPLT_CB callBack);
Function pointer to the SectorRead() function of the physical media being used.
uint8_t (* writeProtectState)(DRV_HANDLE
drvHandle);
Function pointer to the WriteProtectState() function of the physical media being
used.
bool (* sectorWrite)(DRV_HANDLE
drvHandle, uint32_t sector_addr, uint8_t*
buffer, void * refHandle,
MEDIA_OP_CMPLT_CB callBack);
Function pointer to the SectorWrite() function of the physical media being used.
Remarks
None.
5.9.7.5.2.5 USB_DEVICE_MSD_INIT Structure
C
struct USB_DEVICE_MSD_INIT {
uint8_t numberOfLogicalUnits;
USB_DEVICE_MSD_MEDIA_INIT_DATA mediaInit[USB_DEVICE_MSD_MAX_LUN];
};
Description
USB MSD init structure.
This structure contains interface number, bulk-IN and bulk-OUT endpoint addresses, endpointSize, number of logical units
supported and pointer to array of structure that contains media initialization.
Members
Members Description
uint8_t numberOfLogicalUnits; Number of logical units supported.
USB_DEVICE_MSD_MEDIA_INIT_DATA
mediaInit[USB_DEVICE_MSD_MAX_LUN];
Media related data
Remarks
This structure must be configured by the user at compile time.
5.9 USB Library Help MPLAB Harmony Help USB MSD Device Library
5-4176
5.9.7.5.2.6 USB_DEVICE_MSD_INQUIRY_RESPONSE Structure
C
struct USB_DEVICE_MSD_INQUIRY_RESPONSE {
uint8_t peripheral;
uint8_t removable;
uint8_t version;
uint8_t responseDataFormat;
uint8_t additionalLength;
uint8_t sccstp;
uint8_t bqueetc;
uint8_t cmdQue;
uint8_t vendorID[8];
uint8_t productID[16];
uint8_t productRev[4];
};
Description
USB Device MSD inquiry response structure as defined in SCSI Primary Commands - 4.
Members
Members Description
uint8_t peripheral; Peripheral_Qualifier:3; Peripheral_DevType:5;
uint8_t removable; Removable medium bit7 = 0 means non removable, rest reserved
uint8_t version; Version
uint8_t responseDataFormat; b7,b6 Obsolete, b5 Access control co-ordinator, b4 hierarchical addressing
support b3:0 response data format 2 indicates response is in format defined by
spec
uint8_t additionalLength; length in bytes of remaining in standard inquiry data
uint8_t sccstp; b7 SCCS, b6 ACC, b5-b4 TGPS, b3 3PC, b2-b1 Reserved, b0 Protected
uint8_t bqueetc; b7 bque, b6- EncServ, b5-VS, b4-MultiP, b3-MChngr, b2-b1 Obsolete, b0-Addr16
uint8_t cmdQue; b7-b6 Obsolete, b5-WBUS, b4-Sync, b3-Linked, b2 Obsolete,b1 Cmdque, b0-VS
uint8_t vendorID[8]; Vendor ID
uint8_t productID[16]; Product ID
uint8_t productRev[4]; Product Revision
Remarks
None.
5.9.7.5.2.7 USB_DEVICE_MSD_MEDIA_INIT_DATA Structure
C
struct USB_DEVICE_MSD_MEDIA_INIT_DATA {
SYS_MODULE_INDEX instanceIndex;
USB_DEVICE_MSD_INQUIRY_RESPONSE inquiryResponse;
USB_DEVICE_MSD_MEDIA_FUNCTIONS mediaCallBackPtrs;
};
Description
It holds pointer to inquiry response, instance index and pointer to a structure that contains all media callback functions.
Members
Members Description
SYS_MODULE_INDEX instanceIndex; Instance index of the media
5.9 USB Library Help MPLAB Harmony Help USB MSD Device Library
5-4177
USB_DEVICE_MSD_INQUIRY_RESPONSE
inquiryResponse;
Pointer to inquiry response
USB_DEVICE_MSD_MEDIA_FUNCTIONS
mediaCallBackPtrs;
Callback function pointers of the media
Remarks
An object of this structure must be configured by the user at compile time.
5.9.7.6 Files
Files
Name Description
usb_device_msd.h USB device MSD function driver interface header
usb_device_msd_config_template.h usb device MSD configuration template header file
Description
5.9.7.6.1 usb_device_msd.h
USB MSD function driver interface header
USB device MSD function driver interface header
Macros
Name Description
USB_DEVICE_MSD_INTF MSD Interface Class Code
USB_DEVICE_MSD_INTF_SUBCLASS Only scsi transparent is supported.
USB_DEVICE_MSD_PROTOCOL MSD Interface Class Protocol Codes
Structures
Name Description
USB_DEVICE_MSD_INIT This structure contains required parameters for MSD initialization.
USB_DEVICE_MSD_INQUIRY_RESPONSE Inquiry response structure.
USB_DEVICE_MSD_MEDIA_FUNCTIONS This structure contains all the media driver callback function
pointers. The MSD driver makes call to these function pointers at run
time to know the status of the media and to read and write the media.
USB_DEVICE_MSD_MEDIA_INIT_DATA This structure holds media related data of a particular logical unit.
File Name
usb_device_msd.h
Company
Microchip Technology Inc.
5.9.7.6.2 usb_device_msd_config_template.h
USB device MSD function driver compile time options
This file contains USB device MSD function driver compile time options(macros) that has to be configured by the user. This file is
5.9 USB Library Help MPLAB Harmony Help USB MSD Device Library
5-4178
a template file and must be used as an example only. This file must not be directly included in the project.
Macros
Name Description
USB_DEVICE_MSD_MAX_INSTANCES This constant sets maximum possible number of instances of USB
device MSD function driver that can be instantiated by using
USB_DEVICE_MSD_Initialize() routine.
USB_DEVICE_MSD_MAX_LUN This constant sets maximum possible number of Logical Unit an
instance of MSD can support.
USB_DEVICE_MSD_MAX_SECTOR_SIZE This constant defines the max possible media sector size supported
by the MSD.
File Name
usb_device_msd_config_template.h
Company
Microchip Technology Incorported
5.9.8 USB Host Layer Library
5.9.8.1 Introduction
Introduces the MPLAB Harmony USB Host Library
Description
The USB Host layer library is part of USB Host stack that is available for the Microchip family of microcontrollers. This library
uses the USB Host Controller Driver to interact with the USB peripheral and therefore cannot operate independently of it. Within
the USB Host stack, the USB Host layer is responsible for enumeration the attached device, matching available class drivers and
maintaining the class drivers.
The USB Host layer library implementation adheres to USB Device Framework of chapter-9 of USB specification 2.0. In the USB
Host stack, the host layer features the following:
• Supports USB Low-Speed, Full-Speed, and Hi-Speed USB Devices
• Based on a modular and event driven architecture.
• Supports the PIC32MX and PIC32MZ families of microcontrollers
• Designed to support multiple device and multiple configurations
• Contains class driver to supports the following type of devices
• CDC
• MSD
• Supports non-blocking operation and is RTOS friendly
• Designed to integrate readily with other Harmony Middleware
• Supports both interrupt and polling operation
5.9 USB Library Help MPLAB Harmony Help USB Host Layer Library
5-4179
5.9.8.2 Release Notes
MPLAB Harmony Version: v0.70b USB Host Layer Library Version : 0.01 Alpha Release Date: 18Nov2013
New This Release:
This is the first release of the library. The interface can change in the beta and\or 1.0 release.
Known Issues:
• The host Stack has not been tested with a Real Time Operating System.
• Attach/Detach behavior has been tested in a limited capacity.
• The host stack only supports interrupt mode operation. Polled mode operation will be added in a future release.
• While running the host stack on PIC32MZ microcontroller, the stack requires 3 seconds to initialize. This is due to a hardware
issue with PIC32MZ USB module.
• MSD Host has been tested with a limited number of commercially available USB Flash Drives.
• MSD Host and the USB Host Layer have not been tested for read/write throughput. This will be done in a future release.
• Host stack has not been tested with low speed devices.
5.9.8.3 SW License Agreement
(c) 2013 Microchip Technology Inc.
Microchip licenses this software to you solely for use with Microchip products. The software is owned by Microchip and its
licensors, and is protected under applicable copyright laws. All rights reserved.
SOFTWARE IS PROVIDED "AS IS" MICROCHIP EXPRESSLY DISCLAIMS ANY WARRANTY OF ANY KIND, WHETHER
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. IN NO EVENT SHALL MICROCHIP BE LIABLE FOR
ANY INCIDENTAL, SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, HARM TO
YOUR EQUIPMENT, COST OF PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY OR SERVICES, ANY CLAIMS
BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), ANY CLAIMS FOR INDEMNITY OR
CONTRIBUTION, OR OTHER SIMILAR COSTS.
To the fullest extent allowed by law, Microchip and its licensors liability shall not exceed the amount of fees, if any, that you have
paid directly to Microchip to use this software.
MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE TERMS.
5.9.8.4 Library Interface
Data Types and Constants
Name Description
USB_HOST_HANDLE Handle identifying a client when calling Host layer client
functions.
USB_HOST_INIT Defines the data required to initialize a USB Host Layer
instance.
USB_HOST_HANDLE_INVALID Definition of an invalid USB Host Client Handle
5.9 USB Library Help MPLAB Harmony Help USB Host Layer Library
5-4180
USB_DEVICE_INFORMATION Defines the USB Device Information data strucutre.
USB_HOST_EVENT_CALLBACK USB Host Event Handler Function Pointer Type.
USB_HOST_EVENT_DATA_VBUS_REQUEST_POWER Defines the data returned along with the
USB_HOST_EVENT_VBUS_REQUEST_POWER
event.
USB_HOST_EVENT_RESPONSE USB Host Event Handler Response Type
USB_HOST_EVENTS Identifies the possible events that the host layer can
generate.
USB_HOST_TPL_FLAGS USB Host Layer Target Peripheral List Entry flags
TPL_MATCH_VID_PID This macro when used in the TPL table will direct the
Host Layer to match the corresponding class driver by
device vendor ID (VID) and product ID (PID).
USB_HOST_0 USB Host module index definitions
USB_HOST_1 This is macro USB_HOST_1.
USB_HOST_ENDPOINT_TABLE_SIZE USB Host Endpoint Table size needed while running the
host on PIC32MX devices.
USB_HOST_EVENT_RESPONSE_NONE USB Host Layer Event Handler Response Type None.
Functions
Name Description
USB_HOST_Close Closes an opened-instance of the USB Host Layer.
USB_HOST_Open Opens the specified Host Layer instance and returns a handle to it
USB_HOST_Deinitialize Deinitializes the specified instance of the USB Host Layer.
USB_HOST_DeviceInformationGet Returns select information about the attached device.
USB_HOST_DeviceIsResumed Checks if the attached USB device has been resumed.
USB_HOST_DeviceIsSuspended Checks if the attached USB device has been suspended.
USB_HOST_DeviceResume Resumes the USB.
USB_HOST_DeviceSuspend Suspends the USB.
USB_HOST_EventCallBackSet Allows a client to identify an event handling function for the host layer to call
back when host layer events are generated.
USB_HOST_Initialize Initializes the USB Host layer instance for the specified instance index.
USB_HOST_OperationDisable Disabled host operation.
USB_HOST_OperationEnable Enables host operation.
USB_HOST_OperationIsEnabled Allows the application to check if the host operation is enabled.
USB_HOST_Status Gets the current status of the USB Host Layer.
USB_HOST_Tasks Maintains the USB Host's state machine. It manages the USB Module driver
and responds to USB Module driver events.
Description
This section describes the Application Programming Interface (API) functions of the USB Host Layer
5.9.8.4.1 Functions
5.9.8.4.1.1 USB_HOST_Close Function
C
void USB_HOST_Close(
USB_HOST_HANDLE hostHandle
);
5.9 USB Library Help MPLAB Harmony Help USB Host Layer Library
5-4181
Description
This routine closes an opened-instance of the USB Host Layer, invalidating the handle.
Preconditions
The USB_HOST_Initialize routine must have been called for the specified USB Host Layer instance.
Parameters
Parameters Description
handle A valid open-instance handle, returned from the Host Layers's open routine
Returns
None
Remarks
After calling this routine, the handle passed in "handle" must not be used with any of the remaining driver routines. A new handle
must be obtained by calling USB_HOST_Open before the caller may use the driver again. This function is thread safe in a RTOS
application.
Usually there is no need for the driver client to verify that the Close operation has completed.
Example
USB_HOST_HANDLE handle; // Returned from USB_HOST_Open
USB_HOST_Close(handle);
5.9.8.4.1.2 USB_HOST_Open Function
C
USB_HOST_HANDLE USB_HOST_Open(
SYS_MODULE_INDEX index,
const DRV_IO_INTENT ioIntent
);
Description
This routine opens the specified Host Layer instance and provides a handle that must be provided to all other client-level
operations to identify the caller and the instance of the host layer. The host layer can be opened exclusively by a client by
specifying the ioIntent as DRV_IO_INTENT_EXCLUSIVE. Any other flag settings will not have an effect on clients interaction
with the host layer.
Preconditions
Function USB_HOST_Initialize must have been called before calling this function.
Parameters
Parameters Description
index Identifier for the object instance to be opened
intent can be DRV_IO_INTENT_EXCLUSIVE which allows a client to open the host
layer exclusively. Any other flags are ignored.
Returns
If successful, the routine returns a valid open-instance handle (a number identifying both the caller and the module instance).
If an error occurs, the return value is USB_HOST_HANDLE_INVALID. Error can occur
• if the number of client ojects allocated via USB_HOST_CLIENTS_NUMBER is
insufficient.
5.9 USB Library Help MPLAB Harmony Help USB Host Layer Library
5-4182
• if the client is trying to open the host layer but host layer has been opened
exclusively by another client.
• if the host layer instance being opened is not initialized or is
invalid.
Remarks
The handle returned is valid until the USB_HOST_Close routine is called. This routine will NEVER block waiting for hardware.
This function is thread safe in a RTOS application. It should not be called in an ISR.
Example
USB_HOST_HANDLE handle;
handle = USB_HOST_Open(USB_HOST_0, DRV_IO_INTENT_EXCLUSIVE);
if (USB_HOST_HANDLE_INVALID == handle)
{
// Unable to open the driver
// May be the driver is not initialized or the initialization
// is not complete.
}
5.9.8.4.1.3 USB_HOST_Deinitialize Function
C
void USB_HOST_Deinitialize(
SYS_MODULE_OBJ driverObject
);
Description
Deinitializes the specified instance of the USB Host Layer. This function will aslo deinitialize the USB Module driver and hence
stop all USB Host related operation on the bus. All internal data structures will be reset.
Preconditions
Function USB_HOST_Initialize should have been called before calling this function.
Parameters
Parameters Description
object USB Host layer object handle, returned from the USB_HOST_Initialize routine
Returns
None.
Remarks
Once the Initialize operation has been called, the Deinitialize operation must be called before the Initialize operation can be
called again. This routine will NEVER block waiting for hardware.
Example
SYS_MODULE_OBJ object; // Returned from USB_HOST_Initialize
SYS_STATUS status;
USB_HOST_Deinitialize(object);
status = USB_HOST_Status(object);
if (SYS_MODULE_DEINITIALIZED != status)
{
// Check again later if you need to know
// when the driver is deinitialized.
5.9 USB Library Help MPLAB Harmony Help USB Host Layer Library
5-4183
}
5.9.8.4.1.4 USB_HOST_DeviceInformationGet Function
C
USB_ERROR USB_HOST_DeviceInformationGet(
USB_HOST_HANDLE hostHandle,
uint8_t deviceAddress,
USB_DEVICE_INFORMATION * deviceInfo
);
Description
This function returns select information about the attached device. The application may use this information to update it display
or for other application purposes. The device information is returned in the deviceInformation data structure.
Preconditions
The USB_HOST_Initialize routine must have been called for the specified USB Host Layer instance.
Parameters
Parameters Description
handle A valid open-instance handle, returned from the Host Layers's open routine
address Address of the device.
deviceInformation pointer to a data structure where the device information will be stored
Returns
USB_ERROR_NONE - Function was successful. USB_ERROR_PARAMETER_INVALID - Device address or host handle is
invalid or deviceInformation pointer is NULL.
Remarks
None.
Example
USB_HOST_HANDLE handle; // Returned from USB_HOST_Open
USB_ERROR result;
USB_DEVICE_INFORMATION deviceInfo;
// Get informationa about attached device with address 2
result = USB_HOST_DeviceInformationGet(handle, 2, &deviceInfo);
if(USB_ERROR_NONE == result)
{
// Display the string descriptor of the attached device.
APP_PrintToDisplay(deviceInformation.stringDesciptor);
}
5.9.8.4.1.5 USB_HOST_DeviceIsResumed Function
C
bool USB_HOST_DeviceIsResumed(
USB_HOST_HANDLE hostHandle,
uint8_t deviceAddress
);
Description
This function checks if the attached USB device has been resumed. This function can be called after calling the
USB_HOST_DeviceResume() function to check if resume request has been completed.
5.9 USB Library Help MPLAB Harmony Help USB Host Layer Library
5-4184
Preconditions
The USB_HOST_Initialize routine must have been called for the specified USB Host Layer instance.
Parameters
Parameters Description
handle A valid open-instance handle, returned from the Host Layers's open routine
address Address of the device.
Returns
true - Device is resumed. false - Device is not resumed or device address or handle is invalid.
Remarks
In cases where the device is connected directly to the USB Module, the bus resume request will be serviced immediately. In
cases where the device is connected to the USB module via a hub, the application must call the
USB_HOST_DeviceIsResumed() function to check if the device has been resumed.
Example
USB_HOST_HANDLE handle; // Returned from USB_HOST_Open
USB_ERROR result;
// Resume the device with address 2
result = USB_HOST_DeviceResume(handle, 2);
if(USB_ERROR_NONE == result)
{
// Wait till device is resumed.
while(!USB_HOST_DeviceIsResumed(handle, 2));
}
5.9.8.4.1.6 USB_HOST_DeviceIsSuspended Function
C
bool USB_HOST_DeviceIsSuspended(
USB_HOST_HANDLE hostHandle,
uint8_t deviceAddress
);
Description
This function checks if the attached USB device has been suspended. This function can be called after calling the
USB_HOST_DeviceSuspend() function to check if suspend request has been completed.
Preconditions
The USB_HOST_Initialize routine must have been called for the specified USB Host Layer instance.
Parameters
Parameters Description
handle A valid open-instance handle, returned from the Host Layers's open routine
address Address of the device.
Returns
true - Device is suspended. false - Device is not suspended or device address or handle is invalid.
Remarks
In cases where the device is connected directly to the USB Module, the bus suspend request will be serviced immediately. In
cases where the device is connected to the USB module via a hub, the application must call the
USB_HOST_DeviceIsSuspended() function to check if the device has been suspended.
5.9 USB Library Help MPLAB Harmony Help USB Host Layer Library
5-4185
Example
USB_HOST_HANDLE handle; // Returned from USB_HOST_Open
USB_ERROR result;
// Suspend the device with address 2
result = USB_HOST_Device(handle, 2);
if(USB_ERROR_NONE == result)
{
// Wait till device is suspended.
while(!USB_HOST_DeviceIsSuspended(handle, 2));
}
5.9.8.4.1.7 USB_HOST_DeviceResume Function
C
USB_ERROR USB_HOST_DeviceResume(
USB_HOST_HANDLE hostHandle,
uint8_t deviceAddress
);
Description
The function resumes the USB. If address is an address of a device that is connected directly to the USB module, this function
will directly resume the bus. If the address is an address of a device that is connected to the module via a hub, the USB Host
layer will resume the hub port to which this device is connected. The function only places a request to resume the device. The
application must use the USB_HOST_DeviceIsResumeed() function to check if the device resume is complete.
Preconditions
The USB_HOST_Initialize routine must have been called for the specified USB Host Layer instance.
Parameters
Parameters Description
handle A valid open-instance handle, returned from the Host Layers's open routine
address Address of the device.
Returns
USB_ERROR_NONE - The request was accepted successfully. USB_ERROR_PARAMETER_INVALID - The device address or
handle is invalid.
Remarks
In cases where the device is connected directly to the USB Module, the bus resume request will be serviced immediately. In
cases where the device is connected to the USB module via a hub, the application must call the
USB_HOST_DeviceIsResumed() function to check if the device has been resumed.
Example
USB_HOST_HANDLE handle; // Returned from USB_HOST_Open
USB_ERROR result;
// Resume the device with address 2
result = USB_HOST_Device(handle, 2);
if(USB_ERROR_NONE == result)
{
// Wait till device is resumed.
while(!USB_HOST_DeviceIsResumed(handle, 2));
}
5.9 USB Library Help MPLAB Harmony Help USB Host Layer Library
5-4186
5.9.8.4.1.8 USB_HOST_DeviceSuspend Function
C
USB_ERROR USB_HOST_DeviceSuspend(
USB_HOST_HANDLE hostHandle,
uint8_t deviceAddress
);
Description
The function suspends the USB. If address is an address of a device that is connected directly to the USB module, this function
will directly suspend the bus. If the address is an address of a device that is connected to the module via a hub, the USB Host
layer will suspend the hub port to which this device is connected. The function only places a request to suspend the device. The
application must use the USB_HOST_DeviceIsSuspended() function to check if the device suspend is complete.
Preconditions
The USB_HOST_Initialize routine must have been called for the specified USB Host Layer instance.
Parameters
Parameters Description
handle A valid open-instance handle, returned from the Host Layers's open routine
address Address of the device.
Returns
USB_ERROR_NONE - The request was accepted successfully. USB_ERROR_PARAMETER_INVALID - The device address or
handle is invalid.
Remarks
In cases where the device is connected directly to the USB Module, the bus suspend request will be serviced immediately. In
cases where the device is connected to the USB module via a hub, the application must call the
USB_HOST_DeviceIsSuspended() function to check if the device has been suspended.
Example
USB_HOST_HANDLE handle; // Returned from USB_HOST_Open
USB_ERROR result;
// Suspend the device with address 2
result = USB_HOST_Device(handle, 2);
if(USB_ERROR_NONE == result)
{
// Wait till device is suspended.
while(!USB_HOST_DeviceIsSuspended(handle, 2));
}
5.9.8.4.1.9 USB_HOST_EventCallBackSet Function
C
USB_ERROR USB_HOST_EventCallBackSet(
USB_HOST_HANDLE hostHandle,
USB_HOST_EVENT_CALLBACK callback,
uintptr_t context
);
Description
This function allows a client to identify an event handling function for the host layer to call back when host layer events are
generated.
5.9 USB Library Help MPLAB Harmony Help USB Host Layer Library
5-4187
The event handler should be set before the client the host layer operation is enabled. The event handler once set, persists until
the client closes the driver or sets another event handler.
Preconditions
The USB_HOST_Initialize routine must have been called for the specified Host Layer instance.
USB_HOST_Open must have been called to obtain a valid opened Host Layer handle.
Parameters
Parameters Description
handle A valid open-instance handle, returned from the host layer's open routine
callback Pointer to the event handler function.
context The value of parameter will be passed back to the client unchanged, when the
eventHandler function is called. It can be used to identify any client specific data
object that identifies the instance of the client module (for example, it may be a
pointer to the client module's state structure).
Returns
USB_ERROR_NONE - Callback function was registered successfully. USB_ERROR_PARAMETER_INVALID - Callback
function was NULL or hostHandle is invalid.
Remarks
None.
Example
// myAppObj is an application specific state data object.
MY_APP_OBJ myAppObj;
USB_HOST_HANDLE usbHostHandle;
// usbHostHandle is the handle returned
// by the USB_HOST_Open function.
// Client registers an event handler with host layer.
USB_HOST_EventCallBackSet( usbHostHandle, APP_USBHostEventHandler,
(uintptr_t)&myAppObj );
USB_HOST_EVENT_RESPONSE APP_USBHostEventHandler(uintptr_t context,
USB_HOST_EVENTS event, void * eventData)
{
switch(event)
{
case USB_HOST_EVENT_UNSUPPORTED_DEVICE:
break;
...
}
return(USB_HOST_EVENT_RESPONSE_NONE);
}
5.9.8.4.1.10 USB_HOST_Initialize Function
C
SYS_MODULE_OBJ USB_HOST_Initialize(
const SYS_MODULE_INDEX index,
const SYS_MODULE_INIT * init
);
5.9 USB Library Help MPLAB Harmony Help USB Host Layer Library
5-4188
Description
This routine initializes the USB Host Layer instance for the specified instance index, making it ready for clients to open and use
it. The initialization data is specified by the init parameter. The intialization may fail if the number of host layer objects allocated
are insufficient or if the specificed host layer instance is already initialized. This function also initializes the USB Module driver for
host mode operation. The init data structure thus contains information required for driver initialization. Note that initializing the
Host Layer does not enable its operations. This must be done using USB_HOST_OperationEnable() function.
Preconditions
None.
Parameters
Parameters Description
index Identifier for the instance to be initialized
init Pointer to a USB_HOST_INIT data structure containing data necessary to initialize
the driver.
Returns
If successful, returns a valid handle to a driver instance object. Otherwise, returns SYS_MODULE_OBJ_INVALID.
Remarks
This routine must be called before any other USB Host routine is called.
This routine should only be called once during system initialization unless USB_HOST_Deinitialize is called to de-initialize the
Host Layer instance. This routine will NEVER block for hardware access.
Example
// Initializes the host layer for use with PIC32MX devices.
// We assume that the TPL table is already created and has two
// entries.
USB_HOST_TARGET_PERIPHERAL_LIST * tplTable;
USB_HOST_INIT usbHostInit;
SYS_MODULE_OBJ objectHandle;
// Allocate an endpoint table
uint8_t __attribute__((aligned(512))) endpointTable[USB_HOST_ENDPOINT_TABLE_SIZE];
usbHostInit.moduleInit = SYS_MODULE_POWER_RUN_FULL;
// The usbID member of the USB_HOST_INIT data structure
// should be USB_ID_x for PIC32MX devices and should be
// USBHS_ID_x PIC32MZ devices. Typical values are USB_ID_1
// for PIC32MX and USBHS_ID_0 for PIC32MZ devices.
usbHostInit.usbID = USB_ID_1; //for PIC32MX devices
usbHostInit.stopInIdle = false;
usbHostInit.suspendInSleep = false;
usbHostInit.endpointTable = endpointTable;
usbHostInit.interruptSource = INT_SOURCE_USB_1;
usbHostInit.nTPLEntries = 2
usbHostInit.usbSpeed = USB_SPEED_FULL;
usbHostInit.tplTable = tplTable;
objectHandle = USB_HOST_Initialize(USB_HOST_0, (SYS_MODULE_INIT*)usbHostInit);
if (SYS_MODULE_OBJ_INVALID == objectHandle)
{
// Handle error
}
5.9 USB Library Help MPLAB Harmony Help USB Host Layer Library
5-4189
5.9.8.4.1.11 USB_HOST_OperationDisable Function
C
void USB_HOST_OperationDisable(
USB_HOST_HANDLE hostHandle
);
Description
The function disables host operation. Disabling the host operation will cause the host to ignore attached device. All bus
communication will be halted and USB bus will be suspended.
Preconditions
The USB_HOST_Initialize routine must have been called for the specified USB Host Layer instance.
Parameters
Parameters Description
handle A valid open-instance handle, returned from the Host Layers's open routine
Returns
None
Remarks
This function may not be used in a typical USB Host application. One possible use could be in a case where a fatal system error
has occurred. Once disabled, the Host operation must be enabled again using the USB_HOST_OperationEnable() function.
Example
USB_HOST_HANDLE handle; // Returned from USB_HOST_Open
// Enabled host operation
USB_HOST_OperationDisable(handle);
5.9.8.4.1.12 USB_HOST_OperationEnable Function
C
void USB_HOST_OperationEnable(
USB_HOST_HANDLE hostHandle
);
Description
The function enables host operation. When enabled, the host layer can detect and enumerate attached devices. The application
must call the USB_HOST_OperationIsEnabled() function to check if the operation has completed.
Preconditions
The USB_HOST_Initialize routine must have been called for the specified USB Host Layer instance.
Parameters
Parameters Description
handle A valid open-instance handle, returned from the Host Layers's open routine
Returns
None
Remarks
It is recommended that only on host layer client call this function. Multiple host layer clients calling this may cause indeterministic
behavior.
5.9 USB Library Help MPLAB Harmony Help USB Host Layer Library
5-4190
Example
USB_HOST_HANDLE handle; // Returned from USB_HOST_Open
// Enabled host operation
USB_HOST_OperationEnable(handle);
// Wait till host operation is enabled.
while(!USB_HOST_OperationIsEnabled(handle));
5.9.8.4.1.13 USB_HOST_OperationIsEnabled Function
C
bool USB_HOST_OperationIsEnabled(
USB_HOST_HANDLE hostHandle
);
Description
The function allows the application to check if the host operation is enabled. This function should be called after the
USB_HOST_OperationEnable() function is called to check if the operation has been enabled.
Preconditions
The USB_HOST_Initialize routine must have been called for the specified USB Host Layer instance.
Parameters
Parameters Description
handle A valid open-instance handle, returned from the Host Layers's open routine
Returns
None.
Remarks
None.
Example
USB_HOST_HANDLE handle; // Returned from USB_HOST_Open
// Enabled host operation
USB_HOST_OperationEnable(handle);
// Wait till host operation is enabled.
while(!USB_HOST_OperationIsEnabled(handle));
5.9.8.4.1.14 USB_HOST_Status Function
C
SYS_STATUS USB_HOST_Status(
SYS_MODULE_OBJ driverObject
);
Description
This routine provides the current status of the USB Host Layer.
Preconditions
Function USB_HOST_Initialize should have been called before calling this function.
5.9 USB Library Help MPLAB Harmony Help USB Host Layer Library
5-4191
Parameters
Parameters Description
object USB Host Layer object handle, returned from the USB_HOST_Initialize routine
Returns
SYS_STATUS_READY - Indicates that the USB Host layer is ready for operations.
SYS_STATUS_DEINITIALIZED - Indicates that the driver has been de-initialized
Remarks
None.
Example
SYS_MODULE_OBJ object; // Returned from USB_HOST_Initialize
SYS_STATUS status;
status = USB_HOST_Status(object);
if (SYS_STATUS_READY == status)
{
// This means the driver can be opened using the
// USB_HOST_Open() function.
}
5.9.8.4.1.15 USB_HOST_Tasks Function
C
void USB_HOST_Tasks(
SYS_MODULE_OBJ driverObject
);
Description
This routine maintains the USB Host layer's state machine. It manages and the USB Module driver and responds to USB module
driver events. This function should be called from the SYS_Tasks() function.
Preconditions
The USB_HOST_Initialize routine must have been called for the specified USB Host Layer instance.
Parameters
Parameters Description
object Object handle for the specified driver instance (returned from
USB_HOST_Initialize)
Returns
None.
Remarks
This routine is normally not called directly by an application.
Example
SYS_MODULE_OBJ object; // Returned from USB_HOST_Initialize
while (true)
{
USB_HOST_Tasks (object);
// Do other tasks
}
5.9 USB Library Help MPLAB Harmony Help USB Host Layer Library
5-4192
5.9.8.4.2 Data Types and Constants
5.9.8.4.2.1 USB_HOST_HANDLE Type
C
typedef uintptr_t USB_HOST_HANDLE;
Description
USB Host Client Handle
A USB Host Client Handle is returned by a call to the USB_HOST_Open() function. The handle maintains the relationship
between USB Host Layer and its client. All USB Host Client functions required the client handle to be specified when the
functions are called. A client handle is valid till the the client calls the USB_HOST_Close() function at which point it becomes
invalid.
Remarks
None.
5.9.8.4.2.2 USB_HOST_INIT Structure
C
typedef struct {
SYS_MODULE_INIT moduleInit;
uint8_t usbID;
bool stopInIdle;
bool suspendInSleep;
void * endpointTable;
INT_SOURCE interruptSource;
unsigned int nTPLEntries;
USB_SPEED usbSpeed;
USB_HOST_TARGET_PERIPHERAL_LIST * tplList;
} USB_HOST_INIT;
Description
USB Host Intialization Data Structure
This data type defines the data required to initialize an USB Host Layer Instance. A pointer to a structure of this type is required
by the USB_HOST_Initialize() function.
Members
Members Description
SYS_MODULE_INIT moduleInit; System Module Initialization data
uint8_t usbID; Identifies the Peripheral Library ID of the USB Peripheral to be used by this
instance of the host layer
bool stopInIdle; Identifies the Idle mode behavior. If true the USB module will stop when the
microcontroller enter IDLE mode
bool suspendInSleep; If true, the USB module will automatically suspend when the the microcontroller
enter sleep mode
void * endpointTable; Pointer to an endpoint table whose size should be
USB_HOST_ENDPOINT_TABLE_SIZE number of bytes.
INT_SOURCE interruptSource; Interrupt Peripheral Library ID of the interrupt source of USB module which this
Host layer will control
unsigned int nTPLEntries; Number of entries in the TPL table
5.9 USB Library Help MPLAB Harmony Help USB Host Layer Library
5-4193
USB_SPEED usbSpeed; Speed at which the module should operate
USB_HOST_TARGET_PERIPHERAL_LIST
* tplList;
Pointer to the TPL table
Remarks
Intentionally defined to be empty.
5.9.8.4.2.3 USB_HOST_HANDLE_INVALID Macro
C
#define USB_HOST_HANDLE_INVALID
Description
USB Host Invalid Client Handle
This is the definition of an invalid USB Host Client Handle. An invalid client handle is returned by the USB_HOST_Open()
function when it was not able to open the USB Host Layer successfully.
Remarks
None.
5.9.8.4.2.4 USB_DEVICE_INFORMATION Structure
C
typedef struct {
uint16_t vid;
uint16_t pid;
uint16_t stringDescriptor[USB_HOST_DEVICE_INFORMATION_STRING_LENGTH];
} USB_DEVICE_INFORMATION;
Description
USB Device Information Structure
This data type defines the USB Device information data structure. This data structure is passed to
USB_HOST_DeviceInformationGet() function to obtain specific information about the device. The application can use this
information to update its display or for other purposes. When processed by the USB_HOST_DeviceInformationGet() function, the
stringDesciptor member of this data structure will contain a NULL terminated string descriptor string in UTF-16 format. The vid
and pid members of the data structure will be populated with VID and PID of the attached device respectively.
Members
Members Description
uint16_t vid; VID of the attached device
uint16_t pid; PID of the attached device
uint16_t
stringDescriptor[USB_HOST_DEVICE_INFORMATION_STRING_LENGTH];
String desciptor string in UTF-16 format. The
string when returned by
USB_HOST_DeviceInformationGet() function will
be NULL terminated.
Remarks
None.
5.9 USB Library Help MPLAB Harmony Help USB Host Layer Library
5-4194
5.9.8.4.2.5 USB_HOST_EVENT_CALLBACK Type
C
typedef USB_HOST_EVENT_RESPONSE (* USB_HOST_EVENT_CALLBACK)(USB_HOST_EVENTS event, void *
eventData, uintptr_t context);
Description
USB Host Event Handler Function Pointer Type.
This data type defines the required function signature of the USB Host Layer event handling callback function. The application
must register a pointer to a USB Host Event handling function who's function signature (parameter and return value types) match
the types specified by this function pointer in order to receive event call backs from the USB Host Layer. The function driver will
invoke this function with event relevant parameters. The description of the event handler function parameters is given here.
event - Type of event generated.
eventData - This parameter should be type casted to a event specific pointer type based on the event that has occurred. Refer to
the USB_HOST_EVENTS enumeration description for more details.
context - Value identifying the context of the application that registered the event handling function.
Remarks
None.
5.9.8.4.2.6 USB_HOST_EVENT_DATA_VBUS_REQUEST_POWER Structure
C
typedef struct {
uint8_t port;
uint8_t current;
} USB_HOST_EVENT_DATA_VBUS_REQUEST_POWER;
Description
USB Host VBUS Power Request Event Data Structure
This data type defines the data returned along with the USB_HOST_EVENT_VBUS_REQUEST_POWER event.
Members
Members Description
uint8_t port; Port where the device is connected
uint8_t current; Current (in 2mA units) that the device is requesting
Remarks
None.
5.9.8.4.2.7 USB_HOST_EVENT_RESPONSE Type
C
typedef void USB_HOST_EVENT_RESPONSE;
Description
USB Host Event Handler Response Type
This is the return type of the USB Host Layer Event Handler
5.9 USB Library Help MPLAB Harmony Help USB Host Layer Library
5-4195
Remarks
None.
5.9.8.4.2.8 USB_HOST_EVENTS Enumeration
C
typedef enum {
USB_HOST_EVENT_VBUS_REQUEST_POWER,
USB_HOST_EVENT_UNSUPPORTED_DEVICE,
USB_HOST_EVENT_CANNOT_ENUMERATE
} USB_HOST_EVENTS;
Description
USB Host Events
This enumeration identifies the possible events that the host layer can generate. A Host Layer client should register an event
handler using the USB_HOST_EventCallBackSet() function to receive host layer events. An event may have data associated
with it. The event description before provides details of such cases.
Members
Members Description
5.9.8.4.2.9 USB_HOST_TPL_FLAGS Enumeration
C
typedef enum {
TPL_FLAG_VID_PID = 0x1,
TPL_FLAG_CLASS_SUBCLASS_PROTOCOL = 0x2
} USB_HOST_TPL_FLAGS;
Description
USB Host Layer TPL Table Entry Flags
This type defines the possible flags that can be used when adding an entry into the TPL table. Using the TPL_FLAG_VID_PID
will direct the host layer to match the class driver to the attached device based on the device Vendor ID and the Product ID.
Using the TPL_FLAG_CLASS_SUBCLASS_PROTOCOL will direct the host layer to match the class driver to the attached
device based on the device class, subclass and protocol fields.
Members
Members Description
TPL_FLAG_VID_PID = 0x1 Match by VID and PID
TPL_FLAG_CLASS_SUBCLASS_PROTOCOL
= 0x2
Match by Class, Subclass and Protocol
Remarks
None.
5.9.8.4.2.10 TPL_MATCH_VID_PID Macro
C
#define TPL_MATCH_VID_PID(vid,pid)
Description
USB Host Class Driver Match by VID and PID
5.9 USB Library Help MPLAB Harmony Help USB Host Layer Library
5-4196
This macro when used in the TPL table will direct the Host Layer to match the corresponding class driver by device vendor ID
and product ID. The applicaton must set the device member of the TPL table entry to this macro is order to match the attached
device to the class driver by device Vendor ID and Product ID.
Remarks
None.
5.9.8.4.2.11 USB_HOST_0 Macro
C
#define USB_HOST_0 0
Description
Driver USB Host Module Index
These constants provide USB Host index definitions.
Remarks
These constants should be used in place of hard-coded numeric literals. These values should be passed into the
USB_HOST_Initialize() and USB_HOST_Open() routines to identify the host layer instance in use.
5.9.8.4.2.12 USB_HOST_1 Macro
C
#define USB_HOST_1 1
Description
This is macro USB_HOST_1.
5.9.8.4.2.13 USB_HOST_ENDPOINT_TABLE_SIZE Macro
C
#define USB_HOST_ENDPOINT_TABLE_SIZE
Description
USB Host Endpoint Table Size
This macro defines the USB Endpoint Table size while running the host layer on PIC32MX devices. The application should
allocate a uint8_t type array of this size. The array should be aligned at a 512 byte boundary.
Remarks
None.
5.9.8.4.2.14 USB_HOST_EVENT_RESPONSE_NONE Macro
C
#define USB_HOST_EVENT_RESPONSE_NONE
Description
USB Host Layer Event Handler Response None
This is the definition of the USB Host Layer Event Handler Response Type None.
5.9 USB Library Help MPLAB Harmony Help USB Host Layer Library
5-4197
Remarks
Intentionally defined to be empty.
5.9.8.5 Files
Files
Name Description
usb_host.h USB HOST Layer Interface Header
Description
5.9.8.5.1 usb_host.h
USB Host Layer Interface Definition
This header file contains the function prototypes and definitions of the data types and constants that make up the interface to the
USB HOST layer.
Enumerations
Name Description
USB_HOST_EVENTS Identifies the possible events that the host layer can generate.
USB_HOST_TPL_FLAGS USB Host Layer Target Peripheral List Entry flags
Functions
Name Description
USB_HOST_Close Closes an opened-instance of the USB Host Layer.
USB_HOST_Deinitialize Deinitializes the specified instance of the USB Host Layer.
USB_HOST_DeviceInformationGet Returns select information about the attached device.
USB_HOST_DeviceIsResumed Checks if the attached USB device has been resumed.
USB_HOST_DeviceIsSuspended Checks if the attached USB device has been suspended.
USB_HOST_DeviceResume Resumes the USB.
USB_HOST_DeviceSuspend Suspends the USB.
USB_HOST_EventCallBackSet Allows a client to identify an event handling function for the host layer to call
back when host layer events are generated.
USB_HOST_Initialize Initializes the USB Host layer instance for the specified instance index.
USB_HOST_Open Opens the specified Host Layer instance and returns a handle to it
USB_HOST_OperationDisable Disabled host operation.
USB_HOST_OperationEnable Enables host operation.
USB_HOST_OperationIsEnabled Allows the application to check if the host operation is enabled.
USB_HOST_Status Gets the current status of the USB Host Layer.
USB_HOST_Tasks Maintains the USB Host's state machine. It manages the USB Module driver
and responds to USB Module driver events.
5.9 USB Library Help MPLAB Harmony Help USB Host Layer Library
5-4198
Macros
Name Description
TPL_MATCH_VID_PID This macro when used in the TPL table will direct the Host Layer to
match the corresponding class driver by device vendor ID (VID) and
product ID (PID).
USB_HOST_0 USB Host module index definitions
USB_HOST_1 This is macro USB_HOST_1.
USB_HOST_ENDPOINT_TABLE_SIZE USB Host Endpoint Table size needed while running the host on
PIC32MX devices.
USB_HOST_EVENT_RESPONSE_NONE USB Host Layer Event Handler Response Type None.
USB_HOST_HANDLE_INVALID Definition of an invalid USB Host Client Handle
Structures
Name Description
USB_DEVICE_INFORMATION Defines the USB Device Information data strucutre.
USB_HOST_EVENT_DATA_VBUS_REQUEST_POWER Defines the data returned along with the
USB_HOST_EVENT_VBUS_REQUEST_POWER
event.
USB_HOST_INIT Defines the data required to initialize a USB Host Layer
instance.
Types
Name Description
USB_HOST_EVENT_CALLBACK USB Host Event Handler Function Pointer Type.
USB_HOST_EVENT_RESPONSE USB Host Event Handler Response Type
USB_HOST_HANDLE Handle identifying a client when calling Host layer client functions.
File Name
usb_host.h
Company
Microchip Technology Incorported
5.9.9 USB CDC Host Library
5.9.9.1 Introduction
Introduces the MPLAB Harmony USB Host CDC Class Driver Library
Description
The USB Host CDC Class Driver library is a part of the USB Host stack that is available for Microchip family of microcontrollers.
This library uses the USB Host Layer to interact with the attached USB CDC device and therefore cannot operate independently
of it. Within the USB Host stack, the CDC Class Driver library is responsible for providing the host application with access to the
functionality of the attached CDC Device.
5.9 USB Library Help MPLAB Harmony Help USB CDC Host Library
5-4199
The USB Host CDC Class Driver library implementation adheres to revision 1.2 of the USB CDC Specification release. The USB
Host CDC Class Driver provides the following features:
• Support CDC-ACM devices.
• Abstracts CDC function interface details from the application and provides a clear interface to device functions.
• Provides functions to send commands such as Set Line Coding , Get Line Coding to the attached CDC Device.
• Provides functions to read and write data and request serial line notification from the device.
• Generates bus related events to user application and class drivers.
• Provides events to indicate completion and status of class driver functions.
5.9.9.2 Release Notes
MPLAB Harmony Version: v0.70b USB CDC Host Library Version : 0.01 Alpha Release Date: 18Nov2013
New This Release:
This is the first release of the library. The interface can change in the beta and\or 1.0 release.
Known Issues:
Nothing to report in this release.
5.9.9.3 SW License Agreement
(c) 2013 Microchip Technology Inc.
Microchip licenses this software to you solely for use with Microchip products. The software is owned by Microchip and its
licensors, and is protected under applicable copyright laws. All rights reserved.
SOFTWARE IS PROVIDED "AS IS" MICROCHIP EXPRESSLY DISCLAIMS ANY WARRANTY OF ANY KIND, WHETHER
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. IN NO EVENT SHALL MICROCHIP BE LIABLE FOR
ANY INCIDENTAL, SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, HARM TO
YOUR EQUIPMENT, COST OF PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY OR SERVICES, ANY CLAIMS
BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), ANY CLAIMS FOR INDEMNITY OR
CONTRIBUTION, OR OTHER SIMILAR COSTS.
To the fullest extent allowed by law, Microchip and its licensors liability shall not exceed the amount of fees, if any, that you have
paid directly to Microchip to use this software.
MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE TERMS.
5.9.9.4 Library Interface
5.9 USB Library Help MPLAB Harmony Help USB CDC Host Library
5-4200
5.9.9.4.1 Functions
Functions
Name Description
USB_HOST_CDC_BreakSend This function sends a request to the attached to update it's break
duration.
USB_HOST_CDC_ControlLineStateSet This function sets the state of the control line connecting the host to
the device.
USB_HOST_CDC_EventHandlerSet This class registers a event handler for the specified CDC class
driver instance.
USB_HOST_CDC_LineCodingGet This function requests line coding from the attached CDC device.
USB_HOST_CDC_LineCodingSet This function sets the line coding of the attached CDC device.
USB_HOST_CDC_Read This function reads data from the attached CDC device.
USB_HOST_CDC_SerialStateNotificationGet This function requests serial state noitification data from the
attached CDC device.
USB_HOST_CDC_Write This function writes data to the attached CDC device.
Description
5.9.9.4.1.1 USB_HOST_CDC_BreakSend Function
C
USB_HOST_CDC_RESULT USB_HOST_CDC_BreakSend(
USB_HOST_CDC_INDEX index,
USB_HOST_CDC_TRANSFER_HANDLE * transferHandle,
uint16_t breakDuration
);
Description
This function sends a request to the attached to update it's break duration. The function schedules a SEND BREAK control
transfer. If successful, the transferHandle parameter will contain a valid transfer handle, else it will contain
USB_HOST_CDC_TRANSFER_HANDLE_INVALID. When completed, the CDC class driver will generate a
USB_HOST_CDC_EVENT_SEND_BREAK_COMPLETE event. The CDC Class driver does not support queuing of control
transfers. If a control transfer is in progress, this function will return with an error.
Preconditions
None.
Parameters
Parameters Description
index CDC Class Driver Instance Index where the request should be scheduled.
transferHandle Pointer to USB_HOST_CDC_TRANSFER_HANDLE type of a variable. This will
contain a valid transfer handle if the request was successful.
breakDuration Break duration.
Returns
USB_HOST_CDC_RESULT_OK - The operation was successful. transferHandle will contain a valid transfer handle.
USB_HOST_CDC_RESULT_ERROR_INSTANCE_INVALID - The specified instance does not exist.
USB_HOST_CDC_RESULT_ERROR_TRANSFER_QUEUE_FULL - Another control transfer is in progress and this transfer
cannot be scheduled. USB_HOST_CDC_RESULT_ERROR_INSTANCE_NOT_READY - The specified instance does not have
5.9 USB Library Help MPLAB Harmony Help USB CDC Host Library
5-4201
a CDC device associated with it. This can happen if the attached device was disconnected or the set request was called with an
CDC class driver instance that was not attached with a CDC device.
Remarks
None.
Example
// The following code snippet shows an example of scheduling a CDC Class
// Driver Control Line State Set Request.
USB_HOST_CDC_TRANSFER_HANDLE transferHandle;
USB_HOST_CDC_RESULT result;
uint16_t breakDuration;
result = USB_HOST_CDC_BreakSend(USB_HOST_CDC_0,
&transferHandle, breakDuration);
if(USB_HOST_CDC_RESULT_OK != result)
{
// Error handling here
}
// The completion of the set request can be tracked by using the
// USB_HOST_CDC_EVENT_SEND_BREAK_COMPLETE event.
5.9.9.4.1.2 USB_HOST_CDC_ControlLineStateSet Function
C
USB_HOST_CDC_RESULT USB_HOST_CDC_ControlLineStateSet(
USB_HOST_CDC_INDEX index,
USB_HOST_CDC_TRANSFER_HANDLE * transferHandle,
USB_CDC_CONTROL_LINE_STATE * controlLineState
);
Description
This function sets the state of the control line connecting the host to the device. The function schedules a SET CONTROL LINE
STATE control transfer. If successful, the transferHandle parameter will contain a valid transfer handle, else it will contain
USB_HOST_CDC_TRANSFER_HANDLE_INVALID. When completed, the CDC class driver will generate a
USB_HOST_CDC_EVENT_SET_CONTROL_LINE_STATE_COMPLETE event. The CDC Class driver does not support
queuing of control transfers. If a control transfer is in progress, this function will return with an error.
Preconditions
None.
Parameters
Parameters Description
index CDC Class Driver Instance Index where the request should be scheduled.
transferHandle Pointer to USB_HOST_CDC_TRANSFER_HANDLE type of a variable. This will
contain a valid transfer handle if the request was successful.
controlLineState pointer to the buffer containing control line state data to be sent to the device
Returns
USB_HOST_CDC_RESULT_OK - The operation was successful. transferHandle will contain a valid transfer handle.
USB_HOST_CDC_RESULT_ERROR_INSTANCE_INVALID - The specified instance does not exist.
USB_HOST_CDC_RESULT_ERROR_TRANSFER_QUEUE_FULL - Another control transfer is in progress and this transfer
cannot be scheduled. USB_HOST_CDC_RESULT_ERROR_INSTANCE_NOT_READY - The specified instance does not have
a CDC device associated with it. This can happen if the attached device was disconnected or the set request was called with an
5.9 USB Library Help MPLAB Harmony Help USB CDC Host Library
5-4202
CDC class driver instance that was not attached with a CDC device.
USB_HOST_CDC_RESULT_ERROR_PARAMETER_INVALID - The controlLineState buffer pointer is NULL.
Remarks
None.
Example
// The following code snippet shows an example of scheduling a CDC Class
// Driver Control Line State Set Request.
USB_HOST_CDC_TRANSFER_HANDLE transferHandle;
USB_HOST_CDC_RESULT result;
USB_CDC_HOST_CONTROL_LINE_STATE * buffer;
result = USB_HOST_CDC_ControlLineStateSet(USB_HOST_CDC_0,
&transferHandle, buffer);
if(USB_HOST_CDC_RESULT_OK != result)
{
// Error handling here
}
// The completion of the set request can be tracked by using the
// USB_HOST_CDC_EVENT_SET_CONTROL_LINE_STATE_COMPLETE event.
5.9.9.4.1.3 USB_HOST_CDC_EventHandlerSet Function
C
USB_HOST_CDC_RESULT USB_HOST_CDC_EventHandlerSet(
USB_HOST_CDC_INDEX index,
USB_HOST_CDC_EVENT_HANDLER eventHandler,
uintptr_t context
);
Description
This function registers an application event handler for the specified CDC class driver instance events. The event handler should
be registered before the host layer operation is enabled.
Preconditions
None.
Parameters
Parameters Description
instance Instance of the CDC Class Driver.
eventHandler A pointer to event handler function.
context Application specific context that is returned in the event handler.
Returns
USB_HOST_CDC_RESULT_OK - The operation was successful USB_HOST_CDC_RESULT_ERROR_INSTANCE_INVALID -
The specified instance does not exist. USB_HOST_CDC_RESULT_ERROR_PARAMETER_INVALID - The eventHandler
parameter is NULL
Remarks
None.
Example
// This code snippet shows an example of registering an event handler. Here
// the application specifies the context parameter as a pointer to an
5.9 USB Library Help MPLAB Harmony Help USB CDC Host Library
5-4203
// application object (appObject) that should be associated with this
// instance of the CDC class driver.
USB_HOST_CDC_RESULT result;
USB_HOST_CDC_EVENT_RESPONSE APP_USBHostCDCEventHandler
(
USB_HOST_CDC_INDEX instanceIndex ,
USB_HOST_CDC_EVENT event ,
void * event, uintptr_t context
)
{
// Event Handling comes here
switch(event)
{
...
}
return(USB_HOST_CDC_EVENT_RESPONSE_NONE);
}
result = USB_HOST_CDC_EventHandlerSet ( 0 ,&APP_EventHandler, (uintptr_t) &appObject);
if(USB_HOST_CDC_RESULT_OK != result)
{
SYS_ASSERT ( false , "invalid event handler class" );
}
5.9.9.4.1.4 USB_HOST_CDC_LineCodingGet Function
C
USB_HOST_CDC_RESULT USB_HOST_CDC_LineCodingGet(
USB_HOST_CDC_INDEX index,
USB_HOST_CDC_TRANSFER_HANDLE * transferHandle,
USB_CDC_LINE_CODING * lineCoding
);
Description
This function requests line coding from the attached CDC device. The function schedules a GET LINE CODING control transfer.
If successful, the transferHandle parameter will contain a valid transfer handle, else it will contain
USB_HOST_CDC_TRANSFER_HANDLE_INVALID. When completed, the CDC class driver will generate a
USB_HOST_CDC_EVENT_GET_LINE_CODING_COMPLETE event. When completed, the lineCoding parameter will contain
the line coding. The CDC Class driver does not support queuing of control transfers. If a control transfer is in progress, this
function will return with an error.
Preconditions
None.
Parameters
Parameters Description
index CDC Class Driver Instance Index where the request should be scheduled.
transferHandle Pointer to USB_HOST_CDC_TRANSFER_HANDLE type of a variable. This will
contain a valid transfer handle if the request was successful.
lineCoding pointer to the buffer where the line coding data will be stored.
Returns
USB_HOST_CDC_RESULT_OK - The operation was successful. transferHandle will contain a valid transfer handle.
USB_HOST_CDC_RESULT_ERROR_INSTANCE_INVALID - The specified instance does not exist.
5.9 USB Library Help MPLAB Harmony Help USB CDC Host Library
5-4204
USB_HOST_CDC_RESULT_ERROR_TRANSFER_QUEUE_FULL - Another control transfer is in progress and this transfer
cannot be scheduled. USB_HOST_CDC_RESULT_ERROR_INSTANCE_NOT_READY - The specified instance does not have
a CDC device associated with it. This can happen if the attached device was disconnected or the get request was called with an
CDC class driver instance that was not attached with a CDC device.
USB_HOST_CDC_RESULT_ERROR_PARAMETER_INVALID - The lineCoding buffer pointer is NULL.
Remarks
None.
Example
// The following code snippet shows an example of scheduling a CDC Class
// Driver Get Line Coding Request.
USB_HOST_CDC_TRANSFER_HANDLE transferHandle;
USB_HOST_CDC_RESULT result;
USB_CDC_LINE_CODING * buffer;
result = USB_HOST_CDC_LineCodingGet(USB_HOST_CDC_0,
&transferHandle, buffer);
if(USB_HOST_CDC_RESULT_OK != result)
{
// Error handling here
}
// The completion of the get request can be tracked by using the
// USB_HOST_CDC_EVENT_GET_LINE_CODING_COMPLETE event.
5.9.9.4.1.5 USB_HOST_CDC_LineCodingSet Function
C
USB_HOST_CDC_RESULT USB_HOST_CDC_LineCodingSet(
USB_HOST_CDC_INDEX index,
USB_HOST_CDC_TRANSFER_HANDLE * transferHandle,
USB_CDC_LINE_CODING * lineCoding
);
Description
This function sets the line coding of the attached CDC device. The function schedules a SET LINE CODING control transfer. If
successful, the transferHandle parameter will contain a valid transfer handle, else it will contain
USB_HOST_CDC_TRANSFER_HANDLE_INVALID. When completed, the CDC class driver will generate a
USB_HOST_CDC_EVENT_SET_LINE_CODING_COMPLETE event. The lineCoding parameter contain the line coding to be
sent to the attached device. The CDC Class driver does not support queuing of control transfers. If a control transfer is in
progress, this function will return with an error.
Preconditions
None.
Parameters
Parameters Description
index CDC Class Driver Instance Index where the request should be scheduled.
transferHandle Pointer to USB_HOST_CDC_TRANSFER_HANDLE type of a variable. This will
contain a valid transfer handle if the request was successful.
lineCoding pointer to the buffer containing line coding data to be sent to the device
Returns
USB_HOST_CDC_RESULT_OK - The operation was successful. transferHandle will contain a valid transfer handle.
5.9 USB Library Help MPLAB Harmony Help USB CDC Host Library
5-4205
USB_HOST_CDC_RESULT_ERROR_INSTANCE_INVALID - The specified instance does not exist.
USB_HOST_CDC_RESULT_ERROR_TRANSFER_QUEUE_FULL - Another control transfer is in progress and this transfer
cannot be scheduled. USB_HOST_CDC_RESULT_ERROR_INSTANCE_NOT_READY - The specified instance does not have
a CDC device associated with it. This can happen if the attached device was disconnected or the set request was called with an
CDC class driver instance that was not attached with a CDC device.
USB_HOST_CDC_RESULT_ERROR_PARAMETER_INVALID - The lineCoding buffer pointer is NULL.
Remarks
None.
Example
// The following code snippet shows an example of scheduling a CDC Class
// Driver Set Line Coding Request.
USB_HOST_CDC_TRANSFER_HANDLE transferHandle;
USB_HOST_CDC_RESULT result;
USB_CDC_LINE_CODING * buffer;
result = USB_HOST_CDC_LineCodingSet(USB_HOST_CDC_0,
&transferHandle, buffer);
if(USB_HOST_CDC_RESULT_OK != result)
{
// Error handling here
}
// The completion of the set request can be tracked by using the
// USB_HOST_CDC_EVENT_SET_LINE_CODING_COMPLETE event.
5.9.9.4.1.6 USB_HOST_CDC_Read Function
C
USB_HOST_CDC_RESULT USB_HOST_CDC_Read(
USB_HOST_CDC_INDEX index,
USB_HOST_CDC_TRANSFER_HANDLE * transferHandle,
void * destination,
size_t length
);
Description
This function reads data from the attached CDC device. The function will schedule a read transfer. If successful, the
transferHandle parameter will contain a valid transfer handle, else it will contain
USB_HOST_CDC_TRANSFER_HANDLE_INVALID. When completed, the CDC class driver will generate a
USB_HOST_CDC_EVENT_READ_COMPLETE event. Multiple read requests can be queued. In such a case, the transfer
handle for each request will be unique.
Preconditions
None.
Parameters
Parameters Description
index CDC Class Driver Instance Index where the request should be scheduled.
transferHandle Pointer to USB_HOST_CDC_TRANSFER_HANDLE type of a variable. This will
contain a valid transfer handle if the request was successful.
dest pointer to the buffer where the read data will be stored.
length Amount of data to read (in bytes).
5.9 USB Library Help MPLAB Harmony Help USB CDC Host Library
5-4206
Returns
USB_HOST_CDC_RESULT_OK - The operation was successful. transferHandle will contain a valid transfer handle.
USB_HOST_CDC_RESULT_ERROR_INSTANCE_INVALID - The specified instance does not exist.
USB_HOST_CDC_RESULT_ERROR_TRANSFER_QUEUE_FULL - The transfer queue is full and the requested transfer
cannot be scheduled. USB_HOST_CDC_RESULT_ERROR_INSTANCE_NOT_READY - The specified instance does not have
a CDC device associated with it. This can happen if the attached device was disconnected or the read function was called with
an CDC class driver instance that was not attached to a CDC device.
USB_HOST_CDC_RESULT_ERROR_PARAMETER_INVALID - The destination buffer pointer is NULL or the length parameter
is zero.
Remarks
None.
Example
// The following code snippet shows an example of scheduling a CDC Class
// Driver read. In this example, the class driver reads 64 bytes from the
// attached device.
USB_HOST_CDC_TRANSFER_HANDLE transferHandle;
USB_HOST_CDC_RESULT result;
uint8_t buffer[64];
result = USB_HOST_CDC_Read(USB_HOST_CDC_0, &transferHandle, buffer, 64);
if(USB_HOST_CDC_RESULT_OK != result)
{
// Error handling here
}
// The completion of the read request can be tracked by using the
// USB_HOST_CDC_EVENT_READ_COMPLETE.
5.9.9.4.1.7 USB_HOST_CDC_SerialStateNotificationGet Function
C
USB_HOST_CDC_RESULT USB_HOST_CDC_SerialStateNotificationGet(
USB_HOST_CDC_INDEX index,
USB_HOST_CDC_TRANSFER_HANDLE * transferHandle,
USB_HOST_CDC_SERIAL_STATE_NOTIFICATION_DATA * dest
);
Description
This function requests serial state noitification data from the attached CDC device. The function will schedule a read transfer
over the CDC notification interface. If successful, the transferHandle parameter will contain a valid transfer handle, else it will
contain USB_HOST_CDC_TRANSFER_HANDLE_INVALID. When completed, the CDC class driver will generate a
USB_HOST_CDC_EVENT_SERIAL_STATE_NOTIFICATION_RECEIVED event. Multiple get requests can be queued. In such
a case, the transfer handle for each request will be unique.
Preconditions
None.
Parameters
Parameters Description
index CDC Class Driver Instance Index where the request should be scheduled.
transferHandle Pointer to USB_HOST_CDC_TRANSFER_HANDLE type of a variable. This will
contain a valid transfer handle if the request was successful.
5.9 USB Library Help MPLAB Harmony Help USB CDC Host Library
5-4207
dest pointer to the buffer where the serial state notification data should be stored.
Returns
USB_HOST_CDC_RESULT_OK - The operation was successful. transferHandle will contain a valid transfer handle.
USB_HOST_CDC_RESULT_ERROR_INSTANCE_INVALID - The specified instance does not exist.
USB_HOST_CDC_RESULT_ERROR_TRANSFER_QUEUE_FULL - The transfer queue is full and the requested transfer
cannot be scheduled. USB_HOST_CDC_RESULT_ERROR_INSTANCE_NOT_READY - The specified instance does not have
a CDC device associated with it. This can happen if the attached device was disconnected or the get request was called with an
CDC class driver instance that was not attached with a CDC device.
USB_HOST_CDC_RESULT_ERROR_PARAMETER_INVALID - The source buffer pointer is NULL.
Remarks
None.
Example
// The following code snippet shows an example of scheduling a CDC Class
// Driver Serial State Notification Get function.
USB_HOST_CDC_TRANSFER_HANDLE transferHandle;
USB_HOST_CDC_RESULT result;
USB_HOST_CDC_SERIAL_STATE_NOTIFICATION_DATA * buffer;
result = USB_HOST_CDC_SerialStateNotificationGet(USB_HOST_CDC_0,
&transferHandle, buffer);
if(USB_HOST_CDC_RESULT_OK != result)
{
// Error handling here
}
// The completion of the get request can be tracked by using the
// USB_HOST_CDC_EVENT_SERIAL_STATE_NOTIFICATION_RECEIVED.
5.9.9.4.1.8 USB_HOST_CDC_Write Function
C
USB_HOST_CDC_RESULT USB_HOST_CDC_Write(
USB_HOST_CDC_INDEX index,
USB_HOST_CDC_TRANSFER_HANDLE * transferHandle,
void * source,
size_t length
);
Description
This function writes data to the attached CDC device. The function will schedule a write transfer. If successful, the
transferHandle parameter will contain a valid transfer handle, else it will contain
USB_HOST_CDC_TRANSFER_HANDLE_INVALID. When completed, the CDC class driver will generate a
USB_HOST_CDC_EVENT_WRITE_COMPLETE event. Multiple write requests can be queued. In such a case, the transfer
handle for each request will be unique.
Preconditions
None.
Parameters
Parameters Description
index CDC Class Driver Instance Index where the request should be scheduled.
5.9 USB Library Help MPLAB Harmony Help USB CDC Host Library
5-4208
transferHandle Pointer to USB_HOST_CDC_TRANSFER_HANDLE type of a variable. This will
contain a valid transfer handle if the request was successful.
source pointer to the buffer containing data to be written to the device.
length Amount of data to written (in bytes).
Returns
USB_HOST_CDC_RESULT_OK - The operation was successful. transferHandle will contain a valid transfer handle.
USB_HOST_CDC_RESULT_ERROR_INSTANCE_INVALID - The specified instance does not exist.
USB_HOST_CDC_RESULT_ERROR_TRANSFER_QUEUE_FULL - The transfer queue is full and the requested transfer
cannot be scheduled. USB_HOST_CDC_RESULT_ERROR_INSTANCE_NOT_READY - The specified instance does not have
a CDC device associated with it. This can happen if the attached device was disconnected or the write function was called with
an CDC class driver instance that was not attached to a CDC device.
USB_HOST_CDC_RESULT_ERROR_PARAMETER_INVALID - The source buffer pointer is NULL or the length parameter is
zero.
Remarks
None.
Example
// The following code snippet shows an example of scheduling a CDC Class
// Driver Write. In this example, the class driver writes 64 bytes to the
// attached device.
USB_HOST_CDC_TRANSFER_HANDLE transferHandle;
USB_HOST_CDC_RESULT result;
uint8_t buffer[64];
result = USB_HOST_CDC_Write(USB_HOST_CDC_0, &transferHandle, buffer, 64);
if(USB_HOST_CDC_RESULT_OK != result)
{
// Error handling here
}
// The completion of the write request can be tracked by using the
// USB_HOST_CDC_EVENT_WRITE_COMPLETE.
5.9.9.4.2 Data Types and Constants
Enumerations
Name Description
USB_HOST_CDC_EVENT Identifies the possible events that the CDC Class Driver can generate.
USB_HOST_CDC_RESULT USB Host CDC Class Driver CDC Result enumeration.
USB_HOST_CDC_TRANSFER_STATUS USB Host CDC Class Driver Transfer Status enumeration.
Macros
Name Description
USB_HOST_CDC_EVENT_RESPONSE_NONE USB Host CDC Class Driver Event Handler Response Type
None.
USB_HOST_CDC_TRANSFER_HANDLE_INVALID USB Host CDC Class Driver Invalid Transfer Handle
Definition.
5.9 USB Library Help MPLAB Harmony Help USB CDC Host Library
5-4209
Structures
Name Description
USB_HOST_CDC_EVENT_DATA_GET_LINE_CODING_COMPLETE USB Host CDC Class Driver
Event Data.
USB_HOST_CDC_EVENT_DATA_READ_COMPLETE USB Host CDC Class Driver
Event Data.
USB_HOST_CDC_EVENT_DATA_SEND_BREAK_COMPLETE USB Host CDC Class Driver
Event Data.
USB_HOST_CDC_EVENT_DATA_SERIAL_STATE_NOTIFICATION_RECEIVED USB Host CDC Class Driver
Event Data.
USB_HOST_CDC_EVENT_DATA_SET_CONTROL_LINE_STATE_COMPLETE USB Host CDC Class Driver
Event Data.
USB_HOST_CDC_EVENT_DATA_SET_LINE_CODING_COMPLETE USB Host CDC Class Driver
Event Data.
USB_HOST_CDC_EVENT_DATA_WRITE_COMPLETE USB Host CDC Class Driver
Event Data.
Types
Name Description
USB_HOST_CDC_TRANSFER_HANDLE USB Host CDC Class Driver Transfer Handle
USB_HOST_CDC_EVENT_HANDLER USB Host CDC Class Driver Event Handler Function
Pointer Type.
USB_HOST_CDC_EVENT_RESPONSE USB Host CDC Class Driver Event Callback
Response Type
USB_HOST_CDC_INDEX USB Host CDC Class Driver Index
USB_HOST_CDC_SERIAL_STATE_NOTIFICATION_DATA USB Host Serial State Notification Data Type.
USB_HOST_CDC_CONTROL_LINE_STATE USB Host Control Line State Data Type.
Description
5.9.9.4.2.1 USB_HOST_CDC_EVENT Enumeration
C
typedef enum {
USB_HOST_CDC_EVENT_READ_COMPLETE,
USB_HOST_CDC_EVENT_WRITE_COMPLETE,
USB_HOST_CDC_EVENT_SERIAL_STATE_NOTIFICATION_RECEIVED,
USB_HOST_CDC_EVENT_GET_LINE_CODING_COMPLETE,
USB_HOST_CDC_EVENT_SET_LINE_CODING_COMPLETE,
USB_HOST_CDC_EVENT_SET_CONTROL_LINE_STATE_COMPLETE,
USB_HOST_CDC_EVENT_SEND_BREAK_COMPLETE,
USB_HOST_CDC_EVENT_ATTACH,
USB_HOST_CDC_EVENT_DETACH
} USB_HOST_CDC_EVENT;
Description
CDC Class Driver Events
This enumeration identifies the possible events that the CDC Class Driver can generate. The application should register an event
handler using the USB_HOST_CDC_EventHandlerSet() function to receive CDC Class Driver events.
An event may have data associated with it. Events that are generated due to a transfer of data between the host and device are
accompanied by data structures that provide the status of the transfer termination. For example, the
5.9 USB Library Help MPLAB Harmony Help USB CDC Host Library
5-4210
USB_HOST_CDC_EVENT_SET_LINE_CODING_COMPLETE event is accompanied by a pointer to a
USB_HOST_CDC_EVENT_DATA_SET_LINE_CODING_COMPLETE data structure. The transferStatus member of this data
structure indicates the success or failure of the transfer. A transfer may fail due to device not responding on the bus, if the device
stalls any stages of the transfer or due to NAK timeouts. The event description provides details on the nature of the event and
the data that is associated with the event.
The following code snippet shows an example event handling scheme for
// This code snippet shows an example event handling scheme for
// CDC Class Driver events.
USB_HOST_CDC_EVENT_RESPONSE APP_USBHostCDCEventHandler
(
USB_HOST_CDC_INDEX index,
USB_HOST_CDC_EVENT event,
void * eventData,
uintptr_t context
)
{
uint8_t deviceAddress;
USB_HOST_CDC_EVENT_DATA_SET_LINE_CODING_COMPLETE * setLineCodingEventData;
USB_HOST_CDC_EVENT_DATA_GET_LINE_CODING_COMPLETE * getLineCodingEventData;
USB_HOST_CDC_EVENT_DATA_SET_CONTROL_LINE_STATE_COMPLETE * setControlLineStateEventData;
USB_HOST_CDC_EVENT_DATA_SEND_BREAK_COMPLETE * sendBreakEventData;
USB_HOST_CDC_EVENT_DATA_READ_COMPLETE * readCompleteEventData;
USB_HOST_CDC_EVENT_DATA_WRITE_COMPLETE * writeCompleteEventData;
USB_HOST_CDC_EVENT_DATA_SERIAL_STATE_NOTIFICATION_RECEIVED *
serialStateNotificationEventData;
switch(event)
{
case USB_HOST_CDC_EVENT_ATTACH:
// The event data in this case is the address of the
// attached device.
deviceAddress = (uint8_t *)eventData;
break;
case USB_HOST_CDC_EVENT_DETACH:
// This means the device was detached. There is no event data
// associated with this event.
break;
case USB_HOST_CDC_EVENT_SET_LINE_CODING_COMPLETE:
// This means the Set Line Coding request completed. We can
// find out if the request was successful.
setLineCodingEventData =
(USB_HOST_CDC_EVENT_DATA_SET_LINE_CODING_COMPLETE *)eventData;
if(setLineCodingEventData->transferStatus
== USB_HOST_CDC_TRANSFER_STATUS_ERROR)
{
// This means there transfer terminated because of an
// error.
}
break;
case USB_HOST_CDC_EVENT_GET_LINE_CODING_COMPLETE:
// This means the Get Line Coding request completed. We can
// find out if the request was successful.
5.9 USB Library Help MPLAB Harmony Help USB CDC Host Library
5-4211
getLineCodingEventData =
(USB_HOST_CDC_EVENT_DATA_GET_LINE_CODING_COMPLETE *)eventData;
if(getLineCodingEventData->transferStatus
== USB_HOST_CDC_TRANSFER_STATUS_ERROR)
{
// This means there transfer terminated because of an
// error.
}
case USB_HOST_CDC_EVENT_SET_CONTROL_LINE_STATE_COMPLETE:
// This means the Set Control Line State request completed. We can
// find out if the request was successful.
setControlLineStateEventData =
(USB_HOST_CDC_EVENT_DATA_SET_CONTROL_LINE_STATE_COMPLETE *)eventData;
if(setControlLineStateEventData->transferStatus
== USB_HOST_CDC_TRANSFER_STATUS_ERROR)
{
// This means there transfer terminated because of an
// error.
}
break;
case USB_HOST_CDC_EVENT_SEND_BREAK_COMPLETE:
// This means the Send Break request completed. We can
// find out if the request was successful.
sendBreakEventData =
(USB_HOST_CDC_EVENT_DATA_SEND_BREAK_COMPLETE *)eventData;
if(sendBreakEventData->transferStatus
== USB_HOST_CDC_TRANSFER_STATUS_ERROR)
{
// This means there transfer terminated because of an
// error.
}
break;
case USB_HOST_CDC_EVENT_WRITE_COMPLETE:
// This means the Write request completed. We can
// find out if the request was successful.
writeCompleteEventData =
(USB_HOST_CDC_EVENT_DATA_WRITE_COMPLETE *)eventData;
if(writeCompleteEventData->transferStatus
== USB_HOST_CDC_TRANSFER_STATUS_ERROR)
{
// This means there transfer terminated because of an
// error.
}
break;
case USB_HOST_CDC_EVENT_READ_COMPLETE:
// This means the Read request completed. We can
// find out if the request was successful.
readCompleteEventData =
(USB_HOST_CDC_EVENT_DATA_READ_COMPLETE *)eventData;
if(readCompleteEventData->transferStatus
== USB_HOST_CDC_TRANSFER_STATUS_ERROR)
{
// This means there transfer terminated because of an
5.9 USB Library Help MPLAB Harmony Help USB CDC Host Library
5-4212
// error.
}
break;
case USB_HOST_CDC_EVENT_SERIAL_STATE_NOTIFICATION_RECEIVED:
// This means the Serial State Notification request completed.
// We can find out if the request was successful.
serialStateNotificationEventData =
(USB_HOST_CDC_EVENT_DATA_SERIAL_STATE_NOTIFICATION_RECEIVED *)eventData;
if(serialStateNotificationEventData->transferStatus
== USB_HOST_CDC_TRANSFER_STATUS_ERROR)
{
// This means there transfer terminated because of an
// error.
}
break;
default:
break;
}
return(USB_HOST_CDC_EVENT_RESPONSE_NONE);
}
Members
Members Description
USB_HOST_CDC_EVENT_READ_COMPLETE This event occurs when a CDC Class Driver Read
operation has completed i.e when the data has
been received from the connected CDC device.
This event is generated after the application calls
the USB_HOST_CDC_Read() function. The
eventData parameter in the event call back function
will be of a pointer to a
USB_HOST_CDC_EVENT_DATA_READ_COMPL
ETE
structure. This contains details about the transfer
handle associated with this read request, the
amount of data read and the termination status of
the read request.
USB_HOST_CDC_EVENT_WRITE_COMPLETE This event occurs when a CDC Class Driver Write
operation has completed i.e when the data has
been written to the connected CDC device. This
event is generated after the application calls the
USB_HOST_CDC_Wrte() function. The eventData
parameter in the event call back function will be of a
pointer to a
USB_HOST_CDC_EVENT_DATA_WRITE_COMPL
ETE
structure. This contains details about the transfer
handle associated with this write request, the
amount of data written and the termination status of
the write request.
5.9 USB Library Help MPLAB Harmony Help USB CDC Host Library
5-4213
USB_HOST_CDC_EVENT_SERIAL_STATE_NOTIFICATION_RECEIVED This event occurs when a CDC Class Driver Serial
State Notification Get operation has completed.
This event is generated after the application calls
the USB_HOST_CDC_SerialStateNotificationGet()
and the device sends a serial state notification to
the host. The eventData parameter in the event call
back function will be of a pointer to a
USB_HOST_CDC_EVENT_DATA_SERIAL_STATE
_NOTIFICATION_RECEIVED
structure. This contains details about the transfer
handle associated with this request, the amount of
data received and the termination status of the get
request.
USB_HOST_CDC_EVENT_GET_LINE_CODING_COMPLETE This event occurs when a CDC Class Driver Get
Line Coding request has completed. This event is
generated after the application calls the
USB_HOST_CDC_LineCodingGet() function and
the device sends the line coding to the host. The
eventData parameter in the event call back function
will be of a pointer to a
USB_HOST_CDC_EVENT_DATA_GET_LINE_CO
DING_COMPLETE
structure. This contains details about the transfer
handle associated with this request, the amount of
data received and the termination status of the get
request.
USB_HOST_CDC_EVENT_SET_LINE_CODING_COMPLETE This event occurs when a CDC Class Driver Set
Line Coding request has completed. This event is
generated after the application calls the
USB_HOST_CDC_LineCodingSet() function and
the device either acknowledged or stalled the
request. The eventData parameter in the event call
back function will be of a pointer to a
USB_HOST_CDC_EVENT_DATA_SET_LINE_COD
ING_COMPLETE
structure. This contains details about the transfer
handle associated with this request, the amount of
data sent and the termination status of the set
request.
USB_HOST_CDC_EVENT_SET_CONTROL_LINE_STATE_COMPLETE This event occurs when a CDC Class Driver Set
Control Line State request has completed. This
event is generated after the application calls the
USB_HOST_CDC_ControlLineStateSet() function
and the device has either acknowledged or stalled
the request. The eventData parameter in the event
call back function will be of a pointer to a
USB_HOST_CDC_EVENT_DATA_SET_CONTROL
_LINE_STATE_COMPLETE
structure. This contains details about the transfer
handle associated with this request, the amount of
data sent and the termination status of the set
request.
5.9 USB Library Help MPLAB Harmony Help USB CDC Host Library
5-4214
USB_HOST_CDC_EVENT_SEND_BREAK_COMPLETE This event occurs when a CDC Class Driver Send
Break request has completed. This event is
generated after the application calls the
USB_HOST_CDC_BreakSend() function and the
device has either acknowledged or stalled the
request. The eventData parameter in the event call
back function will be of a pointer to a
USB_HOST_CDC_EVENT_DATA_SET_CONTROL
_LINE_STATE_COMPLETE
structure. This contains details about the transfer
handle associated with this request, the amount of
data sent and the termination status of the set
request.
USB_HOST_CDC_EVENT_ATTACH This event occurs when the host layer has
successfully attached the CDC Class Driver
instance to the attached USB CDC device. The
event also indicates that the class driver is fully
initialized and is ready to accept command and
data transfer requests from the application. The
eventData parameter should be interpreted as a
uint8_t pointer to the device address.
USB_HOST_CDC_EVENT_DETACH This event occurs when host layer has detached
the CDC class driver instance from a USB CDC
device. This can happen if the device itself was
detached, or if the device configuration was
changed. There is no event data associated with
this event.
Remarks
None.
5.9.9.4.2.2 USB_HOST_CDC_RESULT Enumeration
C
typedef enum {
USB_HOST_CDC_RESULT_OK,
USB_HOST_CDC_RESULT_ERROR_TRANSFER_QUEUE_FULL,
USB_HOST_CDC_RESULT_ERROR_INSTANCE_INVALID,
USB_HOST_CDC_RESULT_ERROR_INSTANCE_NOT_READY,
USB_HOST_CDC_RESULT_ERROR_PARAMETER_INVALID
} USB_HOST_CDC_RESULT;
Description
USB Host CDC Class Driver Result enumeration.
This enumeration lists the possible USB Host CDC Class Driver operation results. These values are returned by CDC Class
Driver functions.
Members
Members Description
USB_HOST_CDC_RESULT_OK The operation was successful
5.9.9.4.2.3 USB_HOST_CDC_TRANSFER_HANDLE Type
C
typedef uintptr_t USB_HOST_CDC_TRANSFER_HANDLE;
5.9 USB Library Help MPLAB Harmony Help USB CDC Host Library
5-4215
Description
USB Host CDC Class Driver Transfer Handle
This is returned by the CDC Class driver command and data transfer routines and should be used by the application to track the
transfer especially in cases where transfers are queued.
Remarks
None.
5.9.9.4.2.4 USB_HOST_CDC_EVENT_DATA_GET_LINE_CODING_COMPLETE Structure
C
typedef struct {
USB_HOST_CDC_TRANSFER_HANDLE transferHandle;
USB_HOST_CDC_TRANSFER_STATUS transferStatus;
size_t length;
} USB_HOST_CDC_EVENT_DATA_READ_COMPLETE, USB_HOST_CDC_EVENT_DATA_WRITE_COMPLETE,
USB_HOST_CDC_EVENT_DATA_SERIAL_STATE_NOTIFICATION_RECEIVED,
USB_HOST_CDC_EVENT_DATA_GET_LINE_CODING_COMPLETE,
USB_HOST_CDC_EVENT_DATA_SET_LINE_CODING_COMPLETE,
USB_HOST_CDC_EVENT_DATA_SET_CONTROL_LINE_STATE_COMPLETE,
USB_HOST_CDC_EVENT_DATA_SEND_BREAK_COMPLETE;
Description
USB Host CDC Class Driver Event Data.
This data type defines the data structure returned by the driver along with the following events:
USB_HOST_CDC_EVENT_DATA_READ_COMPLETE, USB_HOST_CDC_EVENT_DATA_WRITE_COMPLETE,
USB_HOST_CDC_EVENT_DATA_SET_LINE_CODING_COMPLETE,
USB_HOST_CDC_EVENT_DATA_SEND_BREAK_COMPLETE,
USB_HOST_CDC_EVENT_DATA_GET_LINE_CODING_COMPLETE,
USB_HOST_CDC_EVENT_DATA_SET_CONTROL_LINE_STATE_COMPLETE,
USB_HOST_CDC_EVENT_DATA_SERIAL_STATE_NOTIFICATION_RECEIVED
Members
Members Description
USB_HOST_CDC_TRANSFER_HANDLE
transferHandle;
Transfer handle of this transfer
USB_HOST_CDC_TRANSFER_STATUS
transferStatus;
Termination transfer status
size_t length; Amount of data transferred
Remarks
None.
5.9.9.4.2.5 USB_HOST_CDC_EVENT_DATA_READ_COMPLETE Structure
C
typedef struct {
USB_HOST_CDC_TRANSFER_HANDLE transferHandle;
USB_HOST_CDC_TRANSFER_STATUS transferStatus;
size_t length;
} USB_HOST_CDC_EVENT_DATA_READ_COMPLETE, USB_HOST_CDC_EVENT_DATA_WRITE_COMPLETE,
USB_HOST_CDC_EVENT_DATA_SERIAL_STATE_NOTIFICATION_RECEIVED,
USB_HOST_CDC_EVENT_DATA_GET_LINE_CODING_COMPLETE,
5.9 USB Library Help MPLAB Harmony Help USB CDC Host Library
5-4216
USB_HOST_CDC_EVENT_DATA_SET_LINE_CODING_COMPLETE,
USB_HOST_CDC_EVENT_DATA_SET_CONTROL_LINE_STATE_COMPLETE,
USB_HOST_CDC_EVENT_DATA_SEND_BREAK_COMPLETE;
Description
USB Host CDC Class Driver Event Data.
This data type defines the data structure returned by the driver along with the following events:
USB_HOST_CDC_EVENT_DATA_READ_COMPLETE, USB_HOST_CDC_EVENT_DATA_WRITE_COMPLETE,
USB_HOST_CDC_EVENT_DATA_SET_LINE_CODING_COMPLETE,
USB_HOST_CDC_EVENT_DATA_SEND_BREAK_COMPLETE,
USB_HOST_CDC_EVENT_DATA_GET_LINE_CODING_COMPLETE,
USB_HOST_CDC_EVENT_DATA_SET_CONTROL_LINE_STATE_COMPLETE,
USB_HOST_CDC_EVENT_DATA_SERIAL_STATE_NOTIFICATION_RECEIVED
Members
Members Description
USB_HOST_CDC_TRANSFER_HANDLE
transferHandle;
Transfer handle of this transfer
USB_HOST_CDC_TRANSFER_STATUS
transferStatus;
Termination transfer status
size_t length; Amount of data transferred
Remarks
None.
5.9.9.4.2.6 USB_HOST_CDC_EVENT_DATA_SEND_BREAK_COMPLETE Structure
C
typedef struct {
USB_HOST_CDC_TRANSFER_HANDLE transferHandle;
USB_HOST_CDC_TRANSFER_STATUS transferStatus;
size_t length;
} USB_HOST_CDC_EVENT_DATA_READ_COMPLETE, USB_HOST_CDC_EVENT_DATA_WRITE_COMPLETE,
USB_HOST_CDC_EVENT_DATA_SERIAL_STATE_NOTIFICATION_RECEIVED,
USB_HOST_CDC_EVENT_DATA_GET_LINE_CODING_COMPLETE,
USB_HOST_CDC_EVENT_DATA_SET_LINE_CODING_COMPLETE,
USB_HOST_CDC_EVENT_DATA_SET_CONTROL_LINE_STATE_COMPLETE,
USB_HOST_CDC_EVENT_DATA_SEND_BREAK_COMPLETE;
Description
USB Host CDC Class Driver Event Data.
This data type defines the data structure returned by the driver along with the following events:
USB_HOST_CDC_EVENT_DATA_READ_COMPLETE, USB_HOST_CDC_EVENT_DATA_WRITE_COMPLETE,
USB_HOST_CDC_EVENT_DATA_SET_LINE_CODING_COMPLETE,
USB_HOST_CDC_EVENT_DATA_SEND_BREAK_COMPLETE,
USB_HOST_CDC_EVENT_DATA_GET_LINE_CODING_COMPLETE,
USB_HOST_CDC_EVENT_DATA_SET_CONTROL_LINE_STATE_COMPLETE,
USB_HOST_CDC_EVENT_DATA_SERIAL_STATE_NOTIFICATION_RECEIVED
Members
Members Description
USB_HOST_CDC_TRANSFER_HANDLE
transferHandle;
Transfer handle of this transfer
5.9 USB Library Help MPLAB Harmony Help USB CDC Host Library
5-4217
USB_HOST_CDC_TRANSFER_STATUS
transferStatus;
Termination transfer status
size_t length; Amount of data transferred
Remarks
None.
5.9.9.4.2.7 USB_HOST_CDC_EVENT_DATA_SERIAL_STATE_NOTIFICATION_RECEIVED
Structure
C
typedef struct {
USB_HOST_CDC_TRANSFER_HANDLE transferHandle;
USB_HOST_CDC_TRANSFER_STATUS transferStatus;
size_t length;
} USB_HOST_CDC_EVENT_DATA_READ_COMPLETE, USB_HOST_CDC_EVENT_DATA_WRITE_COMPLETE,
USB_HOST_CDC_EVENT_DATA_SERIAL_STATE_NOTIFICATION_RECEIVED,
USB_HOST_CDC_EVENT_DATA_GET_LINE_CODING_COMPLETE,
USB_HOST_CDC_EVENT_DATA_SET_LINE_CODING_COMPLETE,
USB_HOST_CDC_EVENT_DATA_SET_CONTROL_LINE_STATE_COMPLETE,
USB_HOST_CDC_EVENT_DATA_SEND_BREAK_COMPLETE;
Description
USB Host CDC Class Driver Event Data.
This data type defines the data structure returned by the driver along with the following events:
USB_HOST_CDC_EVENT_DATA_READ_COMPLETE, USB_HOST_CDC_EVENT_DATA_WRITE_COMPLETE,
USB_HOST_CDC_EVENT_DATA_SET_LINE_CODING_COMPLETE,
USB_HOST_CDC_EVENT_DATA_SEND_BREAK_COMPLETE,
USB_HOST_CDC_EVENT_DATA_GET_LINE_CODING_COMPLETE,
USB_HOST_CDC_EVENT_DATA_SET_CONTROL_LINE_STATE_COMPLETE,
USB_HOST_CDC_EVENT_DATA_SERIAL_STATE_NOTIFICATION_RECEIVED
Members
Members Description
USB_HOST_CDC_TRANSFER_HANDLE
transferHandle;
Transfer handle of this transfer
USB_HOST_CDC_TRANSFER_STATUS
transferStatus;
Termination transfer status
size_t length; Amount of data transferred
Remarks
None.
5.9.9.4.2.8 USB_HOST_CDC_EVENT_DATA_SET_CONTROL_LINE_STATE_COMPLETE
Structure
C
typedef struct {
USB_HOST_CDC_TRANSFER_HANDLE transferHandle;
USB_HOST_CDC_TRANSFER_STATUS transferStatus;
size_t length;
} USB_HOST_CDC_EVENT_DATA_READ_COMPLETE, USB_HOST_CDC_EVENT_DATA_WRITE_COMPLETE,
USB_HOST_CDC_EVENT_DATA_SERIAL_STATE_NOTIFICATION_RECEIVED,
USB_HOST_CDC_EVENT_DATA_GET_LINE_CODING_COMPLETE,
5.9 USB Library Help MPLAB Harmony Help USB CDC Host Library
5-4218
USB_HOST_CDC_EVENT_DATA_SET_LINE_CODING_COMPLETE,
USB_HOST_CDC_EVENT_DATA_SET_CONTROL_LINE_STATE_COMPLETE,
USB_HOST_CDC_EVENT_DATA_SEND_BREAK_COMPLETE;
Description
USB Host CDC Class Driver Event Data.
This data type defines the data structure returned by the driver along with the following events:
USB_HOST_CDC_EVENT_DATA_READ_COMPLETE, USB_HOST_CDC_EVENT_DATA_WRITE_COMPLETE,
USB_HOST_CDC_EVENT_DATA_SET_LINE_CODING_COMPLETE,
USB_HOST_CDC_EVENT_DATA_SEND_BREAK_COMPLETE,
USB_HOST_CDC_EVENT_DATA_GET_LINE_CODING_COMPLETE,
USB_HOST_CDC_EVENT_DATA_SET_CONTROL_LINE_STATE_COMPLETE,
USB_HOST_CDC_EVENT_DATA_SERIAL_STATE_NOTIFICATION_RECEIVED
Members
Members Description
USB_HOST_CDC_TRANSFER_HANDLE
transferHandle;
Transfer handle of this transfer
USB_HOST_CDC_TRANSFER_STATUS
transferStatus;
Termination transfer status
size_t length; Amount of data transferred
Remarks
None.
5.9.9.4.2.9 USB_HOST_CDC_EVENT_DATA_SET_LINE_CODING_COMPLETE Structure
C
typedef struct {
USB_HOST_CDC_TRANSFER_HANDLE transferHandle;
USB_HOST_CDC_TRANSFER_STATUS transferStatus;
size_t length;
} USB_HOST_CDC_EVENT_DATA_READ_COMPLETE, USB_HOST_CDC_EVENT_DATA_WRITE_COMPLETE,
USB_HOST_CDC_EVENT_DATA_SERIAL_STATE_NOTIFICATION_RECEIVED,
USB_HOST_CDC_EVENT_DATA_GET_LINE_CODING_COMPLETE,
USB_HOST_CDC_EVENT_DATA_SET_LINE_CODING_COMPLETE,
USB_HOST_CDC_EVENT_DATA_SET_CONTROL_LINE_STATE_COMPLETE,
USB_HOST_CDC_EVENT_DATA_SEND_BREAK_COMPLETE;
Description
USB Host CDC Class Driver Event Data.
This data type defines the data structure returned by the driver along with the following events:
USB_HOST_CDC_EVENT_DATA_READ_COMPLETE, USB_HOST_CDC_EVENT_DATA_WRITE_COMPLETE,
USB_HOST_CDC_EVENT_DATA_SET_LINE_CODING_COMPLETE,
USB_HOST_CDC_EVENT_DATA_SEND_BREAK_COMPLETE,
USB_HOST_CDC_EVENT_DATA_GET_LINE_CODING_COMPLETE,
USB_HOST_CDC_EVENT_DATA_SET_CONTROL_LINE_STATE_COMPLETE,
USB_HOST_CDC_EVENT_DATA_SERIAL_STATE_NOTIFICATION_RECEIVED
Members
Members Description
USB_HOST_CDC_TRANSFER_HANDLE
transferHandle;
Transfer handle of this transfer
5.9 USB Library Help MPLAB Harmony Help USB CDC Host Library
5-4219
USB_HOST_CDC_TRANSFER_STATUS
transferStatus;
Termination transfer status
size_t length; Amount of data transferred
Remarks
None.
5.9.9.4.2.10 USB_HOST_CDC_EVENT_DATA_WRITE_COMPLETE Structure
C
typedef struct {
USB_HOST_CDC_TRANSFER_HANDLE transferHandle;
USB_HOST_CDC_TRANSFER_STATUS transferStatus;
size_t length;
} USB_HOST_CDC_EVENT_DATA_READ_COMPLETE, USB_HOST_CDC_EVENT_DATA_WRITE_COMPLETE,
USB_HOST_CDC_EVENT_DATA_SERIAL_STATE_NOTIFICATION_RECEIVED,
USB_HOST_CDC_EVENT_DATA_GET_LINE_CODING_COMPLETE,
USB_HOST_CDC_EVENT_DATA_SET_LINE_CODING_COMPLETE,
USB_HOST_CDC_EVENT_DATA_SET_CONTROL_LINE_STATE_COMPLETE,
USB_HOST_CDC_EVENT_DATA_SEND_BREAK_COMPLETE;
Description
USB Host CDC Class Driver Event Data.
This data type defines the data structure returned by the driver along with the following events:
USB_HOST_CDC_EVENT_DATA_READ_COMPLETE, USB_HOST_CDC_EVENT_DATA_WRITE_COMPLETE,
USB_HOST_CDC_EVENT_DATA_SET_LINE_CODING_COMPLETE,
USB_HOST_CDC_EVENT_DATA_SEND_BREAK_COMPLETE,
USB_HOST_CDC_EVENT_DATA_GET_LINE_CODING_COMPLETE,
USB_HOST_CDC_EVENT_DATA_SET_CONTROL_LINE_STATE_COMPLETE,
USB_HOST_CDC_EVENT_DATA_SERIAL_STATE_NOTIFICATION_RECEIVED
Members
Members Description
USB_HOST_CDC_TRANSFER_HANDLE
transferHandle;
Transfer handle of this transfer
USB_HOST_CDC_TRANSFER_STATUS
transferStatus;
Termination transfer status
size_t length; Amount of data transferred
Remarks
None.
5.9.9.4.2.11 USB_HOST_CDC_EVENT_HANDLER Type
C
typedef USB_HOST_CDC_EVENT_RESPONSE (* USB_HOST_CDC_EVENT_HANDLER)(USB_HOST_CDC_INDEX index,
USB_HOST_CDC_EVENT event, void * eventData, uintptr_t context);
Description
USB Host CDC Class Driver Event Handler Function Pointer Type.
This data type defines the required function signature of the USB Host CDC Class Driver event handling callback function. The
application must register a pointer to a CDC Class Driver events handling function who's function signature (parameter and
return value types) match the types specified by this function pointer in order to receive event call backs from the CDC Class
5.9 USB Library Help MPLAB Harmony Help USB CDC Host Library
5-4220
Driver. The class driver will invoke this function with event relevant parameters. The description of the event handler function
parameters is given here.
instanceIndex - Instance index of the CDC Class Driver that generated the event.
event - Type of event generated.
eventData - This parameter should be type casted to a event specific pointer type based on the event that has occurred. Refer to
the USB_HOST_CDC_EVENT enumeration description for more details.
context - Value identifying the context of the application that was registered along with the event handling function.
Remarks
None.
5.9.9.4.2.12 USB_HOST_CDC_EVENT_RESPONSE Type
C
typedef void USB_HOST_CDC_EVENT_RESPONSE;
Description
USB Host CDC Class Driver Event Handler Response Type
This is the return type of the CDC Class Driver event handler.
Remarks
None.
5.9.9.4.2.13 USB_HOST_CDC_INDEX Type
C
typedef uintptr_t USB_HOST_CDC_INDEX;
Description
USB Host CDC Class Driver Index
This uniquely identifies a CDC Class Driver instance.
Remarks
None.
5.9.9.4.2.14 USB_HOST_CDC_SERIAL_STATE_NOTIFICATION_DATA Type
C
typedef USB_CDC_SERIAL_STATE USB_HOST_CDC_SERIAL_STATE_NOTIFICATION_DATA;
Description
USB Host CDC Serial State Notification Data Type.
This defines the data type for the CDC Serial State. This data is requested from the device over the CDC notification interface.
Remarks
None.
5.9 USB Library Help MPLAB Harmony Help USB CDC Host Library
5-4221
5.9.9.4.2.15 USB_HOST_CDC_TRANSFER_STATUS Enumeration
C
typedef enum {
USB_HOST_CDC_TRANSFER_STATUS_OK,
USB_HOST_CDC_TRANSFER_STATUS_ERROR
} USB_HOST_CDC_TRANSFER_STATUS;
Description
USB Host CDC Class Driver Transfer Status.
This enumeration lists the possible termination status of CDC class driver transfers. This information is a part of the event data
that is returned along with transfer related events.
Members
Members Description
USB_HOST_CDC_TRANSFER_STATUS_OK The transfer completed successfully. In case of read transfers, either the
requested amount of data was received or the device sent less data
USB_HOST_CDC_TRANSFER_STATUS_ERROR The transfer terminated due to an error. The error could be due to device
malfunction on the bus, a NAK timeout occurred or the device stalled the
request
Remarks
None.
5.9.9.4.2.16 USB_HOST_CDC_EVENT_RESPONSE_NONE Macro
C
#define USB_HOST_CDC_EVENT_RESPONSE_NONE
Description
USB Host CDC Class Driver Event Handler Response None
This is the definition of the CDC Class Driver Event Handler Response Type none.
Remarks
Intentionally defined to be empty.
5.9.9.4.2.17 USB_HOST_CDC_TRANSFER_HANDLE_INVALID Macro
C
#define USB_HOST_CDC_TRANSFER_HANDLE_INVALID ((USB_HOST_CDC_TRANSFER_HANDLE)(-1))
Description
USB Host CDC Class Driver Invalid Transfer Handle Definition
This definition defines a USB Host CDC Class Driver Invalid Transfer Handle. A Invalid Transfer Handle is returned by the CDC
Class Driver data and command transfer routines when the request was not successful.
Remarks
None.
5.9 USB Library Help MPLAB Harmony Help USB CDC Host Library
5-4222
5.9.9.4.2.18 USB_HOST_CDC_CONTROL_LINE_STATE Type
C
typedef USB_CDC_CONTROL_LINE_STATE USB_HOST_CDC_CONTROL_LINE_STATE;
Description
USB Host CDC Control Line State Data Type.
This defines the data type for the CDC Control Line State. This data is requested from the device over the CDC control interface.
Remarks
None.
5.9.9.5 Files
Files
Name Description
usb_host_cdc.h USB Host CDC Class Driver Interface Header
Description
5.9.9.5.1 usb_host_cdc.h
USB Host CDC Class Driver Interface Definition
This header file contains the function prototypes and definitions of the data types and constants that make up the interface to the
USB Host CDC Class Driver.
Enumerations
Name Description
USB_HOST_CDC_EVENT Identifies the possible events that the CDC Class Driver can generate.
USB_HOST_CDC_RESULT USB Host CDC Class Driver CDC Result enumeration.
USB_HOST_CDC_TRANSFER_STATUS USB Host CDC Class Driver Transfer Status enumeration.
Functions
Name Description
USB_HOST_CDC_BreakSend This function sends a request to the attached to update it's break
duration.
USB_HOST_CDC_ControlLineStateSet This function sets the state of the control line connecting the host to
the device.
USB_HOST_CDC_EventHandlerSet This class registers a event handler for the specified CDC class
driver instance.
USB_HOST_CDC_LineCodingGet This function requests line coding from the attached CDC device.
USB_HOST_CDC_LineCodingSet This function sets the line coding of the attached CDC device.
USB_HOST_CDC_Read This function reads data from the attached CDC device.
USB_HOST_CDC_SerialStateNotificationGet This function requests serial state noitification data from the
attached CDC device.
USB_HOST_CDC_Write This function writes data to the attached CDC device.
5.9 USB Library Help MPLAB Harmony Help USB CDC Host Library
5-4223
Macros
Name Description
USB_HOST_CDC_EVENT_RESPONSE_NONE USB Host CDC Class Driver Event Handler Response Type
None.
USB_HOST_CDC_TRANSFER_HANDLE_INVALID USB Host CDC Class Driver Invalid Transfer Handle
Definition.
Structures
Name Description
USB_HOST_CDC_EVENT_DATA_GET_LINE_CODING_COMPLETE USB Host CDC Class Driver
Event Data.
USB_HOST_CDC_EVENT_DATA_READ_COMPLETE USB Host CDC Class Driver
Event Data.
USB_HOST_CDC_EVENT_DATA_SEND_BREAK_COMPLETE USB Host CDC Class Driver
Event Data.
USB_HOST_CDC_EVENT_DATA_SERIAL_STATE_NOTIFICATION_RECEIVED USB Host CDC Class Driver
Event Data.
USB_HOST_CDC_EVENT_DATA_SET_CONTROL_LINE_STATE_COMPLETE USB Host CDC Class Driver
Event Data.
USB_HOST_CDC_EVENT_DATA_SET_LINE_CODING_COMPLETE USB Host CDC Class Driver
Event Data.
USB_HOST_CDC_EVENT_DATA_WRITE_COMPLETE USB Host CDC Class Driver
Event Data.
Types
Name Description
USB_HOST_CDC_CONTROL_LINE_STATE USB Host Control Line State Data Type.
USB_HOST_CDC_EVENT_HANDLER USB Host CDC Class Driver Event Handler Function
Pointer Type.
USB_HOST_CDC_EVENT_RESPONSE USB Host CDC Class Driver Event Callback
Response Type
USB_HOST_CDC_INDEX USB Host CDC Class Driver Index
USB_HOST_CDC_SERIAL_STATE_NOTIFICATION_DATA USB Host Serial State Notification Data Type.
USB_HOST_CDC_TRANSFER_HANDLE USB Host CDC Class Driver Transfer Handle
File Name
usb_host_cdc.h
Company
Microchip Technology Incorported
5.9 USB Library Help MPLAB Harmony Help USB CDC Host Library
5-4224
6 Third-Party Library Help
6 MPLAB Harmony Help
6-4225
6.1 Third-Party Library Overview
6.1.1 Introduction
This topic provides an overview of the Third-Party Libraries in MPLAB Harmony.
Description
Note: This information was not available at time of release and will be added in a future release of MPLAB Harmony.
6.1.2 Release Notes
MPLAB Harmony Version: v0.70b Release Date: 18Nov2013
New This Release:
Nothing to report in this release.
Known Issues:
Nothing to report in this release.
6.1.3 SW License Agreement
(c) 2013 Microchip Technology Inc.
Microchip licenses this software to you solely for use with Microchip products. The software is owned by Microchip and its
licensors, and is protected under applicable copyright laws. All rights reserved.
SOFTWARE IS PROVIDED "AS IS" MICROCHIP EXPRESSLY DISCLAIMS ANY WARRANTY OF ANY KIND, WHETHER
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. IN NO EVENT SHALL MICROCHIP BE LIABLE FOR
ANY INCIDENTAL, SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, HARM TO
YOUR EQUIPMENT, COST OF PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY OR SERVICES, ANY CLAIMS
BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), ANY CLAIMS FOR INDEMNITY OR
CONTRIBUTION, OR OTHER SIMILAR COSTS.
To the fullest extent allowed by law, Microchip and its licensors liability shall not exceed the amount of fees, if any, that you have
paid directly to Microchip to use this software.
MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE TERMS.
6.1 Third-Party Library Overview MPLAB Harmony Help SW License Agreement
6-4226
7 Board Support Packages Help
7 MPLAB Harmony Help
7-4227
7.1 Board Support Packages Overview
7.1.1 Introduction
This topic provides information for the Board Support Package (BSP) in MPLAB Harmony.
Description
A Board Support Package (BSP) provides code and configuration items necessary to support board-specific hardware. A BSP
may be provided for Microchip development or demo boards or may be defined by customers for their own boards (which is
recommended to make it easy to support multiple boards in the future, even of only a single board exists when a project is first
created).
A BSP may contain a board-specific configuration header ("bsp_config.h" and possibly others), a board-specific system
initialization file ("bsp_sys_init.c"), a file containing board-specific ISR implementations ("bsp_sys_int.c"), a board-specific system
"tasks" routine (implemented in a "bsp_sys_tasks.c" file), and even board-specific driver implementations (each with it's own
directory).
Everything that is contained within a BSP can be either used by or replaced by application specific items if desired. For example,
the application may configure the system initialization routine ("SYS_Initialize") to directly call a board-specific initialization
routine (called "BSP_Initialize") or it can use the BSP-specific initialization routine as an example from which to start developing
application-specific board initialization code. Normally, Microchip demo applications will use the BSP code directly to avoid
duplication of board-specific code.
7.1.2 Configuration
This topic describes the BSP configuration header options.
Description
A BSP configuration header defines configuration options that are "fixed" by the board. That is, any option that cannot be
changed unless the hardware on the board is changed may be defined in a BSP's "bsp_config.h" file (or in a file included by it).
This will normally include board parameters such as the oscillator frequency for a fixed-frequency oscillator or convenient names
by which board-specific features may be identified (such as which pins connect to switches or LEDs). It may also include options
for libraries and drivers that can be used by an application running on that board that are "fixed" by the hardware on the board.
However, it may not define all options necessary for a library, only the board-specific options. Application-specific headers may
include BSP-specific headers to define the board-hardware-specific options or it may define them itself, thus overriding a BSP's
options.
7.1 Board Support Packages Overview MPLAB Harmony Help Board Drivers
7-4228
7.1.3 Board Drivers
This topic describes the board drivers of the BSP.
Description
Some peripheral hardware may not be directly built into the microcontroller. For example, devices such as external CODECs,
EEPROMs, etc, may be built onto a board and will not be available as peripherals in the microcontroller. Devices such as these
still need device drivers and these drivers still need to follow the MPLAB harmony driver architecture. However, they will not
normally be provided as part of the standard MPLAB Harmony driver set for Microchip microcontrollers. Instead, all files related
to drivers for devices mounted on Microchip demo and development boards will be contained within the "bsp/drivers" directory.
They will otherwise, follow the same rules as all other MPLAB Harmony device drivers.
7.1.4 System Initialization
This topic describes BSP system initialization.
Description
Normally, an application will define or configure the “SYS_Initialize” routine in any way that is necessary to initialize the system
as desired. However, board-specific initialization may be necessary. When it is, a BSP must implement a board-specific
initialization routine called "BSP_Initialize" that performs any necessary low-level board initialization necessary to support normal
system operation. The "BSP_Initialize" routine may have an associated "initialization" structure, a pointer to which may be
passed in as a parameter, to define any application-specific parameters necessary to initialize any low-level board hardware.
Low-level board hardware may be things like power subsystems, bus enable signals, or other items necessary for basic board
operations. It should not include the initialization of board-specific drivers as that is done separately. However, a BSP may define
initialization data used to initialize board-specific drivers if that data is "fixed" by the board.
7.1.5 ISR Implementation
This topic describes BSP ISR implentation.
Description
Like the SYS_Initialize routine, an ISR may be implemented by an application in any way necessary to support the desired
system behavior. Unlike the initialization support, a BSP-specific ISR implementation should never be called by the
application-specific ISR implementation. It must either be used exactly as defined by the BSP or the application's system
interrupt support must define its own ISR implementation. If the application defines its own implementation, the BSP ISR can be
used as an example.
7.1 Board Support Packages Overview MPLAB Harmony Help ISR Implementation
7-4229
7.2 Explorer 16 PIC32MX795F512L BSP Library
7.2.1 Introduction
Explorer 16 PIC32MX795F512L BSP Library
for
Microchip Microcontrollers
This library provides a low-level abstraction of the Explorer 16 PIC32MX795F512L BSP Library that is available on the Microchip
family of microcontrollers with a convenient C language interface. It can be used to simplify low-level access to the module
without the necessity of interacting directly with the module's registers, there by hiding differences from one microcontroller
variant to another.
Description
Note: This information was not available at time of release and will be added in a future release of MPLAB Harmony.
7.2.2 Release Notes
MPLAB Harmony Version: v0.70b Explorer 16 PIC32MX795F512L BSP Library Version : 0.51.03b Release Date:
18Nov2013
New This Release:
This is the first release of the library. The interface can change in the beta and\or 1.0 release.
Known Issues:
Nothing to report in this release.
7.2.3 SW License Agreement
(c) 2013 Microchip Technology Inc.
Microchip licenses this software to you solely for use with Microchip products. The software is owned by Microchip and its
licensors, and is protected under applicable copyright laws. All rights reserved.
SOFTWARE IS PROVIDED "AS IS" MICROCHIP EXPRESSLY DISCLAIMS ANY WARRANTY OF ANY KIND, WHETHER
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. IN NO EVENT SHALL MICROCHIP BE LIABLE FOR
ANY INCIDENTAL, SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, HARM TO
YOUR EQUIPMENT, COST OF PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY OR SERVICES, ANY CLAIMS
7.2 Explorer 16 PIC32MX795F512L BSP MPLAB Harmony Help SW License Agreement
7-4230
BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), ANY CLAIMS FOR INDEMNITY OR
CONTRIBUTION, OR OTHER SIMILAR COSTS.
To the fullest extent allowed by law, Microchip and its licensors liability shall not exceed the amount of fees, if any, that you have
paid directly to Microchip to use this software.
MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE TERMS.
7.2.4 Using the Library
This topic describes the basic architecture of the Explorer 16 PIC32MX795F512L BSP Library and provides information and
examples on how to use it.
Interface Header File: bsp_config.h
The interface to the Explorer 16 PIC32MX795F512L BSP library is defined in the "bsp_config.h" header file. Any C language
source (.c) file that uses the Explorer 16 PIC32MX795F512L BSP library should include "bsp_config.h".
7.2.4.1 Library Overview
The library interface routines are divided into various sub-sections, each of sub-section addresses one of the blocks or the
overall operation of the Explorer 16 PIC32MX795F512L BSP Library module.
Library Interface Section Description
Initialization Functions This section provides initialization functions.
LED Control Functions This section provides functions for LED Control.
Other Functions This section provides additional functions for this API.
Data Types and Constants This section provides various definitions describing this API.
7.2 Explorer 16 PIC32MX795F512L BSP MPLAB Harmony Help Using the Library
7-4231
7.3 PIC32 USB Starter Kit II BSP Library
7.3.1 Introduction
PIC332 USB Starter Kit II BSP Library
for
Microchip Microcontrollers
This library provides a low-level abstraction of the PIC32 USB Starter Kit II Library that is available on the Microchip family of
microcontrollers with a convenient C language interface. It can be used to simplify low-level access to the module without the
necessity of interacting directly with the module's registers, there by hiding differences from one microcontroller variant to
another.
Description
Note: This information was not available at time of release and will be added in a future release of MPLAB Harmony.
7.3.2 Release Notes
MPLAB Harmony Version: v0.70b PIC32 USB Starter Kit II BSP Library Version : 0.51.03b Release Date: 18Nov2013
New This Release:
This is the first release of the library. The interface can change in the beta and\or 1.0 release.
Known Issues:
Nothing to report in this release.
7.3.3 SW License Agreement
(c) 2013 Microchip Technology Inc.
Microchip licenses this software to you solely for use with Microchip products. The software is owned by Microchip and its
licensors, and is protected under applicable copyright laws. All rights reserved.
SOFTWARE IS PROVIDED "AS IS" MICROCHIP EXPRESSLY DISCLAIMS ANY WARRANTY OF ANY KIND, WHETHER
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. IN NO EVENT SHALL MICROCHIP BE LIABLE FOR
ANY INCIDENTAL, SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, HARM TO
YOUR EQUIPMENT, COST OF PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY OR SERVICES, ANY CLAIMS
BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), ANY CLAIMS FOR INDEMNITY OR
7.3 PIC32 USB Starter Kit II BSP Library MPLAB Harmony Help SW License Agreement
7-4232
CONTRIBUTION, OR OTHER SIMILAR COSTS.
To the fullest extent allowed by law, Microchip and its licensors liability shall not exceed the amount of fees, if any, that you have
paid directly to Microchip to use this software.
MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE TERMS.
7.3.4 Using the Library
This topic describes the basic architecture of the PIC32 USB Starter Kit II BSP Library and provides information and examples
on how to use it.
Interface Header File: bsp_config.h
The interface to the PIC32 USB Starter Kit II BSP Library is defined in the "bsp_config.h" header file. Any C language source (.c)
file that uses the PIC32 USB Starter Kit II BSP Library should include "bsp_config.h".
7.3.4.1 Library Overview
The library interface routines are divided into various sub-sections, each of sub-section addresses one of the blocks or the
overall operation of the PIC32 USB Starter Kit II Library module.
Library Interface Section Description
Initialization Functions This section provides initialization functions.
LED Control Functions This section provides functions for LED Control.
Other Functions This section provides additional functions for this API.
Data Types and Constants This section provides various definitions describing this API.
7.3 PIC32 USB Starter Kit II BSP Library MPLAB Harmony Help Using the Library
7-4233
7.4 PIC32MX USB Audio BSP Library
7.4.1 Introduction
PIC32MX USB Audio BSP Library
for
Microchip Microcontrollers
This library provides a low-level abstraction of the PIC32MX USB Audio BSP Library that is available on the Microchip family of
microcontrollers with a convenient C language interface. It can be used to simplify low-level access to the module without the
necessity of interacting directly with the module's registers, there by hiding differences from one microcontroller variant to
another.
Description
Note: This information was not available at time of release and will be provided in a future release of MPLAB Harmony.
7.4.2 Release Notes
MPLAB Harmony Version: v0.70b PIC32MX USB Audio BSP Library Version : 0.51.03b Release Date: 18Nov2013
New This Release:
This is the first release of the library. The interface can change in the beta and\or 1.0 release.
Known Issues:
Nothing to report in this release.
7.4.3 SW License Agreement
(c) 2013 Microchip Technology Inc.
Microchip licenses this software to you solely for use with Microchip products. The software is owned by Microchip and its
licensors, and is protected under applicable copyright laws. All rights reserved.
SOFTWARE IS PROVIDED "AS IS" MICROCHIP EXPRESSLY DISCLAIMS ANY WARRANTY OF ANY KIND, WHETHER
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. IN NO EVENT SHALL MICROCHIP BE LIABLE FOR
ANY INCIDENTAL, SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, HARM TO
YOUR EQUIPMENT, COST OF PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY OR SERVICES, ANY CLAIMS
BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), ANY CLAIMS FOR INDEMNITY OR
7.4 PIC32MX USB Audio BSP Library MPLAB Harmony Help SW License Agreement
7-4234
CONTRIBUTION, OR OTHER SIMILAR COSTS.
To the fullest extent allowed by law, Microchip and its licensors liability shall not exceed the amount of fees, if any, that you have
paid directly to Microchip to use this software.
MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE TERMS.
7.4.4 Using the Library
This topic describes the basic architecture of the PIC32MX USB Audio BSP Library and provides information and examples on
how to use it.
Interface Header File: bsp_config.h
The interface to the PIC32MX USB Audio BSP Library is defined in the "bsp_config.h" header file. Any C language source (.c)
file that uses the PIC32MX USB Audio BSP Library should include "bsp_config.h".
7.4.4.1 Library Overview
The library interface routines are divided into various sub-sections, each of sub-section addresses one of the blocks or the
overall operation of the PIC32MX USB Audio BSP Library module.
Library Interface Section Description
Initialization Functions This section provides initialization functions.
LED Control Functions This section provides functions for LED Control.
Other Functions This section provides additional functions for this API.
Data Types and Constants This section provides various definitions describing this API.
7.4 PIC32MX USB Audio BSP Library MPLAB Harmony Help Using the Library
7-4235
7.5 PIC32MZ Embedded Connectivity (EC) Starter
Kit BSP Library
7.5.1 Introduction
PIC32MZ Embedded Connectivity (EC) Starter Kit BSP Library
for
Microchip Microcontrollers
This library provides a low-level abstraction of the PIC32MZ Embedded Connectivity (EC) Starter Kit BSP Library that is
available on the Microchip family of microcontrollers with a convenient C language interface. It can be used to simplify low-level
access to the module without the necessity of interacting directly with the module's registers, there by hiding differences from
one microcontroller variant to another.
Description
Note: This information was not available at time of release and will be added in a future release of MPLAB Harmony.
7.5.2 Release Notes
MPLAB Harmony Version: v0.70b PIC32MZ Embedded Connectivity (EC) Starter Kit BSP Library Version : 0.51.03b
Release Date: 18Nov2013
New This Release:
This is the first release of the library. The interface can change in the beta and\or 1.0 release.
Known Issues:
Nothing to report in this release.
7.5.3 SW License Agreement
(c) 2013 Microchip Technology Inc.
Microchip licenses this software to you solely for use with Microchip products. The software is owned by Microchip and its
licensors, and is protected under applicable copyright laws. All rights reserved.
SOFTWARE IS PROVIDED "AS IS" MICROCHIP EXPRESSLY DISCLAIMS ANY WARRANTY OF ANY KIND, WHETHER
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
7.5 PIC32MZ Embedded Connectivity (EC) MPLAB Harmony Help SW License Agreement
7-4236
FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. IN NO EVENT SHALL MICROCHIP BE LIABLE FOR
ANY INCIDENTAL, SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, HARM TO
YOUR EQUIPMENT, COST OF PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY OR SERVICES, ANY CLAIMS
BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), ANY CLAIMS FOR INDEMNITY OR
CONTRIBUTION, OR OTHER SIMILAR COSTS.
To the fullest extent allowed by law, Microchip and its licensors liability shall not exceed the amount of fees, if any, that you have
paid directly to Microchip to use this software.
MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE TERMS.
7.5.4 Using the Library
This topic describes the basic architecture of the PIC32MZ Embedded Connectivity (EC) Starter Kit BSP Library and provides
information and examples on how to use it.
Interface Header File: bsp_config.h
The interface to the PIC32MZ Embedded Connectivity (EC) Starter Kit BSP Library is defined in the "bsp_config.h" header file.
Any C language source (.c) file that uses the PIC32MZ Embedded Connectivity (EC) Starter Kit BSP Library should include
"bsp_config.h".
7.5.4.1 Library Overview
The library interface routines are divided into various sub-sections, each of sub-section addresses one of the blocks or the
overall operation of the PIC32MZ Embedded Connectivity (EC) Starter Kit BSP Library module.
Library Interface Section Description
Initialization Functions This section provides initialization functions.
LED Control Functions This section provides functions for LED Control.
Other Functions This section provides additional functions for this API.
Data Types and Constants This section provides various definitions describing this API.
7.5 PIC32MZ Embedded Connectivity (EC) MPLAB Harmony Help Using the Library
7-4237
7.6 Library Interface
7.6.1 Initialization Functions
Functions
Name Description
BSP_Initialize Performs the necessary actions to initialize a board
Description
7.6.1.1 BSP_Initialize Function
C
void BSP_Initialize();
Description
This routine performs the neccassary actions to initialize a board
Preconditions
None
Returns
None
7.6.2 LED Control Functions
Functions
Name Description
BSP_SwitchOFFLED Turns OFF specified LED on the board.
BSP_SwitchONLED Turns ON specified LED on the board.
BSP_ToggleLED Toggles specified LED on the board.
BSP_SwitchToggleLED Toggles the onboard LED.
Description
7.6 Library Interface MPLAB Harmony Help LED Control Functions
7-4238
7.6.2.1 BSP_SwitchOFFLED Function
C
void BSP_SwitchOFFLED(
BSP_LED led
);
Description
This fucntion turns OFF specified LED on the board.
Preconditions
BSP should be initialized by calling void BSP_Initialize(void) function.
Parameters
Parameters Description
led LED ID as specified by BSP_LED enum.
Returns
None
7.6.2.2 BSP_SwitchONLED Function
C
void BSP_SwitchONLED(
BSP_LED led
);
Description
This fucntion turns ON specified LED on the board.
Preconditions
BSP should be initialized by calling void BSP_Initialize(void) function.
Parameters
Parameters Description
led LED ID as specified by BSP_LED enum.
Returns
None
7.6.2.3 BSP_ToggleLED Function
C
void BSP_ToggleLED(
BSP_LED led
);
Description
This fucntion Toggles specified LED on the board.
7.6 Library Interface MPLAB Harmony Help LED Control Functions
7-4239
Preconditions
BSP should be initialized by calling void BSP_Initialize(void) function.
Parameters
Parameters Description
led LED ID as specified by BSP_LED enum.
Returns
None
7.6.2.4 BSP_SwitchToggleLED Function
C
void BSP_SwitchToggleLED(
BSP_LED led
);
Description
This routine toggles the onboard LED.
7.6.3 Other Functions
Functions
Name Description
SYSTEMConfigPerformance Configures the system cache and flash wait states for maximum performance.
BSP_ReadCoreTimer Returns the current core timer value.
BSP_ReadSwitch Reads the switch state.
Description
7.6.3.1 SYSTEMConfigPerformance Function
C
unsigned int SYSTEMConfigPerformance(
unsigned int sys_clock
);
Description
This function configures the system cache and flash wait states for maximum performance.
Preconditions
None
7.6 Library Interface MPLAB Harmony Help Other Functions
7-4240
Parameters
Parameters Description
sys_clock Value of system clock
7.6.3.2 BSP_ReadCoreTimer Function
C
uint32_t BSP_ReadCoreTimer();
Description
Returns the current core timer value.
Preconditions
None
7.6.3.3 BSP_ReadSwitch Function
C
BSP_SWITCH_STATE BSP_ReadSwitch(
BSP_SWITCH bspSwitch
);
Description
Reads the switch state.
Preconditions
None
Parameters
Parameters Description
bspSwitch Switch ID as specified by BSP_SWITCH enum.
Return Values
Return Values Description
BSP_SWITCH_STATE_PRESSED Switch is pressed.
BSP_SWITCH_STATE_RELEASED Switch is not pressed.
7.6.4 Data Types and Constants
Enumerations
Name Description
BSP_LED Holds LED numbers.
BSP_SWITCH Holds Switch numbers.
BSP_SWITCH_STATE Holds Switch status.
7.6 Library Interface MPLAB Harmony Help Data Types and Constants
7-4241
Macros
Name Description
BSP_ANALOG_PIN Defines the constant which identifies analog pin
BSP_DIGITAL_PIN Defines the constant which identifies digital pin
BSP_INPUT Defines the constant which identifies input
BSP_OUTPUT Defines the constant which identifies output
Description
7.6.4.1 BSP_ANALOG_PIN Macro
C
#define BSP_ANALOG_PIN PORTS_PIN_MODE_ANALOG
Description
analog Pin Constant
This constant identifies analog pin
7.6.4.2 BSP_DIGITAL_PIN Macro
C
#define BSP_DIGITAL_PIN PORTS_PIN_MODE_DIGITAL
Description
Digital Pin Constant
This constant identifies digital pin
7.6.4.3 BSP_INPUT Macro
C
#define BSP_INPUT 1
Description
Input Constant
This constant identifies input
7.6.4.4 BSP_OUTPUT Macro
C
#define BSP_OUTPUT 0
Description
Output Constant
7.6 Library Interface MPLAB Harmony Help Data Types and Constants
7-4242
This constant identifies output
7.6.4.5 BSP_LED Enumeration
C
typedef enum {
LED_3 = PORTS_BIT_POS_0,
LED_4 = PORTS_BIT_POS_1,
LED_5 = PORTS_BIT_POS_2,
LED_6 = PORTS_BIT_POS_3,
LED_7 = PORTS_BIT_POS_4,
LED_8 = PORTS_BIT_POS_5,
LED_9 = PORTS_BIT_POS_6,
LED_10 = PORTS_BIT_POS_7
} BSP_LED;
Description
LED Number.
This enumeration defines the LED numbers.
Members
Members Description
LED_3 = PORTS_BIT_POS_0 LED 3
LED_4 = PORTS_BIT_POS_1 LED 4
LED_5 = PORTS_BIT_POS_2 LED 5
LED_6 = PORTS_BIT_POS_3 LED 6
LED_7 = PORTS_BIT_POS_4 LED 7
LED_8 = PORTS_BIT_POS_5 LED 8
LED_9 = PORTS_BIT_POS_6 LED 9
LED_10 = PORTS_BIT_POS_7 LED 10
Remarks
None.
7.6.4.6 BSP_SWITCH Enumeration
C
typedef enum {
SWITCH_3 = PORTS_BIT_POS_6,
SWITCH_4 = PORTS_BIT_POS_13,
SWITCH_5 = PORTS_BIT_POS_7,
SWITCH_6 = PORTS_BIT_POS_7
} BSP_SWITCH;
Description
BSP Switch.
This enumeration defines the Switch numbers.
7.6 Library Interface MPLAB Harmony Help Data Types and Constants
7-4243
Members
Members Description
SWITCH_3 = PORTS_BIT_POS_6 SWITCH 3
SWITCH_4 = PORTS_BIT_POS_13 SWITCH 4
SWITCH_5 = PORTS_BIT_POS_7 SWITCH 5
SWITCH_6 = PORTS_BIT_POS_7 SWITCH 6
Remarks
None.
7.6.4.7 BSP_SWITCH_STATE Enumeration
C
typedef enum {
BSP_SWITCH_STATE_PRESSED = 0,
BSP_SWITCH_STATE_RELEASED = 1
} BSP_SWITCH_STATE;
Description
BSP Switch state.
This enumeration defines the switch state.
Members
Members Description
BSP_SWITCH_STATE_PRESSED = 0 Switch pressed
BSP_SWITCH_STATE_RELEASED = 1 Switch not pressed
Remarks
None.
7.6 Library Interface MPLAB Harmony Help Data Types and Constants
7-4244
7.7 Files
Files
Name Description
bsp_config.h Board support configuration file.
Description
7.7.1 bsp_config.h
Board support configuration file.
This contains all the configuration that is required to be done for the application running on PIC32 USB starter kit
Enumerations
Name Description
BSP_LED Holds LED numbers.
BSP_SWITCH Holds Switch numbers.
BSP_SWITCH_STATE Holds Switch status.
Functions
Name Description
BSP_Initialize Performs the necessary actions to initialize a board
BSP_ReadCoreTimer Returns the current core timer value.
BSP_ReadSwitch Reads the switch state.
BSP_SwitchOFFLED Turns OFF specified LED on the board.
BSP_SwitchONLED Turns ON specified LED on the board.
BSP_SwitchToggleLED Toggles the onboard LED.
BSP_ToggleLED Toggles specified LED on the board.
SYSTEMConfigPerformance Configures the system cache and flash wait states for maximum performance.
Macros
Name Description
BSP_ANALOG_PIN Defines the constant which identifies analog pin
BSP_DIGITAL_PIN Defines the constant which identifies digital pin
BSP_INPUT Defines the constant which identifies input
BSP_OUTPUT Defines the constant which identifies output
File Name
bsp_config.h
Company
Microchip Technology Incorported
7.7 Files MPLAB Harmony Help bsp_config.h
7-4245
8 Symbol Reference
8 MPLAB Harmony Help
8-4246
8.1 Macros
Macros
Name Description
DRV_ETHMAC_INDEX_0 Ethernet driver index definitions.
DRV_ETHMAC_INDEX_COUNT Number of valid Ethernet driver indices.
8.1.1 DRV_ETHMAC_INDEX_0 Macro
C
#define DRV_ETHMAC_INDEX_0 0
Description
Ethernet Driver Module Index Numbers
These constants provide Ethernet driver index definitions.
Remarks
These constants should be used in place of hard-coded numeric literals.
These values should be passed into the DRV_ETHMAC_Initialize and DRV_ETHMAC_Open routines to identify the driver
instance in use.
8.1.2 DRV_ETHMAC_INDEX_COUNT Macro
C
#define DRV_ETHMAC_INDEX_COUNT ETH_NUMBER_OF_MODULES
Description
Ethernet Driver Module Index Count
This constant identifies number of valid Ethernet driver indices.
Remarks
This constant should be used in place of hard-coded numeric literals.
This value is derived from part-specific header files defined as part of the peripheral libraries.
8.1 Macros MPLAB Harmony Help DRV_ETHMAC_INDEX_COUNT Macro
8-4247
Index
_
_LIBQ_Q15_cos_Q2_13 function 5-1287
_LIBQ_Q15_sin_Q2_13 function 5-1286
_LIBQ_Q15FromFloat function 5-1298
_LIBQ_Q15FromString function 5-1301
_LIBQ_Q15Rand function 5-1297
_LIBQ_Q16_tan_Q2_29 function 5-1288
_LIBQ_Q16Div function 5-1281
_LIBQ_Q16Exp function 5-1285
_LIBQ_Q16Power function 5-1284
_LIBQ_Q16Sqrt function 5-1281
_LIBQ_Q2_13_acos_Q15 function 5-1292
_LIBQ_Q2_13_asin_Q15 function 5-1289
_LIBQ_Q2_13_atan_Q7_8 function 5-1294
_LIBQ_Q2_13_atan2_Q7_8 function 5-1295
_LIBQ_Q2_29_acos_Q31 function 5-1292
_LIBQ_Q2_29_acos_Q31_Fast function 5-1293
_LIBQ_Q2_29_asin_Q31 function 5-1290
_LIBQ_Q2_29_asin_Q31_Fast function 5-1291
_LIBQ_Q2_29_atan_Q16 function 5-1294
_LIBQ_Q2_29_atan2_Q16 function 5-1296
_LIBQ_Q3_12_log10_Q16 function 5-1282
_LIBQ_Q31_cos_Q2_29 function 5-1287
_LIBQ_Q31_sin_Q2_29 function 5-1286
_LIBQ_Q31FromFloat function 5-1299
_LIBQ_Q31Rand function 5-1297
_LIBQ_Q4_11_ln_Q16 function 5-1283
_LIBQ_Q5_10_log2_Q16 function 5-1283
_LIBQ_Q7_8_tan_Q2_13 function 5-1289
_LIBQ_ToFloatQ15 function 5-1300
_LIBQ_ToFloatQ31 function 5-1300
_LIBQ_ToStringQ15 function 5-1302
_PARM_EQUAL_FILTER structure 5-1265
_PARM_EQUAL_FILTER_16 structure 5-1266
_PARM_EQUAL_FILTER_32 structure 5-1266
_Q0_15 type 5-1305
_Q0_31 type 5-1305
_Q15 type 5-1305
_Q15_16 type 5-1306
_Q15_MAX macro 5-1302
_Q15_MIN macro 5-1303
_Q16 type 5-1306
_Q16_MAX macro 5-1303
_Q16_MIN macro 5-1303
_Q2_13 type 5-1306
_Q2_13_MAX macro 5-1303
_Q2_13_MIN macro 5-1303
_Q2_29 type 5-1306
_Q2_29_MAX macro 5-1303
_Q2_29_MIN macro 5-1303
_Q3_12 type 5-1306
_Q3_12_MAX macro 5-1304
_Q3_12_MIN macro 5-1304
_Q31 type 5-1306
_Q31_MAX macro 5-1304
_Q31_MIN macro 5-1304
_Q4_11 type 5-1307
_Q4_11_MAX macro 5-1304
_Q4_11_MIN macro 5-1304
_Q5_10 type 5-1307
_Q5_10_MAX macro 5-1305
_Q5_10_MIN macro 5-1305
_Q7_8 type 5-1307
_Q7_8_MAX macro 5-1305
_Q7_8_MIN macro 5-1305
_SYS_MSG_H macro 5-3462
_SYS_MSG_OBJECT macro 5-3462
_SYS_TASKS_PRIORITIES enumeration 5-3341
2
2. Creating Your Own Applications 1-21
3
3. Release Notes & Information 1-23
9 MPLAB Harmony Help
a
4
4. Previous Releases 1-32
5
5. Tips and Tricks 1-36
6
6. Glossary 1-37
A
About CAN Protocol 5-1555
Abstract Control Model (ACM) 5-4063
Abstraction Model 5-195, 5-228, 5-255, 5-290, 5-300, 5-310,
5-320, 5-334, 5-344, 5-368, 5-398, 5-419, 5-458, 5-513, 5-553,
5-607, 5-695, 5-1112, 5-1129, 5-1313, 5-3349, 5-3364, 5-3420,
5-3442, 5-3466, 5-3502, 5-3531, 5-3570, 5-3576, 5-3599,
5-3615, 5-3626, 5-3637, 5-3647, 5-3655, 5-3660, 5-3691,
5-3699, 5-3710, 5-3719, 5-3749, 5-3772, 5-3795, 5-3800,
5-3807, 5-3810, 5-3823, 5-3859, 5-3869, 5-3882, 5-3914,
5-3918, 5-3931, 5-3956, 5-4005, 5-4061, 5-4103, 5-4169
accept function 5-3602
Accessing the Result Buffers 5-1373
ADC Driver Library 5-193
ADC Peripheral Library 5-1361
ADC_ACQUISITION_TIME type 5-1438
ADC_BUFFER_MODE enumeration 5-1426
ADC_CHANNEL_GROUP enumeration 5-1423
ADC_CHANNEL123_INPUTS_NEG enumeration 5-1432
ADC_CHANNEL123_INPUTS_POS enumeration 5-1433
ADC_CLOCK_SOURCE enumeration 5-1424
ADC_CONVERSION_CLOCK type 5-1438
ADC_CONVERSION_ORDER enumeration 5-1435
ADC_CONVERSION_TRIGGER_SOURCE enumeration 5-1424
ADC_DMA_ADDRESS_INCREMENT enumeration 5-1435
ADC_DMA_BUFFER_MODE enumeration 5-1431
ADC_DMA_INPUT_BUFFER enumeration 5-1437
ADC_INPUTS_NEGATIVE enumeration 5-1421
ADC_INPUTS_POSITIVE enumeration 5-1433
ADC_INPUTS_SCAN enumeration 5-1428
ADC_MODULE_ID enumeration 5-1420
ADC_MUX enumeration 5-1427
ADC_PAIR enumeration 5-1431
ADC_REFERENCE_INPUT enumeration 5-1430
ADC_RESULT_BUF_STATUS enumeration 5-1427
ADC_RESULT_FORMAT enumeration 5-1430
ADC_RESULT_SIZE enumeration 5-1426
ADC_SAMPLE type 5-1439
ADC_SAMPLES_PER_INTERRUPT enumeration 5-1422
ADC_SAMPLING_MODE enumeration 5-1427
ADC_VOLTAGE_REFERENCE enumeration 5-1420
ADCP Peripheral Library 5-1471
ADCP_CLASS12_INPUT_ID enumeration 5-1507
ADCP_CLOCK_SOURCE enumeration 5-1507
ADCP_DCMP_ID enumeration 5-1513
ADCP_DSH_ID enumeration 5-1509
ADCP_INPUT_ID enumeration 5-1510
ADCP_MODULE_ID enumeration 5-1506
ADCP_ODFLTR_ID enumeration 5-1513
ADCP_ODFLTR_OSR enumeration 5-1514
ADCP_SCAN_TRG_SRC enumeration 5-1514
ADCP_SH_ID enumeration 5-1508
ADCP_SH_MODE enumeration 5-1509
ADCP_TRG_SRC enumeration 5-1515
ADCP_VREF_SOURCE enumeration 5-1507
adhocMode enumeration 5-655
Advanced Data Transfer 5-517
Advanced Font Features 5-1119
Advanced MPFS2 Settings 5-3544
AF_INET macro 5-3609
Alarm Config 5-479
Alarm Functionality 5-466
Alarm Functionality Examples 5-481
Alarm Mode Operations 5-2710
Alpha Blending 5-1116, 5-1123
ALPHA_DELTA macro 5-294
AN_READY type 5-1517
AN_SELECT union 5-1516
Announce TCP/IP Stack Library 5-3569
9 MPLAB Harmony Help
b
ANNOUNCE_MAX_PAYLOAD macro 5-3571
ANNOUNCE_PORT macro 5-3571
Application Interaction 5-3380
Applications Help 3-61
Applications Overview 3-62
Architecture 5-3378
Architecture Overview 5-4132
Arcs 5-1114
ARP Changes 5-3551
ARP TCP/IP Stack Library 5-3574
arp.h 5-3596
arp_app_callbacks structure 5-3595
ARP_CACHE_ENTRIES_97J60 macro 5-3577
ARP_CACHE_ENTRIES_DEFAULT macro 5-3578
ARP_CACHE_ENTRIES_ENCJ60 macro 5-3578
ARP_CACHE_ENTRIES_ENCJ600 macro 5-3578
ARP_CACHE_ENTRIES_MRF24W macro 5-3578
ARP_CACHE_ENTRIES_PIC32INT macro 5-3578
ARP_CACHE_PENDING_ENTRY_TMO macro 5-3578
ARP_CACHE_PENDING_RETRY_TMO macro 5-3579
ARP_CACHE_PERMANENT_QUOTA macro 5-3579
ARP_CACHE_PURGE_QUANTA macro 5-3579
ARP_CACHE_PURGE_THRESHOLD macro 5-3579
ARP_CACHE_SOLVED_ENTRY_TMO macro 5-3579
arp_config.h 5-3597
arp_manager.h 5-3597
ARP_MODULE_CONFIG structure 5-3595
ARP_TASK_PROCESS_RATE macro 5-3579
Assigning Buffer Memory 5-1558
Asynchronous Counter 5-3017
Asynchronous USART Mode 5-3090
Audio Protocol Interface Mode 5-2817
audio_speaker 3-166
AUTH_LOCALIZED_PASSWORD_KEY_LEN macro 5-3826
B
Before You Start 1-2
berekely_api_config.h 5-3613
Berkeley TCP/IP Stack Library 5-3598
berkeley_api.h 5-3613
BERKELEY_MODULE_CONFIG structure 5-3610
Bevels 5-1115
bind function 5-3603
biquad16 structure 5-1264
BLACK macro 5-941
Blocking Applications 3-99
BLUE macro 5-941
BMX Peripheral Library 5-1519
BMX_MODULE_ID enumeration 5-1543
Board Drivers 7-4229
Board Support Packages Help 7-4227
Board Support Packages Overview 7-4228
BRIGHTBLUE macro 5-941
BRIGHTCYAN macro 5-942
BRIGHTGREEN macro 5-942
BRIGHTMAGENTA macro 5-942
BRIGHTRED macro 5-942
BRIGHTYELLOW macro 5-942
BROWN macro 5-942
BSP_ANALOG_PIN macro 7-4242
bsp_config.h 7-4245
BSP_DIGITAL_PIN macro 7-4242
BSP_Initialize function 7-4238
BSP_INPUT macro 7-4242
BSP_LED enumeration 7-4243
BSP_OUTPUT macro 7-4242
BSP_ReadCoreTimer function 7-4241
BSP_ReadSwitch function 7-4241
BSP_SWITCH enumeration 7-4243
BSP_SWITCH_STATE enumeration 7-4244
BSP_SwitchOFFLED function 7-4239
BSP_SwitchONLED function 7-4239
BSP_SwitchToggleLED function 7-4240
BSP_ToggleLED function 7-4239
Building MPFS2 Images 5-3542
Building Projects 4-178
Building Projects Help 4-177
Building the Application 3-109, 3-126, 3-145
9 MPLAB Harmony Help
c
Building the Library 5-202, 5-236, 5-262, 5-291, 5-301, 5-311,
5-326, 5-335, 5-352, 5-377, 5-400, 5-428, 5-482, 5-519, 5-574,
5-609, 5-701, 5-1124, 5-1130, 5-1324, 5-2256, 5-3368, 5-3444,
5-3474, 5-3517, 5-3572, 5-3580, 5-3601, 5-3618, 5-3630,
5-3640, 5-3648, 5-3657, 5-3692, 5-3700, 5-3711, 5-3723,
5-3753, 5-3773, 5-3796, 5-3804, 5-3808, 5-3814, 5-3832,
5-3862, 5-3875, 5-3888, 5-3916, 5-3921, 5-3935, 5-3957
Builiding the Library 5-3532
Bulk and Interrupt Transfers 5-570
BURLYWOOD macro 5-942
Bus Arbiter 5-1522
C
Cache Control 5-1522
Cache Control Operations 5-2431
Cache Line Operations 5-2432
Cache Status Operations 5-2433
Can Bit Time Quanta 5-1556
CAN Peripheral Library 5-1553
CAN_CHANNEL enumeration 5-1620
CAN_CHANNEL_EVENT enumeration 5-1621
CAN_CHANNEL_MASK enumeration 5-1622
CAN_DNET_FILTER_SIZE enumeration 5-1623
CAN_ERROR_STATE enumeration 5-1624
CAN_FILTER enumeration 5-1625
CAN_FILTER_MASK enumeration 5-1627
CAN_FILTER_MASK_TYPE enumeration 5-1627
CAN_FUNCTONAL_MODES enumeration 5-1628
CAN_ID_TYPE enumeration 5-1628
CAN_MODULE_EVENT enumeration 5-1629
CAN_MODULE_ID enumeration 5-1629
CAN_MSG_EID structure 5-1630
CAN_OPERATION_MODES enumeration 5-1630
CAN_RECEIVE_CHANNEL enumeration 5-1631
CAN_RECEIVE_MODES enumeration 5-1631
CAN_RX_DATA_MODE enumeration 5-1632
CAN_RX_DATA_ONLY_SIZE_BYTES macro 5-1636
CAN_RX_MSG_BUFFER union 5-1632
CAN_RX_MSG_SID structure 5-1633
CAN_TIME_SEGMENT_LENGTH enumeration 5-1633
CAN_TX_CHANNEL_STATUS enumeration 5-1634
CAN_TX_MSG_BUFFER union 5-1634
CAN_TX_MSG_SID structure 5-1635
CAN_TX_RTR enumeration 5-1635
CAN_TX_RX_MESSAGE_SIZE_BYTES macro 5-1636
CAN_TXCHANNEL_PRIORITY enumeration 5-1635
cdc_basic 3-167
cdc_com_port_dual 3-154
cdc_com_port_single 3-152
cdc_serial_emulator 3-156
CH_CLR0 macro 5-943
CH_CLR1 macro 5-943
CH_CLR10 macro 5-943
CH_CLR11 macro 5-943
CH_CLR12 macro 5-943
CH_CLR13 macro 5-943
CH_CLR14 macro 5-944
CH_CLR15 macro 5-944
CH_CLR2 macro 5-944
CH_CLR3 macro 5-944
CH_CLR4 macro 5-944
CH_CLR5 macro 5-944
CH_CLR6 macro 5-944
CH_CLR7 macro 5-945
CH_CLR8 macro 5-945
CH_CLR9 macro 5-945
Change Notification 5-3472
Changing the Clock 5-3351
Changing the Default Font 5-1119
Channel Configuration 5-1559
Channel Events 5-1562
Channel Management 5-1743
CHART_MARGIN macro 5-945
CHART_YGRIDCOUNT macro 5-945
CHARTPARAM structure 5-888
Cient Transfer - Core 5-423
ClearPaletteChangeError function 5-827
Client Access 5-422, 5-516
Client Access Operation 5-346
Client Basic Operation 5-346
9 MPLAB Harmony Help
d
Client Block Data Operation 5-348
Client Config 5-480
Client Configuration 5-428
Client Core Functionality 5-196
Client Data Handling 5-4111
Client Functionality 5-608
Client Interaction 5-462
Client Operation 5-373
Client Setup 5-4105
Client Subclass Specific 5-4120
Client Transfer - Advanced 5-425
CLK_PERIPH_BUS_MZ enumeration 5-3361
CLK_SOURCE_PERIPHERAL enumeration 5-3361
Clock Sources 5-2334
Clock System Service Library 5-3347
closesocket function 5-3603
Closing a File 5-3395
CMP_CLOCK_DIVIDE enumeration 5-1716
CMP_CVREF_BANDGAP_SELECT enumeration 5-1716
CMP_CVREF_REFERENCE_SELECT enumeration 5-1717
CMP_CVREF_VALUE enumeration 5-1717
CMP_CVREF_VOLTAGE_SOURCE enumeration 5-1718
CMP_FILTER_CLOCK enumeration 5-1718
CMP_INTERRUPT_EVENT enumeration 5-1719
CMP_INVERTING_INPUT enumeration 5-1719
CMP_MASK_A enumeration 5-1719
CMP_MASK_B enumeration 5-1720
CMP_MASK_C enumeration 5-1721
CMP_MODULE_ID enumeration 5-1721
CMP_NON_INVERTING_INPUT enumeration 5-1722
CMP_SPEED_POWER enumeration 5-1722
Code Examples 5-197
COLOR_DEPTH macro 5-325
Colors 5-1123
Communication Mode 5-2822
Comparator Peripheral Library 5-1667
Comparison of API Names 5-3386
Compression Library 4-181
Configuration 7-4228
Configuring the Application 3-109, 3-127, 3-146
Configuring the Comparator Interrupts 5-1671
Configuring the Driver Library 5-311
Configuring the Hardware 3-67, 3-69, 3-72, 3-74, 3-76, 3-86,
3-88, 3-89, 3-90, 3-109, 3-114, 3-115, 3-116, 3-117, 3-126,
3-131, 3-133, 3-135, 3-145, 3-153, 3-154, 3-156, 3-158, 3-160,
3-161, 3-162, 3-164, 3-165, 3-167, 3-168, 3-169
Configuring the Libraries 3-110, 3-127, 3-146
Configuring the Library 5-202, 5-234, 5-259, 5-290, 5-300,
5-321, 5-335, 5-349, 5-376, 5-400, 5-428, 5-474, 5-519, 5-574,
5-608, 5-701, 5-1123, 5-1130, 5-1322, 5-1380, 5-1480, 5-1526,
5-1566, 5-1748, 5-1866, 5-2089, 5-2175, 5-2205, 5-2256,
5-2294, 5-2336, 5-2434, 5-2488, 5-2601, 5-2666, 5-2690,
5-2712, 5-2766, 5-2823, 5-2903, 5-3021, 5-3101, 5-3182,
5-3322, 5-3352, 5-3366, 5-3424, 5-3443, 5-3474, 5-3516,
5-3532, 5-3571, 5-3577, 5-3600, 5-3616, 5-3627, 5-3638,
5-3648, 5-3656, 5-3661, 5-3691, 5-3700, 5-3710, 5-3720,
5-3749, 5-3773, 5-3796, 5-3801, 5-3807, 5-3814, 5-3824,
5-3860, 5-3872, 5-3884, 5-3914, 5-3920, 5-3933, 5-3957,
5-3985
Configuring the Stack 5-3974
connect function 5-3604
Constants 5-190
Control Transfers 5-565
Controlling the Conversion Process 5-1371
Controlling the Sampling Process 5-1370
Conversion Sequence Examples 5-1375
ConvertColor25 macro 5-945
ConvertColor50 macro 5-946
ConvertColor75 macro 5-946
CopyPageWindow macro 5-946
Core Functionality 5-465, 5-515, 5-1112, 5-1315, 5-2896,
5-3366, 5-3883, 5-3932, 5-3956
Counter Modification 5-465
Creating Your Own USB Device 5-3970
Critical Section Operation 5-1320
Critical Sections 5-3422
CRYPT_AES_CBC_Decrypt function 5-1156
CRYPT_AES_CBC_Encrypt function 5-1157
CRYPT_AES_CTR_Encrypt function 5-1157
CRYPT_AES_CTX structure 5-1161
CRYPT_AES_DIRECT_Decrypt function 5-1158
CRYPT_AES_DIRECT_Encrypt function 5-1158
CRYPT_AES_IvSet function 5-1158
CRYPT_AES_KeySet function 5-1159
9 MPLAB Harmony Help
e
CRYPT_ECC_CTX structure 5-1162
CRYPT_ECC_DHE_KeyMake function 5-1146
CRYPT_ECC_DHE_SharedSecretMake function 5-1147
CRYPT_ECC_DSA_HashSign function 5-1147
CRYPT_ECC_DSA_HashVerify function 5-1148
CRYPT_ECC_Free function 5-1148
CRYPT_ECC_Initialize function 5-1148
CRYPT_ECC_KeySizeGet function 5-1149
CRYPT_ECC_PrivateImport function 5-1149
CRYPT_ECC_PublicExport function 5-1150
CRYPT_ECC_PublicImport function 5-1150
CRYPT_ECC_SignatureSizeGet function 5-1150
CRYPT_ERROR_StringGet function 5-1132
CRYPT_HMAC_CTX structure 5-1162
CRYPT_HMAC_DataAdd function 5-1135
CRYPT_HMAC_Finalize function 5-1136
CRYPT_HMAC_SetKey function 5-1136
CRYPT_HUFFMAN_Compress function 5-1145
CRYPT_HUFFMAN_DeCompress function 5-1146
CRYPT_MD5_CTX structure 5-1162
CRYPT_MD5_DataAdd function 5-1159
CRYPT_MD5_Finalize function 5-1160
CRYPT_MD5_Initialize function 5-1161
CRYPT_RNG_BlockGenerate function 5-1143
CRYPT_RNG_CTX structure 5-1162
CRYPT_RNG_Get function 5-1144
CRYPT_RNG_Initialize function 5-1144
CRYPT_RSA_CTX structure 5-1163
CRYPT_RSA_EncryptSizeGet function 5-1154
CRYPT_RSA_Free function 5-1154
CRYPT_RSA_Initialize function 5-1154
CRYPT_RSA_PrivateDecrypt function 5-1155
CRYPT_RSA_PrivateKeyDecode function 5-1155
CRYPT_RSA_PublicEncrypt function 5-1156
CRYPT_RSA_PublicKeyDecode function 5-1156
CRYPT_SHA_CTX structure 5-1163
CRYPT_SHA_DataAdd function 5-1141
CRYPT_SHA_Finalize function 5-1142
CRYPT_SHA_Initialize function 5-1142
CRYPT_SHA256_CTX structure 5-1163
CRYPT_SHA256_DataAdd function 5-1139
CRYPT_SHA256_Finalize function 5-1139
CRYPT_SHA256_Initialize function 5-1140
CRYPT_SHA384_CTX structure 5-1163
CRYPT_SHA384_DataAdd function 5-1137
CRYPT_SHA384_Finalize function 5-1137
CRYPT_SHA384_Initialize function 5-1138
CRYPT_SHA512_CTX structure 5-1164
CRYPT_SHA512_DataAdd function 5-1133
CRYPT_SHA512_Finalize function 5-1134
CRYPT_SHA512_Initialize function 5-1134
CRYPT_TDES_CBC_Decrypt function 5-1151
CRYPT_TDES_CBC_Encrypt function 5-1152
CRYPT_TDES_CTX structure 5-1164
CRYPT_TDES_IvSet function 5-1152
CRYPT_TDES_KeySet function 5-1153
Crypto Library 4-181
crypto.h 5-1165
Cryptographic (Crypto) Library 5-1127
Customizing the Application 3-110, 3-126, 3-147
CYAN macro 5-946
D
DARKGRAY macro 5-946
DARKORANGE macro 5-947
Data Transfer 5-516
Data Types 5-188
Data Types and Constants 5-305, 5-317, 5-340, 5-4174,
5-4209, 7-4241
DATASERIES structure 5-889
ddns.h 5-3653
DDNS_CHECKIP_SERVER macro 5-3648
ddns_config.h 5-3654
DDNS_DEFAULT_PORT macro 5-3648
DDNS_MODULE_CONFIG structure 5-3650
DDNS_POINTERS structure 5-3651
DDNS_SERVICES enumeration 5-3652
DDNS_STATUS enumeration 5-3652
9 MPLAB Harmony Help
f
Defining Colors 5-1118
DELAY_FIRST_PROBE_TIME macro 5-3802
Delays 5-3512
Demonstration 5-3957
Demonstration Application Configurations 3-151
Demonstration Board Information 3-77, 3-91, 3-118, 3-136,
3-170
Demonstrations 3-65, 3-85, 3-114, 3-131, 3-152
Descriptor Table Example 5-1917
Descriptors 5-4010
Developing Vendor-specific Function Drivers 5-4017
Development Information (Advance Information) 5-3565
Device 3-152
Device Control System Service Library 5-3363
Device Events 5-4015
DHCP Server TCP/IP Stack Library 5-3625
DHCP TCP/IP Stack Library 5-3614
dhcp.h 5-3624
DHCP_CLIENT_ENABLED macro 5-3617
DHCP_CLIENT_PORT macro 5-3617
dhcp_config.h 5-3624
DHCP_MODULE_CONFIG structure 5-3622
DHCP_SERVER_GATEWAY_ADDRESS macro 5-3628
DHCP_SERVER_IP_ADDRESS macro 5-3628
DHCP_SERVER_NETMASK_ADDRESS macro 5-3628
DHCP_SERVER_POOL_ENTRY_TYPE enumeration 5-3633
DHCP_SERVER_PORT macro 5-3617
DHCP_SERVER_PRIMARY_DNS_ADDRESS macro 5-3628
DHCP_SERVER_SECONDARY_DNS_ADDRESS macro
5-3628
DHCP_TASK_TICK_RATE macro 5-3617
DHCP_TIMEOUT macro 5-3617
dhcps.h 5-3635
dhcps_config.h 5-3635
DHCPS_IP_ADDRESS_RANGE_START macro 5-3629
DHCPS_LEASE_DURATION macro 5-3629
DHCPS_LEASE_ENTRIES_DEFAULT macro 5-3629
DHCPS_LEASE_ENTRY structure 5-3633
DHCPS_LEASE_HANDLE type 5-3634
DHCPS_LEASE_REMOVED_BEFORE_ACK macro 5-3629
DHCPS_LEASE_SOLVED_ENTRY_TMO macro 5-3629
DHCPS_MODULE_CONFIG structure 5-3634
DHCPS_TASK_PROCESS_RATE macro 5-3629
DisablePalette function 5-827
DisplayUpdatePending variable 5-887
DMA Mode 5-2898
DMA Peripheral Library Help 5-1733
DMA_ADDRESS_OFFSET_TYPE enumeration 5-1821
DMA_CHANNEL enumeration 5-1821
DMA_CHANNEL_ADDRESSING_MODE enumeration 5-1822
DMA_CHANNEL_COLLISION enumeration 5-1822
DMA_CHANNEL_DATA_SIZE enumeration 5-1823
DMA_CHANNEL_PRIORITY enumeration 5-1823
DMA_CHANNEL_TRANSFER_DIRECTION enumeration
5-1824
DMA_CHANNEL_TRIGGER_TYPE enumeration 5-1824
DMA_CRC_BIT_ORDER enumeration 5-1824
DMA_CRC_BYTE_ORDER enumeration 5-1825
DMA_CRC_TYPE enumeration 5-1825
DMA_DESTINATION_ADDRESSING_MODE enumeration
5-1826
DMA_INT_TYPE enumeration 5-1826
DMA_ISR_TASK enumeration 5-307
DMA_MODULE_ID enumeration 5-1827
DMA_PATTERN_LENGTH enumeration 5-1827
DMA_PING_PONG_MODE enumeration 5-1828
DMA_SOURCE_ADDRESSING_MODE enumeration 5-1828
DMA_TRANSFER_MODE enumeration 5-1829
DMA_TRIGGER_SOURCE enumeration 5-1829
DNS TCP/IP Stack Library 5-3636
dns.h 5-3645
DNS_CLIENT_ARP_TMO macro 5-3639
DNS_CLIENT_MODULE_CONFIG structure 5-3643
DNS_CLIENT_OPEN_TMO macro 5-3639
DNS_CLIENT_PORT macro 5-3639
DNS_CLIENT_SERVER_TMO macro 5-3639
DNS_CLIENT_TASK_PROCESS_RATE macro 5-3640
DNS_CLIENT_VERSION_NO macro 5-3640
dns_config.h 5-3645
DNS_RESOLVE_TYPE enumeration 5-3643
9 MPLAB Harmony Help
g
DNS_RESULT enumeration 5-3644
DNS_SERVER_MODULE_CONFIG structure 5-3644
Double Buffering 5-1121
doubleBuffEnabled variable 5-888
DrawArc function 5-827
Driver Initialization 5-554
Driver Library Help 5-185
Driver Library Overview 5-185
driver.h 5-192
driver_common.h 5-193
DRIVER_COUNT macro 5-325
DriverInterfaceInit function 5-291
drv_adc.c 5-202
drv_adc.h 5-225
DRV_ADC_ACQUISITION_TIME macro 5-219
DRV_ADC_ALTERNATE_INPUT_SAMPLING_ENABLE macro
5-219
DRV_ADC_ANALOG_INPUT macro 5-220
DRV_ADC_AUTO_SAMPLING_ENABLE macro 5-220
drv_adc_client_multi.c 5-203
drv_adc_client_single.c 5-203
DRV_ADC_CLIENT_STATUS enumeration 5-217
DRV_ADC_CLIENTS_NUMBER macro 5-220
DRV_ADC_ClientStatus function 5-210
DRV_ADC_Close function 5-210
DRV_ADC_CONVERSION_CLOCK_PRESCALER macro 5-220
DRV_ADC_CONVERSION_CLOCK_SOURCE macro 5-221
DRV_ADC_CONVERSION_TRIGGER_SOURCE macro 5-221
DRV_ADC_Deinitialize function 5-205
drv_adc_hw_dynamic.c 5-203
drv_adc_hw_static.c 5-203
DRV_ADC_INDEX macro 5-221
DRV_ADC_INDEX_0 macro 5-222
DRV_ADC_INDEX_1 macro 5-222
DRV_ADC_INDEX_2 macro 5-222
DRV_ADC_INDEX_COUNT macro 5-222
DRV_ADC_INIT structure 5-218
DRV_ADC_INIT_FLAGS enumeration 5-219
DRV_ADC_Initialize function 5-206
DRV_ADC_InputsRegister function 5-211
DRV_ADC_INSTANCES_NUMBER macro 5-222
DRV_ADC_INTERNAL_BUFFER_SIZE macro 5-223
DRV_ADC_INTERRUPT_MODE macro 5-223
DRV_ADC_INTERRUPT_SOURCE macro 5-223
DRV_ADC_Open function 5-211
DRV_ADC_PERIPHERAL_ID macro 5-223
DRV_ADC_POWER_STATE macro 5-224
DRV_ADC_Reinitialize function 5-207
DRV_ADC_RESULT_FORMAT macro 5-224
DRV_ADC_SampleMaxGet function 5-214
DRV_ADC_SampleMinGet function 5-215
DRV_ADC_SAMPLES_PER_INTERRUPT macro 5-224
DRV_ADC_SamplesAvailable function 5-212
DRV_ADC_SamplesRead function 5-215
DRV_ADC_SamplesReadLatest function 5-216
DRV_ADC_Start function 5-213
DRV_ADC_Status function 5-208
DRV_ADC_Stop function 5-214
DRV_ADC_STOP_ON_CONVERSION_ENABLE macro 5-224
DRV_ADC_Tasks function 5-209
DRV_ADC_VOLTAGE_REFERENCE macro 5-225
DRV_CLIENT_STATUS enumeration 5-188
DRV_CONFIG_NOT_SUPPORTED macro 5-191
drv_ethernet_flags.h 5-252, 5-288
drv_ethmac.h 5-252
DRV_ETHMAC_CLIENTS_NUMBER macro 5-235
drv_ethmac_config.h 5-253
DRV_ETHMAC_INDEX macro 5-235
DRV_ETHMAC_INDEX_0 macro 8-4247
DRV_ETHMAC_INDEX_1 macro 5-251
DRV_ETHMAC_INDEX_COUNT macro 8-4247
DRV_ETHMAC_INSTANCES_NUMBER macro 5-235
DRV_ETHMAC_INTERRUPT_MODE macro 5-235
DRV_ETHMAC_INTERRUPT_SOURCE macro 5-236
DRV_ETHMAC_PERIPHERAL_ID macro 5-236
DRV_ETHMAC_PIC32MACClose function 5-238
DRV_ETHMAC_PIC32MACEventAcknowledge function 5-243
DRV_ETHMAC_PIC32MACEventMaskSet function 5-244
DRV_ETHMAC_PIC32MACEventPendingGet function 5-245
9 MPLAB Harmony Help
h
DRV_ETHMAC_PIC32MACGetConfig function 5-238
DRV_ETHMAC_PIC32MACLinkCheck function 5-239
DRV_ETHMAC_PIC32MACOpen function 5-239
DRV_ETHMAC_PIC32MACPacketRx function 5-241
DRV_ETHMAC_PIC32MACPacketTx function 5-242
DRV_ETHMAC_PIC32MACPowerMode function 5-246
DRV_ETHMAC_PIC32MACProcess function 5-246
DRV_ETHMAC_PIC32MACRxFilterHashTableEntrySet function
5-242
DRV_ETHMAC_PIC32MACSetup function 5-240
DRV_ETHMAC_PIC32MACTeardown function 5-240
DRV_ETHMAC_POWER_STATE macro 5-236
drv_ethphy.h 5-286
DRV_ETHPHY_CLIENT_STATUS enumeration 5-284
DRV_ETHPHY_CLIENTS_NUMBER macro 5-260
DRV_ETHPHY_ClientStatus function 5-268
DRV_ETHPHY_Close function 5-268
drv_ethphy_config.h 5-288
DRV_ETHPHY_Deinitialize function 5-264
DRV_ETHPHY_HWConfigFlagsGet function 5-269
DRV_ETHPHY_INDEX macro 5-260
DRV_ETHPHY_INDEX_0 macro 5-260
DRV_ETHPHY_INDEX_1 macro 5-251
DRV_ETHPHY_INDEX_COUNT macro 5-261
DRV_ETHPHY_INIT structure 5-285
DRV_ETHPHY_Initialize function 5-264
DRV_ETHPHY_INSTANCES_NUMBER macro 5-261
DRV_ETHPHY_LinkScanRead function 5-270
DRV_ETHPHY_LinkScanStart function 5-270
DRV_ETHPHY_LinkScanStop function 5-271
DRV_ETHPHY_LinkStatusGet function 5-271
DRV_ETHPHY_NegotiationIsComplete function 5-272
DRV_ETHPHY_NegotiationResultGet function 5-273
DRV_ETHPHY_Open function 5-273
DRV_ETHPHY_PERIPHERAL_ID macro 5-261
DRV_ETHPHY_Reinitialize function 5-265
DRV_ETHPHY_Reset function 5-274
DRV_ETHPHY_RestartNegotiation function 5-275
DRV_ETHPHY_Setup function 5-275
DRV_ETHPHY_SMIClockSet function 5-276
DRV_ETHPHY_SMIisBusy function 5-277
DRV_ETHPHY_SMIReadResultGet function 5-277
DRV_ETHPHY_SMIReadStart function 5-278
DRV_ETHPHY_SMIScanDataGet function 5-278
DRV_ETHPHY_SMIScanStart function 5-279
DRV_ETHPHY_SMIScanStatusGet function 5-279
DRV_ETHPHY_SMIScanStop function 5-280
DRV_ETHPHY_SMIWriteStart function 5-280
DRV_ETHPHY_Status function 5-266
DRV_ETHPHY_Tasks function 5-267
DRV_ETHPHY_VersionGet function 5-283
DRV_ETHPHY_VersionStrGet function 5-284
drv_gfx_config_template.h 5-299
drv_gfx_display.h 5-295
drv_gfx_lcc.h 5-296
drv_gfx_lcc_config_template.h 5-308
drv_gfx_otm2201a.h 5-318
drv_gfx_s1d13517.h 5-297
drv_gfx_s1d13517_config_template.h 5-332
drv_gfx_ssd1926.h 5-298
drv_gfx_ssd1926_config_template.h 5-341
DRV_HANDLE type 5-189
DRV_HANDLE_INVALID macro 5-191
DRV_IO_BUFFER_TYPES enumeration 5-189
DRV_IO_INTENT enumeration 5-189
DRV_IO_ISBLOCKING macro 5-191
DRV_IO_ISEXCLUSIVE macro 5-191
DRV_IO_ISNONBLOCKING macro 5-192
drv_nvm.h 5-365
DRV_NVM_BUFFER_HANDLE type 5-363
DRV_NVM_BUFFER_HANDLE_INVALID macro 5-362
DRV_NVM_BUFFER_OBJECT_NUMBER macro 5-349
DRV_NVM_BUFFER_STATUS enumeration 5-363
DRV_NVM_BufferStatus function 5-361
DRV_NVM_CLIENT_STATUS enumeration 5-364
DRV_NVM_CLIENTS_NUMBER macro 5-350
DRV_NVM_ClientStatus function 5-355
DRV_NVM_Close function 5-356
drv_nvm_config_template.h 5-366
9 MPLAB Harmony Help
i
DRV_NVM_Deinitialize function 5-353
DRV_NVM_Erase function 5-357
DRV_NVM_ERASE_SIZE macro 5-350
DRV_NVM_INDEX_0 macro 5-362
DRV_NVM_INDEX_1 macro 5-365
DRV_NVM_INDEX_COUNT macro 5-363
DRV_NVM_INIT structure 5-364
DRV_NVM_Initialize function 5-353
DRV_NVM_INSTANCES_NUMBER macro 5-350
DRV_NVM_INTERRUPT_MODE macro 5-350
DRV_NVM_Open function 5-357
DRV_NVM_Read function 5-359
DRV_NVM_ROW_SIZE macro 5-351
DRV_NVM_Status function 5-354
DRV_NVM_Tasks function 5-360
DRV_NVM_UNLOCK_KEY1 macro 5-351
DRV_NVM_UNLOCK_KEY2 macro 5-351
DRV_NVM_Write function 5-360
drv_pmp.h 5-395
DRV_PMP_CHIPX_STROBE_MODE enumeration 5-388
DRV_PMP_CLIENT_STATUS enumeration 5-388
DRV_PMP_CLIENTS_NUMBER macro 5-376
DRV_PMP_ClientStatus function 5-383
DRV_PMP_Close function 5-383
drv_pmp_config.h 5-396
DRV_PMP_Deinitialize function 5-378
DRV_PMP_ENDIAN_MODE enumeration 5-389
DRV_PMP_INDEX enumeration 5-389
DRV_PMP_INDEX_COUNT macro 5-388
DRV_PMP_INIT structure 5-389
DRV_PMP_Initialize function 5-379
DRV_PMP_INSTANCES_NUMBER macro 5-376
DRV_PMP_MODE_CONFIG structure 5-390
DRV_PMP_ModeConfig function 5-384
DRV_PMP_Open function 5-385
DRV_PMP_POLARITY_OBJECT structure 5-390
DRV_PMP_PORT_CONTROL enumeration 5-391
DRV_PMP_PORTS structure 5-391
DRV_PMP_QUEUE_ELEMENT_OBJ type 5-392
DRV_PMP_QUEUE_SIZE macro 5-376
DRV_PMP_Read function 5-386
DRV_PMP_Reinitialize function 5-380
DRV_PMP_Status function 5-381
DRV_PMP_Tasks function 5-382
DRV_PMP_TRANSFER_STATUS enumeration 5-392
DRV_PMP_TRANSFER_TYPE enumeration 5-393
DRV_PMP_TransferStatus function 5-387
DRV_PMP_VersionGet function 5-394
DRV_PMP_VersionStrGet function 5-394
DRV_PMP_WAIT_STATES structure 5-392
DRV_PMP_Write function 5-386
drv_sdcard.h 5-416
DRV_SDCARD_BUFFER_HANDLE type 5-414
DRV_SDCARD_BufferStatusGet function 5-409
DRV_SDCARD_CLIENT_STATUS enumeration 5-414
DRV_SDCARD_ClientStatus function 5-405
DRV_SDCARD_Close function 5-406
DRV_SDCARD_Deinitialize function 5-401
DRV_SDCARD_INDEX_0 macro 5-413
DRV_SDCARD_INDEX_1 macro 5-416
DRV_SDCARD_INDEX_2 macro 5-416
DRV_SDCARD_INDEX_3 macro 5-416
DRV_SDCARD_INDEX_COUNT macro 5-414
DRV_SDCARD_INIT type 5-415
DRV_SDCARD_Initialize function 5-402
DRV_SDCARD_MediaStatusGet function 5-410
DRV_SDCARD_Open function 5-407
DRV_SDCARD_Reinitialize function 5-403
DRV_SDCARD_SectorRead function 5-407
DRV_SDCARD_SectorsCountGet function 5-410
DRV_SDCARD_SectorSizeGet function 5-411
DRV_SDCARD_SectorWrite function 5-408
DRV_SDCARD_Status function 5-404
DRV_SDCARD_Tasks function 5-405
DRV_SDCARD_VersionGet function 5-412
DRV_SDCARD_VersionStrGet function 5-413
DRV_SDCARD_WriteProtectionIsEnabled function 5-412
drv_spi.h 5-455
9 MPLAB Harmony Help
j
DRV_SPI_BAUD_RATE macro 5-443
DRV_SPI_BAUD_RATE_CLOCK macro 5-444
DRV_SPI_BUFFER_EVENT enumeration 5-450
DRV_SPI_BUFFER_EVENT_HANDLER type 5-451
DRV_SPI_BUFFER_HANDLE type 5-452
DRV_SPI_BUFFER_HANDLE_INVALID macro 5-444
DRV_SPI_BUFFER_SIZE macro 5-444
DRV_SPI_BUFFER_TYPE enumeration 5-452
DRV_SPI_BUFFER_USAGE_TYPE macro 5-444
DRV_SPI_BufferAddRead function 5-438
DRV_SPI_BufferAddWrite function 5-439
DRV_SPI_BufferAddWriteRead function 5-440
DRV_SPI_BufferStatus function 5-435
DRV_SPI_CLIENT_SETUP type 5-453
DRV_SPI_CLIENTS_NUMBER macro 5-445
DRV_SPI_ClientSetup function 5-436
DRV_SPI_CLOCK_MODE enumeration 5-453
DRV_SPI_CLOCK_OPERATION_MODE macro 5-445
DRV_SPI_Close function 5-437
DRV_SPI_COMMUNICATION_WIDTH macro 5-445
drv_spi_config_template.h 5-456
DRV_SPI_Deinitialize function 5-430
DRV_SPI_FRAME_SYNC_PULSE_COUNT macro 5-445
DRV_SPI_FRAME_SYNC_PULSE_DIRECTION macro 5-446
DRV_SPI_FRAME_SYNC_PULSE_EDGE macro 5-446
DRV_SPI_FRAME_SYNC_PULSE_POLARITY macro 5-446
DRV_SPI_FRAME_SYNC_PULSE_WIDTH macro 5-446
DRV_SPI_INDEX macro 5-447
DRV_SPI_INDEX_0 macro 5-447
DRV_SPI_INDEX_1 macro 5-442
DRV_SPI_INDEX_2 macro 5-442
DRV_SPI_INDEX_3 macro 5-443
DRV_SPI_INDEX_4 macro 5-443
DRV_SPI_INDEX_5 macro 5-443
DRV_SPI_INDEX_COUNT macro 5-447
DRV_SPI_INIT type 5-453
DRV_SPI_Initialize function 5-431
DRV_SPI_INPUT_SAMPLE_PHASE macro 5-447
DRV_SPI_INSTANCES_NUMBER macro 5-448
DRV_SPI_INTERRUPT_MODE macro 5-448
DRV_SPI_INTERRUPT_SOURCE_ERROR macro 5-448
DRV_SPI_INTERRUPT_SOURCE_RX macro 5-448
DRV_SPI_INTERRUPT_SOURCE_TX macro 5-449
DRV_SPI_MODE enumeration 5-454
DRV_SPI_Open function 5-437
DRV_SPI_PERIPHERAL_ID macro 5-449
DRV_SPI_PORTS_REMAP_USAGE macro 5-449
DRV_SPI_POWER_STATE macro 5-450
DRV_SPI_PROTOCOL macro 5-450
DRV_SPI_PROTOCOL_TYPE enumeration 5-454
DRV_SPI_Read function 5-434
DRV_SPI_RX_FIFO_INTERRUPT_MODE macro 5-443
DRV_SPI_Status function 5-432
DRV_SPI_Tasks function 5-433
DRV_SPI_TX_FIFO_INTERRUPT_MODE macro 5-443
DRV_SPI_USAGE_MODE macro 5-450
DRV_SPI_VersionGet function 5-441
DRV_SPI_VersionStrGet function 5-442
DRV_SPI_Write function 5-434
drv_tmr.h 5-508
DRV_TMR_ALARM_CONFIG structure 5-504
DRV_TMR_ALARM_ENABLE macro 5-479
DRV_TMR_ALARM_PERIODIC macro 5-480
DRV_TMR_ALARM_TYPE enumeration 5-504
DRV_TMR_AlarmCountClear function 5-493
DRV_TMR_AlarmCountGet function 5-494
DRV_TMR_AlarmSet function 5-494
DRV_TMR_ASYNC_WRITE_ENABLE macro 5-481
DRV_TMR_CALLBACK type 5-505
DRV_TMR_CLIENT_STATUS enumeration 5-505
DRV_TMR_CLIENTS_NUMBER macro 5-480
DRV_TMR_ClientStatus function 5-488
DRV_TMR_CLOCK_SOURCE macro 5-474
DRV_TMR_Close function 5-489
drv_tmr_config_alarm.h 5-481
drv_tmr_config_template.h 5-509
DRV_TMR_COUNT_WIDTH macro 5-477
DRV_TMR_Counter16BitGet function 5-498
9 MPLAB Harmony Help
k
DRV_TMR_Counter16BitSet function 5-499
DRV_TMR_Counter32BitGet function 5-499
DRV_TMR_Counter32BitSet function 5-500
DRV_TMR_Counter8BitGet function 5-500
DRV_TMR_Counter8BitSet function 5-501
DRV_TMR_Deinitialize function 5-483
DRV_TMR_ElapsedStatusGetAndClear function 5-489
DRV_TMR_INDEX macro 5-477
DRV_TMR_INDEX_0 macro 5-477
DRV_TMR_INDEX_1 macro 5-477
DRV_TMR_INDEX_2 macro 5-478
DRV_TMR_INDEX_3 macro 5-478
DRV_TMR_INDEX_4 macro 5-478
DRV_TMR_INDEX_5 macro 5-478
DRV_TMR_INDEX_COUNT macro 5-478
DRV_TMR_INIT structure 5-506
DRV_TMR_Initialize function 5-484
DRV_TMR_INSTANCES_NUMBER macro 5-478
DRV_TMR_INTERRUPT_MODE macro 5-479
DRV_TMR_INTERRUPT_SOURCE macro 5-507
DRV_TMR_Open function 5-490
DRV_TMR_OperatingFrequencyGet function 5-502
DRV_TMR_Period16BitGet function 5-495
DRV_TMR_Period16BitSet function 5-495
DRV_TMR_Period32BitGet function 5-496
DRV_TMR_Period32BitSet function 5-497
DRV_TMR_Period8BitGet function 5-497
DRV_TMR_Period8BitSet function 5-498
DRV_TMR_PERIPHERAL_ID macro 5-475
DRV_TMR_POSTSCALE macro 5-475
DRV_TMR_POWER_STATE macro 5-507
DRV_TMR_PRESCALE macro 5-475
DRV_TMR_PRESCALER_ENABLE macro 5-481
DRV_TMR_Reinitialize function 5-485
DRV_TMR_SOURCE_EDGE macro 5-475
DRV_TMR_Start function 5-491
DRV_TMR_Status function 5-486
DRV_TMR_Stop function 5-491
DRV_TMR_SYNC_MODE enumeration 5-506
DRV_TMR_SYNCHRONIZATION_MODE macro 5-476
DRV_TMR_SyncModeGet function 5-492
DRV_TMR_SyncModeSet function 5-492
DRV_TMR_Tasks function 5-487
DRV_TMR_TickFrequencyGet function 5-502
DRV_TMR_TIMER_PERIOD macro 5-476
DRV_TMR_UNIFIED macro 5-507
DRV_TMR_VersionGet function 5-503
DRV_TMR_VersionStrGet function 5-503
drv_usart.h 5-549
DRV_USART_AUTO_BAUD_ENABLE macro 5-536
DRV_USART_BAUD_RATE macro 5-537
DRV_USART_BUFFER_FLAGS enumeration 5-543
DRV_USART_BUFFER_STATUS enumeration 5-543
DRV_USART_BufferAdd function 5-526
DRV_USART_BufferStatus function 5-527
DRV_USART_BufferTransferStatus function 5-532
DRV_USART_BYTE_Q_SIZE_RX macro 5-537
DRV_USART_BYTE_Q_SIZE_TX macro 5-537
DRV_USART_CALLBACK type 5-544
DRV_USART_CLIENT_STATUS enumeration 5-544
DRV_USART_CLIENTS_NUMBER macro 5-537
DRV_USART_ClientStatus function 5-533
DRV_USART_Close function 5-534
drv_usart_config_template.h 5-551
DRV_USART_Deinitialize function 5-521
DRV_USART_HANDSHAKE_MODE macro 5-537
DRV_USART_HANDSHAKE_MODES enumeration 5-545
DRV_USART_INDEX macro 5-538
DRV_USART_INDEX_0 macro 5-538
DRV_USART_INDEX_1 macro 5-538
DRV_USART_INDEX_2 macro 5-538
DRV_USART_INDEX_3 macro 5-538
DRV_USART_INDEX_4 macro 5-539
DRV_USART_INDEX_5 macro 5-539
DRV_USART_INDEX_COUNT macro 5-539
DRV_USART_INIT structure 5-545
DRV_USART_INIT_FLAGS enumeration 5-546
DRV_USART_Initialize function 5-522
9 MPLAB Harmony Help
l
DRV_USART_INSTANCES_NUMBER macro 5-539
DRV_USART_INTERRUPT_MODE macro 5-539
DRV_USART_INTERRUPT_SOURCE_ERROR macro 5-540
DRV_USART_INTERRUPT_SOURCE_RX macro 5-540
DRV_USART_INTERRUPT_SOURCE_TX macro 5-540
DRV_USART_IO_BUFFER structure 5-546
DRV_USART_LINE_CONTROL macro 5-540
DRV_USART_LINE_CONTROL_MODES enumeration 5-547
DRV_USART_Open function 5-534
DRV_USART_OPERATION_MODE macro 5-541
DRV_USART_OPERATION_MODE_INIT union 5-547
DRV_USART_OPERATION_MODES enumeration 5-548
DRV_USART_PERIPHERAL_ID macro 5-541
DRV_USART_POLARITY_INVERTED_RX macro 5-541
DRV_USART_POLARITY_INVERTED_TX macro 5-542
DRV_USART_POWER_STATE macro 5-542
DRV_USART_Read function 5-528
DRV_USART_ReadByte function 5-529
DRV_USART_Reinitialize function 5-523
DRV_USART_Status function 5-535
DRV_USART_TasksError function 5-524
DRV_USART_TasksRX function 5-525
DRV_USART_TasksTX function 5-525
DRV_USART_TRANSFER_STATUS enumeration 5-548
DRV_USART_TransferStatus function 5-530
DRV_USART_WAKE_ON_START_ENABLE macro 5-542
DRV_USART_Write function 5-530
DRV_USART_WriteByte function 5-531
DRV_USART_XFER_BUFFER_NUMBER macro 5-542
DRV_USART_XFER_HANDLE type 5-549
drv_usb.h 5-598
DRV_USB_ClientEventCallBackSet function 5-581
DRV_USB_Close function 5-579
drv_usb_config_template.h 5-600
DRV_USB_DEVICE_AddressSet function 5-582
DRV_USB_DEVICE_Attach function 5-582
DRV_USB_DEVICE_CurrentSpeedGet function 5-583
DRV_USB_DEVICE_Detach function 5-584
DRV_USB_DEVICE_EndpointDisable function 5-585
DRV_USB_DEVICE_EndpointDisableAll function 5-585
DRV_USB_DEVICE_EndpointEnable function 5-586
DRV_USB_DEVICE_EndpointIsEnabled function 5-587
DRV_USB_DEVICE_EndpointIsStalled function 5-588
DRV_USB_DEVICE_EndpointStall function 5-589
DRV_USB_DEVICE_EndpointStallClear function 5-589
DRV_USB_DEVICE_IRPCancelAll function 5-590
DRV_USB_DEVICE_IRPSubmit function 5-591
DRV_USB_ENDPOINT_TABLE_ENTRY_SIZE macro 5-595
DRV_USB_EVENT enumeration 5-596
DRV_USB_EVENT_CALLBACK type 5-597
DRV_USB_HOST_BusResetControl function 5-593
DRV_USB_HOST_DeviceCurrentSpeedGet function 5-593
DRV_USB_HOST_IRPCancel function 5-593
DRV_USB_HOST_IRPSubmit function 5-593
DRV_USB_HOST_OperationEnable function 5-593
DRV_USB_HOST_OperationIsEnabled function 5-578
DRV_USB_HOST_PIPE_HANDLE type 5-597
DRV_USB_HOST_PIPE_HANDLE_INVALID macro 5-595
DRV_USB_HOST_PipeClose function 5-581
DRV_USB_HOST_PipeSetup function 5-580
DRV_USB_HOST_StartOfFrameControl function 5-594
DRV_USB_HOST_TimerIsComplete function 5-594
DRV_USB_HOST_TimerReset function 5-594
DRV_USB_HOST_TimerStart function 5-594
DRV_USB_INDEX macro 5-595
DRV_USB_INDEX_0 macro 5-596
DRV_USB_INIT structure 5-597
DRV_USB_Initialize function 5-576
DRV_USB_INTERRUPT_SOURCE macro 5-596
DRV_USB_Open function 5-579
DRV_USB_PERIPHERAL_ID macro 5-596
DRV_USB_Status function 5-577
DRV_USB_Tasks function 5-594
DRV_USB_Tasks_ISR function 5-578
drv_wifi.h 5-674
DRV_WIFI_ADHOC_CONNECT_ONLY enumeration member
5-655
DRV_WIFI_ADHOC_CONNECT_THEN_START enumeration
member 5-655
9 MPLAB Harmony Help
m
DRV_WIFI_ADHOC_MODES enumeration 5-655
DRV_WIFI_ADHOC_NETWORK_CONTEXT structure 5-655
DRV_WIFI_ADHOC_START_ONLY enumeration member
5-655
DRV_WIFI_AdhocContextSet function 5-636
DRV_WIFI_BSSID_LENGTH macro 5-647
DRV_WIFI_BssidGet function 5-613
DRV_WIFI_BssidSet function 5-614
DRV_WIFI_ChannelListGet function 5-615
DRV_WIFI_ChannelListSet function 5-615
DRV_WIFI_ConfigDataErase function 5-643
DRV_WIFI_ConfigDataLoad function 5-643
DRV_WIFI_ConfigDataPrint function 5-644
DRV_WIFI_ConfigDataSave function 5-644
DRV_WIFI_Connect function 5-641
DRV_WIFI_ConnectContextGet function 5-616
DRV_WIFI_CONNECTION_CONTEXT structure 5-656
DRV_WIFI_CONNECTION_STATES enumeration 5-656
DRV_WIFI_ConnectionStateGet function 5-616
DRV_WIFI_DEAUTH_REASONCODE_MASK macro 5-647
DRV_WIFI_DEFAULT_ADHOC_BEACON_PERIOD macro
5-647
DRV_WIFI_DEFAULT_ADHOC_HIDDEN_SSID macro 5-648
DRV_WIFI_DEFAULT_ADHOC_MODE macro 5-648
DRV_WIFI_DEFAULT_PS_DTIM_ENABLED macro 5-648
DRV_WIFI_DEFAULT_PS_DTIM_INTERVAL macro 5-648
DRV_WIFI_DEFAULT_PS_LISTEN_INTERVAL macro 5-648
DRV_WIFI_DEFAULT_SCAN_COUNT macro 5-648
DRV_WIFI_DEFAULT_SCAN_MAX_CHANNEL_TIME macro
5-649
DRV_WIFI_DEFAULT_SCAN_MIN_CHANNEL_TIME macro
5-649
DRV_WIFI_DEFAULT_SCAN_PROBE_DELAY macro 5-649
DRV_WIFI_DEFAULT_WEP_KEY_TYPE macro 5-649
DRV_WIFI_Deinitialize function 5-641
DRV_WIFI_DEVICE_INFO structure 5-657
DRV_WIFI_DEVICE_TYPES enumeration 5-657
DRV_WIFI_DeviceInfoGet function 5-617
DRV_WIFI_DISABLED macro 5-649
DRV_WIFI_DISASSOC_REASONCODE_MASK macro 5-649
DRV_WIFI_Disconnect function 5-641
DRV_WIFI_DOMAIN_CODES enumeration 5-657
DRV_WIFI_ENABLED macro 5-650
DRV_WIFI_EVENT_CONN_TEMP_LOST_CODES
enumeration 5-658
DRV_WIFI_EVENT_INFO enumeration 5-658
DRV_WIFI_EVENTS enumeration 5-659
DRV_WIFI_GENERAL_ERRORS enumeration 5-660
DRV_WIFI_GratuitousArpStart function 5-638
DRV_WIFI_GratuitousArpStop function 5-638
DRV_WIFI_HIBERNATE_STATE structure 5-660
DRV_WIFI_HIBERNATE_STATES enumeration 5-660
DRV_WIFI_HibernateEnable function 5-639
DRV_WIFI_HWMulticastFilterGet function 5-617
DRV_WIFI_HWMulticastFilterSet function 5-618
DRV_WIFI_Initialize function 5-642
DRV_WIFI_isHibernateEnable function 5-639
DRV_WIFI_MAC_STATS structure 5-660
DRV_WIFI_MacAddressGet function 5-619
DRV_WIFI_MacAddressSet function 5-619
DRV_WIFI_MacStatsGet function 5-620
DRV_WIFI_MAX_CHANNEL_LIST_LENGTH macro 5-650
DRV_WIFI_MAX_NUM_RATES macro 5-650
DRV_WIFI_MAX_SECURITY_KEY_LENGTH macro 5-650
DRV_WIFI_MAX_SSID_LENGTH macro 5-650
DRV_WIFI_MAX_WEP_KEY_LENGTH macro 5-650
DRV_WIFI_MAX_WPA_PASS_PHRASE_LENGTH macro
5-650
DRV_WIFI_MAX_WPA2_PASS_PHRASE_LENGTH macro
5-651
DRV_WIFI_MGMT_ERRORS enumeration 5-661
DRV_WIFI_MGMT_INDICATE_SOFT_AP_EVENT structure
5-662
DRV_WIFI_MIN_WPA_PASS_PHRASE_LENGTH macro 5-651
DRV_WIFI_MULTICAST_FILTER_IDS enumeration 5-663
DRV_WIFI_MULTICAST_FILTERS enumeration 5-663
DRV_WIFI_NETWORK_TYPE_ADHOC macro 5-651
DRV_WIFI_NETWORK_TYPE_INFRASTRUCTURE macro
5-651
DRV_WIFI_NETWORK_TYPE_P2P macro 5-651
DRV_WIFI_NETWORK_TYPE_SOFT_AP macro 5-651
DRV_WIFI_NetworkTypeGet function 5-620
9 MPLAB Harmony Help
n
DRV_WIFI_NetworkTypeSet function 5-621
DRV_WIFI_NO_ADDITIONAL_INFO macro 5-652
DRV_WIFI_POWER_SAVE_STATES enumeration 5-664
DRV_WIFI_PowerSaveStateGet function 5-621
DRV_WIFI_ProcessEvent function 5-644
DRV_WIFI_PS_POLL_CONTEXT structure 5-664
DRV_WIFI_PsPollDisable function 5-640
DRV_WIFI_PsPollEnable function 5-640
DRV_WIFI_REASON_CODES enumeration 5-665
DRV_WIFI_RECONNECT_MODES enumeration 5-665
DRV_WIFI_ReconnectModeGet function 5-622
DRV_WIFI_ReconnectModeSet function 5-623
DRV_WIFI_RegionalDomainGet function 5-624
DRV_WIFI_RETRY_ADHOC macro 5-652
DRV_WIFI_RETRY_FOREVER macro 5-652
DRV_WIFI_RssiGet function 5-637
DRV_WIFI_RssiSet function 5-637
DRV_WIFI_RTS_THRESHOLD_MAX macro 5-652
DRV_WIFI_RtsThresholdGet function 5-625
DRV_WIFI_RtsThresholdSet function 5-625
DRV_WIFI_Scan function 5-642
DRV_WIFI_SCAN_CONTEXT structure 5-665
DRV_WIFI_SCAN_RESULT structure 5-666
DRV_WIFI_SCAN_TYPES enumeration 5-667
DRV_WIFI_ScanContextGet function 5-626
DRV_WIFI_ScanContextSet function 5-627
DRV_WIFI_ScanGetResult function 5-645
DRV_WIFI_SECURITY_CONTEXT union 5-667
DRV_WIFI_SECURITY_EAP macro 5-652
DRV_WIFI_SECURITY_OPEN macro 5-652
DRV_WIFI_SECURITY_WEP_104 macro 5-653
DRV_WIFI_SECURITY_WEP_40 macro 5-653
DRV_WIFI_SECURITY_WPA_AUTO_WITH_KEY macro 5-653
DRV_WIFI_SECURITY_WPA_AUTO_WITH_PASS_PHRASE
macro 5-653
DRV_WIFI_SECURITY_WPA_WITH_KEY macro 5-653
DRV_WIFI_SECURITY_WPA_WITH_PASS_PHRASE macro
5-653
DRV_WIFI_SECURITY_WPA2_WITH_KEY macro 5-654
DRV_WIFI_SECURITY_WPA2_WITH_PASS_PHRASE macro
5-654
DRV_WIFI_SECURITY_WPS_PIN macro 5-654
DRV_WIFI_SECURITY_WPS_PUSH_BUTTON macro 5-654
DRV_WIFI_SecurityGet function 5-627
DRV_WIFI_SecurityOpenSet function 5-628
DRV_WIFI_SecurityWepSet function 5-628
DRV_WIFI_SecurityWpaSet function 5-629
DRV_WIFI_SecurityWpsSet function 5-630
DRV_WIFI_SetLinkDownThreshold function 5-645
DRV_WIFI_SetPSK function 5-646
DRV_WIFI_SOFT_AP_EVENT_REASON_CODES
enumeration 5-667
DRV_WIFI_SOFT_AP_STATES enumeration 5-668
DRV_WIFI_SoftApEventInfoGet function 5-630
DRV_WIFI_SsidGet function 5-631
DRV_WIFI_SsidSet function 5-631
DRV_WIFI_STATUS_CODES enumeration 5-668
DRV_WIFI_SWMULTICAST_CONFIG structure 5-668
DRV_WIFI_SWMultiCastFilterEnable function 5-646
DRV_WIFI_SWMulticastFilterSet function 5-632
DRV_WIFI_TX_MODES enumeration 5-669
DRV_WIFI_TxModeGet function 5-633
DRV_WIFI_TxModeSet function 5-633
DRV_WIFI_TxPowerFactoryMaxGet function 5-634
DRV_WIFI_TxPowerMaxGet function 5-634
DRV_WIFI_TxPowerMaxSet function 5-635
DRV_WIFI_VERSION_NUMBER macro 5-654
DRV_WIFI_WEP_CONTEXT structure 5-669
DRV_WIFI_WEP_KEY_TYPE enumeration 5-670
DRV_WIFI_WEP104_KEY_LENGTH macro 5-654
DRV_WIFI_WEP40_KEY_LENGTH macro 5-654
DRV_WIFI_WepKeyTypeGet function 5-635
DRV_WIFI_WPA_CONTEXT structure 5-670
DRV_WIFI_WPA_KEY_INFO structure 5-671
DRV_WIFI_WPA_KEY_LENGTH macro 5-655
DRV_WIFI_WPA2_KEY_LENGTH macro 5-655
DRV_WIFI_WPS_AUTH_TYPES enumeration 5-671
DRV_WIFI_WPS_CONTEXT structure 5-671
DRV_WIFI_WPS_CREDENTIAL structure 5-672
DRV_WIFI_WPS_ENCODE_TYPES enumeration 5-673
9 MPLAB Harmony Help
o
DRV_WIFI_WPS_PIN_LENGTH macro 5-655
DRV_WIFI_WPSCredentialsGet function 5-636
DRV_WIFI_YieldPassphraseToHost function 5-647
DSP Fixed-Point Library 5-1167
DSP Math Library 4-181
dsp.h 5-1268
DSP_ComplexAdd32 function 5-1175
DSP_ComplexConj16 function 5-1175
DSP_ComplexConj32 function 5-1176
DSP_ComplexDotProd32 function 5-1177
DSP_ComplexMult32 function 5-1178
DSP_ComplexScalarMult32 function 5-1179
DSP_ComplexSub32 function 5-1180
DSP_FilterFIR32 function 5-1180
DSP_FilterFIRDecim32 function 5-1182
DSP_FilterFIRInterp32 function 5-1183
DSP_FilterIIR16 function 5-1184
DSP_FilterIIRBQ16 function 5-1185
DSP_FilterIIRBQ16_cascade8 function 5-1187
DSP_FilterIIRBQ16_cascade8_fast function 5-1188
DSP_FilterIIRBQ16_fast function 5-1190
DSP_FilterIIRBQ16_parallel8 function 5-1191
DSP_FilterIIRBQ16_parallel8_fast function 5-1193
DSP_FilterIIRBQ32 function 5-1194
DSP_FilterIIRSetup16 function 5-1195
DSP_FilterLMS16 function 5-1196
DSP_MatrixAdd32 function 5-1197
DSP_MatrixEqual32 function 5-1199
DSP_MatrixInit32 function 5-1199
DSP_MatrixMul32 function 5-1200
DSP_MatrixScale32 function 5-1202
DSP_MatrixSub32 function 5-1202
DSP_MatrixTranspose32 function 5-1204
DSP_TransformFFT16 function 5-1205
DSP_TransformFFT16_setup function 5-1206
DSP_TransformFFT32 function 5-1206
DSP_TransformFFT32_setup function 5-1207
DSP_TransformIFFT16 function 5-1208
DSP_TransformWindow_Bart16 function 5-1209
DSP_TransformWindow_Bart32 function 5-1210
DSP_TransformWindow_Black16 function 5-1211
DSP_TransformWindow_Black32 function 5-1212
DSP_TransformWindow_Cosine16 function 5-1213
DSP_TransformWindow_Cosine32 function 5-1213
DSP_TransformWindow_Hamm16 function 5-1214
DSP_TransformWindow_Hamm32 function 5-1215
DSP_TransformWindow_Hann16 function 5-1216
DSP_TransformWindow_Hann32 function 5-1217
DSP_TransformWindow_Kaiser16 function 5-1217
DSP_TransformWindow_Kaiser32 function 5-1218
DSP_TransformWinInit_Bart16 function 5-1219
DSP_TransformWinInit_Bart32 function 5-1220
DSP_TransformWinInit_Black16 function 5-1220
DSP_TransformWinInit_Black32 function 5-1221
DSP_TransformWinInit_Cosine16 function 5-1222
DSP_TransformWinInit_Cosine32 function 5-1223
DSP_TransformWinInit_Hamm16 function 5-1223
DSP_TransformWinInit_Hamm32 function 5-1224
DSP_TransformWinInit_Hann16 function 5-1225
DSP_TransformWinInit_Hann32 function 5-1225
DSP_TransformWinInit_Kaiser16 function 5-1226
DSP_TransformWinInit_Kaiser32 function 5-1227
DSP_VectorAbs16 function 5-1228
DSP_VectorAbs32 function 5-1228
DSP_VectorAdd16 function 5-1229
DSP_VectorAdd32 function 5-1230
DSP_VectorAddc16 function 5-1231
DSP_VectorAddc32 function 5-1232
DSP_VectorAutocorr16 function 5-1233
DSP_VectorBexp16 function 5-1234
DSP_VectorBexp32 function 5-1234
DSP_VectorChkEqu32 function 5-1235
DSP_VectorCopy function 5-1236
DSP_VectorCopyReverse32 function 5-1237
DSP_VectorDivC function 5-1238
DSP_VectorDotp16 function 5-1238
DSP_VectorDotp32 function 5-1239
DSP_VectorExp function 5-1240
9 MPLAB Harmony Help
p
DSP_VectorFill function 5-1241
DSP_VectorLn function 5-1242
DSP_VectorLog10 function 5-1243
DSP_VectorLog2 function 5-1244
DSP_VectorMax32 function 5-1244
DSP_VectorMaxIndex32 function 5-1245
DSP_VectorMean32 function 5-1246
DSP_VectorMin32 function 5-1247
DSP_VectorMinIndex32 function 5-1247
DSP_VectorMul16 function 5-1248
DSP_VectorMul32 function 5-1249
DSP_VectorMulc16 function 5-1250
DSP_VectorMulc32 function 5-1251
DSP_VectorNegate function 5-1252
DSP_VectorRecip function 5-1253
DSP_VectorRMS16 function 5-1254
DSP_VectorShift function 5-1254
DSP_VectorSqrt function 5-1255
DSP_VectorStdDev16 function 5-1256
DSP_VectorSub16 function 5-1257
DSP_VectorSub32 function 5-1258
DSP_VectorSumSquares16 function 5-1259
DSP_VectorSumSquares32 function 5-1259
DSP_VectorVari16 function 5-1260
DSP_VectorVariance function 5-1261
DSP_VectorZeroPad function 5-1262
Dual Compare Continuous Mode 5-2292
Dynamic Configuration 5-3426
Dynamic DNS TCP/IP Stack Library 5-3646
E
EBI Peripheral Library 5-1864
EMAC_RX_BUFF_SIZE macro 5-3750
EMAC_RX_DESCRIPTORS macro 5-3750
EMAC_RX_FRAGMENTS macro 5-3750
EMAC_RX_MAX_FRAME macro 5-3751
EMAC_TX_DESCRIPTORS macro 5-3751
ENABLE_P2P_PRINTS macro 5-673
ENABLE_WPS_PRINTS macro 5-673
EnablePalette function 5-828
Enabling 5-3956
Enabling Events 5-1560
END_OF_SNMP_READ_COMMUNITIES macro 5-3826
END_OF_SNMP_WRITE_COMMUNITIES macro 5-3826
Endpoint Pipes 5-557
Enhanced Buffer Master Mode 5-2807
Enhanced Buffer Slave Mode 5-2809
Enhanced Buffer SPI Mode 5-2807
Error Operation 5-1321
ETH_AUTOPAD_OPTION enumeration 5-2050
ETH_CFG_10 macro 5-3751
ETH_CFG_100 macro 5-3751
ETH_CFG_AUTO macro 5-3751
ETH_CFG_AUTO_MDIX macro 5-3752
ETH_CFG_FDUPLEX macro 5-3752
ETH_CFG_HDUPLEX macro 5-3752
ETH_CFG_LINK macro 5-3752
ETH_CFG_LINK_INIT_DELAY macro 5-3752
ETH_CFG_SWAP_MDIX macro 5-3752
ETH_CLOSE_FLAGS enumeration 5-247
ETH_INTERRUPT_SOURCES enumeration 5-2050
ETH_LINK_STATUS enumeration 5-247
ETH_MIIM_CLK enumeration 5-2050
ETH_MODULE_STATUS enumeration 5-248
ETH_OPEN_FLAGS enumeration 5-248
ETH_PATTERN_MATCH_MODE type 5-2051
ETH_PAUSE_TYPE enumeration 5-249
ETH_RECEIVE_FILTER enumeration 5-2051
ETH_RESULT_CODE enumeration 5-250
ETH_RMII_SPEED enumeration 5-2052
Ethernet Controller Operation 5-1909
Ethernet DMA and Buffer Management Engine 5-1912
Ethernet Frame Overview 5-1909
Ethernet MAC Driver Library 5-226
Ethernet Peripheral Library 5-1902
Ethernet PHY Driver Library 5-254
ETHPHY_CONFIG_FLAGS enumeration 5-251
Event Handling 5-563, 5-3975, 5-3981, 5-4066, 5-4135
9 MPLAB Harmony Help
q
Events 5-1317
Example - Channel Scanning 5-1476
Example - Digital Comparator 5-1478
Example - Digital Oversampling Filter 5-1477
Example - Simultaneous Sampling Three Class 1 Inputs 5-1475
Example Code for Complete Operation 5-374
Example Usage of the Timer Driver 5-467
Examples 5-3514
Examples - Sample Functionality 5-609, 5-1324, 5-3366
Exception Generator 5-1522
Explorer 16 Development Board 3-78, 3-104, 3-124, 3-143,
3-171
Explorer 16 PIC32MX795F512L BSP Library 7-4230
Extended ID Message Format 5-1556
EXTPHY_MDIXCONFIGURE type 5-281
EXTPHY_MIICONFIGURE type 5-281
EXTPHY_SMIADDRESSGET type 5-282
EXTPHY_SMICLOCKGET type 5-282
F
Fail-Safe Clock Monitor 5-2335
FAT_FS_MAX_LFN macro 5-3417
FAT_FS_MAX_SS macro 5-3417
FAT_FS_USE_LFN macro 5-3417
File EOF 5-3395
File Seek 5-3396
File System Demonstrations 3-64
File System Service Library 5-3376
File Tell 5-3396
FileFeof type 5-889
FileRead type 5-890
Files 3-111, 3-128, 3-148, 5-192, 5-225, 5-252, 5-286, 5-295,
5-308, 5-318, 5-332, 5-341, 5-365, 5-395, 5-416, 5-454, 5-508,
5-549, 5-598, 5-608, 5-674, 5-1062, 5-1126, 5-1164, 5-1268,
5-1307, 5-1358, 5-1466, 5-1518, 5-1551, 5-1662, 5-1730,
5-1858, 5-1900, 5-2052, 5-2166, 5-2200, 5-2250, 5-2285,
5-2328, 5-2423, 5-2475, 5-2588, 5-2659, 5-2686, 5-2702,
5-2759, 5-2796, 5-2887, 5-3006, 5-3081, 5-3164, 5-3312,
5-3330, 5-3345, 5-3362, 5-3374, 5-3418, 5-3437, 5-3463,
5-3498, 5-3528, 5-3534, 5-3573, 5-3596, 5-3613, 5-3623,
5-3634, 5-3645, 5-3653, 5-3658, 5-3687, 5-3696, 5-3707,
5-3716, 5-3745, 5-3769, 5-3793, 5-3797, 5-3805, 5-3808,
5-3821, 5-3853, 5-3866, 5-3879, 5-3910, 5-3916, 5-3928,
5-3952, 5-3962, 5-4002, 5-4057, 5-4098, 5-4129, 5-4166,
5-4178, 5-4198, 5-4223, 7-4245
Files to Include 5-3979, 5-4007, 5-4064, 5-4104, 5-4133
FileSeek type 5-890
FileTell type 5-890
Filters and Masks Configuration 5-1559
Fixed-Point Math Library 4-182
Flash ECC Operations 5-2434
Flash Operations 5-2256
Flow Control Overview 5-1911
FONT_ORIENTATION enumeration 5-890
Fonts 5-1123
Forming Transfers 5-2084
Framed SPI Modes 5-2810
Framework Help 5-184
FreeRTOS RTOS with Graphics 3-116
FreeRTOS_basic_demo 3-114
FTP TCP/IP Stack Library 5-3654
ftp.h 5-3658
ftp_config.h 5-3659
FTP_MODULE_CONFIG structure 5-3658
Functions 5-301, 5-311, 5-326, 5-335, 5-4201
Functions Registeration Table 5-4013
G
Gated Timer 5-3019
General 5-1367
General Configuration 5-1736
Generating Server Certificates 5-3870
generic_device 3-164
GENERIC_TRAP_NOTIFICATION_TYPE enumeration 5-3847
gethostname function 5-3604
GetPaletteChangeError function 5-828
Getting Help 5-3542
Getting Started 5-3378
gfx.h 5-1062
GFX_ActivePageGet macro 5-947
GFX_ALIGNMENT enumeration 5-890
GFX_ALPHA_PARAMS structure 5-295
GFX_AlphaBlendingValueGet function 5-828
9 MPLAB Harmony Help
r
GFX_AlphaBlendingValueSet function 5-829
GFX_AlphaBlendWindow function 5-829
GFX_AlphaParamsSet macro 5-947
GFX_AnalogClockCreate function 5-718
GFX_BACKGROUND structure 5-891
GFX_BACKGROUND_TYPE enumeration 5-891
GFX_BackgroundColorGet function 5-830
GFX_BackgroundImageGet function 5-830
GFX_BackgroundImageLeftGet function 5-830
GFX_BackgroundImageTopGet function 5-831
GFX_BackgroundSet function 5-831
GFX_BackgroundTypeGet function 5-832
GFX_BackgroundTypeSet function 5-832
GFX_BarAlphaDraw function 5-832
GFX_BarDraw function 5-833
GFX_BarGradientDraw function 5-835
GFX_BEVEL_RENDER_TYPE enumeration 5-892
GFX_BevelDraw function 5-836
GFX_BevelDrawTypeGet function 5-836
GFX_BevelDrawTypeSet function 5-836
GFX_BevelGradientDraw function 5-836
GFX_BUFFER1 macro 5-948
GFX_BUFFER2 macro 5-948
GFX_CircleDraw function 5-838
GFX_CircleFillDraw function 5-838
GFX_COLOR type 5-892
GFX_ColorGet function 5-839
gfx_colors.h 5-1063
gfx_colors_w3.h 5-1064
gfx_colors_x11.h 5-1068
GFX_ColorSet function 5-839
GFX_COMP_MASK macro 5-948
GFX_CONFIG_DRIVER_COUNT macro 5-294
GFX_CONFIG_OBJECT_METER_DEGREECOUNT macro
5-948
GFX_CONFIG_OBJECT_METER_RESOLUTION macro 5-948
GFX_CONFIG_OBJECT_METER_SCALE_COUNT macro
5-949
gfx_config_template.h 5-1071
GFX_CosineGet macro 5-1125
GFX_DOUBLE_BUFFERING_MODE structure 5-892
GFX_DoubleBufferAreaGet function 5-840
GFX_DoubleBufferAreaMark function 5-840
GFX_DoubleBufferDisable function 5-840
GFX_DoubleBufferEnable function 5-840
GFX_DoubleBufferStatusGet function 5-841
GFX_DoubleBufferSyncAllStatusClear function 5-841
GFX_DoubleBufferSyncAllStatusGet function 5-841
GFX_DoubleBufferSyncAllStatusSet function 5-841
GFX_DoubleBufferSyncAreaCountGet function 5-841
GFX_DoubleBufferSyncAreaCountSet function 5-841
GFX_DoubleBufferSynchronize function 5-841
GFX_DoubleBufferSynchronizeCancel function 5-841
GFX_DoubleBufferSynchronizeRequest function 5-841
GFX_DoubleBufferSynchronizeSet function 5-841
GFX_DoubleBufferSynchronizeStatusGet function 5-841
GFX_DoubleBufferVisualPageUpdate function 5-842
GFX_DrawBufferGet function 5-842
GFX_DrawBufferSelect function 5-842
GFX_DrawBufferSet function 5-842
GFX_DRV_DATA structure 5-292
GFX_DRV_FontSet function 5-842
GFX_DRV_FUNCTIONS structure 5-293
GFX_DRV_lcc_BrightnessSet function 5-302
GFX_DRV_lcc_Close function 5-301
GFX_DRV_lcc_COMMAND structure 5-306
GFX_DRV_lcc_COMMANDQUEUESIZE macro 5-307
GFX_DRV_lcc_Initialize function 5-302
GFX_DRV_lcc_Layer function 5-305
GFX_DRV_lcc_Open function 5-302
GFX_DRV_lcc_PixelArrayGet function 5-303
GFX_DRV_lcc_PixelArrayPut function 5-303
GFX_DRV_lcc_PixelPut function 5-303
GFX_DRV_lcc_PixelsPut function 5-304
GFX_DRV_lcc_SetColor function 5-304
GFX_DRV_lcc_SetInstance function 5-304
GFX_DRV_lcc_SetPage function 5-305
GFX_DRV_lcc_Tasks function 5-302
GFX_DRV_OTM2201A_AddressSet function 5-312
9 MPLAB Harmony Help
s
GFX_DRV_OTM2201A_BrightnessSet function 5-312
GFX_DRV_OTM2201A_Busy function 5-312
GFX_DRV_OTM2201A_Close function 5-313
GFX_DRV_OTM2201A_ColorSet function 5-313
GFX_DRV_OTM2201A_COMMAND structure 5-317
GFX_DRV_OTM2201A_Initialize function 5-313
GFX_DRV_OTM2201A_InstanceSet function 5-314
GFX_DRV_OTM2201A_Open function 5-314
GFX_DRV_OTM2201A_PixelArrayGet function 5-314
GFX_DRV_OTM2201A_PixelArrayPut function 5-315
GFX_DRV_OTM2201A_PixelPut function 5-315
GFX_DRV_OTM2201A_PixelsPut function 5-316
GFX_DRV_OTM2201A_RegGet function 5-316
GFX_DRV_OTM2201A_RegSet function 5-316
GFX_DRV_OTM2201A_Tasks function 5-317
GFX_DRV_S1D13517_AlphaBlendWindow function 5-327
GFX_DRV_S1D13517_BrightnessSet function 5-327
GFX_DRV_S1D13517_Close function 5-327
GFX_DRV_S1D13517_COMMAND structure 5-331
GFX_DRV_S1D13517_GetReg function 5-327
GFX_DRV_S1D13517_Initialize function 5-328
GFX_DRV_S1D13517_Layer function 5-328
GFX_DRV_S1D13517_Open function 5-328
GFX_DRV_S1D13517_PixelArrayPut function 5-329
GFX_DRV_S1D13517_PixelPut function 5-329
GFX_DRV_S1D13517_PixelsPut function 5-329
GFX_DRV_S1D13517_SetColor function 5-330
GFX_DRV_S1D13517_SetInstance function 5-330
GFX_DRV_S1D13517_SetPage function 5-330
GFX_DRV_S1D13517_SetReg function 5-331
GFX_DRV_S1D13517_Tasks function 5-331
GFX_DRV_SSD1926_BarFill function 5-336
GFX_DRV_SSD1926_BrightnessSet function 5-336
GFX_DRV_SSD1926_Busy function 5-336
GFX_DRV_SSD1926_Close function 5-336
GFX_DRV_SSD1926_COMMAND structure 5-340
GFX_DRV_SSD1926_GetReg function 5-337
GFX_DRV_SSD1926_Initialize function 5-337
GFX_DRV_SSD1926_Open function 5-337
GFX_DRV_SSD1926_PixelArrayGet function 5-338
GFX_DRV_SSD1926_PixelArrayPut function 5-338
GFX_DRV_SSD1926_PixelPut function 5-339
GFX_DRV_SSD1926_PixelsPut function 5-339
GFX_DRV_SSD1926_SetColor function 5-339
GFX_DRV_SSD1926_SetInstance function 5-339
GFX_DRV_SSD1926_SetReg function 5-340
GFX_DRV_SSD1926_TASK structure 5-341
GFX_DRV_SSD1926_Tasks function 5-340
GFX_DRV_TextStringWidthGet function 5-842
GFX_ExternalCharInfoGet function 5-843
GFX_ExternalResourceCallback function 5-843
GFX_FEATURE_STATUS enumeration 5-893
GFX_FILL_STYLE enumeration 5-893
GFX_FillStyleGet function 5-844
GFX_FillStyleSet function 5-844
GFX_FlashCharInfoGet function 5-845
GFX_FONT_ANTIALIAS_TYPE enumeration 5-893
GFX_FONT_CURRENT structure 5-894
GFX_FONT_GLYPH_ENTRY structure 5-894
GFX_FONT_GLYPH_ENTRY_EXTENDED structure 5-895
GFX_FONT_HEADER structure 5-895
GFX_FONT_OUTCHAR structure 5-895
GFX_FONT_SPACE macro 5-949
GFX_FontAlignmentSet macro 5-949
GFX_FontAntiAliasGet function 5-845
GFX_FontAntiAliasSet function 5-845
GFX_FontGet function 5-846
GFX_FontSet function 5-846
GFX_FrameBufferGet function 5-846
GFX_FrameBufferSelect function 5-846
GFX_free macro 5-326
gfx_gol.h 5-1072
gfx_gol_analog_clock.h 5-1074
GFX_GOL_ANALOGCLOCK structure 5-896
GFX_GOL_ANALOGCLOCK_DISABLED macro 5-949
GFX_GOL_ANALOGCLOCK_DRAW macro 5-950
GFX_GOL_ANALOGCLOCK_HIDE macro 5-950
GFX_GOL_ANALOGCLOCK_PRESSED macro 5-950
9 MPLAB Harmony Help
t
GFX_GOL_ANALOGCLOCK_TICK macro 5-950
GFX_GOL_ANALOGCLOCK_UPDATE_HOUR macro 5-950
GFX_GOL_ANALOGCLOCK_UPDATE_MINUTE macro 5-950
GFX_GOL_ANALOGCLOCK_UPDATE_SECOND macro 5-951
GFX_GOL_AnalogClockDraw function 5-719
GFX_GOL_AnalogClockHandsDraw function 5-720
GFX_GOL_AnalogClockHourSet function 5-721
GFX_GOL_AnalogClockMinuteSet function 5-721
GFX_GOL_AnalogClockSecondSet function 5-722
GFX_GOL_BUTTON structure 5-896
gfx_gol_button.h 5-1075
GFX_GOL_BUTTON_STATE enumeration 5-897
GFX_GOL_ButtonActionGet function 5-722
GFX_GOL_ButtonActionSet function 5-723
GFX_GOL_ButtonCreate function 5-724
GFX_GOL_ButtonDraw function 5-726
GFX_GOL_ButtonPressStateImageGet macro 5-951
GFX_GOL_ButtonPressStateImageSet macro 5-951
GFX_GOL_ButtonReleaseStateImageGet macro 5-952
GFX_GOL_ButtonReleaseStateImageSet macro 5-952
GFX_GOL_ButtonTextAlignmentGet function 5-726
GFX_GOL_ButtonTextAlignmentSet function 5-727
GFX_GOL_ButtonTextGet macro 5-953
GFX_GOL_ButtonTextSet function 5-727
GFX_GOL_CHART structure 5-898
gfx_gol_chart.h 5-1076
GFX_GOL_CHART_3D_ENABLE macro 5-953
GFX_GOL_CHART_BAR macro 5-953
GFX_GOL_CHART_BAR_HOR macro 5-953
GFX_GOL_CHART_DISABLED macro 5-954
GFX_GOL_CHART_DONUT macro 5-954
GFX_GOL_CHART_DRAW macro 5-954
GFX_GOL_CHART_DRAW_DATA macro 5-954
GFX_GOL_CHART_HIDE macro 5-954
GFX_GOL_CHART_LEGEND macro 5-954
GFX_GOL_CHART_NUMERIC macro 5-955
GFX_GOL_CHART_PERCENT macro 5-955
GFX_GOL_CHART_PIE macro 5-955
GFX_GOL_CHART_VALUE macro 5-955
GFX_GOL_ChartActionGet function 5-733
GFX_GOL_ChartAxisLabelFontGet macro 5-955
GFX_GOL_ChartAxisLabelFontSet macro 5-956
GFX_GOL_ChartColorTableGet macro 5-956
GFX_GOL_ChartColorTableSet macro 5-957
GFX_GOL_ChartCreate function 5-734
GFX_GOL_ChartDataSeriesAdd function 5-736
GFX_GOL_ChartDataSeriesFree function 5-736
GFX_GOL_ChartDataSeriesRemove function 5-737
GFX_GOL_ChartDataSeriesSet function 5-737
GFX_GOL_ChartDraw function 5-738
GFX_GOL_ChartGridLabelFontGet macro 5-957
GFX_GOL_ChartGridLabelFontSet macro 5-958
GFX_GOL_ChartPercentMaxGet macro 5-958
GFX_GOL_ChartPercentMinGet macro 5-959
GFX_GOL_ChartPercentRangeGet macro 5-959
GFX_GOL_ChartPercentRangeSet function 5-738
GFX_GOL_ChartSampleEndGet macro 5-960
GFX_GOL_ChartSampleLabelGet macro 5-960
GFX_GOL_ChartSampleLabelSet macro 5-960
GFX_GOL_ChartSampleRangeGet macro 5-961
GFX_GOL_ChartSampleRangeSet function 5-739
GFX_GOL_ChartSampleStartGet macro 5-961
GFX_GOL_ChartSeriesHide macro 5-962
GFX_GOL_ChartShowSeriesCountGet macro 5-962
GFX_GOL_ChartShowSeriesSet macro 5-963
GFX_GOL_ChartShowSeriesStatusGet macro 5-963
GFX_GOL_ChartTitleFontGet macro 5-964
GFX_GOL_ChartTitleFontSet macro 5-964
GFX_GOL_ChartTitleGet macro 5-965
GFX_GOL_ChartTitleSet macro 5-965
GFX_GOL_ChartValueLabelGet macro 5-966
GFX_GOL_ChartValueLabelSet macro 5-966
GFX_GOL_ChartValueMaxGet macro 5-967
GFX_GOL_ChartValueMinGet macro 5-967
GFX_GOL_ChartValueRangeGet macro 5-968
GFX_GOL_ChartValueRangeSet function 5-740
gfx_gol_check_box.h 5-1080
GFX_GOL_CHECKBOX structure 5-898
9 MPLAB Harmony Help
u
GFX_GOL_CHECKBOX_STATE enumeration 5-899
GFX_GOL_CheckBoxActionGet function 5-728
GFX_GOL_CheckBoxActionSet function 5-729
GFX_GOL_CheckBoxCreate function 5-730
GFX_GOL_CheckBoxDraw function 5-731
GFX_GOL_CheckBoxTextAlignmentGet function 5-732
GFX_GOL_CheckBoxTextAlignmentSet function 5-732
GFX_GOL_CheckBoxTextGet macro 5-968
GFX_GOL_CheckBoxTextSet function 5-732
gfx_gol_custom_control.h 5-1080
GFX_GOL_CUSTOMCONTROL structure 5-899
GFX_GOL_CUSTOMCONTROL_DISABLED macro 5-969
GFX_GOL_CUSTOMCONTROL_DRAW macro 5-969
GFX_GOL_CUSTOMCONTROL_DRAW_BAR macro 5-969
GFX_GOL_CUSTOMCONTROL_HIDE macro 5-969
GFX_GOL_CustomControlActionGet function 5-740
GFX_GOL_CustomControlActionSet function 5-741
GFX_GOL_CustomControlCreate function 5-741
GFX_GOL_CustomControlDraw function 5-742
GFX_GOL_CustomControlGetPos macro 5-969
GFX_GOL_CustomControlSetPos macro 5-970
gfx_gol_digital_meter.h 5-1081
GFX_GOL_DIGITALMETER structure 5-900
GFX_GOL_DIGITALMETER_INDENT macro 5-970
GFX_GOL_DIGITALMETER_STATE enumeration 5-901
GFX_GOL_DIGITALMETER_WIDTH macro 5-970
GFX_GOL_DigitalMeterActionGet function 5-742
GFX_GOL_DigitalMeterCreate function 5-743
GFX_GOL_DigitalMeterDecrement function 5-744
GFX_GOL_DigitalMeterDraw function 5-745
GFX_GOL_DigitalMeterIncrement function 5-745
GFX_GOL_DigitalMeterTextAlignmentGet macro 5-1057
GFX_GOL_DigitalMeterTextAlignmentSet macro 5-1058
GFX_GOL_DigitalMeterValueGet macro 5-970
GFX_GOL_DigitalMeterValueSet function 5-746
GFX_GOL_DRAW_CALLBACK_FUNC type 5-901
GFX_GOL_DrawCallbackSet function 5-702
gfx_gol_edit_box.h 5-1082
GFX_GOL_EDITBOX structure 5-902
GFX_GOL_EDITBOX_STATE enumeration 5-1056
GFX_GOL_EditBoxActionGet function 5-747
GFX_GOL_EditBoxActionSet function 5-748
GFX_GOL_EditBoxCharAdd function 5-749
GFX_GOL_EditBoxCharRemove function 5-749
GFX_GOL_EditBoxCreate function 5-750
GFX_GOL_EditBoxDraw function 5-751
GFX_GOL_EditBoxTextAlignmentGet macro 5-1058
GFX_GOL_EditBoxTextAlignmentSet macro 5-1059
GFX_GOL_EditBoxTextGet macro 5-1059
GFX_GOL_EditBoxTextSet function 5-751
gfx_gol_font_default.h 5-1083
GFX_GOL_FONT_DEFAULT_H_FILE macro 5-971
gfx_gol_grid.h 5-1083
gfx_gol_group_box.h 5-1085
GFX_GOL_GROUPBOX structure 5-902
GFX_GOL_GROUPBOX_STATE enumeration 5-903
GFX_GOL_GroupboxActionGet function 5-759
GFX_GOL_GroupboxCreate function 5-760
GFX_GOL_GroupboxDraw function 5-761
GFX_GOL_GroupboxTextAlignmentGet function 5-761
GFX_GOL_GroupboxTextAlignmentSet function 5-762
GFX_GOL_GroupboxTextGet macro 5-971
GFX_GOL_GroupboxTextSet function 5-762
gfx_gol_list_box.h 5-1086
GFX_GOL_LISTBOX structure 5-903
GFX_GOL_LISTBOX_ITEM_STATUS enumeration 5-903
GFX_GOL_LISTBOX_STATE enumeration 5-904
GFX_GOL_ListBoxActionGet function 5-763
GFX_GOL_ListBoxActionSet function 5-764
GFX_GOL_ListBoxCreate function 5-765
GFX_GOL_ListBoxDraw function 5-766
GFX_GOL_ListBoxItemAdd function 5-767
GFX_GOL_ListBoxItemCountGet macro 5-972
GFX_GOL_ListBoxItemFocusGet function 5-768
GFX_GOL_ListBoxItemFocusSet function 5-769
GFX_GOL_ListBoxItemImageGet macro 5-972
GFX_GOL_ListBoxItemImageSet macro 5-973
GFX_GOL_ListBoxItemListGet macro 5-973
9 MPLAB Harmony Help
v
GFX_GOL_ListBoxItemListRemove function 5-769
GFX_GOL_ListBoxItemRemove function 5-770
GFX_GOL_ListBoxItemSelectStatusClear macro 5-974
GFX_GOL_ListBoxItemSelectStatusSet macro 5-974
GFX_GOL_ListBoxSelectionChange function 5-770
GFX_GOL_ListBoxSelectionGet function 5-771
GFX_GOL_ListBoxTextAlignmentGet macro 5-1060
GFX_GOL_ListBoxTextAlignmentSet macro 5-1060
GFX_GOL_ListBoxVisibleItemCountGet function 5-772
GFX_GOL_LISTITEM structure 5-904
GFX_GOL_MESSAGE structure 5-905
GFX_GOL_MessageCallbackSet function 5-702
GFX_GOL_METER structure 5-906
gfx_gol_meter.h 5-1087
GFX_GOL_METER_DRAW_TYPE enumeration 5-907
GFX_GOL_METER_STATE enumeration 5-907
GFX_GOL_MeterActionGet function 5-772
GFX_GOL_MeterActionSet function 5-773
GFX_GOL_MeterCreate function 5-773
GFX_GOL_MeterDecrement function 5-775
GFX_GOL_MeterDraw function 5-776
GFX_GOL_MeterIncrement function 5-776
GFX_GOL_MeterMaximumValueGet macro 5-975
GFX_GOL_MeterMinimumValueGet macro 5-975
GFX_GOL_MeterRangeSet function 5-777
GFX_GOL_MeterScaleColorsSet function 5-777
GFX_GOL_MeterTitleFontSet macro 5-976
GFX_GOL_MeterTypeSet macro 5-976
GFX_GOL_MeterValueFontSet macro 5-976
GFX_GOL_MeterValueGet macro 5-977
GFX_GOL_MeterValueSet function 5-778
GFX_GOL_OBJ_HEADER structure 5-908
GFX_GOL_OBJ_SCHEME structure 5-908
GFX_GOL_OBJ_TYPE enumeration 5-910
GFX_GOL_ObjectAdd function 5-703
GFX_GOL_ObjectBackGroundSet function 5-704
GFX_GOL_ObjectByIDDelete function 5-704
GFX_GOL_ObjectCanBeFocused function 5-704
GFX_GOL_ObjectDelete function 5-705
GFX_GOL_ObjectDrawDisable function 5-705
GFX_GOL_ObjectDrawEnable function 5-706
GFX_GOL_ObjectFind function 5-707
GFX_GOL_ObjectFocusGet function 5-707
GFX_GOL_ObjectFocusNextGet function 5-708
GFX_GOL_ObjectFocusPrevGet function 5-708
GFX_GOL_ObjectFocusSet function 5-709
GFX_GOL_ObjectHideDraw function 5-709
GFX_GOL_ObjectIDGet function 5-709
GFX_GOL_ObjectIsRedrawSet function 5-710
GFX_GOL_ObjectListDraw function 5-711
GFX_GOL_ObjectListFree function 5-711
GFX_GOL_ObjectListGet function 5-712
GFX_GOL_ObjectListNew function 5-712
GFX_GOL_ObjectListSet function 5-713
GFX_GOL_ObjectMessage function 5-714
GFX_GOL_ObjectNextGet function 5-715
GFX_GOL_ObjectRectangleRedraw function 5-715
GFX_GOL_ObjectStateClear macro 5-978
GFX_GOL_ObjectStateGet macro 5-978
GFX_GOL_ObjectStateSet macro 5-979
GFX_GOL_ObjectTypeGet function 5-716
GFX_GOL_PanelAlphaParameterSet function 5-717
GFX_GOL_PanelBackgroundSet function 5-717
GFX_GOL_PanelDraw function 5-717
GFX_GOL_PanelGradientParameterSet function 5-717
GFX_GOL_PanelParameterSet function 5-717
gfx_gol_picture.h 5-1087
GFX_GOL_PICTURECONTROL structure 5-1056
GFX_GOL_PictureControlActionGet function 5-783
GFX_GOL_PICTURECONTROLCONTROL_STATE
enumeration 5-1057
GFX_GOL_PictureControlCreate function 5-784
GFX_GOL_PictureControlDraw function 5-785
GFX_GOL_PictureControlImageGet macro 5-1061
GFX_GOL_PictureControlImageSet macro 5-1061
GFX_GOL_PictureControlPartialSet function 5-785
GFX_GOL_PictureControlScaleSet macro 5-1062
gfx_gol_progress_bar.h 5-1088
GFX_GOL_PROGRESSBAR structure 5-911
9 MPLAB Harmony Help
w
GFX_GOL_PROGRESSBAR_STATE enumeration 5-911
GFX_GOL_ProgressBarActionGet function 5-779
GFX_GOL_ProgressBarCreate function 5-780
GFX_GOL_ProgressBarDraw function 5-781
GFX_GOL_ProgressBarPositionGet macro 5-980
GFX_GOL_ProgressBarPositionSet function 5-782
GFX_GOL_ProgressBarRangeGet macro 5-980
GFX_GOL_ProgressBarRangeSet function 5-782
gfx_gol_radio_button.h 5-1089
GFX_GOL_RADIOBUTTON structure 5-912
GFX_GOL_RADIOBUTTON_STATE enumeration 5-912
GFX_GOL_RadioButtonActionGet function 5-787
GFX_GOL_RadioButtonActionSet function 5-788
GFX_GOL_RadioButtonCheckGet function 5-788
GFX_GOL_RadioButtonCheckSet function 5-790
GFX_GOL_RadioButtonCreate function 5-790
GFX_GOL_RadioButtonDraw function 5-792
GFX_GOL_RadioButtonTextAlignmentGet function 5-792
GFX_GOL_RadioButtonTextAlignmentSet function 5-793
GFX_GOL_RadioButtonTextGet macro 5-980
GFX_GOL_RadioButtonTextSet function 5-793
gfx_gol_round_dial.h 5-1090
GFX_GOL_RoundDailActionGet function 5-794
GFX_GOL_RoundDailActionSet function 5-795
GFX_GOL_ROUNDDIAL structure 5-913
GFX_GOL_ROUNDDIAL_DISABLED macro 5-981
GFX_GOL_ROUNDDIAL_DRAW macro 5-981
GFX_GOL_ROUNDDIAL_HIDE macro 5-981
GFX_GOL_ROUNDDIAL_MAX_POSITIONS macro 5-981
GFX_GOL_ROUNDDIAL_QUADRANT_POSITIONS macro
5-981
GFX_GOL_ROUNDDIAL_ROT_CCW macro 5-982
GFX_GOL_ROUNDDIAL_ROT_CW macro 5-982
GFX_GOL_RoundDialCreate function 5-796
GFX_GOL_RoundDialDraw function 5-797
GFX_GOL_RoundDialValueDecrement macro 5-982
GFX_GOL_RoundDialValueGet macro 5-982
GFX_GOL_RoundDialValueIncrement macro 5-983
GFX_GOL_RoundDialValueSet macro 5-983
gfx_gol_scan_codes.h 5-1091
gfx_gol_scheme.h 5-1092
GFX_GOL_SchemeAlphaPrecentSet function 5-878
GFX_GOL_SchemeBackgroundColorGet function 5-878
GFX_GOL_SchemeBackgroundColorSet function 5-878
GFX_GOL_SchemeBackgroundImageSet function 5-879
GFX_GOL_SchemeBackgroundTypeGet function 5-879
GFX_GOL_SchemeBackgroundTypeSet function 5-879
GFX_GOL_SchemeColor0Get function 5-879
GFX_GOL_SchemeColor0Set function 5-879
GFX_GOL_SchemeColor1Get function 5-880
GFX_GOL_SchemeColor1Set function 5-880
GFX_GOL_SchemeColorDisabledGet function 5-880
GFX_GOL_SchemeColorDisabledSet function 5-880
GFX_GOL_SchemeColorSet function 5-880
GFX_GOL_SchemeEmbossDarkColorGet function 5-881
GFX_GOL_SchemeEmbossDarkColorSet function 5-881
GFX_GOL_SchemeEmbossLightColorGet function 5-881
GFX_GOL_SchemeEmbossLightColorSet function 5-881
GFX_GOL_SchemeEmbossSet function 5-881
GFX_GOL_SchemeEmbossSizeGet function 5-882
GFX_GOL_SchemeEmbossSizeSet function 5-882
GFX_GOL_SchemeFillStyleGet function 5-882
GFX_GOL_SchemeFillStyleSet function 5-882
GFX_GOL_SchemeFontGet function 5-882
GFX_GOL_SchemeFontSet function 5-883
GFX_GOL_SchemeGradientColorSet function 5-883
GFX_GOL_SchemeGradientEndColorGet function 5-883
GFX_GOL_SchemeGradientEndColorSet function 5-883
GFX_GOL_SchemeGradientStartColorGet function 5-883
GFX_GOL_SchemeGradientStartColorSet function 5-884
GFX_GOL_SchemeTextColor0Get function 5-884
GFX_GOL_SchemeTextColor0Set function 5-884
GFX_GOL_SchemeTextColor1Get function 5-884
GFX_GOL_SchemeTextColor1Set function 5-884
GFX_GOL_SchemeTextColorDisableGet function 5-885
GFX_GOL_SchemeTextColorDisableSet function 5-885
GFX_GOL_SchemeTextColorSet function 5-885
gfx_gol_scroll_bar.h 5-1093
GFX_GOL_SCROLLBAR structure 5-914
9 MPLAB Harmony Help
x
GFX_GOL_SCROLLBAR_STATE enumeration 5-914
GFX_GOL_ScrollBarActionGet function 5-798
GFX_GOL_ScrollBarActionSet function 5-799
GFX_GOL_ScrollBarCreate function 5-800
GFX_GOL_ScrollBarDraw function 5-802
GFX_GOL_ScrollBarPageGet function 5-802
GFX_GOL_ScrollBarPageSet function 5-803
GFX_GOL_ScrollBarPositionDecrement function 5-804
GFX_GOL_ScrollBarPositionGet function 5-804
GFX_GOL_ScrollBarPositionIncrement function 5-805
GFX_GOL_ScrollBarPositionSet function 5-806
GFX_GOL_ScrollBarRangeGet function 5-807
GFX_GOL_ScrollBarRangeSet function 5-807
gfx_gol_static_text.h 5-1094
GFX_GOL_STATICTEXT structure 5-915
GFX_GOL_STATICTEXT_STATE enumeration 5-915
GFX_GOL_StaticTextActionGet function 5-808
GFX_GOL_StaticTextAlignmentGet function 5-809
GFX_GOL_StaticTextAlignmentSet function 5-809
GFX_GOL_StaticTextCreate function 5-810
GFX_GOL_StaticTextDraw function 5-811
GFX_GOL_StaticTextGet function 5-811
GFX_GOL_StaticTextSet function 5-812
gfx_gol_text_entry.h 5-1095
GFX_GOL_TEXTENTRY structure 5-916
GFX_GOL_TEXTENTRY_KEY_COMMAND_TYPE
enumeration 5-916
GFX_GOL_TEXTENTRY_STATE enumeration 5-917
GFX_GOL_TextEntryActionGet function 5-812
GFX_GOL_TextEntryActionSet function 5-814
GFX_GOL_TextEntryBufferClear function 5-815
GFX_GOL_TextEntryBufferGet function 5-815
GFX_GOL_TextEntryBufferSet function 5-816
GFX_GOL_TextEntryCharAdd function 5-816
GFX_GOL_TextEntryCreate function 5-817
GFX_GOL_TextEntryDraw function 5-818
GFX_GOL_TextEntryKeyCommandGet function 5-819
GFX_GOL_TextEntryKeyCommandSet function 5-819
GFX_GOL_TextEntryKeyIsPressed function 5-820
GFX_GOL_TextEntryKeyListCreate function 5-820
GFX_GOL_TextEntryKeyMemberListDelete function 5-821
GFX_GOL_TextEntryKeyTextSet function 5-821
GFX_GOL_TextEntryLastCharDelete function 5-822
GFX_GOL_TextEntrySpaceCharAdd function 5-822
GFX_GOL_TRANSLATED_ACTION enumeration 5-917
GFX_GOL_TRANSLATED_ACTION, \
GFX_GOL_OBJ_HEADER *, \ GFX_GOL_MESSAGE * \ ) type
5-919
GFX_GOL_TwoTonePanelDraw function 5-718
GFX_GOL_WINDOW structure 5-920
gfx_gol_window.h 5-1096
GFX_GOL_WINDOW_STATE enumeration 5-920
GFX_GOL_WindowActionGet function 5-823
GFX_GOL_WindowCreate function 5-823
GFX_GOL_WindowDraw function 5-824
GFX_GOL_WindowImageGet macro 5-984
GFX_GOL_WindowTextAlignmentGet function 5-825
GFX_GOL_WindowTextAlignmentSet function 5-825
GFX_GOL_WindowTextGet macro 5-984
GFX_GOL_WindowTextSet function 5-826
GFX_GRADIENT_STYLE structure 5-921
GFX_GradientColorSet function 5-847
GFX_GradientEndColorGet function 5-847
GFX_GradientStartColorGet function 5-847
GFX_GradientTypeSet macro 5-1125
gfx_imageDecoder.h 5-1096
GFX_ImageDraw function 5-848
GFX_ImageHeaderGet function 5-848
GFX_ImageHeightGet function 5-849
GFX_ImageOffsetAddressGet function 5-849
GFX_ImagePartialDraw function 5-850
GFX_ImageStretchSet macro 5-985
GFX_ImageWidthGet function 5-851
GFX_Initialize function 5-852
GFX_Layer function 5-852
GFX_LAYER_PARAMS structure 5-295
GFX_LINE_STYLE enumeration 5-921
GFX_LineDraw function 5-853
GFX_LinePositionRelativeSet function 5-853
GFX_LinePositionSet function 5-854
9 MPLAB Harmony Help
y
GFX_LinePositionXGet function 5-854
GFX_LinePositionYGet function 5-855
GFX_LineStyleGet function 5-855
GFX_LineStyleSet function 5-855
GFX_LineToDraw function 5-856
GFX_LineToRelativeDraw function 5-856
GFX_malloc macro 5-326
GFX_MAX_INVALIDATE_AREAS macro 5-985
GFX_MaxXGet macro 5-985
GFX_MaxYGet macro 5-985
GFX_MCHP_BITMAP_HEADER structure 5-922
GFX_MEM_MASK macro 5-986
GFX_PageSet function 5-857
gfx_palette.h 5-1098
GFX_PALETTE_ENTRY union 5-922
GFX_PARTIAL_IMAGE_PARAM structure 5-923
GFX_PixelPut macro 5-986
GFX_PixelsPut macro 5-986
GFX_PolygonDraw function 5-857
GFX_PrevAlphaColorGet macro 5-986
GFX_PrevAlphaColorSet macro 5-986
GFX_PRIM_SetPIPWindow function 5-305
gfx_primitive.h 5-1100
GFX_Primitive_DATA structure 5-923
GFX_Primitive_Initialize function 5-858
GFX_Primitive_instance variable 5-888
gfx_primitive_local.h 5-1104
GFX_RectangleDraw function 5-858
GFX_RectangleFillDraw function 5-859
GFX_RectangleRoundDraw function 5-860
GFX_RectangleRoundFillDraw function 5-861
GFX_RECTANGULAR_AREA structure 5-924
GFX_RenderingBufferGet function 5-862
GFX_RenderToDisplayBufferDisable function 5-862
GFX_RenderToDisplayBufferDisableFlagGet function 5-862
GFX_RenderToDisplayBufferEnable function 5-862
GFX_RESOURCE enumeration 5-924
GFX_RESOURCE_BINARY structure 5-926
GFX_RESOURCE_FONT structure 5-927
GFX_RESOURCE_HDR structure 5-927
GFX_RESOURCE_IMAGE structure 5-928
GFX_RESOURCE_PALETTE structure 5-929
GFX_RGBConvert macro 5-987
GFX_ScreenClear function 5-863
GFX_SetFontOrientation macro 5-987
GFX_SetTransitionParameters function 5-863
GFX_SineCosineGet function 5-1124
GFX_SineGet macro 5-1125
GFX_SolidLineDraw function 5-864
GFX_STATUS enumeration 5-929
GFX_STATUS_BIT enumeration 5-929
GFX_StyledLineDraw function 5-864
GFX_TextAreaBottomGet function 5-864
GFX_TextAreaBottomSet function 5-864
GFX_TextAreaLeftGet function 5-865
GFX_TextAreaLeftSet function 5-865
GFX_TextAreaRightGet function 5-865
GFX_TextAreaRightSet function 5-865
GFX_TextAreaTopGet function 5-865
GFX_TextAreaTopSet function 5-865
GFX_TextCharDraw function 5-866
GFX_TextCursorPositionSet function 5-866
GFX_TextCursorPositionXGet function 5-867
GFX_TextCursorPositionYGet function 5-867
GFX_TextStringBoxDraw function 5-868
GFX_TextStringDraw function 5-869
GFX_TextStringHeightGet function 5-869
GFX_TextStringWidthGet function 5-870
GFX_ThickBevelDraw function 5-871
GFX_Transition function 5-871
GFX_TRANSITION_DIRECTION enumeration 5-930
GFX_TRANSITION_PARAMS structure 5-930
GFX_TRANSITION_TYPE enumeration 5-930
gfx_transitions.h 5-1105
GFX_TransparentColorDisable function 5-871
GFX_TransparentColorEnable function 5-872
GFX_TransparentColorGet function 5-873
GFX_TransparentColorStatusGet function 5-873
9 MPLAB Harmony Help
z
GFX_TRIG_FUNCTION_TYPE enumeration 5-931
GFX_TYPE_MASK macro 5-988
gfx_types_font.h 5-1107
GFX_TYPES_FONTS_H macro 5-988
gfx_types_image.h 5-1107
GFX_TYPES_IMAGE_H macro 5-988
gfx_types_macros.h 5-1108
gfx_types_palette.h 5-1109
GFX_TYPES_PALETTE_H macro 5-988
gfx_types_resource.h 5-1109
GFX_TYPES_RESOURCE_H macro 5-988
GFX_UXCHAR macro 5-988
GFX_VisualPageGet macro 5-989
GFX_W3_ALICEBLUE macro 5-989
GFX_W3_ANTIQUEWHITE macro 5-989
GFX_W3_AQUA macro 5-989
GFX_W3_AQUAMARINE macro 5-989
GFX_W3_AZURE macro 5-989
GFX_W3_BEIGE macro 5-990
GFX_W3_BISQUE macro 5-990
GFX_W3_BLACK macro 5-990
GFX_W3_BLANCHEDALMOND macro 5-990
GFX_W3_BLUE macro 5-990
GFX_W3_BLUEVIOLET macro 5-990
GFX_W3_BROWN macro 5-990
GFX_W3_BURLYWOOD macro 5-991
GFX_W3_CADETBLUE macro 5-991
GFX_W3_CHARTREUSE macro 5-991
GFX_W3_CHOCOLATE macro 5-991
GFX_W3_CORAL macro 5-991
GFX_W3_CORNFLOWERBLUE macro 5-991
GFX_W3_CORNSILK macro 5-992
GFX_W3_CRIMSON macro 5-992
GFX_W3_CYAN macro 5-992
GFX_W3_DARKBLUE macro 5-992
GFX_W3_DARKCYAN macro 5-992
GFX_W3_darkgoldenrod macro 5-992
GFX_W3_DARKGRAY macro 5-992
GFX_W3_DARKGREEN macro 5-993
GFX_W3_DARKGREY macro 5-993
GFX_W3_DARKHAKI macro 5-993
GFX_W3_DARKMAGENTA macro 5-993
GFX_W3_DARKOLIVEGREEN macro 5-993
GFX_W3_DARKORANGE macro 5-993
GFX_W3_DARKORCHID macro 5-994
GFX_W3_DARKRED macro 5-994
GFX_W3_DARKSALMON macro 5-994
GFX_W3_DARKSEAGREEN macro 5-994
GFX_W3_DARKSLATEBLUE macro 5-994
GFX_W3_DARKSLATEGRAY macro 5-994
GFX_W3_DARKSLATEGREY macro 5-994
GFX_W3_DARKTURQUOISE macro 5-995
GFX_W3_DARKVIOLET macro 5-995
GFX_W3_DEEPPINK macro 5-995
GFX_W3_DEEPSKYBLUE macro 5-995
GFX_W3_DIMGRAY macro 5-995
GFX_W3_DIMGREY macro 5-995
GFX_W3_DODGERBLUE macro 5-996
GFX_W3_FIREBRICK macro 5-996
GFX_W3_FLORALWHITE macro 5-996
GFX_W3_FORESTGREEN macro 5-996
GFX_W3_FUCHSIA macro 5-996
GFX_W3_GAINSBORO macro 5-996
GFX_W3_GHOSTWHITE macro 5-996
GFX_W3_GOLD macro 5-997
GFX_W3_GOLDENROD macro 5-997
GFX_W3_GRAY macro 5-997
GFX_W3_GREEN macro 5-997
GFX_W3_GREENYELLOW macro 5-997
GFX_W3_GREY macro 5-997
GFX_W3_HONEYDEW macro 5-998
GFX_W3_HOTPINK macro 5-998
GFX_W3_INDIANRED macro 5-998
GFX_W3_INDIGO macro 5-998
GFX_W3_IVORY macro 5-998
GFX_W3_LAVENDER macro 5-998
GFX_W3_LAVENDERBLUSH macro 5-998
GFX_W3_LAWNGREEN macro 5-999
9 MPLAB Harmony Help
aa
GFX_W3_LEMONCHIFFON macro 5-999
GFX_W3_LIGHTBLUE macro 5-999
GFX_W3_LIGHTCORAL macro 5-999
GFX_W3_LIGHTCYAN macro 5-999
GFX_W3_LIGHTGOLDENRODYELLOW macro 5-999
GFX_W3_LIGHTGRAY macro 5-1000
GFX_W3_LIGHTGREEN macro 5-1000
GFX_W3_LIGHTGREY macro 5-1000
GFX_W3_LIGHTPINK macro 5-1000
GFX_W3_LIGHTSALMON macro 5-1000
GFX_W3_LIGHTSKYBLUE macro 5-1000
GFX_W3_LIGHTSLATEGRAY macro 5-1000
GFX_W3_LIGHTSLATEGREY macro 5-1001
GFX_W3_LIGHTSTEELBLUE macro 5-1001
GFX_W3_LIGHTYELLOW macro 5-1001
GFX_W3_LIGTHSEAGREEN macro 5-1001
GFX_W3_LIME macro 5-1001
GFX_W3_LIMEGREEN macro 5-1001
GFX_W3_LINEN macro 5-1002
GFX_W3_MAGENTA macro 5-1002
GFX_W3_MAROON macro 5-1002
GFX_W3_MEDIUMAQUAMARINE macro 5-1002
GFX_W3_MEDIUMBLUE macro 5-1002
GFX_W3_MEDIUMORCHID macro 5-1002
GFX_W3_MEDIUMPURPLE macro 5-1002
GFX_W3_MEDIUMSEAGREEN macro 5-1003
GFX_W3_MEDIUMSLATEBLUE macro 5-1003
GFX_W3_MEDIUMSPRINGGREEN macro 5-1003
GFX_W3_MEDIUMTURQUOISE macro 5-1003
GFX_W3_MEDIUMVIOLETRED macro 5-1003
GFX_W3_MIDNIGHTBLUE macro 5-1003
GFX_W3_MINTCREAM macro 5-1004
GFX_W3_MISTYROSE macro 5-1004
GFX_W3_MOCCASIN macro 5-1004
GFX_W3_NAVAJOWHITE macro 5-1004
GFX_W3_NAVY macro 5-1004
GFX_W3_OLDLACE macro 5-1004
GFX_W3_OLIVE macro 5-1004
GFX_W3_OLIVEDRAB macro 5-1005
GFX_W3_ORANGE macro 5-1005
GFX_W3_ORANGERED macro 5-1005
GFX_W3_ORCHID macro 5-1005
GFX_W3_PALEGOLDENROD macro 5-1005
GFX_W3_PALEGREEN macro 5-1005
GFX_W3_PALETURQUOISE macro 5-1006
GFX_W3_PALEVIOLETRED macro 5-1006
GFX_W3_PAPAYAWHIP macro 5-1006
GFX_W3_PEACHPUFF macro 5-1006
GFX_W3_PERU macro 5-1006
GFX_W3_PINK macro 5-1006
GFX_W3_PLUM macro 5-1006
GFX_W3_POWDERBLUE macro 5-1007
GFX_W3_PURPLE macro 5-1007
GFX_W3_RED macro 5-1007
GFX_W3_ROSYBROWN macro 5-1007
GFX_W3_ROYALBLUE macro 5-1007
GFX_W3_SADDLEBROWN macro 5-1007
GFX_W3_SALMON macro 5-1008
GFX_W3_SANDYGREEN macro 5-1008
GFX_W3_SEAGREEN macro 5-1008
GFX_W3_SEASHELL macro 5-1008
GFX_W3_SIENNA macro 5-1008
GFX_W3_SILVER macro 5-1008
GFX_W3_SKYBLUE macro 5-1008
GFX_W3_SLATEBLUE macro 5-1009
GFX_W3_SLATEGRAY macro 5-1009
GFX_W3_SLATEGREY macro 5-1009
GFX_W3_SNOW macro 5-1009
GFX_W3_SPRINGGREEN macro 5-1009
GFX_W3_STEELBLUE macro 5-1009
GFX_W3_TAN macro 5-1010
GFX_W3_TEAL macro 5-1010
GFX_W3_THISTLE macro 5-1010
GFX_W3_TOMATO macro 5-1010
GFX_W3_TURQUOISE macro 5-1010
GFX_W3_VIOLET macro 5-1010
GFX_W3_WHEAT macro 5-1010
GFX_W3_WHITE macro 5-1011
9 MPLAB Harmony Help
bb
GFX_W3_WHITESMOKE macro 5-1011
GFX_W3_YELLOW macro 5-1011
GFX_W3_YELLOWGREEN macro 5-1011
GFX_X11_ALICE_BLUE macro 5-1011
GFX_X11_ANTIQUE_WHITE macro 5-1011
GFX_X11_AQUA macro 5-1012
GFX_X11_AQUAMARINE macro 5-1012
GFX_X11_AZURE macro 5-1012
GFX_X11_BEIGE macro 5-1012
GFX_X11_BISQUE macro 5-1012
GFX_X11_BLACK macro 5-1012
GFX_X11_BLANCHED_ALMOND macro 5-1012
GFX_X11_BLUE macro 5-1013
GFX_X11_BLUE_VIOLET macro 5-1013
GFX_X11_BROWN macro 5-1013
GFX_X11_BURLY_WOOD macro 5-1013
GFX_X11_CADEL_BLUE macro 5-1013
GFX_X11_CHARTEUSE macro 5-1013
GFX_X11_CHOCOLATE macro 5-1014
GFX_X11_CORAL macro 5-1014
GFX_X11_CORNFLOWER_BLUE macro 5-1014
GFX_X11_CORNSILK macro 5-1014
GFX_X11_CRIMSON macro 5-1014
GFX_X11_CYAN macro 5-1014
GFX_X11_DARK_BLUE macro 5-1014
GFX_X11_DARK_CYAN macro 5-1015
GFX_X11_DARK_GOLDENROD macro 5-1015
GFX_X11_DARK_GREEN macro 5-1015
GFX_X11_DARK_GREY macro 5-1015
GFX_X11_DARK_KHAKI macro 5-1015
GFX_X11_DARK_MAGENTA macro 5-1015
GFX_X11_DARK_OLIVE_GREEN macro 5-1016
GFX_X11_DARK_ORANGE macro 5-1016
GFX_X11_DARK_ORCHID macro 5-1016
GFX_X11_DARK_RED macro 5-1016
GFX_X11_DARK_SALMON macro 5-1016
GFX_X11_DARK_SEA_GREEN macro 5-1016
GFX_X11_DARK_SLATE_BLUE macro 5-1016
GFX_X11_DARK_SLATE_GREY macro 5-1017
GFX_X11_DARK_TURQUOISE macro 5-1017
GFX_X11_DARK_VIOLET macro 5-1017
GFX_X11_DEEP_PINK macro 5-1017
GFX_X11_DEEP_SKY_BLUE macro 5-1017
GFX_X11_DIM_GREY macro 5-1017
GFX_X11_DODGER_BLUE macro 5-1018
GFX_X11_FIRE_BRICK macro 5-1018
GFX_X11_FLORAL_WHITE macro 5-1018
GFX_X11_FOREST_GREEN macro 5-1018
GFX_X11_FUCHSIA macro 5-1018
GFX_X11_GAINSBORO macro 5-1018
GFX_X11_GHOST_WHITE macro 5-1018
GFX_X11_GOLD macro 5-1019
GFX_X11_GOLDENROD macro 5-1019
GFX_X11_GREEN macro 5-1019
GFX_X11_GREEN_YELLOW macro 5-1019
GFX_X11_GREY macro 5-1019
GFX_X11_HONEYDEW macro 5-1019
GFX_X11_HOT_PINK macro 5-1020
GFX_X11_INDIAN_RED macro 5-1020
GFX_X11_INDIGO macro 5-1020
GFX_X11_IVORY macro 5-1020
GFX_X11_KHAKI macro 5-1020
GFX_X11_LAVENDER macro 5-1020
GFX_X11_LAVENDOR_BLUSH macro 5-1020
GFX_X11_LAWN_GREEN macro 5-1021
GFX_X11_LEMON_CHIFFON macro 5-1021
GFX_X11_LIGHT_BLUE macro 5-1021
GFX_X11_LIGHT_CAROL macro 5-1021
GFX_X11_LIGHT_CYAN macro 5-1021
GFX_X11_LIGHT_GOLDENROD_YELLOW macro 5-1021
GFX_X11_LIGHT_GRAY macro 5-1022
GFX_X11_LIGHT_GREEN macro 5-1022
GFX_X11_LIGHT_PINK macro 5-1022
GFX_X11_LIGHT_SALMON macro 5-1022
GFX_X11_LIGHT_SEA_GREEN macro 5-1022
GFX_X11_LIGHT_SKY_BLUE macro 5-1022
GFX_X11_LIGHT_SLATE_GREY macro 5-1022
GFX_X11_LIGHT_STEEL_BLUE macro 5-1023
9 MPLAB Harmony Help
cc
GFX_X11_LIGHT_YELLOW macro 5-1023
GFX_X11_LIME macro 5-1023
GFX_X11_LIME_GREEN macro 5-1023
GFX_X11_LINEN macro 5-1023
GFX_X11_MAGENTA macro 5-1023
GFX_X11_MARRON macro 5-1024
GFX_X11_MEDIUM_AQUAMARINE macro 5-1024
GFX_X11_MEDIUM_BLUE macro 5-1024
GFX_X11_MEDIUM_ORCHID macro 5-1024
GFX_X11_MEDIUM_PURPLE macro 5-1024
GFX_X11_MEDIUM_SEA_GREEN macro 5-1024
GFX_X11_MEDIUM_SLATE_BLUE macro 5-1024
GFX_X11_MEDIUM_SPRING_GREEN macro 5-1025
GFX_X11_MEDIUM_TURQUOISE macro 5-1025
GFX_X11_MEDIUM_VIOLET_RED macro 5-1025
GFX_X11_MIDNIGHT_BLUE macro 5-1025
GFX_X11_MINT_CREAM macro 5-1025
GFX_X11_MISTY_ROSE macro 5-1025
GFX_X11_MOCCASIN macro 5-1026
GFX_X11_NAVAJO_WHITE macro 5-1026
GFX_X11_NAVY macro 5-1026
GFX_X11_OLD_LACE macro 5-1026
GFX_X11_OLIVE macro 5-1026
GFX_X11_OLIVE_DRAB macro 5-1026
GFX_X11_ORANGE macro 5-1026
GFX_X11_ORANGE_RED macro 5-1027
GFX_X11_ORCHID macro 5-1027
GFX_X11_PALE_GOLDENROD macro 5-1027
GFX_X11_PALE_GREEN macro 5-1027
GFX_X11_PALE_TURQUOISE macro 5-1027
GFX_X11_PALE_VIOLET_RED macro 5-1027
GFX_X11_PAPAYA_WHIP macro 5-1028
GFX_X11_PEACH_PUFF macro 5-1028
GFX_X11_PERU macro 5-1028
GFX_X11_PINK macro 5-1028
GFX_X11_PLUM macro 5-1028
GFX_X11_POWDER_BLUE macro 5-1028
GFX_X11_PURPLE macro 5-1028
GFX_X11_RED macro 5-1029
GFX_X11_ROSY_BROWN macro 5-1029
GFX_X11_ROYAL_BLUE macro 5-1029
GFX_X11_SADDLE_BROWN macro 5-1029
GFX_X11_SALMON macro 5-1029
GFX_X11_SANDY_BROWN macro 5-1029
GFX_X11_SEA_GREEN macro 5-1030
GFX_X11_SEASHELL macro 5-1030
GFX_X11_SIENNA macro 5-1030
GFX_X11_SILVER macro 5-1030
GFX_X11_SKY_BLUE macro 5-1030
GFX_X11_SLATE_BLUE macro 5-1030
GFX_X11_SLATE_GREY macro 5-1030
GFX_X11_SNOW macro 5-1031
GFX_X11_SPRING_GREEN macro 5-1031
GFX_X11_STEEL_BLUE macro 5-1031
GFX_X11_TAN macro 5-1031
GFX_X11_TEAL macro 5-1031
GFX_X11_THISTLE macro 5-1031
GFX_X11_TOMATO macro 5-1032
GFX_X11_TURQUOISE macro 5-1032
GFX_X11_VIOLET macro 5-1032
GFX_X11_WHEAT macro 5-1032
GFX_X11_WHITE macro 5-1032
GFX_X11_WHITE_SMOKE macro 5-1032
GFX_X11_YELLOW macro 5-1032
GFX_X11_YELLOW_GREEN macro 5-1033
GFX_XCHAR macro 5-1033
GFXCirclePointGet function 5-1125
GOL_PANEL_PARAM structure 5-932
GOLD macro 5-1033
Gradients 5-1114
Graphic Display Driver Layer Changes 5-683
Graphic Object Layer (GOL) Changes 5-683
Graphic Primitive Layer Changes 5-682
Graphics (GFX) Driver Library 5-289
Graphics Demonstrations 3-84
Graphics Library Help 5-680
Graphics Library Porting Guide 5-680
Graphics Object Library 5-694
9 MPLAB Harmony Help
dd
Graphics Primitive Library 5-1110
GRAPHICS_LIBRARY_VERSION macro 5-1033
GRAY000 macro 5-1034
GRAY001 macro 5-1034
GRAY002 macro 5-1034
GRAY003 macro 5-1034
GRAY004 macro 5-1034
GRAY005 macro 5-1034
GRAY006 macro 5-1034
GRAY007 macro 5-1035
GRAY008 macro 5-1035
GRAY009 macro 5-1035
GRAY010 macro 5-1035
GRAY011 macro 5-1035
GRAY012 macro 5-1035
GRAY013 macro 5-1036
GRAY014 macro 5-1036
GRAY015 macro 5-1036
GRAY032 macro 5-1036
GRAY096 macro 5-1036
GRAY128 macro 5-1036
GRAY160 macro 5-1036
GRAY192 macro 5-1037
GRAY204 macro 5-1037
GRAY224 macro 5-1037
GRAY229 macro 5-1037
GRAY242 macro 5-1037
GREEN macro 5-1037
GRID structure 5-932
GRID_DISABLED macro 5-1038
GRID_DRAW_ALL macro 5-1038
GRID_DRAW_ITEMS macro 5-1038
GRID_FOCUSED macro 5-1038
GRID_HEIGHT macro 5-1038
GRID_HIDE macro 5-1038
GRID_MAX_COLUMNS macro 5-1039
GRID_MAX_ROWS macro 5-1039
GRID_OUT_OF_BOUNDS macro 5-1039
GRID_SHOW_BORDER_ONLY macro 5-1039
GRID_SHOW_FOCUS macro 5-1039
GRID_SHOW_LINES macro 5-1039
GRID_SHOW_SEPARATORS_ONLY macro 5-1039
GRID_SUCCESS macro 5-1040
GRID_TYPE_MASK macro 5-1040
GRID_WIDTH macro 5-1040
GridClearCellState function 5-752
GridCreate function 5-753
GridDraw function 5-754
GridFreeItems function 5-754
GridGetCell function 5-755
GridGetFocusX macro 5-1040
GridGetFocusY macro 5-1041
GRIDITEM structure 5-933
GRIDITEM_DRAW macro 5-1041
GRIDITEM_IS_BITMAP macro 5-1041
GRIDITEM_IS_TEXT macro 5-1041
GRIDITEM_SELECTED macro 5-1041
GRIDITEM_TEXTBOTTOM macro 5-1042
GRIDITEM_TEXTLEFT macro 5-1042
GRIDITEM_TEXTRIGHT macro 5-1042
GRIDITEM_TEXTTOP macro 5-1042
GridMsgDefault function 5-755
GridSetCell function 5-756
GridSetCellState function 5-757
GridSetFocus function 5-757
GridTranslateMsg function 5-758
H
Handling Endpoint 0 (EP0) Packets 5-3976
Handling Errors 5-2085, 5-2487
Handling Events 5-1562
Hardware 3-103, 3-124, 3-143
Hardware Abstraction Model 5-1362, 5-1473, 5-1521, 5-1564,
5-1669, 5-1735, 5-1905, 5-2087, 5-2172, 5-2203, 5-2253,
5-2289, 5-2332, 5-2429, 5-2479, 5-2595, 5-2663, 5-2689,
5-2705, 5-2763, 5-2801, 5-2893, 5-3012, 5-3087, 5-3322
Hardware Abstraction Models 5-3171
Hardware Drivers 5-309
Hardware Information 3-103, 3-124, 3-143
9 MPLAB Harmony Help
ee
help_sys_ports.h 5-3498
hid_basic 3-158
hid_joystick 3-161
hid_keyboard 3-161
hid_mouse 3-160
HIDE_DATA macro 5-1042
Host 3-167
How the Library Works 5-195, 5-345, 5-369, 5-399, 5-421,
5-459, 5-514, 5-554, 5-607, 5-697, 5-1112, 5-1315, 5-1367,
5-1474, 5-1522, 5-1555, 5-1670, 5-1736, 5-1866, 5-1906,
5-2061, 5-2173, 5-2205, 5-2255, 5-2290, 5-2333, 5-2431,
5-2480, 5-2598, 5-2666, 5-2690, 5-2707, 5-2764, 5-2802,
5-2896, 5-3015, 5-3088, 5-3321, 5-3350, 5-3365, 5-3422,
5-3443, 5-3470, 5-3506, 5-3531, 5-3576, 5-3616, 5-3627,
5-3869, 5-3883, 5-3932, 5-4007, 5-4170
HTTP Changes 5-3551
HTTP Server TCP/IP Stack Library 5-3659
http.h 5-3688
HTTP_CACHE_LEN macro 5-3662
http_config.h 5-3689
HTTP_CONFIG_FLAGS macro 5-3662
HTTP_CONN_HANDLE type 5-3684
HTTP_DEFAULT_FILE macro 5-3662
HTTP_DEFAULT_LEN macro 5-3663
HTTP_FILE_TYPE enumeration 5-3684
HTTP_FILE_UPLOAD macro 5-3663
HTTP_IO_RESULT enumeration 5-3684
HTTP_MAX_CONNECTIONS macro 5-3663
HTTP_MAX_DATA_LEN macro 5-3663
HTTP_MAX_HEADER_LEN macro 5-3663
HTTP_MIN_CALLBACK_FREE macro 5-3663
HTTP_MODULE_CONFIG structure 5-3685
HTTP_MODULE_FLAGS enumeration 5-3685
HTTP_PORT macro 5-3664
HTTP_READ_STATUS enumeration 5-3685
HTTP_SKT_RX_BUFF_SIZE macro 5-3664
HTTP_SKT_TX_BUFF_SIZE macro 5-3664
HTTP_SSL_ONLY_CHAR macro 5-3664
HTTP_STATUS enumeration 5-3686
HTTP_TIMEOUT macro 5-3664
HTTP_USE_AUTHENTICATION macro 5-3664
HTTP_USE_COOKIES macro 5-3665
HTTP_USE_POST macro 5-3665
HTTPCheckAuth function 5-3679
HTTPExecuteGet function 5-3680
HTTPExecutePost function 5-3681
HTTPNeedsAuth function 5-3682
HTTPPrint_varname function 5-3683
HTTPReadPostPair macro 5-3687
HTTPS_DEFAULT_FILE macro 5-3665
HTTPS_PORT macro 5-3665
I
I2C Peripheral Library 5-2059
I2C_MODULE_ID enumeration 5-2165
IC_BUFFER_SIZE enumeration 5-2188
IC_CLOCK_SOURCES enumeration 5-2188
IC_EDGE_TYPES enumeration 5-2189
IC_EVENTS_PER_INTERRUPT enumeration 5-2189
IC_INPUT_CAPTURE_MODES enumeration 5-2189
IC_MODULE_ID enumeration 5-2190
IC_SYNC_MODE_INPUTS enumeration 5-2191
IC_SYNC_MODES enumeration 5-2192
IC_TIMERS enumeration 5-2192
ICMP TCP/IP Stack Library 5-3690
icmp.h 5-3696
icmp_config.h 5-3697
ICMP_ECHO_RESULT enumeration 5-3695
ICMP_HANDLE type 5-3695
ICMP_MODULE_CONFIG structure 5-3696
ICMP_TIMEOUT macro 5-3692
ICMPv6 TCP/IP Stack Library 5-3697
icmpv6.h 5-3707
icmpv6_config.h 5-3708
ICMPV6_ERR_DU_CODE enumeration 5-3704
ICMPV6_ERR_PP_CODE enumeration 5-3705
ICMPV6_ERR_PTB_CODE macro 5-3703
ICMPV6_ERR_TE_CODE enumeration 5-3705
ICMPV6_HANDLE type 5-3705
ICMPV6_HEADER_ECHO structure 5-3706
ICMPV6_HEADER_ERROR structure 5-3706
9 MPLAB Harmony Help
ff
ICMPV6_INFO_EREQ_CODE macro 5-3704
ICMPV6_INFO_ERPL_CODE macro 5-3704
ICMPV6_PACKET_TYPES enumeration 5-3706
ICMPV6_TIMEOUT macro 5-3700
IMAGE_STRETCH enumeration 5-933
ImageAbort macro 5-1042
ImageDecoderInit function 5-874
ImageDecodeTask function 5-874
ImageFullScreenDecode macro 5-1043
ImageLoopCallbackRegister function 5-875
Images 5-1117, 5-1124
IMG_ALIGN_CENTER macro 5-1044
IMG_bAlignCenter variable 5-885
IMG_bDownScalingFactor variable 5-885
IMG_blAbortImageDecoding variable 5-886
IMG_DECODE_ABORTED macro 5-1044
IMG_DOWN_SCALE macro 5-1044
IMG_FCLOSE macro 5-1044
IMG_FEOF macro 5-1044
IMG_FILE macro 5-1044
IMG_FILE_FORMAT type 5-933
IMG_FILE_SYSTEM_API type 5-933
IMG_FOPEN macro 5-1045
IMG_FREAD macro 5-1045
IMG_FSEEK macro 5-1045
IMG_FTELL macro 5-1045
IMG_LOOP_CALLBACK type 5-933
IMG_pCurrentFile variable 5-886
IMG_pFileAPIs variable 5-886
IMG_PIXEL_OUTPUT type 5-934
IMG_PIXEL_XY_RGB_888 type 5-934
IMG_PixelXYColor variable 5-886
IMG_pLoopCallbackFn variable 5-886
IMG_pPixelOutput variable 5-886
IMG_SCREEN_HEIGHT macro 5-1045
IMG_SCREEN_WIDTH macro 5-1045
IMG_vCheckAndAbort macro 5-1045
IMG_vLoopCallback macro 5-1046
IMG_vPutPixel macro 5-1046
IMG_vSetboundaries function 5-875
IMG_vSetColor macro 5-1046
IMG_wHeight variable 5-886
IMG_wImageHeight variable 5-887
IMG_wImageWidth variable 5-887
IMG_wStartX variable 5-887
IMG_wStartY variable 5-887
IMG_wWidth variable 5-887
in_addr structure 5-3611
INADDR_ANY macro 5-3609
Initator Initialization 5-2764
Initialization 5-1367, 5-1670, 5-1915, 5-2481, 5-3350, 5-3387
Initialization Functions 7-4238
Initialization of CAN 5-1557
Initialization Overrides 5-474, 5-574, 5-608, 5-1323
Initializing and Communicating with the Endpoint 5-3975
Initializing the Data Structure 5-4014
Initializing the I2C 5-2061
Initializing the Library 5-3980, 5-4007
Initializing the USB Device Stack 5-3973
Input Capture Module Setup 5-2173
Input Capture Peripheral Library 5-2170
INPUT_DEVICE_EVENT enumeration 5-934
INPUT_DEVICE_TYPE enumeration 5-935
Installing the Configurator Plug-in 2-42
INT_EXTERNAL_SOURCES enumeration 5-2232
INT_PRIORITY_LEVEL enumeration 5-2233
INT_SOURCE enumeration 5-2233
INT_SUBPRIORITY_LEVEL enumeration 5-2237
INT_TRAP_SOURCE enumeration 5-2238
INT_VECTOR enumeration 5-2238
int16_gfx_image_prog type 5-935
int16_prog type 5-935
int16_prog_pack type 5-935
int16c structure 5-1264
int32_gfx_image_prog type 5-936
int32_prog type 5-936
int32_prog_pack type 5-936
int32c structure 5-1265
9 MPLAB Harmony Help
gg
int8_gfx_image_prog type 5-936
int8_prog type 5-936
int8_prog_pack type 5-936
Internal FRC Oscillator Tuning 5-2335
Interrupt Control and Management 5-1738
Interrupt Operation 5-1320
Interrupt Peripheral Library 5-2202
Interrupt State Machine 5-2076
Interrupt System Service Library 5-3419
Interrupt System Setup 5-3422
Interrupts 5-2823
Introduction 2-40, 3-64, 3-84, 3-98, 3-102, 3-113, 3-123, 3-130,
3-142, 3-149, 4-178, 5-193, 5-226, 5-254, 5-289, 5-299, 5-309,
5-319, 5-333, 5-342, 5-367, 5-397, 5-418, 5-457, 5-510, 5-552,
5-600, 5-680, 5-694, 5-1110, 5-1127, 5-1167, 5-1275, 5-1311,
5-1361, 5-1471, 5-1519, 5-1553, 5-1667, 5-1733, 5-1864,
5-1902, 5-2059, 5-2170, 5-2202, 5-2252, 5-2287, 5-2330,
5-2427, 5-2478, 5-2593, 5-2662, 5-2687, 5-2703, 5-2762,
5-2798, 5-2891, 5-3011, 5-3085, 5-3167, 5-3319, 5-3347,
5-3363, 5-3376, 5-3419, 5-3438, 5-3465, 5-3500, 5-3529,
5-3536, 5-3546, 5-3569, 5-3574, 5-3598, 5-3614, 5-3625,
5-3636, 5-3646, 5-3654, 5-3659, 5-3690, 5-3697, 5-3709,
5-3718, 5-3747, 5-3771, 5-3794, 5-3798, 5-3806, 5-3809,
5-3822, 5-3858, 5-3867, 5-3881, 5-3913, 5-3917, 5-3930,
5-3955, 5-3963, 5-3973, 5-3977, 5-4004, 5-4060, 5-4100,
5-4131, 5-4168, 5-4179, 5-4199, 6-4226, 7-4228, 7-4230,
7-4232, 7-4234, 7-4236
INVALID_SOCKET macro 5-3910
INVALID_TCP_PORT macro 5-3609
INVALID_UDP_SOCKET macro 5-3950
IP_ADDR_ANY macro 5-3609
ip_config.h 5-3716, 5-3747
IP_DEFAULT_ALLOCATION_BLOCK_SIZE macro 5-3711
IP_VERSION_4 macro 5-3735
IP_VERSION_6 macro 5-3735
IPPROTO_IP macro 5-3609
IPPROTO_TCP macro 5-3609
IPPROTO_UDP macro 5-3609
IPv4 TCP/IP Stack Library 5-3708
ipv4.h 5-3717
IPV4_HEADER structure 5-3715
IPV4_HEADER_TYPE enumeration 5-3715
IPV4_MODULE_CONFIG structure 5-3715
IPV4_PACKET structure 5-3716
IPV4_QUEUED_PACKET_LIMIT macro 5-3711
IPV4_QUEUED_PACKET_TIMEOUT macro 5-3711
IPV4_TASK_PROCESS_RATE macro 5-3711
IPv6 TCP/IP Stack Library 5-3718
ipv6.h 5-3745
IPV6_ACTION enumeration 5-3739
IPV6_ADDRESS_POLICY structure 5-3739
IPV6_ADDRESS_PREFERENCE enumeration 5-3739
IPV6_ADDRESS_TYPE union 5-3739
IPV6_DATA_DYNAMIC_BUFFER macro 5-3735
IPV6_DATA_NETWORK_FIFO macro 5-3736
IPV6_DATA_NONE macro 5-3736
IPV6_DATA_PIC_RAM macro 5-3736
IPV6_DATA_SEGMENT_HEADER type 5-3740
IPV6_DEFAULT_BASE_REACHABLE_TIME macro 5-3722
IPV6_DEFAULT_CUR_HOP_LIMIT macro 5-3722
IPV6_DEFAULT_LINK_MTU macro 5-3722
IPV6_DEFAULT_RETRANSMIT_TIME macro 5-3722
IPV6_EVENT_HANDLER type 5-3740
IPV6_EVENT_TYPE enumeration 5-3740
IPV6_FRAGMENT_HEADER structure 5-3741
IPV6_HANDLE type 5-3741
IPV6_HEADER structure 5-3741
IPV6_HEADER_OFFSET_DEST_ADDR macro 5-3736
IPV6_HEADER_OFFSET_NEXT_HEADER macro 5-3736
IPV6_HEADER_OFFSET_PAYLOAD_LENGTH macro 5-3736
IPV6_HEADER_OFFSET_SOURCE_ADDR macro 5-3737
IPV6_INIT_TASK_PROCESS_RATE macro 5-3720
IPV6_MINIMUM_LINK_MTU macro 5-3721
IPV6_MODULE_CONFIG structure 5-3742
IPV6_MTU_INCREASE_TIMEOUT macro 5-3802
IPV6_NEIGHBOR_CACHE_ENTRY_STALE_TIMEOUT macro
5-3721
IPV6_NEXT_HEADER_TYPE enumeration 5-3742
IPV6_NO_UPPER_LAYER_CHECKSUM macro 5-3737
IPV6_PACKET type 5-3743
IPV6_PACKET_ACK_FNC type 5-3743
IPV6_QUEUE_MCAST_PACKET_LIMIT macro 5-3721
IPV6_QUEUE_NEIGHBOR_PACKET_LIMIT macro 5-3721
IPV6_QUEUED_MCAST_PACKET_TIMEOUT macro 5-3721
IPV6_RX_FRAGMENT_BUFFER type 5-3743
9 MPLAB Harmony Help
hh
IPV6_SEGMENT_TYPE enumeration 5-3743
IPV6_SNMP_TRAP_INFO structure 5-3848
IPV6_TASK_PROCESS_RATE macro 5-3721
IPV6_TLV_HBHO_PAYLOAD_JUMBOGRAM macro 5-3737
IPV6_TLV_HBHO_ROUTER_ALERT macro 5-3737
IPV6_TLV_OPTION_TYPE union 5-3744
IPV6_TLV_PAD_1 macro 5-3737
IPV6_TLV_PAD_N macro 5-3737
IPV6_TLV_UNREC_OPT_DISCARD_PP macro 5-3737
IPV6_TLV_UNREC_OPT_DISCARD_PP_NOT_MC macro
5-3738
IPV6_TLV_UNREC_OPT_DISCARD_SILENT macro 5-3738
IPV6_TLV_UNREC_OPT_SKIP_OPTION macro 5-3738
IPV6_ULA_FLAGS enumeration 5-3744
IPV6_ULA_NTP_ACCESS_TMO macro 5-3722
IPV6_ULA_NTP_VALID_WINDOW macro 5-3722
IPV6_ULA_RESULT enumeration 5-3745
Isochronous Transfers 5-571
IsPaletteEnabled function 5-875
ISR Implementation 7-4229
K
KEYMEMBER structure 5-936
KHAKI macro 5-1046
L
LAYER_ACTIONS enumeration 5-937
LAYER_REGISTERS structure 5-332
LAYER_TYPE enumeration 5-294
lcc_demo 3-85
LCC_TASK enumeration 5-307
LED Control Functions 7-4238
LibQ Fixed-Point Math Library 5-1275
libq.h 5-1307
Library Architecture 5-2428, 5-2690, 5-2800, 5-3978, 5-4061,
5-4101, 5-4132
Library Configuration 5-4022, 5-4065, 5-4104, 5-4134
Library Initialization 5-4065, 5-4134
Library Interface 5-204, 5-237, 5-262, 5-291, 5-301, 5-311,
5-326, 5-335, 5-352, 5-377, 5-400, 5-428, 5-482, 5-519, 5-574,
5-609, 5-702, 5-1124, 5-1130, 5-1171, 5-1278, 5-1325, 5-1381,
5-1480, 5-1526, 5-1567, 5-1672, 5-1748, 5-1866, 5-1922,
5-2089, 5-2175, 5-2206, 5-2257, 5-2294, 5-2337, 5-2434,
5-2488, 5-2601, 5-2666, 5-2690, 5-2712, 5-2766, 5-2824,
5-2903, 5-3022, 5-3101, 5-3182, 5-3323, 5-3332, 5-3353,
5-3368, 5-3397, 5-3426, 5-3444, 5-3474, 5-3517, 5-3532,
5-3572, 5-3580, 5-3601, 5-3618, 5-3630, 5-3640, 5-3649,
5-3658, 5-3665, 5-3692, 5-3700, 5-3712, 5-3723, 5-3753,
5-3773, 5-3797, 5-3804, 5-3808, 5-3815, 5-3832, 5-3863,
5-3875, 5-3888, 5-3916, 5-3921, 5-3935, 5-3958, 5-3985,
5-4023, 5-4075, 5-4120, 5-4141, 5-4173, 5-4180, 5-4200,
7-4238
Library Overview 5-194, 5-230, 5-257, 5-290, 5-300, 5-310,
5-321, 5-334, 5-344, 5-369, 5-399, 5-420, 5-459, 5-514, 5-553,
5-607, 5-696, 5-1112, 5-1129, 5-1168, 5-1276, 5-1314, 5-1473,
5-1566, 5-2598, 5-3014, 5-3173, 5-3322, 5-3349, 5-3365,
5-3422, 5-3442, 5-3470, 5-3506, 5-3531, 5-3571, 5-3576,
5-3600, 5-3616, 5-3627, 5-3638, 5-3647, 5-3656, 5-3661,
5-3691, 5-3699, 5-3710, 5-3719, 5-3749, 5-3772, 5-3796,
5-3801, 5-3810, 5-3823, 5-3859, 5-3869, 5-3882, 5-3914,
5-3919, 5-3932, 5-3956, 5-4007, 5-4101, 7-4231, 7-4233,
7-4235, 7-4237
Library Usage Model 5-1366, 5-1670, 5-1736, 5-2088, 5-2204,
5-2254, 5-2333, 5-2480, 5-2665, 5-2706, 5-2895, 5-3088
LIGHTBLUE macro 5-1046
LIGHTCYAN macro 5-1047
LIGHTGRAY macro 5-1047
LIGHTGREEN macro 5-1047
LIGHTMAGENTA macro 5-1047
LIGHTORANGE macro 5-1047
LIGHTRED macro 5-1047
LIGHTYELLOW macro 5-1048
Link Local (Zeroconf) 5-3956
listen function 5-3605
LOCAL_TCP_PORT_END_NUMBER macro 5-3885
LOCAL_TCP_PORT_START_NUMBER macro 5-3885
Low-Cost Controllerless (LCC) Graphics Driver Library 5-299
M
MAC TCP/IP Stack Library 5-3747
MAGENTA macro 5-1048
Main Program Changes 5-684, 5-3555
MAIN_RETURN macro 5-3341
MAIN_RETURN_CODE macro 5-3342
MAIN_RETURN_CODES enumeration 5-3334
Manager TCP/IP Stack Library 5-3770
9 MPLAB Harmony Help
ii
Managing Slave Addresses 5-2082
Master Descriptor Table 5-4012
Master Mode 5-2819
Math Library Help 5-1167
matrix32 structure 5-1265
MAX_ANYCAST_DELAY_TIME macro 5-3802
MAX_BSD_CLIENT_CONNECTIONS macro 5-3601
MAX_BSD_SERVER_CONNECTIONS macro 5-3601
MAX_MULTICAST_SOLICIT macro 5-3802
MAX_NEIGHBOR_ADVERTISEMENT macro 5-3802
MAX_NONBUFFERED_BYTE_COUNT macro 5-393
MAX_RTR_SOLICITATION_DELAY macro 5-3802
MAX_RTR_SOLICITATIONS macro 5-3803
MAX_SMTP_CONNECTIONS macro 5-3814
MAX_TELNET_CONNECTIONS macro 5-3915
MAX_UNICAST_SOLICIT macro 5-3803
MAX16 macro 5-1267
MAX32 macro 5-1267
MC_CRYPTO_API_H macro 5-1164
MCHP_BITMAP_NORMAL macro 5-1048
MCHP_BITMAP_PALETTE_STR macro 5-1048
mDNS 5-3957
MDNSD_ERR_CODE enumeration 5-3961
Media Driver Registration 5-4173
Media Independent Interface (MII) 5-1910
Memory Access Control 5-1524
Memory Operation 5-1322
Messaging Functionality 5-700
Messaging System Service Library 5-3438
Micrium uC_OS_III with Graphics 3-117
Migration Guide 5-3386
MIN16 macro 5-1267
MIN32 macro 5-1267
Miscellaneous 5-3473, 5-3513
Miscellaneous Config 5-480
Miscellaneous Configuration 5-428
Miscellaneous Functions 5-2256
Mode Configuration 5-1557
Module Events 5-1563
More Information 1-20
Mounting a Volume 5-3392
MPFS2 Command Line Options 5-3544
MPFS2 Utility 5-3542
MPLAB Harmony Configurator 2-40
MPLAB Harmony Configurator Help 2-39
MPLAB Harmony Graphics Library Access Changes 5-682
MPLAB Harmony Graphics Library API Changes 5-682
MPLAB Harmony Graphics Library BSP Configuration 5-685
MPLAB Harmony Graphics Library Configuration 5-685
MPLAB Harmony Graphics Library Configuration Changes
5-685
MPLAB Harmony Graphics Library Design 5-682
MPLAB Harmony Graphics Library File Name Compliance 5-686
MPLAB Harmony Graphics Library Function Name Compliance
5-687
MPLAB Harmony Graphics Library Initialization Changes 5-684
MPLAB Harmony Graphics Library Key Features 5-681
MPLAB Harmony Graphics Library Structure 5-681
MPLAB Harmony Graphics Library Utilities 5-685
MPLAB Harmony TCP/IP Stack Access Changes 5-3556
MPLAB Harmony TCP/IP Stack API Changes 5-3548
MPLAB Harmony TCP/IP Stack Configuration 5-3553
MPLAB Harmony TCP/IP Stack Configuration Changes 5-3553
MPLAB Harmony TCP/IP Stack Design 5-3548
MPLAB Harmony TCP/IP Stack Function Name Compliance
5-3558
MPLAB Harmony TCP/IP Stack Heap Configuration 5-3553
MPLAB Harmony TCP/IP Stack Initialization Changes 5-3556
MPLAB Harmony TCP/IP Stack Key Features 5-3546
MPLAB Harmony TCP/IP Stack SSL/RSA Usage 5-3557
MPLAB Harmony TCP/IP Stack Storage Changes 5-3552
MPLAB Harmony TCP/IP Stack Structure 5-3547
MPLAB Harmony TCP/IP Stack Utilities 5-3557
MPLAB Harmony vs. the Unified TCP/IP Stack 5-257
MPLAB Harmony vs. Unified Stack Functions 5-230
MRF24W Wi-Fi Driver Library 5-600
MSD Function Driver Registration 5-4172
msd_basic 3-164, 3-169
mul16 function 5-1263
9 MPLAB Harmony Help
jj
mul16r function 5-1263
mul32 function 5-1263
Multimedia Expansion Board (MEB) 3-96
Multimedia Expansion Board II (MEB II) 3-82, 3-96, 3-107,
3-140, 3-175
Mutex Operation 5-1318
MY_DEFAULT_SNMP_IF macro 5-3826
N
NBNS TCP/IP Stack Library 5-3794
nbns.h 5-3797
nbns_config.h 5-3797
NBNS_MODULE_CONFIG structure 5-3797
NBNS_PORT macro 5-3796
NDP TCP/IP Stack Library 5-3798
ndp.h 5-3805
ndp_config.h 5-3805
NDP_TASK_TIMER_RATE macro 5-3803
NDP_VALID_LIFETIME_TWO_HOURS macro 5-3803
New MPLAB Harmony Graphics Library API Functions 5-684
New MPLAB Harmony TCP/IP Stack API Functions 5-3555
NMI Events Functions 5-2699
nmv_mpfs_single_disk 3-73
Non-Volatile Memory (NVM) Driver Library 5-342
NOTIFY_COMMUNITY_LEN macro 5-3827
NTP_DEFAULT_CONNECTION_TYPE macro 5-3860
NTP_DEFAULT_IF macro 5-3861
NTP_EPOCH macro 5-3861
NTP_FAST_QUERY_INTERVAL macro 5-3861
NTP_MAX_RETRIES macro 5-3861
NTP_MAX_STRATUM macro 5-3861
NTP_QUERY_INTERVAL macro 5-3861
NTP_REPLY_TIMEOUT macro 5-3862
NTP_SERVER macro 5-3862
NTP_SERVER_PORT macro 5-3862
NTP_TIME_STAMP_TMO macro 5-3862
NTP_VERSION macro 5-3862
NUM_ALPHA_LEVELS macro 5-294
NVM Driver Demonstration 3-102
NVM Peripheral Library 5-2252
nvm_fat_single_disk 3-66
nvm_sdcard_fat_mpfs_multi_disk 3-75
nvm_sdcard_fat_multi_disk 3-71
O
Object Initialization 5-4171
object_demo 3-88
Objects Functionality 5-697
OC_16BIT_TIMERS enumeration 5-2312
OC_BUFFER_SIZE enumeration 5-2312
OC_CLOCK_RESOLUTION enumeration 5-2312
OC_COMPARE_MODES enumeration 5-2313
OC_FAULT_MODES enumeration 5-2314
OC_FAULT_OUT enumeration 5-2314
OC_FAULT_TRISTATE enumeration 5-2315
OC_FAULTS enumeration 5-2315
OC_MODULE_ID enumeration 5-2315
OC_SYNC_MODES enumeration 5-2316
OC_SYNC_SOURCES enumeration 5-2316
OC_TRIGGER_STATUS_MODES enumeration 5-2318
OID_MAX_LEN macro 5-3827
One Shot Callback 5-3510
ONEP25 macro 5-1048
Opening a File 5-3393
Opening the Driver 5-556
Operating as a Master 5-2483
Operating as a Master Receiver 5-2070
Operating as a Master Transmitter 5-2065
Operating as a Slave 5-2484
Operating as a Slave Receiver 5-2062
Operating as a Slave Transmitter 5-2063
Operating System Abstraction Layer (OSAL) Library Help
5-1311
Operating/Addressing Mode Management 5-1739
Optional Interfaces 5-467
ORANGE macro 5-1048
OSAL Operation 5-1322
osal.c 5-1325
9 MPLAB Harmony Help
kk
osal.h 5-1358
OSAL_CRIT_Enter function 5-1349
OSAL_CRIT_Leave function 5-1349
OSAL_CRIT_TYPE enumeration 5-1350
OSAL_CRIT_TYPE_HIGH enumeration member 5-1350
OSAL_CRIT_TYPE_LOW enumeration member 5-1350
OSAL_ERROR_CALLBACK_DEFAULT enumeration member
5-1352
OSAL_ERROR_CALLBACK_ERROR enumeration member
5-1352
OSAL_ERROR_CALLBACK_OUT_OF_MEMORY enumeration
member 5-1352
OSAL_ERROR_CALLBACK_STACK_OVERFLOW
enumeration member 5-1352
OSAL_ERROR_CALLBACK_TYPE enumeration 5-1352
OSAL_ErrorCallback function 5-1352
OSAL_Free function 5-1353
OSAL_Initialize function 5-1355
OSAL_ISR_Enter function 5-1351
OSAL_ISR_Exit function 5-1351
OSAL_Malloc function 5-1354
OSAL_MUTEX_Create function 5-1338
OSAL_MUTEX_DECLARE macro 5-1340
OSAL_MUTEX_Delete function 5-1338
OSAL_MUTEX_HANDLE_TYPE macro 5-1356
OSAL_MUTEX_Lock function 5-1339
OSAL_MUTEX_Unlock function 5-1340
OSAL_Name function 5-1355
OSAL_QUEUE_Add function 5-1341
OSAL_QUEUE_AddHead function 5-1342
OSAL_QUEUE_AddHeadISR function 5-1342
OSAL_QUEUE_AddISR function 5-1343
OSAL_QUEUE_Create function 5-1344
OSAL_QUEUE_DECLARE macro 5-1341
OSAL_QUEUE_Delete function 5-1345
OSAL_QUEUE_HANDLE_TYPE macro 5-1356
OSAL_QUEUE_Peek function 5-1345
OSAL_QUEUE_PeekISR function 5-1346
OSAL_QUEUE_Remove function 5-1347
OSAL_QUEUE_RemoveISR function 5-1348
OSAL_RESULT enumeration 5-1357
OSAL_RESULT_FALSE enumeration member 5-1357
OSAL_RESULT_NOT_IMPLEMENTED enumeration member
5-1357
OSAL_RESULT_TRUE enumeration member 5-1357
OSAL_SEM_Create function 5-1333
OSAL_SEM_DECLARE macro 5-1337
OSAL_SEM_Delete function 5-1334
OSAL_SEM_GetCount function 5-1334
OSAL_SEM_HANDLE_TYPE macro 5-1356
OSAL_SEM_Pend function 5-1335
OSAL_SEM_Post function 5-1336
OSAL_SEM_PostISR function 5-1336
OSAL_SEM_TYPE enumeration 5-1357
OSAL_SEM_TYPE_BINARY enumeration member 5-1357
OSAL_SEM_TYPE_COUNTING enumeration member 5-1357
OSAL_Start function 5-1356
OSAL_THREAD_Create function 5-1327
OSAL_THREAD_CreateDaemon function 5-1328
OSAL_THREAD_FUNCTION type 5-1327
OSAL_THREAD_HANDLE_TYPE macro 5-1357
OSAL_THREAD_PriorityGet function 5-1329
OSAL_THREAD_PrioritySet function 5-1330
OSAL_THREAD_Resume function 5-1330
OSAL_THREAD_ResumeAll function 5-1331
OSAL_THREAD_Sleep function 5-1331
OSAL_THREAD_Suspend function 5-1332
OSAL_THREAD_SuspendAll function 5-1333
OSAL_USE_NONE macro 5-1357
OSAL_WAIT_FOREVER macro 5-1357
OSC_AUX_CLOCK_SOURCE enumeration 5-2394
OSC_AUX_MODE enumeration 5-2394
OSC_AUXPLL_IN_DIV enumeration 5-2394
OSC_AUXPLL_MULTIPLIER enumeration 5-2395
OSC_AUXPLL_OUT_DIV enumeration 5-2395
OSC_DOZE_RATIO enumeration 5-2396
OSC_FRC_DIV enumeration 5-2396
OSC_FRC_TUNE enumeration 5-2397
OSC_GFX_CLOCK enumeration 5-2398
OSC_LFSR_TYPE enumeration 5-2398
OSC_MODULE_ID enumeration 5-2399
9 MPLAB Harmony Help
ll
OSC_OPERATION_ON_WAIT enumeration 5-2399
OSC_PB_CLOCK_DIV_TYPE macro 5-2393
OSC_PERIPHERAL_BUS enumeration 5-2399
OSC_PLL_SELECT enumeration 5-2400
OSC_PLLAUX_CLOCK_SOURCE enumeration 5-2400
OSC_REF_BASECLOCK enumeration 5-2401
OSC_REF_DIV enumeration 5-2401
OSC_REF_DIVISOR_TYPE macro 5-2393
OSC_REFERENCE enumeration 5-2402
OSC_REFERENCE_MAX_DIV macro 5-2393
OSC_SYS_CLOCK_DIV enumeration 5-2403
OSC_SYS_TYPE enumeration 5-2403
OSC_SYSPLL_FREQ_RANGE enumeration 5-2404
OSC_SYSPLL_IN_CLK_SOURCE enumeration 5-2404
OSC_SYSPLL_IN_DIV enumeration 5-2405
OSC_SYSPLL_MULTIPLIER_TYPE macro 5-2393
OSC_SYSPLL_OUT_DIV enumeration 5-2405
OSC_TUNING_MODE enumeration 5-2406
OSC_TUNING_SEQUENCERS enumeration 5-2406
OSC_USBCLOCK_SOURCE enumeration 5-2407
Oscillator Peripheral Library 5-2330
Oscillator Selection and Switching 5-2333
Oscillator Tuning 5-3351
Other Features 5-2086, 5-2487, 5-2822, 5-3020, 5-3099
Other Functionality 5-608, 5-1316, 5-2711
Other Functions 7-4240
Others 5-574, 5-609, 5-1324, 5-3366
OTM2201A Graphics Controller Driver Library 5-309
OTM2201A_TASK enumeration 5-318
Output Compare Peripheral Library 5-2287
Overview 3-65
P
PA6_IO macro 5-673
PA6_TRISTATE macro 5-674
PAGE_TYPE enumeration 5-294
PALETTE_ENTRY union 5-938
PALETTE_EXTERNAL type 5-938
PALETTE_FLASH structure 5-938
PALETTE_HEADER structure 5-939
PaletteInit function 5-876
Parallel Master Port (PMP) Driver Library 5-367
PARM_EQUAL_FILTER structure 5-1265
PARM_EQUAL_FILTER_16 structure 5-1266
PARM_EQUAL_FILTER_32 structure 5-1266
PARM_FILTER_GAIN structure 5-1267
PCACHE_MODULE_ID enumeration 5-2463
Percentage2Alpha function 5-291
Period Modification 5-464
Periodic Callback 5-3509
Peripheral Libraries 4-182
Peripheral Library Example Applications 3-98
Peripheral Library Help 5-1361
Peripheral Pin Select 5-3473
PERU macro 5-1049
PGV Error Handling 5-2765
PHY_NEG_DONE_TMO macro 5-261
PHY_NEG_INIT_TMO macro 5-262
PHY_RESET_CLR_TMO macro 5-262
PIC32 Ethernet Starter Kit 3-136
PIC32 USB Digital Audio Accessory Board 3-173
PIC32 USB Starter Kit II 3-77, 3-91, 3-104, 3-118, 3-170
PIC32 USB Starter Kit II BSP Library 7-4232
pic32_ethernet_starter_kit 3-131
PIC32MX USB Audio BSP Library 7-4234
PIC32MX795F512 Plug-In-Module (PIM) 3-79
PIC32MX795F512L Plug-in Module (PIM) 3-105, 3-125, 3-144
PIC32MX795F512L Plug-In-Module (PIM) 3-96, 3-173
PIC32MZ Embedded Connectivity (EC) Starter Kit 3-80, 3-92,
3-106, 3-119, 3-137, 3-173
PIC32MZ Embedded Connectivity (EC) Starter Kit BSP Library
7-4236
PICtail Daughter Board for SD and MMC 3-80
PICtail Plus LCC Daughter Board 3-95
PICtail Plus S1D13517 Daughter Board 3-95
PICtail Plus SSD1926 Daughter Board 3-95
Pin Control 5-3470
PIO Mode 5-2900
PIP_BUFFER macro 5-307
9 MPLAB Harmony Help
mm
Pipe Close 5-560
Pipe Setup 5-558
Pipe Stall 5-561
Pipe Status 5-559
Pipe Transfer Queue 5-560
plib_adc.h 5-1467
PLIB_ADC_AsynchronousDedicatedSamplingDisable function
5-1417
PLIB_ADC_AsynchronousDedicatedSamplingEnable function
5-1417
PLIB_ADC_CalibrationDisable function 5-1389
PLIB_ADC_CalibrationEnable function 5-1388
PLIB_ADC_ChannelGroupSelect function 5-1393
PLIB_ADC_ConversionClockGet function 5-1402
PLIB_ADC_ConversionClockSet function 5-1402
PLIB_ADC_ConversionClockSourceSelect function 5-1403
PLIB_ADC_ConversionHasCompleted function 5-1400
PLIB_ADC_ConversionOrderSelect function 5-1404
PLIB_ADC_ConversionStart function 5-1399
PLIB_ADC_ConversionStopSequenceDisable function 5-1401
PLIB_ADC_ConversionStopSequenceEnable function 5-1401
PLIB_ADC_ConversionTriggerGroupSelect function 5-1404
PLIB_ADC_ConversionTriggerSourceSelect function 5-1400
PLIB_ADC_Disable function 5-1386
PLIB_ADC_DMAAddressIncrementSelect function 5-1405
PLIB_ADC_DMABufferModeSelect function 5-1405
PLIB_ADC_DMADisable function 5-1406
PLIB_ADC_DMAEnable function 5-1406
PLIB_ADC_DMAInputBufferSelect function 5-1407
PLIB_ADC_Enable function 5-1385
PLIB_ADC_ExistsAsynchronousDedicatedSampling function
5-1439
PLIB_ADC_ExistsCalibrationControl function 5-1439
PLIB_ADC_ExistsChannelGroup function 5-1440
PLIB_ADC_ExistsConversionClock function 5-1440
PLIB_ADC_ExistsConversionClockSource function 5-1441
PLIB_ADC_ExistsConversionControl function 5-1441
PLIB_ADC_ExistsConversionOrder function 5-1442
PLIB_ADC_ExistsConversionStatus function 5-1442
PLIB_ADC_ExistsConversionStopSequenceControl function
5-1443
PLIB_ADC_ExistsConversionTriggerGroup function 5-1443
PLIB_ADC_ExistsConversionTriggerSource function 5-1444
PLIB_ADC_ExistsDMAAddressIncrement function 5-1444
PLIB_ADC_ExistsDMABufferMode function 5-1445
PLIB_ADC_ExistsDMABuffersPerAnalogInput function 5-1445
PLIB_ADC_ExistsDMAControl function 5-1446
PLIB_ADC_ExistsEnableControl function 5-1446
PLIB_ADC_ExistsGlobalSoftwareTrigger function 5-1447
PLIB_ADC_ExistsInputSelect function 5-1447
PLIB_ADC_ExistsInternalReferenceChannelControl function
5-1448
PLIB_ADC_ExistsISRJumpTableBaseAddress function 5-1448
PLIB_ADC_ExistsMuxChannel0NegativeInput function 5-1449
PLIB_ADC_ExistsMuxChannel0PositiveInput function 5-1449
PLIB_ADC_ExistsMuxChannel123NegativeInput function
5-1450
PLIB_ADC_ExistsMuxChannel123PositiveInput function 5-1450
PLIB_ADC_ExistsMuxInputScanControl function 5-1451
PLIB_ADC_ExistsMuxInputScanSelect function 5-1451
PLIB_ADC_ExistsPairConversionControl function 5-1452
PLIB_ADC_ExistsPairInterruptOnConversion function 5-1453
PLIB_ADC_ExistsPairInterruptRequest function 5-1453
PLIB_ADC_ExistsPairSampleStatus function 5-1454
PLIB_ADC_ExistsPairTriggerSource function 5-1454
PLIB_ADC_ExistsResultBufferFillStatus function 5-1455
PLIB_ADC_ExistsResultBufferMode function 5-1455
PLIB_ADC_ExistsResultFormat function 5-1456
PLIB_ADC_ExistsResultGet function 5-1456
PLIB_ADC_ExistsResultGetByIndex function 5-1457
PLIB_ADC_ExistsResultSign function 5-1457
PLIB_ADC_ExistsResultSize function 5-1458
PLIB_ADC_ExistsSampleResolution function 5-1458
PLIB_ADC_ExistsSamplesPerInterruptSelect function 5-1459
PLIB_ADC_ExistsSamplingAcquisitionTime function 5-1459
PLIB_ADC_ExistsSamplingAutoStart function 5-1460
PLIB_ADC_ExistsSamplingControl function 5-1460
PLIB_ADC_ExistsSamplingModeControl function 5-1461
PLIB_ADC_ExistsSamplingStatus function 5-1461
PLIB_ADC_ExistsStopInIdleControl function 5-1462
PLIB_ADC_ExistsVoltageReference function 5-1462
9 MPLAB Harmony Help
nn
PLIB_ADC_GlobalSoftwareTriggerSet function 5-1418
PLIB_ADC_InputScanMaskAdd function 5-1390
PLIB_ADC_InputScanMaskRemove function 5-1391
PLIB_ADC_InputSelectNegative function 5-1390
PLIB_ADC_InputSelectPositive function 5-1389
PLIB_ADC_InternalReferenceChannelDisable function 5-1392
PLIB_ADC_InternalReferenceChannelEnable function 5-1392
PLIB_ADC_IsrJumpTableBaseAddressGet function 5-1419
PLIB_ADC_IsrJumpTableBaseAddressSet function 5-1419
PLIB_ADC_MuxAInputScanDisable function 5-1463
PLIB_ADC_MuxAInputScanEnable function 5-1463
PLIB_ADC_MuxChannel0InputNegativeSelect function 5-1464
PLIB_ADC_MuxChannel0InputPositiveSelect function 5-1465
PLIB_ADC_MuxChannel123InputNegativeSelect function
5-1465
PLIB_ADC_MuxChannel123InputPositiveSelect function 5-1466
PLIB_ADC_PairConversionIsPending function 5-1408
PLIB_ADC_PairConversionStart function 5-1408
PLIB_ADC_PairInterruptAfterFirstConversion function 5-1409
PLIB_ADC_PairInterruptAfterSecondConversion function 5-1409
PLIB_ADC_PairInterruptRequestDisable function 5-1410
PLIB_ADC_PairInterruptRequestEnable function 5-1410
PLIB_ADC_PairSampleIsAvailable function 5-1411
PLIB_ADC_PairSampleStatusClear function 5-1412
PLIB_ADC_PairTriggerSourceSelect function 5-1412
PLIB_ADC_ResultBufferModeSelect function 5-1413
PLIB_ADC_ResultBufferStatusGet function 5-1413
PLIB_ADC_ResultFormatSelect function 5-1414
PLIB_ADC_ResultGet function 5-1415
PLIB_ADC_ResultGetByIndex function 5-1415
PLIB_ADC_ResultSignGet function 5-1416
PLIB_ADC_ResultSizeSelect function 5-1416
PLIB_ADC_SampleAcqusitionTimeSet function 5-1394
PLIB_ADC_SampleAutoStartDisable function 5-1394
PLIB_ADC_SampleAutoStartEnable function 5-1395
PLIB_ADC_SampleMaxGet function 5-1395
PLIB_ADC_SampleMinGet function 5-1396
PLIB_ADC_SamplesPerInterruptSelect function 5-1396
PLIB_ADC_SamplingIsActive function 5-1397
PLIB_ADC_SamplingModeSelect function 5-1397
PLIB_ADC_SamplingStart function 5-1398
PLIB_ADC_SamplingStop function 5-1399
PLIB_ADC_StopInIdleDisable function 5-1386
PLIB_ADC_StopInIdleEnable function 5-1387
PLIB_ADC_VoltageReferenceSelect function 5-1387
plib_adcp.h 5-1518
PLIB_ADCP_AlternateInputSelect function 5-1489
PLIB_ADCP_CalibrationStart function 5-1484
PLIB_ADCP_ChannelScanConfigure function 5-1492
PLIB_ADCP_Class12TriggerConfigure function 5-1495
PLIB_ADCP_Configure function 5-1482
PLIB_ADCP_DefaultInputSelect function 5-1490
PLIB_ADCP_DigCmpAIdGet function 5-1500
PLIB_ADCP_DigCmpConfig function 5-1500
PLIB_ADCP_DigCmpDisable function 5-1499
PLIB_ADCP_DigCmpEnable function 5-1499
PLIB_ADCP_Disable function 5-1483
PLIB_ADCP_Enable function 5-1483
PLIB_ADCP_ExistsCalibration function 5-1486
PLIB_ADCP_ExistsChannelScan function 5-1493
PLIB_ADCP_ExistsConfiguration function 5-1488
PLIB_ADCP_ExistsConversionResults function 5-1498
PLIB_ADCP_ExistsDigCmp function 5-1502
PLIB_ADCP_ExistsEnableControl function 5-1486
PLIB_ADCP_ExistsInputSelect function 5-1491
PLIB_ADCP_ExistsLowPowerControl function 5-1487
PLIB_ADCP_ExistsModeSelect function 5-1491
PLIB_ADCP_ExistsOsampDigFilter function 5-1505
PLIB_ADCP_ExistsReadyStatus function 5-1489
PLIB_ADCP_ExistsTriggering function 5-1495
PLIB_ADCP_GlobalSoftwareTrigger function 5-1494
PLIB_ADCP_IndividualTrigger function 5-1494
PLIB_ADCP_LowPowerStateEnter function 5-1484
PLIB_ADCP_LowPowerStateExit function 5-1485
PLIB_ADCP_LowPowerStateGet function 5-1485
PLIB_ADCP_ModuleIsReady function 5-1488
PLIB_ADCP_OsampDigFilterConfig function 5-1505
PLIB_ADCP_OsampDigFilterDataGet function 5-1504
PLIB_ADCP_OsampDigFilterDataRdy function 5-1503
9 MPLAB Harmony Help
oo
PLIB_ADCP_OsampDigFilterDisable function 5-1503
PLIB_ADCP_OsampDigFilterEnable function 5-1502
PLIB_ADCP_ResultGet function 5-1497
PLIB_ADCP_ResultReady function 5-1496
PLIB_ADCP_ResultReadyGrpIntConfigure function 5-1497
PLIB_ADCP_SHModeSelect function 5-1492
plib_bmx.h 5-1552
PLIB_BMX_ARB_MODE enumeration 5-1543
PLIB_BMX_ArbitrationModeGet function 5-1535
PLIB_BMX_ArbitrationModeSet function 5-1535
PLIB_BMX_BusExceptionDataDisable function 5-1528
PLIB_BMX_BusExceptionDataEnable function 5-1529
PLIB_BMX_BusExceptionDMADisable function 5-1529
PLIB_BMX_BusExceptionDMAEnable function 5-1530
PLIB_BMX_BusExceptionICDDisable function 5-1530
PLIB_BMX_BusExceptionICDEnable function 5-1531
PLIB_BMX_BusExceptionInstructionDisable function 5-1531
PLIB_BMX_BusExceptionInstructionEnable function 5-1532
PLIB_BMX_BusExceptionIXIDisable function 5-1532
PLIB_BMX_BusExceptionIXIEnable function 5-1533
PLIB_BMX_DATA_RAM_WAIT_STATES enumeration 5-1543
PLIB_BMX_DataRAMKernelProgramOffsetGet function 5-1536
PLIB_BMX_DataRAMPartitionSet function 5-1536
PLIB_BMX_DataRAMSizeGet function 5-1537
PLIB_BMX_DataRAMUserDataOffsetGet function 5-1538
PLIB_BMX_DataRAMUserProgramOffsetGet function 5-1538
PLIB_BMX_DataRamWaitStateGet function 5-1539
PLIB_BMX_DataRamWaitStateSet function 5-1540
PLIB_BMX_DRM_BLOCK_SIZE macro 5-1544
PLIB_BMX_EXCEPTION_SRC enumeration 5-1544
PLIB_BMX_ExistsArbitrationMode function 5-1545
PLIB_BMX_ExistsBusExceptionData function 5-1545
PLIB_BMX_ExistsBusExceptionDMA function 5-1546
PLIB_BMX_ExistsBusExceptionICD function 5-1546
PLIB_BMX_ExistsBusExceptionInstruction function 5-1547
PLIB_BMX_ExistsBusExceptionIXI function 5-1547
PLIB_BMX_ExistsDataRAMPartition function 5-1548
PLIB_BMX_ExistsDataRAMSize function 5-1548
PLIB_BMX_ExistsDataRamWaitState function 5-1549
PLIB_BMX_ExistsProgramFlashBootSize function 5-1549
PLIB_BMX_ExistsProgramFlashMemoryCacheDma function
5-1550
PLIB_BMX_ExistsProgramFlashMemorySize function 5-1550
PLIB_BMX_ExistsProgramFlashPartition function 5-1551
PLIB_BMX_PFM_BLOCK_SIZE macro 5-1544
PLIB_BMX_ProgramFlashBootSizeGet function 5-1540
PLIB_BMX_ProgramFlashMemoryCacheDmaDisable function
5-1533
PLIB_BMX_ProgramFlashMemoryCacheDmaEnable function
5-1534
PLIB_BMX_ProgramFlashMemorySizeGet function 5-1541
PLIB_BMX_ProgramFlashPartitionGet function 5-1541
PLIB_BMX_ProgramFlashPartitionSet function 5-1542
plib_can.h 5-1662
PLIB_CAN_AllChannelEventsGet function 5-1595
PLIB_CAN_AllChannelOverflowStatusGet function 5-1596
PLIB_CAN_BusActivityWakeupDisable function 5-1572
PLIB_CAN_BusActivityWakeupEnable function 5-1572
PLIB_CAN_BusLine3TimesSamplingDisable function 5-1583
PLIB_CAN_BusLine3TimesSamplingEnable function 5-1584
PLIB_CAN_ChannelEventClear function 5-1597
PLIB_CAN_ChannelEventDisable function 5-1592
PLIB_CAN_ChannelEventEnable function 5-1598
PLIB_CAN_ChannelEventGet function 5-1599
PLIB_CAN_ChannelForReceiveSet function 5-1589
PLIB_CAN_ChannelForTransmitSet function 5-1590
PLIB_CAN_ChannelReset function 5-1590
PLIB_CAN_ChannelResetIsComplete function 5-1579
PLIB_CAN_ChannelUpdate function 5-1591
PLIB_CAN_DeviceNetConfigure function 5-1579
PLIB_CAN_Disable function 5-1573
PLIB_CAN_Enable function 5-1574
PLIB_CAN_ErrorStateGet function 5-1617
PLIB_CAN_ExistsActiveStatus function 5-1636
PLIB_CAN_ExistsAllChannelEvents function 5-1637
PLIB_CAN_ExistsAllChannelOverflow function 5-1637
PLIB_CAN_ExistsBusActivityWakeup function 5-1638
PLIB_CAN_ExistsBusLine3TimesSampling function 5-1638
PLIB_CAN_ExistsChannelEvent function 5-1639
9 MPLAB Harmony Help
pp
PLIB_CAN_ExistsChannelEventEnable function 5-1639
PLIB_CAN_ExistsChannelForReceiveSet function 5-1640
PLIB_CAN_ExistsChannelForTransmitSet function 5-1640
PLIB_CAN_ExistsChannelReset function 5-1641
PLIB_CAN_ExistsChannelUpdate function 5-1641
PLIB_CAN_ExistsDeviceNet function 5-1642
PLIB_CAN_ExistsEnableControl function 5-1642
PLIB_CAN_ExistsErrorState function 5-1643
PLIB_CAN_ExistsFilterConfigure function 5-1643
PLIB_CAN_ExistsFilterEnable function 5-1644
PLIB_CAN_ExistsFilterMaskConfigure function 5-1644
PLIB_CAN_ExistsFilterToChannelLink function 5-1645
PLIB_CAN_ExistsFunctionalMode function 5-1645
PLIB_CAN_ExistsLatestFilterMatchGet function 5-1646
PLIB_CAN_ExistsMemoryBufferAssign function 5-1646
PLIB_CAN_ExistsMessageIsReceived function 5-1647
PLIB_CAN_ExistsModuleEventClear function 5-1647
PLIB_CAN_ExistsModuleEventEnable function 5-1648
PLIB_CAN_ExistsModuleInfo function 5-1648
PLIB_CAN_ExistsOperationModeRead function 5-1649
PLIB_CAN_ExistsOperationModeWrite function 5-1649
PLIB_CAN_ExistsPendingEventsGet function 5-1650
PLIB_CAN_ExistsPendingTransmissionsAbort function 5-1650
PLIB_CAN_ExistsPhaseSegment1Length function 5-1651
PLIB_CAN_ExistsPhaseSegment2Length function 5-1651
PLIB_CAN_ExistsPhaseSegment2LengthFreelyProgrammable
function 5-1652
PLIB_CAN_ExistsPropagationTimeSegment function 5-1652
PLIB_CAN_ExistsReceiveBufferClear function 5-1653
PLIB_CAN_ExistsReceiveBufferIsEmpty function 5-1653
PLIB_CAN_ExistsReceivedMessageGet function 5-1654
PLIB_CAN_ExistsReceiveErrorCount function 5-1654
PLIB_CAN_ExistsReceiveModeSelect function 5-1655
PLIB_CAN_ExistsRemoteTransmitReq function 5-1655
PLIB_CAN_ExistsRxFIFOFourLeftNotify function 5-1656
PLIB_CAN_ExistsRxFIFOOneLeftNotify function 5-1656
PLIB_CAN_ExistsStopInIdle function 5-1657
PLIB_CAN_ExistsSyncJumpWidthSet function 5-1657
PLIB_CAN_ExistsTimeStampEnable function 5-1658
PLIB_CAN_ExistsTimeStampPrescalar function 5-1658
PLIB_CAN_ExistsTimeStampValue function 5-1659
PLIB_CAN_ExistsTransmissionIsAborted function 5-1660
PLIB_CAN_ExistsTransmitBufferGet function 5-1660
PLIB_CAN_ExistsTransmitChannelFlush function 5-1661
PLIB_CAN_ExistsTransmitChannelStatus function 5-1661
PLIB_CAN_ExistsTransmitErrorCountGet function 5-1662
PLIB_CAN_FilterConfigure function 5-1612
PLIB_CAN_FilterDisable function 5-1612
PLIB_CAN_FilterEnable function 5-1613
PLIB_CAN_FilterIsDisabled function 5-1614
PLIB_CAN_FilterMaskConfigure function 5-1614
PLIB_CAN_FilterToChannelLink function 5-1615
PLIB_CAN_FunctionalModeGet function 5-1580
PLIB_CAN_FunctionalModeSelect function 5-1583
PLIB_CAN_IsActive function 5-1574
PLIB_CAN_LatestFilterMatchGet function 5-1616
PLIB_CAN_MemoryBufferAssign function 5-1580
PLIB_CAN_MessageIsReceived function 5-1609
PLIB_CAN_ModuleEventClear function 5-1593
PLIB_CAN_ModuleEventDisable function 5-1593
PLIB_CAN_ModuleEventEnable function 5-1594
PLIB_CAN_ModuleEventGet function 5-1595
PLIB_CAN_OperationModeGet function 5-1575
PLIB_CAN_OperationModeSelect function 5-1576
PLIB_CAN_PendingEventsGet function 5-1600
PLIB_CAN_PendingTransmissionsAbort function 5-1601
PLIB_CAN_PhaseSegment1LengthSet function 5-1585
PLIB_CAN_PhaseSegment2LengthFreelyProgrammableDisable
function 5-1586
PLIB_CAN_PhaseSegment2LengthFreelyProgrammableEnable
function 5-1586
PLIB_CAN_PhaseSegment2LengthSet function 5-1587
PLIB_CAN_PropagationTimeSegmentSet function 5-1588
PLIB_CAN_ReceiveBufferClear function 5-1610
PLIB_CAN_ReceiveBufferIsEmpty function 5-1610
PLIB_CAN_ReceivedMessageGet function 5-1605
PLIB_CAN_ReceiveErrorCountGet function 5-1616
PLIB_CAN_ReceiveModeGet function 5-1608
PLIB_CAN_ReceiveModeSelect function 5-1608
9 MPLAB Harmony Help
qq
PLIB_CAN_RemoteTransmitReqIsReceived function 5-1611
PLIB_CAN_RxFIFOFourLeftNotify function 5-1607
PLIB_CAN_RxFIFOOneLeftNotify function 5-1607
PLIB_CAN_StopInIdleDisable function 5-1576
PLIB_CAN_StopInIdleEnable function 5-1577
PLIB_CAN_SyncJumpWidthSet function 5-1588
PLIB_CAN_TimeStampDisable function 5-1577
PLIB_CAN_TimeStampEnable function 5-1578
PLIB_CAN_TimeStampPrescalarSet function 5-1581
PLIB_CAN_TimeStampValueGet function 5-1582
PLIB_CAN_TimeStampValueSet function 5-1582
PLIB_CAN_TotalChannelsGet function 5-1618
PLIB_CAN_TotalFiltersGet function 5-1618
PLIB_CAN_TotalMasksGet function 5-1619
PLIB_CAN_TransmissionIsAborted function 5-1601
PLIB_CAN_TransmitBufferGet function 5-1602
PLIB_CAN_TransmitChannelFlush function 5-1603
PLIB_CAN_TransmitChannelStatusGet function 5-1604
PLIB_CAN_TransmitErrorCountGet function 5-1605
plib_cmp.h 5-1730
PLIB_CMP_AndGateAInputDisable function 5-1696
PLIB_CMP_AndGateAInputEnable function 5-1697
PLIB_CMP_AndGateBInputDisable function 5-1697
PLIB_CMP_AndGateBInputEnable function 5-1698
PLIB_CMP_AndGateCInputDisable function 5-1704
PLIB_CMP_AndGateCInputEnable function 5-1698
PLIB_CMP_AndGateInvertedAInputDisable function 5-1699
PLIB_CMP_AndGateInvertedAInputEnable function 5-1699
PLIB_CMP_AndGateInvertedBInputDisable function 5-1700
PLIB_CMP_AndGateInvertedBInputEnable function 5-1700
PLIB_CMP_AndGateInvertedCInputDisable function 5-1701
PLIB_CMP_AndGateInvertedCInputEnable function 5-1701
PLIB_CMP_Cmp1OutputHighSelect function 5-1690
PLIB_CMP_Cmp1OutputLowSelect function 5-1690
PLIB_CMP_Cmp2OutputHighSelect function 5-1691
PLIB_CMP_Cmp2OutputLowSelect function 5-1691
PLIB_CMP_CVREF_BandGapReferenceSourceSelect function
5-1676
PLIB_CMP_CVREF_Disable function 5-1689
PLIB_CMP_CVREF_Enable function 5-1676
PLIB_CMP_CVREF_Output2Disable function 5-1677
PLIB_CMP_CVREF_Output2Enable function 5-1677
PLIB_CMP_CVREF_OutputDisable function 5-1678
PLIB_CMP_CVREF_OutputEnable function 5-1678
PLIB_CMP_CVREF_ReferenceVoltageSelect function 5-1679
PLIB_CMP_CVREF_SourceNegativeInputSelect function
5-1679
PLIB_CMP_CVREF_SourceVoltageSelect function 5-1680
PLIB_CMP_CVREF_ValueGet function 5-1680
PLIB_CMP_CVREF_ValueSelect function 5-1681
PLIB_CMP_CVREF_WideRangeDisable function 5-1681
PLIB_CMP_CVREF_WideRangeEnable function 5-1682
PLIB_CMP_CVREF_WideRangeIsEnabled function 5-1682
PLIB_CMP_Disable function 5-1683
PLIB_CMP_Enable function 5-1683
PLIB_CMP_EventHasOccurred function 5-1684
PLIB_CMP_EventStatusClear function 5-1684
PLIB_CMP_ExistsCVREFBGRefVoltageRangeSelect function
5-1722
PLIB_CMP_ExistsCVREFEnableControl function 5-1723
PLIB_CMP_ExistsCVREFOutputEnableControl function 5-1723
PLIB_CMP_ExistsCVREFRefVoltageRangeSelect function
5-1724
PLIB_CMP_ExistsCVREFValueSelect function 5-1724
PLIB_CMP_ExistsCVREFVoltageRangeSelect function 5-1725
PLIB_CMP_ExistsCVREFWideRangeControl function 5-1725
PLIB_CMP_ExistsEnableControl function 5-1726
PLIB_CMP_ExistsInterruptEventSelect function 5-1727
PLIB_CMP_ExistsInvertingInputSelect function 5-1727
PLIB_CMP_ExistsInvertOutputControl function 5-1728
PLIB_CMP_ExistsNonInvertingInputSelect function 5-1728
PLIB_CMP_ExistsOutputEnableControl function 5-1729
PLIB_CMP_ExistsOutputLevelControl function 5-1729
PLIB_CMP_ExistsStopInIdle function 5-1730
PLIB_CMP_FilterClockDivideSelect function 5-1704
PLIB_CMP_FilterDisable function 5-1705
PLIB_CMP_FilterEnable function 5-1705
PLIB_CMP_FilterInputClockSelect function 5-1706
PLIB_CMP_HighLevelMaskSelect function 5-1715
PLIB_CMP_HysteresisDisable function 5-1692
9 MPLAB Harmony Help
rr
PLIB_CMP_HysteresisEnable function 5-1692
PLIB_CMP_InterruptEventSelect function 5-1685
PLIB_CMP_InvertedOutputSelect function 5-1686
PLIB_CMP_InvertingInputChannelSelect function 5-1686
PLIB_CMP_LowLevelMaskSelect function 5-1715
PLIB_CMP_NegativeAndGateOutputDisable function 5-1702
PLIB_CMP_NegativeAndGateOutputEnable function 5-1702
PLIB_CMP_NonInvertedOutputSelect function 5-1687
PLIB_CMP_NonInvertingInputChannelSelect function 5-1687
PLIB_CMP_OpAmpModeDisable function 5-1706
PLIB_CMP_OpAmpModeEnable function 5-1707
PLIB_CMP_OpAmpOutputDisable function 5-1707
PLIB_CMP_OpAmpOutputEnable function 5-1708
PLIB_CMP_OrGateAInputDisable function 5-1708
PLIB_CMP_OrGateAInputEnable function 5-1709
PLIB_CMP_OrGateBInputDisable function 5-1709
PLIB_CMP_OrGateBInputEnable function 5-1710
PLIB_CMP_OrGateCInputDisable function 5-1710
PLIB_CMP_OrGateCInputEnable function 5-1711
PLIB_CMP_OrGateInvertedAInputDisable function 5-1711
PLIB_CMP_OrGateInvertedAInputEnable function 5-1712
PLIB_CMP_OrGateInvertedBInputDisable function 5-1712
PLIB_CMP_OrGateInvertedBInputEnable function 5-1713
PLIB_CMP_OrGateInvertedCInputDisable function 5-1713
PLIB_CMP_OrGateInvertedCInputEnable function 5-1714
PLIB_CMP_OutputDisable function 5-1688
PLIB_CMP_OutputEnable function 5-1688
PLIB_CMP_OutputHighSelect function 5-1693
PLIB_CMP_OutputLowSelect function 5-1693
PLIB_CMP_OutputStatusGet function 5-1689
PLIB_CMP_OutputSynchronousWithTimer1Disable function
5-1694
PLIB_CMP_OutputSynchronousWithTimer1Enable function
5-1694
PLIB_CMP_PositiveAndGateOutputDisable function 5-1703
PLIB_CMP_PositiveAndGateOutputEnable function 5-1703
PLIB_CMP_StopInIdleModeDisable function 5-1695
PLIB_CMP_StopInIdleModeEnable function 5-1696
plib_dma.h 5-1859
PLIB_DMA_AbortTransferSet function 5-1758
PLIB_DMA_BusyActiveReset function 5-1755
PLIB_DMA_BusyActiveSet function 5-1755
PLIB_DMA_ChannelBitsGet function 5-1820
PLIB_DMA_ChannelPriorityGet function 5-1788
PLIB_DMA_ChannelPrioritySelect function 5-1788
PLIB_DMA_ChannelXAbortIRQSet function 5-1759
PLIB_DMA_ChannelXAddressModeGet function 5-1766
PLIB_DMA_ChannelXAddressModeSelect function 5-1767
PLIB_DMA_ChannelXAutoDisable function 5-1789
PLIB_DMA_ChannelXAutoEnable function 5-1789
PLIB_DMA_ChannelXAutoIsEnabled function 5-1815
PLIB_DMA_ChannelXBufferedDataIsWritten function 5-1816
PLIB_DMA_ChannelXBusyActiveSet function 5-1790
PLIB_DMA_ChannelXBusyInActiveSet function 5-1790
PLIB_DMA_ChannelXBusyIsBusy function 5-1816
PLIB_DMA_ChannelXCellProgressPointerGet function 5-1779
PLIB_DMA_ChannelXCellSizeGet function 5-1779
PLIB_DMA_ChannelXCellSizeSet function 5-1780
PLIB_DMA_ChannelXChainDisable function 5-1791
PLIB_DMA_ChannelXChainEnable function 5-1791
PLIB_DMA_ChannelXChainIsEnabled function 5-1817
PLIB_DMA_ChannelXChainToHigher function 5-1792
PLIB_DMA_ChannelXChainToLower function 5-1792
PLIB_DMA_ChannelXCollisionStatus function 5-1817
PLIB_DMA_ChannelXDataSizeGet function 5-1780
PLIB_DMA_ChannelXDataSizeSelect function 5-1781
PLIB_DMA_ChannelXDestinationAddressModeGet function
5-1768
PLIB_DMA_ChannelXDestinationAddressModeSelect function
5-1768
PLIB_DMA_ChannelXDestinationPointerGet function 5-1782
PLIB_DMA_ChannelXDestinationSizeGet function 5-1782
PLIB_DMA_ChannelXDestinationSizeSet function 5-1783
PLIB_DMA_ChannelXDestinationStartAddressGet function
5-1774
PLIB_DMA_ChannelXDestinationStartAddressSet function
5-1774
PLIB_DMA_ChannelXDisable function 5-1793
PLIB_DMA_ChannelXDisabledDisablesEvents function 5-1796
PLIB_DMA_ChannelXDisabledEnablesEvents function 5-1797
PLIB_DMA_ChannelXEnable function 5-1793
9 MPLAB Harmony Help
ss
PLIB_DMA_ChannelXEventIsDetected function 5-1818
PLIB_DMA_ChannelXINTSourceDisable function 5-1763
PLIB_DMA_ChannelXINTSourceEnable function 5-1763
PLIB_DMA_ChannelXINTSourceFlagClear function 5-1764
PLIB_DMA_ChannelXINTSourceFlagGet function 5-1764
PLIB_DMA_ChannelXINTSourceFlagSet function 5-1765
PLIB_DMA_ChannelXINTSourceIsEnabled function 5-1766
PLIB_DMA_ChannelXIsEnabled function 5-1819
PLIB_DMA_ChannelXNullWriteModeDisable function 5-1769
PLIB_DMA_ChannelXNullWriteModeEnable function 5-1769
PLIB_DMA_ChannelXNullWriteModeIsEnabled function 5-1819
PLIB_DMA_ChannelXOperatingTransferModeGet function
5-1770
PLIB_DMA_ChannelXOperatingTransferModeSelect function
5-1770
PLIB_DMA_ChannelXPatternDataGet function 5-1783
PLIB_DMA_ChannelXPatternDataSet function 5-1784
PLIB_DMA_ChannelXPatternIgnoreByteDisable function 5-1797
PLIB_DMA_ChannelXPatternIgnoreByteEnable function 5-1798
PLIB_DMA_ChannelXPatternIgnoreByteIsEnabled function
5-1798
PLIB_DMA_ChannelXPatternIgnoreGet function 5-1799
PLIB_DMA_ChannelXPatternIgnoreSet function 5-1799
PLIB_DMA_ChannelXPatternLengthGet function 5-1800
PLIB_DMA_ChannelXPatternLengthSet function 5-1801
PLIB_DMA_ChannelXPeripheralAddressGet function 5-1775
PLIB_DMA_ChannelXPeripheralAddressSet function 5-1775
PLIB_DMA_ChannelXPingPongModeGet function 5-1820
PLIB_DMA_ChannelXPriorityGet function 5-1794
PLIB_DMA_ChannelXPrioritySelect function 5-1794
PLIB_DMA_ChannelXReloadDisable function 5-1771
PLIB_DMA_ChannelXReloadEnable function 5-1771
PLIB_DMA_ChannelXReloadIsEnabled function 5-1773
PLIB_DMA_ChannelXSourceAddressModeGet function 5-1772
PLIB_DMA_ChannelXSourceAddressModeSelect function
5-1772
PLIB_DMA_ChannelXSourcePointerGet function 5-1785
PLIB_DMA_ChannelXSourceSizeGet function 5-1785
PLIB_DMA_ChannelXSourceSizeSet function 5-1786
PLIB_DMA_ChannelXSourceStartAddressGet function 5-1776
PLIB_DMA_ChannelXSourceStartAddressSet function 5-1777
PLIB_DMA_ChannelXStartAddressOffsetGet function 5-1777
PLIB_DMA_ChannelXStartAddressOffsetSet function 5-1778
PLIB_DMA_ChannelXStartIRQSet function 5-1760
PLIB_DMA_ChannelXTransferCountGet function 5-1786
PLIB_DMA_ChannelXTransferCountSet function 5-1787
PLIB_DMA_ChannelXTransferDirectionGet function 5-1795
PLIB_DMA_ChannelXTransferDirectionSelect function 5-1796
PLIB_DMA_ChannelXTriggerDisable function 5-1761
PLIB_DMA_ChannelXTriggerEnable function 5-1761
PLIB_DMA_ChannelXTriggerIsEnabled function 5-1762
PLIB_DMA_CRCAppendModeDisable function 5-1801
PLIB_DMA_CRCAppendModeEnable function 5-1802
PLIB_DMA_CRCAppendModeIsEnabled function 5-1802
PLIB_DMA_CRCBitOrderSelect function 5-1803
PLIB_DMA_CRCByteOrderGet function 5-1803
PLIB_DMA_CRCByteOrderSelect function 5-1804
PLIB_DMA_CRCChannelGet function 5-1804
PLIB_DMA_CRCChannelSelect function 5-1805
PLIB_DMA_CRCDataRead function 5-1805
PLIB_DMA_CRCDataWrite function 5-1806
PLIB_DMA_CRCDisable function 5-1806
PLIB_DMA_CRCEnable function 5-1807
PLIB_DMA_CRCIsEnabled function 5-1811
PLIB_DMA_CRCPolynomialLengthGet function 5-1807
PLIB_DMA_CRCPolynomialLengthSet function 5-1808
PLIB_DMA_CRCTypeGet function 5-1808
PLIB_DMA_CRCTypeSet function 5-1809
PLIB_DMA_CRCWriteByteOrderAlter function 5-1809
PLIB_DMA_CRCWriteByteOrderMaintain function 5-1810
PLIB_DMA_CRCXOREnableGet function 5-1810
PLIB_DMA_CRCXOREnableSet function 5-1810
PLIB_DMA_Disable function 5-1756
PLIB_DMA_Enable function 5-1756
PLIB_DMA_ExistsAbortTransfer function 5-1835
PLIB_DMA_ExistsBusy function 5-1835
PLIB_DMA_ExistsChannelBits function 5-1836
PLIB_DMA_ExistsChannelX function 5-1837
PLIB_DMA_ExistsChannelXAbortIRQ function 5-1837
PLIB_DMA_ExistsChannelXAuto function 5-1838
9 MPLAB Harmony Help
tt
PLIB_DMA_ExistsChannelXBusy function 5-1838
PLIB_DMA_ExistsChannelXCellProgressPointer function 5-1839
PLIB_DMA_ExistsChannelXCellSize function 5-1839
PLIB_DMA_ExistsChannelXChain function 5-1840
PLIB_DMA_ExistsChannelXChainEnbl function 5-1840
PLIB_DMA_ExistsChannelXDestinationPointer function 5-1841
PLIB_DMA_ExistsChannelXDestinationSize function 5-1841
PLIB_DMA_ExistsChannelXDestinationStartAddress function
5-1842
PLIB_DMA_ExistsChannelXDisabled function 5-1843
PLIB_DMA_ExistsChannelXEvent function 5-1843
PLIB_DMA_ExistsChannelXINTSource function 5-1844
PLIB_DMA_ExistsChannelXINTSourceFlag function 5-1844
PLIB_DMA_ExistsChannelXPatternData function 5-1845
PLIB_DMA_ExistsChannelXPatternIgnore function 5-1845
PLIB_DMA_ExistsChannelXPatternIgnoreByte function 5-1846
PLIB_DMA_ExistsChannelXPatternLength function 5-1846
PLIB_DMA_ExistsChannelXPriority function 5-1847
PLIB_DMA_ExistsChannelXSourcePointer function 5-1847
PLIB_DMA_ExistsChannelXSourceSize function 5-1848
PLIB_DMA_ExistsChannelXSourceStartAddress function
5-1848
PLIB_DMA_ExistsChannelXStartIRQ function 5-1849
PLIB_DMA_ExistsChannelXTrigger function 5-1849
PLIB_DMA_ExistsCRC function 5-1850
PLIB_DMA_ExistsCRCAppendMode function 5-1850
PLIB_DMA_ExistsCRCBitOrder function 5-1851
PLIB_DMA_ExistsCRCByteOrder function 5-1852
PLIB_DMA_ExistsCRCChannel function 5-1852
PLIB_DMA_ExistsCRCData function 5-1853
PLIB_DMA_ExistsCRCPolynomialLength function 5-1853
PLIB_DMA_ExistsCRCType function 5-1854
PLIB_DMA_ExistsCRCWriteByteOrder function 5-1854
PLIB_DMA_ExistsCRCXOREnable function 5-1855
PLIB_DMA_ExistsEnableControl function 5-1855
PLIB_DMA_ExistsLastBusAccess function 5-1856
PLIB_DMA_ExistsRecentAddress function 5-1856
PLIB_DMA_ExistsStartTransfer function 5-1857
PLIB_DMA_ExistsStopInIdle function 5-1857
PLIB_DMA_ExistsSuspend function 5-1858
PLIB_DMA_IsBusy function 5-1812
PLIB_DMA_IsEnabled function 5-1812
PLIB_DMA_LastBusAccessIsRead function 5-1813
PLIB_DMA_LastBusAccessIsWrite function 5-1813
PLIB_DMA_LastChannelActive function 5-1814
PLIB_DMA_RecentAddressAccessed function 5-1814
PLIB_DMA_StartTransferSet function 5-1759
PLIB_DMA_StopInIdleDisable function 5-1756
PLIB_DMA_StopInIdleEnable function 5-1757
PLIB_DMA_SuspendDisable function 5-1757
PLIB_DMA_SuspendEnable function 5-1758
PLIB_DMA_SuspendIsEnabled function 5-1814
plib_ebi.h 5-1900
PLIB_EBI_AddressHoldTimeGet function 5-1869
PLIB_EBI_AddressPinEnableBitsSet function 5-1876
PLIB_EBI_AddressSetupTimeGet function 5-1870
PLIB_EBI_BaseAddressGet function 5-1870
PLIB_EBI_BaseAddressSet function 5-1876
PLIB_EBI_ByteSelectPinSet function 5-1877
PLIB_EBI_ChipSelectEnableSet function 5-1878
PLIB_EBI_ControlEnableClear function 5-1869
PLIB_EBI_ControlEnableGet function 5-1870
PLIB_EBI_ControlEnableSet function 5-1886
PLIB_EBI_DataEnableSet function 5-1878
PLIB_EBI_DataTurnAroundTimeGet function 5-1871
PLIB_EBI_ExistsAddressHoldTime function 5-1887
PLIB_EBI_ExistsAddressPinEnableBits function 5-1887
PLIB_EBI_ExistsAddressSetupTime function 5-1888
PLIB_EBI_ExistsBaseAddress function 5-1888
PLIB_EBI_ExistsByteSelectPin function 5-1889
PLIB_EBI_ExistsChipSelectEnable function 5-1889
PLIB_EBI_ExistsControlEnable function 5-1890
PLIB_EBI_ExistsDataEnable function 5-1890
PLIB_EBI_ExistsDataTurnAroundTime function 5-1891
PLIB_EBI_ExistsFlashPowerDownMode function 5-1891
PLIB_EBI_ExistsFlashResetPin function 5-1892
PLIB_EBI_ExistsFlashTiming function 5-1892
PLIB_EBI_ExistsMemoryCharacteristics function 5-1893
PLIB_EBI_ExistsMemoryPaging function 5-1893
9 MPLAB Harmony Help
uu
PLIB_EBI_ExistsMemoryTimingConfig function 5-1894
PLIB_EBI_ExistsPageMode function 5-1894
PLIB_EBI_ExistsPageReadTime function 5-1895
PLIB_EBI_ExistsReadCycleTime function 5-1895
PLIB_EBI_ExistsReadyMode function 5-1896
PLIB_EBI_ExistsReadyPin1Config function 5-1896
PLIB_EBI_ExistsReadyPin2Config function 5-1897
PLIB_EBI_ExistsReadyPin3Config function 5-1897
PLIB_EBI_ExistsReadyPinSens function 5-1898
PLIB_EBI_ExistsStaticMemoryWidthRegister function 5-1898
PLIB_EBI_ExistsWriteOutputControl function 5-1899
PLIB_EBI_ExistsWritePulseWidth function 5-1899
PLIB_EBI_FlashPowerDownModeGet function 5-1871
PLIB_EBI_FlashPowerDownModeSet function 5-1879
PLIB_EBI_FlashResetPinGet function 5-1872
PLIB_EBI_FlashResetPinSet function 5-1879
PLIB_EBI_FlashTimingGet function 5-1872
PLIB_EBI_FlashTimingSet function 5-1880
PLIB_EBI_MemoryCharacteristicsSet function 5-1880
PLIB_EBI_MemoryPagingSet function 5-1881
PLIB_EBI_MemoryTimingConfigSet function 5-1882
PLIB_EBI_PageModeGet function 5-1873
PLIB_EBI_PageReadCycleTimeGet function 5-1873
PLIB_EBI_PageSizeGet function 5-1873
PLIB_EBI_ReadCycleTimeGet function 5-1874
PLIB_EBI_ReadyModeGet function 5-1874
PLIB_EBI_ReadyModeSet function 5-1886
PLIB_EBI_ReadyPin1ConfigSet function 5-1882
PLIB_EBI_ReadyPin2ConfigSet function 5-1883
PLIB_EBI_ReadyPin3ConfigSet function 5-1884
PLIB_EBI_ReadyPinSensSet function 5-1884
PLIB_EBI_StaticMemoryWidthRegisterGet function 5-1875
PLIB_EBI_StaticMemoryWidthRegisterSet function 5-1885
PLIB_EBI_WriteOutputControlSet function 5-1885
PLIB_EBI_WritePulseWidthGet function 5-1875
plib_eth.h 5-2052
PLIB_ETH_AlignErrorCountClear function 5-2019
PLIB_ETH_AlignErrorCountGet function 5-2019
PLIB_ETH_AutoDetectPadClear function 5-1929
PLIB_ETH_AutoDetectPadGet function 5-1929
PLIB_ETH_AutoDetectPadSet function 5-1930
PLIB_ETH_AutoFlowControlDisable function 5-1998
PLIB_ETH_AutoFlowControlEnable function 5-1999
PLIB_ETH_AutoFlowControlIsEnabled function 5-1999
PLIB_ETH_BackPresNoBackoffDisable function 5-2000
PLIB_ETH_BackPresNoBackoffEnable function 5-2000
PLIB_ETH_BackPresNoBackoffIsEnabled function 5-2001
PLIB_ETH_BackToBackIPGGet function 5-1930
PLIB_ETH_BackToBackIPGSet function 5-1931
PLIB_ETH_CollisionWindowGet function 5-1932
PLIB_ETH_CollisionWindowSet function 5-1932
PLIB_ETH_CRCDisable function 5-1982
PLIB_ETH_CRCEnable function 5-1983
PLIB_ETH_CRCIsEnabled function 5-1983
PLIB_ETH_DataNotValid function 5-1984
PLIB_ETH_DelayedCRCDisable function 5-1933
PLIB_ETH_DelayedCRCEnable function 5-1933
PLIB_ETH_DelayedCRCIsEnabled function 5-1934
PLIB_ETH_Disable function 5-1934
PLIB_ETH_Enable function 5-1935
PLIB_ETH_EthernetIsBusy function 5-1984
PLIB_ETH_ExcessDeferDisable function 5-1935
PLIB_ETH_ExcessDeferEnable function 5-1936
PLIB_ETH_ExcessDeferIsEnabled function 5-1936
PLIB_ETH_ExistsAlignmentErrorCount function 5-2026
PLIB_ETH_ExistsAutoFlowControl function 5-2027
PLIB_ETH_ExistsCollisionCounts function 5-2028
PLIB_ETH_ExistsCollisionWindow function 5-2028
PLIB_ETH_ExistsEnable function 5-2029
PLIB_ETH_ExistsEthernetControllerStatus function 5-2029
PLIB_ETH_ExistsFCSErrorCount function 5-2030
PLIB_ETH_ExistsFramesTransmittedOK function 5-2030
PLIB_ETH_ExistsFramexReceivedOK function 5-2031
PLIB_ETH_ExistsHashTable function 5-2031
PLIB_ETH_ExistsInterPacketGaps function 5-2032
PLIB_ETH_ExistsInterrupt function 5-2033
PLIB_ETH_ExistsMAC_Configuration function 5-2033
PLIB_ETH_ExistsMAC_Resets function 5-2035
9 MPLAB Harmony Help
vv
PLIB_ETH_ExistsMAC_Testing function 5-2036
PLIB_ETH_ExistsManualFlowControl function 5-2037
PLIB_ETH_ExistsMaxFrameLength function 5-2037
PLIB_ETH_ExistsMIIM_Config function 5-2038
PLIB_ETH_ExistsMIIM_Indicators function 5-2038
PLIB_ETH_ExistsMIIMAddresses function 5-2039
PLIB_ETH_ExistsMIIMReadWrite function 5-2040
PLIB_ETH_ExistsMIIMScanMode function 5-2040
PLIB_ETH_ExistsMIIWriteReadData function 5-2041
PLIB_ETH_ExistsPatternMatch function 5-2041
PLIB_ETH_ExistsPauseTimer function 5-2042
PLIB_ETH_ExistsReceiveBufferSize function 5-2042
PLIB_ETH_ExistsReceiveFilters function 5-2043
PLIB_ETH_ExistsReceiveOverflowCount function 5-2043
PLIB_ETH_ExistsReceiveWmarks function 5-2044
PLIB_ETH_ExistsRetransmissionMaximum function 5-2045
PLIB_ETH_ExistsRMII_Support function 5-2045
PLIB_ETH_ExistsRxBufferCountDecrement function 5-2046
PLIB_ETH_ExistsRxEnable function 5-2046
PLIB_ETH_ExistsRxPacketDescriptorAddress function 5-2047
PLIB_ETH_ExistsStationAddress function 5-2047
PLIB_ETH_ExistsStopInIdle function 5-2048
PLIB_ETH_ExistsTransmitRTS function 5-2048
PLIB_ETH_ExistsTxPacketDescriptorAddress function 5-2049
PLIB_ETH_FCSErrorCountClear function 5-2020
PLIB_ETH_FCSErrorCountGet function 5-2020
PLIB_ETH_FrameLengthCheckDisable function 5-1937
PLIB_ETH_FrameLengthCheckEnable function 5-1937
PLIB_ETH_FrameLengthCheckIsEnabled function 5-1938
PLIB_ETH_FramesRxdOkCountClear function 5-2021
PLIB_ETH_FramesRxdOkCountGet function 5-2021
PLIB_ETH_FramesTxdOkCountClear function 5-2022
PLIB_ETH_FramesTxdOkCountGet function 5-2022
PLIB_ETH_FullDuplexDisable function 5-1938
PLIB_ETH_FullDuplexEnable function 5-1939
PLIB_ETH_FullDuplexIsEnabled function 5-1939
PLIB_ETH_HashTableGet function 5-1987
PLIB_ETH_HashTableSet function 5-1988
PLIB_ETH_HugeFrameDisable function 5-1940
PLIB_ETH_HugeFrameEnable function 5-1940
PLIB_ETH_HugeFrameIsEnabled function 5-1941
PLIB_ETH_InterruptClear function 5-2014
PLIB_ETH_InterruptSet function 5-2015
PLIB_ETH_InterruptsGet function 5-2015
PLIB_ETH_InterruptSourceDisable function 5-2016
PLIB_ETH_InterruptSourceEnable function 5-2016
PLIB_ETH_InterruptSourceIsEnabled function 5-2017
PLIB_ETH_InterruptSourcesGet function 5-2018
PLIB_ETH_InterruptStatusGet function 5-2018
PLIB_ETH_IsEnabled function 5-1941
PLIB_ETH_LinkHasFailed function 5-1985
PLIB_ETH_LongPreambleDisable function 5-1942
PLIB_ETH_LongPreambleEnable function 5-1942
PLIB_ETH_LongPreambleIsEnabled function 5-1943
PLIB_ETH_LoopbackDisable function 5-1943
PLIB_ETH_LoopbackEnable function 5-1944
PLIB_ETH_LoopbackIsEnabled function 5-1944
PLIB_ETH_ManualFlowControlDisable function 5-2001
PLIB_ETH_ManualFlowControlEnable function 5-2002
PLIB_ETH_ManualFlowControlIsEnabled function 5-2002
PLIB_ETH_MaxFrameLengthGet function 5-1945
PLIB_ETH_MaxFrameLengthSet function 5-1945
PLIB_ETH_MCSRxResetDisable function 5-1957
PLIB_ETH_MCSRxResetEnable function 5-1958
PLIB_ETH_MCSRxResetIsEnabled function 5-1958
PLIB_ETH_MCSTxResetDisable function 5-1959
PLIB_ETH_MCSTxResetEnable function 5-1959
PLIB_ETH_MCSTxResetIsEnabled function 5-1960
PLIB_ETH_MIIMClockGet function 5-1946
PLIB_ETH_MIIMClockSet function 5-1946
PLIB_ETH_MIIMIsBusy function 5-1985
PLIB_ETH_MIIMIsScanning function 5-1986
PLIB_ETH_MIIMNoPreDisable function 5-1947
PLIB_ETH_MIIMNoPreEnable function 5-1947
PLIB_ETH_MIIMNoPreIsEnabled function 5-1948
PLIB_ETH_MIIMReadDataGet function 5-1960
PLIB_ETH_MIIMReadStart function 5-1961
PLIB_ETH_MIIMResetDisable function 5-1961
9 MPLAB Harmony Help
ww
PLIB_ETH_MIIMResetEnable function 5-1962
PLIB_ETH_MIIMResetIsEnabled function 5-1962
PLIB_ETH_MIIMScanIncrDisable function 5-1963
PLIB_ETH_MIIMScanIncrEnable function 5-1963
PLIB_ETH_MIIMScanIncrIsEnabled function 5-1964
PLIB_ETH_MIIMScanModeDisable function 5-1964
PLIB_ETH_MIIMScanModeEnable function 5-1965
PLIB_ETH_MIIMScanModeIsEnabled function 5-1965
PLIB_ETH_MIIMWriteDataSet function 5-1966
PLIB_ETH_MIIMWriteStart function 5-1966
PLIB_ETH_MIIResetDisable function 5-1967
PLIB_ETH_MIIResetEnable function 5-1968
PLIB_ETH_MIIResetIsEnabled function 5-1968
PLIB_ETH_MultipleCollisionCountClear function 5-2023
PLIB_ETH_MultipleCollisionCountGet function 5-2023
PLIB_ETH_NoBackoffDisable function 5-2003
PLIB_ETH_NoBackoffEnable function 5-2003
PLIB_ETH_NoBackoffIsEnabled function 5-2004
PLIB_ETH_NonBackToBackIPG1Get function 5-1948
PLIB_ETH_NonBackToBackIPG1Set function 5-1949
PLIB_ETH_NonBackToBackIPG2Get function 5-1949
PLIB_ETH_NonBackToBackIPG2Set function 5-1950
PLIB_ETH_PassAllDisable function 5-1988
PLIB_ETH_PassAllEnable function 5-1989
PLIB_ETH_PassAllIsEnabled function 5-1989
PLIB_ETH_PatternMatchChecksumGet function 5-1990
PLIB_ETH_PatternMatchChecksumSet function 5-1990
PLIB_ETH_PatternMatchGet function 5-1991
PLIB_ETH_PatternMatchModeGet function 5-1991
PLIB_ETH_PatternMatchModeSet function 5-1992
PLIB_ETH_PatternMatchOffsetGet function 5-1992
PLIB_ETH_PatternMatchOffsetSet function 5-1993
PLIB_ETH_PatternMatchSet function 5-1993
PLIB_ETH_PauseTimerGet function 5-1950
PLIB_ETH_PauseTimerSet function 5-1951
PLIB_ETH_PHYAddressGet function 5-1969
PLIB_ETH_PHYAddressSet function 5-1969
PLIB_ETH_PurePreambleDisable function 5-1994
PLIB_ETH_PurePreambleEnable function 5-1994
PLIB_ETH_PurePreambleIsEnabled function 5-1995
PLIB_ETH_ReceiveBufferSizeGet function 5-1951
PLIB_ETH_ReceiveBufferSizeSet function 5-1952
PLIB_ETH_ReceiveDisable function 5-1952
PLIB_ETH_ReceiveEnable function 5-1953
PLIB_ETH_ReceiveFilterDisable function 5-1995
PLIB_ETH_ReceiveFilterEnable function 5-1996
PLIB_ETH_ReceiveFilterIsEnable function 5-1997
PLIB_ETH_ReceiveIsBusy function 5-1986
PLIB_ETH_ReceiveIsEnabled function 5-1953
PLIB_ETH_RegisterAddressGet function 5-1970
PLIB_ETH_RegisterAddressSet function 5-1970
PLIB_ETH_ReTxMaxGet function 5-1954
PLIB_ETH_ReTxMaxSet function 5-1954
PLIB_ETH_RMIIResetDisable function 5-1971
PLIB_ETH_RMIIResetEnable function 5-1971
PLIB_ETH_RMIIResetIsEnabled function 5-1972
PLIB_ETH_RMIISpeedGet function 5-1955
PLIB_ETH_RMIISpeedSet function 5-1955
PLIB_ETH_RxBufferCountDecrement function 5-1972
PLIB_ETH_RxDisable function 5-1973
PLIB_ETH_RxEmptyWmarkGet function 5-2004
PLIB_ETH_RxEmptyWmarkSet function 5-2005
PLIB_ETH_RxEnable function 5-1973
PLIB_ETH_RxFullWmarkGet function 5-2006
PLIB_ETH_RxFullWmarkSet function 5-2006
PLIB_ETH_RxFuncResetDisable function 5-1974
PLIB_ETH_RxFuncResetEnable function 5-1974
PLIB_ETH_RxFuncResetIsEnabled function 5-1975
PLIB_ETH_RxIsEnabled function 5-1975
PLIB_ETH_RxOverflowCountClear function 5-2024
PLIB_ETH_RxOverflowCountGet function 5-2024
PLIB_ETH_RxPacketCountGet function 5-2025
PLIB_ETH_RxPacketDescAddrGet function 5-1976
PLIB_ETH_RxPacketDescAddrSet function 5-1976
PLIB_ETH_RxPauseDisable function 5-2007
PLIB_ETH_RxPauseEnable function 5-2007
PLIB_ETH_RxPauseIsEnabled function 5-2008
PLIB_ETH_ShortcutQuantaDisable function 5-2008
9 MPLAB Harmony Help
xx
PLIB_ETH_ShortcutQuantaEnable function 5-2009
PLIB_ETH_ShortcutQuantaIsEnabled function 5-2009
PLIB_ETH_SimResetDisable function 5-2010
PLIB_ETH_SimResetEnable function 5-2010
PLIB_ETH_SimResetIsEnabled function 5-2011
PLIB_ETH_SingleCollisionCountClear function 5-2025
PLIB_ETH_SingleCollisionCountGet function 5-2026
PLIB_ETH_StationAddressGet function 5-1997
PLIB_ETH_StationAddressSet function 5-1998
PLIB_ETH_StopInIdleDisable function 5-1956
PLIB_ETH_StopInIdleEnable function 5-1956
PLIB_ETH_StopInIdleIsEnabled function 5-1957
PLIB_ETH_TestBackPressDisable function 5-2011
PLIB_ETH_TestBackPressEnable function 5-2012
PLIB_ETH_TestBackPressIsEnabled function 5-2012
PLIB_ETH_TestPauseDisable function 5-1977
PLIB_ETH_TestPauseEnable function 5-1977
PLIB_ETH_TestPauseIsEnabled function 5-1978
PLIB_ETH_TransmitIsBusy function 5-1987
PLIB_ETH_TxFuncResetDisable function 5-1978
PLIB_ETH_TxFuncResetEnable function 5-1979
PLIB_ETH_TxFuncResetIsEnabled function 5-1979
PLIB_ETH_TxPacketDescAddrGet function 5-1980
PLIB_ETH_TxPacketDescAddrSet function 5-1980
PLIB_ETH_TxPauseDisable function 5-2013
PLIB_ETH_TxPauseEnable function 5-2013
PLIB_ETH_TxPauseIsEnabled function 5-2014
PLIB_ETH_TxRTSDisable function 5-1981
PLIB_ETH_TxRTSEnable function 5-1981
PLIB_ETH_TxRTSIsEnabled function 5-1982
plib_i2c.h 5-2166
PLIB_I2C_AcksequenceIsInProgress function 5-2122
PLIB_I2C_ArbitrationLossClear function 5-2103
PLIB_I2C_ArbitrationLossHasOccurred function 5-2104
PLIB_I2C_BaudRateGet function 5-2109
PLIB_I2C_BaudRateSet function 5-2109
PLIB_I2C_BusIsIdle function 5-2105
PLIB_I2C_DataLineHoldTimeSet function 5-2123
PLIB_I2C_Disable function 5-2093
PLIB_I2C_Enable function 5-2094
PLIB_I2C_ExistsAcksequenceProgress function 5-2144
PLIB_I2C_ExistsArbitrationLoss function 5-2144
PLIB_I2C_ExistsBaudRate function 5-2145
PLIB_I2C_ExistsBusIsIdle function 5-2146
PLIB_I2C_ExistsClockStretching function 5-2146
PLIB_I2C_ExistsDataLineHoldTime function 5-2147
PLIB_I2C_ExistsGeneralCall function 5-2147
PLIB_I2C_ExistsGeneralCallAddressDetect function 5-2148
PLIB_I2C_ExistsHighFrequency function 5-2148
PLIB_I2C_ExistsIPMI function 5-2149
PLIB_I2C_ExistsMasterReceiverClock1Byte function 5-2149
PLIB_I2C_ExistsMasterStart function 5-2150
PLIB_I2C_ExistsMasterStartRepeat function 5-2150
PLIB_I2C_ExistsMasterStop function 5-2151
PLIB_I2C_ExistsModuleEnable function 5-2151
PLIB_I2C_ExistsReceivedByteAcknowledge function 5-2152
PLIB_I2C_ExistsReceivedByteAvailable function 5-2152
PLIB_I2C_ExistsReceivedByteGet function 5-2153
PLIB_I2C_ExistsReceiverOverflow function 5-2153
PLIB_I2C_ExistsReservedAddressProtect function 5-2154
PLIB_I2C_ExistsSlaveAddress10Bit function 5-2154
PLIB_I2C_ExistsSlaveAddress7Bit function 5-2155
PLIB_I2C_ExistsSlaveAddressDetect function 5-2155
PLIB_I2C_ExistsSlaveAddressHoldEnable function 5-2156
PLIB_I2C_ExistsSlaveBufferOverwrite function 5-2156
PLIB_I2C_ExistsSlaveBusCollisionDetect function 5-2157
PLIB_I2C_ExistsSlaveClockHold function 5-2157
PLIB_I2C_ExistsSlaveDataDetect function 5-2158
PLIB_I2C_ExistsSlaveInterruptOnStart function 5-2158
PLIB_I2C_ExistsSlaveInterruptOnStop function 5-2159
PLIB_I2C_ExistsSlaveMask function 5-2160
PLIB_I2C_ExistsSlaveReadRequest function 5-2160
PLIB_I2C_ExistsSMBus function 5-2161
PLIB_I2C_ExistsStartDetect function 5-2161
PLIB_I2C_ExistsStopDetect function 5-2162
PLIB_I2C_ExistsStopInIdle function 5-2162
PLIB_I2C_ExistsTransmitterByteAcknowledge function 5-2163
PLIB_I2C_ExistsTransmitterByteComplete function 5-2163
9 MPLAB Harmony Help
yy
PLIB_I2C_ExistsTransmitterByteSend function 5-2164
PLIB_I2C_ExistsTransmitterIsBusy function 5-2164
PLIB_I2C_ExistsTransmitterOverflow function 5-2165
PLIB_I2C_GeneralCallDisable function 5-2094
PLIB_I2C_GeneralCallEnable function 5-2095
PLIB_I2C_HighFrequencyDisable function 5-2096
PLIB_I2C_HighFrequencyEnable function 5-2096
PLIB_I2C_IPMIDisable function 5-2097
PLIB_I2C_IPMIEnable function 5-2098
PLIB_I2C_MasterReceiverClock1Byte function 5-2131
PLIB_I2C_MasterReceiverReadyToAcknowledge function
5-2143
PLIB_I2C_MasterStart function 5-2132
PLIB_I2C_MasterStartRepeat function 5-2132
PLIB_I2C_MasterStop function 5-2133
PLIB_I2C_ReceivedByteAcknowledge function 5-2139
PLIB_I2C_ReceivedByteGet function 5-2140
PLIB_I2C_ReceivedByteIsAvailable function 5-2140
PLIB_I2C_ReceiverByteAcknowledgeHasCompleted function
5-2141
PLIB_I2C_ReceiverOverflowClear function 5-2142
PLIB_I2C_ReceiverOverflowHasOccurred function 5-2142
PLIB_I2C_ReservedAddressProtectDisable function 5-2098
PLIB_I2C_ReservedAddressProtectEnable function 5-2099
PLIB_I2C_SlaveAddress10BitGet function 5-2110
PLIB_I2C_SlaveAddress10BitSet function 5-2111
PLIB_I2C_SlaveAddress10BitWasDetected function 5-2112
PLIB_I2C_SlaveAddress7BitGet function 5-2112
PLIB_I2C_SlaveAddress7BitSet function 5-2113
PLIB_I2C_SlaveAddressHoldDisable function 5-2114
PLIB_I2C_SlaveAddressHoldEnable function 5-2114
PLIB_I2C_SlaveAddressIsDetected function 5-2115
PLIB_I2C_SlaveAddressIsGeneralCall function 5-2116
PLIB_I2C_SlaveAddressModeIs10Bits function 5-2117
PLIB_I2C_SlaveBufferOverwriteDisable function 5-2124
PLIB_I2C_SlaveBufferOverwriteEnable function 5-2124
PLIB_I2C_SlaveBusCollisionDetectDisable function 5-2125
PLIB_I2C_SlaveBusCollisionDetectEnable function 5-2125
PLIB_I2C_SlaveClockHold function 5-2126
PLIB_I2C_SlaveClockRelease function 5-2127
PLIB_I2C_SlaveClockStretchingDisable function 5-2099
PLIB_I2C_SlaveClockStretchingEnable function 5-2100
PLIB_I2C_SlaveDataHoldDisable function 5-2127
PLIB_I2C_SlaveDataHoldEnable function 5-2128
PLIB_I2C_SlaveDataIsDetected function 5-2117
PLIB_I2C_SlaveInterruptOnStartDisable function 5-2129
PLIB_I2C_SlaveInterruptOnStartEnable function 5-2129
PLIB_I2C_SlaveInterruptOnStopDisable function 5-2130
PLIB_I2C_SlaveInterruptOnStopEnable function 5-2130
PLIB_I2C_SlaveMask10BitGet function 5-2119
PLIB_I2C_SlaveMask10BitSet function 5-2120
PLIB_I2C_SlaveMask7BitGet function 5-2121
PLIB_I2C_SlaveMask7BitSet function 5-2121
PLIB_I2C_SlaveReadIsRequested function 5-2118
PLIB_I2C_SMBDisable function 5-2101
PLIB_I2C_SMBEnable function 5-2101
PLIB_I2C_StartClear function 5-2106
PLIB_I2C_StartWasDetected function 5-2106
PLIB_I2C_StopClear function 5-2107
PLIB_I2C_StopInIdleDisable function 5-2102
PLIB_I2C_StopInIdleEnable function 5-2103
PLIB_I2C_StopWasDetected function 5-2108
PLIB_I2C_TransmitterByteHasCompleted function 5-2134
PLIB_I2C_TransmitterByteSend function 5-2134
PLIB_I2C_TransmitterByteWasAcknowledged function 5-2135
PLIB_I2C_TransmitterIsBusy function 5-2136
PLIB_I2C_TransmitterIsReady function 5-2137
PLIB_I2C_TransmitterOverflowClear function 5-2138
PLIB_I2C_TransmitterOverflowHasOccurred function 5-2138
plib_ic.h 5-2201
PLIB_IC_AlternateClockDisable function 5-2182
PLIB_IC_AlternateClockEnable function 5-2183
PLIB_IC_Buffer16BitGet function 5-2183
PLIB_IC_Buffer32BitGet function 5-2184
PLIB_IC_BufferIsEmpty function 5-2184
PLIB_IC_BufferOverflowHasOccurred function 5-2185
PLIB_IC_BufferSizeSelect function 5-2185
PLIB_IC_ClockSourceSelect function 5-2179
PLIB_IC_Disable function 5-2177
9 MPLAB Harmony Help
zz
PLIB_IC_Enable function 5-2177
PLIB_IC_EventsPerInterruptSelect function 5-2178
PLIB_IC_ExistsAlternateClock function 5-2193
PLIB_IC_ExistsBufferIsEmptyStatus function 5-2193
PLIB_IC_ExistsBufferOverflowStatus function 5-2194
PLIB_IC_ExistsBufferSize function 5-2194
PLIB_IC_ExistsBufferValue function 5-2195
PLIB_IC_ExistsCaptureMode function 5-2195
PLIB_IC_ExistsClockSource function 5-2196
PLIB_IC_ExistsEdgeCapture function 5-2196
PLIB_IC_ExistsEnable function 5-2197
PLIB_IC_ExistsEventsPerInterruptSelect function 5-2197
PLIB_IC_ExistsStopInIdle function 5-2198
PLIB_IC_ExistsSyncMode function 5-2198
PLIB_IC_ExistsSyncModeInput function 5-2199
PLIB_IC_ExistsTimerSelect function 5-2199
PLIB_IC_ExistsTimerTriggered function 5-2200
PLIB_IC_FirstCaptureEdgeSelect function 5-2179
PLIB_IC_ModeSelect function 5-2186
PLIB_IC_StopInIdleDisable function 5-2187
PLIB_IC_StopInIdleEnable function 5-2187
PLIB_IC_SyncModeInputSelect function 5-2180
PLIB_IC_SyncModeSelect function 5-2180
PLIB_IC_TimerIsTriggered function 5-2181
PLIB_IC_TimerSelect function 5-2181
plib_int.h 5-2250
PLIB_INT_AlternateVectorTableSelect function 5-2208
PLIB_INT_CPUCurrentPriorityLevelGet function 5-2228
PLIB_INT_Disable function 5-2209
PLIB_INT_DISIStatusGet function 5-2209
PLIB_INT_Enable function 5-2210
PLIB_INT_ExistsAlternateVectorTable function 5-2240
PLIB_INT_ExistsCPUCurrentPriorityLevel function 5-2240
PLIB_INT_ExistsEnableControl function 5-2241
PLIB_INT_ExistsExternalINTEdgeSelect function 5-2241
PLIB_INT_ExistsHighPriority function 5-2242
PLIB_INT_ExistsINTCPUPriority function 5-2242
PLIB_INT_ExistsINTCPUVector function 5-2243
PLIB_INT_ExistsINTNesting function 5-2243
PLIB_INT_ExistsLowPriority function 5-2244
PLIB_INT_ExistsPeripheralControl function 5-2244
PLIB_INT_ExistsPriority function 5-2245
PLIB_INT_ExistsProximityTimerControl function 5-2245
PLIB_INT_ExistsProximityTimerEnable function 5-2246
PLIB_INT_ExistsSingleVectorShadowSet function 5-2246
PLIB_INT_ExistsSourceControl function 5-2247
PLIB_INT_ExistsSourceFlag function 5-2247
PLIB_INT_ExistsTrapSource function 5-2248
PLIB_INT_ExistsVectorPriority function 5-2248
PLIB_INT_ExistsVectorSelect function 5-2249
PLIB_INT_ExternalFallingEdgeSelect function 5-2210
PLIB_INT_ExternalRisingEdgeSelect function 5-2211
PLIB_INT_IsEnabled function 5-2211
PLIB_INT_MultiVectorSelect function 5-2212
PLIB_INT_NestingDisable function 5-2213
PLIB_INT_NestingEnable function 5-2213
PLIB_INT_PeripheralsDisable function 5-2214
PLIB_INT_PeripheralsEnable function 5-2214
PLIB_INT_PriorityDisable function 5-2214
PLIB_INT_PriorityEnable function 5-2215
PLIB_INT_PriorityGet function 5-2216
PLIB_INT_PriorityHighDisable function 5-2216
PLIB_INT_PriorityHighEnable function 5-2217
PLIB_INT_PriorityLowDisable function 5-2217
PLIB_INT_PriorityLowEnable function 5-2218
PLIB_INT_ProximityTimerDisable function 5-2218
PLIB_INT_ProximityTimerEnable function 5-2219
PLIB_INT_ProximityTimerGet function 5-2229
PLIB_INT_ProximityTimerSet function 5-2230
PLIB_INT_SingleVectorSelect function 5-2219
PLIB_INT_SingleVectorShadowSetDisable function 5-2220
PLIB_INT_SingleVectorShadowSetEnable function 5-2220
PLIB_INT_SourceDisable function 5-2221
PLIB_INT_SourceEnable function 5-2222
PLIB_INT_SourceFlagClear function 5-2223
PLIB_INT_SourceFlagGet function 5-2224
PLIB_INT_SourceFlagSet function 5-2225
PLIB_INT_SourceIsEnabled function 5-2225
9 MPLAB Harmony Help
aaa
PLIB_INT_StandardVectorTableSelect function 5-2221
PLIB_INT_TrapSourceFlagClear function 5-2230
PLIB_INT_TrapSourceFlagGet function 5-2231
PLIB_INT_VectorGet function 5-2232
PLIB_INT_VectorPriorityGet function 5-2226
PLIB_INT_VectorPrioritySet function 5-2227
PLIB_INT_VectorSubPriorityGet function 5-2227
PLIB_INT_VectorSubPrioritySet function 5-2228
plib_nvm.h 5-2285
PLIB_NVM_BootPageWriteProtectionDisable function 5-2271
PLIB_NVM_BootPageWriteProtectionEnable function 5-2271
PLIB_NVM_DataBlockSourceAddress function 5-2263
PLIB_NVM_ExistsAccessEnable function 5-2274
PLIB_NVM_ExistsAddressModifyControl function 5-2275
PLIB_NVM_ExistsBootPageWriteProtect function 5-2275
PLIB_NVM_ExistsEEPROMReadInitiate function 5-2276
PLIB_NVM_ExistsFlashBankRegionSelect function 5-2276
PLIB_NVM_ExistsFlashWPMemoryRangeProvide function
5-2277
PLIB_NVM_ExistsKeySequence function 5-2277
PLIB_NVM_ExistsLockBootSelect function 5-2278
PLIB_NVM_ExistsLockPFMSelect function 5-2278
PLIB_NVM_ExistsLowVoltageError function 5-2279
PLIB_NVM_ExistsLowVoltageStatus function 5-2279
PLIB_NVM_ExistsMemoryModificationControl function 5-2280
PLIB_NVM_ExistsOperationMode function 5-2280
PLIB_NVM_ExistsProgramEraseOperation function 5-2281
PLIB_NVM_ExistsProvideData function 5-2281
PLIB_NVM_ExistsProvideQuadData function 5-2282
PLIB_NVM_ExistsSourceAddress function 5-2282
PLIB_NVM_ExistsStopInIdle function 5-2283
PLIB_NVM_ExistsWriteErrorStatus function 5-2283
PLIB_NVM_ExistsWriteOperation function 5-2284
PLIB_NVM_FlashAccessEnable function 5-2263
PLIB_NVM_FlashAddressToModify function 5-2264
PLIB_NVM_FlashEraseOperationSelect function 5-2264
PLIB_NVM_FlashEraseStart function 5-2265
PLIB_NVM_FlashProvideData function 5-2265
PLIB_NVM_FlashProvideQuadData function 5-2266
PLIB_NVM_FlashRead function 5-2266
PLIB_NVM_FlashWriteCycleHasCompleted function 5-2267
PLIB_NVM_FlashWriteKeySequence function 5-2267
PLIB_NVM_FlashWriteOperationSelect function 5-2268
PLIB_NVM_FlashWriteProtectMemoryAreaRange function
5-2268
PLIB_NVM_FlashWriteStart function 5-2269
PLIB_NVM_IsBootMemoryLocked function 5-2272
PLIB_NVM_IsBootPageWriteProtected function 5-2272
PLIB_NVM_IsProgramFlashMemoryLocked function 5-2269
PLIB_NVM_LockBootMemory function 5-2273
PLIB_NVM_LockProgramFlashMemory function 5-2274
PLIB_NVM_LowVoltageEventIsActive function 5-2259
PLIB_NVM_LowVoltageIsDetected function 5-2259
PLIB_NVM_MemoryModifyEnable function 5-2260
PLIB_NVM_MemoryModifyInhibit function 5-2260
PLIB_NVM_MemoryOperationSelect function 5-2261
PLIB_NVM_ProgramFlashBank1LowerRegion function 5-2270
PLIB_NVM_ProgramFlashBank2LowerRegion function 5-2270
PLIB_NVM_StopInIdleDisable function 5-2261
PLIB_NVM_StopInIdleEnable function 5-2262
PLIB_NVM_WriteOperationHasTerminated function 5-2262
plib_oc.h 5-2328
PLIB_OC_AlternateClockDisable function 5-2306
PLIB_OC_AlternateClockEnable function 5-2307
PLIB_OC_Buffer16BitSet function 5-2299
PLIB_OC_Buffer32BitSet function 5-2299
PLIB_OC_BufferSizeSelect function 5-2300
PLIB_OC_Disable function 5-2296
PLIB_OC_Enable function 5-2297
PLIB_OC_ExistsAlternateClock function 5-2318
PLIB_OC_ExistsBufferSize function 5-2319
PLIB_OC_ExistsBufferValue function 5-2319
PLIB_OC_ExistsCompareModeSelect function 5-2320
PLIB_OC_ExistsEnableControl function 5-2320
PLIB_OC_ExistsFaultInput function 5-2321
PLIB_OC_ExistsFaultModeSelect function 5-2321
PLIB_OC_ExistsFaultOutSelect function 5-2322
PLIB_OC_ExistsFaultStatus function 5-2322
PLIB_OC_ExistsFaultTristateSelect function 5-2323
PLIB_OC_ExistsPolarityInvert function 5-2323
9 MPLAB Harmony Help
bbb
PLIB_OC_ExistsPulseWidth function 5-2324
PLIB_OC_ExistsPWMDutyCycleResolutionControl function
5-2324
PLIB_OC_ExistsStopInIdle function 5-2325
PLIB_OC_ExistsSyncModeSelect function 5-2325
PLIB_OC_ExistsSyncSourceSelect function 5-2326
PLIB_OC_ExistsTimerSelect function 5-2326
PLIB_OC_ExistsTimerTriggered function 5-2327
PLIB_OC_ExistsTriggerControl function 5-2327
PLIB_OC_ExistsTriggerStatusModeSelect function 5-2328
PLIB_OC_FaultHasOccurred function 5-2309
PLIB_OC_FaultInputSelect function 5-2309
PLIB_OC_FaultModeSelect function 5-2310
PLIB_OC_FaultOutSelect function 5-2310
PLIB_OC_FaultTristateSelect function 5-2311
PLIB_OC_IsTriggered function 5-2302
PLIB_OC_ModeSelect function 5-2297
PLIB_OC_PolarityInvertedDisable function 5-2298
PLIB_OC_PolarityInvertedEnable function 5-2298
PLIB_OC_PulseWidth16BitSet function 5-2301
PLIB_OC_PulseWidth32BitSet function 5-2301
PLIB_OC_PWMDutyCycleResolutionSet function 5-2302
PLIB_OC_StopInIdleDisable function 5-2307
PLIB_OC_StopInIdleEnable function 5-2308
PLIB_OC_SyncModeSelect function 5-2303
PLIB_OC_SyncSourceSelect function 5-2304
PLIB_OC_TimerSelect function 5-2304
PLIB_OC_TriggerClear function 5-2305
PLIB_OC_TriggerSet function 5-2305
PLIB_OC_TriggerStatusModeSelect function 5-2306
plib_osc.h 5-2423
PLIB_OSC_AuxClockSourceGet function 5-2347
PLIB_OSC_AuxClockSourceSet function 5-2347
PLIB_OSC_AuxModeGet function 5-2348
PLIB_OSC_AuxModeSelect function 5-2348
PLIB_OSC_ClockHasFailed function 5-2392
PLIB_OSC_ClockSwitchingAbort function 5-2365
PLIB_OSC_ClockSwitchingIsComplete function 5-2366
PLIB_OSC_CurrentSysClockGet function 5-2366
PLIB_OSC_DozeModeDisable function 5-2368
PLIB_OSC_DozeModeEnable function 5-2368
PLIB_OSC_DozeRatioGet function 5-2369
PLIB_OSC_DozeRatioSelect function 5-2369
PLIB_OSC_DozeRecoverOnInterruptDisable function 5-2370
PLIB_OSC_DozeRecoverOnInterruptEnable function 5-2370
PLIB_OSC_DozeRecoverOnInterruptIsEnabled function 5-2371
PLIB_OSC_ExistsClockFail function 5-2408
PLIB_OSC_ExistsFRCDivisor function 5-2408
PLIB_OSC_ExistsFRCTuning function 5-2409
PLIB_OSC_ExistsOnWaitAction function 5-2409
PLIB_OSC_ExistsOscCurrentGet function 5-2410
PLIB_OSC_ExistsOscSelect function 5-2410
PLIB_OSC_ExistsOscSwitchInit function 5-2411
PLIB_OSC_ExistsPBClockDivisor function 5-2411
PLIB_OSC_ExistsPBClockOutputEnable function 5-2412
PLIB_OSC_ExistsPBClockReady function 5-2412
PLIB_OSC_ExistsPLLClockLock function 5-2413
PLIB_OSC_ExistsPLLLockStatus function 5-2413
PLIB_OSC_ExistsReferenceOscBaseClock function 5-2414
PLIB_OSC_ExistsReferenceOscChange function 5-2414
PLIB_OSC_ExistsReferenceOscChangeActive function 5-2415
PLIB_OSC_ExistsReferenceOscDivisor function 5-2415
PLIB_OSC_ExistsReferenceOscEnable function 5-2416
PLIB_OSC_ExistsReferenceOscStopInIdleEnable function
5-2416
PLIB_OSC_ExistsReferenceOscStopInSleep function 5-2417
PLIB_OSC_ExistsReferenceOscTrim function 5-2417
PLIB_OSC_ExistsReferenceOutputEnable function 5-2418
PLIB_OSC_ExistsSecondaryEnable function 5-2419
PLIB_OSC_ExistsSecondaryReady function 5-2419
PLIB_OSC_ExistsSysPLLFrequencyRange function 5-2420
PLIB_OSC_ExistsSysPLLInputClockSource function 5-2420
PLIB_OSC_ExistsSysPLLInputDivisor function 5-2421
PLIB_OSC_ExistsSysPLLMultiplier function 5-2421
PLIB_OSC_ExistsSysPLLOutputDivisor function 5-2422
PLIB_OSC_ExistsUsbClockSource function 5-2422
PLIB_OSC_FRCDitherEnable function 5-2359
PLIB_OSC_FRCDivisorGet function 5-2360
PLIB_OSC_FRCDivisorSelect function 5-2360
PLIB_OSC_FRCTuningModeGet function 5-2361
9 MPLAB Harmony Help
ccc
PLIB_OSC_FRCTuningModeSet function 5-2361
PLIB_OSC_FRCTuningSelect function 5-2362
PLIB_OSC_FRCTuningSequenceValueGet function 5-2362
PLIB_OSC_FRCTuningSequenceValueSet function 5-2363
PLIB_OSC_GraphicsClockDivisorGet function 5-2371
PLIB_OSC_GraphicsClockDivisorSet function 5-2372
PLIB_OSC_GraphicsClockSourceGet function 5-2372
PLIB_OSC_GraphicsClockSourceSelect function 5-2373
PLIB_OSC_LinearFeedbackShiftRegGet function 5-2364
PLIB_OSC_LinearFeedbackShiftRegSet function 5-2365
PLIB_OSC_OnWaitActionGet function 5-2342
PLIB_OSC_OnWaitActionSet function 5-2342
PLIB_OSC_PBClockDivisorGet function 5-2388
PLIB_OSC_PBClockDivisorIsReady function 5-2389
PLIB_OSC_PBClockDivisorSet function 5-2390
PLIB_OSC_PBOutputClockDisable function 5-2390
PLIB_OSC_PBOutputClockEnable function 5-2391
PLIB_OSC_PBOutputClockIsEnabled function 5-2391
PLIB_OSC_PLLAuxClockSourceGet function 5-2374
PLIB_OSC_PLLAuxClockSourceSelect function 5-2375
PLIB_OSC_PLLAuxInputDivisorGet function 5-2375
PLIB_OSC_PLLAuxInputDivisorSelect function 5-2376
PLIB_OSC_PLLAuxIsLocked function 5-2376
PLIB_OSC_PLLAuxMultiplierGet function 5-2377
PLIB_OSC_PLLAuxMultiplierSelect function 5-2378
PLIB_OSC_PLLAuxOutputDivisorGet function 5-2378
PLIB_OSC_PLLAuxOutputDivisorSet function 5-2379
PLIB_OSC_PLLClockIsLocked function 5-2379
PLIB_OSC_PLLClockLock function 5-2380
PLIB_OSC_PLLClockUnlock function 5-2380
PLIB_OSC_PLLDisable function 5-2381
PLIB_OSC_PLLEnable function 5-2381
PLIB_OSC_PLLIsEnabled function 5-2382
PLIB_OSC_PLLIsLocked function 5-2382
PLIB_OSC_PrimaryOscInSleepModeDisable function 5-2343
PLIB_OSC_PrimaryOscInSleepModeEnable function 5-2344
PLIB_OSC_PrimaryOscInSleepModeIsEnabled function 5-2344
PLIB_OSC_ReferenceOscBaseClockSelect function 5-2349
PLIB_OSC_ReferenceOscDisable function 5-2350
PLIB_OSC_ReferenceOscDivisorValueSet function 5-2350
PLIB_OSC_ReferenceOscEnable function 5-2351
PLIB_OSC_ReferenceOscIsEnabled function 5-2351
PLIB_OSC_ReferenceOscSourceChangeIsActive function
5-2352
PLIB_OSC_ReferenceOscStopInIdleDisable function 5-2353
PLIB_OSC_ReferenceOscStopInIdleEnable function 5-2353
PLIB_OSC_ReferenceOscStopInIdleIsEnabled function 5-2354
PLIB_OSC_ReferenceOscStopInSleepDisable function 5-2354
PLIB_OSC_ReferenceOscStopInSleepEnable function 5-2355
PLIB_OSC_ReferenceOscStopInSleepIsEnabled function
5-2356
PLIB_OSC_ReferenceOscSwitchIsComplete function 5-2356
PLIB_OSC_ReferenceOscTrimSet function 5-2357
PLIB_OSC_ReferenceOutputDisable function 5-2357
PLIB_OSC_ReferenceOutputEnable function 5-2358
PLIB_OSC_ReferenceOutputIsEnabled function 5-2358
PLIB_OSC_SecondaryDisable function 5-2345
PLIB_OSC_SecondaryEnable function 5-2345
PLIB_OSC_SecondaryIsEnabled function 5-2346
PLIB_OSC_SecondaryIsReady function 5-2346
PLIB_OSC_StartupTimerHasExpired function 5-2343
PLIB_OSC_SysClockSelect function 5-2367
PLIB_OSC_SysPLLFrequencyRangeGet function 5-2383
PLIB_OSC_SysPLLFrequencyRangeSet function 5-2383
PLIB_OSC_SysPLLInputClockSourceGet function 5-2384
PLIB_OSC_SysPLLInputClockSourceSet function 5-2384
PLIB_OSC_SysPLLInputDivisorGet function 5-2385
PLIB_OSC_SysPLLInputDivisorSet function 5-2386
PLIB_OSC_SysPLLMultiplierGet function 5-2386
PLIB_OSC_SysPLLMultiplierSelect function 5-2387
PLIB_OSC_SysPLLOutputDivisorGet function 5-2387
PLIB_OSC_SysPLLOutputDivisorSet function 5-2388
PLIB_OSC_UsbClockSourceGet function 5-2373
PLIB_OSC_UsbClockSourceSelect function 5-2374
plib_pcache.h 5-2475
PLIB_PCACHE_CacheHitRead function 5-2452
PLIB_PCACHE_CacheHitWrite function 5-2452
PLIB_PCACHE_CacheLineAddrGet function 5-2441
PLIB_PCACHE_CacheLineAddrSet function 5-2441
9 MPLAB Harmony Help
ddd
PLIB_PCACHE_CacheLineData function 5-2442
PLIB_PCACHE_CacheLineDeselect function 5-2442
PLIB_PCACHE_CacheLineFlashTypeBoot function 5-2443
PLIB_PCACHE_CacheLineFlashTypeInst function 5-2443
PLIB_PCACHE_CacheLineFlashTypeIsInst function 5-2444
PLIB_PCACHE_CacheLineInst function 5-2444
PLIB_PCACHE_CacheLineInvalid function 5-2445
PLIB_PCACHE_CacheLineIsInst function 5-2445
PLIB_PCACHE_CacheLineIsLocked function 5-2446
PLIB_PCACHE_CacheLineIsValid function 5-2447
PLIB_PCACHE_CacheLineLock function 5-2447
PLIB_PCACHE_CacheLineMaskGet function 5-2448
PLIB_PCACHE_CacheLineMaskSet function 5-2448
PLIB_PCACHE_CacheLineSelect function 5-2449
PLIB_PCACHE_CacheLineUnlock function 5-2449
PLIB_PCACHE_CacheLineValid function 5-2450
PLIB_PCACHE_CacheMissRead function 5-2453
PLIB_PCACHE_CacheMissWrite function 5-2453
PLIB_PCACHE_DATA_ENABLE enumeration 5-2463
PLIB_PCACHE_DataCacheEnableGet function 5-2437
PLIB_PCACHE_DataCacheEnableSet function 5-2438
PLIB_PCACHE_ExistsCacheHit function 5-2464
PLIB_PCACHE_ExistsCacheLine function 5-2465
PLIB_PCACHE_ExistsCacheLineAddr function 5-2465
PLIB_PCACHE_ExistsCacheLineFlashType function 5-2466
PLIB_PCACHE_ExistsCacheLineLock function 5-2466
PLIB_PCACHE_ExistsCacheLineMask function 5-2467
PLIB_PCACHE_ExistsCacheLineType function 5-2467
PLIB_PCACHE_ExistsCacheLineValid function 5-2468
PLIB_PCACHE_ExistsCacheMiss function 5-2468
PLIB_PCACHE_ExistsDataCacheEnable function 5-2469
PLIB_PCACHE_ExistsFlashDEDStatus function 5-2470
PLIB_PCACHE_ExistsFlashSECCount function 5-2470
PLIB_PCACHE_ExistsFlashSECInt function 5-2471
PLIB_PCACHE_ExistsFlashSECStatus function 5-2471
PLIB_PCACHE_ExistsInvalidateOnPFMProgram function
5-2472
PLIB_PCACHE_ExistsLeastRecentlyUsedState function 5-2472
PLIB_PCACHE_ExistsPrefetchAbort function 5-2473
PLIB_PCACHE_ExistsPrefetchEnable function 5-2473
PLIB_PCACHE_ExistsWaitState function 5-2474
PLIB_PCACHE_ExistsWord function 5-2474
PLIB_PCACHE_FlashDEDStatusClear function 5-2457
PLIB_PCACHE_FlashDEDStatusGet function 5-2457
PLIB_PCACHE_FlashSECCountGet function 5-2458
PLIB_PCACHE_FlashSECCountSet function 5-2458
PLIB_PCACHE_FlashSECIntDisable function 5-2459
PLIB_PCACHE_FlashSECIntEnable function 5-2460
PLIB_PCACHE_FlashSECStatusClear function 5-2460
PLIB_PCACHE_FlashSECStatusGet function 5-2461
PLIB_PCACHE_FlashSECStatusSet function 5-2461
PLIB_PCACHE_InvalidateOnPFMProgramAll function 5-2438
PLIB_PCACHE_InvalidateOnPFMProgramUnlocked function
5-2439
PLIB_PCACHE_LeastRecentlyUsedStateRead function 5-2454
PLIB_PCACHE_MAX_SEC_COUNT macro 5-2462
PLIB_PCACHE_NUM_LINES macro 5-2462
PLIB_PCACHE_NUM_WORDS_PER_LINE macro 5-2462
PLIB_PCACHE_PREFETCH_ENABLE enumeration 5-2463
PLIB_PCACHE_PrefetchAbortRead function 5-2456
PLIB_PCACHE_PrefetchAbortWrite function 5-2456
PLIB_PCACHE_PrefetchEnableGet function 5-2454
PLIB_PCACHE_PrefetchEnableSet function 5-2455
PLIB_PCACHE_WaitStateGet function 5-2439
PLIB_PCACHE_WaitStateSet function 5-2440
PLIB_PCACHE_WordRead function 5-2450
PLIB_PCACHE_WordWrite function 5-2451
plib_pmp.h 5-2588
PLIB_PMP_AddressGet function 5-2531
PLIB_PMP_AddressIncrementModeGet function 5-2494
PLIB_PMP_AddressIncrementModeSelect function 5-2495
PLIB_PMP_AddressLatchPolaritySelect function 5-2540
PLIB_PMP_AddressLatchStrobeDisable function 5-2496
PLIB_PMP_AddressLatchStrobeEnable function 5-2496
PLIB_PMP_AddressLinesA0A1Get function 5-2532
PLIB_PMP_AddressLinesA0A1Set function 5-2532
PLIB_PMP_AddressPortDisable function 5-2535
PLIB_PMP_AddressPortEnable function 5-2535
PLIB_PMP_AddressSet function 5-2533
PLIB_PMP_AlternateMasterHasAccess function 5-2513
9 MPLAB Harmony Help
eee
PLIB_PMP_AlternateMasterRequestStatus function 5-2514
PLIB_PMP_BusKeeperDisable function 5-2506
PLIB_PMP_BusKeeperEnable function 5-2506
PLIB_PMP_ByteEnablePolaritySelect function 5-2541
PLIB_PMP_ByteEnablePortDisable function 5-2536
PLIB_PMP_ByteEnablePortEnable function 5-2537
PLIB_PMP_ChipSelectFunctionSelect function 5-2497
PLIB_PMP_ChipSelectXAckPolaritySelect function 5-2543
PLIB_PMP_ChipSelectXByteEnablePortPolaritySelect function
5-2544
PLIB_PMP_ChipSelectXDisable function 5-2497
PLIB_PMP_ChipSelectXEnable function 5-2498
PLIB_PMP_ChipSelectXEnableStrobeDeSelect function 5-2507
PLIB_PMP_ChipSelectXEnableStrobeSelect function 5-2508
PLIB_PMP_ChipSelectXIsActive function 5-2499
PLIB_PMP_ChipSelectXPolaritySelect function 5-2542
PLIB_PMP_ChipSelectXPortDisable function 5-2539
PLIB_PMP_ChipSelectXPortEnable function 5-2540
PLIB_PMP_ChipSelectXReadWriteStrobePolaritySelect
function 5-2545
PLIB_PMP_ChipSelectXWriteEnableStrobePolaritySelect
function 5-2545
PLIB_PMP_ChipXAckModeSelect function 5-2509
PLIB_PMP_ChipXBaseAddressSet function 5-2534
PLIB_PMP_ChipXDataSizeSelect function 5-2510
PLIB_PMP_ChipXWaitStatesAlternateMasterSelect function
5-2527
PLIB_PMP_ChipXWaitStatesDataHoldSelect function 5-2528
PLIB_PMP_ChipXWaitStatesDataSetupSelect function 5-2529
PLIB_PMP_ChipXWaitStatesStrobeSelect function 5-2529
PLIB_PMP_DataSizeSelect function 5-2499
PLIB_PMP_Disable function 5-2500
PLIB_PMP_Enable function 5-2500
PLIB_PMP_EnhancedMasterModeSelect function 5-2510
PLIB_PMP_ExistsAddressControl function 5-2557
PLIB_PMP_ExistsAddressLatchPolarity function 5-2557
PLIB_PMP_ExistsAddressLatchStrobePortControl function
5-2558
PLIB_PMP_ExistsAddressPortPinControl function 5-2558
PLIB_PMP_ExistsAltMasterRequest function 5-2559
PLIB_PMP_ExistsBufferOverFlow function 5-2560
PLIB_PMP_ExistsBufferRead function 5-2560
PLIB_PMP_ExistsBufferType function 5-2561
PLIB_PMP_ExistsBufferUnderFlow function 5-2561
PLIB_PMP_ExistsBufferWrite function 5-2562
PLIB_PMP_ExistsBusKeeper function 5-2562
PLIB_PMP_ExistsBusyStatus function 5-2563
PLIB_PMP_ExistsByteEnablePolarity function 5-2563
PLIB_PMP_ExistsByteEnablePortControl function 5-2564
PLIB_PMP_ExistsChipSelectEnable function 5-2564
PLIB_PMP_ExistsChipSelectoperation function 5-2565
PLIB_PMP_ExistsChipXACKMode function 5-2565
PLIB_PMP_ExistsChipXACKPolarity function 5-2566
PLIB_PMP_ExistsChipXAltMasterWaitStates function 5-2566
PLIB_PMP_ExistsChipXBaseAddress function 5-2567
PLIB_PMP_ExistsChipXByteEnablePolarity function 5-2567
PLIB_PMP_ExistsChipXDataHoldWaitStates function 5-2568
PLIB_PMP_ExistsChipXDataSetupWaitStates function 5-2568
PLIB_PMP_ExistsChipXDataSize function 5-2569
PLIB_PMP_ExistsChipXEnableStorbeSelect function 5-2569
PLIB_PMP_ExistsChipXPolarity function 5-2570
PLIB_PMP_ExistsChipXReadWritePolarity function 5-2570
PLIB_PMP_ExistsChipXStrobeWaitStates function 5-2571
PLIB_PMP_ExistsChipXWriteEnablePolarity function 5-2571
PLIB_PMP_ExistsCSXActiveStatus function 5-2572
PLIB_PMP_ExistsCSXPortControl function 5-2572
PLIB_PMP_ExistsCurrentMaster function 5-2573
PLIB_PMP_ExistsDataHoldWaitStates function 5-2573
PLIB_PMP_ExistsDataSetUpWaitStates function 5-2574
PLIB_PMP_ExistsDataStrobeWaitStates function 5-2574
PLIB_PMP_ExistsDataTransferSize function 5-2575
PLIB_PMP_ExistsEnableControl function 5-2575
PLIB_PMP_ExistsEnhancedMasterMode function 5-2576
PLIB_PMP_ExistsIncrementMode function 5-2576
PLIB_PMP_ExistsInputBufferFull function 5-2577
PLIB_PMP_ExistsInputBufferXStatus function 5-2577
PLIB_PMP_ExistsInterruptMode function 5-2578
PLIB_PMP_ExistsMasterRXTX function 5-2578
PLIB_PMP_ExistsMUXModeSelect function 5-2579
PLIB_PMP_ExistsOperationMode function 5-2579
9 MPLAB Harmony Help
fff
PLIB_PMP_ExistsOutPutBufferEmpty function 5-2580
PLIB_PMP_ExistsOutputBufferXStatus function 5-2580
PLIB_PMP_ExistsReadWritePolarity function 5-2581
PLIB_PMP_ExistsReadWriteStrobePortControl function 5-2581
PLIB_PMP_ExistsReservedAddrSpace function 5-2582
PLIB_PMP_ExistsSlaveRX function 5-2582
PLIB_PMP_ExistsSlaveTX function 5-2583
PLIB_PMP_ExistsSmartAddress function 5-2583
PLIB_PMP_ExistsStopInIdleControl function 5-2584
PLIB_PMP_ExistsTransactionError function 5-2584
PLIB_PMP_ExistsTransactionTimeOut function 5-2585
PLIB_PMP_ExistsWaitStatesAddrHoldStrobe function 5-2585
PLIB_PMP_ExistsWaitStatesAddrLatchStrobe function 5-2586
PLIB_PMP_ExistsWriteEnablePolarity function 5-2586
PLIB_PMP_ExistsWriteEnablePortControl function 5-2587
PLIB_PMP_InputBuffersAreFull function 5-2518
PLIB_PMP_InputBufferTypeSelect function 5-2501
PLIB_PMP_InputBufferXByteReceive function 5-2519
PLIB_PMP_InputBufferXIsFull function 5-2519
PLIB_PMP_InputOverflowClear function 5-2515
PLIB_PMP_InputOverflowHasOccurred function 5-2512
PLIB_PMP_InterruptModeGet function 5-2502
PLIB_PMP_InterruptModeSelect function 5-2502
PLIB_PMP_IsDataReceived function 5-2520
PLIB_PMP_IsDataTransmitted function 5-2521
PLIB_PMP_IsEnabled function 5-2511
PLIB_PMP_MasterReceive function 5-2521
PLIB_PMP_MasterSend function 5-2522
PLIB_PMP_MultiplexModeGet function 5-2503
PLIB_PMP_MultiplexModeSelect function 5-2503
PLIB_PMP_OperationModeGet function 5-2504
PLIB_PMP_OperationModeSelect function 5-2504
PLIB_PMP_OutputBuffersAreEmpty function 5-2522
PLIB_PMP_OutputBufferXByteSend function 5-2523
PLIB_PMP_OutputBufferXIsEmpty function 5-2524
PLIB_PMP_OutputUnderflowClear function 5-2515
PLIB_PMP_OutputUnderflowHasOccurred function 5-2513
PLIB_PMP_PortIsBusy function 5-2512
PLIB_PMP_ReadWriteStrobePolaritySelect function 5-2542
PLIB_PMP_ReadWriteStrobePortDisable function 5-2537
PLIB_PMP_ReadWriteStrobePortEnable function 5-2538
PLIB_PMP_ReservedAddressSpaceBitsSet function 5-2534
PLIB_PMP_SlaveReceive function 5-2524
PLIB_PMP_SlaveSend function 5-2525
PLIB_PMP_SmartAddressStrobeDisable function 5-2508
PLIB_PMP_SmartAddressStrobeEnable function 5-2509
PLIB_PMP_StopInIdleDisable function 5-2505
PLIB_PMP_StopInIdleEnable function 5-2505
PLIB_PMP_TransactionErrorClear function 5-2516
PLIB_PMP_TransactionErrorHasOccurred function 5-2516
PLIB_PMP_TransactionHasTimedOut function 5-2517
PLIB_PMP_TransactionTimeoutClear function 5-2517
PLIB_PMP_WaitStatesAddressHoldStrobeSelect function
5-2530
PLIB_PMP_WaitStatesAddressLatchStrobeSelect function
5-2531
PLIB_PMP_WaitStatesDataHoldSelect function 5-2526
PLIB_PMP_WaitStatesDataSetUpSelect function 5-2526
PLIB_PMP_WaitStatesStrobeSelect function 5-2527
PLIB_PMP_WriteEnableStrobePolaritySelect function 5-2543
PLIB_PMP_WriteEnableStrobePortDisable function 5-2538
PLIB_PMP_WriteEnableStrobePortEnable function 5-2539
plib_ports.h 5-2659
PLIB_PORTS_ChangeNoticeDisable function 5-2618
PLIB_PORTS_ChangeNoticeEnable function 5-2618
PLIB_PORTS_ChangeNoticeInIdleDisable function 5-2619
PLIB_PORTS_ChangeNoticeInIdleEnable function 5-2619
PLIB_PORTS_ChangeNoticeInIdlePerPortDisable function
5-2620
PLIB_PORTS_ChangeNoticeInIdlePerPortEnable function
5-2620
PLIB_PORTS_ChangeNoticePerPortHasOccured function
5-2621
PLIB_PORTS_ChangeNoticePerPortTurnOff function 5-2622
PLIB_PORTS_ChangeNoticePerPortTurnOn function 5-2622
PLIB_PORTS_ChangeNoticePullDownPerPortDisable function
5-2623
PLIB_PORTS_ChangeNoticePullDownPerPortEnable function
5-2624
PLIB_PORTS_ChangeNoticePullUpDisable function 5-2624
PLIB_PORTS_ChangeNoticePullUpEnable function 5-2625
9 MPLAB Harmony Help
ggg
PLIB_PORTS_ChangeNoticePullUpPerPortDisable function
5-2625
PLIB_PORTS_ChangeNoticePullUpPerPortEnable function
5-2626
PLIB_PORTS_Clear function 5-2609
PLIB_PORTS_DirectionGet function 5-2610
PLIB_PORTS_DirectionInputSet function 5-2610
PLIB_PORTS_DirectionOutputSet function 5-2611
PLIB_PORTS_ExistsChangeNotice function 5-2650
PLIB_PORTS_ExistsChangeNoticeInIdle function 5-2650
PLIB_PORTS_ExistsChangeNoticePerPortInIdle function
5-2651
PLIB_PORTS_ExistsChangeNoticePerPortStatus function
5-2651
PLIB_PORTS_ExistsChangeNoticePerPortTurnOn function
5-2652
PLIB_PORTS_ExistsChangeNoticePullDownPerPort function
5-2652
PLIB_PORTS_ExistsChangeNoticePullUp function 5-2653
PLIB_PORTS_ExistsChangeNoticePullUpPerPort function
5-2653
PLIB_PORTS_ExistsPinChangeNotice function 5-2654
PLIB_PORTS_ExistsPinChangeNoticePerPort function 5-2654
PLIB_PORTS_ExistsPinMode function 5-2655
PLIB_PORTS_ExistsPinModePerPort function 5-2655
PLIB_PORTS_ExistsPortsDirection function 5-2656
PLIB_PORTS_ExistsPortsOpenDrain function 5-2656
PLIB_PORTS_ExistsPortsRead function 5-2657
PLIB_PORTS_ExistsPortsWrite function 5-2658
PLIB_PORTS_ExistsRemapInput function 5-2658
PLIB_PORTS_ExistsRemapOutput function 5-2659
PLIB_PORTS_OpenDrainDisable function 5-2615
PLIB_PORTS_OpenDrainEnable function 5-2616
PLIB_PORTS_PinChangeNoticeDisable function 5-2627
PLIB_PORTS_PinChangeNoticeEnable function 5-2627
PLIB_PORTS_PinChangeNoticePerPortDisable function 5-2628
PLIB_PORTS_PinChangeNoticePerPortEnable function 5-2628
PLIB_PORTS_PinClear function 5-2603
PLIB_PORTS_PinDirectionInputSet function 5-2604
PLIB_PORTS_PinDirectionOutputSet function 5-2605
PLIB_PORTS_PinGet function 5-2605
PLIB_PORTS_PinModePerPortSelect function 5-2608
PLIB_PORTS_PinModeSelect function 5-2606
PLIB_PORTS_PinOpenDrainDisable function 5-2611
PLIB_PORTS_PinOpenDrainEnable function 5-2612
PLIB_PORTS_PinSet function 5-2606
PLIB_PORTS_PinToggle function 5-2607
PLIB_PORTS_PinWrite function 5-2608
PLIB_PORTS_Read function 5-2613
PLIB_PORTS_RemapInput function 5-2616
PLIB_PORTS_RemapOutput function 5-2617
PLIB_PORTS_Set function 5-2613
PLIB_PORTS_Toggle function 5-2614
PLIB_PORTS_Write function 5-2614
plib_power.h 5-2686
PLIB_POWER_ClearIdleStatus function 5-2672
PLIB_POWER_ClearSleepStatus function 5-2673
PLIB_POWER_DeepSleepBORDisable function 5-2668
PLIB_POWER_DeepSleepBOREnable function 5-2668
PLIB_POWER_DeepSleepFaultDetectStatus function 5-2673
PLIB_POWER_DeepSleepInterruptOnChangeStatus function
5-2674
PLIB_POWER_DeepSleepMCLREventStatus function 5-2675
PLIB_POWER_DeepSleepModeDisable function 5-2669
PLIB_POWER_DeepSleepModeEnable function 5-2669
PLIB_POWER_DeepSleepPowerOnResetStatus function
5-2675
PLIB_POWER_DeviceWasInIdleMode function 5-2676
PLIB_POWER_DeviceWasInSleepMode function 5-2676
PLIB_POWER_ExistsDeepSleepBOR function 5-2681
PLIB_POWER_ExistsDeepSleepFaultDetect function 5-2681
PLIB_POWER_ExistsDeepSleepInterruptOnChange function
5-2682
PLIB_POWER_ExistsDeepSleepMCLREvent function 5-2682
PLIB_POWER_ExistsDeepSleepMode function 5-2683
PLIB_POWER_ExistsDeepSleepPowerOnReset function 5-2683
PLIB_POWER_ExistsIdleStatus function 5-2684
PLIB_POWER_ExistsPeripheralModuleControl function 5-2684
PLIB_POWER_ExistsSleepStatus function 5-2685
PLIB_POWER_ExistsVoltageRegulatorControl function 5-2685
PLIB_POWER_PeripheralModuleDisable function 5-2670
PLIB_POWER_PeripheralModuleEnable function 5-2670
9 MPLAB Harmony Help
hhh
PLIB_POWER_PeripheralModuleIsEnabled function 5-2671
PLIB_POWER_VoltageRegulatorDisable function 5-2671
PLIB_POWER_VoltageRegulatorEnable function 5-2672
PLIB_POWER_VoltageRegulatorIsEnabled function 5-2677
plib_reset.h 5-2702
PLIB_RESET_ConfigRegReadErrorGet function 5-2693
PLIB_RESET_ExistsConfigRegReadError function 5-2697
PLIB_RESET_ExistsNmiControl function 5-2698
PLIB_RESET_ExistsNmiCounter function 5-2698
PLIB_RESET_ExistsResetReasonStatus function 5-2696
PLIB_RESET_ExistsSoftwareResetTrigger function 5-2697
PLIB_RESET_ExistsWdtoInSleep function 5-2699
PLIB_RESET_NmiCounterValueGet function 5-2699
PLIB_RESET_NmiCounterValueSet function 5-2700
PLIB_RESET_NmiEventClear function 5-2701
PLIB_RESET_NmiEventTrigger function 5-2701
PLIB_RESET_NmiReasonGet function 5-2702
PLIB_RESET_ReasonClear function 5-2692
PLIB_RESET_ReasonGet function 5-2692
PLIB_RESET_SoftwareResetEnable function 5-2691
PLIB_RESET_WdtTimeOutHasOccurredInSleep function
5-2693
plib_rtcc.h 5-2759
PLIB_RTCC_AlarmChimeDisable function 5-2729
PLIB_RTCC_AlarmChimeEnable function 5-2729
PLIB_RTCC_AlarmDateGet function 5-2730
PLIB_RTCC_AlarmDateSet function 5-2730
PLIB_RTCC_AlarmDayGet function 5-2731
PLIB_RTCC_AlarmDaySet function 5-2731
PLIB_RTCC_AlarmDisable function 5-2732
PLIB_RTCC_AlarmEnable function 5-2732
PLIB_RTCC_AlarmHourGet function 5-2733
PLIB_RTCC_AlarmHourSet function 5-2734
PLIB_RTCC_AlarmMaskModeSelect function 5-2734
PLIB_RTCC_AlarmMinuteGet function 5-2735
PLIB_RTCC_AlarmMinuteSet function 5-2735
PLIB_RTCC_AlarmMonthGet function 5-2736
PLIB_RTCC_AlarmMonthSet function 5-2736
PLIB_RTCC_AlarmPulseInitialGet function 5-2737
PLIB_RTCC_AlarmPulseInitialSet function 5-2737
PLIB_RTCC_AlarmRepeatCountGet function 5-2738
PLIB_RTCC_AlarmRepeatCountSet function 5-2739
PLIB_RTCC_AlarmSecondGet function 5-2739
PLIB_RTCC_AlarmSecondSet function 5-2740
PLIB_RTCC_AlarmTimeGet function 5-2740
PLIB_RTCC_AlarmTimeSet function 5-2741
PLIB_RTCC_AlarmValueRegisterPointer function 5-2741
PLIB_RTCC_AlarmWeekDayGet function 5-2742
PLIB_RTCC_AlarmWeekDaySet function 5-2742
PLIB_RTCC_ClockOutputDisable function 5-2715
PLIB_RTCC_ClockOutputEnable function 5-2716
PLIB_RTCC_ClockRunningStatus function 5-2716
PLIB_RTCC_ClockSourceSelect function 5-2743
PLIB_RTCC_Disable function 5-2717
PLIB_RTCC_DriftCalibrateGet function 5-2744
PLIB_RTCC_DriftCalibrateSet function 5-2744
PLIB_RTCC_Enable function 5-2717
PLIB_RTCC_ExistsAlarmChimeControl function 5-2749
PLIB_RTCC_ExistsAlarmControl function 5-2749
PLIB_RTCC_ExistsAlarmDate function 5-2750
PLIB_RTCC_ExistsAlarmMaskControl function 5-2750
PLIB_RTCC_ExistsAlarmPulseInitial function 5-2751
PLIB_RTCC_ExistsAlarmRepeatControl function 5-2751
PLIB_RTCC_ExistsAlarmSyncronization function 5-2752
PLIB_RTCC_ExistsAlarmTime function 5-2752
PLIB_RTCC_ExistsCalibration function 5-2753
PLIB_RTCC_ExistsClockRunning function 5-2753
PLIB_RTCC_ExistsClockSelect function 5-2754
PLIB_RTCC_ExistsEnableControl function 5-2754
PLIB_RTCC_ExistsHalfSecond function 5-2755
PLIB_RTCC_ExistsOutputControl function 5-2755
PLIB_RTCC_ExistsOutputSelect function 5-2756
PLIB_RTCC_ExistsRTCDate function 5-2756
PLIB_RTCC_ExistsRTCTime function 5-2757
PLIB_RTCC_ExistsStopInIdleControl function 5-2757
PLIB_RTCC_ExistsSynchronization function 5-2758
PLIB_RTCC_ExistsWriteEnable function 5-2758
PLIB_RTCC_HalfSecondStatusGet function 5-2745
PLIB_RTCC_OutputSelect function 5-2745
9 MPLAB Harmony Help
iii
PLIB_RTCC_RTCDateGet function 5-2719
PLIB_RTCC_RTCDateSet function 5-2719
PLIB_RTCC_RTCDayGet function 5-2720
PLIB_RTCC_RTCDaySet function 5-2720
PLIB_RTCC_RTCHourGet function 5-2721
PLIB_RTCC_RTCHourSet function 5-2722
PLIB_RTCC_RTCMinuteGet function 5-2722
PLIB_RTCC_RTCMinuteSet function 5-2723
PLIB_RTCC_RTCMonthGet function 5-2723
PLIB_RTCC_RTCMonthSet function 5-2724
PLIB_RTCC_RTCSecondGet function 5-2724
PLIB_RTCC_RTCSecondSet function 5-2725
PLIB_RTCC_RTCTimeGet function 5-2725
PLIB_RTCC_RTCTimeSet function 5-2726
PLIB_RTCC_RTCWeekDayGet function 5-2726
PLIB_RTCC_RTCWeekDaySet function 5-2727
PLIB_RTCC_RTCYearGet function 5-2727
PLIB_RTCC_RTCYearSet function 5-2728
PLIB_RTCC_StopInIdleDisable function 5-2746
PLIB_RTCC_StopInIdleEnable function 5-2746
PLIB_RTCC_WriteDisable function 5-2718
PLIB_RTCC_WriteEnable function 5-2718
plib_sb.h 5-2796
PLIB_SB_ARB_POLICY enumeration 5-2781
PLIB_SB_CPUPrioritySet function 5-2786
PLIB_SB_DMAPrioritySet function 5-2786
PLIB_SB_ERROR enumeration 5-2781
PLIB_SB_ExistsCPUPriority function 5-2788
PLIB_SB_ExistsDMAPriority function 5-2788
PLIB_SB_ExistsInitPermGrp function 5-2789
PLIB_SB_ExistsPGRegAddr function 5-2789
PLIB_SB_ExistsPGRegRdPerm function 5-2790
PLIB_SB_ExistsPGRegSize function 5-2790
PLIB_SB_ExistsPGRegWrPerm function 5-2791
PLIB_SB_ExistsPGVErrClear function 5-2791
PLIB_SB_ExistsPGVErrClrMulti function 5-2792
PLIB_SB_ExistsPGVErrClrSingle function 5-2793
PLIB_SB_ExistsPGVErrCmdCode function 5-2793
PLIB_SB_ExistsPGVErrInitID function 5-2794
PLIB_SB_ExistsPGVErrPG function 5-2794
PLIB_SB_ExistsPGVErrRegion function 5-2795
PLIB_SB_ExistsPGVErrRptPri function 5-2795
PLIB_SB_ExistsPGVErrStatus function 5-2796
PLIB_SB_INIT_ID enumeration 5-2781
PLIB_SB_INIT_PG enumeration 5-2782
PLIB_SB_InitPermGrpSet function 5-2787
PLIB_SB_OCP_CMD_CODE enumeration 5-2782
PLIB_SB_PG_INITIATOR enumeration 5-2782
PLIB_SB_PGRegionAddrGet function 5-2768
PLIB_SB_PGRegionAddrSet function 5-2769
PLIB_SB_PGRegionReadPermClear function 5-2770
PLIB_SB_PGRegionReadPermSet function 5-2770
PLIB_SB_PGRegionSizeGet function 5-2771
PLIB_SB_PGRegionSizeSet function 5-2771
PLIB_SB_PGRegionWritePermClear function 5-2772
PLIB_SB_PGRegionWritePermSet function 5-2773
PLIB_SB_PGVErrorClearMulti function 5-2773
PLIB_SB_PGVErrorClearSingle function 5-2774
PLIB_SB_PGVErrorCode function 5-2775
PLIB_SB_PGVErrorCommandCode function 5-2775
PLIB_SB_PGVErrorInitiatorID function 5-2776
PLIB_SB_PGVErrorLogClearMulti function 5-2776
PLIB_SB_PGVErrorLogClearSingle function 5-2777
PLIB_SB_PGVErrorMulti function 5-2777
PLIB_SB_PGVErrorPermissionGroup function 5-2778
PLIB_SB_PGVErrorRegion function 5-2778
PLIB_SB_PGVErrorReportPrimaryDisable function 5-2779
PLIB_SB_PGVErrorReportPrimaryEnable function 5-2779
PLIB_SB_PGVErrorStatus function 5-2780
PLIB_SB_REGION_PG enumeration 5-2783
PLIB_SB_TGT_ID enumeration 5-2783
PLIB_SB_TGT_REGION enumeration 5-2784
plib_spi.h 5-2888
PLIB_SPI_AudioCommunicationWidthSelect function 5-2850
PLIB_SPI_AudioErrorDisable function 5-2851
PLIB_SPI_AudioErrorEnable function 5-2851
PLIB_SPI_AudioProtocolDisable function 5-2852
PLIB_SPI_AudioProtocolEnable function 5-2852
9 MPLAB Harmony Help
jjj
PLIB_SPI_AudioProtocolModeSelect function 5-2853
PLIB_SPI_AudioTransmitModeSelect function 5-2854
PLIB_SPI_BaudRateClockSelect function 5-2827
PLIB_SPI_BaudRateSet function 5-2828
PLIB_SPI_BufferClear function 5-2843
PLIB_SPI_BufferRead function 5-2844
PLIB_SPI_BufferWrite function 5-2844
PLIB_SPI_ClockPolaritySelect function 5-2829
PLIB_SPI_CommunicationWidthSelect function 5-2829
PLIB_SPI_Disable function 5-2830
PLIB_SPI_Enable function 5-2830
PLIB_SPI_ErrorInterruptDisable function 5-2831
PLIB_SPI_ErrorInterruptEnable function 5-2832
PLIB_SPI_ExistsAudioCommunicationWidth function 5-2868
PLIB_SPI_ExistsAudioErrorControl function 5-2868
PLIB_SPI_ExistsAudioProtocolControl function 5-2869
PLIB_SPI_ExistsAudioProtocolMode function 5-2869
PLIB_SPI_ExistsAudioTransmitMode function 5-2870
PLIB_SPI_ExistsBaudRate function 5-2870
PLIB_SPI_ExistsBaudRateClock function 5-2871
PLIB_SPI_ExistsBuffer function 5-2871
PLIB_SPI_ExistsBusStatus function 5-2872
PLIB_SPI_ExistsClockPolarity function 5-2872
PLIB_SPI_ExistsCommunicationWidth function 5-2873
PLIB_SPI_ExistsEnableControl function 5-2873
PLIB_SPI_ExistsErrorInterruptControl function 5-2874
PLIB_SPI_ExistsFIFOControl function 5-2874
PLIB_SPI_ExistsFIFOCount function 5-2875
PLIB_SPI_ExistsFIFOInterruptMode function 5-2875
PLIB_SPI_ExistsFIFOShiftRegisterEmptyStatus function 5-2876
PLIB_SPI_ExistsFramedCommunication function 5-2876
PLIB_SPI_ExistsFrameErrorStatus function 5-2877
PLIB_SPI_ExistsFrameSyncPulseCounter function 5-2877
PLIB_SPI_ExistsFrameSyncPulseDirection function 5-2878
PLIB_SPI_ExistsFrameSyncPulseEdge function 5-2878
PLIB_SPI_ExistsFrameSyncPulsePolarity function 5-2879
PLIB_SPI_ExistsFrameSyncPulseWidth function 5-2879
PLIB_SPI_ExistsInputSamplePhase function 5-2880
PLIB_SPI_ExistsMasterControl function 5-2880
PLIB_SPI_ExistsOutputDataPhase function 5-2881
PLIB_SPI_ExistsPinControl function 5-2881
PLIB_SPI_ExistsPrimaryPrescale function 5-2882
PLIB_SPI_ExistsReadDataSignStatus function 5-2882
PLIB_SPI_ExistsReceiveBufferStatus function 5-2883
PLIB_SPI_ExistsReceiveFIFOStatus function 5-2883
PLIB_SPI_ExistsReceiverOverflow function 5-2884
PLIB_SPI_ExistsSecondaryPrescale function 5-2884
PLIB_SPI_ExistsSlaveSelectControl function 5-2885
PLIB_SPI_ExistsStopInIdleControl function 5-2885
PLIB_SPI_ExistsTransmitBufferEmptyStatus function 5-2886
PLIB_SPI_ExistsTransmitBufferFullStatus function 5-2886
PLIB_SPI_ExistsTransmitUnderRunStatus function 5-2887
PLIB_SPI_FIFOCountGet function 5-2832
PLIB_SPI_FIFODisable function 5-2833
PLIB_SPI_FIFOEnable function 5-2833
PLIB_SPI_FIFOInterruptModeSelect function 5-2834
PLIB_SPI_FIFOShiftRegisterIsEmpty function 5-2835
PLIB_SPI_FramedCommunicationDisable function 5-2845
PLIB_SPI_FramedCommunicationEnable function 5-2846
PLIB_SPI_FrameErrorStatusGet function 5-2846
PLIB_SPI_FrameSyncPulseCounterSelect function 5-2847
PLIB_SPI_FrameSyncPulseDirectionSelect function 5-2847
PLIB_SPI_FrameSyncPulseEdgeSelect function 5-2848
PLIB_SPI_FrameSyncPulsePolaritySelect function 5-2849
PLIB_SPI_FrameSyncPulseWidthSelect function 5-2849
PLIB_SPI_InputSamplePhaseSelect function 5-2835
PLIB_SPI_IsBusy function 5-2836
PLIB_SPI_MasterEnable function 5-2836
PLIB_SPI_OutputDataPhaseSelect function 5-2837
PLIB_SPI_PinDisable function 5-2838
PLIB_SPI_PinEnable function 5-2838
PLIB_SPI_PrescalePrimarySelect function 5-2839
PLIB_SPI_PrescaleSecondarySelect function 5-2839
PLIB_SPI_ReadDataIsSignExtended function 5-2840
PLIB_SPI_ReceiverBufferIsFull function 5-2856
PLIB_SPI_ReceiverFIFOIsEmpty function 5-2857
PLIB_SPI_ReceiverHasOverflowed function 5-2857
PLIB_SPI_ReceiverOverflowClear function 5-2858
9 MPLAB Harmony Help
kkk
PLIB_SPI_SlaveEnable function 5-2841
PLIB_SPI_SlaveSelectDisable function 5-2841
PLIB_SPI_SlaveSelectEnable function 5-2842
PLIB_SPI_StopInIdleDisable function 5-2842
PLIB_SPI_StopInIdleEnable function 5-2843
PLIB_SPI_TransmitBufferIsEmpty function 5-2854
PLIB_SPI_TransmitBufferIsFull function 5-2855
PLIB_SPI_TransmitUnderRunStatusGet function 5-2855
plib_sqi.h 5-3006
PLIB_SQI_BurstEnable function 5-2908
PLIB_SQI_ByteCountGet function 5-2937
PLIB_SQI_ByteCountSet function 5-2938
PLIB_SQI_ChipSelectDeassertDisable function 5-2938
PLIB_SQI_ChipSelectDeassertEnable function 5-2939
PLIB_SQI_ChipSelectGet function 5-2940
PLIB_SQI_ChipSelectSet function 5-2940
PLIB_SQI_ClockDisable function 5-2909
PLIB_SQI_ClockDividerGet function 5-2925
PLIB_SQI_ClockDividerSet function 5-2925
PLIB_SQI_ClockEnable function 5-2926
PLIB_SQI_ClockIsStable function 5-2926
PLIB_SQI_ConfigWordGet function 5-2941
PLIB_SQI_ConfigWordSet function 5-2941
PLIB_SQI_ControlBufferThresholdGet function 5-2909
PLIB_SQI_ControlBufferThresholdSet function 5-2910
PLIB_SQI_ControlWordGet function 5-2910
PLIB_SQI_ControlWordSet function 5-2911
PLIB_SQI_CSOutputEnableSelect function 5-2912
PLIB_SQI_DataFormatGet function 5-2912
PLIB_SQI_DataFormatSet function 5-2913
PLIB_SQI_DataLineStatus function 5-2949
PLIB_SQI_DataModeGet function 5-2913
PLIB_SQI_DataModeSet function 5-2914
PLIB_SQI_DataOutputEnableSelect function 5-2914
PLIB_SQI_Disable function 5-2915
PLIB_SQI_DMABDBaseAddressGet function 5-2954
PLIB_SQI_DMABDBaseAddressSet function 5-2955
PLIB_SQI_DMABDControlWordGet function 5-2956
PLIB_SQI_DMABDCurrentAddressGet function 5-2955
PLIB_SQI_DMABDFetchStart function 5-2960
PLIB_SQI_DMABDIsBusy function 5-2960
PLIB_SQI_DMABDPollCounterSet function 5-2961
PLIB_SQI_DMABDPollDisable function 5-2962
PLIB_SQI_DMABDPollEnable function 5-2962
PLIB_SQI_DMABDPollIsEnabled function 5-2963
PLIB_SQI_DMABDReceiveBufferCountGet function 5-2957
PLIB_SQI_DMABDReceiveBufferLengthGet function 5-2957
PLIB_SQI_DMABDReceiveStateGet function 5-2958
PLIB_SQI_DMABDStateGet function 5-2963
PLIB_SQI_DMABDTransmitBufferCountGet function 5-2958
PLIB_SQI_DMABDTransmitBufferLengthGet function 5-2959
PLIB_SQI_DMABDTransmitStateGet function 5-2959
PLIB_SQI_DMADisable function 5-2964
PLIB_SQI_DMAEnable function 5-2964
PLIB_SQI_DMAHasStarted function 5-2965
PLIB_SQI_DMAIsEnabled function 5-2965
PLIB_SQI_Enable function 5-2915
PLIB_SQI_ExistsBDBaseAddress function 5-2974
PLIB_SQI_ExistsBDControlWord function 5-2975
PLIB_SQI_ExistsBDCurrentAddress function 5-2975
PLIB_SQI_ExistsBDPollCount function 5-2976
PLIB_SQI_ExistsBDPollingEnable function 5-2976
PLIB_SQI_ExistsBDProcessState function 5-2977
PLIB_SQI_ExistsBDRxBufCount function 5-2977
PLIB_SQI_ExistsBDRxLength function 5-2978
PLIB_SQI_ExistsBDRxState function 5-2978
PLIB_SQI_ExistsBDTxBufCount function 5-2979
PLIB_SQI_ExistsBDTxLength function 5-2979
PLIB_SQI_ExistsBDTxState function 5-2980
PLIB_SQI_ExistsBurstControl function 5-2980
PLIB_SQI_ExistsChipSelect function 5-2981
PLIB_SQI_ExistsClockControl function 5-2981
PLIB_SQI_ExistsClockDivider function 5-2982
PLIB_SQI_ExistsClockReady function 5-2982
PLIB_SQI_ExistsConBufThreshold function 5-2983
PLIB_SQI_ExistsConfigWord function 5-2983
PLIB_SQI_ExistsControlWord function 5-2984
PLIB_SQI_ExistsCSDeassert function 5-2984
9 MPLAB Harmony Help
lll
PLIB_SQI_ExistsCSOutputEnable function 5-2985
PLIB_SQI_ExistsDataFormat function 5-2985
PLIB_SQI_ExistsDataModeControl function 5-2986
PLIB_SQI_ExistsDataOutputEnable function 5-2986
PLIB_SQI_ExistsDataPinStatus function 5-2987
PLIB_SQI_ExistsDmaEnable function 5-2987
PLIB_SQI_ExistsDMAEngineBusy function 5-2988
PLIB_SQI_ExistsDMAProcessInProgress function 5-2988
PLIB_SQI_ExistsEnableControl function 5-2989
PLIB_SQI_ExistsHoldPinControl function 5-2989
PLIB_SQI_ExistsInterruptControl function 5-2990
PLIB_SQI_ExistsInterruptSignalControl function 5-2990
PLIB_SQI_ExistsInterruptStatus function 5-2991
PLIB_SQI_ExistsLaneMode function 5-2992
PLIB_SQI_ExistsReceiveLatch function 5-2992
PLIB_SQI_ExistsRxBufferCount function 5-2993
PLIB_SQI_ExistsRxBufIntThreshold function 5-2993
PLIB_SQI_ExistsRxBufThreshold function 5-2994
PLIB_SQI_ExistsRxData function 5-2994
PLIB_SQI_ExistsRxUnderRun function 5-2995
PLIB_SQI_ExistsSoftReset function 5-2995
PLIB_SQI_ExistsStartDMA function 5-2996
PLIB_SQI_ExistsTransferCommand function 5-2996
PLIB_SQI_ExistsTransferCount function 5-2997
PLIB_SQI_ExistsTransferModeControl function 5-2997
PLIB_SQI_ExistsTxBufferFree function 5-2998
PLIB_SQI_ExistsTxBufIntThreshold function 5-2998
PLIB_SQI_ExistsTxBufThreshold function 5-2999
PLIB_SQI_ExistsTxData function 5-2999
PLIB_SQI_ExistsTxOverFlow function 5-3000
PLIB_SQI_ExistsWPPinControl function 5-3000
PLIB_SQI_ExistsXIPChipSelect function 5-3001
PLIB_SQI_ExistsXIPControlWord1 function 5-3001
PLIB_SQI_ExistsXIPControlWord2 function 5-3002
PLIB_SQI_ExistsXIPLaneMode function 5-3003
PLIB_SQI_ExistsXIPModeBytes function 5-3003
PLIB_SQI_ExistsXIPModeCode function 5-3004
PLIB_SQI_ExistsXIPNumberOfAddressBytes function 5-3004
PLIB_SQI_ExistsXIPNumberOfDummyBytes function 5-3005
PLIB_SQI_ExistsXIPReadOpCode function 5-3005
PLIB_SQI_HoldClear function 5-2916
PLIB_SQI_HoldGet function 5-2916
PLIB_SQI_HoldSet function 5-2917
PLIB_SQI_InterruptDisable function 5-2950
PLIB_SQI_InterruptEnable function 5-2950
PLIB_SQI_InterruptFlagGet function 5-2951
PLIB_SQI_InterruptIsEnabled function 5-2952
PLIB_SQI_InterruptSignalDisable function 5-2952
PLIB_SQI_InterruptSignalEnable function 5-2953
PLIB_SQI_InterruptSignalIsEnabled function 5-2953
PLIB_SQI_LaneModeGet function 5-2917
PLIB_SQI_LaneModeSet function 5-2918
PLIB_SQI_NumberOfReceiveBufferReads function 5-2919
PLIB_SQI_ReceiveBufferIsUnderrun function 5-2942
PLIB_SQI_ReceiveData function 5-2919
PLIB_SQI_ReceiveLatchDisable function 5-2920
PLIB_SQI_ReceiveLatchEnable function 5-2920
PLIB_SQI_ReceiveLatchGet function 5-2921
PLIB_SQI_RxBufferThresholdGet function 5-2943
PLIB_SQI_RxBufferThresholdIntGet function 5-2943
PLIB_SQI_RxBufferThresholdIntSet function 5-2944
PLIB_SQI_RxBufferThresholdSet function 5-2944
PLIB_SQI_SoftReset function 5-2921
PLIB_SQI_TransferDirectionGet function 5-2945
PLIB_SQI_TransferDirectionSet function 5-2945
PLIB_SQI_TransferModeGet function 5-2922
PLIB_SQI_TransferModeSet function 5-2922
PLIB_SQI_TransmitBufferFreeSpaceGet function 5-2946
PLIB_SQI_TransmitBufferHasOverflowed function 5-2947
PLIB_SQI_TransmitData function 5-2923
PLIB_SQI_TxBufferThresholdGet function 5-2947
PLIB_SQI_TxBufferThresholdIntGet function 5-2948
PLIB_SQI_TxBufferThresholdIntSet function 5-2948
PLIB_SQI_TxBufferThresholdSet function 5-2949
PLIB_SQI_WriteProtectClear function 5-2923
PLIB_SQI_WriteProtectGet function 5-2924
PLIB_SQI_WriteProtectSet function 5-2924
PLIB_SQI_XIPAddressBytesGet function 5-2927
9 MPLAB Harmony Help
mmm
PLIB_SQI_XIPAddressBytesSet function 5-2927
PLIB_SQI_XIPChipSelectGet function 5-2928
PLIB_SQI_XIPChipSelectSet function 5-2928
PLIB_SQI_XIPControlWord1Get function 5-2929
PLIB_SQI_XIPControlWord1Set function 5-2930
PLIB_SQI_XIPControlWord2Get function 5-2931
PLIB_SQI_XIPControlWord2Set function 5-2931
PLIB_SQI_XIPDummyBytesGet function 5-2932
PLIB_SQI_XIPDummyBytesSet function 5-2932
PLIB_SQI_XIPLaneModeGet function 5-2933
PLIB_SQI_XIPLaneModeSet function 5-2933
PLIB_SQI_XIPModeBytesGet function 5-2934
PLIB_SQI_XIPModeBytesSet function 5-2935
PLIB_SQI_XIPModeCodeGet function 5-2935
PLIB_SQI_XIPModeCodeSet function 5-2936
PLIB_SQI_XIPReadOpcodeGet function 5-2936
PLIB_SQI_XIPReadOpcodeSet function 5-2937
plib_tmr.h 5-3081
PLIB_TMR_AssignmentSelect function 5-3025
PLIB_TMR_ClockSourceEdgeGet function 5-3034
PLIB_TMR_ClockSourceEdgeSelect function 5-3035
PLIB_TMR_ClockSourceExternalSyncDisable function 5-3035
PLIB_TMR_ClockSourceExternalSyncEnable function 5-3036
PLIB_TMR_ClockSourceSelect function 5-3036
PLIB_TMR_ContinousCountModeEnable function 5-3026
PLIB_TMR_Counter16BitClear function 5-3050
PLIB_TMR_Counter16BitGet function 5-3050
PLIB_TMR_Counter16BitSet function 5-3051
PLIB_TMR_Counter32BitClear function 5-3051
PLIB_TMR_Counter32BitGet function 5-3052
PLIB_TMR_Counter32BitSet function 5-3053
PLIB_TMR_Counter8BitClear function 5-3053
PLIB_TMR_Counter8BitGet function 5-3054
PLIB_TMR_Counter8BitSet function 5-3054
PLIB_TMR_CounterAsyncWriteDisable function 5-3055
PLIB_TMR_CounterAsyncWriteEnable function 5-3055
PLIB_TMR_CounterAsyncWriteInProgress function 5-3056
PLIB_TMR_ExistsClockSource function 5-3064
PLIB_TMR_ExistsClockSourceEdge function 5-3065
PLIB_TMR_ExistsClockSourceSync function 5-3065
PLIB_TMR_ExistsCounter16Bit function 5-3066
PLIB_TMR_ExistsCounter32Bit function 5-3066
PLIB_TMR_ExistsCounter8Bit function 5-3067
PLIB_TMR_ExistsCounterAsyncWriteControl function 5-3067
PLIB_TMR_ExistsCounterAsyncWriteInProgress function
5-3068
PLIB_TMR_ExistsCountMode function 5-3068
PLIB_TMR_ExistsEnableControl function 5-3069
PLIB_TMR_ExistsGateCurrentState function 5-3069
PLIB_TMR_ExistsGatedTimeAccumulation function 5-3070
PLIB_TMR_ExistsGatePolarity function 5-3070
PLIB_TMR_ExistsGateSinglePulseAcqusition function 5-3071
PLIB_TMR_ExistsGateSinglePulseMode function 5-3071
PLIB_TMR_ExistsGateSource function 5-3072
PLIB_TMR_ExistsGateToggleMode function 5-3072
PLIB_TMR_ExistsMode16Bit function 5-3073
PLIB_TMR_ExistsMode32Bit function 5-3073
PLIB_TMR_ExistsMode8Bit function 5-3074
PLIB_TMR_ExistsOperationInSleep function 5-3074
PLIB_TMR_ExistsPeriod16Bit function 5-3075
PLIB_TMR_ExistsPeriod32Bit function 5-3075
PLIB_TMR_ExistsPeriod8Bit function 5-3076
PLIB_TMR_ExistsPostscale function 5-3076
PLIB_TMR_ExistsPrescale function 5-3077
PLIB_TMR_ExistsPrescalerAssignment function 5-3078
PLIB_TMR_ExistsStopInIdleControl function 5-3078
PLIB_TMR_ExistsSystemClockStatus function 5-3079
PLIB_TMR_ExistsTimerAssignment function 5-3079
PLIB_TMR_ExistsTimerOperationMode function 5-3080
PLIB_TMR_ExistsTimerOscillator function 5-3080
PLIB_TMR_ExistsTriggerEventReset function 5-3081
PLIB_TMR_GateCurrentStateGet function 5-3037
PLIB_TMR_GateDisable function 5-3038
PLIB_TMR_GateEnable function 5-3038
PLIB_TMR_GatePolaritySelect function 5-3039
PLIB_TMR_GateSinglePulseAcquisitionHasCompleted function
5-3039
PLIB_TMR_GateSinglePulseAcquisitionStart function 5-3040
PLIB_TMR_GateSinglePulseModeDisable function 5-3040
9 MPLAB Harmony Help
nnn
PLIB_TMR_GateSinglePulseModeEnable function 5-3041
PLIB_TMR_GateSourceSelect function 5-3041
PLIB_TMR_GateToggleModeDisable function 5-3042
PLIB_TMR_GateToggleModeEnable function 5-3042
PLIB_TMR_IsPeriodMatchBased function 5-3058
PLIB_TMR_Mode16BitEnable function 5-3026
PLIB_TMR_Mode32BitEnable function 5-3027
PLIB_TMR_Mode8BitEnable function 5-3028
PLIB_TMR_OperateInSleepDisable function 5-3032
PLIB_TMR_OperateInSleepEnable function 5-3032
PLIB_TMR_Period16BitGet function 5-3046
PLIB_TMR_Period16BitSet function 5-3046
PLIB_TMR_Period32BitGet function 5-3047
PLIB_TMR_Period32BitSet function 5-3048
PLIB_TMR_Period8BitGet function 5-3048
PLIB_TMR_Period8BitSet function 5-3049
PLIB_TMR_PostscaleDivisorGet function 5-3057
PLIB_TMR_PostscaleGet function 5-3057
PLIB_TMR_PostscaleSelect function 5-3058
PLIB_TMR_PrescaleDivisorGet function 5-3043
PLIB_TMR_PrescaleGet function 5-3044
PLIB_TMR_PrescalerDisable function 5-3044
PLIB_TMR_PrescalerEnable function 5-3045
PLIB_TMR_PrescaleSelect function 5-3045
PLIB_TMR_SingleShotModeEnable function 5-3031
PLIB_TMR_Start function 5-3028
PLIB_TMR_Stop function 5-3029
PLIB_TMR_StopInIdleDisable function 5-3033
PLIB_TMR_StopInIdleEnable function 5-3033
PLIB_TMR_SystemClockFromTimerIsActive function 5-3059
PLIB_TMR_TimerOscillatorDisable function 5-3029
PLIB_TMR_TimerOscillatorEnable function 5-3030
PLIB_TMR_TriggerEventResetDisable function 5-3030
PLIB_TMR_TriggerEventResetEnable function 5-3031
plib_usart.h 5-3164
PLIB_USART_AlternateIODisable function 5-3105
PLIB_USART_AlternateIOEnable function 5-3105
PLIB_USART_BaudRateAutoDetectEnable function 5-3116
PLIB_USART_BaudRateAutoDetectIsComplete function 5-3117
PLIB_USART_BaudRateAutoDetectOverflowHasOccurred
function 5-3117
PLIB_USART_BaudRateGet function 5-3118
PLIB_USART_BaudRateHighDisable function 5-3118
PLIB_USART_BaudRateHighEnable function 5-3119
PLIB_USART_BaudRateHighSet function 5-3119
PLIB_USART_BaudRateModeSelect function 5-3120
PLIB_USART_BaudRateSet function 5-3121
PLIB_USART_Disable function 5-3106
PLIB_USART_Enable function 5-3106
PLIB_USART_ExistsAlternateIO function 5-3144
PLIB_USART_ExistsBaudRate function 5-3145
PLIB_USART_ExistsBaudRateAutoDetect function 5-3145
PLIB_USART_ExistsBaudRateAutoDetectOverflow function
5-3146
PLIB_USART_ExistsBaudRateBitMode function 5-3146
PLIB_USART_ExistsBaudRateHigh function 5-3147
PLIB_USART_ExistsEnable function 5-3147
PLIB_USART_ExistsHandshakeMode function 5-3148
PLIB_USART_ExistsIrDA function 5-3148
PLIB_USART_ExistsLineControlMode function 5-3149
PLIB_USART_ExistsLoopback function 5-3149
PLIB_USART_ExistsOperationMode function 5-3150
PLIB_USART_ExistsReceiver function 5-3150
PLIB_USART_ExistsReceiverAddressAutoDetect function
5-3151
PLIB_USART_ExistsReceiverAddressDetect function 5-3151
PLIB_USART_ExistsReceiverDataAvailableStatus function
5-3152
PLIB_USART_ExistsReceiverEnable function 5-3152
PLIB_USART_ExistsReceiverFramingErrorStatus function
5-3153
PLIB_USART_ExistsReceiverIdleStateLowEnable function
5-3153
PLIB_USART_ExistsReceiverIdleStatus function 5-3154
PLIB_USART_ExistsReceiverInterruptMode function 5-3154
PLIB_USART_ExistsReceiverMode function 5-3155
PLIB_USART_ExistsReceiverOverrunStatus function 5-3155
PLIB_USART_ExistsReceiverParityErrorStatus function 5-3156
PLIB_USART_ExistsStopInIdle function 5-3156
PLIB_USART_ExistsSyncClockPolarity function 5-3157
9 MPLAB Harmony Help
ooo
PLIB_USART_ExistsSyncClockSource function 5-3158
PLIB_USART_ExistsSyncMode function 5-3158
PLIB_USART_ExistsTransmitter function 5-3159
PLIB_USART_ExistsTransmitter9BitsSend function 5-3159
PLIB_USART_ExistsTransmitterBreak function 5-3160
PLIB_USART_ExistsTransmitterBufferFullStatus function
5-3160
PLIB_USART_ExistsTransmitterEmptyStatus function 5-3161
PLIB_USART_ExistsTransmitterEnable function 5-3161
PLIB_USART_ExistsTransmitterIdleIsLow function 5-3162
PLIB_USART_ExistsTransmitterIdleStatus function 5-3162
PLIB_USART_ExistsTransmitterInterruptMode function 5-3163
PLIB_USART_ExistsWakeOnStart function 5-3163
PLIB_USART_HandshakeModeSelect function 5-3107
PLIB_USART_IrDADisable function 5-3108
PLIB_USART_IrDAEnable function 5-3108
PLIB_USART_LineControlModeSelect function 5-3109
PLIB_USART_LoopbackDisable function 5-3109
PLIB_USART_LoopbackEnable function 5-3110
PLIB_USART_OperationModeSelect function 5-3110
PLIB_USART_ReceiverAddressAutoDetectDisable function
5-3129
PLIB_USART_ReceiverAddressAutoDetectEnable function
5-3129
PLIB_USART_ReceiverAddressDetectDisable function 5-3130
PLIB_USART_ReceiverAddressDetectEnable function 5-3131
PLIB_USART_ReceiverAddressIsReceived function 5-3131
PLIB_USART_ReceiverByteReceive function 5-3132
PLIB_USART_ReceiverDataIsAvailable function 5-3133
PLIB_USART_ReceiverDisable function 5-3133
PLIB_USART_ReceiverEnable function 5-3134
PLIB_USART_ReceiverFramingErrorHasOccurred function
5-3134
PLIB_USART_ReceiverIdleStateLowDisable function 5-3135
PLIB_USART_ReceiverIdleStateLowEnable function 5-3135
PLIB_USART_ReceiverInterruptModeSelect function 5-3136
PLIB_USART_ReceiverIsIdle function 5-3136
PLIB_USART_ReceiverModeSelect function 5-3137
PLIB_USART_ReceiverOverrunErrorClear function 5-3138
PLIB_USART_ReceiverOverrunHasOccurred function 5-3138
PLIB_USART_ReceiverParityErrorHasOccurred function 5-3139
PLIB_USART_StopInIdleDisable function 5-3111
PLIB_USART_StopInIdleEnable function 5-3111
PLIB_USART_SyncClockPolarityIdleHighDisable function
5-3112
PLIB_USART_SyncClockPolarityIdleHighEnable function
5-3113
PLIB_USART_SyncClockSourceSelect function 5-3113
PLIB_USART_SyncModeSelect function 5-3114
PLIB_USART_Transmitter9BitsSend function 5-3122
PLIB_USART_TransmitterBreakSend function 5-3122
PLIB_USART_TransmitterBreakSendIsComplete function
5-3123
PLIB_USART_TransmitterBufferIsFull function 5-3124
PLIB_USART_TransmitterByteSend function 5-3124
PLIB_USART_TransmitterDisable function 5-3125
PLIB_USART_TransmitterEnable function 5-3125
PLIB_USART_TransmitterIdleIsLowDisable function 5-3126
PLIB_USART_TransmitterIdleIsLowEnable function 5-3127
PLIB_USART_TransmitterInterruptModeSelect function 5-3127
PLIB_USART_TransmitterIsEmpty function 5-3128
PLIB_USART_TransmitterIsIdle function 5-3128
PLIB_USART_WakeOnStartDisable function 5-3114
PLIB_USART_WakeOnStartEnable function 5-3115
PLIB_USART_WakeOnStartIsEnabled function 5-3115
plib_usb.h 5-3313
PLIB_USB_ActivityPending function 5-3260
PLIB_USB_AllInterruptEnable function 5-3188
PLIB_USB_AutoSuspendDisable function 5-3189
PLIB_USB_AutoSuspendEnable function 5-3190
PLIB_USB_BDTBaseAddressGet function 5-3201
PLIB_USB_BDTBaseAddressSet function 5-3201
PLIB_USB_BufferAddressGet function 5-3202
PLIB_USB_BufferAddressSet function 5-3203
PLIB_USB_BufferAllCancelReleaseToUSB function 5-3203
PLIB_USB_BufferByteCountGet function 5-3204
PLIB_USB_BufferByteCountSet function 5-3205
PLIB_USB_BufferCancelReleaseToUSB function 5-3205
PLIB_USB_BufferClearAll function 5-3206
PLIB_USB_BufferClearAllDTSEnable function 5-3207
PLIB_USB_BufferDataToggleGet function 5-3207
9 MPLAB Harmony Help
ppp
PLIB_USB_BufferDataToggleSelect function 5-3208
PLIB_USB_BufferDataToggleSyncDisable function 5-3209
PLIB_USB_BufferDataToggleSyncEnable function 5-3209
PLIB_USB_BufferEP0RxStatusInitialize function 5-3210
PLIB_USB_BufferIndexGet function 5-3211
PLIB_USB_BufferPIDBitsClear function 5-3211
PLIB_USB_BufferPIDGet function 5-3212
PLIB_USB_BufferReleasedToSW function 5-3213
PLIB_USB_BufferReleaseToUSB function 5-3214
PLIB_USB_BufferSchedule function 5-3214
PLIB_USB_BufferStallDisable function 5-3215
PLIB_USB_BufferStallEnable function 5-3216
PLIB_USB_BufferStallGet function 5-3217
PLIB_USB_DeviceAddressGet function 5-3190
PLIB_USB_DeviceAddressSet function 5-3191
PLIB_USB_Disable function 5-3191
PLIB_USB_Enable function 5-3192
PLIB_USB_EP0HostSetup function 5-3217
PLIB_USB_EP0LSDirectConnectDisable function 5-3218
PLIB_USB_EP0LSDirectConnectEnable function 5-3218
PLIB_USB_EP0NakRetryDisable function 5-3219
PLIB_USB_EP0NakRetryEnable function 5-3219
PLIB_USB_EPnAttributesClear function 5-3220
PLIB_USB_EPnAttributesSet function 5-3221
PLIB_USB_EPnControlTransferDisable function 5-3221
PLIB_USB_EPnControlTransferEnable function 5-3222
PLIB_USB_EPnDirectionDisable function 5-3222
PLIB_USB_EPnHandshakeDisable function 5-3223
PLIB_USB_EPnHandshakeEnable function 5-3223
PLIB_USB_EPnIsStalled function 5-3224
PLIB_USB_EPnRxDisable function 5-3225
PLIB_USB_EPnRxEnable function 5-3225
PLIB_USB_EPnRxSelect function 5-3226
PLIB_USB_EPnStallClear function 5-3226
PLIB_USB_EPnTxDisable function 5-3227
PLIB_USB_EPnTxEnable function 5-3227
PLIB_USB_EPnTxRxSelect function 5-3228
PLIB_USB_EPnTxSelect function 5-3229
PLIB_USB_ErrorInterruptDisable function 5-3234
PLIB_USB_ErrorInterruptEnable function 5-3235
PLIB_USB_ErrorInterruptFlagAllGet function 5-3235
PLIB_USB_ErrorInterruptFlagClear function 5-3236
PLIB_USB_ErrorInterruptFlagGet function 5-3236
PLIB_USB_ErrorInterruptFlagSet function 5-3237
PLIB_USB_ErrorInterruptIsEnabled function 5-3237
PLIB_USB_ExistsActivityPending function 5-3283
PLIB_USB_ExistsALL_Interrupt function 5-3284
PLIB_USB_ExistsAutomaticSuspend function 5-3284
PLIB_USB_ExistsBDTBaseAddress function 5-3285
PLIB_USB_ExistsBDTFunctions function 5-3285
PLIB_USB_ExistsBufferFreeze function 5-3286
PLIB_USB_ExistsDeviceAddress function 5-3287
PLIB_USB_ExistsEP0LowSpeedConnect function 5-3287
PLIB_USB_ExistsEP0NAKRetry function 5-3288
PLIB_USB_ExistsEPnRxEnable function 5-3289
PLIB_USB_ExistsEPnTxRx function 5-3289
PLIB_USB_ExistsERR_Interrupt function 5-3290
PLIB_USB_ExistsERR_InterruptStatus function 5-3290
PLIB_USB_ExistsEyePattern function 5-3291
PLIB_USB_ExistsFrameNumber function 5-3291
PLIB_USB_ExistsGEN_Interrupt function 5-3292
PLIB_USB_ExistsGEN_InterruptStatus function 5-3293
PLIB_USB_ExistsHostBusyWithToken function 5-3293
PLIB_USB_ExistsHostGeneratesReset function 5-3294
PLIB_USB_ExistsLastDirection function 5-3294
PLIB_USB_ExistsLastEndpoint function 5-3295
PLIB_USB_ExistsLastPingPong function 5-3295
PLIB_USB_ExistsLastTransactionDetails function 5-3296
PLIB_USB_ExistsLiveJState function 5-3296
PLIB_USB_ExistsLiveSingleEndedZero function 5-3297
PLIB_USB_ExistsModuleBusy function 5-3297
PLIB_USB_ExistsModulePower function 5-3298
PLIB_USB_ExistsNextTokenSpeed function 5-3298
PLIB_USB_ExistsOnChipPullup function 5-3299
PLIB_USB_ExistsOnChipTransceiver function 5-3299
PLIB_USB_ExistsOpModeSelect function 5-3300
PLIB_USB_ExistsOTG_ASessionValid function 5-3300
PLIB_USB_ExistsOTG_BSessionEnd function 5-3301
9 MPLAB Harmony Help
qqq
PLIB_USB_ExistsOTG_IDPinState function 5-3301
PLIB_USB_ExistsOTG_Interrupt function 5-3302
PLIB_USB_ExistsOTG_InterruptStatus function 5-3302
PLIB_USB_ExistsOTG_LineState function 5-3303
PLIB_USB_ExistsOTG_PullUpPullDown function 5-3303
PLIB_USB_ExistsOTG_SessionValid function 5-3304
PLIB_USB_ExistsOTG_VbusCharge function 5-3304
PLIB_USB_ExistsOTG_VbusDischarge function 5-3305
PLIB_USB_ExistsOTG_VbusPowerOnOff function 5-3305
PLIB_USB_ExistsPacketTransfer function 5-3306
PLIB_USB_ExistsPingPongMode function 5-3306
PLIB_USB_ExistsResumeSignaling function 5-3307
PLIB_USB_ExistsSleepEntryGuard function 5-3308
PLIB_USB_ExistsSOFThreshold function 5-3308
PLIB_USB_ExistsSpeedControl function 5-3309
PLIB_USB_ExistsStartOfFrames function 5-3309
PLIB_USB_ExistsStopInIdle function 5-3310
PLIB_USB_ExistsSuspend function 5-3310
PLIB_USB_ExistsTokenEP function 5-3311
PLIB_USB_ExistsTokenPID function 5-3311
PLIB_USB_ExistsUOEMonitor function 5-3312
PLIB_USB_ExternalComparatorMode2Pin function 5-3267
PLIB_USB_ExternalComparatorMode3Pin function 5-3267
PLIB_USB_EyePatternDisable function 5-3274
PLIB_USB_EyePatternEnable function 5-3274
PLIB_USB_FrameNumberGet function 5-3261
PLIB_USB_FullSpeedDisable function 5-3193
PLIB_USB_FullSpeedEnable function 5-3193
PLIB_USB_I2CInterfaceForExtModuleDisable function 5-3265
PLIB_USB_I2CInterfaceForExtModuleEnable function 5-3265
PLIB_USB_InterruptDisable function 5-3229
PLIB_USB_InterruptEnable function 5-3230
PLIB_USB_InterruptEnableGet function 5-3230
PLIB_USB_InterruptFlagAllGet function 5-3231
PLIB_USB_InterruptFlagClear function 5-3231
PLIB_USB_InterruptFlagGet function 5-3232
PLIB_USB_InterruptFlagSet function 5-3233
PLIB_USB_InterruptIsEnabled function 5-3233
PLIB_USB_IsBusyWithToken function 5-3241
PLIB_USB_JStateIsActive function 5-3261
PLIB_USB_LastTransactionDetailsGet function 5-3238
PLIB_USB_LastTransactionDirectionGet function 5-3239
PLIB_USB_LastTransactionEndPtGet function 5-3239
PLIB_USB_LastTransactionPingPongStateGet function 5-3240
PLIB_USB_ModuleIsBusy function 5-3275
PLIB_USB_OnChipPullUpDisable function 5-3194
PLIB_USB_OnChipPullUpEnable function 5-3194
PLIB_USB_OperatingModeSelect function 5-3195
PLIB_USB_OTG_BSessionHasEnded function 5-3249
PLIB_USB_OTG_IDPinStateIsTypeA function 5-3249
PLIB_USB_OTG_InterruptDisable function 5-3257
PLIB_USB_OTG_InterruptEnable function 5-3257
PLIB_USB_OTG_InterruptFlagClear function 5-3258
PLIB_USB_OTG_InterruptFlagGet function 5-3258
PLIB_USB_OTG_InterruptFlagSet function 5-3259
PLIB_USB_OTG_InterruptIsEnabled function 5-3259
PLIB_USB_OTG_LineStateIsStable function 5-3250
PLIB_USB_OTG_PullUpPullDownSetup function 5-3251
PLIB_USB_OTG_SessionValid function 5-3251
PLIB_USB_OTG_VBusChargeDisable function 5-3252
PLIB_USB_OTG_VBusChargeEnable function 5-3252
PLIB_USB_OTG_VBusChargeTo3V function 5-3253
PLIB_USB_OTG_VBusChargeTo5V function 5-3253
PLIB_USB_OTG_VBusDischargeDisable function 5-3254
PLIB_USB_OTG_VBusDischargeEnable function 5-3254
PLIB_USB_OTG_VBusPowerOff function 5-3255
PLIB_USB_OTG_VBusPowerOn function 5-3255
PLIB_USB_OTG_VBusValid function 5-3256
PLIB_USB_PacketTransferDisable function 5-3262
PLIB_USB_PacketTransferEnable function 5-3263
PLIB_USB_PacketTransferIsDisabled function 5-3263
PLIB_USB_PingPongFreeze function 5-3276
PLIB_USB_PingPongModeGet function 5-3195
PLIB_USB_PingPongModeSelect function 5-3196
PLIB_USB_PingPongReset function 5-3276
PLIB_USB_PingPongUnfreeze function 5-3277
PLIB_USB_PWMCounterDisable function 5-3268
PLIB_USB_PWMCounterEnable function 5-3268
9 MPLAB Harmony Help
rrr
PLIB_USB_PWMDisable function 5-3269
PLIB_USB_PWMEnable function 5-3269
PLIB_USB_PWMPolaritiyActiveLow function 5-3270
PLIB_USB_PWMPolarityActiveHigh function 5-3270
PLIB_USB_ResetSignalDisable function 5-3246
PLIB_USB_ResetSignalEnable function 5-3247
PLIB_USB_ResumeSignalingDisable function 5-3248
PLIB_USB_ResumeSignalingEnable function 5-3248
PLIB_USB_SE0InProgress function 5-3264
PLIB_USB_SleepGuardDisable function 5-3197
PLIB_USB_SleepGuardEnable function 5-3197
PLIB_USB_SOFDisable function 5-3241
PLIB_USB_SOFEnable function 5-3242
PLIB_USB_SOFThresholdGet function 5-3242
PLIB_USB_SOFThresholdSet function 5-3243
PLIB_USB_StopInIdleDisable function 5-3198
PLIB_USB_StopInIdleEnable function 5-3198
PLIB_USB_SuspendDisable function 5-3199
PLIB_USB_SuspendEnable function 5-3199
PLIB_USB_TokenEPGet function 5-3244
PLIB_USB_TokenEPSet function 5-3244
PLIB_USB_TokenPIDGet function 5-3245
PLIB_USB_TokenPIDSet function 5-3245
PLIB_USB_TokenSend function 5-3277
PLIB_USB_TokenSpeedSelect function 5-3246
PLIB_USB_TransceiverDisable function 5-3266
PLIB_USB_TransceiverEnable function 5-3266
PLIB_USB_UOEMonitorDisable function 5-3200
PLIB_USB_UOEMonitorEnable function 5-3200
PLIB_USB_VBoostDisable function 5-3271
PLIB_USB_VBoostEnable function 5-3271
PLIB_USB_VBUSComparatorDisable function 5-3272
PLIB_USB_VBUSComparatorEnable function 5-3272
PLIB_USB_VBUSPullUpDisable function 5-3273
PLIB_USB_VBUSPullUpEnable function 5-3273
plib_wdt.h 5-3330
PLIB_WDT_Disable function 5-3323
PLIB_WDT_Enable function 5-3324
PLIB_WDT_ExistsEnableControl function 5-3328
PLIB_WDT_ExistsPostscalarValue function 5-3328
PLIB_WDT_ExistsTimerClear function 5-3329
PLIB_WDT_ExistsWindowEnable function 5-3329
PLIB_WDT_IsEnabled function 5-3326
PLIB_WDT_PostscalarValueGet function 5-3327
PLIB_WDT_TimerClear function 5-3325
PLIB_WDT_WindowDisable function 5-3324
PLIB_WDT_WindowEnable function 5-3325
PMP Peripheral Library 5-2478
PMP_ACK_MODE enumeration 5-2546
PMP_ADDRESS_HOLD_LATCH_WAIT_STATES enumeration
5-2546
PMP_ADDRESS_LATCH enumeration 5-2547
PMP_ADDRESS_LATCH_WAIT_STATES enumeration 5-2547
PMP_ADDRESS_PORT enumeration 5-2548
PMP_ALTERNATE_MASTER_WAIT_STATES enumeration
5-2549
PMP_CHIP_SELECT enumeration 5-2549
PMP_CHIPSELECT_FUNCTION enumeration 5-2550
PMP_DATA_HOLD_STATES enumeration 5-2550
PMP_DATA_LENGTH enumeration 5-2551
PMP_DATA_SIZE enumeration 5-2551
PMP_DATA_WAIT_STATES enumeration 5-2551
PMP_INCREMENT_MODE enumeration 5-2552
PMP_INPUT_BUFFER_TYPE enumeration 5-2552
PMP_INTERRUPT_MODE enumeration 5-2553
PMP_MASTER_MODE enumeration 5-2553
PMP_MODULE_ID enumeration 5-2554
PMP_MUX_MODE enumeration 5-2554
PMP_OPERATION_MODE enumeration 5-2555
PMP_PMBE_PORT enumeration 5-2555
PMP_POLARITY_LEVEL enumeration 5-2556
PMP_STROBE_WAIT_STATES enumeration 5-2556
Porting Applications from the MLA Graphics Library to the
MPLAB Harmony Graphics Library 5-686
Porting Applications from the V6 Beta TCP/IP Stack to the
MPLAB Harmony TCP/IP Stack 5-3557
Porting the MPLAB Harmony Drivers and Peripheral Library
5-3565
Ports Change Notification 5-2599
Ports Control 5-2598, 5-3471
9 MPLAB Harmony Help
sss
Ports Function Remap 5-2599
Ports Peripheral Library 5-2593
Ports System Service Library 5-3465
PORTS_ANALOG_PIN enumeration 5-2629
PORTS_BIT_POS enumeration 5-2631
PORTS_CHANGE_NOTICE_PIN enumeration 5-2632
PORTS_CHANNEL enumeration 5-2635
PORTS_DATA_MASK type 5-2636
PORTS_DATA_TYPE type 5-2636
PORTS_MODULE_ID enumeration 5-2636
PORTS_PERIPHERAL_OD enumeration 5-2637
PORTS_PIN enumeration 5-2638
PORTS_PIN_MODE enumeration 5-2638
PORTS_REMAP_FUNCTION enumeration 5-2639
PORTS_REMAP_INPUT_FUNCTION enumeration 5-2642
PORTS_REMAP_INPUT_PIN enumeration 5-2643
PORTS_REMAP_OUTPUT_FUNCTION enumeration 5-2644
PORTS_REMAP_OUTPUT_PIN enumeration 5-2645
PORTS_REMAP_PIN enumeration 5-2646
Power Peripheral Library 5-2662
POWER_MODULE enumeration 5-2677
POWER_MODULE_ID enumeration 5-2680
Power-Saving Modes 5-1374, 5-1672, 5-2822
Prefetch Cache Peripheral Library 5-2427
Prefetch Control Operations 5-2433
Prefetch Status Operations 5-2433
Previous Versions 5-3964
primitive_demo 3-87
primitiveTaskImage variable 5-888
PRIV_LOCALIZED_PASSWORD_KEY_LEN macro 5-3827
Project Layout 1-10
PUTIMAGE_PARAM structure 5-939
PWM Mode with Enabled Faults 5-2293
Q
Queue Operation 5-1319
QUEUE_ELEMENT_OBJECT type 5-393
R
RdiaCosine function 5-797
RdiaSine function 5-798
REACHABLE_TIME macro 5-3803
Reading a Capture Value 5-2174
Reading a File 5-3394
Reboot TCP/IP Stack Library 5-3806
REBOOT_PORT macro 5-3808
REBOOT_SAME_SUBNET_ONLY macro 5-3808
Receive 5-1919
Receive Filtering Overview 5-1912
Receiving a CAN Message 5-1562
Receiving a Report 5-4140
Receiving Data 5-4074
recv function 5-3605
recvfrom function 5-3606
RED macro 5-1049
Reduced Media Independent Interface (RMII) 5-1910
Release Contents 1-25
Release Notes 1-23, 2-40, 3-64, 3-84, 3-99, 3-102, 3-113,
3-123, 3-130, 3-142, 3-149, 4-178, 5-194, 5-227, 5-254, 5-289,
5-299, 5-309, 5-320, 5-333, 5-343, 5-367, 5-397, 5-419, 5-457,
5-511, 5-552, 5-601, 5-680, 5-695, 5-1110, 5-1127, 5-1167,
5-1275, 5-1312, 5-1362, 5-1472, 5-1520, 5-1554, 5-1668,
5-1734, 5-1865, 5-1904, 5-2060, 5-2171, 5-2203, 5-2253,
5-2288, 5-2331, 5-2428, 5-2478, 5-2594, 5-2662, 5-2688,
5-2704, 5-2762, 5-2799, 5-2892, 5-3011, 5-3086, 5-3170,
5-3320, 5-3348, 5-3363, 5-3377, 5-3419, 5-3439, 5-3466,
5-3500, 5-3530, 5-3536, 5-3546, 5-3570, 5-3575, 5-3598,
5-3615, 5-3625, 5-3637, 5-3646, 5-3654, 5-3659, 5-3690,
5-3698, 5-3709, 5-3718, 5-3748, 5-3771, 5-3795, 5-3799,
5-3806, 5-3809, 5-3822, 5-3858, 5-3868, 5-3881, 5-3913,
5-3917, 5-3930, 5-3955, 5-3964, 5-3978, 5-4004, 5-4060,
5-4100, 5-4131, 5-4169, 5-4180, 5-4200, 6-4226, 7-4230,
7-4232, 7-4234, 7-4236
Release Types 1-30
Rendering 5-698
RequestEntirePaletteChange macro 5-1049
RequestPaletteChange function 5-876
Required Hardware 3-103, 3-124, 3-143
Reset Peripheral Library 5-2687
RESET_CONFIG_REG_READ_ERROR enumeration 5-2695
RESET_MODULE_ID enumeration 5-2694
9 MPLAB Harmony Help
ttt
RESET_NMI_COUNT_TYPE type 5-2695
RESET_NMI_REASON enumeration 5-2695
RETRANS_TIMER macro 5-3803
RTCC Mode Operations 5-2708
RTCC Peripheral Library 5-2703
RTCC_ALARM_MASK_CONFIGURATION enumeration 5-2747
RTCC_MODULE_ID enumeration 5-2748
RTCC_VALUE_REGISTER_POINTER enumeration 5-2748
RTOS Demonstrations 3-113
RTR_SOLICITATION_INTERVAL macro 5-3804
Running the Application 3-111, 3-128, 3-147
Running the Configurator Plug-in 2-44
Running the Demonstration 3-67, 3-70, 3-72, 3-74, 3-76, 3-86,
3-88, 3-90, 3-91, 3-115, 3-116, 3-118, 3-131, 3-133, 3-135,
3-153, 3-155, 3-156, 3-159, 3-160, 3-161, 3-162, 3-164, 3-165,
3-167, 3-168, 3-170
S
S1D13517 Data Types and Constants 5-331
S1D13517 Graphics Controller Driver Library 5-319
SADDLEBROWN macro 5-1049
Sample Code 5-1912
SAT16 function 5-1263
SAT16N function 5-1264
SAT16P function 5-1264
SB_MODULE_ID enumeration 5-2786
SCAN_BS_PRESSED macro 5-1049
SCAN_BS_RELEASED macro 5-1050
SCAN_CR_PRESSED macro 5-1050
SCAN_CR_RELEASED macro 5-1050
SCAN_CRA_PRESSED macro 5-1050
SCAN_CRA_RELEASED macro 5-1050
SCAN_DEL_PRESSED macro 5-1050
SCAN_DEL_RELEASED macro 5-1051
SCAN_DOWN_PRESSED macro 5-1051
SCAN_DOWN_RELEASED macro 5-1051
SCAN_END_PRESSED macro 5-1051
SCAN_END_RELEASED macro 5-1051
SCAN_HOME_PRESSED macro 5-1051
SCAN_HOME_RELEASED macro 5-1051
SCAN_LEFT_PRESSED macro 5-1052
SCAN_LEFT_RELEASED macro 5-1052
SCAN_PGDOWN_PRESSED macro 5-1052
SCAN_PGDOWN_RELEASED macro 5-1052
SCAN_PGUP_PRESSED macro 5-1052
SCAN_PGUP_RELEASED macro 5-1052
SCAN_RIGHT_PRESSED macro 5-1053
SCAN_RIGHT_RELEASED macro 5-1053
SCAN_SPACE_PRESSED macro 5-1053
SCAN_SPACE_RELEASED macro 5-1053
SCAN_TAB_PRESSED macro 5-1053
SCAN_TAB_RELEASED macro 5-1053
SCAN_UP_PRESSED macro 5-1053
SCAN_UP_RELEASED macro 5-1054
Scheme Functionality 5-701
sd_card_fat_single_disk 3-69
SDCARD_MAX_LIMIT macro 5-415
Secure Digital (SD) Card Driver Library 5-397
Semaphores 5-1318
send function 5-3607
Sending a Report 5-4139
Sending Data 5-4072
sendto function 5-3607
Service Discovery 5-3957
SET_PA6_AS_OUTPUT macro 5-674
SetEntirePalette macro 5-1054
SetPalette function 5-876
SetPaletteBpp function 5-877
SetPaletteFlash function 5-877
Setting Bus Speed 5-1558
SHOW_DATA macro 5-1054
SIENNA macro 5-1054
SIN45 macro 5-1055
Single Compare Set High Mode 5-2291
Single Compare Toggle Mode 5-2292
Slave Mode 5-2821
SMI_SCAN_DATA_STATUS enumeration 5-285
SMTP Client Examples 5-3810
SMTP Client Long Message Example 5-3812
9 MPLAB Harmony Help
uuu
SMTP Client Short Message Example 5-3811
SMTP TCP/IP Stack Library 5-3809
smtp.h 5-3821
SMTP_CLIENT_MODULE_CONFIG structure 5-3820
smtp_config.h 5-3822
SMTP_CONNECT_ERROR macro 5-3819
SMTP_POINTERS structure 5-3820
SMTP_PORT macro 5-3814
SMTP_RESOLVE_ERROR macro 5-3819
SMTP_SERVER_REPLY_TIMEOUT macro 5-3814
SMTP_SUCCESS macro 5-3820
SNMP TCP/IP Stack Library 5-3822
snmp.h 5-3854
SNMP_BIB_FILE_NAME macro 5-3827
SNMP_BUFFER_DATA structure 5-3848
SNMP_COMMUNITY_MAX_LEN macro 5-3827
SNMP_COMMUNITY_TYPE enumeration 5-3848
snmp_config.h 5-3855
SNMP_END_OF_VAR macro 5-3846
SNMP_H macro 5-3846
SNMP_ID type 5-3849
SNMP_INDEX type 5-3849
SNMP_INDEX_INVALID macro 5-3847
SNMP_MAX_COMMUNITY_SUPPORT macro 5-3827
SNMP_MAX_MSG_SIZE macro 5-3828
SNMP_MAX_NON_REC_ID_OID macro 5-3828
SNMP_MODULE_CONFIG structure 5-3849
SNMP_NET_CONFIG structure 5-3831
SNMP_NON_MIB_RECD_INFO structure 5-3849
SNMP_NOTIFY_INFO structure 5-3849
SNMP_PROCESSING_MEM_INFO_PTRS structure 5-3850
SNMP_READ_COMMUNITIES macro 5-3828
SNMP_STACK_DCPT_STUB structure 5-3850
SNMP_START_OF_VAR macro 5-3847
SNMP_TRAP_COMMUNITY_MAX_LEN_MEM_USE macro
5-3828
SNMP_TRAP_INFO structure 5-3850
SNMP_TRAP_IP_ADDRESS_TYPE enumeration 5-3851
SNMP_V1 macro 5-3847
SNMP_V2C macro 5-3847
SNMP_V3 macro 5-3847
SNMP_VAL union 5-3851
SNMP_WRITE_COMMUNITIES macro 5-3828
SNMPGetExactIndex function 5-3841
SNMPGetNextIndex function 5-3841
SNMPGetVar function 5-3842
SNMPIsValidSetLen function 5-3842
SNMPSendTrap function 5-3843
SNMPSetVar function 5-3843
snmpv3.h 5-3856
SNMPV3_AUTH_LOCALIZED_PASSWORD_KEY_LEN_MEM_
USE
macro 5-3829
snmpv3_config.h 5-3857
SNMPV3_PRIV_LOCALIZED_PASSWORD_KEY_LEN_MEM_
USE
macro 5-3829
SNMPV3_PROCESSING_MEM_INFO_PTRS structure 5-3852
SNMPV3_STACK_DCPT_STUB structure 5-3852
SNMPV3_TRAP_MSG_PROCESS_MODEL_DB macro 5-3829
SNMPV3_TRAP_SECURITY_LEVEL_DB macro 5-3829
SNMPV3_TRAP_SECURITY_MODEL_TYPE_DB macro 5-3829
SNMPV3_TRAP_USER_SECURITY_NAME_DB macro 5-3829
SNMPV3_USER_AUTH_PASSWD_DB macro 5-3830
SNMPV3_USER_AUTH_TYPE_DB macro 5-3830
SNMPV3_USER_PRIV_PASSWD_DB macro 5-3830
SNMPV3_USER_PRIV_TYPE_DB macro 5-3830
SNMPV3_USER_SECURITY_NAME_DB macro 5-3830
SNMPV3_USER_SECURITY_NAME_LEN_MEM_USE macro
5-3830
SNMPV3_USM_MAX_USER macro 5-3831
SNMPv3ComputeHMACIpadOpadForAuthLoclzedKey function
5-3845
SNMPv3USMAuthPrivPswdLocalization function 5-3845
SNMPValidateCommunity function 5-3844
SNTP TCP/IP Stack Library 5-3858
sntp.h 5-3866
sntp_config.h 5-3867
SNTP_MODULE_CONFIG structure 5-3865
SNTP_RESULT enumeration 5-3865
SOCK_DGRAM macro 5-3610
9 MPLAB Harmony Help
vvv
SOCK_STREAM macro 5-3610
sockaddr structure 5-3612
SOCKADDR type 5-3611
sockaddr_in structure 5-3612
SOCKADDR_IN type 5-3611
socket function 5-3608
SOCKET type 5-3611
SOCKET_CNXN_IN_PROGRESS macro 5-3610
SOCKET_DISCONNECTED macro 5-3610
SOCKET_ERROR macro 5-3610
Software Drivers 5-299
Source Files to Include 5-3973
Source Interrupt Management 5-3423
Source/Destination/Peripheral Address Management 5-1745
Source/Destination/Peripheral Data Management 5-1746
Special Considerations 5-2600, 5-3473
Special Function Modules (CRC) 5-1747
SPI Driver Demonstrations 3-123
SPI Driver Library 5-417
SPI Error Handling 5-2823
SPI Master Mode and Frame Master Mode 5-2811
SPI Master Mode and Frame Slave Mode 5-2812
SPI Master Mode Clock Frequency 5-2823
SPI Peripheral Library 5-2798
SPI Receive-only Operation 5-2823
SPI Slave Mode and Frame Master Mode 5-2814, 5-2815
SPI_AUDIO_COMMUNICATION_WIDTH enumeration 5-2859
SPI_AUDIO_ERROR enumeration 5-2859
SPI_AUDIO_PROTOCOL enumeration 5-2859
SPI_AUDIO_TRANSMIT_MODE enumeration 5-2860
SPI_BAUD_RATE_CLOCK enumeration 5-2860
SPI_CLOCK_POLARITY enumeration 5-2860
SPI_COMMUNICATION_WIDTH enumeration 5-2861
SPI_DATA_TYPE type 5-2861
SPI_ERROR_INTERRUPT enumeration 5-2861
SPI_FIFO_INTERRUPT enumeration 5-2862
SPI_FIFO_TYPE enumeration 5-2863
SPI_FRAME_PULSE_DIRECTION enumeration 5-2863
SPI_FRAME_PULSE_EDGE enumeration 5-2863
SPI_FRAME_PULSE_POLARITY enumeration 5-2864
SPI_FRAME_PULSE_WIDTH enumeration 5-2864
SPI_FRAME_SYNC_PULSE enumeration 5-2864
SPI_INPUT_SAMPLING_PHASE enumeration 5-2865
SPI_MODULE_ID enumeration 5-2865
SPI_OUTPUT_DATA_PHASE enumeration 5-2866
SPI_PIN enumeration 5-2866
SPI_PRESCALE_PRIMARY enumeration 5-2867
SPI_PRESCALE_SECONDARY enumeration 5-2867
SQI Peripheral Library 5-2891
SQI_ADDR_BYTES enumeration 5-2966
SQI_BD_CTRL_WORD enumeration 5-2966
SQI_BD_STATE enumeration 5-2967
SQI_CLK_DIV enumeration 5-2968
SQI_CS_NUM enumeration 5-2969
SQI_CS_OEN enumeration 5-2969
SQI_DATA_FORMAT enumeration 5-2969
SQI_DATA_MODE enumeration 5-2970
SQI_DATA_OEN enumeration 5-2970
SQI_DATA_TYPE type 5-2970
SQI_DUMMY_BYTES enumeration 5-2971
SQI_INTERRUPTS enumeration 5-2971
SQI_LANE_MODE enumeration 5-2972
SQI_MODE_BYTES enumeration 5-2972
SQI_MODULE_ID enumeration 5-2973
SQI_XFER_CMD enumeration 5-2973
SQI_XFER_MODE enumeration 5-2974
ssd_demo 3-90
SSD1926 Graphics Controller Driver Library 5-333
SSL Client Support 5-3869
SSL Limitations 5-3870
SSL Server Support 5-3870
SSL TCP/IP Stack Library 5-3867
ssl.h 5-3879
ssl_config.h 5-3880
SSL_MAX_BUFFERS macro 5-3873
SSL_MAX_CONNECTIONS macro 5-3873
SSL_MAX_HASHES macro 5-3873
SSL_MAX_SESSIONS macro 5-3874
9 MPLAB Harmony Help
www
SSL_MIN_SESSION_LIFETIME macro 5-3874
SSL_MODULE_CONFIG structure 5-3879
SSL_MULTIPLE_INTERFACES macro 5-3874
SSL_RSA_CLIENT_SIZE macro 5-3874
SSL_RSA_KEY_SIZE macro 5-3874
SSL_RSA_LIFETIME_EXTENSION macro 5-3874
SSL_VERSION macro 5-3875
SSL_VERSION_HI macro 5-3875
SSL_VERSION_LO macro 5-3875
Standard ID Message Format 5-1555
Standard Master Mode 5-2804
Standard Slave Mode 5-2805
Standard SPI Mode 5-2804
Start Here 1-1
State Machine 5-2255, 5-2485, 5-2707, 5-2802, 5-3088
State-Driven Applications 3-101
States 5-698
Static Configuration 5-3425
Status (including Channel) 5-1748
Support for Legacy "Ethernet Controller Library" 5-232, 5-1920
Supported Demonstration Boards 3-67, 3-69, 3-71, 3-73, 3-75,
3-86, 3-87, 3-89, 3-90, 3-103, 3-114, 3-115, 3-116, 3-117,
3-124, 3-143, 3-153, 3-154, 3-156, 3-158, 3-160, 3-161, 3-162,
3-164, 3-166, 3-167, 3-169
Supported Hardware 3-131, 3-133, 3-135
Supported Libraries 4-181
SW License Agreement 2-41, 3-64, 3-85, 3-99, 3-102, 3-113,
3-123, 3-130, 3-142, 3-150, 5-194, 5-227, 5-254, 5-289, 5-299,
5-309, 5-320, 5-334, 5-343, 5-368, 5-398, 5-419, 5-458, 5-512,
5-553, 5-606, 5-680, 5-695, 5-1111, 5-1128, 5-1168, 5-1276,
5-1312, 5-1362, 5-1472, 5-1520, 5-1554, 5-1668, 5-1734,
5-1865, 5-1904, 5-2060, 5-2172, 5-2203, 5-2253, 5-2289,
5-2331, 5-2428, 5-2479, 5-2594, 5-2663, 5-2688, 5-2705,
5-2762, 5-2799, 5-2892, 5-3012, 5-3086, 5-3170, 5-3320,
5-3348, 5-3363, 5-3377, 5-3420, 5-3439, 5-3466, 5-3501,
5-3530, 5-3539, 5-3546, 5-3570, 5-3575, 5-3598, 5-3615,
5-3625, 5-3637, 5-3647, 5-3655, 5-3660, 5-3690, 5-3698,
5-3709, 5-3718, 5-3748, 5-3771, 5-3795, 5-3799, 5-3806,
5-3809, 5-3822, 5-3859, 5-3868, 5-3881, 5-3913, 5-3918,
5-3931, 5-3955, 5-3966, 5-3978, 5-4005, 5-4061, 5-4101,
5-4131, 5-4169, 5-4180, 5-4200, 6-4226, 7-4230, 7-4232,
7-4234, 7-4236
Sync Mode Selection 5-463
Synchronizing Timer 5-2174
Synchronous External Clock Counter 5-3016
Synchronous Internal Clock Counter 5-3015
Synchronous Master Mode 5-3095
Synchronous Slave Mode 5-3097
sys_clk.h 5-3362
SYS_CLK_ClockFailureCallbackRegister function 5-3353
SYS_CLK_ClockFrequencyGet function 5-3355
SYS_CLK_ClockFrequencySet function 5-3355
SYS_CLK_ClockIsReady function 5-3356
SYS_CLK_FRCTune function 5-3356
SYS_CLK_FRCTUNING_DATA structure 5-3358
SYS_CLK_FRCTuningSet function 5-3357
SYS_CLK_INIT structure 5-3358
SYS_CLK_Initialize function 5-3354
SYS_CLK_MZPeriphBusFreqGet function 5-3357
SYS_CLK_OUTPUT enumeration 5-3359
SYS_CLK_SOURCE enumeration 5-3360
sys_common.h 5-3345
sys_devcon.h 5-3375
sys_devcon_config.h 5-3375
SYS_DEVCON_Deinitialize function 5-3369
SYS_DEVCON_HANDLE type 5-3373
SYS_DEVCON_INDEX_0 macro 5-3374
SYS_DEVCON_INIT structure 5-3374
SYS_DEVCON_Initialize function 5-3369
SYS_DEVCON_PerformanceConfig function 5-3370
SYS_DEVCON_PIC32MX_MAX_PB_FREQ macro 5-3368
SYS_DEVCON_PRIMARY_CLOCK macro 5-3368
SYS_DEVCON_Reinitialize function 5-3371
SYS_DEVCON_Status function 5-3371
SYS_DEVCON_SYSTEM_CLOCK macro 5-3368
SYS_DEVCON_Tasks function 5-3372
sys_fs.h 5-3418
SYS_FS_ERROR enumeration 5-3411
SYS_FS_FILE_OPEN_ATTRIBUTES enumeration 5-3412
SYS_FS_FILE_SEEK_CONTROL enumeration 5-3413
SYS_FS_FILE_SYSTEM_TYPE enumeration 5-3414
SYS_FS_FileClose function 5-3398
SYS_FS_FileEOF function 5-3399
SYS_FS_FileError function 5-3407
SYS_FS_FileNameGet function 5-3406
9 MPLAB Harmony Help
xxx
SYS_FS_FileOpen function 5-3400
SYS_FS_FileRead function 5-3401
SYS_FS_FileSeek function 5-3401
SYS_FS_FileSize function 5-3402
SYS_FS_FileStat function 5-3403
SYS_FS_FileTell function 5-3404
SYS_FS_FileWrite function 5-3405
SYS_FS_FSTAT structure 5-3414
SYS_FS_FUNCTIONS structure 5-3415
SYS_FS_HANDLE type 5-3416
SYS_FS_HANDLE_INVALID macro 5-3417
SYS_FS_Initialize function 5-3407
SYS_FS_Mount function 5-3408
SYS_FS_REGISTRATION_TABLE structure 5-3416
SYS_FS_RESULT enumeration 5-3416
SYS_FS_Tasks 5-3397
SYS_FS_Tasks function 5-3410
SYS_FS_Unmount function 5-3410
SYS_Initialize function 5-3373
sys_int.h 5-3437
SYS_INT_Disable function 5-3429
SYS_INT_DynamicDeregister function 5-3428
SYS_INT_DynamicRegister function 5-3428
SYS_INT_Enable function 5-3430
SYS_INT_Initialize function 5-3427
SYS_INT_IsEnabled function 5-3430
SYS_INT_SourceDisable function 5-3431
SYS_INT_SourceEnable function 5-3432
SYS_INT_SourceIsEnabled function 5-3432
SYS_INT_SourceStatusClear function 5-3433
SYS_INT_SourceStatusGet function 5-3433
SYS_INT_SourceStatusSet function 5-3434
SYS_INT_TASKS_POINTER type 5-3437
SYS_INT_VectorPrioritySet function 5-3435
SYS_INT_VectorSubprioritySet function 5-3436
SYS_MEDIA_EVENT enumeration 5-415
sys_module.h 5-3346
SYS_MODULE_DATA structure 5-3334
SYS_MODULE_DEINITIALIZE_ROUTINE type 5-3335
SYS_MODULE_INDEX type 5-3335
SYS_MODULE_INIT union 5-3335
SYS_MODULE_INITIALIZE_ROUTINE type 5-3336
SYS_MODULE_INTERFACE structure 5-3337
SYS_MODULE_OBJ type 5-3338
SYS_MODULE_OBJ_INVALID macro 5-3342
SYS_MODULE_OBJ_STATIC macro 5-3343
SYS_MODULE_POWER_IDLE_RUN macro 5-3343
SYS_MODULE_POWER_IDLE_STOP macro 5-3343
SYS_MODULE_POWER_OFF macro 5-3344
SYS_MODULE_POWER_RUN_FULL macro 5-3344
SYS_MODULE_POWER_SLEEP macro 5-3344
SYS_MODULE_REINITIALIZE_ROUTINE type 5-3338
SYS_MODULE_STATUS_ROUTINE type 5-3339
SYS_MODULE_TASKS_DATA structure 5-3339
SYS_MODULE_TASKS_ROUTINE type 5-3340
SYS_MSB_MailboxClose function 5-3449
SYS_MSB_MailboxOpen function 5-3449
SYS_MSB_MailboxReinit function 5-3450
sys_msg.h 5-3463
SYS_MSG_BUFFER_SIZES macro 5-3458
sys_msg_config.h 5-3464
SYS_MSG_Deinitialize function 5-3445
SYS_MSG_GotMessages function 5-3454
SYS_MSG_ID2hMsgType function 5-3456
SYS_MSG_INIT structure 5-3459
SYS_MSG_Initialize function 5-3446
SYS_MSG_INSTANCE enumeration 5-3460
SYS_MSG_MAILBOXES_ADDONE macro 5-3462
SYS_MSG_MailboxMessagesGet function 5-3450
SYS_MSG_MailboxMsgAdd function 5-3451
SYS_MSG_MailboxMsgRemove function 5-3452
SYS_MSG_MAX_MAILBOXES macro 5-3458
SYS_MSG_MAX_MSGS_DELIVERED macro 5-3458
SYS_MSG_MAX_PRIORITY macro 5-3459
SYS_MSG_MAX_TYPES macro 5-3459
SYS_MSG_MessageDeliver function 5-3454
SYS_MSG_MessageReceive function 5-3455
SYS_MSG_MessageSend function 5-3456
9 MPLAB Harmony Help
yyy
SYS_MSG_NUM_MAILBOX_BITMAPS macro 5-3463
SYS_MSG_OBJECT structure 5-3460
SYS_MSG_QUEUE_STATUS enumeration 5-3461
SYS_MSG_QueueStatus function 5-3457
SYS_MSG_RECEIVE_CALLBACK type 5-3461
SYS_MSG_RESULTS enumeration 5-3461
SYS_MSG_Tasks function 5-3447
SYS_MSG_TypeCreate function 5-3453
SYS_MSG_TypeRemove function 5-3453
SYS_MSG_VersionGet function 5-3447
SYS_MSG_VersionStrGet function 5-3448
SYS_MSGQ_ELEMENT structure 5-3462
SYS_OBJ_HANDLE type 5-286
SYS_OBJ_HANDLE_INVALID macro 5-286
SYS_OBJ_HANDLE_STATIC macro 5-286
sys_ports.h 5-3498
SYS_PORTS_ChangeNotificationDisable function 5-3489
SYS_PORTS_ChangeNotificationEnable function 5-3489
SYS_PORTS_ChangeNotificationGlobalDisable function 5-3490
SYS_PORTS_ChangeNotificationGlobalEnable function 5-3490
SYS_PORTS_ChangeNotificationInIdleModeDisable function
5-3491
SYS_PORTS_ChangeNotificationInIdleModeEnable function
5-3491
SYS_PORTS_ChangeNotificationPullDownDisable function
5-3491
SYS_PORTS_ChangeNotificationPullDownEnable function
5-3492
SYS_PORTS_ChangeNotificationPullUpDisable function 5-3493
SYS_PORTS_ChangeNotificationPullUpEnable function 5-3493
SYS_PORTS_ChangeNotificationStatus function 5-3494
SYS_PORTS_Clear function 5-3482
SYS_PORTS_DirectionGet function 5-3483
SYS_PORTS_DirectionSelect function 5-3483
SYS_PORTS_IOLockDisable function 5-3494
SYS_PORTS_IOLockEnable function 5-3495
SYS_PORTS_IOLockIsActive function 5-3495
SYS_PORTS_OpenDrainDisable function 5-3484
SYS_PORTS_OpenDrainEnable function 5-3484
SYS_PORTS_PIN_DIRECTION enumeration 5-3497
SYS_PORTS_PinClear function 5-3481
SYS_PORTS_PinDirectionSelect function 5-3481
SYS_PORTS_PinModeSelect function 5-3476
SYS_PORTS_PinOpenDrainDisable function 5-3476
SYS_PORTS_PinOpenDrainEnable function 5-3477
SYS_PORTS_PinPullUpDisable function 5-3477
SYS_PORTS_PinPullUpEnable function 5-3478
SYS_PORTS_PinRead function 5-3479
SYS_PORTS_PinSet function 5-3479
SYS_PORTS_PinToggle function 5-3480
SYS_PORTS_PinWrite function 5-3480
SYS_PORTS_PULLUP_PULLDOWN_STATUS enumeration
5-3497
SYS_PORTS_PullUpDisable function 5-3485
SYS_PORTS_PullUpEnable function 5-3486
SYS_PORTS_Read function 5-3486
SYS_PORTS_RemapInput function 5-3496
SYS_PORTS_RemapOutput function 5-3496
SYS_PORTS_Set function 5-3487
SYS_PORTS_Toggle function 5-3487
SYS_PORTS_Write function 5-3488
SYS_STATUS enumeration 5-3340
SYS_Tasks function 5-3333
SYS_TASKS_PRIORITY enumeration 5-3341
SYS_TASKS_PRIORITY_HIGH enumeration member 5-3341
SYS_TASKS_PRIORITY_INVALID enumeration member
5-3341
SYS_TASKS_PRIORITY_LOW enumeration member 5-3341
SYS_TASKS_PRIORITY_MEDIUM enumeration member
5-3341
sys_tmr.h 5-3528
SYS_TMR_AlarmPeriodGet function 5-3525
SYS_TMR_CALLBACK type 5-3525
SYS_TMR_CallbackPeriodic function 5-3522
SYS_TMR_CallbackSingle function 5-3523
SYS_TMR_CallbackStop function 5-3523
sys_tmr_config.h 5-3529
SYS_TMR_Deinitialize function 5-3518
SYS_TMR_DELAY_STATUS enumeration 5-3526
SYS_TMR_DelayMS function 5-3524
SYS_TMR_DelayStatusGet function 5-3524
9 MPLAB Harmony Help
zzz
SYS_TMR_ERROR_TOLERANCE macro 5-3516
SYS_TMR_HANDLE type 5-3526
SYS_TMR_HANDLE_INVALID macro 5-3527
SYS_TMR_INDEX_0 macro 5-3527
SYS_TMR_INIT structure 5-3526
SYS_TMR_Initialize function 5-3519
SYS_TMR_INTERRUPT_MODE macro 5-3516
SYS_TMR_MAX_PERIODIC_EVENTS macro 5-3517
SYS_TMR_Reinitialize function 5-3520
SYS_TMR_RUNNING macro 5-3527
SYS_TMR_SINGLE_PERIODIC_EVENT macro 5-3517
SYS_TMR_Status function 5-3521
SYS_TMR_Tasks function 5-3521
SYS_TMR_TickCountGet function 5-3525
sys_wdt.h 5-3534
sys_wdt_config.h 5-3535
SYS_WDT_Disable function 5-3533
SYS_WDT_Enable function 5-3533
SYS_WDT_TimerClear function 5-3533
System Access 5-421
System Bus Peripheral Library 5-2762
System Config 5-476
System Configuration 5-428, 5-3390
System Configuration Functions 5-4173
System Initialization 5-195, 5-345, 5-370, 5-514, 5-608, 7-4229
System Interaction 5-459, 5-3365, 5-3507, 5-4170
System Overview 3-63
System Service Library Help 5-3332
System Service Overview 5-3332
system.h 5-3347
system_config.h 1-16
system_init.c 1-17
system_int.c 1-19
system_tasks.c 1-19
SYSTEMConfigPerformance function 7-4240
T
Table of Library Functions 5-1170, 5-1277
TAN macro 5-1055
Target Initialization 5-2765
TCP Changes 5-3548
TCP TCP/IP Stack Library 5-3880
tcp.h 5-3910
TCP/IP Demonstrations 3-130
TCP/IP Discoverer 5-3545
TCP/IP Library Overview 5-3536
TCP/IP Stack Library Help 5-3536
TCP/IP Stack Porting Guide 5-3545
TCP_ADJUST_FLAGS enumeration 5-3907
TCP_AUTO_TRANSMIT_TIMEOUT_VAL macro 5-3885
TCP_CLOSE_WAIT_TIMEOUT macro 5-3885
tcp_config.h 5-3912
TCP_DELAYED_ACK_TIMEOUT macro 5-3885
TCP_FIN_WAIT_2_TIMEOUT macro 5-3886
TCP_KEEP_ALIVE_TIMEOUT macro 5-3886
TCP_MAX_RETRIES macro 5-3886
TCP_MAX_SEG_SIZE_RX_LOCAL macro 5-3886
TCP_MAX_SEG_SIZE_RX_NON_LOCAL macro 5-3886
TCP_MAX_SEG_SIZE_TX macro 5-3887
TCP_MAX_SOCKETS macro 5-3887
TCP_MAX_SYN_RETRIES macro 5-3887
TCP_MAX_UNACKED_KEEP_ALIVES macro 5-3887
TCP_MODULE_CONFIG structure 5-3907
TCP_OPTION_LINGER_DATA structure 5-3908
TCP_PORT type 5-3908
TCP_SOCKET type 5-3908
TCP_SOCKET_DEFAULT_RX_SIZE macro 5-3887
TCP_SOCKET_DEFAULT_TX_SIZE macro 5-3888
TCP_SOCKET_INFO structure 5-3909
TCP_SOCKET_OPTION enumeration 5-3909
TCP_START_TIMEOUT_VAL macro 5-3888
TCP_TASK_TICK_RATE macro 5-3888
TCP_WINDOW_UPDATE_TIMEOUT_VAL macro 5-3888
tcpip_announce_config.h 5-3574
TCPIP_ANNOUNCE_DeInit function 5-3572
TCPIP_ANNOUNCE_Init function 5-3572
tcpip_announce_manager.h 5-3574
TCPIP_ANNOUNCE_MODULE_CONFIG structure 5-3573
9 MPLAB Harmony Help
aaaa
TCPIP_ANNOUNCE_Send function 5-3573
TCPIP_ANNOUNCE_Task function 5-3573
TCPIP_ANNOUNCE_TaskPending function 5-3573
TCPIP_ARP_CacheEntriesNoGet function 5-3589
TCPIP_ARP_CacheThresholdSet function 5-3590
TCPIP_ARP_CallbacksDeregister function 5-3581
TCPIP_ARP_CallbacksRegister function 5-3581
TCPIP_ARP_Deinitialize function 5-3582
TCPIP_ARP_ENTRY_QUERY structure 5-3592
TCPIP_ARP_ENTRY_TYPE enumeration 5-3592
TCPIP_ARP_EntryGet function 5-3582
TCPIP_ARP_EntryQuery function 5-3590
TCPIP_ARP_EntryRemove function 5-3583
TCPIP_ARP_EntryRemoveAll function 5-3591
TCPIP_ARP_EntryRemoveNet function 5-3584
TCPIP_ARP_EntrySet function 5-3588
TCPIP_ARP_EVENT_HANDLER type 5-3592
TCPIP_ARP_EVENT_TYPE enumeration 5-3593
TCPIP_ARP_HANDLE type 5-3593
TCPIP_ARP_HandlerDeRegister function 5-3584
TCPIP_ARP_HandlerRegister function 5-3585
TCPIP_ARP_Initialize function 5-3585
TCPIP_ARP_IsResolved function 5-3586
TCPIP_ARP_OPERATION_TYPE enumeration 5-3593
TCPIP_ARP_Probe function 5-3586
TCPIP_ARP_Process function 5-3589
TCPIP_ARP_Resolve function 5-3587
TCPIP_ARP_RESULT enumeration 5-3594
TCPIP_ARP_Task function 5-3588
TCPIP_ARP_TaskIsPending function 5-3588
TCPIP_DDNS_LastIPGet function 5-3649
TCPIP_DDNS_LastStatusGet function 5-3649
TCPIP_DDNS_ServiceSet function 5-3650
TCPIP_DDNS_UpdateForce function 5-3650
TCPIP_DHCP_Disable function 5-3618
TCPIP_DHCP_Enable function 5-3619
TCPIP_DHCP_EVENT_HANDLER type 5-3623
TCPIP_DHCP_EVENT_TYPE enumeration 5-3623
TCPIP_DHCP_HANDLE type 5-3623
TCPIP_DHCP_HandlerDeRegister function 5-3619
TCPIP_DHCP_HandlerRegister function 5-3619
TCPIP_DHCP_IsBound function 5-3621
TCPIP_DHCP_IsEnabled function 5-3621
TCPIP_DHCP_IsServerDetected function 5-3622
TCPIP_DHCP_Renew function 5-3620
TCPIP_DHCP_Request function 5-3620
TCPIP_DHCP_RequestTimeoutSet function 5-3621
TCPIP_DHCPS_Disable function 5-3630
TCPIP_DHCPS_Enable function 5-3631
TCPIP_DHCPS_GetPoolEntries function 5-3631
TCPIP_DHCPS_IsEnabled function 5-3633
TCPIP_DHCPS_LeaseEntryGet function 5-3632
TCPIP_DHCPS_RemovePoolEntries function 5-3632
TCPIP_DNS_IsResolved function 5-3641
TCPIP_DNS_Resolve function 5-3641
TCPIP_DNS_UsageBegin function 5-3642
TCPIP_DNS_UsageEnd function 5-3642
TCPIP_FTP_DATA_SKT_RX_BUFF_SIZE macro 5-3656
TCPIP_FTP_DATA_SKT_TX_BUFF_SIZE macro 5-3657
TCPIP_FTP_MAX_CONNECTIONS macro 5-3657
TCPIP_FTP_PASSWD_LEN macro 5-3657
TCPIP_FTP_PUT_ENABLED macro 5-3657
TCPIP_FTP_USER_NAME_LEN macro 5-3657
TCPIP_HTTP_ActiveConnectionCountGet function 5-3666
TCPIP_HTTP_ArgGet function 5-3667
TCPIP_HTTP_CurrentConnectionByteCountDec function
5-3668
TCPIP_HTTP_CurrentConnectionByteCountGet function 5-3668
TCPIP_HTTP_CurrentConnectionByteCountSet function 5-3669
TCPIP_HTTP_CurrentConnectionCallbackPosGet function
5-3669
TCPIP_HTTP_CurrentConnectionCallbackPosSet function
5-3670
TCPIP_HTTP_CurrentConnectionDataBufferGet function 5-3670
TCPIP_HTTP_CurrentConnectionFileGet function 5-3671
TCPIP_HTTP_CurrentConnectionHasArgsSet function 5-3671
TCPIP_HTTP_CurrentConnectionIsAuthorizedGet function
5-3672
TCPIP_HTTP_CurrentConnectionIsAuthorizedSet function
5-3672
9 MPLAB Harmony Help
bbbb
TCPIP_HTTP_CurrentConnectionPostSmGet function 5-3673
TCPIP_HTTP_CurrentConnectionPostSmSet function 5-3673
TCPIP_HTTP_CurrentConnectionSocketGet function 5-3674
TCPIP_HTTP_CurrentConnectionStatusSet function 5-3675
TCPIP_HTTP_CurrentConnectionUserDataGet function 5-3675
TCPIP_HTTP_CurrentConnectionUserDataSet function 5-3676
TCPIP_HTTP_FileInclude function 5-3676
TCPIP_HTTP_PostNameRead function 5-3677
TCPIP_HTTP_PostValueRead function 5-3678
TCPIP_HTTP_URLDecode function 5-3679
TCPIP_ICMP_CallbackDeregister function 5-3693
TCPIP_ICMP_CallbackRegister function 5-3693
TCPIP_ICMP_EchoRequestSend function 5-3694
TCPIP_ICMPV6_CallbackDeregister function 5-3701
TCPIP_ICMPV6_CallbackRegister function 5-3702
TCPIP_ICMPV6_Close function 5-3702
TCPIP_ICMPV6_Flush function 5-3702
TCPIP_ICMPV6_HeaderEchoRequestPut function 5-3703
TCPIP_ICMPV6_PutHeaderEchoReply macro 5-3704
TCPIP_IF_PIC32INT macro 5-262
TCPIP_IPV4_PacketFormatTx function 5-3712
TCPIP_IPV4_PacketGetDestAddress function 5-3713
TCPIP_IPV4_PacketGetSourceAddress function 5-3713
TCPIP_IPV4_PacketTransmit function 5-3714
TCPIP_IPV4_SelectSourceInterface function 5-3714
TCPIP_IPV6_AddressUnicastRemove function 5-3725
TCPIP_IPV6_ArrayGet function 5-3725
TCPIP_IPV6_ArrayPutHelper function 5-3726
TCPIP_IPV6_DASSourceAddressSelect function 5-3726
TCPIP_IPV6_DestAddressGet function 5-3727
TCPIP_IPV6_DestAddressSet function 5-3727
TCPIP_IPV6_Flush function 5-3728
TCPIP_IPV6_Get function 5-3728
TCPIP_IPV6_HandlerDeregister function 5-3728
TCPIP_IPV6_HandlerRegister function 5-3729
TCPIP_IPV6_InterfaceIsReady function 5-3729
TCPIP_IPV6_MulticastListenerAdd function 5-3730
TCPIP_IPV6_MulticastListenerRemove function 5-3730
TCPIP_IPV6_PacketFree function 5-3731
TCPIP_IPV6_PayloadSet function 5-3731
TCPIP_IPV6_Put function 5-3732
TCPIP_IPV6_PutArray macro 5-3738
TCPIP_IPV6_SourceAddressGet function 5-3732
TCPIP_IPV6_SourceAddressSet function 5-3733
TCPIP_IPV6_TxIsPutReady function 5-3733
TCPIP_IPV6_TxPacketAllocate function 5-3734
TCPIP_IPV6_UnicastAddressAdd function 5-3734
TCPIP_IPV6_UniqueLocalUnicastAddressAdd function 5-3735
TCPIP_LOCAL_MASK_TYPE enumeration 5-3793
tcpip_mac.h 5-3770
TCPIP_MAC_ACTION enumeration 5-3757
TCPIP_MAC_ADDR structure 5-3758
TCPIP_MAC_Close function 5-3753
tcpip_mac_config.h 5-3770
TCPIP_MAC_DATA_SEGMENT type 5-3758
TCPIP_MAC_Deinitialize function 5-3753
TCPIP_MAC_ETHERNET_HEADER structure 5-3758
TCPIP_MAC_EVENT enumeration 5-3758
TCPIP_MAC_EventAcknowledge function 5-3753
TCPIP_MAC_EventF type 5-3760
TCPIP_MAC_EventMaskSet function 5-3753
TCPIP_MAC_EventPendingGet function 5-3754
TCPIP_MAC_HANDLE type 5-3761
TCPIP_MAC_HEAP_CallocF type 5-3761
TCPIP_MAC_HEAP_FreeF type 5-3761
TCPIP_MAC_HEAP_HANDLE type 5-3762
TCPIP_MAC_HEAP_MallocF type 5-3762
TCPIP_MAC_Initialize function 5-3754
TCPIP_MAC_LinkCheck function 5-3754
TCPIP_MAC_MODULE_CTRL structure 5-3762
TCPIP_MAC_Open function 5-3754
TCPIP_MAC_PACKET type 5-3763
TCPIP_MAC_PACKET_ACK_FUNC type 5-3763
TCPIP_MAC_PACKET_FLAGS enumeration 5-3763
TCPIP_MAC_PACKET_RX_STAT structure 5-3764
TCPIP_MAC_PacketRx function 5-3754
TCPIP_MAC_PacketTx function 5-3755
TCPIP_MAC_PKT_ACK_RES enumeration 5-3765
9 MPLAB Harmony Help
cccc
TCPIP_MAC_PKT_AckF type 5-3766
TCPIP_MAC_PKT_AllocF type 5-3766
TCPIP_MAC_PKT_FreeF type 5-3766
TCPIP_MAC_POWER_MODE enumeration 5-3766
TCPIP_MAC_Process function 5-3756
TCPIP_MAC_PROCESS_FLAGS enumeration 5-3767
TCPIP_MAC_Reinitialize function 5-3757
TCPIP_MAC_RES enumeration 5-3767
TCPIP_MAC_RxFilterHashTableEntrySet function 5-3757
TCPIP_MAC_SEGMENT_FLAGS enumeration 5-3768
tcpip_manager.h 5-3793
TCPIP_MDNS_ServiceDeregister function 5-3958
TCPIP_MDNS_ServiceRegister function 5-3959
TCPIP_MDNS_ServiceUpdate function 5-3960
TCPIP_MODULE_MAC_97J60_CONFIG structure 5-3768
TCPIP_MODULE_MAC_ENCJ60_CONFIG structure 5-3768
TCPIP_MODULE_MAC_ENCJ600_CONFIG structure 5-3769
TCPIP_MODULE_MAC_MRF24W_CONFIG structure 5-3769
TCPIP_MODULE_MAC_PIC32INT_CONFIG structure 5-3769
TCPIP_NDP_NborReachConfirm function 5-3804
TCPIP_NET_HANDLE type 5-3793
tcpip_reboot_config.h 5-3808
TCPIP_SMTP_ArrayPut function 5-3815
TCPIP_SMTP_Flush function 5-3816
TCPIP_SMTP_IsBusy function 5-3816
TCPIP_SMTP_IsPutReady function 5-3816
TCPIP_SMTP_MailSend function 5-3817
TCPIP_SMTP_Put function 5-3817
TCPIP_SMTP_PutIsDone function 5-3818
TCPIP_SMTP_StringPut function 5-3818
TCPIP_SMTP_UsageBegin function 5-3818
TCPIP_SMTP_UsageEnd function 5-3819
TCPIP_SNMP_ClientGetNet function 5-3834
TCPIP_SNMP_DataCopyToProcessBuffer function 5-3834
TCPIP_SNMP_DCPT structure 5-3851
TCPIP_SNMP_EventNotifyGet function 5-3835
TCPIP_SNMP_Notify function 5-3835
TCPIP_SNMP_NotifyIsReady function 5-3836
TCPIP_SNMP_NotifyPrepare function 5-3837
TCPIP_SNMP_PacketProcStubPtrsGet function 5-3837
TCPIP_SNMP_ProcessBufferDataGet function 5-3838
TCPIP_SNMP_ReadCommunityGet function 5-3838
TCPIP_SNMP_SM enumeration 5-3852
TCPIP_SNMP_TrapTimeGet function 5-3839
TCPIP_SNMP_WriteCommunityGet function 5-3839
TCPIP_SNMPv3_CmprTrapSecNameAndSecLvlWithUSMDb
function 5-3845
TCPIP_SNMPv3_Notify function 5-3839
TCPIP_SNMPV3_PacketProcStubPtrsGet function 5-3840
TCPIP_SNTP_ConnectionInitiate function 5-3863
TCPIP_SNTP_ConnectionParamSet function 5-3863
TCPIP_SNTP_LastErrorGet function 5-3864
TCPIP_SNTP_TimeStampGet function 5-3864
TCPIP_SNTP_UTCSecondsGet function 5-3865
TCPIP_STACK_Deinitialize function 5-3774
TCPIP_STACK_IndexToNet function 5-3777
TCPIP_STACK_Initialize function 5-3774
TCPIP_STACK_ModuleGetConfig function 5-3783
TCPIP_STACK_NetAddress function 5-3784
TCPIP_STACK_NetAddressBcast function 5-3784
TCPIP_STACK_NetAddressDnsPrimary function 5-3785
TCPIP_STACK_NetAddressDnsPrimarySet function 5-3785
TCPIP_STACK_NetAddressDnsSecond function 5-3786
TCPIP_STACK_NetAddressDnsSecondSet function 5-3786
TCPIP_STACK_NetAddressGateway function 5-3787
TCPIP_STACK_NetAddressGatewaySet function 5-3787
TCPIP_STACK_NetAddressMac function 5-3788
TCPIP_STACK_NetAddressMacSet function 5-3788
TCPIP_STACK_NetAddressSet function 5-3789
TCPIP_STACK_NetBIOSName function 5-3777
TCPIP_STACK_NetBiosNameSet function 5-3778
TCPIP_STACK_NetConfigGet function 5-3790
TCPIP_STACK_NetConfigSet function 5-3791
TCPIP_STACK_NetDefaultGet function 5-3778
TCPIP_STACK_NetDefaultSet function 5-3779
TCPIP_STACK_NetDown function 5-3781
TCPIP_STACK_NetHandleGet function 5-3779
TCPIP_STACK_NetIndexGet function 5-3780
TCPIP_STACK_NetIPv6AddressGet function 5-3790
9 MPLAB Harmony Help
dddd
TCPIP_STACK_NetIsLinked function 5-3782
TCPIP_STACK_NetIsUp function 5-3782
TCPIP_STACK_NetMACId function 5-3792
TCPIP_STACK_NetMask function 5-3780
TCPIP_STACK_NetNameGet function 5-3780
TCPIP_STACK_NetUp function 5-3783
TCPIP_STACK_NumberOfNetworksGet function 5-3781
TCPIP_STACK_SetLocalMasks function 5-3775
TCPIP_STACK_SetLocalMasksType function 5-3776
TCPIP_STACK_Task function 5-3777
TCPIP_STACK_USE_BASE64_DECODE macro 5-3665
TCPIP_TCP_Abort function 5-3897
TCPIP_TCP_ArrayFind function 5-3901
TCPIP_TCP_ArrayGet function 5-3902
TCPIP_TCP_ArrayPeek function 5-3902
TCPIP_TCP_ArrayPut function 5-3898
TCPIP_TCP_Bind function 5-3890
TCPIP_TCP_ClientOpen function 5-3891
TCPIP_TCP_Close function 5-3891
TCPIP_TCP_Connect function 5-3892
TCPIP_TCP_Discard function 5-3903
TCPIP_TCP_Disconnect function 5-3892
TCPIP_TCP_FifoRxFreeGet function 5-3906
TCPIP_TCP_FifoRxFullGet macro 5-3906
TCPIP_TCP_FifoSizeAdjust function 5-3903
TCPIP_TCP_FifoTxFreeGet macro 5-3907
TCPIP_TCP_FifoTxFullGet function 5-3899
TCPIP_TCP_Find function 5-3904
TCPIP_TCP_Flush function 5-3899
TCPIP_TCP_Get function 5-3905
TCPIP_TCP_GetIsReady function 5-3905
TCPIP_TCP_IsConnected function 5-3893
TCPIP_TCP_OptionsGet function 5-3893
TCPIP_TCP_OptionsSet function 5-3894
TCPIP_TCP_Peek function 5-3905
TCPIP_TCP_Put function 5-3899
TCPIP_TCP_PutIsReady function 5-3900
TCPIP_TCP_RemoteBind function 5-3894
TCPIP_TCP_ServerOpen function 5-3895
TCPIP_TCP_SocketInfoGet function 5-3896
TCPIP_TCP_SocketIsSecuredBySSL function 5-3876
TCPIP_TCP_SocketNetGet function 5-3896
TCPIP_TCP_SocketNetSet function 5-3898
TCPIP_TCP_StringPut function 5-3900
TCPIP_TCP_WasReset function 5-3896
TCPIP_TCPSSL_ClientBegin function 5-3876
TCPIP_TCPSSL_ClientStart function 5-3877
TCPIP_TCPSSL_HandshakeClear function 5-3877
TCPIP_TCPSSL_ListenerAdd function 5-3878
TCPIP_TCPSSL_ServerStart function 5-3878
TCPIP_TCPSSL_StillHandshaking function 5-3879
TCPIP_TFTP_DataByteGet function 5-3922
TCPIP_TFTP_DataBytePut function 5-3923
TCPIP_TFTP_DataIsGetReady function 5-3923
TCPIP_TFTP_FileClose function 5-3923
TCPIP_TFTP_FileIsClosed function 5-3923
TCPIP_TFTP_FileIsOpen function 5-3923
TCPIP_TFTP_FragRAMFileUploadToHost function 5-3923
TCPIP_TFTP_IsOpen function 5-3924
TCPIP_TFTP_IsReadyForPut function 5-3924
TCPIP_TFTP_Open function 5-3924
TCPIP_TFTP_RAMFileUploadToHost function 5-3924
TCPIP_TFTP_UploadStatusGet function 5-3924
TCPIP_UDP_ArrayGet function 5-3944
TCPIP_UDP_ArrayPut function 5-3947
TCPIP_UDP_BcastIPV4AddressSet function 5-3937
TCPIP_UDP_Bind function 5-3937
TCPIP_UDP_ClientOpen function 5-3938
TCPIP_UDP_Close function 5-3938
TCPIP_UDP_DestinationIPAddressSet function 5-3939
TCPIP_UDP_Discard function 5-3948
TCPIP_UDP_Flush function 5-3945
TCPIP_UDP_Get function 5-3949
TCPIP_UDP_GetIsReady function 5-3949
TCPIP_UDP_IsConnected function 5-3939
TCPIP_UDP_IsOpened macro 5-3950
TCPIP_UDP_OptionsGet function 5-3940
TCPIP_UDP_OptionsSet function 5-3940
9 MPLAB Harmony Help
eeee
TCPIP_UDP_Put function 5-3945
TCPIP_UDP_RemoteBind function 5-3941
TCPIP_UDP_RxOffsetSet function 5-3949
TCPIP_UDP_ServerOpen function 5-3942
TCPIP_UDP_SocketInfoGet function 5-3942
TCPIP_UDP_SocketNetGet function 5-3942
TCPIP_UDP_SocketNetSet function 5-3943
TCPIP_UDP_SourceIPAddressSet function 5-3943
TCPIP_UDP_StringPut function 5-3946
TCPIP_UDP_TxCountGet function 5-3946
TCPIP_UDP_TxOffsetSet function 5-3944
TCPIP_UDP_TxPutIsReady function 5-3947
TCPIP_ZCLL_Disable function 5-3960
TCPIP_ZCLL_Enable function 5-3961
TCPIP_ZCLL_IsEnabled function 5-3961
TE_ROUNDEDBUTTON_RADIUS macro 5-1055
Telnet TCP/IP Stack Library 5-3913
telnet.h 5-3917
telnet_config.h 5-3917
TELNET_MODULE_CONFIG structure 5-3916
TELNET_PASSWORD macro 5-3915
TELNET_PORT macro 5-3915
TELNET_USERNAME macro 5-3915
TELNETS_PORT macro 5-3916
TFTP TCP/IP Stack Library 5-3917
TFTP_ACCESS_ERROR type 5-3928
TFTP_ARP_TIMEOUT_VAL macro 5-3920
TFTP_BLOCK_SIZE macro 5-3920
TFTP_BLOCK_SIZE_MSB macro 5-3920
TFTP_CHUNK_DESCRIPTOR structure 5-3928
TFTP_CLIENT_PORT macro 5-3921
TFTP_FILE_MODE type 5-3928
TFTP_GET_TIMEOUT_VAL macro 5-3921
TFTP_MAX_RETRIES macro 5-3921
TFTP_RESULT type 5-3928
TFTP_SERVER_PORT macro 5-3921
TFTP_UPLOAD_COMPLETE macro 5-3925
TFTP_UPLOAD_CONNECT macro 5-3925
TFTP_UPLOAD_CONNECT_TIMEOUT macro 5-3925
TFTP_UPLOAD_GET_DNS macro 5-3925
TFTP_UPLOAD_HOST_RESOLVE_TIMEOUT macro 5-3925
TFTP_UPLOAD_RESOLVE_HOST macro 5-3926
TFTP_UPLOAD_SEND_DATA macro 5-3926
TFTP_UPLOAD_SEND_FILENAME macro 5-3926
TFTP_UPLOAD_SERVER_ERROR macro 5-3926
TFTP_UPLOAD_WAIT_FOR_CLOSURE macro 5-3926
tftpc.h 5-3929
tftpc_config.h 5-3930
TFTPClose macro 5-3926
TFTPGetError macro 5-3927
TFTPIsFileOpenReady macro 5-3927
TFTPOpenFile function 5-3925
The Application File(s) 1-13
The Main File 1-12
Third-Party Library Help 6-4225
Third-Party Library Overview 6-4226
Thread Operation 5-1316
Timer Driver Library 5-457
Timer Peripheral Library 5-3011
Timer System Service Library 5-3500
tIPV6_SNMP_TRAP_INFO structure 5-3848
TMR_ASSIGNMENT enumeration 5-3060
TMR_CLOCK_SOURCE enumeration 5-3060
TMR_CLOCK_SOURCE_EDGE enumeration 5-3060
TMR_GATE_POLARITY enumeration 5-3061
TMR_GATE_SOURCE enumeration 5-3061
TMR_MODULE_ID enumeration 5-3062
TMR_POSTSCALE enumeration 5-3062
TMR_PRESCALE enumeration 5-3063
TPL_MATCH_VID_PID macro 5-4196
Transfer Abort 5-573
Transfer Operation 5-372
Transfer Requests 5-565
Transfer Status 5-572
Transfer/Abort (Asynchronous) Trigger Management 5-1737
Transfer/Abort (Synchronous) 5-1737
Transferring Data 5-3984
Transitions 5-1122
9 MPLAB Harmony Help
ffff
Transmit 5-1918
Transmitting a CAN Message 5-1561
TRAP_COMMUNITY_MAX_LEN macro 5-3831
TRAP_TABLE_SIZE macro 5-3831
tSNMP_TRAP_INFO structure 5-3850
Tutorial 2-49
U
uC_OS_III_basic_demo 3-115
UDP Changes 5-3550
UDP TCP/IP Stack Library 5-3930
udp.h 5-3953
udp_config.h 5-3954
UDP_LOCAL_PORT_END_NUMBER macro 5-3933
UDP_LOCAL_PORT_START_NUMBER macro 5-3934
UDP_MAX_SOCKETS macro 5-3934
UDP_MODULE_CONFIG structure 5-3950
UDP_PORT type 5-3951
UDP_SOCKET type 5-3951
UDP_SOCKET_BCAST_TYPE enumeration 5-3951
UDP_SOCKET_DEFAULT_TX_QUEUE_LIMIT macro 5-3934
UDP_SOCKET_DEFAULT_TX_SIZE macro 5-3934
UDP_SOCKET_INFO structure 5-3951
UDP_SOCKET_OPTION enumeration 5-3952
UDP_SOCKET_POOL_BUFFER_SIZE macro 5-3934
UDP_SOCKET_POOL_BUFFERS macro 5-3935
UDP_USE_RX_CHECKSUM macro 5-3935
UDP_USE_TX_CHECKSUM macro 5-3935
UDPIsPutReady function 5-3948
uint16_gfx_image_prog type 5-940
uint16_prog type 5-940
uint16_prog_pack type 5-940
uint32_gfx_image_prog type 5-940
uint32_prog type 5-940
uint32_prog_pack type 5-940
uint8_gfx_image_prog type 5-941
uint8_prog type 5-941
uint8_prog_pack type 5-941
Upgrading from the MLA Graphics Library to the MPLAB
Harmony Graphics Library 5-681
Upgrading from the V5 TCP/IP Stack to the MPLAB Harmony
TCP/IP Stack 5-3546
Uploading Pre-built MPFS2 Images 5-3543
USART Driver Demonstration 3-142
USART Driver Library 5-510
USART Peripheral Library 5-3085
USART_BAUD_RATE_MODE enumeration 5-3140
USART_HANDSHAKE_MODE enumeration 5-3140
USART_LINECONTROL_MODE enumeration 5-3140
USART_MODULE_ID enumeration 5-3141
USART_OPERATION_MODE enumeration 5-3142
USART_RECEIVE_INTR_MODE enumeration 5-3142
USART_RECEIVE_MODES enumeration 5-3142
USART_SYNC_CLOCK_SOURCE enumeration 5-3143
USART_SYNC_MODES enumeration 5-3143
USART_TRANSMIT_INTR_MODE enumeration 5-3144
USB Audio Device Library 5-3977
USB Buffers and the Buffer Descriptor Table (BDT) 5-3175
USB CDC Host Library 5-4199
USB Demonstrations 3-149
USB Device CDC Library 5-4060
USB Device Layer Library 5-4004
USB Device Library - Application Interaction 5-3968
USB Device Library - Getting Started 5-3963
USB Device Library Architecture 5-3966
USB Device Stack Migration Guide 5-3973
USB Driver Library 5-552
USB Generic Device Library 5-4100
USB HID Device Library 5-4130
USB Host Layer Library 5-4179
USB Library Help 5-3963
USB MSD Device Library 5-4168
USB Peripheral Library 5-3167
USB Setup Example 5-3179
USB_BUFFER_DATA01 enumeration 5-3278
USB_BUFFER_DIRECTION enumeration 5-3278
USB_BUFFER_PING_PONG enumeration 5-3279
USB_BUFFER_SCHEDULE_DATA01 enumeration 5-3279
usb_device.h 5-4057
9 MPLAB Harmony Help
gggg
USB_DEVICE_Attach function 5-4033
usb_device_audio.h 5-4002
USB_DEVICE_AUDIO_CONTROL_TRANSFER_HANDLE type
5-3995
USB_DEVICE_AUDIO_ControlReceive function 5-3987
USB_DEVICE_AUDIO_ControlSend function 5-3988
USB_DEVICE_AUDIO_ControlStatus function 5-3990
USB_DEVICE_AUDIO_EP_INSTANCE structure 5-3995
USB_DEVICE_AUDIO_EVENT enumeration 5-3996
USB_DEVICE_AUDIO_EVENT_DATA_READ_COMPLETE
structure 5-3997
USB_DEVICE_AUDIO_EVENT_DATA_WRITE_COMPLETE
structure 5-3997
USB_DEVICE_AUDIO_EVENT_HANDLER type 5-3997
USB_DEVICE_AUDIO_EVENT_RESPONSE type 5-3998
USB_DEVICE_AUDIO_EVENT_RESPONSE_NONE macro
5-3994
USB_DEVICE_AUDIO_EventHandlerSet function 5-3991
USB_DEVICE_AUDIO_INDEX type 5-3998
USB_DEVICE_AUDIO_INSTANCE structure 5-3998
USB_DEVICE_AUDIO_INSTANCE_STATE enumeration
5-3999
USB_DEVICE_AUDIO_INTERFACE_COLLECTION structure
5-3999
USB_DEVICE_AUDIO_INTERFACE_INFO structure 5-3999
USB_DEVICE_AUDIO_INTERFACE_TYPE enumeration
5-4000
USB_DEVICE_AUDIO_IRP_OBJECT structure 5-4000
USB_DEVICE_AUDIO_Read function 5-3992
USB_DEVICE_AUDIO_RESULT enumeration 5-4000
USB_DEVICE_AUDIO_STREAMING_INTERFACE structure
5-4001
USB_DEVICE_AUDIO_STREAMING_INTERFACE_ALTERNAT
E_SETTING
structure 5-4001
USB_DEVICE_AUDIO_TRANSFER_HANDLE type 5-4002
USB_DEVICE_AUDIO_TRANSFER_HANDLE_INVALID macro
5-3995
USB_DEVICE_AUDIO_Write function 5-3993
USB_DEVICE_CALLBACK type 5-4048
usb_device_cdc.h 5-4098
USB_DEVICE_CDC_CONTROL_TRANSFER_HANDLE type
5-4089
USB_DEVICE_CDC_ControlReceive function 5-4076
USB_DEVICE_CDC_ControlSend function 5-4078
USB_DEVICE_CDC_ControlStatus function 5-4080
USB_DEVICE_CDC_EVENT enumeration 5-4089
USB_DEVICE_CDC_EVENT_DATA_GET_LINE_CODING type
5-4092
USB_DEVICE_CDC_EVENT_DATA_READ_COMPLETE
structure 5-4092
USB_DEVICE_CDC_EVENT_DATA_SEND_BREAK structure
5-4092
USB_DEVICE_CDC_EVENT_DATA_SERIAL_STATE_NOTIFIC
ATION_COMPLETE
structure 5-4093
USB_DEVICE_CDC_EVENT_DATA_SET_CONTROL_LINE_S
TATE
type 5-4093
USB_DEVICE_CDC_EVENT_DATA_SET_LINE_CODING type
5-4093
USB_DEVICE_CDC_EVENT_DATA_WRITE_COMPLETE
structure 5-4094
USB_DEVICE_CDC_EVENT_HANDLER type 5-4094
USB_DEVICE_CDC_EVENT_RESPONSE type 5-4095
USB_DEVICE_CDC_EVENT_RESPONSE_NONE macro
5-4097
USB_DEVICE_CDC_EventHandlerSet function 5-4082
USB_DEVICE_CDC_INDEX type 5-4095
USB_DEVICE_CDC_INIT structure 5-4095
USB_DEVICE_CDC_Read function 5-4084
USB_DEVICE_CDC_RESULT enumeration 5-4095
USB_DEVICE_CDC_SERIAL_STATE_NOTIFICATION_DATA
type 5-4096
USB_DEVICE_CDC_SerialStateNotificationSend function
5-4085
USB_DEVICE_CDC_TRANSFER_FLAGS enumeration 5-4096
USB_DEVICE_CDC_TRANSFER_HANDLE type 5-4097
USB_DEVICE_CDC_TRANSFER_HANDLE_INVALID macro
5-4097
USB_DEVICE_CDC_Write function 5-4086
USB_DEVICE_ClientStatus function 5-4036
USB_DEVICE_Close function 5-4026
USB_DEVICE_CONFIG_DESCS_PTR type 5-4049
usb_device_config_template.h 5-4059
USB_DEVICE_CONTROL_STATUS enumeration 5-4049
USB_DEVICE_CONTROL_TRANSFER_CALLBACK type
5-4049
9 MPLAB Harmony Help
hhhh
USB_DEVICE_CONTROL_TRANSFER_EVENT enumeration
5-4050
USB_DEVICE_CONTROL_TRANSFER_EVENT_DATA union
5-4050
USB_DEVICE_CONTROL_TRANSFER_HANDLE type 5-4050
USB_DEVICE_CONTROL_TRANSFER_RESULT enumeration
5-4051
USB_DEVICE_ControlEventCallBackSet function 5-4028
USB_DEVICE_ControlReceive function 5-4032
USB_DEVICE_ControlSend function 5-4033
USB_DEVICE_ControlStatus function 5-4040
USB_DEVICE_Deinitialize function 5-4026
USB_DEVICE_Detach function 5-4034
USB_DEVICE_ENDPOINT_TABLE_SIZE macro 5-4057
USB_DEVICE_EndpointDisable function 5-4030
USB_DEVICE_EndpointEnable function 5-4040
USB_DEVICE_EndpointIsEnabled function 5-4042
USB_DEVICE_EndpointIsStalled function 5-4042
USB_DEVICE_EndpointStall function 5-4043
USB_DEVICE_EndpointStallClear function 5-4044
USB_DEVICE_EVENT enumeration 5-4051
USB_DEVICE_EVENT_DATA union 5-4052
USB_DEVICE_EVENT_DATA_CONFIGURED structure 5-4052
USB_DEVICE_EventCallBackSet function 5-4031
USB_DEVICE_FUNC_REGISTRATION_TABLE structure
5-4052
USB_DEVICE_FUNCTION_DRIVER structure 5-4053
usb_device_generic.h 5-4129
USB_DEVICE_GENERIC_EndpointIsEnabled function 5-4121
USB_DEVICE_GENERIC_EndpointRead function 5-4122
USB_DEVICE_GENERIC_EndpointStall function 5-4122
USB_DEVICE_GENERIC_EndpointStallClear function 5-4123
USB_DEVICE_GENERIC_EndpointStallStatusGet function
5-4123
USB_DEVICE_GENERIC_EndpointWrite function 5-4124
USB_DEVICE_GENERIC_EVENT enumeration 5-4125
USB_DEVICE_GENERIC_EVENT_DATA union 5-4125
USB_DEVICE_GENERIC_EVENT_DATA_CONTROL_TRANSF
ER_SETUP_REQUEST
structure 5-4126
USB_DEVICE_GENERIC_EVENT_DATA_ENDPOINT_READ_
COMPLETE
structure 5-4126
USB_DEVICE_GENERIC_EVENT_DATA_ENDPOINT_WRITE_
COMPLETE
structure 5-4127
USB_DEVICE_GENERIC_EVENT_HANDLER type 5-4127
USB_DEVICE_GENERIC_EVENT_RESPONSE type 5-4127
USB_DEVICE_GENERIC_EventHandlerSet function 5-4124
USB_DEVICE_GENERIC_INDEX type 5-4128
USB_DEVICE_GENERIC_RESULT enumeration 5-4128
USB_DEVICE_GENERIC_TRANSFER_FLAG enumeration
5-4128
USB_DEVICE_GENERIC_TRANSFER_HANDLE type 5-4129
USB_DEVICE_GetConfigurationValue function 5-4039
USB_DEVICE_GetDeviceSpeed function 5-4037
USB_DEVICE_GetDeviceState function 5-4038
USB_DEVICE_HANDLE type 5-4053
USB_DEVICE_HANDLE_INVALID macro 5-4057
usb_device_hid.h 5-4166
usb_device_hid_config_template..h 5-4168
USB_DEVICE_HID_CONTROL_STATUS enumeration 5-4152
USB_DEVICE_HID_CONTROL_TRANSFER_HANDLE type
5-4153
USB_DEVICE_HID_ControlReceive function 5-4142
USB_DEVICE_HID_ControlSend function 5-4144
USB_DEVICE_HID_ControlStatus function 5-4146
USB_DEVICE_HID_EVENT enumeration 5-4153
USB_DEVICE_HID_EVENT_DATA_GET_IDLE structure
5-4160
USB_DEVICE_HID_EVENT_DATA_GET_PROTOCOL
structure 5-4160
USB_DEVICE_HID_EVENT_DATA_GET_REPORT structure
5-4160
USB_DEVICE_HID_EVENT_DATA_REPORT_RECEIVED
structure 5-4161
USB_DEVICE_HID_EVENT_DATA_REPORT_SENT structure
5-4161
USB_DEVICE_HID_EVENT_DATA_SET_DESCRIPTOR
structure 5-4162
USB_DEVICE_HID_EVENT_DATA_SET_IDLE structure 5-4162
USB_DEVICE_HID_EVENT_DATA_SET_PROTOCOL
structure 5-4162
USB_DEVICE_HID_EVENT_DATA_SET_REPORT structure
5-4163
USB_DEVICE_HID_EVENT_HANDLER type 5-4163
9 MPLAB Harmony Help
iiii
USB_DEVICE_HID_EVENT_RESPONSE type 5-4164
USB_DEVICE_HID_EVENT_RESPONSE_NONE macro 5-4165
USB_DEVICE_HID_EventHandlerSet function 5-4148
USB_DEVICE_HID_INDEX type 5-4164
USB_DEVICE_HID_INIT structure 5-4164
USB_DEVICE_HID_INSTANCES_NUMBER macro 5-4166
USB_DEVICE_HID_QUEUE_DEPTH_COMINED macro 5-4166
USB_DEVICE_HID_ReportReceive function 5-4149
USB_DEVICE_HID_ReportSend function 5-4151
USB_DEVICE_HID_RESULT enumeration 5-4165
USB_DEVICE_HID_TRANSFER_HANDLE type 5-4165
USB_DEVICE_HID_TRANSFER_HANDLE_INVALID macro
5-4166
USB_DEVICE_INDEX_0 macro 5-4047
USB_DEVICE_INDEX_1 macro 5-4047
USB_DEVICE_INDEX_2 macro 5-4048
USB_DEVICE_INDEX_3 macro 5-4048
USB_DEVICE_INDEX_4 macro 5-4048
USB_DEVICE_INDEX_5 macro 5-4048
USB_DEVICE_INDEX_COUNT macro 5-4048
USB_DEVICE_INFORMATION structure 5-4194
USB_DEVICE_INIT structure 5-4054
USB_DEVICE_Initialize function 5-4027
USB_DEVICE_IRPCancelAll function 5-4044
USB_DEVICE_IRPSubmit function 5-4045
USB_DEVICE_MAX_CLIENTS macro 5-4023
USB_DEVICE_MAX_FUNCTION_DRIVER macro 5-4023
USB_DEVICE_MAX_INSTANCES macro 5-4023
usb_device_msd.h 5-4178
usb_device_msd_config_template.h 5-4178
USB_DEVICE_MSD_INIT structure 5-4176
USB_DEVICE_MSD_INQUIRY_RESPONSE structure 5-4177
USB_DEVICE_MSD_INTF macro 5-4175
USB_DEVICE_MSD_INTF_SUBCLASS macro 5-4175
USB_DEVICE_MSD_MAX_INSTANCES macro 5-4174
USB_DEVICE_MSD_MAX_LUN macro 5-4174
USB_DEVICE_MSD_MAX_SECTOR_SIZE macro 5-4174
USB_DEVICE_MSD_MEDIA_FUNCTIONS structure 5-4175
USB_DEVICE_MSD_MEDIA_INIT_DATA structure 5-4177
USB_DEVICE_MSD_PROTOCOL macro 5-4175
USB_DEVICE_Open function 5-4032
USB_DEVICE_POWER_STATE enumeration 5-4054
USB_DEVICE_PowerStateSet function 5-4039
USB_DEVICE_Reinitialize function 5-4028
USB_DEVICE_REMOTE_WAKEUP_STATUS enumeration
5-4055
USB_DEVICE_RemoteWakeupIsEnabled function 5-4039
USB_DEVICE_ResumeStart function 5-4036
USB_DEVICE_ResumeStop function 5-4037
USB_DEVICE_STATE enumeration 5-4055
USB_DEVICE_Status function 5-4035
USB_DEVICE_STRING_DESCS_PTR type 5-4056
USB_DEVICE_Tasks function 5-4031
USB_EP_TXRX enumeration 5-3279
usb_host.h 5-4198
USB_HOST_0 macro 5-4197
USB_HOST_1 macro 5-4197
usb_host_cdc.h 5-4223
USB_HOST_CDC_BreakSend function 5-4201
USB_HOST_CDC_CONTROL_LINE_STATE type 5-4223
USB_HOST_CDC_ControlLineStateSet function 5-4202
USB_HOST_CDC_EVENT enumeration 5-4210
USB_HOST_CDC_EVENT_DATA_GET_LINE_CODING_COM
PLETE
structure 5-4216
USB_HOST_CDC_EVENT_DATA_READ_COMPLETE
structure 5-4216
USB_HOST_CDC_EVENT_DATA_SEND_BREAK_COMPLETE
structure 5-4217
USB_HOST_CDC_EVENT_DATA_SERIAL_STATE_NOTIFICA
TION_RECEIVED
structure 5-4218
USB_HOST_CDC_EVENT_DATA_SET_CONTROL_LINE_STA
TE_COMPLETE
structure 5-4218
USB_HOST_CDC_EVENT_DATA_SET_LINE_CODING_COMP
LETE
structure 5-4219
USB_HOST_CDC_EVENT_DATA_WRITE_COMPLETE
structure 5-4220
USB_HOST_CDC_EVENT_HANDLER type 5-4220
USB_HOST_CDC_EVENT_RESPONSE type 5-4221
USB_HOST_CDC_EVENT_RESPONSE_NONE macro 5-4222
9 MPLAB Harmony Help
jjjj
USB_HOST_CDC_EventHandlerSet function 5-4203
USB_HOST_CDC_INDEX type 5-4221
USB_HOST_CDC_LineCodingGet function 5-4204
USB_HOST_CDC_LineCodingSet function 5-4205
USB_HOST_CDC_Read function 5-4206
USB_HOST_CDC_RESULT enumeration 5-4215
USB_HOST_CDC_SERIAL_STATE_NOTIFICATION_DATA
type 5-4221
USB_HOST_CDC_SerialStateNotificationGet function 5-4207
USB_HOST_CDC_TRANSFER_HANDLE type 5-4215
USB_HOST_CDC_TRANSFER_HANDLE_INVALID macro
5-4222
USB_HOST_CDC_TRANSFER_STATUS enumeration 5-4222
USB_HOST_CDC_Write function 5-4208
USB_HOST_Close function 5-4181
USB_HOST_Deinitialize function 5-4183
USB_HOST_DeviceInformationGet function 5-4184
USB_HOST_DeviceIsResumed function 5-4184
USB_HOST_DeviceIsSuspended function 5-4185
USB_HOST_DeviceResume function 5-4186
USB_HOST_DeviceSuspend function 5-4187
USB_HOST_ENDPOINT_TABLE_SIZE macro 5-4197
USB_HOST_EVENT_CALLBACK type 5-4195
USB_HOST_EVENT_DATA_VBUS_REQUEST_POWER
structure 5-4195
USB_HOST_EVENT_RESPONSE type 5-4195
USB_HOST_EVENT_RESPONSE_NONE macro 5-4197
USB_HOST_EventCallBackSet function 5-4187
USB_HOST_EVENTS enumeration 5-4196
USB_HOST_HANDLE type 5-4193
USB_HOST_HANDLE_INVALID macro 5-4194
USB_HOST_INIT structure 5-4193
USB_HOST_Initialize function 5-4188
USB_HOST_Open function 5-4182
USB_HOST_OperationDisable function 5-4190
USB_HOST_OperationEnable function 5-4190
USB_HOST_OperationIsEnabled function 5-4191
USB_HOST_Status function 5-4191
USB_HOST_Tasks function 5-4192
USB_HOST_TPL_FLAGS enumeration 5-4196
USB_MASTER_DESCRIPTOR structure 5-4056
USB_MAX_EP_NUMBER macro 5-3283
USB_OPMODES enumeration 5-3280
USB_OTG_INTERRUPTS enumeration 5-3280
USB_OTG_PULL_UP_PULL_DOWN enumeration 5-3281
USB_PID enumeration 5-3281
USB_PING_PONG_MODE enumeration 5-3282
USB_PING_PONG_STATE enumeration 5-3282
USB_TOKEN_SPEED enumeration 5-3283
USE_ANALOGCLOCK macro 5-321
USE_BITMAP_FLASH macro 5-321
USE_BUTTON macro 5-321
USE_CHART macro 5-321
USE_CHECKBOX macro 5-322
USE_COMP_RLE macro 5-322
USE_CUSTOM macro 5-322
USE_DIGITALMETER macro 5-322
USE_EDITBOX macro 5-323
USE_FONT_FLASH macro 5-323
USE_GOL macro 5-323
USE_GRADIENT macro 5-323
USE_GROUPBOX macro 5-323
USE_HORZ_ASCENDING_ORDER macro 5-1055
USE_LCC_SCROLLING macro 5-306
USE_LISTBOX macro 5-323
USE_METER macro 5-323
USE_MULTIBYTECHAR macro 5-324
USE_PICTURE macro 5-324
USE_PIE_ENABLE_LABEL macro 5-1055
USE_PIP macro 5-306
USE_PROGRESSBAR macro 5-324
USE_RADIOBUTTON macro 5-324
USE_ROUNDDIAL macro 5-324
USE_SLIDER macro 5-324
USE_STATICTEXT macro 5-324
USE_TEXTENTRY macro 5-325
USE_TOUCHSCREEN macro 5-325
USE_WINDOW macro 5-325
USER_SECURITY_NAME_LEN macro 5-3831
9 MPLAB Harmony Help
kkkk
Using Primitive Rendering Functions 5-1112
Using Status Functions 5-3351
Using the Build Projects 4-179
Using the Configurator 2-42
Using the File System 5-3381
Using the Library 5-194, 5-228, 5-255, 5-290, 5-300, 5-310,
5-320, 5-334, 5-344, 5-368, 5-398, 5-419, 5-458, 5-513, 5-553,
5-607, 5-695, 5-1111, 5-1129, 5-1168, 5-1276, 5-1313, 5-1362,
5-1472, 5-1521, 5-1564, 5-1669, 5-1734, 5-1866, 5-1905,
5-2087, 5-2172, 5-2203, 5-2253, 5-2289, 5-2331, 5-2428,
5-2479, 5-2595, 5-2663, 5-2689, 5-2705, 5-2763, 5-2799,
5-2893, 5-3012, 5-3086, 5-3171, 5-3321, 5-3349, 5-3364,
5-3420, 5-3439, 5-3466, 5-3501, 5-3530, 5-3570, 5-3575,
5-3599, 5-3615, 5-3626, 5-3637, 5-3647, 5-3655, 5-3660,
5-3691, 5-3698, 5-3710, 5-3719, 5-3748, 5-3771, 5-3795,
5-3799, 5-3807, 5-3810, 5-3823, 5-3859, 5-3868, 5-3881,
5-3914, 5-3918, 5-3931, 5-3955, 5-3979, 5-4005, 5-4064,
5-4104, 5-4133, 5-4169, 7-4231, 7-4233, 7-4235, 7-4237
Utilities 5-3542
V
v0.51.01b 5-601
v0.51.02b 5-3965
v0.51.03b 1-32
v0.51b 5-604, 5-3964
VENDOR_SPECIFIC_TRAP_NOTIFICATION_TYPE
enumeration 5-3852
Version Numbers 1-29
W
Wait States Initialization 5-2482
Watchdog Timer (WDT) System Service Library 5-3529
Watchdog Timer Peripheral Library 5-3319
WDT_MODULE_ID enumeration 5-3327
WDT_PLIB_ID macro 5-3532
web_server 3-131
web_server_nvm_mpfs 3-134
web_server_sdcard_fatfs 3-133
WF_WPS_PIN_LENGTH macro 5-674
What is MPLAB Harmony? 1-4
WHEAT macro 5-1055
WHITE macro 5-1055
Widget Objects 5-697
Writing a File 5-3394
X
XIP Mode 5-2896
Y
YELLOW macro 5-1056
Z
ZCLL_MODULE_CONFIG structure 5-3961
zero_conf_link_local.h 5-3962
zero_conf_multicast_dns.h 5-3962
Zeroconf Enabled Environments 5-3957
Zeroconf TCP/IP Stack Library 5-3954
9 MPLAB Harmony Help
llll
MPLAB Harmony Graphics
Composer User's Guide
MPLAB Harmony Integrated Software Framework
© 2013-2017 Microchip Technology Inc. All rights reserved.
MPLAB Harmony Graphics Composer User's Guide
This section provides user information about using the MPLAB Harmony Graphics Composer (MHGC).
MPLAB Harmony Graphics Composer User's
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 2
Introduction
This user's guide provides information on the MPLAB Harmony Graphics Composer (MHGC), also referred to as the graphics composer, which is
included in your installation of MPLAB Harmony. MHGC is tightly coupled with the Aria User Interface Library to facilitate rapid prototyping and
optimization of the application's graphical user interface (GUI).
Description
The MPLAB Harmony Graphics Composer (MHGC), also referred to as the graphics composer, is a graphics user interface design tool that is
integrated as part of the MPLAB Harmony Configurator (MHC). MHGC is tightly coupled with the Aria User Interface Library to facilitate rapid
prototyping and optimization of the application's graphical user interface (GUI). The tool provides a "What you see is what you get" (WSYWIG)
environment for users to design the graphics user interface for their application. Refer to Volume V: MPLAB Harmony Framework Reference >
Graphics Library Help > Aria User Interface Library for more information.
The MPLAB Harmony Graphics Composer (MHGC) Tool Suite and the Aria User Interface Library provide the following benefits to developers:
• Enhanced User Experience – Libraries and tools are easy to learn and use.
• Intuitive MHGC Window Tool – Flexible window docking/undocking. Undo/Redo and Copy/Paste support. Tree-based design model. Display
design canvas control including zooming.
• Tight Integration Experience – Graphics design & code generator tools are tightly integrated, providing rapid prototyping and optimization of
look and feel
• Powerful User Interface (UI) Library – Provides graphics objects and touch support
• Multi-Layer UI design – Supported in the MHGC tool and Aria Library
• Complete Code Generation – Can generate code for library initialization, library management, touch integration, color schemes and event
handling with a single click
• Supports Performance and Resource Optimization – Draw order, background caching, and advanced color mode support improve performance
• Resource optimization – Measures Flash memory usage and can direct resources to external memory if needed. Global 8-bit color look-up
table (LUT) supports reduced memory footprint. Heap Estimator tool, which helps to manage the SRAM memory footprint.
• Text localization – Easily integrate international language characters into a design and seamlessly change between defined languages at
run-time
• Easy to Use Asset Management – Tools provide intuitive management of all graphics assets (fonts, images, text strings)
• Image Optimization – Supports cropping, resizing, and color mode tuning of images
• Expanded Color Mode Support – The graphics stack can manage frame buffers using 8-bit to 32-bit color
• Powerful Asset Converter – Inputs several image formats, auto converts from input format to several popular internal asset formats, performs
auto palette generation for image compression, supports run-length encoding. Supports automatic font character inclusion & rasterization.
• Event Management – Wizard-based event configuration. Tight coupling to enable touch user events and external logical events to change the
graphics state machine and graphics properties.
• Abstract Hardware Support – Graphics controllers and accelerators can be added or removed without any change to the application
Glossary of Terms
Throughout this user's guide the following terms are used:
Acronym or Term Description
Action A specific task to perform when an event occurs.
Asset An image, font, or binary data blob that is used by a user interface.
Event A notification that a specific occurrence has taken place.
Resolution The size of the target device screen in pixels.
Screen A discreet presentation of organized objects.
Tool An interface used to create objects.
UI Abbreviation for User Interface.
Widget A graphical object that resides on the user interface screen.
MPLAB Harmony Graphics Composer User's Introduction
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 3
Graphics Composer Window User Interface
This section describes the layout of the different windows and tool panels available through MHGC.
Description
MHGC is launched from the MHC toolbar Launch Utility menu. Launching the Graphics Composer creates a new screen. Shown below is the
MHGC screen for the Aria Showcase demonstration. (If you don’t see this screen layout, reset the screen by selecting Window > Reset Dock
Areas from the window’s menus.)
Panels
By default, there are five active panels and one minimize panel on this screen:
• Screen Designer – Shows the screen design for the selected screen. Tabs on the bottom of the Screen Designer panel show the available
screens.
• Tree View – Shows the layer and widget hierarchy for the current screen.
• Screens – Manages screens in the application.
• Schemes – Manages coloring schemes in the application.
Note:
In v2.03b of MPLAB Harmony, a third tab named Options, along with Screens and Schemes was available. These properties are
now located within the File > Settings menu.
• Widget Tool Box – Available graphics widgets are shown on this panel. Widgets are added to the screen by selecting an icon and dragging or
clicking. Widget properties are discussed in the Widget Properties section below.
• Properties Editor – All properties for the currently selected object are shown in this panel.
• The MHGC Output console is parked at the bottom of the Screen Designer window. This console panel can be used to debug problems when
the Graphics Composer boots up or during its operation.
Each of the panels has a window tool icon at the upper right corner. Minimizing a panel parks it on the screen just like the Output Console.
Undocking the panel creates a new, free floating window. Redocking returns a previously undocked window to its original location on the Screen
MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 4
Designer window.
When a panel is undocked, its edges become active and support moving or manipulating the panel as an independent window.
Tool Bar
There are 18 tool bar icons on the Screen Designer Window, as described in the following figure.
MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 5
Create New Design brings up a New Project Wizard dialog that allows you to select anew the screen size, color mode, memory size, and project
type. This will erase the currently displayed design.
Save Design saves the current graphics design.
Note:
The target configuration's configuration.xml will not be updated to reflect these changes in the graphics design until one of
the following events happens:
1. The application is regenerated in MHC,
2. The target configurations are changed in the MPLAB X IDE,
3. MPLAB X IDE is exited.
In items 2 and 3 you will be prompted to save the new configuration.
Undo and Redo manipulate changes in the screen design into internal MHC memory.
Cut/Copy/Paste support the manipulation of graphics objects (widgets).
Canvas Size Dialog brings up a dialog window allowing changes in the pixel width and height of the Screen Designer panel. (Note: Dimensions
smaller than the display’s dimensions are ignored).
Center View centers the panel’s view of the screen.
Zoom In and Zoom Out allow you to change the scale of the Screen Designer’s display of the current window. Currently this only supports coarse
zooming (powers of two zooms in and out).
Toggle Line Snapping enables/disables line snapping when moving objects (widgets).
Show Grid turns the Screen Designer pixel grid on/off.
X and Y Grid Size adjust the pixel grid.
Grid Color selects the pixel grid color.
Toggle Object Clipping turns object clipping on/off.
Toggle Screen Info turns the display of screen information (X and Y axes) on/off.
Select Text Preview Language changes the language used on all text strings shown, when the application supports more than one language.
Screen Designer Window
Most of the work of the MPLAB Harmony Graphics Composer is done using the Screen Designer. This section covers the basics of how a
graphical user interface is designed using the screen designer.
Description
The following figure shows the Screen Designer window for the Aria Quickstart demonstration, with the pic32mz_ef_sk_meb2 configuration
selected. (Load whatever configuration belongs to your board and follow along.)
MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface Screen Designer Window
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 6
The pixel dimensions of the display (480x272) are determined by the MHC Display Manager. Other configuration in Aria Quickstart can have
different size displays (such as: 220x176, 320x24, or 800x480).
This demonstration has three widgets: a label containing the title string at the top, an image of the MPLAB Harmony logo in the middle, and a
button containing the text string “Make changes. Generate. Run.” at the bottom. The label widget’s text string was first created using the String
Assets window before it was assigned to the label widget. The image assigned to the image widget was first imported using the Image Assets. The
string embedded in the button widget was also created using the String Assets window before it was assigned to the button widget.
The Tree View panel organizes the display’s widgets into groups using layers. Every display has at least one layer and complex designs can have
many more. Within the tree view, the order of layers and the order of widgets within a layer determine the draw order. Draw order goes from top to
bottom. Top-most layers and widgets are drawn first and bottom-most are drawn last. Controlling draw order is one of the ways to improve
graphics performance by minimizing redrawing.
Since the location of every widget within a layer is relative to the layer, you can move a layer’s worth of widgets by simply moving the layer. Layers
also provide inheritance of certain properties from the layer to all the layer’s widgets.
MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface Screen Designer Window
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 7
Exploring the Screen Designer Window
We can add another widget to this screen by launching the Widget Tool Box panel into a separate window.
Next, drag a circle from the tool box onto the display. Find a place on the display for this new widget.
Besides dragging widgets onto the display, you can click on a widget in the Widget Tool Box, converting the cursor into that widget, and then click
on the screen to drop the widget in place.
Your display should now look appear like the following figure.
Note how the Tree View panel now shows the widget you just added.
Launch the Properties Editor for the circle.
MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface Screen Designer Window
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 8
Next, change the fill property on the circle from “None” to “Fill”.
Note:
If the properties in the Properties Editor shown are not for CircleWidget1, click on the circle widget to change the focus of the
Properties Window.
When done, the screen should now appear, as follows.
Turn on Line Snapping, which enables drawing guides to assist in aligning widgets on the display.
MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface Screen Designer Window
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 9
Next, turn on Object Clipping, which allows you to see how widgets are clipped by the boundaries of the layer that contains them.
Note: Clipping applies to layers, which can be smaller than the display.
To delete a widget, select the widget and press Delete on your keyboard or use the delete icon ( ) on the Tree View panel.
For more hands-on exploration of graphics using the Aria Quickstart demonstration, see Volume 1: Getting Started With MPLAB Harmony > Quick
Start Guides > Graphics and Touch Quick Start Guides > Adding an Event to the Aria Quickstart Demonstration.
The steps to create a new MPLAB Harmony project with touch input on a PIC32MZ EF Starter Kit with the Multimedia Expansion Board (MEB) II
display can be found in Volume 1: Getting Started With MPLAB Harmony > Quick Start Guides > Graphics and Touch Quick Start Guides >
Creating New Graphics Applications.
Menus
This section provides information on the menus for the MPLAB Harmony Graphics Composer screen.
MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface Menus
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 10
Description
File Menu
New – Same as the Create New Design tool icon.
Save – Same as the Save Design tool icon.
Save As – Supports exporting the design under a new name. By default, the name is composer_export.xml. See Importing and Exporting
Graphics Data for more information.
Import - Reads in (imports) a previously exported design or a ./framework/src/system_config/{board_config}/configuration.xml
file that contains the graphics design to be imported. See Importing and Exporting Graphics Data for more information.
Export – Same as Save As. See Importing and Exporting Graphics Data for more information.
Settings – Brings up Project and User Settings dialog, including:
• Project Color Mode - How colors are managed
• Using a Global Palette
• Show Welcome Dialog
• Pre-emption Level – Allows for sharing of the device’s cycles with other parts of the application
• Hardware Acceleration – Is graphics hardware accelerator enabled in software?
Exit – Closes the MHGC window and exits
The choices for Project and User Settings > Project Color Mode are:
• GS_8 - 8-bit gray scale
• RGB_332 - Red/Green/Blue, 3 bits Red/Green, 2 bits Blue
• RGB_565 - Red/Green/Blue, 5 bits Red, 6 bits Green, 5 bits Blue
• RGBA_5551 - Red/Green/Blue/Alpha, 5 bits Red/ Green/Blue, 1 bit for Alpha Blending
• RGB_888 - Red/Green/Blue, 8 bits Red/Green/Blue
• RGBA_8888 - Red/Green/Blue/Alpha, 8 bits Red/Green/Blue/Alpha Blending
• ARGB_8888 - Alpha/Red/Green/Blue, 8 bits Alpha Blending/Red/Green/Blue
Ensure that the Project Color Mode chosen is compatible with the display hardware you are using; otherwise, the colors shown on the display will
not match those shown on the Graphics Composer Screen Designer.
Using a Global Palette enables frame buffer compression for applications using the Low-Cost Controllerless (LCC) Graphics Controller or Graphics
LCD (GLCD) Controller. If the global palette is enabled, you will have to change the MHC configuration of the Graphics Controller to match. For the
LCC controller, enable "Palette Mode". For the GLCD controller, change the Driver Settings > Frame Buffer Color Mode to "LUT8".
If Using a Global Palette is enabled, the following warning appears.
MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface Menus
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 11
If Show Welcome Dialog is enabled, the following welcome screen appears when launching MHGC.
Note:
If you are not creating a new project you can ignore this window.
When the Preemption Level is set to zero, all dirty graphics objects are refreshed before the graphics process relinquishes control of the device.
(Dirty means needing a redraw.) With the level set to two, graphics provides maximum sharing with the rest of the application, at the cost of slower
display refreshes. A level of one provides an intermediate level of sharing.
The Hardware Acceleration check box determines whether graphics uses the device’s built-in graphics hardware accelerator in software.
Note:
You must also specify the graphics hardware accelerator in the MPLAB Harmony Framework Configuration within the MHC
Options tab. If the host device lacks a graphics processor, you will see a warning message when you try to select a processor that
does not exist on your device.
MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface Menus
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 12
Edit Menu
This menu implements the same functions as the first seven tool icons.
View Menu
This implements the same functions as the remaining tool icons.
Asset Menu
These menu features are discussed in Graphics Composer Asset Management.
MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface Menus
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 13
Tools Menu
The Event Manager, Global Palette, and Heap Estimator are discussed in MHGC Tools.
Window Menu
Selecting Console opens the Output Console for the Graphics Composer. This console panel can be used to debug problems when the Graphics
Composer boots up or during its operation.
Selecting Reset Dock Areas restores the MHGC panel configuration to the default setup by redocking all of the panels that have been undocked
into separate windows.
New Project Wizard
The New Project Wizard is launched from the Welcome dialog of the MPLAB Harmony Graphics Composer (MHGC), which supports the creation
of a new graphics design, or the importing of an existing graphics design.
Description
Welcome Dialog window
The Welcome dialog is launched when the Graphics Composer is chosen from the Launch Utility pull-down menu in the MPLAB Harmony
Configurator (MHC).
The window has three options:
MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface New Project Wizard
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 14
Note:
If this window does not appear, it can be re-enabled from MHGC’s File > Settings > General menu.
New Project Wizard Windows
Selecting the first icon in the Welcome dialog launches the New Project Wizard. There are four stages in the New Project Wizard: Color Mode,
Memory Size, Project Type, and Finish.
The New Project Wizard can also be launched from the first icon (Create New Design) of MHGC’s tool bar:
MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface New Project Wizard
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 15
If the Graphics Stack has not been enabled in MHC, an Enable Graphics Stack? dialog will appear to support enabling the Graphics Stack before
proceeding:
In the Color Mode stage you choose the Display Color Mode for the new graphics design:
This choice must be supported by the graphics controller defined in the board support package of the project configuration. (If you make a mistake
it can be corrected using MHGC’s File > Settings > Project Color Mode menu.) Click Next moves the wizard on to the next stage.
The Memory Size stage configures the Program Flash allocated to memory use. This value is only used by the Graphics Composer’s Asset menu
Memory Configuration tool. The value used in the Memory Size stage can be updated using the Configuration sub-tab of the Memory
Configuration tool window.
MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface New Project Wizard
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 16
Clicking Previous returns to the Color Mode stage and clicking Next moves the wizard to the Project Type stage.
There are two choices at the Project Type stage: A completely blank design, and a template design with a few predefined widgets.
Clicking Previous returns to the Memory Size stage, and clicking Next moves the wizard to the Finish stage.
If the “Template” project type was chosen, MHGC’s Screen Designer will show:
MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface New Project Wizard
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 17
Tree View Panel
The organization of application widgets and layers, including draw order, is managed using this panel.
Description
Example Tree View
The following Tree View (from main screen of the Aria Coffee Maker demonstration shows the tree structure for a screen with three layers.
MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface Tree View Panel
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 18
The tool icons for this panel support layers and managing screen objects (layers/widgets).
Drawing Order and Parent/Child Relationships
The Graphics Composer Tree View panel allows you to organize the widgets per screen in the desired drawing order (z-order). It also allows for
the user to organize the widgets into parent – child hierarchies to allow for the paint algorithm to draw the groups together in event of motion or
re-draw. Please note that this does not associate or group the widgets by functionality. (Example: a group of radio buttons might not belong to a
common parent on the screen.) This parent-child relationship is limited to the widgets location on the screen, motion on the screen and the
drawing order on the screen. (Exceptions to this general rule are the Editor > Hidden, Alpha Blending properties, and layer single versus double
buffering. These apply to the parent and all the parent's children.)
The tree is traversed depth-first. This means that the z-order goes background (bottom of z-order) to foreground (top of z-order) as we go from top
to bottom in the list of widgets, i.e., ImageWidget1, is the widget at the bottom of the z-order and the PanelWidget1 is the topmost widget on the
z-order. The tree structure can be arranged and modified by dragging the widgets and releasing it under the desired parent/child. Also, the list can
be modified by using the up/down arrows provided at the header of the Composer Widget tree window to traverse the tree.
Editor > Hidden Property for Layers
Setting Editor > Hidden hides the layer and all its children from the Graphics Composer Screen Designer but does not affect how the layer and its
children are displayed when the application is running. This can be useful when designing complex screens with overlapping layers.
Alpha Blending Property for Layers
Enabling Alpha Blending allows you to control the transparency of a layer and all its children. You can experiment with Alpha Blending in the Aria
Coffee Maker demonstration. Load the project, launch MHC, and then start the Graphics Composer Screen Designer. There are three layers
(Layer0, Layer1, Layer2) in this demonstration. Layer1 (the drag panel on the right) and Layer2 (the drag panel on the left) have Alpha Blending
enabled with Alpha Amount = 225. Setting the Alpha Amount to 255 is the same as disabling Alpha Blending (255 = no transparency). Setting the
MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface Tree View Panel
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 19
Alpha Amount to 0 makes the layer invisible (0 = full transparency, i.e., invisible).
The following figure shows the main screen with Alpha Blending = 225.
The following figure shows the main screen with Layer 2’s Alpha Blending = 255.
Double Buffering for Layers
Graphics double buffering for the LCC driver is enabled in the Display Manager’s Display Setting screen when the application is changed to use
external memory instead of internal. Click Configure to bring up the LCC Driver Configuration Settings Window.
MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface Tree View Panel
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 20
Configure the memory according to whether double buffering is to be enabled for the display’s layer or layers.
MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface Tree View Panel
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 21
Increasing the Buffer Count of a layer from 1 to 2 enables double buffering for the layer and all its child widgets. To prevent tearing on the display
when switching from one buffer to the other, VSync Enabled should also be selected.
Screens Panel
Application screens are managed using the Screens Panel.
Description
The Screens panel tab manages all the application’s screens, as shown in the following figure.
MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface Screens Panel
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 22
Note:
These screens are examples from the Aria Showcase demonstration project
The underlined screen name identifies the primary screen (in this case, SplashScreen.) The bold screen name identifies the currently active
screen in the Graphics Composer Screen Designer window (in this case MainMenu.) The blue background identifies the selected screen (i.e., the
screen that is manipulated by the tool icons), in this case FirstScreen.
Window Toolbar
The window’s tools icons support:
1. Create New Screen – Create a new screen. You will be prompted for the name of the new screen, which will appear at the bottom of the
Screens list.
2. Delete Screen – Delete the selected screen. This removes the selected screen from the application.
3. Set as Primary Screen – Sets the selected screen as the default screen displayed by the application at boot-up.
4. Make Screen Active – This selected screen is displayed in the Screen Designer panel. You can also select the active screen by clicking on the
screen’s tab at the bottom of the Screen Designer panel.
5. Move Screen Up in Order – Moves the selected screen up in the list of screens, which is useful in organizing a large list of screens, but has no
other significance.
6. Move Screen Down in Order – Moves the selected screen down in the list of screens.
Useful in organizing a large list of screens, but has no other significance.
Window Columns
The Generate check box is used in selecting those screens that will be included in the application when MPLAB Harmony Configurator (MHC)
generates/regenerates the application. (This, along with the Enabled check box for languages, allows customization of the application’s build to
support different end uses from the same project.) The Visible check box can be cleared to hide a screen from the sub-tabs located at the bottom
of the Screen Designer. The View column provides a mouse-over preview of the screen.
MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface Schemes Panel
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 23
Schemes Panel
Application color schemes are managed using the Schemes Panel.
Description
Color schemes for the application’s graphics are managed using the Schemes sub-tab.
Editing a Scheme
To edit an existing scheme, select the scheme from the list and click Edit.
The Scheme Editor dialog appears, which allows you to change the colors associated with this display scheme.
Scheme Editor
The Scheme Editor window supports editing the individual colors of a color scheme. Clicking the ellipsis ( … ) opens the Color Picker window.
MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface Schemes Panel
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 24
Color Picker
The Color Picker window allows the user to easily select a color by providing a color wheel, brightness gauge, and some common predefined color
choices. The user can change the individual color values or input a number in Hexadecimal format. The end result is displayed in the top right
corner.
MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface Schemes Panel
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 25
Options
Provides information on the defeatured Options window.
Description
In v2.03b, MPLAB Harmony Graphics Composer user interface provided a third window along with Screens and Schemes, named Options.
Beginning with v2.04b of MPLAB Harmony, these options are now located within the File > Settings menu (see Menus for details).
Widget Tool Box Panel
The Widget Tool Box panel is the interface by which users add widgets into the screen representation.
Description
All the available graphics widgets are shown in the Widget Tool Box:
MPLAB Harmony Graphics Composer provides automatic code optimization by keeping track of the widgets that are currently being used. When
MHC generates or regenerates the application, only the Graphics Library code necessary for your design is included in the project.
There are two primary methods for creating new widget objects: clicking and dragging. To add a new layer to a screen use the Screens sub-tab.
Click Method
The following actions can be performed by using the Click method:
• Clicking an item selects it as active. Users can then move the cursor into the screen window and view a representation of the object about to be
added.
• Left-clicking confirms the placement of the new object
• Right-clicking aborts object creation
• Clicking the active item again deactivates it
MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface Widget Tool Box Panel
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 26
Drag Method
Dragging and dropping a tool item into the Screen Designer Window creates a new instance of an object. When dragging a tool item, releasing the
cursor outside of the Screen Designer Window cancels the drag operation.
Widget List
The Graphics Composer Tool Box is the interface by which users add widgets into the screen representation.
Click Method
The following actions can be performed by using the Click method:
• Clicking an item selects it as active. Users can then move the cursor into the screen window and view a representation of the object about to be
added.
• Left-clicking confirms the placement of the new object
• Right-clicking aborts object creation
• Clicking the active item again deactivates it.
Drag Method
Dragging and dropping a tool item into the Screen Designer Window creates a new instance of an object. When dragging a tool item, releasing the
cursor outside of the Screen Designer Window cancels the drag operation.
Automatic Code Optimization
MPLAB Harmony Graphics Composer keeps track of the types of widgets that are used and updates the MHC Tree constantly to ensure that only
the Graphics Library code necessary for your design is included in the project.
Widgets
Widgets can be configured by using the Properties Editor on the right side of the MHGC interface. Each widget has multiple properties to manage
their appearance as well as their functioning. Most properties related to appearance are common between widgets, though some widgets require
specific property entries.
Button - A binary On and Off control with events generation for Press and Release state.
Check Box - A selection box with Checked and Unchecked states, and associated events.
Circle - A graphical object in the shape of a circle.
Draw Surface - A container with a callback from its paint loop. a draw surface lets the application have a chance to make draw calls directly to the
HAL during LibAria's paint loop.
Gradient - A draw window that can be associated with a gradient color scheme. This allows for color variation on the window.
Group Box - A container with a border and a text title. With respect to functionality, a group box is similar to a window.
Image Sequence - A special widget that allows image display on screen to be scheduled and sequenced. You can select the images to be
displayed, the order for display, and the durations.
MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface Widget Tool Box Panel
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 27
Image - Allows an image to be displayed on screen. The size and shape of the widget decides the visible part of the image, as scaling is not
enabled for images at this time.
Key Pad - A key entry widget that can can be designed for the number of entries divided as specified number of rows and column entries. The
widget has a key click event that can be customized.
Label - A text display widget. This does not have any input at runtime capability. A Text Field widget serves that purpose.
Line - A graphical object in the shape of a line.
List Wheel - Allows multiple radial selections that were usually touch-based selections and browsing.
List - Allows making lists of text and image items. The list contents, number of items, and the sequence can be managed through a List
Configuration dialog box in the Properties box.
Panel - A container widget that is a simpler alternative to DrawSurface as it does not have the DrawSurface callback feature.
Progress Bar - Displays the progress pointer for an event being monitored through the "Value Changed" event in the Properties Editor.
Radio Button - A set of button widgets that are selected out of the group one at a time. The group is specified by the Group property in the
Properties Editor.
Note:
The radio buttons in the same group must have the same group number specified in their properties.
Rectangle - A graphical object in the shape of a rectangle.
Scroll Bar - Intended to be used with another relevant widget such as the List Wheel to scroll up and down. It has a callback each time the value
is changed. The callback allows users to trigger actions to be handled on the scroll value change event.
Slider - Can change values with an external input such as touch. Event callbacks on value change are also available through the Properties Editor.
Text Field - Text input can be accepted into the text field from an external input or from a widget such as keypad. Event 'Text Changed' in the
Properties Editor is used for accepting the input.
Touch Test - Allows tracking of touch inputs. Each new touch input is added to the list of displayed touch coordinates. The input is accepted
through the 'Point Added' event callback in the Properties Editor.
Window - A container widget similar to the Panel but has the customizable title bar.
Properties Editor Panel
The properties for all layers and widgets are managed using this panel.
Description
The Properties Editor displays options for the currently-selected object (layer or widget), or the options for the active screen if no objects are
selected. To edit an option: left-click the value in the right column and then change the value. Some values have an ellipsis that will provide
additional options. In the previous case, the ellipsis button will display the Color Picker dialog.
Some properties, like the screen width and height, are locked and cannot be edited. Other properties offer check boxes and combo-type
drop-down box choices. Some properties are grouped together like the Position and Size entries. Individual values of the group can be edited by
expanding the group using the plus symbol. For example, the following figure shows properties for a Button Widget.
A new support feature is the ? icon to the right of the Scheme pull-down, which brings up an “Scheme Helper” for the widget showing how it is
colored when using a Bevel border. For a more complete description of widget coloring, see Widget Colors.
MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface Properties Editor Panel
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 28
Object Properties
Provides information on widget, layer, and screen properties.
Description
Object Properties and Event Actions
Each widget has a structured tree of properties, visible under the MPLAB Harmony Configurator window on the right of the standard window setup
within MPLAB X IDE. Most widget properties have a Related Event action that can be use in an event or macro to change or set a property from
the application.
Each widget has 3-4 property sets:
Editor – Controls the behavior of layers and widgets under the MPLAB Harmony Graphics Composer Suite Editor.
Property Name Type Description Related Event Actions
Locked Boolean Locks the object (widget), preventing changes by the designer.
Only affects the object (widget) in the editor.
N/A
Hidden Boolean Hides the widget and its children in the designer window. Only
affects the appearance of the widget in the editor.
N/A
Active Boolean For layers only. Sets the layer as active. Any objects (widgets)
added to the screen will be added to this layer.
N/A
Locked to Screen Size Boolean For layers only. Locks the layer size to the size of the display’s
screen.
N/A
Widget – Controls the behavior of screens, layers, and widgets on the display.
MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface Properties Editor Panel
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 29
Property Name Type Description Related Event Actions
Name String Editable name for each object. By default, widgets are named
NameWidget1, …,NameWidgetN. For example: ButtonWidget1,
ButtonWidget2, … .
N/A
Position [X,Y] Pair of
Integers
Location on the layer of the upper left corner of the widget or
the location on the display of the upper left corner of the layer.
Measured in display pixels. X is measured from left-to-right and
Y is measured from up-to-down from the upper left corner of the
parent object (typically a Layer or Panel).
Adjust Position, Set X
Position, Set Y Position
Size [X,Y] Pair of
Integers
X: Width, Y: Height of object, in display pixels. Adjust Size, Set Size, Set
Width, Set Height
Enabled Boolean Is the object enabled? Disabled objects are not built into the
display’s firmware.
Set Enabled
Visible Boolean Is the object visible by default? Object visibility can be
manipulated in firmware using laWidget_GetVisible and
laWidget_SetVisible.
Set Visible
Border Widget Border Choices are: { None | Line | Bevel }. Set Border Type
Margin Integer Four integers ([Left,Top,Right,Bottom]) defining the widget’s
margins on the display, in display pixels.
Set Margins
Scheme Color scheme assigned to the layer or widget. Blank implies the
default color scheme.
Set Scheme
Background Type Sets the background of the layer or widget. Choices are { None
| Fill | Cache }. In MPLAB Harmony v2.03, this type was
Boolean. Now, Off = None, On = Fill. With Fill selected, the
widget's background is one solid color. With Cache selected, a
copy (cache) of the framebuffer is created before the widget is
drawn and this cache is used to fill the background of the
widget. This supports transparent widgets in front of complex
widgets, such as JPEG images. Instead of rerendering the
JPEG image, it is just drawn from the cache.
Set Draw Background
Alpha Blending Boolean Is alpha blending enabled for this layer or widget and all of its
children? If enabled, specify the amount of alpha blending as an
8-bit integer. Zero makes the object invisible, whereas 255
makes the background invisible.
N/A
Widget Advanced – Advanced control of layers and widgets
Optimization
Sub-Property Name
Type Description Related Event Actions
Draw Once Boolean Indicates that the widget should draw once per screen Show
Event. All other attempts to invalidate or paint the widget will be
rejected.
N/A
Force Opaque Boolean Provides a hint to the renderer that the entire area for this
widget is opaque. Useful for widgets that may use something
like an opaque image to fill the entire widget rectangle despite
having fill mode set to None. This can help reduce unnecessary
drawing.
N/A
Local Redraw Boolean Provides a “hint” to the widget’s renderer that the widget is
responsible for removing old pixel data. This can avoid
unnecessary redrawing.
N/A
Important!
Use Local Redraw only if you know what you’re doing!
Widget Name (e.g., Button Check Box, Circle, etc.) – Optional properties tied to each widget. See Dedicated Widget Properties and Event
Actions.
Events – Associates widget events with event call-backs. For example, you can enable and specify a button pressed event and button release
event for the Button widget.
For each event you specify:
• Enabled/Disabled Check box – To enable or disable (default) the event.
MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface Properties Editor Panel
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 30
• Event Callback – Selected from the Event Editor Action List.
There are additional Event actions that do not correspond to any specific property:
• Set Parent – Set the parent of the object, including no parent.
Dedicated Widget Properties and Event Actions
Button
Property Name Type Description Related Event Actions
Toggleable Boolean Is button toggle enabled? Set Toggleable
Pressed Boolean If Toggleable is enabled, provide default state of the button.
This can be used to see the colors of an asserted button.
Set Press State
Text String Select widget’s text string from the Select String Dialog. Set Text
Alignment:
• Horizontal
• Vertical
Text string alignment within the button object.
Horizontal alignment. Choices are: { Left | Center | Right }.
Vertical alignment. Choices are: { Top | Middle | Bottom }.
Set Horizontal Alignment
Set Vertical Alignment
Pressed Image Select image used for pressed state. Default: no image. Set Pressed Image
Released Image Select image used for pressed state. Default: no image. Set Released Image
Image Position Position of image relative to button text. Choices are: { LeftOf |
Above | RightOf | Below | Bottom }.
Set Image Position
Pressed Offset Integer Offset of button contents when pressed. In Pixels.
The X and Y position of the button contents is offset by this
amount.
Set Pressed Offset
Check Box
Property Name Type Description Related Event Actions
Text String Select widget’s text string from the Select String Dialog. Set Text
Alignment:
• Horizontal
• Vertical
Text string alignment within the button object.
Horizontal alignment. Choices are: { Left | Center | Right }.
Vertical alignment. Choices are: { Top | Middle | Bottom }.
Set Horizontal Alignment
Set Vertical Alignment
Checked Boolean Default state of the check box. Set Check State
Unchecked Image Select image used for widget’s unchecked state. Default: no
image.
Set Unchecked Image
Checked Image Select image used for the widget’s checked state. Default: no
image.
Set Checked Image
Image Position Position of image relative to check box text. Choices are: : {
LeftOf | Above | RightOf | Below | Bottom }.
Set Image Position
Image Margin Integer Space between image and text. In Pixels. Set Image Margin
Circle
Property Name Type Description Related Event Actions
X Integer X offset of circle’s center, from widget’s upper left hand corner,
in pixels.
N/A
Y Integer Y offset of circle’s center, from widget’s upper left hand corner,
in pixels.
N/A
Radius Integer Circle’s radius, in pixels. Set Radius
Draw Surface – No additional properties.
Gradient
Property Name Type Description Related Event Actions
Direction Gradient draw direction. Choices are: { Right | Down | Left | Up }. Set Direction
Group Box
MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface Properties Editor Panel
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 31
Property Name Type Description Related Event Actions
Text String Select widget’s text string from the Select String Dialog. Set Text
Alignment Text string alignment within the widget. Choices are: {
Left|Center|Right }.
Set Alignment
Image Sequence
Property Name Type Description Related Event Actions
Sequence Configuration
Dialog
Specify image sequence by using the Image Sequence
Configuration Dialog window.
Set Entry Image, Set Entry
Horizontal Alignment, Set
Entry Vertical Alignment,
Set Entry Duration, Set
Image Count
Starting Image Integer Selects the first image to be shown. Set Active Image
Play By Default Boolean Will image sequence play automatically? N/A
Repeat Boolean Should the image sequence repeat? Set Repeat
Additional related event
actions: , Show Next, Start
Playing, Stop Playing.
Image Widget
Property Name Type Description Related Event Actions
Image Select image used. Set Image
Alignment:
• Horizontal
• Vertical
Image alignment within the image object.
Horizontal alignment. Choices are: { Left | Center | Right }.
Vertical alignment. Choices are: { Top | Middle | Bottom }.
Set Horizontal Alignment
Set Vertical Alignment
Key Pad
Property Name Type Description Related Event Actions
Row Count Integer Number of key pad rows. None.
Column Count Integer Number of key pad columns. None.
Key Pad Configuration
Dialog
(see Description) The Key Pad dialog window has the following:
• Width – Integer. Width of each key, in pixels.
• Height – Integer. Height of each key, in pixels.
• Rows – Integer. Number of key rows. A duplicate of Row
Count.
• Columns – Integer. Number of key columns. A duplicate of
Column Count.
None.
None.
None.
None.
MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface Properties Editor Panel
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 32
- - Selecting one of the keys on the key pad diagram displays the
Cell Properties for that key:
• Enabled – Boolean. Disabled cells (keys) are made
invisible.
• Text String – Select key’s text string from the Select String
Dialog.
• Pressed Image – Select image used for pressed state.
Default: no image.
• Released Image – Select image used for released state.
Default: no image.
• Image Position – Position of image relative to key text.
Choices are: { LeftOf | Above | RightOf | Below | Behind }.
• Image Margin – Integer. Space between image and text. In
Pixels.
• Draw Background – Boolean. Controls whether the key
should fill its background rectangle.
• Editor Action – Select the generic editor action that fires
when the key is clicked. Choices are: { None | Accept |
Append |
• Editor Value String
Other Key Event Actions:
Set Key Enabled
Set Key Text
Set Key Pressed Image
Set Key Released Image
Set Key Image position
Set Key Image Margin
None.
Set Key Action
Set Key Value
Set Key Background Type
Label
Property Name Type Description Related Event Actions
Text String Select widget’s text string from the Select String Dialog. Set Text
Alignment:
• Horizontal
• Vertical
Text string alignment within the widget.
Horizontal alignment. Choices are: { Left | Center | Right }.
Vertical alignment. Choices are: { Top | Middle | Bottom }.
Set Horizontal Alignment
Set Vertical Alignment
Line
Property Name Type Description Related Event Actions
Start X Integer X start of line, in pixels, from upper left hand corner of the
widget.
Set Start Point Position
Start Y Integer Y start of line, in pixels, from upper left hand corner of the
widget.
Set Start Point Position
End X Integer X end of line, in pixels, from upper left hand corner of the widget. Set End Point Position.
End Y Integer Y end of line, in pixels, from upper left hand corner of the widget. Set End Point Position.
List
Property Name Type Description Related Event Actions
Selection Mode Select list selection mode. Choices are:
{Single|Multiple|Contiguous}.
Set Selection Mode
Allow Empty Selection Boolean Is a list selection allowed to be empty? Set Allow Empty Selection
Alignment Horizontal text alignment. Choices are: { Left | Center | Right }. Set Item Alignment
Icon Position Position of list icons relative to list text. Choices are: { LeftOf |
RightOf }.
Set Icon Position
Icon Margin Space between icon and text, in pixels. Set Icon Margin
List Configuration Dialog Defines the string and icon image for each entry in the list. Set Item Icon, Set Item
Icon (actually sets item
text).
Additional Related Event
Actions: Deselect All
Items, Insert Item, Remove
All Items, Remove Item,
Select All Items, Set Item
Selected, Toggle Item
Select(ed).
MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface Properties Editor Panel
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 33
List Wheel
Property Name Type Description Related Event Actions
Alignment Sets horizontal text alignment. Choices are: { Left | Center |
Right }.
Set Item Alignment
Icon Position Position of icons relative to text. Choices are: { LeftOf | RightOf
}.
Set Icon Position
Icon Margin Integer Sets the space between icon and text. In pixels. Set Icon Margin
Selected Index Integer Selects the default list item. Set Selected Index
List Configuration Dialog Defines the image/text for each entry in the list. Set Item Icon, Set Item
Icon (actually sets item
text)
Additional Related Event
Actions: Append Item,
Insert Item, Remove All
Items, Remove Item,
Select Next Item, Select
Previous Item.
Panel – No additional properties.
Progress Bar
Property Name Type Description Related Event Actions
Direction Direction of progress bar. Choices are: { Right | Down | Left | Up
}.
Set Direction
Value Default value of the progress bar. The primitives
laProgressBarWidget_GetValue and
laProgressBarWidget_GetValue can be used to
manipulate the widget’s value during run time.
Set Value
Radio Button
Property Name Type Description Related Event Actions
Text String Select widget’s text string from the Select String Dialog. Set Text
Alignment:
• Horizontal
• Vertical
Text string alignment within the widget.
Horizontal alignment. Choices are: { Left | Center | Right }.
Vertical alignment. Choices are: { Top | Middle | Bottom }.
Set Horizontal Alignment
Set Vertical Alignment
Group Integer Radio Button Group Number. Default is -1, indicating no group.
Only one radio button in a group can have a default selected
value of On. All others in the group are Off
N/A
Selected Boolean If selected, the button has a default value of On. All other
buttons in the group have a Selected value of Off.
Select
Selected Image Select image used for selected state. Default: no image. Set Selected Image
Unselected Image Select image used for unselected state. Default: no image. Set Unselected Image
Image Position Position of image relative to widget text. Choices are: { LeftOf |
Above | RightOf | Below | Behind }.
Set Image Position
Image Margin Space between radio button image and text, in pixels. Set Image Margin
Rectangle
Property Name Type Description Related Event Actions
Thickness Integer Line thickness in pixels. Set Thickness
Scroll Bar
Property Name Type Description Related Event Actions
Orientation Scroll bar orientation. Choices are: { Vertical | Horizontal }. Set Orientation
Maximum Integer Maximum scroll value (minimum = 0.) Set Maximum Value
MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface Properties Editor Panel
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 34
Extent Integer Length of scroll bar slider, re scroll bar maximum value.
Indicates the number of lines or size of window visible at each
scroll setting.
Set Extent
Value Integer Initial scroll bar value. Set Value, Set Value
Percentage
Step Size Integer Step size value of scroll bar arrow buttons. ( Min = 1, Max =
9999 ).
Set Step Size
Additional Related Event
Actions: Step Backward,
Step Forward
Slider
Property Name Type Description Related Event Actions
Orientation Orientation of the slider. Choices are: { Vertical | Horizontal }. Set Orientation
Minimum Minimum slider value. Set Minimum Value
Maximum Maximum slider value. Set Maximum Value
Value Initial slider value. Set Value, Set Value
Percentage
Grip Size Grip size of slider, from 10 to 9999, in pixels. Set Grip Size
Additional Related Event
Actions: Step
Text Field
Property Name Type Description Related Event Actions
Text String Select widget’s text string from the Select String Dialog. Clear Text followed by
Append Text
Alignment Horizontal alignment. Choices are: { Left | Center | Right }. Set Alignment
Cursor Enable Boolean. Show blinking cursor while editing. Set Cursor Enabled
Cursor Delay Cursor delay in milliseconds. From 1 to 999,999. Set Cursor Delay
Additional Related Event
Actions: Accept Text,
Append Text, Backspace,
Clear Text, Start Editing.
Touch Test – No dedicated properties.
Window
Property Name Type Description Related Event Actions
Title String Select widget’s title string from the Select String Dialog. Set Title
Icon Image Select image used. Default: no image. Set Icon
Image Margin Integer Space between icon and title, in pixels. N/A
Layer Properties and Event Actions
The property list for a graphic layer is close in look and feel to that of a widget. Each Layer has three property sets: Editor (see above), Widget
(see above), and Layer (see below).
Layer Properties
Property Name Type Description Related Event Actions
Transparency Enabled Boolean Automatically mask out pixels of with a specified color.
If enabled Specify:
N/A
Mask Color Integer Red/Green/Blue or Red/Green/Blue/Alpha color value N/A
All Input Passthrough Boolean Allow input events to pass through this layer to layers behind it. N/A
VSync Enabled Boolean Layers should swap only during vertical syncs. N/A
MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface Properties Editor Panel
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 35
Buffer Count Integer Integer number of frame buffers associated with this layer,
either 1 or 2.
N/A
Buffer N For each buffer (N= 1 or 2) you specify:
Allocation Method Buffer allocation method.
Choices are: { Auto | Address | Variable Name }
• Auto – Automatically allocate frame buffer space
• Address – Specify a memory address
• Variable Name – Use variable name as buffer location
N/A
Memory Address If Address is the allocation method, specify the raw (physical)
memory address as a hexadecimal number.
N/A
Variable Name String If Variable name is the allocation method,
specify the variable name as a string value.
N/A
Screen Properties and Events
The property list for a screen shares the Name and Size properties with Layers and Widgets but has these unique properties.
Screen Properties
Property Name Type Description Related Event Actions
Orientation Display orientation: 0, 90, 180, 270 Degrees.
This can also be set using the Display Manager.
N/A
Mirrored Boolean Enables screen mirroring. N/A
Layer Swap Sync Boolean Enables that all layer buffer swapping happen at the same time,
delaying lower layers until higher layers are finished drawing as
well. For example, assume you make changes to layer 0 and
layer 1 and you want to see those changes show up on the
screen at the same time. Without this option you’d see layer 0’s
changes as soon as it finishes when layer 1 has not yet started
drawing. This option will hold layer 0’s swap operation until
layer 1 finishes as well.
Note: Currently, this property is only supported by the
CLCD Graphics Controller Driver and is ignored by all other
drivers.
N/A
Persistent Boolean Indicates that the screen should not free its widgets and
memory when it is hidden. This results in faster load times and
persistent data, but at the cost of higher memory consumption.
N/A
Export Boolean Includes this screen the application build.
This can also be set using the Screens panel.
N/A
Primary Boolean Sets this screen as the primary screen. The primary screen is
the first screen displayed when the application starts. This can
also be done using the Screens Panel Generate check box.
N/A
Graphics Composer Asset Management
The Asset menu supports managing all graphical assets (memory, images, languages, fonts, strings, and binary data).
Memory Configuration
Provides information on configuring memory locations.
Description
The Memory Locations window is launched from the Graphics Composer’s Asset menu. Selecting Memory Locations this brings up a window with
three sub-tabs (in this example, the Aria Showcase demonstration is referenced):
MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface Graphics Composer Asset Management
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 36
Window Toolbar
The window’s tools icons support:
1. Add New Memory Location – This supports multiple external memory resources.
2. Delete Selected Memory Location – Removes a previously defined memory location.
3. Rename Selected Memory Location – Renames a previously defined memory location.
4. Configure External Media Application Callback – This allow definition of media callbacks, which must be provided in the project.
MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface Graphics Composer Asset Management
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 37
5. Show Values as Percent – Memory utilization on the bar graph can be in bytes or as a percent of the total internal flash memory assigned to
support asset storage. (That memory allocation is set using the Configuration sub-tab.)
The APIs for the external media callback functions are as follows:
GFX_Result app_externalMediaOpen(GFXU_AssetHeader* asset);
GFX_Result app_externalMediaRead(GFXU_ExternalAssetReader* reader,
GFXU_AssetHeader* asset,
void* address,
uint32_t readSize,
uint8_t* destBuffer,
GFXU_MediaReadRequestCallback_FnPtr cb);
void app_externalMediaClose(GFXU_AssetHeader* asset);
The graphics demonstration project, aria_external_resources, provides an example of how to write these callbacks. This demonstration supports
three types of external memory: SQI External Memory, USB Binary, and USB with File System. Examples of these callbacks are found in the
project’s app.c file. The Aria demonstration projects Aria External Resources and Aria Flash provide more details on how to use external memory
to store graphics assets.
Sub-tabs
There are three sub-tabs to this window.
Summary Sub-tab
This sub-tab summarizes program flash allocations for images, strings, and fonts.
MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface Graphics Composer Asset Management
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 38
The memory allocation shown for “Font Glyphs” measure the space that holds all the font glyphs used by the application, either by static strings or
by glyph ranges defined in support of dynamic strings. Strings are defined by arrays of pointers to glyphs, so string memory usage measures the
size of these arrays, not the actual font glyphs used. (“Glyph” is defined here.)
Note:
The word “glyph” comes from the Greek for “carving”, as seen in the word hieroglyph – Greek for “sacred writing”. In modern
usage, a glyph is an elemental or atomic symbol representing a readable character for purposes of communicating through writing.
Configuration Sub-tab
This sub-tab specifies the intended allocation of internal (program) flash memory to graphics assets (Total Size). (The default value is 1024 bytes.)
It also names the graphics assets file name (here it will be gfx_assets.c). The allocation of flash is only used to scale the Total/Used/Available
bar graph at the top of the display. Under sizing or oversizing this amount does not affect how the application is built.
If your device has 1024 Kbytes (1048576 bytes) of flash, you can assign 40% to asset storage and 60% to code. In that case the “Total Size” in the
above sub-tab would be set to 419430 (= 40% of 1048576).
The Calculator button can assist you in allocating internal flash. Click on it and then set the device flash capacity. Then you can apply an
adjustment to that value to assign that memory to asset storage.
Example:
If the device has 2 Mbytes of internal Flash, click 2MB.
MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface Graphics Composer Asset Management
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 39
Then, to assign 75% of the 2 Mbytes to asset storage, click -25% to reduce the 2 MB by 25%, leaving 75%, and then click OK to finish. This will
then assign 1,536,000 bytes to asset storage.
Internal (program) Flash is shared between the application’s code and asset storage. If the application code and graphics assets (fonts, strings,
images) won’t fit into the available flash memory then the linker will be unable to build the application and an error will be generated in MPLAB X
IDE.
The Output File Name must be compatible with the operating system hosting MPLAB X IDE. In most cases the default name (gfx_asset.c) will
suffice, but this is provided for additional flexibility in building the application.
Optimization Sub-tab
The Optimization sub-tab for the Aria Quickstart demonstration is shown in the following figure.
MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface Graphics Composer Asset Management
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 40
The Size column shows the bytes allocated for storage in internal flash for the images, fonts, and binaries of the application.
The References column shows the number of known references for these assets by the application’s widgets. A references count of zero
suggests that the asset is not used by the application, but it could also mean that the asset is only used in real-time when it is dynamically
assigned to a widget by the application. Clicking the title of a column (Name, Size, or References) sorts the lists of graphics assets by that column.
Clicking the same column again reverses the sort order.
The window’s tools icons support:
1. Edit Selected Asset – This brings up the edit dialog for the image, font, or binary chosen
2. Delete Selected Assets – Removes the selected assets
3. Move Selected Assets – Move assets from one location to another. This is useful for moving assets to/from internal memory from/to external
memory.
4. Show Only Images – Show image assets toggle on/off
5. Show Only Fonts – Show font assets toggle on/off
6. Show Only Binaries – Show binary assets toggle on/off
Image Assets
Provides information on the Image Assets features.
Description
The Image Assets window is launched from the Graphics Composer’s Asset menu.
The Image Assets window lets you import images, select different image formats/color modes for each image, select compression methods (for
example, RLE) for each image, and displays the memory footprint of each. Images can be imported as a BMP, GIF, JPEG, and PNG (but not
TIFF). Images can be stored as Raw (BMP, GIF), JPEG, and PNG.
Note:
MHGC does not support image motion that can be found in GIF (.gif) files. GIF images are stored in the raw image format,
meaning that there is no image header information stored with the image.
When an image is imported into MGHC, the Graphics Asset Converter (GAC) stores the input format and color mode along with any relevant
header data. The image’s pixel data is then promoted from its native format into a Java Image using 32 bits/pixel (8 bits for each color, RGB, and 8
bits for Alpha Blending). If the image contains Alpha Blending then this information is stored in the “A” of RGBA, otherwise the “A” is set to
maximum opacity. When the application is built each image is stored in the image format and color mode selected. Images displayed in the Screen
Designer are converted from Java Image format into the format/color mode selected so that the Screen Designer accurately represents what the
application will show when running.
The images are decoded on the fly by the graphics library and rendered on the screen. This provides the designer with considerable flexibility to
MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface Graphics Composer Asset Management
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 41
import using one format and store resources using another format, thus exploring and maximizing the best memory utilization for their application
and hardware. This supports trading a smaller memory footprint at the cost of additional processing (for static or drawn-once) or reducing
processing at the cost of a larger memory footprint (dynamic or drawn many times).
The following figure shows the Image Assets window for the Aria Quickstart demonstration.
Window Toolbar
There are five icons on the toolbar below the Images tab:
1. Add Image Asset – Brings up “Import Image File” dialog window to select image file to add to the graphics application.
2. Replace Existing Image with New Image File – Brings up the same “Import Image File” dialog but instead of creating a new image, the file’s
content replaces the currently selected image.
3. Rename Selected Image – Renames the selected image.
4. Create New Virtual Folder – Creates a new virtual folder, allowing you to organize images in a hierarchy.
5. Delete Selected Images – removes the selected images from the application.
Selecting the Add Image Asset or Replace Existing Image icon opens the Import Image File dialog that can be used to select and import an image.
After selecting the file and clicking Open, the Image Assets window opens.
MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface Graphics Composer Asset Management
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 42
The size of the memory used for this image based on its color mode, format, compression, and global palette usage is shown by Size (bytes). See
Image Format Options below for more details.
The File Name of the original source file is also shown, but may be blank if the image was imported under MPLAB Harmony v2.03b or earlier. The
format and color mode of the stored image can be changed to reduce the image’s memory footprint. (If using an LCC controller, you can also turn
on the Global Palette, replacing each pixel in the image with just an 8 bit LUT index.)
The three internal image formats are:
• Raw – binary bit map with no associated header information. GIF and BMP images are imported into this format.
• PNG – lossless image format with compression, 24 bits/pixel (RBG_888) or 32bits/pixel (RGBA_8888). A good choice for line drawings, text,
and icons.
• JPEG (JPG) – loss compressed format, uses much less storage than the equivalent bit map (raw). Good for photos and realistic images.
The Image Assets window supports resizing, cropping, or resetting an image:
• Resize – Brings up a dialog window to change the pixel dimensions of the image. The image is interpolated from the original pixel array into the
new pixel array.
• Crop – Places a cropping rectangle on the image. Click and drag a rectangle across the image to select the new image. Then click Ok to crop
the image.
MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface Graphics Composer Asset Management
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 43
• Reset – Allows undoing of a resize or crop. The original image is always stored in the project, so a Reset is always available to return the
image to its original state.
Original images are retained by MHGC by the superset Java Image format. So an image crop will change how the image is stored in the
application but not how it is stored in MHGC. Reset will always restore the image back to the original pixels. (Reset is not an “undo”.)
Example Images
Example images are available from many sites on the internet. One of the best sites is found at the USC-SIPI Image Database
(http://sipi.usc.edu/database/). There are many canonical test images, such as Lena, The Mandrill (Baboon), and other favorites, all in the TIFF
format. The TIFF format is not supported by the Graphics Composer, but you can easily convert from TIFF to BMP, GIF, JPEG, or PNG using the
export feature found in the GNU Image Manipulation Program (GIMP), which is available for free download at: https://www.gimp.org. GIMP also
allows you to change the pixel size of these images, usually 512x512, to something that will fit on the MEB II display (either 256x256 or smaller).
The following figure shows the Graphics Composer Screen Designer for the pic32mz_da_sk_meb2 configuration of the Aria Quick Start project
after adding three images.
The following figure shows the Optimization Tab after adding these images.
MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface Graphics Composer Asset Management
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 44
Selecting the Baboon_GIF image and the Edit Selected Asset icon ( ) opens an Image Assets window, as shown in the following figure.
Because this image had only 253 unique pixel colors (Unique Pixel Count = 253) the Enable Palette option was automatically enabled. This
feature, which works on an image by image basis, is separate from enabling a Global Palette. The image is stored using 8 bits of indexing into an
image-specific lookup table (LUT). If the image has more than 256 unique colors then the Enable Palette option is not available and is not shown.
Image Format Options
Raw Format Images
Raw format images have the following options:
MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface Graphics Composer Asset Management
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 45
Regardless of the Color Mode of the imported the image, the stored image can be stored in a different color mode. For example, a JPEG image
could be in 24 bits/pixel RGB format but stored in the application using RGB_565 or even RBG_332 to save space. The Project Color Mode (set
through the File > Settings menu) is different from the Color Mode of images. This is determined by the capabilities of the projects graphics
controller. The graphics library converts images from the stored color mode to the project’s color mode before output.
If the image has 256 or less unique pixel colors an option to Enable Palette is set by default. If the image has more than 256 unique colors this
option is not displayed. This replaces the palette pixels with 8-bit indices into the image’s palette look up table (LUT). NOTE: Enabling the Global
Palette disables this for all images and all image pixels are replaced by 8-bit indices into the global palette LUT.
The Compression Mode for a raw format image is either None (no compression) or RLE for run-length encoding.
Image masking is a form of cheap blending. For example, given the following image, you may want to show the image without having to match the
lime green background. With image masking you can specify that the lime green color as the “mask color”, causing it to be ignored when drawing
this image. The rasterizer will simply match a pixel to be drawn with the mask. If they match, the pixel is not rendered.
PNG Format Images
For PNG format images you can change the image format and the image color mode:
JPEG Format Images
For JPEG format images you can change from JPEG format to Raw or PNG:
Once changed from JPEG into another format, the new format will have other options.
Managing Complex Designs
The Image assets tool lists the images in the order of their creation. In a future version of MPLAB Harmony this will be sortable by image name.
For now, it is recommended that you use the Memory Locations asset tool, and use the Optimization sub-tab instead to manage a complex set of
images. The Optimization sub-tab allows you to sort graphics assets (fonts, images, binaries) by Name, Size, and number of widget References.
This makes it much easier to find and edit an image by its name rather than order of creation.
Font Assets
Provides information on the Font Assets features.
Description
The Font Assets window is launched from the Graphics Composer’s Asset menu.
Note:
There are three dimensions to text support: Languages, Fonts, and Strings. Language “ID” strings are identified when an
application supports more than one language. (In the case of single language support, the language default is provided.) Fonts are
imported and organized using the Font Assets window. Strings are defined by a string name, and this name is used by widgets to
reference the string. For each string and each language supported the glyphs are defined to spell out the string’s text and the font
is chosen for that text.
• Languages are managed within the String Table Configuration window
• Fonts are managed within the Font Assets window (this topic)
• Strings are managed within the String Assets window
The following figure shows the Font Assets window from the Aria Coffee Maker demonstration.
MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface Graphics Composer Asset Management
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 46
The Size (bytes): for a Font asset shows how much memory is needed to store all the glyphs used by the application from this font. For static
strings MHGC determines which glyphs are used by the application’s pre-defined strings and builds these glyphs into the application. For dynamic
strings (i.e. strings created during run time) ranges of glyphs are selected by the designer and these ranges are also included in the application by
MHGC. The memory needed to store all these glyphs is shown by Size (bytes): .
Window Toolbar
There are five icons on the toolbar below the Images tab:
1. Add Font From File – Adds a font asset from a file.
MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface Graphics Composer Asset Management
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 47
2. Add Installed Font – Add a font installed on your computer.
3. Replace Existing Font Data with New Source Font – Both Add Font From File and Add Installed Font create a new font asset. This icon
allows you to update an existing font asset, importing from a file or using a font installed on your computer.
4. Rename Selected Font – Renames an existing font asset. In the example above, the Arial font was installed twice, first as a 16 point font and
second as a 12 point font. If added to the fonts assets in this order, the 12 point font will have the name Arial_1. This font asset was renamed to
Arial_Small using this tool.
MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface Graphics Composer Asset Management
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 48
5. Delete Selected Fonts – Removes selected font assets from the application.
Sub-tabs
There are three sub-tabs to this window.
Style Sub-tab
The Size (bytes): shown represents the memory needed to store all the font’s glyphs. The application only stores the glyphs that are used by static
(build-time) strings and by predefined glyph ranges to support dynamic (run-time) strings.
The choices for Memory Location must be defined before the font can be assigned. Go to the Memory Configuration window to add a new location
before using it in this sub-tab.
Each font asset consists of a font, size, and some combination of the { Bold, Italic, Anti-Aliasing } options, including selecting none of these
options. If you need bold for one set of strings and italic for another, then you will need two font assets, one with Bold checked and a second with
Italic checked. The same applies for font sizes. Each font size requires its own font asset. Thus if you need two sizes of Arial, with plain, bold, and
italic for each size, you will need 6 separate assets (6 = 2 Sizes x 3 ).
Glyphs are normally (Anti-Aliasing off) stored as a pixel bit array, with each pixel represented by only one bit. Turning on Anti-Aliasing replaces
each pixel bit with an 8-bit gray scale, thereby increasing font storage by a factor of 8!
What if a font is chosen that does not support the character types of the text used for a particular language in the application? How can you test
and debug this? There a basically two ways:
• Use an external font viewer to examine if the needed glyphs exist
• Configure, build, and run the application and verify the strings are correctly rendered
If the glyphs are not available they will be rendered as rectangles ( ).
MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface Graphics Composer Asset Management
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 49
Strings Sub-tab
The Bound check box accomplishes the same thing as assigning a font to a text string in the Strings Assets window (Window:Strings menu).
Assigning a string to a font means that the font will generate glyphs for that string. This is just another way to accomplish the binding of the string
text to font.
This sub-tab is also useful in a complicated graphics design to see how many strings use a particular font. Lightly-used or unused fonts can be
eliminated to free up internal Flash memory.
Glyphs Sub-tab
Note:
The word “glyph” comes from the Greek for “carving”, as seen in the word hieroglyph – Greek for “sacred writing”. In modern
usage a glyph is an elemental or atomic symbol representing a readable character for purposes of communicating via writing.
The Glyph sub-tab is only used when your application supports dynamic strings. For static (build-time) strings MHGC automatically determines
which font glyphs are used based on the characters present in all the strings used by the application’s graphics widgets. Only these glyphs are
included as part of the application’s font assets. With dynamic (i.e. run-time) strings this is not possible. This sub-tab allows you to specify which
range of glyphs will be used by run-time strings. Once glyph ranges are defined, these glyphs are added to the font glyphs used by static strings.
The Create New Custom Import Range icon ( ) allows you to input a new glyph range for the font. Selecting this icon opens the Font Assets
window.
MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface Graphics Composer Asset Management
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 50
String Table Configuration
Provides information on the String Assets features.
Description
The String Table Configuration window is launched from the Graphics Composer’s Asset menu.
Note:
There are three dimensions to text support: Languages, Fonts, and Strings. Language “ID” strings are identified when an
application supports more than one language. (In the case of single language support, the language default is provided.) Fonts are
imported and organized using the Font Assets window. Strings are defined by a string name, and this name is used by widgets to
reference the string. For each string and each language supported the glyphs are defined to spell out the string’s text and the font
is chosen for that text.
• Languages are managed within the String Table Configuration window (this topic)
• Fonts are managed within the Font Assets window
• Strings are managed within the String Assets window
Within this window, the Languages supported by the application are defined and the encoding for all application glyphs selected.
The “ID” string used for each language is merely for ease of use in building the texts to be used. “English”, “American”, or any other string can be
used to identity that language, as long as it is understood by the application’s creator when selecting the text to be used for that particular
language. Then the application can switch to supporting one of its languages using “ID” strings defined.
Here is an example string asset definition, taken from the Aria Coffee Maker demonstration. This application supports English, French, Italian, and
German. The text string “InfoText_Desc9” uses the Arial font, and text for each language is specified within the String Assets window.
MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface Graphics Composer Asset Management
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 51
Any number of languages can be defined as long as there is memory to store the strings needed.
The following figure shows the String Table Configuration for an application that uses English, Spanish, and Chinese.
The size of all the strings for each language is shown in the Size column. String size represents the memory allocated for glyph indices for all the
strings supporting that language. A language can be enabled/disabled via the check box in the Enabled column. Disabling a language removes it
from the application build but keeps it in the project.
Window Toolbar
There are three icons on the toolbar:
1. Add New Language – Adds a new Language.
2. Set Default Language – Sets the application’s default language. Note, this is different than the abc tool on the Graphics Composer Window
toolbar. The abc icon sets the preview language for the Screen Designer panel only. This icon sets the language used by the application after
boot-up.
3. Remove Selected Language – Removes language from the application.
Clicking Add New Language opens a new line, allowing you to select and edit the new language’s “ID” string.
MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface Graphics Composer Asset Management
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 52
Then, for every string defined in the application there will be a line to define the needed text, and to specify the font to be used.
If you don’t provide a value for the new language the string will be output as a null (empty string). If you don’t provide a Font selection then the
string will be output as a series of blocks (?).
The Aria User Interface Library primitive, LIB_EXPORT void laContext_SetStringLanguage(uint32_t id), allows the application to
switch between languages using the Language ID #defines are specified in the application’s gfx_assets.h file.
Sub-tabs
There are two sub-tabs to this window.
Language Definitions Sub-tab
This sub-tab shows the languages defined for the application. A Language can be enabled/disabled to include or exclude it from the application’s
generation/regeneration under MPLAB Harmony Configurator (MHC). New languages can be added by specifying a text string for the language.
With a new language, go to the String Assets window to specify the text and fonts for all defined strings.
Encoding Sub-tab
Selecting the Character Encoding Format Selection Dialog icon gives you three choices for how the characters in all strings in the graphics
application are encoded:
MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface Graphics Composer Asset Management
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 53
The default is ASCII. It is typically the most efficient in terms of memory and processing, but it does not support as many glyphs. Chinese text
should be encoded in UTF-8 or UTF-16, but Western language text can be encoded in ASCII to save memory. The trade-off between ASCII,
UTF-8, and UTF-16 depends on the application. Changing from UTF-8 to UTF-16 will double the size of all strings in the application. This is
because the sizes of all glyph indices double in size. (String sizes are the sizes of glyph reference indices, not the size of the particular font glyphs
used to write out the string.)
The memory utilization resulting from an encoding choice can be seen in the Summary sub-tab of the Memory Configuration window.
String Assets
Provides information on the String Assets features.
Description
The String Assets window is launched from the Graphics Composer’s Asset menu.
The String Assets window supports managing the strings in the application. Strings are referenced by graphic widgets using an application-wide
unique name. This unique name is built into an enumeration that the application’s C code uses. For each language supported text is defined and a
font asset selected.
Note:
There are three dimensions to text support: Languages, Fonts, and Strings. Language “ID” strings are identified when an
application supports more than one language. (In the case of single language support, the language default is provided.) Fonts are
imported and organized using the Font Assets window. Strings are defined by a string name, and this name is used by widgets to
reference the string. For each string and each language supported the glyphs are defined to spell out the string’s text and the font
is chosen for that text.
• Languages are managed within the String Table Configuration window
• Fonts are managed within the Font Assets window
• Strings are managed within the String Assets window (this topic)
The following figure shows an example taken from the Aria Coffee Maker demonstration. The string name, InfoText_Desc9, defines a string asset
that is used by the application.
MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface Graphics Composer Asset Management
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 54
The Total Size in Byte: for a string asset represents the memory needed to store the glyph indices for all the text defined for that string asset.
Adding more text will increase the number of glyph indices needed thus increasing the size of the string’s memory. Adding another language will
do the same, since the number of glyph indices also increases. Changing the font does not increase the size of the string’s memory, but may
increase the size of the font chosen if it is a “bigger” font and adds more glyphs to the new font. (By “bigger” we mean a font with more pixels, for
example because it is bigger in size, or perhaps because it is anti-aliased and the original font was not.)
Note:
The Reference Count shown reflects the number of build-time references to the string. Dynamic uses of a string, such as through
macros or events, is not reflected in this number.
Window Toolbar
There are four icons on the toolbar:
1. Add New String – Adds a new string.
2. Rename Selected Item – Allows renaming the string.
3. Create New Virtual Folder – Creates a new virtual folder, allowing you to organize strings in a hierarchy. Here’s an example reorganization of
the existing strings. Note the order of virtual folders or items in the list is strictly alphabetical. Virtual folders and string asset organization is
merely for the convenience of the developer. Neither has an effect on how the application is built.
MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface Graphics Composer Asset Management
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 55
4. Delete Selected Items – Deletes selected strings from the application.
Creating New Strings
To create a new string, click Add New String ( ).
Selecting this icon opens the Add String dialog to name the string. The text chosen for the string name should be acceptable as a C variable.
After entering the new string’s name and click Create, the following String Assets window appears.
MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface Graphics Composer Asset Management
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 56
In the String Assets window, there will be a line for each of the languages defined for the application. Provide the string text and font for each of
the languages. If you don’t provide the text an empty string will be used instead. Not providing a font causes the string to be rendered as a string of
boxes ( ).
Binary Assets
Provides information on the Binary Assets features.
Description
The Binary Assets window is launched from the Graphics Composer’s Asset menu.
Selecting the Add Binary File icon ( opens the Import File dialog.
MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface Graphics Composer Asset Management
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 57
This supports any formatted binary file. Developers can then add a custom-coded decoder to support the format implied by the imported file. (A
future version of the GFX library will include a bin2code utility in support of this feature.)
MHGC Tools
The Tools menu supports managing all graphics events, using a global palette, and estimating heap memory usage.
Event Manager
This section provide information on the Event Manager.
Description
The Graphics Composer Event Manager provides a GUI interface to manage all of the events associated with a graphics application. In a general
sense, an event is an action or occurrence that is processed by software using an “event handler”. Button pushes or keystrokes are widely
recognized and handled events. Events related to a touch screen are commonly called “gestures”. This GUI allows the assignment of actions to
events associated with graphics widgets and to events outside of the graphics library. Under the Graphics Composer Event Manager tab there are
two sub-tabs, one for “Events” and a second for “Macros”.
“Events” under the first tab are generated from within graphics widgets and can manipulate the properties of screen widgets or set semaphores
that engage with the rest of the application. “Macros” are executed outside of graphics widgets by other parts of the application. “Macros” allow the
application to change widget properties or behavior.
Both “Events” and “Macros” event handlers can be built using collections of “Template” actions or using “Custom” developer-provided code. Most
widget properties have an associated Template action that can be used to manipulate that property in an event handler (either “Event” or “Macro”).
For more information on properties and related actions, see the discussion on the Properties Window below.
To explore these capabilities, let’s look at the Aria Quickstart project after the completion of the Adding an Event to the Aria Quickstart
Demonstration Quick Start Guide.
Graphics Composer Events
The Graphics Composer Screen Designer shows that there is one layer and three widgets in this demonstration.
MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface MHGC Tools
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 58
Of the three widgets shown above, only ButtonWidget1 can have events associated with it, one for button pressed and a second for button
released. This can be seen in the Graphics Composer Event Manager window, which is available from the Tools menu:
The events shown under “ButtonWidget1” are mirrored in the widget’s properties. Selecting or clearing an event in one window does the same in
the other window, thus enabling (selecting) or disabling (clearing) the corresponding event.
We can add a Check Box widget to the applications display and then use the Event Manager to assign actions to the widget’s events. A Check
Box widget has two events, one for being “Checked” (i.e., selected) and another for being “Unchecked” (i.e., cleared). Enabling the “Checked”
event then allows the selection of the action or actions for that event.
The Actions: sub-window has five tool icons for managing the actions associated with an event:
MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface MHGC Tools
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 59
Clicking the Create New Action icon ( ) opens the Action Edit dialog.
If you select Custom and click Next, you will see the following dialog. Unfortunately, there is no C code error checking with this window. It just
copies the code into libaria.c and libaria.h. If there is a problem with the code you will not know about it until you try to build your
application. An alternative is just to type a comment such as /*My event goes here*/, generate the code, and then find out where this
comment landed in the code. (Typically, inside libaria_events.c, or libaria_macros.c) You can then write the action routine from within
the MPLAB X IDE editor and compile just that file to debug the code written.
If you select Template, the Action Edit dialog will update, as follows. Select ButtonWidget1.
As shown previously, you next need to select the widget that you want to manipulate with this action. Note that the event originated with
CheckBoxWidget1, but the event’s action can manipulate any of the existing widgets. In this case, ButtonWidget1 has been selected. Clicking Next
MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface MHGC Tools
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 60
will then bring up a list of the actions available in manipulating a button widget.
You can select the “Set Text” action, which will then change the button’s text property, followed by NEXT, which will open a dialog to select the text
string for this action.
You can then select from the available (already defined) strings which text to use for the button’s text field. Press the Finish button to complete the
definition of this action.
Screen Events
As shown previously, the Graphics Composer Event Manager, Events sub-tab supports screen events when the screen is visible (On Show) and
hidden (On Hide). These events can define event handlers based on Template actions or Custom, user-defined code.
Widget Events
Not all widgets can generate an event. For example, a Label Widget has nothing to generate, it just sits there on the screen, labeling. Here is a list
of the widgets that can generate an event:
• Button – Pressed and Released events
• Check Box – Checked and Unchecked events
• Draw Surface – Draw Notification event
• Image Sequence – Image Changed event
MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface MHGC Tools
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 61
• Key Pad – Key Click event
• List Wheel – Select Item Changed event
• List – Selection Changed event
• Progress Bar – Value Changed event
• Radio Button – Selected and Deselected event
• Scroll Bar – Value Changed event
• Slider Widget – Value Changed event
• Text Field – Text Changed event
• Touch Test – Point Added event
Graphics Composer Macros
Macros implement event handlers for events that originate outside of graphics primitives such as widgets and are designed to change or
manipulate widgets inside of the graphics part of an application. (Events that originate outside of graphics and don’t touch the graphics part of the
application are outside of the scope of the Graphics Event Manager and are not discussed here.)
The following figure shows a simple example of a macro.
The toolbar for Macros has three icons.
Creating a new macro and selecting its actions is just like that of a widget event:
1. Create a new macro using the “Create New Macro” tool. The check box to the left of the new macro’s name enables/disables the macro.
Clearing it removes the macro from the next code generation.
2. Select the new macro and edit it using the second icon (shown previously).
3. In the Actions: window, select Create New Action. An optional name can be provided in the Name: box. You can then choose to use a
Template and select a predefined action or Custom to create a customized action.
4. If you chose a “Custom” action, proceed as discussed previous in Graphics Composer Events. When using templates the next step is to
choose the target widget for the action. This choice is limited to those only the widgets in the currently “active” screen. If your application has
multiple screens and the widget you are targeting is not part of the currently active screen you need to change the active screen.
• Changing the active screen can be done by selecting the corresponding screen tab at the bottom of the Graphics Composer Screen
Designer
• Alternately, you can switch using the Graphics Composer Manager:Screens tab
MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface MHGC Tools
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 62
5. After selecting the target widget for this macro, click Next button to select an action related to this widget. (Just as with template-based widget
events.) The macro can contain more than one action, targeting more than one widget.
Heap Estimator
Provides information on heap space allocation.
Description
Many parts of a graphics design are implemented using memory allocated from the application’s heap space. Therefore, it is important to allocate
sufficient memory for the heap. This tool can estimate heap usage by the allocation based on the widgets, layers, screens, and decoders currently
in the design.
When launching the tool from the Tools menu, the Heap Configuration window appears.
Clicking Calculate estimates heap usage. The following figure shows what occurs within the Aria Quickstart demonstration if the heap space is
only 4096 bytes:
MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface MHGC Tools
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 63
The Summary tab shows how the estimated heap requirements was derived by summing up all the sizes shown under the “Size (Bytes)” column.
Note that the largest contribution comes from the screen requiring the largest heap allocation (in this case MainMenu).
If there is insufficient memory allocated to the heap, an exclamation point ( ! ) appears in the window. If you hold your mouse pointer over this icon,
the following message appears:
You can click Set MHC Heap Value to reset the heap allocation to match the estimated requirements. Selecting Add to MHC Heap Value adds
the estimated heap requirements to the current heap value. (In the case above, this would change the heap allocation to 4096+10664 bytes.)
Alternately, you can set the heap allocation to a larger value by going to the MPLAB Harmony Configurator window, selecting the Options tab and
setting the Heap Size within Device & Project Configuration > Project Configuration.
The Screen Details tab (from the Aria Showcase demonstration) shows screen-by-screen the heap space needed for each layer and widget on the
screen selected.
Note:
After you have updated the Heap Size, either using the Heap Estimator tool or by directly editing the value as shown above, you
must regenerate the project using the Generate Code button. This will update the actual heap size value used in building the
application.
MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface MHGC Tools
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 64
Clicking the “Name” column will alphabetize the list. Clicking the “Size (Bytes)” column sorts the assets by size, with the largest at the top and
smallest at the bottom.
This sub-tab can help in managing the application’s utilization of heap space. For example, excess use of cached backgrounds for widgets can
become ruinously expensive, expanding the application’s need for heap well beyond the capabilities of the device. As an example, consider a
screen label from the Aria Showcase demonstration.
The Heap Estimator tool shows that if caching is enabled for the label’s background, this widget requires 23699 bytes of heap to store the widget.
Note that the label is twice the size of the text it contains, so one way of reducing the cost of the widget is to make it smaller, thereby reducing the
number of background pixels that must be stored. If the label is resized, the heap allocation is reduced to 11688 bytes, which is a drop of
appoximately 50%. Finally, if the background is changed from “Cache” to “Fill” the widget only needs 188 bytes.
The lesson learned is to use Cache as a background only for widgets where it is absolutely necessary and to make the “cached” widgets as small
as possible.
Global Palette
Provides information on the Global Palette features.
Description
The Global Palette window is launched from the Graphics Composer’s Asset pull-down menu.
Using a Global Palette enables frame buffer compression for the LCC graphics controller. It creates a 256 color look up table (LUT) and then
changes the entire user interface design to adhere to that LUT. Frame buffers are stored as 8 bits/pixel (bpp) indices rather than 16-32 bpp colors.
The display driver performs a LUT operation to change each LUT index into a color before writing to the display/controller memory. This enables
the use of double buffering, without using external memory, on devices that could not support it before. It also supports single buffering on larger
displays. Of course, running the LUT requires more processing on the host. Currently only the LCC graphics controller supports this feature. The
Aria demonstration Aria Basic Motion is an example of how using a Global Palette greatly improves the efficiency and capabilities of a design.
Enable the Global Palette by clicking on the Enable Global Palette check box in the window or using the File > Settings menu. the Global palette
can always be disabled. MHGC will then restore the project back to its original configuration.
If the global palette is enabled you will have to change the MHC configuration of the Graphics Controller to match. For the LCC controller, enable
MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface MHGC Tools
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 65
"Palette Mode". For the GLCD controller, change the Driver Settings > Fame Buffer Color Mode to "LUT8".
The results of enabling the Global Palette:
• 8bpp frame buffers. In the case of the most common demonstrations this means a 50% reduction in the size of the frame buffer.
• This also opens up the capability to support a single frame buffer for some larger displays.
What is lost by enabling the Global Palette:
• First and foremost - No Dynamic Colors. Dynamic colors are unlikely to match up with an entry in the global palette’s look-up table.
• No alpha blending capability. The level of alpha blending can be changed during run-time. (See No Dynamic Colors.)
• No JPEGs or PNGs. Again, no dynamic colors. All images in MGHC will be changed to the color mode of the project, and generated as Raw.
• No font anti-aliasing. Again, no dynamic colors. While the 8-bits/pixel for each glyph is known, the color of the text depends on the color
scheme used, and color schemes can change at run time.
• Additional overhead when performing LUT (index->color) operations in the display driver.
The following figure shows the default “Global Palette” when Project Color Mode is set to RGB_888.
This default palette is good for designs that use a wide array of colors. MHGC also supports developing a custom palette by importing an image
defining the palette or by analyzing the pixel colors already in use by the application’s images. The palette’s color mode is determined by the
Project Color Mode, which is determined by the graphics controller.
Clicking on an entry in the palette with bring up the Color Picker dialog window, allowing you to edit the entry’s color.
Window Toolbar
There are four icons on the toolbar:
1. Import From Image File - Importing a global palette from an image file. Selecting this brings up the following warning. Images can be imported
as a BMP,.GIF, JPEG, and PNG (but not TIFF).
2. Auto-Calculate Palette – Calculates a new palette using the current design. Selecting this brings up the following warning.
MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface MHGC Tools
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 66
• Selecting Yes opens a status window that shows the progress made in selecting a palette of 256 colors
• This can be lengthy operation, but it will effectively generate a palette better tailored to the design. However, extreme (or rare) colors will be
changed to nearby, more-plentiful colors, thereby eliminating some of the contrast in images. Whites will tend to darken and blacks lighten. This
can be remedied by editing the calculated palette to whiten the whites, darken the blacks, and make other colors closer to the original. This of
course may increase the posterization of the image, but that is a natural trade-off in using only 256 colors.
3. Reset to Default – This returns the Global Palette to its default values, which opens the Reset Global Palette dialog.
4. Enable Global Palette – This performs the same function as File > Settings: Using a Global Palette. Selecting this opens the Enable Global
Palette Mode warning.
MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface MHGC Tools
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 67
Widget Colors
Provides information on widget coloring.
Description
Widget Colors
Widget coloring can be customized by creating additional color schemes and assigning these customized schemes to a subset of the widgets
uses. For example, a ButtonColorScheme could be customized and used only for Button Widgets.
To help highlight the different colors available for each widget, a “CrazyScheme”, with extreme contrast among the 16 available colors, was used
as the color scheme for each widget:
Use this color scheme to help identify the relevant colors for the widgets listed below.
The left column shows the coloring assignments for a Bezel boarder. The right side shows Line/No Border color assignments.
Widget With Bezel Border Widget With Line or No Borders
MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface Widget Colors
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 68
MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface Widget Colors
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 69
MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface Widget Colors
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 70
MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface Widget Colors
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 71
MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface Widget Colors
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 72
MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface Widget Colors
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 73
Code Generation
This topic describes using the graphics composer to generate code.
Description
MPLAB Harmony Graphics Composer data is generated the same way as the rest of the project within MHC through the Generate button.
libaria_harmony.h/c – These files provide the interface that binds libaria to the overall MPLAB Harmony framework. They contain the
implementations for the standard state management, variable storage, and initialization and tasks functions. If the touch functionality is enabled
then the touch bindings are also generated in libaria_harmony.c.
libaria_init.h/c - These files contain the main initialization functions for the library state and screens. The header file contains all predefined
information for the library state including screen IDs, schemes, and widget pointers. The main initialization function initializes all schemes and
screens, creates all screen objects, and sets the initial state of the library context. As each screen must be capable of being created at any time,
each screen has a unique create function that can be called at any time by the library. The libaria_init.c file contains these create functions.
libaria_events.h/c – The event files contain the definitions and implementations of all enabled MHGC events. Each event implementation will
contain all generated actions for that event.
libaria_macros.h/c – The macro files contain the definitions and implementations of all defined MHGC screen macros. A macro is similar to an
event in that it can contain actions. However, it is meant to be called from an external source such as the main application.
libaria_config.h – This file contains configuration values for the library. These are controlled through settings defined in the MHC settings tree.
gfx_display_def.c – This file contains generated definitions for enabled graphics displays.
gfx_driver_def.c – This file contains generated definitions for enabled graphics drivers.
gfx_processor_def.c – This file contains generated definitions for enabled graphics processors.
gfx_assets.h/c – These files contain generated asset data.
MPLAB Harmony Graphics Composer User's Code Generation
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 74
Advanced Topics
This section provides advanced information topics for MHGC.
Adding Third-Party Graphics Products Using the Hardware Abstsraction Layer (HAL)
This topic provides information on using the Hardware Abstraction Layer (HAL) to add third-party graphics products.
Description
The architecture of the MPLAB Harmony Graphics Stack is shown in the following diagram.
Hardware Abstraction Layer (HAL)
The HAL is a software layer that serves as a gatekeeper for all graphics controller and accelerator drivers. This layer is configured at initialization
by the underlying graphics drivers and provides functionality such as buffer management, primitive shape drawing, hardware abstraction, and draw
state management. This layer serves as a means of protection for the drivers, frame buffers, and draw state in order to prevent state
mismanagement by the application.
Third-Party Graphics Library
The third-party graphics library can be used with the MPLAB Harmony framework to perform the graphics operations desired by the application.
The third-party library has access to the HAL, which has been configured to service the frame buffer which is filled by the third-party graphics
library.
The third-party graphics library can access the MPLAB Harmony framework drivers such as touch drivers, graphics controller driver, and display
driver through the HAL. The draw pipeline and the user interface (UI) design files come from the third-party graphics library. The third-party
graphics library needs the frame buffer location to fill the frame buffer with the pixel values. Or, in case of external controllers, it would need a
function to access the controller drivers to output pixels on the display. The HAL provides the third-party graphics library with the frame buffer
location or the API to communicate the pixel values to the external controllers.
The following figure from the MPLAB Harmony Configurator (MHC), shows the selections made in the Graphics Stack to enable the needed
graphics display and controller features. Note that the Draw Pipeline for the MPLAB Harmony Graphics Stack has been disabled to assure that the
third-party graphics alone is taking effect. The MPLAB Harmony Graphics Configurator (MHGC) is also not enabled, as the design tools from the
third-party graphics library are used to generate the UI graphics. The LCDConf.c file has appropriate APIs for the third-party graphics library to
communicate through the HAL with the display drivers and the framebuffer.
MPLAB Harmony Graphics Composer User's Advanced Topics Adding Third-Party Graphics Products Using the
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 75
Example Demonstration Project
The Aria demonstration project, emwin_quickstart, has three configurations. Each configuration has an API named LCD_X_Config, which is
generated with the relevant calls for SEGGER emWin to communicate with the display driver and obtain the frame buffer location pointer to write
the pixel data to it. For PIC32MZ DA and PIC32MZ EF configurations, the frame buffer pointer address is provided to SEGGER emWin by the
HAL. For the S1D controller on PIC32MX devices (pic32mx_usb_sk2_s1d_pictail_wqvga), The pixel write function pointers are assigned to the
appropriate S1D driver APIs, which allow SEGGER emWin to write to the display controller.
Speed and Performance of Different Image Decode Formats in MHGC
Provides information and recommendations for image decode formats.
Description
MHGC supports various image formats and the MHGC Image Assets Manager provides the ability to convert and store a source image into to the
following formats
• Bitmap RAW
• Bitmap Raw Run-Length Encoded (RLE)
• JPEG
• PNG
• Predecoded RAW Bitmap in DDR (PIC32MZ DA)
The following table shows the relative rendering time and Flash memory requirements of the different image formats in the MPLAB Harmony
Graphics Library. The rendering time includes decoding the image and drawing it to the screen. This information is helpful when optimizing a
MPLAB Harmony graphics project for performance and/or Flash memory space. For example, as shown by the red highlighted text in the table, a
40x40 pixel 16-bit RAW image renders 2.38 times faster and uses 2.59 times more Flash space than a JPEG image.
MPLAB Harmony Graphics Composer User's Advanced Topics Speed and Performance of Different Image
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 76
Predecoded Images in DDR (RAW)
For PIC32MZ DA devices with DDR, the MHGC Image Asset Manager provides an option to predecode images from Flash and store them into
DDR as RAW images. The GPU is used to render the decoded image from DDR to the frame buffer. This provides a faster render time than an
equivalent RAW image in Flash memory, specifically for large images (up to 10 times faster for a 200x200 image). Conversely, predecoding small
images 40x40 pixels or smaller in DDR may not render faster due to the additional overhead of setting up the GPU.
Recommendations:
• If there is adequate DDR memory available, consider predecoding images to DDR for best performance
• Using JPEG images and predecoding them into DDR can provide the best rendering performance and most Flash memory savings.
Note:
The images are decoded from Flash to DDR memory by the Graphics Library during initialization and may introduce delay at
boot-up, depending on the number and size of the images.
RAW Images
RAW images provide fast rendering time, as there is no decoding needed. However, depending on image content, it can be two times larger than a
Run-Length Encoded (RLE) image and about 3 to 10 times larger than a JPEG.
Recommendation:
For small images that are to be rendered frequently, consider using a RAW image for better performance
JPEG Images
JPEG images provide the most Flash space savings, but are slower to render compared to RAW and RAW RLE.
Recommendations:
• If images are large and not used frequently, consider using the JPEG image format to save flash memory space
• If DDR memory is available, consider predecoding JPEG images in DDR for better rendering performance
Run-Length Encoded RAW Images
In terms of rendering speed and size, RAW RLE images are in between RAW and other compressed formats like JPEG or PNG. Depending on the
image contents, RAW RLE can be approximately 1.5 times faster than JPEG, but could be significantly larger in size for large images. Again,
depending on the image content, RAW RLE can be about half the size and performance of a RAW image.
Recommendation:
If optimizing your application for both speed and flash size consider using RAW RLE images
PNG Images
Among the image formats, PNG is slowest to render and requires more memory to decode.
Recommendations:
• Unless fine levels of alpha-blending are needed, it is better to use other image formats to achieve the best performance. Use the MHGC Asset
Manager to convert the source PNG image and store it in a different image format.
• If you would like to use an image with a transparent background, it may be better to use a RAW RLE image with background color masking to
achieve the same effect with better performance than a PNG. Color masking is supported in the MHGC Image Asset Manager.
MPLAB Harmony Graphics Composer User's Advanced Topics Draw Pipeline Options
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 77
Draw Pipeline Options
This section details how to use the Graphics Pipeline.
Description
The nominal rendering pipeline for an image is shown in the following figure.
The order of rendering for other widgets may differ. For example, for a colored rectangle the color mask is first checked. If the rectangle’s fill
matches the mask color defined then there is nothing to draw.
Graphics Pipeline
Provides information on the graphics pipeline.
Description
Layer Clipping
In order of the processing, Layer Clipping is first applied to the image. If the image extends beyond the edges of the layer that contains it then
those pixels are not drawn. Failure to clip out-of-bound pixels can cause the application to crash. The following figures shows an example of layer
clipping:
Before applying layer boundaries:
After applying layer boundaries:
MPLAB Harmony Graphics Composer User's Advanced Topics Draw Pipeline Options
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 78
Rectangle Clipping
Next, the image is clipped to the boundaries of any widgets that contain it as a parent, such as a rectangle.
Before applying the clipping rectangle.:
After applying the clipping rectangle:
Color Masking of Pixels
Pixels in the image are matched to a mask color. If the colors match the pixel is discarded (not drawn). In the following example, the black border
of the image is removed by defining the mask color to be black.
Before applying color mask:
MPLAB Harmony Graphics Composer User's Advanced Topics Draw Pipeline Options
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 79
After applying color mask:
Orientation and Mirroring
The logical orientation of the graphics design may not match the physical layout of the display. Pixels may need to be reoriented from logical to
physical space before being rendered.
Pixels may also need to be flipped (mirrored) before being rendered.
MPLAB Harmony Graphics Composer User's Advanced Topics Draw Pipeline Options
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 80
Alpha Blending
Each pixel drawn is a composite of the image color and the background color based on the alpha blend value defined by a global alpha value, the
pixels alpha value, or both.
Before alpha blending:
After alpha blending:
Color Conversion
The image color format may not be the same as the destination frame buffer. Each pixel must be converted before it is written. In the following
example, the image is stored using 24 bits per pixel; however, the frame buffer uses 16 bits per pixel.
MPLAB Harmony Graphics Composer User's Advanced Topics Draw Pipeline Options
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 81
Frame Buffer Write
The final stage in rendering an image is to write each-color converted pixel to the frame buffer.
Graphics Pipeline Options
Provides information graphics pipeline options.
Description
Each stage in the graphics pipeline adds overhead to the rendering. Stages can be removed from processing using MPLAB Harmony Configurator
(MHC) options for the Draw Pipeline, found by selecting MPLAB Harmony Framework Configuration > Graphics Stack.
For example, the Alpha Blending stage can be disabled if your graphics application does not use alpha blending. If the color mode of the display
matches the color mode of all images you can disable Color Conversion. Disabling unneeded stages can improve performance and reduce code
size.
Also, a graphics controller driver may add additional stages, or opt to bypass stages completely depending on the capabilities of the graphics
hardware supported by the driver.
Improved Touch Performance with Phantom Buttons
This topic provides information on the use of phantom buttons to improve touch performance.
MPLAB Harmony Graphics Composer User's Advanced Topics Improved Touch Performance with Phantom
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 82
aria_coffeemaker Demonstration Example
Provides image examples with buttons in the aria_coffeemaker demonstration.
Description
Small buttons are hard to activate on the screen. The use of phantom (invisible) buttons can improve touch performance without increasing the
size of the visible footprint of the button on the display.
The aria_coffee_maker has a sliding tray on each side of the display. Sliding a tray in, or out, is accomplished by a phantom (invisible) button.
Looking at the left tray, we see the three parts of this phantom button.
1. LeftTrayLid: An invisible button widget, whose outline is shown in blue. This area is the touch field.
2. ImageWidget5: An image widget containing a hand icon, providing a visual clue as to how to manipulate the tray.
3. The Release Image and Pressed Image: These are defined as part of the button widget properties. The Pressed Image has a darker coloring
than the Released Image. This difference is what shows the user that the button has been pressed.
The drawing hierarchy for this part of the design is shows that ImageWidget5 is a daughter widget to the LeftTrayLid button widget.
Examining the properties of the LeftTrayLid button widget reveals more about how this works. The following figure demonstrates these three
properties.
1. The Border is defined as None.
2. Background Type is defined as None.
3. The different images used will show when the button is Pressed or Released.
MPLAB Harmony Graphics Composer User's Advanced Topics Improved Touch Performance with Phantom
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 83
By setting the border and background to None, the button is invisible. Only by providing different images for Released versus Pressed does the
user know when the button has been pressed.
The actual touch region defined by the button is much larger than the images shown on the display. This extra area increases the touch response
of the display.
Small Buttons Controlled by Phantom Buttons
Provides information on phantom button control of small buttons.
Description
When the border is not set to None, and the background is not set to None, the button widget provides a direct visible clue to the user when it is
pressed. Which can be seen in the following figure with the button from aria_quickstart. In aria_quickstart, ButtonWidget1 has a bevel border, and
a fill background.
MPLAB Harmony Graphics Composer User's Advanced Topics Improved Touch Performance with Phantom
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 84
Let’s use aria_quickstart to demonstrate how to control ButtonWidget1 using a phantom button to surround it, thereby increasing touch
responsiveness.
When using a bevel border and filled background, the button provides visible feedback when it is asserted.
To use this feedback mechanism instead of images, there is a way to have a small button on the display, with a larger touch zone provided by
another phantom button.
Steps:
1. Click on ButtonWidget1 in the Screen Designer panel. Go to the Properties Editor panel for the widget and uncheck the Enabled property to
disable the button. Enable Toggleable so that this button will have a memory.
2. Drag a new button from the Widget Tool Box panel and center it around ButtonWidget1. In the Properties Editor panel for this new button,
change the name of the widget to PhantomButton. Change the Background Type to None. Leave the Border set as Bevel for now. The
following figure displays the new button in the Screen Designer panel:
MPLAB Harmony Graphics Composer User's Advanced Topics Improved Touch Performance with Phantom
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 85
The Properties Editor panel should display the following information.
3. In the Tree View panel, drag ButtonWidget1 to be a daughter widget of PhantomWidget. When PhantomWidget is moved, ButtonWidget1 will
move along with the parent.
4. Click on PhantomButton again in the Screen Designer panel and move to the Properties Editor. Enable both the Pressed and Released events.
Then click on the (…) icon to define the events. (See the following two steps.)
5. Defining the Pressed Event.
Click on the (…) icon. In the Event Editor, under Pressed dialog, click the New icon to define a new event. In the Action Edit Dialog that next
appears, leave the selection on the template and hit the Next button. In the next window, select the target of the event. We want to change the
state of ButtonWidget1, so select it and hit Next. The next dialog shows all the template actions that we can use to modify ButtonWidget1. Choose
Set Pressed State and hit Next. Set the Argument to Enable Pressed. Name this event Set Press state for ButtonWidget1 then hit Finish. Leave
the Event Editor by hitting Ok.
MPLAB Harmony Graphics Composer User's Advanced Topics Improved Touch Performance with Phantom
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 86
6. Defining the Released Event.
Click on the (…) icon. In the Event Editor, under Released dialog, click the New icon to define a new event. In the Action Edit Dialog that next
appears, leave the selection on the template and hit the Next button. In the next window, select the target of the event. We want to change the
state of ButtonWidget1, so select it and hit Next. Choose Set Pressed State and hit Next. Leave the Argument disabled. Name this event Unset
Press state for ButtonWidget1 then hit Finish. Leave the Event Editor by hitting Ok.
7. Generate the application from the MPLAB Harmony Configurator main menu.
8. From the MPLAB main menu, build and run the project. To verify that ButtonWidget1 does change, click outside of the original boundaries.
9. As a final step, hide the PhantomButton by changing its border to None. Next, Generate the code again from MHC. Finally, build and run the
project from MPLAB and see how much easier it is to assert ButtonWidget1 using a phantom button.
MPLAB Harmony Graphics Composer User's Advanced Topics Improved Touch Performance with Phantom
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 87
Importing and Exporting Graphics Data
This topic provides information on importing and exporting graphics composer-related data.
Description
The MPLAB Harmony Graphics Composer (MHGC) provides the capability for users to import and export graphics designs. The user can export
the state of an existing graphics composer configuration or import another graphics composer configuration from another project.
Importing Data
1. To import a graphics design into MHGC, select File > Import. The Browse for MPLAB Harmony Graphics Composer XML file dialog appears,
which allows the selection of a previously exported Graphics Composer .xml file, or the configuration.xml file that contains the desired
graphics image.
2. After selecting a file and clicking Open, you will be prompted whether to overwrite existing data.
3. If you selected a composer_export.xml file, clicking Yes will replace the current graphics design with the new design.
4. Otherwise, if you selected a configuration.xml file, you will be prompted to import the data into the current graphics design. Click Yes to
replace the current graphics design with the new design.
MPLAB Harmony Graphics Composer User's Importing and Exporting Graphics Data
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 88
Exporting Data
1. To export a graphics design from MHGC, select File > Export. The Select File Location for MPLAB Harmony Graphics Composer XML file
dialog appears.
2. To export a graphics design using a configuration.xml file, use the Save Configuration utility from the MPLAB Harmony Configurator
(MHC) toolbar.
MPLAB Harmony Graphics Composer User's Importing and Exporting Graphics Data
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 89
Index
A
Adding Third-Party Graphics Products Using the Hardware Abstsraction
Layer (HAL) 75
Advanced Topics 75
aria_coffeemaker Demonstration Example 83
B
Binary Assets 57
C
Code Generation 74
D
Draw Pipeline Options 78
E
Event Manager 58
F
Font Assets 46
G
Global Palette 65
Graphics Composer Asset Management 36
Graphics Composer Window User Interface 4
Graphics Pipeline 78
Graphics Pipeline Options 82
H
Heap Estimator 63
I
Image Assets 41
Importing and Exporting Graphics Data 88
Improved Touch Performance with Phantom Buttons 82
Introduction 3
M
Memory Configuration 36
Menus 10
MHGC Tools 58
MPLAB Harmony Graphics Composer User's Guide 2
N
New Project Wizard 14
O
Object Properties 29
Options 26
P
Properties Editor Panel 28
S
Schemes Panel 24
Screen Designer Window 6
Screens Panel 22
Small Buttons Controlled by Phantom Buttons 84
Speed and Performance of Different Image Decode Formats in MHGC 76
String Assets 54
String Table Configuration 51
T
Tree View Panel 18
W
Widget Colors 68
Widget Tool Box Panel 26
Index
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.05 90
MPLAB Harmony Graphics Composer
User's Guide
MPLAB Harmony Integrated Software Framework
© 2013-2018 Microchip Technology Inc. All rights reserved.
Volume III: MPLAB Harmony Configurator (MHC)
This volume provides user and developer-specific information on the MPLAB Harmony Configurator (MHC).
Description
The MPLAB Harmony Configurator (MHC) is a graphical utility used to configure MPLAB Harmony projects. MHC provides
a "New MPLAB Harmony" project wizard and a graphical user interface for configuration of MPLAB Harmony projects.
When used, it generates (or updates) a project outline, including the C-language main function and system configuration
files and stores the project configuration selections for later retrieval, modification, and sharing.
Volume III: MPLAB Harmony Configurator (MHC)
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 2
MPLAB Harmony Graphics Composer User's Guide
This section provides user information about using the MPLAB Harmony Graphics Composer (MHGC).
Introduction
This user's guide provides information on the MPLAB Harmony Graphics Composer (MHGC), also referred to as the graphics composer, which is
included in your installation of MPLAB Harmony. MHGC is tightly coupled with the Aria User Interface Library to facilitate rapid prototyping and
optimization of the application's graphical user interface (GUI).
Description
The MPLAB Harmony Graphics Composer (MHGC), also referred to as the graphics composer, is a graphics user interface design tool that is
integrated as part of the MPLAB Harmony Configurator (MHC). MHGC is tightly coupled with the Aria User Interface Library to facilitate rapid
prototyping and optimization of the application's graphical user interface (GUI). The tool provides a "What you see is what you get" (WSYWIG)
environment for users to design the graphics user interface for their application. Refer to Volume V: MPLAB Harmony Framework Reference >
Graphics Library Help > Aria User Interface Library for more information.
The MPLAB Harmony Graphics Composer (MHGC) Tool Suite and the Aria User Interface Library provide the following benefits to developers:
• Enhanced User Experience – Libraries and tools are easy to learn and use.
• Intuitive MHGC Window Tool – Flexible window docking/undocking. Undo/Redo and Copy/Paste support. Tree-based design model. Display
design canvas control including zooming.
• Tight Integration Experience – Graphics design & code generator tools are tightly integrated, providing rapid prototyping and optimization of
look and feel
• Powerful User Interface (UI) Library – Provides graphics objects and touch support
• Multi-Layer UI design – Supported in the MHGC tool and Aria Library
• Complete Code Generation – Can generate code for library initialization, library management, touch integration, color schemes and event
handling with a single click
• Supports Performance and Resource Optimization – Draw order, background caching, and advanced color mode support improve performance
• Resource optimization – Measures Flash memory usage and can direct resources to external memory if needed. Global 8-bit color look-up
table (LUT) supports reduced memory footprint. Heap Estimator tool, which helps to manage the SRAM memory footprint.
• Text localization – Easily integrate international language characters into a design and seamlessly change between defined languages at
run-time
• Easy to Use Asset Management – Tools provide intuitive management of all graphics assets (fonts, images, text strings)
• Image Optimization – Supports cropping, resizing, and color mode tuning of images
• Expanded Color Mode Support – The graphics stack can manage frame buffers using 8-bit to 32-bit color
• Powerful Asset Converter – Inputs several image formats, auto converts from input format to several popular internal asset formats, performs
auto palette generation for image compression, supports run-length encoding. Supports automatic font character inclusion & rasterization.
• Event Management – Wizard-based event configuration. Tight coupling to enable touch user events and external logical events to change the
graphics state machine and graphics properties.
• Abstract Hardware Support – Graphics controllers and accelerators can be added or removed without any change to the application
Glossary of Terms
Throughout this user's guide the following terms are used:
Acronym or Term Description
Action A specific task to perform when an event occurs.
Asset An image, font, or binary data blob that is used by a user interface.
Event A notification that a specific occurrence has taken place.
Resolution The size of the target device screen in pixels.
Screen A discreet presentation of organized objects.
Tool An interface used to create objects.
UI Abbreviation for User Interface.
Widget A graphical object that resides on the user interface screen.
Graphics Composer Window User Interface
This section describes the layout of the different windows and tool panels available through MHGC.
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 3
Description
MHGC is launched from the MHC toolbar Launch Utility menu. Launching the Graphics Composer creates a new screen. Shown below is the
MHGC screen for the Aria Showcase demonstration. (If you don’t see this screen layout, reset the screen by selecting Window > Reset Dock
Areas from the window’s menus.)
Panels
By default, there are five active panels and one minimize panel on this screen:
• Screen Designer – Shows the screen design for the selected screen. Tabs on the bottom of the Screen Designer panel show the available
screens.
• Tree View – Shows the layer and widget hierarchy for the current screen.
• Screens – Manages screens in the application.
• Schemes – Manages coloring schemes in the application.
Note:
In v2.03b of MPLAB Harmony, a third tab named Options, along with Screens and Schemes was available. These properties are
now located within the File > Settings menu.
• Widget Tool Box – Available graphics widgets are shown on this panel. Widgets are added to the screen by selecting an icon and dragging or
clicking. Widget properties are discussed in the Widget Properties section below.
• Properties Editor – All properties for the currently selected object are shown in this panel.
• The MHGC Output console is parked at the bottom of the Screen Designer window. This console panel can be used to debug problems when
the Graphics Composer boots up or during its operation.
Each of the panels has a window tool icon at the upper right corner. Minimizing a panel parks it on the screen just like the Output Console.
Undocking the panel creates a new, free floating window. Redocking returns a previously undocked window to its original location on the Screen
Designer window.
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 4
When a panel is undocked, its edges become active and support moving or manipulating the panel as an independent window.
Tool Bar
There are 18 tool bar icons on the Screen Designer Window, as described in the following figure.
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 5
Create New Design brings up a New Project Wizard dialog that allows you to select anew the screen size, color mode, memory size, and project
type. This will erase the currently displayed design.
Save Design saves the current graphics design.
Note:
The target configuration's configuration.xml will not be updated to reflect these changes in the graphics design until one of
the following events happens:
1. The application is regenerated in MHC,
2. The target configurations are changed in the MPLAB X IDE,
3. MPLAB X IDE is exited.
In items 2 and 3 you will be prompted to save the new configuration.
Undo and Redo manipulate changes in the screen design into internal MHC memory.
Cut/Copy/Paste support the manipulation of graphics objects (widgets).
Canvas Size Dialog brings up a dialog window allowing changes in the pixel width and height of the Screen Designer panel. (Note: Dimensions
smaller than the display’s dimensions are ignored).
Center View centers the panel’s view of the screen.
Zoom In and Zoom Out allow you to change the scale of the Screen Designer’s display of the current window. Currently this only supports coarse
zooming (powers of two zooms in and out).
Toggle Line Snapping enables/disables line snapping when moving objects (widgets).
Show Grid turns the Screen Designer pixel grid on/off.
X and Y Grid Size adjust the pixel grid.
Grid Color selects the pixel grid color.
Toggle Object Clipping turns object clipping on/off.
Toggle Screen Info turns the display of screen information (X and Y axes) on/off.
Select Text Preview Language changes the language used on all text strings shown, when the application supports more than one language.
Screen Designer Window
Most of the work of the MPLAB Harmony Graphics Composer is done using the Screen Designer. This section covers the basics of how a
graphical user interface is designed using the screen designer.
Description
The following figure shows the Screen Designer window for the Aria Quickstart demonstration, with the pic32mz_ef_sk_meb2 configuration
selected. (Load whatever configuration belongs to your board and follow along.)
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 6
The pixel dimensions of the display (480x272) are determined by the MHC Display Manager. Other configuration in Aria Quickstart can have
different size displays (such as: 220x176, 320x24, or 800x480).
This demonstration has three widgets: a label containing the title string at the top, an image of the MPLAB Harmony logo in the middle, and a
button containing the text string “Make changes. Generate. Run.” at the bottom. The label widget’s text string was first created using the String
Assets window before it was assigned to the label widget. The image assigned to the image widget was first imported using the Image Assets. The
string embedded in the button widget was also created using the String Assets window before it was assigned to the button widget.
The Tree View panel organizes the display’s widgets into groups using layers. Every display has at least one layer and complex designs can have
many more. Within the tree view, the order of layers and the order of widgets within a layer determine the draw order. Draw order goes from top to
bottom. Top-most layers and widgets are drawn first and bottom-most are drawn last. Controlling draw order is one of the ways to improve
graphics performance by minimizing redrawing.
Since the location of every widget within a layer is relative to the layer, you can move a layer’s worth of widgets by simply moving the layer. Layers
also provide inheritance of certain properties from the layer to all the layer’s widgets.
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 7
Exploring the Screen Designer Window
We can add another widget to this screen by launching the Widget Tool Box panel into a separate window.
Next, drag a circle from the tool box onto the display. Find a place on the display for this new widget.
Besides dragging widgets onto the display, you can click on a widget in the Widget Tool Box, converting the cursor into that widget, and then click
on the screen to drop the widget in place.
Your display should now look appear like the following figure.
Note how the Tree View panel now shows the widget you just added.
Launch the Properties Editor for the circle.
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 8
Next, change the fill property on the circle from “None” to “Fill”.
Note:
If the properties in the Properties Editor shown are not for CircleWidget1, click on the circle widget to change the focus of the
Properties Window.
When done, the screen should now appear, as follows.
Turn on Line Snapping, which enables drawing guides to assist in aligning widgets on the display.
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 9
Next, turn on Object Clipping, which allows you to see how widgets are clipped by the boundaries of the layer that contains them.
Note: Clipping applies to layers, which can be smaller than the display.
To delete a widget, select the widget and press Delete on your keyboard or use the delete icon ( ) on the Tree View panel.
For more hands-on exploration of graphics using the Aria Quickstart demonstration, see Volume 1: Getting Started With MPLAB Harmony > Quick
Start Guides > Graphics and Touch Quick Start Guides > Adding an Event to the Aria Quickstart Demonstration.
The steps to create a new MPLAB Harmony project with touch input on a PIC32MZ EF Starter Kit with the Multimedia Expansion Board (MEB) II
display can be found in Volume 1: Getting Started With MPLAB Harmony > Quick Start Guides > Graphics and Touch Quick Start Guides >
Creating New Graphics Applications.
Menus
This section provides information on the menus for the MPLAB Harmony Graphics Composer screen.
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 10
Description
File Menu
New – Same as the Create New Design tool icon.
Save – Same as the Save Design tool icon.
Save As – Supports exporting the design under a new name. By default, the name is composer_export.xml. See Importing and Exporting
Graphics Data for more information.
Import - Reads in (imports) a previously exported design or a ./framework/src/system_config/{board_config}/configuration.xml
file that contains the graphics design to be imported. See Importing and Exporting Graphics Data for more information.
Export – Same as Save As. See Importing and Exporting Graphics Data for more information.
Settings – Brings up Project and User Settings dialog, including:
• Project Color Mode - How colors are managed
• Using a Global Palette
• Show Welcome Dialog
• Pre-emption Level – Allows for sharing of the device’s cycles with other parts of the application
• Hardware Acceleration – Is graphics hardware accelerator enabled in software?
Exit – Closes the MHGC window and exits
The choices for Project and User Settings > Project Color Mode are:
• GS_8 - 8-bit gray scale
• RGB_332 - Red/Green/Blue, 3 bits Red/Green, 2 bits Blue
• RGB_565 - Red/Green/Blue, 5 bits Red, 6 bits Green, 5 bits Blue
• RGBA_5551 - Red/Green/Blue/Alpha, 5 bits Red/ Green/Blue, 1 bit for Alpha Blending
• RGB_888 - Red/Green/Blue, 8 bits Red/Green/Blue
• RGBA_8888 - Red/Green/Blue/Alpha, 8 bits Red/Green/Blue/Alpha Blending
• ARGB_8888 - Alpha/Red/Green/Blue, 8 bits Alpha Blending/Red/Green/Blue
Ensure that the Project Color Mode chosen is compatible with the display hardware you are using; otherwise, the colors shown on the display will
not match those shown on the Graphics Composer Screen Designer.
Using a Global Palette enables frame buffer compression for applications using the Low-Cost Controllerless (LCC) Graphics Controller or Graphics
LCD (GLCD) Controller. If the global palette is enabled, you will have to change the MHC configuration of the Graphics Controller to match. For the
LCC controller, enable "Palette Mode". For the GLCD controller, change the Driver Settings > Frame Buffer Color Mode to "LUT8".
If Using a Global Palette is enabled, the following warning appears.
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 11
If Show Welcome Dialog is enabled, the following welcome screen appears when launching MHGC.
Note:
If you are not creating a new project you can ignore this window.
When the Preemption Level is set to zero, all dirty graphics objects are refreshed before the graphics process relinquishes control of the device.
(Dirty means needing a redraw.) With the level set to two, graphics provides maximum sharing with the rest of the application, at the cost of slower
display refreshes. A level of one provides an intermediate level of sharing.
The Hardware Acceleration check box determines whether graphics uses the device’s built-in graphics hardware accelerator in software.
Note:
You must also specify the graphics hardware accelerator in the MPLAB Harmony Framework Configuration within the MHC
Options tab. If the host device lacks a graphics processor, you will see a warning message when you try to select a processor that
does not exist on your device.
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 12
Edit Menu
This menu implements the same functions as the first seven tool icons.
View Menu
This implements the same functions as the remaining tool icons.
Asset Menu
These menu features are discussed in Graphics Composer Asset Management.
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 13
Tools Menu
The Event Manager, Global Palette, and Heap Estimator are discussed in MHGC Tools.
Window Menu
Selecting Console opens the Output Console for the Graphics Composer. This console panel can be used to debug problems when the Graphics
Composer boots up or during its operation.
Selecting Reset Dock Areas restores the MHGC panel configuration to the default setup by redocking all of the panels that have been undocked
into separate windows.
New Project Wizard
The New Project Wizard is launched from the Welcome dialog of the MPLAB Harmony Graphics Composer (MHGC), which supports the creation
of a new graphics design, or the importing of an existing graphics design.
Description
Welcome Dialog window
The Welcome dialog is launched when the Graphics Composer is chosen from the Launch Utility pull-down menu in the MPLAB Harmony
Configurator (MHC).
The window has three options:
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 14
Note:
If this window does not appear, it can be re-enabled from MHGC’s File > Settings > General menu.
New Project Wizard Windows
Selecting the first icon in the Welcome dialog launches the New Project Wizard. There are four stages in the New Project Wizard: Color Mode,
Memory Size, Project Type, and Finish.
The New Project Wizard can also be launched from the first icon (Create New Design) of MHGC’s tool bar:
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 15
If the Graphics Stack has not been enabled in MHC, an Enable Graphics Stack? dialog will appear to support enabling the Graphics Stack before
proceeding:
In the Color Mode stage you choose the Display Color Mode for the new graphics design:
This choice must be supported by the graphics controller defined in the board support package of the project configuration. (If you make a mistake
it can be corrected using MHGC’s File > Settings > Project Color Mode menu.) Click Next moves the wizard on to the next stage.
The Memory Size stage configures the Program Flash allocated to memory use. This value is only used by the Graphics Composer’s Asset menu
Memory Configuration tool. The value used in the Memory Size stage can be updated using the Configuration sub-tab of the Memory
Configuration tool window.
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 16
Clicking Previous returns to the Color Mode stage and clicking Next moves the wizard to the Project Type stage.
There are two choices at the Project Type stage: A completely blank design, and a template design with a few predefined widgets.
Clicking Previous returns to the Memory Size stage, and clicking Next moves the wizard to the Finish stage.
If the “Template” project type was chosen, MHGC’s Screen Designer will show:
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 17
Tree View Panel
The organization of application widgets and layers, including draw order, is managed using this panel.
Description
Example Tree View
The following Tree View (from main screen of the Aria Coffee Maker demonstration shows the tree structure for a screen with three layers.
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 18
The tool icons for this panel support layers and managing screen objects (layers/widgets).
Drawing Order and Parent/Child Relationships
The Graphics Composer Tree View panel allows you to organize the widgets per screen in the desired drawing order (z-order). It also allows for
the user to organize the widgets into parent – child hierarchies to allow for the paint algorithm to draw the groups together in event of motion or
re-draw. Please note that this does not associate or group the widgets by functionality. (Example: a group of radio buttons might not belong to a
common parent on the screen.) This parent-child relationship is limited to the widgets location on the screen, motion on the screen and the
drawing order on the screen. (Exceptions to this general rule are the Editor > Hidden, Alpha Blending properties, and layer single versus double
buffering. These apply to the parent and all the parent's children.)
The tree is traversed depth-first. This means that the z-order goes background (bottom of z-order) to foreground (top of z-order) as we go from top
to bottom in the list of widgets, i.e., ImageWidget1, is the widget at the bottom of the z-order and the PanelWidget1 is the topmost widget on the
z-order. The tree structure can be arranged and modified by dragging the widgets and releasing it under the desired parent/child. Also, the list can
be modified by using the up/down arrows provided at the header of the Composer Widget tree window to traverse the tree.
Editor > Hidden Property for Layers
Setting Editor > Hidden hides the layer and all its children from the Graphics Composer Screen Designer but does not affect how the layer and its
children are displayed when the application is running. This can be useful when designing complex screens with overlapping layers.
Alpha Blending Property for Layers
Enabling Alpha Blending allows you to control the transparency of a layer and all its children. You can experiment with Alpha Blending in the Aria
Coffee Maker demonstration. Load the project, launch MHC, and then start the Graphics Composer Screen Designer. There are three layers
(Layer0, Layer1, Layer2) in this demonstration. Layer1 (the drag panel on the right) and Layer2 (the drag panel on the left) have Alpha Blending
enabled with Alpha Amount = 225. Setting the Alpha Amount to 255 is the same as disabling Alpha Blending (255 = no transparency). Setting the
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 19
Alpha Amount to 0 makes the layer invisible (0 = full transparency, i.e., invisible).
The following figure shows the main screen with Alpha Blending = 225.
The following figure shows the main screen with Layer 2’s Alpha Blending = 255.
Double Buffering for Layers
Graphics double buffering for the LCC driver is enabled in the Display Manager’s Display Setting screen when the application is changed to use
external memory instead of internal. Click Configure to bring up the LCC Driver Configuration Settings Window.
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 20
Configure the memory according to whether double buffering is to be enabled for the display’s layer or layers.
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 21
Increasing the Buffer Count of a layer from 1 to 2 enables double buffering for the layer and all its child widgets. To prevent tearing on the display
when switching from one buffer to the other, VSync Enabled should also be selected.
Screens Panel
Application screens are managed using the Screens Panel.
Description
The Screens panel tab manages all the application’s screens, as shown in the following figure.
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 22
Note:
These screens are examples from the Aria Showcase demonstration project
The underlined screen name identifies the primary screen (in this case, SplashScreen.) The bold screen name identifies the currently active
screen in the Graphics Composer Screen Designer window (in this case MainMenu.) The blue background identifies the selected screen (i.e., the
screen that is manipulated by the tool icons), in this case FirstScreen.
Window Toolbar
The window’s tools icons support:
1. Create New Screen – Create a new screen. You will be prompted for the name of the new screen, which will appear at the bottom of the
Screens list.
2. Delete Screen – Delete the selected screen. This removes the selected screen from the application.
3. Set as Primary Screen – Sets the selected screen as the default screen displayed by the application at boot-up.
4. Make Screen Active – This selected screen is displayed in the Screen Designer panel. You can also select the active screen by clicking on the
screen’s tab at the bottom of the Screen Designer panel.
5. Move Screen Up in Order – Moves the selected screen up in the list of screens, which is useful in organizing a large list of screens, but has no
other significance.
6. Move Screen Down in Order – Moves the selected screen down in the list of screens.
Useful in organizing a large list of screens, but has no other significance.
Window Columns
The Generate check box is used in selecting those screens that will be included in the application when MPLAB Harmony Configurator (MHC)
generates/regenerates the application. (This, along with the Enabled check box for languages, allows customization of the application’s build to
support different end uses from the same project.) The Visible check box can be cleared to hide a screen from the sub-tabs located at the bottom
of the Screen Designer. The View column provides a mouse-over preview of the screen.
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 23
Schemes Panel
Application color schemes are managed using the Schemes Panel.
Description
Color schemes for the application’s graphics are managed using the Schemes sub-tab.
Editing a Scheme
To edit an existing scheme, select the scheme from the list and click Edit.
The Scheme Editor dialog appears, which allows you to change the colors associated with this display scheme.
Scheme Editor
The Scheme Editor window supports editing the individual colors of a color scheme. Clicking the ellipsis ( … ) opens the Color Picker window.
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 24
Color Picker
The Color Picker window allows the user to easily select a color by providing a color wheel, brightness gauge, and some common predefined color
choices. The user can change the individual color values or input a number in Hexadecimal format. The end result is displayed in the top right
corner.
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 25
Options
Provides information on the defeatured Options window.
Description
In v2.03b, MPLAB Harmony Graphics Composer user interface provided a third window along with Screens and Schemes, named Options.
Beginning with v2.04b of MPLAB Harmony, these options are now located within the File > Settings menu (see Menus for details).
Widget Tool Box Panel
The Widget Tool Box panel is the interface by which users add widgets into the screen representation.
Description
All the available graphics widgets are shown in the Widget Tool Box:
MPLAB Harmony Graphics Composer provides automatic code optimization by keeping track of the widgets that are currently being used. When
MHC generates or regenerates the application, only the Graphics Library code necessary for your design is included in the project.
There are two primary methods for creating new widget objects: clicking and dragging. To add a new layer to a screen use the Screens sub-tab.
Click Method
The following actions can be performed by using the Click method:
• Clicking an item selects it as active. Users can then move the cursor into the screen window and view a representation of the object about to be
added.
• Left-clicking confirms the placement of the new object
• Right-clicking aborts object creation
• Clicking the active item again deactivates it
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 26
Drag Method
Dragging and dropping a tool item into the Screen Designer Window creates a new instance of an object. When dragging a tool item, releasing the
cursor outside of the Screen Designer Window cancels the drag operation.
Widget List
The Graphics Composer Tool Box is the interface by which users add widgets into the screen representation.
Widget Example Application
Arc aria_showcase_reloaded
Bar Graph aria_showcase_reloaded
Button aria_adventure and many others, including aria_quickstart
Check Box aria_showcase_reloaded, aria_video_player
Circle None
Circular Gauge aria_showcase_reloaded, aria_oven_controller
Circular Slider aria_showcase_reloaded
Draw Surface None
Gradient aria_showcase (background)
Group Box aria_video_player
Image aria_quickstart
Image Plus aria_oven_controller
Image Sequence aria_showcase, aria_basic_motion
Key Pad aria_showcase, aria_touchadc_calibrate
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 27
Label aria_quickstart
Line aria_video_player, ./aps/examples/3rd_party_display
Line Graph aria_showcase_reloaded
List Wheel aria_showcase
List aria_video_player
Panel aria_video_player
Pie Chart aria_showcase_reloaded
Progress Bar aria_flash
Radial Menu aria_radial_menu, aria_showcase_reloaded
Radio Button aria_showcase
Rectangle aria_benchmark
Scroll Bar None
Slider aria_video_player
Text Field aria_showcase
Touch Test aria_showcase, aria_touchadc_calibrate, ./apps/examples/3rd_party_display
Window None
Click Method
The following actions can be performed by using the Click method:
• Clicking an item selects it as active. Users can then move the cursor into the screen window and view a representation of the object about to be
added.
• Left-clicking confirms the placement of the new object
• Right-clicking aborts object creation
• Clicking the active item again deactivates it.
Drag Method
Dragging and dropping a tool item into the Screen Designer Window creates a new instance of an object. When dragging a tool item, releasing the
cursor outside of the Screen Designer Window cancels the drag operation.
Automatic Code Optimization
MPLAB Harmony Graphics Composer keeps track of the types of widgets that are used and updates the MHC Tree constantly to ensure that only
the Graphics Library code necessary for your design is included in the project.
Widgets
Widgets can be configured by using the Properties Editor on the right side of the MHGC interface. Each widget has multiple properties to manage
their appearance as well as their functioning. Most properties related to appearance are common between widgets, though some widgets require
specific property entries.
Arc – A graphical object in the shape of an arc. The arc thickness can be set and filled.
Bar Graph – A graphing widget that shows data in categories using rectangular bars.
Button - A binary On and Off control with events generation for Press and Release state.
Check Box - A selection box with Checked and Unchecked states, and associated events.
Circle - A graphical object in the shape of a circle.
Circular Gauge – A circular widget that operates like a gauge, where the hand/needle position indicates a value.
Circular Slider – A circular widget that can change values based on external input like touch. The slider is filled based on the value of the widget
relative to the maximum value.
Draw Surface - A container with a callback from its paint loop. a draw surface lets the application have a chance to make draw calls directly to the
HAL during LibAria's paint loop.
Gradient - A draw window that can be associated with a gradient color scheme. This allows for color variation on the window.
Group Box - A container with a border and a text title. With respect to functionality, a group box is similar to a window.
Image Sequence - A special widget that allows image display on screen to be scheduled and sequenced. Select the images to be displayed, and
the order for display. A timer to trigger the transitions must be created by calling the image sequence APIs to show the next image from the timer
callback function.
Image - Allows an image to be displayed on screen. The size and shape of the widget decides the visible part of the image, as scaling is not
enabled for images at this time.
Image Plus - Allows an image to be displayed on screen. The image can be resized (aspect ratio lock is optional). The widget can be set to accept
two-finger touch input.
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 28
Key Pad - A key entry widget that can can be designed for the number of entries divided as specified number of rows and column entries. The
widget has a key click event that can be customized.
Label - A text display widget. This does not have any input at runtime capability. A Text Field widget serves that purpose.
Line - A graphical object in the shape of a line.
Line Graph – A graphing widget that shows data in categories using points and lines.
List Wheel - Allows multiple radial selections that were usually touch-based selections and browsing.
List - Allows making lists of text and image items. The list contents, number of items, and the sequence can be managed through a List
Configuration dialog box in the Properties box.
Panel - A container widget that is a simpler alternative to DrawSurface as it does not have the DrawSurface callback feature.
Pie Chart – A graphing widget that shows data entries as sectors in a circle.
Progress Bar - Displays the progress pointer for an event being monitored through the "Value Changed" event in the Properties Editor.
Radial Menu - A widget that groups any number of images into an elliptical carousel. It can configured as a touch interactive image carousel or
interface menu.
Radio Button - A set of button widgets that are selected out of the group one at a time. The group is specified by the Group property in the
Properties Editor.
Note:
The radio buttons in the same group must have the same group number specified in their properties.
Rectangle - A graphical object in the shape of a rectangle.
Scroll Bar - Intended to be used with another relevant widget such as the List Wheel to scroll up and down. It has a callback each time the value
is changed. The callback allows users to trigger actions to be handled on the scroll value change event.
Slider - Can change values with an external input such as touch. Event callbacks on value change are also available through the Properties Editor.
Text Field - Text input can be accepted into the text field from an external input or from a widget such as keypad. Event 'Text Changed' in the
Properties Editor is used for accepting the input.
Touch Test - Allows tracking of touch inputs. Each new touch input is added to the list of displayed touch coordinates. The input is accepted
through the 'Point Added' event callback in the Properties Editor.
Window - A container widget similar to the Panel but has the customizable title bar.
Properties Editor Panel
The properties for all layers and widgets are managed using this panel.
Description
The Properties Editor displays options for the currently-selected object (layer or widget), or the options for the active screen if no objects are
selected. To edit an option: left-click the value in the right column and then change the value. Some values have an ellipsis that will provide
additional options. In the previous case, the ellipsis button will display the Color Picker dialog.
Some properties, like the screen width and height, are locked and cannot be edited. Other properties offer check boxes and combo-type
drop-down box choices. Some properties are grouped together like the Position and Size entries. Individual values of the group can be edited by
expanding the group using the plus symbol. For example, the following figure shows properties for a Button Widget.
A new support feature is the ? icon to the right of the Scheme pull-down, which brings up an “Scheme Helper” for the widget showing how it is
colored when using a Bevel border. For a more complete description of widget coloring, see Widget Colors.
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 29
Object Properties
Provides information on widget, layer, and screen properties.
Description
Object Properties and Event Actions
Each widget has a structured tree of properties, visible under the MPLAB Harmony Configurator window on the right of the standard window setup
within MPLAB X IDE. Most widget properties have a Related Event action that can be use in an event or macro to change or set a property from
the application.
Each widget has 3-4 property sets:
Editor – Controls the behavior of layers and widgets under the MPLAB Harmony Graphics Composer Suite Editor.
Property Name Type Description Related Event Actions
Locked Boolean Locks the object (widget), preventing changes by the designer.
Only affects the object (widget) in the editor.
N/A
Hidden Boolean Hides the widget and its children in the designer window. Only
affects the appearance of the widget in the editor.
N/A
Active Boolean For layers only. Sets the layer as active. Any objects (widgets)
added to the screen will be added to this layer.
N/A
Locked to Screen Size Boolean For layers only. Locks the layer size to the size of the display’s
screen.
N/A
Widget – Controls the behavior of screens, layers, and widgets on the display.
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 30
Property Name Type Description Related Event Actions
Name String Editable name for each object. By default, widgets are named
NameWidget1, …,NameWidgetN. For example: ButtonWidget1,
ButtonWidget2, … .
N/A
Position [X,Y] Pair of
Integers
Location on the layer of the upper left corner of the widget or
the location on the display of the upper left corner of the layer.
Measured in display pixels. X is measured from left-to-right and
Y is measured from up-to-down from the upper left corner of the
parent object (typically a Layer or Panel).
Adjust Position, Set X
Position, Set Y Position
Size [X,Y] Pair of
Integers
X: Width, Y: Height of object, in display pixels. Adjust Size, Set Size, Set
Width, Set Height
Enabled Boolean Is the object enabled? Disabled objects are not built into the
display’s firmware.
Set Enabled
Visible Boolean Is the object visible by default? Object visibility can be
manipulated in firmware using laWidget_GetVisible and
laWidget_SetVisible.
Set Visible
Border Widget Border Choices are: { None | Line | Bevel }. Set Border Type
Margin Integer Four integers ([Left,Top,Right,Bottom]) defining the widget’s
margins on the display, in display pixels.
Set Margins
Scheme - Color scheme assigned to the layer or widget. Blank implies the
default color scheme.
Set Scheme
Background Type - Sets the background of the layer or widget. Choices are { None
| Fill | Cache }. In MPLAB Harmony v2.03, this type was
Boolean. Now, Off = None, On = Fill. With Fill selected, the
widget's background is one solid color. With Cache selected, a
copy (cache) of the framebuffer is created before the widget is
drawn and this cache is used to fill the background of the
widget. This supports transparent widgets in front of complex
widgets, such as JPEG images. Instead of rerendering the
JPEG image, it is just drawn from the cache.
Set Draw Background
Alpha Blending Boolean Is alpha blending enabled for this layer or widget and all of its
children? If enabled, specify the amount of alpha blending as an
8-bit integer. Zero makes the object invisible, whereas 255
makes the background invisible.
N/A
Widget Advanced – Advanced control of layers and widgets
Optimization
Sub-Property Name
Type Description Related Event Actions
Draw Once Boolean Indicates that the widget should draw once per screen Show
Event. All other attempts to invalidate or paint the widget will be
rejected.
N/A
Force Opaque Boolean Provides a hint to the renderer that the entire area for this
widget is opaque. Useful for widgets that may use something
like an opaque image to fill the entire widget rectangle despite
having fill mode set to None. This can help reduce unnecessary
drawing.
N/A
Local Redraw Boolean Provides a “hint” to the widget’s renderer that the widget is
responsible for removing old pixel data. This can avoid
unnecessary redrawing.
N/A
Important!
Use Local Redraw only if you know what you’re doing!
Widget Name (e.g., Button Check Box, Circle, etc.) – Optional properties tied to each widget. See Dedicated Widget Properties and Event
Actions.
Events – Associates widget events with event call-backs. For example, you can enable and specify a button pressed event and button release
event for the Button widget.
For each event you specify:
• Enabled/Disabled Check box – To enable or disable (default) the event.
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 31
• Event Callback – Selected from the Event Editor Action List.
There are additional Event actions that do not correspond to any specific property:
• Set Parent – Set the parent of the object, including no parent.
Dedicated Widget Properties and Event Actions
Arc Widget
Property
Name
Type Description Related Event
Actions
Radius Integer The outside radius of the arc. Set Radius
Start Angle Integer The starting angle of the arc in degrees. Set Start Angle
Center Angle Integer The center angle of the arc in degrees. A positive angle draws the arc counter-clockwise from
the start angle. A negative angle draws clockwise.
Set Center Angle
Thickness Integer The thickness of the arc fill, measured from the radius to center. (radius – thickness)
determines the inside radius.
Set Thickness
Round Edge Boolean Draws round arc edge. Set Round Edge
Bar Graph Widget
Property Name Type Description Related Event Actions
Stacked Boolean Stacks the bars for the entries in a category Set Stacked Bars
Tick Length Integer The length, in pixels, of the ticks on each axis Set Tick Length
Fill Graph Area Boolean Fills the graph area with scheme base color Fill Graph Area
Value Axis
Configuration
• Maximum Value
• Minimum Value
• Tick Interval
• Subtick Interval
• Show Ticks
• Tick Position
• Show Tick
Labels
• Show Subticks
• Subtick Position
• Show Gridlines
• String Set
Integer
Integer
Integer
Integer
Boolean
Enum
Boolean
Boolean
Enum
Boolean
String
Asset
Configures the value (Y) axis
The maximum value of the axis
The minimum value of the axis
The intervals between major ticks
The interval between minor ticks
Show/Hide the major ticks
Position of major ticks on the value axis. Choices are: {Inside | Center | Outside}
Show/Hide the tick labels
Show/Hide the minor ticks
Position of minor ticks on the value axis. Choices are: {Inside | Center | Outside}
Show/Hide the gridlines
The string asset containing the numeric characters for the tick labels. The asset
must contain the characters for numbers 0 to 9.
Set Max Value
Set Min Value
Set Tick Interval
Set Subtick Interval
Show Value Axis Ticks
Set Value Axis Ticks
Position
Show Value Axis Labels
Show Value Axis
Subticks
Set Value Axis Subticks
Position
Show Value Axis
Gridlines
Set Labels String
Category Axis
Configuration
• Show Tick
• Show Category
Labels
• Tick Position
Boolean
Boolean
Enum
Configures the category (X) axis
Show/Hide the ticks
Show/Hide the category labels
Position of the ticks on the category axis. Choices are: {Inside | Center | Outside}
Show Category Axis
Ticks
Show Category Axis
Labels
Set Category Axis Ticks
Position
Category
Configuration Dialog
(See
Description)
The Category Configuration Dialog lets users add categories to the line graph.
The following properties can be set:
• Label – String Asset. The label to show for each category
None
Data Configuration
Dialog
(See
Description)
The Data Configuration Dialog lets users add and configure data series to the
line graph. The following properties can be set:
• Scheme – Scheme. The color scheme of the data series
• Category Values – Integer. Values in series for each category
None
Button
Property Name Type Description Related Event Actions
Toggleable Boolean Is button toggle enabled? Set Toggleable
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 32
Pressed Boolean If Toggleable is enabled, provide default state of the button.
This can be used to see the colors of an asserted button.
Set Press State
Text String - Select widget’s text string from the Select String Dialog. Set Text
Alignment:
• Horizontal
• Vertical
- Text string alignment within the button object.
Horizontal alignment. Choices are: { Left | Center | Right }.
Vertical alignment. Choices are: { Top | Middle | Bottom }.
Set Horizontal Alignment
Set Vertical Alignment
Pressed Image - Select image used for pressed state. Default: no image. Set Pressed Image
Released Image - Select image used for pressed state. Default: no image. Set Released Image
Image Position - Position of image relative to button text. Choices are: { LeftOf |
Above | RightOf | Below | Bottom }.
Set Image Position
Pressed Offset Integer Offset of button contents when pressed. In Pixels.
The X and Y position of the button contents is offset by this
amount.
Set Pressed Offset
Check Box
Property Name Type Description Related Event Actions
Text String - Select widget’s text string from the Select String Dialog. Set Text
Alignment:
• Horizontal
• Vertical
- Text string alignment within the button object.
Horizontal alignment. Choices are: { Left | Center | Right }.
Vertical alignment. Choices are: { Top | Middle | Bottom }.
Set Horizontal Alignment
Set Vertical Alignment
Checked Boolean Default state of the check box. Set Check State
Unchecked Image - Select image used for widget’s unchecked state. Default: no
image.
Set Unchecked Image
Checked Image - Select image used for the widget’s checked state. Default: no
image.
Set Checked Image
Image Position - Position of image relative to check box text. Choices are: : {
LeftOf | Above | RightOf | Below | Bottom }.
Set Image Position
Image Margin Integer Space between image and text. In Pixels. Set Image Margin
Circle
Property Name Type Description Related Event Actions
X Integer X offset of circle’s center, from widget’s upper left hand corner,
in pixels.
N/A
Y Integer Y offset of circle’s center, from widget’s upper left hand corner,
in pixels.
N/A
Radius Integer Circle’s radius, in pixels. Set Radius
Circular Gauge Widget
Property Name Type Description Related Event Actions
Radius Integer The outside radius of circular gauge. Set Radius
Start Angle Integer The starting angle of the circular gauge in degrees. Set Start Angle
Center Angle Integer The canter angle of the circular gauge in degrees. A positive
value draws the gauge counter-clockwise. Clockwise if negative.
Set Center Angle
Start Value Integer The start value of the circular gauge. Set Start Value
End Value Integer The end value of the circular gauge. Set End Value
Value Integer The value of the circular gauge. Set Value
String Set String
Asset
The string asset containing the numeric characters for the tick
labels. The asset must contain the characters for numbers 0 to 9.
-
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 33
Major Ticks Configuration
• Ticks Visible
• Tick Length
• Tick Value
• Tick Labels Visible
Boolean
Integer
Integer
Boolean
Configures the major ticks.
Shows/Hides the major ticks.
The length of ticks in pixels.
The interval between ticks.
Shows/Hides the major tick labels.
Show/Hide Ticks
Set Tick Length
Set Tick Value
Show/Hide Tick Labels
Hand Configuration
• Hand Visible
• Hand Radius
• Center Circle Visible
• Center Circle Radius
• Center Circle Thickness
Boolean
Integer
Integer
Integer
Integer
Configures the gauge hand/needle.
Shows/Hides the gauge hand/needle.
Sets the length of the hand in pixels
Shows/Hides the hand center circle.
Sets the radius of the center circle in pixels
Sets the thickness of the center circle in pixels.
Show/Hide Hand
Set Hand Radius/Length
Show/Hide Center Circle
Set Center Circle Radius
Set Center Circle Thickness
Advanced Configuration - Additional widget configuration options for adding minor ticks,
labels and arcs.
-
Minor Ticks Configuration
Dialog
(See
Description)
The Minor Ticks configuration lets users add minor ticks to the
widget. The following properties can be set:
• Start Value – Integer. The value where the first tick starts
• End Value – Integer. The value where the last tick ends
• Interval – Integer. The interval between ticks
• Radius – The radius in pixels where the ticks will be drawn
from
• Length – The length of the ticks in pixels, drawn from the
radius towards the center
• Scheme – The color scheme for the ticks
None
Minor Tick Labels
Configuration Dialog
(See
Description)
The Minor Ticks configuration lets users add minor tick labels to
the widget. The following properties can be set:
• Start Value – Integer. The value where the first tick label is
drawn
• End Value – Integer. The value where the last tick ends
• Interval – Integer. The interval between ticks
• Radius – Integer. The radius, in pixels, where the tick labels
will be drawn from
• Position – Enum, choices are {Outside | Inside}. Position of
the label relative to the radius
• Scheme – The color scheme for the ticks
None
Arcs Configuration Dialog (See
Description)
The Arcs configuration lets users draw arcs in the gauge widget.
The arcs can be used to colorize regions or range of values in the
gauge. The following properties can be set for each arc:
• Type – Enum, choices are {VALUE | ANGLE}. A value type
arc is drawn relative to the values in the gauge. An angle
type arc is draw based on the angles and is not affected by
the values in the gauge.
• Start – Integer. The start value or angle of the arc
• End – Integer. The start value or angle of the arc
• Thickness – Integer. The thickness of the arc in pixels, filled
inward from the radius towards the center
• Radius – Integer. The radius of the arc in pixels
• Scheme. The color scheme of the arc
None
Circular Slider Widget
Property Name Type Description Related Event Actions
Radius Integer The outside radius of circular slider. Set Radius
Start Angle Integer The start angle of the circular slider, in degrees. Set Start Angle
Start value Integer The start value of the circular slider. Set Start Value
End Value Integer The end value of the circular slider. Set End Value
Value Integer The value of the circular slider. Set Value
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 34
Border Circle Configuration
• Show Outside Circle
• Outside Circle Thickness
• Show Inside Circle
• Inner Circle Thickness
Boolean
Integer
Boolean
Integer
Configures the border circle.
Shows/Hides the outside circle border.
The thickness of the outside circle border in pixels.
Shows/Hides the inside circle border.
The thickness of the inside circle border in pixels.
Show/Hide Outside Border
Set Outside Border
Thickness
Show/Hide Inside Border
Set Inside Border Thickness
Active Area Configuration
• Fill Active Slider Area
• Round Edges
• Active Slider Area
Thickness
• Inner Circle Thickness
Boolean
Boolean
Integer
Integer
Configures the slider active area.
Fills the active slider area.
Draws a round edge for the active area.
The thickness of the slider active area in pixels.
The thickness of the inside circle border in pixels.
Show/Hide Active Arc Area
Set Round Edges
Set Active Arc Area
Thickness
Show/Hide Inactive Arc Area
Button Configuration
• Show Circular Button
• Sticky Button
• Touch on Button Only
• Circular Button Radius
• Circular Button Thickness
Boolean
Boolean
Boolean
Integer
Integer
Configures the slider button.
Shows/Hides the circular slider button.
If set, the button sticks when it reaches the start/end values.
If set, the widget responds to touches within the button area only.
The radius of the circular button in pixels.
The thickness of the of the circular button border in pixels.
Show/Hide Circular Button
Set Sticky Button
None
Set Circular Button Radius
Set Circular Button
Thickness
Draw Surface – No additional properties.
Gradient
Property Name Type Description Related Event Actions
Direction - Gradient draw direction. Choices are: { Right | Down | Left | Up }. Set Direction
Group Box
Property Name Type Description Related Event Actions
Text String - Select widget’s text string from the Select String Dialog. Set Text
Alignment - Text string alignment within the widget. Choices are: {
Left|Center|Right }.
Set Alignment
Image Sequence
Property Name Type Description Related Event Actions
Sequence Configuration
Dialog
- Specify image sequence by using the Image Sequence
Configuration Dialog window.
Set Entry Image, Set Entry
Horizontal Alignment, Set
Entry Vertical Alignment,
Set Entry Duration, Set
Image Count
Starting Image Integer Selects the first image to be shown. Set Active Image
Play By Default Boolean Will image sequence play automatically? N/A
Repeat Boolean Should the image sequence repeat? Set Repeat
Additional related event
actions: , Show Next, Start
Playing, Stop Playing.
Image Widget
Property Name Type Description Related Event Actions
Image - Select image used. Set Image
Alignment:
• Horizontal
• Vertical
- Image alignment within the image object.
Horizontal alignment. Choices are: { Left | Center | Right }.
Vertical alignment. Choices are: { Top | Middle | Bottom }.
Set Horizontal Alignment
Set Vertical Alignment
Image Plus Widget
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 35
Property
Name
Type Description Related Event Actions
Image - Select Image used Set Image
Resize To Fit Boolean Resize the image to fill the size of the widget area Toggles option to best fit the image to the widget area
Interactive Boolean Makes the widget interactive, allowing the image to be
translated, stretched and zoomed
Toggles option to permit two-finger gestures to interact
with the widget
Key Pad
Property Name Type Description Related Event Actions
Row Count Integer Number of key pad rows. None.
Column Count Integer Number of key pad columns. None.
Key Pad Configuration
Dialog
(see Description) The Key Pad dialog window has the following:
• Width – Integer. Width of each key, in pixels.
• Height – Integer. Height of each key, in pixels.
• Rows – Integer. Number of key rows. A duplicate of Row
Count.
• Columns – Integer. Number of key columns. A duplicate of
Column Count.
None.
None.
None.
None.
- - Selecting one of the keys on the key pad diagram displays the
Cell Properties for that key:
• Enabled – Boolean. Disabled cells (keys) are made
invisible.
• Text String – Select key’s text string from the Select String
Dialog.
• Pressed Image – Select image used for pressed state.
Default: no image.
• Released Image – Select image used for released state.
Default: no image.
• Image Position – Position of image relative to key text.
Choices are: { LeftOf | Above | RightOf | Below | Behind }.
• Image Margin – Integer. Space between image and text. In
Pixels.
• Draw Background – Boolean. Controls whether the key
should fill its background rectangle.
• Editor Action – Select the generic editor action that fires
when the key is clicked. Choices are: { None | Accept |
Append |
• Editor Value String
Other Key Event Actions:
Set Key Enabled
Set Key Text
Set Key Pressed Image
Set Key Released Image
Set Key Image position
Set Key Image Margin
None.
Set Key Action
Set Key Value
Set Key Background Type
Label
Property Name Type Description Related Event Actions
Text String - Select widget’s text string from the Select String Dialog. Set Text
Alignment:
• Horizontal
• Vertical
- Text string alignment within the widget.
Horizontal alignment. Choices are: { Left | Center | Right }.
Vertical alignment. Choices are: { Top | Middle | Bottom }.
Set Horizontal Alignment
Set Vertical Alignment
Line
Property Name Type Description Related Event Actions
Start X Integer X start of line, in pixels, from upper left hand corner of the
widget.
Set Start Point Position
Start Y Integer Y start of line, in pixels, from upper left hand corner of the
widget.
Set Start Point Position
End X Integer X end of line, in pixels, from upper left hand corner of the widget. Set End Point Position.
End Y Integer Y end of line, in pixels, from upper left hand corner of the widget. Set End Point Position.
Line Graph Widget
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 36
Property Name Type Description Related Event
Actions
Stacked Boolean Stacks the values of the entries in a category Set Stacked Points
Tick Length Integer The length of the ticks on each axis Set Tick Length
Fill Graph Area Boolean Fills the graph area with scheme base color Fill Graph Area
Fill Series Area Boolean Fills the series area with series scheme base color Fill Series Area
Value Axis
Configuration
• Maximum
Value
• Minimum
Value
• Tick Interval
• Subtick Interval
• Show Ticks
• Tick Position
• Show Tick
Labels
• Show Subticks
• Subtick
Position
• Show Gridlines
• String Set
Integer
Integer
Integer
Integer
Boolean
Enum
Boolean
Boolean
Enum
Boolean
String
Asset
Configures the value (Y) axis
The maximum value of the axis.
The minimum value of the axis.
The intervals between major ticks.
The interval between minor ticks.
Show/Hide the major ticks.
Position of major ticks on the value axis. Choices are: {Inside | Center | Outside}.
Show/Hide the tick labels.
Show/Hide the minor ticks.
Position of minor ticks on the value axis. Choices are: {Inside | Center | Outside}.
Show/Hide the gridlines.
The string asset containing the numeric characters for the tick labels. The asset must
contain the characters for numbers 0 to 9.
Set Max Value
Set Min Value
Set Tick Interval
Set Subtick Interval
Show Value Axis
Ticks
Set Value Axis Ticks
Position
Show Value Axis
Labels
Show Value Axis
Subticks
Set Value Axis
Subticks Position
Show Value Axis
Gridlines
Set Labels String
Category Axis
Configuration
• Show Tick
• Show
Category
Labels
• Tick Position
Boolean
Boolean
Enum
Configures the category (X) axis
Show/Hide the ticks
Show/Hide the category labels
Position of the ticks on the category axis. Choices are: {Inside | Center | Outside}
Show Category Axis
Ticks
Show Category Axis
Labels
Set Category Axis
Ticks Position
Category
Configuration
Dialog
(See
Description)
The Category Configuration Dialog lets users add categories to the line graph. The
following properties can be set:
• Label – String Asset. The label to show for each category
None
Data Configuration
Dialog
(See
Description)
The Data Configuration Dialog lets users add and configure data series to the line
graph. The following properties can be set:
• Scheme – Scheme. The color scheme of the data series
• Point Type – Enum. The point indicator to use for the series. Choices are: {None |
Circle | Square}
• Fill Points – Boolean. Fills the points with series scheme foreground color
• Draw Lines – Boolean. Draws lines between points in the series using series
scheme foreground color
• Category Values – Integer. Values in series for each category
None
List
Property Name Type Description Related Event Actions
Selection Mode - Select list selection mode. Choices are:
{Single|Multiple|Contiguous}.
Set Selection Mode
Allow Empty Selection Boolean Is a list selection allowed to be empty? Set Allow Empty Selection
Alignment - Horizontal text alignment. Choices are: { Left | Center | Right }. Set Item Alignment
Icon Position - Position of list icons relative to list text. Choices are: { LeftOf |
RightOf }.
Set Icon Position
Icon Margin - Space between icon and text, in pixels. Set Icon Margin
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 37
List Configuration Dialog - Defines the string and icon image for each entry in the list. Set Item Icon, Set Item
Icon (actually sets item
text).
Additional Related Event
Actions: Deselect All
Items, Insert Item, Remove
All Items, Remove Item,
Select All Items, Set Item
Selected, Toggle Item
Select(ed).
List Wheel
Property Name Type Description Related Event Actions
Alignment - Sets horizontal text alignment. Choices are: { Left | Center |
Right }.
Set Item Alignment
Icon Position - Position of icons relative to text. Choices are: { LeftOf | RightOf
}.
Set Icon Position
Icon Margin Integer Sets the space between icon and text. In pixels. Set Icon Margin
Selected Index Integer Selects the default list item. Set Selected Index
List Configuration Dialog - Defines the image/text for each entry in the list. Set Item Icon, Set Item
Icon (actually sets item
text)
Additional Related Event
Actions: Append Item,
Insert Item, Remove All
Items, Remove Item,
Select Next Item, Select
Previous Item.
Panel – No additional properties.
Pie Chart Widget
Property
Name
Type Description Related Event
Actions
Start Angle Integer The starting angle of the pie chart in degrees. Set Start Angle
Center Angle Integer The center angle of the pie chart in degrees. A positive value draws the chart counter-clockwise.
Clockwise if negative.
Set Center
Angle
Labels Visible Boolean Shows/Hides the labels for each data Show/Hide
Labels
Labels Offset Integer The position of the labels relative to the center of the pie chart, in pixels. Set Label Offset
String Set String
Asset
The string asset containing the numeric characters for the tick labels. The asset must contain the
characters for numbers 0 to 9.
Set Label
String ID
Data
Configuration
Dialog
(See
Description)
The Data Configuration Dialog lets users add data entries to the pie chart. The following
properties can be set:
• Value – Integer. The value of the entry
• Radius – Integer. The radius, in pixels, of the pie for the entry
• Offset – Integer. The offset, in pixels, of the pie from the center
• Scheme – The color scheme for the ticks
None
Progress Bar
Property Name Type Description Related Event Actions
Direction - Direction of progress bar. Choices are: { Right | Down | Left | Up
}.
Set Direction
Value - Default value of the progress bar. The primitives
laProgressBarWidget_GetValue and
laProgressBarWidget_GetValue can be used to
manipulate the widget’s value during run time.
Set Value
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 38
Radial Menu Widget
Property
Name
Type Description Related Event actions
Ellipse Visible Boolean Show the elliptical track of the widget Elliptical track gets
draw in Harmony
Composer simulation
and at runtime.
Highlight
Prominent
Boolean Highlights the prominent item when the widget rotation has completed its reset to the
static, selectable position by drawing a rectangle behind the prominent item.
-
Ellipse Type Enum Selects the type of elliptical track
Default – an elliptical track that best fits the widget area based on the size of the tallest
and widest images with the size scale settings factored-in.
Orbital – a “flatter” elliptical track that is best used with the Theta setting for a tilted look
Rolodex – a vertical track with Theta setting locked at 90 degrees
Locks Theta to 90
degrees when Rolodex
is selected
Theta Integer The angle (in degrees) of tilt relative to the y-axis of the ellipse. The number range is 0
to 90 degrees.
This field is only valid
for Default and Orbital
Ellipse Type setting. It
is locked at 90 when
Rolodex is selected.
a Integer This is the half-length (in pixels) of the 0-180 axis of ellipse. It is auto-calculated based
on the widget size, the tallest image’s height, the ellipse type and scale settings.
-
b Integer This is the half-length (in pixels) of the 90-270 axis of ellipse. It is auto-calculated based
on the widget size, the widest image’s width, the ellipse type and scale settings.
-
Size Scale
Configuration
• Size Scale
* Minimum
Size Modifier
* Maximum
Size Modifier
Enum
Integer
Integer
Off – all images displays at its original size
Gradual – images in the very back are scale to the Minimum Size Modifier setting, the
scale is gradually increased, with the prominent front item scaled to the Maximum Size
Modifier setting
Prominent – the image that is at the front, prominent location is scaled based on the
Maximum Size Modifier, all other images are scaled to the Minimum Size Modifier
setting
The value (in percent) for the widget to resize the image to. When Size Scale is set to
Gradual, this value represents the lowest scale for the item in the back. When Size
Scale is set to Prominent, this value represents the scaling value for every image in the
widget except for the prominent item. This value is equal to or less than the Maximum
Size Modifier value
The value (in percent) for the widget to resize the image to. When Size Scale is set to
Gradual, this value represents the largest scale for the item in the front (prominent
position). When Size Scale is set to Prominent, this value represents the scaling value
for the prominent item. This value is equal to or greater than the Minimum Size Modifier
value
-
-
-
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 39
Item List
Configuration
• Total
Number of
Items
Shown
* Total
Number of
Widget Items
* Widget
Items
Configuration
Dialog
Integer
Integer
(See
Description)
The number images visible on the radial menu. This number does not may be less than
or equal to the total images in the widget.
The total number of images the widget contains.
The Widget Items Configuration Dialog lets users add images to the widget. The follow
properties can be set:
• Image – Image Asset. The image to show for the widget item
The widget
automatically
space-out the images
along the elliptical track
base on this value.
If this number is
greater than Total
Number of Items
Shown, some of the
images will be hidden
in a FIFO queue in the
back
-
Touch Area
Configuration
• Show
Touch
Area
* Touch Area
X Offset
* Touch Area
Y Offset
* Touch Area
Width
Percent
* Touch Area
Height
Percent
Boolean
Integer
Integer
Integer
Integer
Show visually in Harmony Graphics composer the rectangular area that permits touch
interaction.
The X-coordinate in local space of the touch-allowed area for the widget. This is
auto-calculated based on the Touch Area Width Percent.
The Y-coordinate in local space of the touch-allowed area for the widget. This is
auto-calculated based on the Touch Area Height Percent.
The percentage of the width of the touch-allowed area as compared to the entire widget
area.
The percentage of the height of the touch-allowed area as compared to the entire
widget area. The default value is 50.
This setting is for
preview in Harmony
Graphics composer
only. The touch area is
not rendered at runtime.
-
-
If this value is less than
100 percent, the area
is horizontally centered.
If this value is less than
100 percent, the area
is defined starting from
the bottom of the
widget.
Radio Button
Property Name Type Description Related Event Actions
Text String - Select widget’s text string from the Select String Dialog. Set Text
Alignment:
• Horizontal
• Vertical
- Text string alignment within the widget.
Horizontal alignment. Choices are: { Left | Center | Right }.
Vertical alignment. Choices are: { Top | Middle | Bottom }.
Set Horizontal Alignment
Set Vertical Alignment
Group Integer Radio Button Group Number. Default is -1, indicating no group.
Only one radio button in a group can have a default selected
value of On. All others in the group are Off
N/A
Selected Boolean If selected, the button has a default value of On. All other
buttons in the group have a Selected value of Off.
Select
Selected Image - Select image used for selected state. Default: no image. Set Selected Image
Unselected Image - Select image used for unselected state. Default: no image. Set Unselected Image
Image Position - Position of image relative to widget text. Choices are: { LeftOf |
Above | RightOf | Below | Behind }.
Set Image Position
Image Margin - Space between radio button image and text, in pixels. Set Image Margin
Circle Button Size - The diameter of the default circle button, in pixels Set Circle Button Size
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 40
Rectangle
Property Name Type Description Related Event Actions
Thickness Integer Line thickness in pixels. Set Thickness
Scroll Bar
Property Name Type Description Related Event Actions
Orientation - Scroll bar orientation. Choices are: { Vertical | Horizontal }. Set Orientation
Maximum Integer Maximum scroll value (minimum = 0.) Set Maximum Value
Extent Integer Length of scroll bar slider, re scroll bar maximum value.
Indicates the number of lines or size of window visible at each
scroll setting.
Set Extent
Value Integer Initial scroll bar value. Set Value, Set Value
Percentage
Step Size Integer Step size value of scroll bar arrow buttons. ( Min = 1, Max =
9999 ).
Set Step Size
Additional Related Event
Actions: Step Backward,
Step Forward
Slider
Property Name Type Description Related Event Actions
Orientation - Orientation of the slider. Choices are: { Vertical | Horizontal }. Set Orientation
Minimum - Minimum slider value. Set Minimum Value
Maximum - Maximum slider value. Set Maximum Value
Value - Initial slider value. Set Value, Set Value
Percentage
Grip Size - Grip size of slider, from 10 to 9999, in pixels. Set Grip Size
Additional Related Event
Actions: Step
Text Field
Property Name Type Description Related Event Actions
Text String - Select widget’s text string from the Select String Dialog. Clear Text followed by
Append Text
Alignment - Horizontal alignment. Choices are: { Left | Center | Right }. Set Alignment
Cursor Enable - Boolean. Show blinking cursor while editing. Set Cursor Enabled
Cursor Delay - Cursor delay in milliseconds. From 1 to 999,999. Set Cursor Delay
Additional Related Event
Actions: Accept Text,
Append Text, Backspace,
Clear Text, Start Editing.
Touch Test – No dedicated properties.
Window
Property Name Type Description Related Event Actions
Title String - Select widget’s title string from the Select String Dialog. Set Title
Icon Image - Select image used. Default: no image. Set Icon
Image Margin Integer Space between icon and title, in pixels. N/A
Layer Properties and Event Actions
The property list for a graphic layer is close in look and feel to that of a widget. Each Layer has three property sets: Editor (see above), Widget
(see above), and Layer (see below).
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 41
Layer Properties
Property Name Type Description Related Event Actions
Transparency Enabled Boolean Automatically mask out pixels of with a specified color.
If enabled Specify:
N/A
Mask Color Integer Red/Green/Blue or Red/Green/Blue/Alpha color value N/A
All Input Passthrough Boolean Allow input events to pass through this layer to layers behind it. N/A
VSync Enabled Boolean Layers should swap only during vertical syncs. N/A
Buffer Count Integer Integer number of frame buffers associated with this layer,
either 1 or 2.
N/A
Buffer N - For each buffer (N= 1 or 2) you specify: -
Allocation Method - Buffer allocation method.
Choices are: { Auto | Address | Variable Name }
• Auto – Automatically allocate frame buffer space
• Address – Specify a memory address
• Variable Name – Use variable name as buffer location
N/A
Memory Address - If Address is the allocation method, specify the raw (physical)
memory address as a hexadecimal number.
N/A
Variable Name String If Variable name is the allocation method,
specify the variable name as a string value.
N/A
Screen Properties and Events
The property list for a screen shares the Name and Size properties with Layers and Widgets but has these unique properties.
Screen Properties
Property Name Type Description Related Event Actions
Orientation - Display orientation: 0, 90, 180, 270 Degrees.
This can also be set using the Display Manager.
N/A
Mirrored Boolean Enables screen mirroring. N/A
Layer Swap Sync Boolean Enables that all layer buffer swapping happen at the same time,
delaying lower layers until higher layers are finished drawing as
well. For example, assume you make changes to layer 0 and
layer 1 and you want to see those changes show up on the
screen at the same time. Without this option you’d see layer 0’s
changes as soon as it finishes when layer 1 has not yet started
drawing. This option will hold layer 0’s swap operation until
layer 1 finishes as well.
Note: Currently, this property is only supported by the
CLCD Graphics Controller Driver and is ignored by all other
drivers.
N/A
Persistent Boolean Indicates that the screen should not free its widgets and
memory when it is hidden. This results in faster load times and
persistent data, but at the cost of higher memory consumption.
N/A
Export Boolean Includes this screen the application build.
This can also be set using the Screens panel.
N/A
Primary Boolean Sets this screen as the primary screen. The primary screen is
the first screen displayed when the application starts. This can
also be done using the Screens Panel Generate check box.
N/A
Graphics Composer Asset Management
The Asset menu supports managing all graphical assets (memory, images, languages, fonts, strings, and binary data).
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 42
Memory Configuration
Provides information on configuring memory locations.
Description
The Memory Locations window is launched from the Graphics Composer’s Asset menu. Selecting Memory Locations this brings up a window with
three sub-tabs (in this example, the Aria Showcase demonstration is referenced):
Window Toolbar
The window’s tools icons support:
1. Add New Memory Location – This supports multiple external memory resources.
2. Delete Selected Memory Location – Removes a previously defined memory location.
3. Rename Selected Memory Location – Renames a previously defined memory location.
4. Configure External Media Application Callback – This allow definition of media callbacks, which must be provided in the project.
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 43
5. Show Values as Percent – Memory utilization on the bar graph can be in bytes or as a percent of the total internal flash memory assigned to
support asset storage. (That memory allocation is set using the Configuration sub-tab.)
The APIs for the external media callback functions are as follows:
GFX_Result app_externalMediaOpen(GFXU_AssetHeader* asset);
GFX_Result app_externalMediaRead(GFXU_ExternalAssetReader* reader,
GFXU_AssetHeader* asset,
void* address,
uint32_t readSize,
uint8_t* destBuffer,
GFXU_MediaReadRequestCallback_FnPtr cb);
void app_externalMediaClose(GFXU_AssetHeader* asset);
The graphics demonstration project, aria_external_resources, provides an example of how to write these callbacks. This demonstration supports
three types of external memory: SQI External Memory, USB Binary, and USB with File System. Examples of these callbacks are found in the
project’s app.c file. The Aria demonstration projects Aria External Resources and Aria Flash provide more details on how to use external memory
to store graphics assets.
Sub-tabs
There are three sub-tabs to this window.
Summary Sub-tab
This sub-tab summarizes program flash allocations for images, strings, and fonts.
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 44
The memory allocation shown for “Font Glyphs” measure the space that holds all the font glyphs used by the application, either by static strings or
by glyph ranges defined in support of dynamic strings. Strings are defined by arrays of pointers to glyphs, so string memory usage measures the
size of these arrays, not the actual font glyphs used. (“Glyph” is defined here.)
Note:
The word “glyph” comes from the Greek for “carving”, as seen in the word hieroglyph – Greek for “sacred writing”. In modern
usage, a glyph is an elemental or atomic symbol representing a readable character for purposes of communicating through writing.
Configuration Sub-tab
This sub-tab specifies the intended allocation of internal (program) flash memory to graphics assets (Total Size). (The default value is 1024 bytes.)
It also names the graphics assets file name (here it will be gfx_assets.c). The allocation of flash is only used to scale the Total/Used/Available
bar graph at the top of the display. Under sizing or oversizing this amount does not affect how the application is built.
If your device has 1024 Kbytes (1048576 bytes) of flash, you can assign 40% to asset storage and 60% to code. In that case the “Total Size” in the
above sub-tab would be set to 419430 (= 40% of 1048576).
The Calculator button can assist you in allocating internal flash. Click on it and then set the device flash capacity. Then you can apply an
adjustment to that value to assign that memory to asset storage.
Example:
If the device has 2 Mbytes of internal Flash, click 2MB.
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 45
Then, to assign 75% of the 2 Mbytes to asset storage, click -25% to reduce the 2 MB by 25%, leaving 75%, and then click OK to finish. This will
then assign 1,536,000 bytes to asset storage.
Internal (program) Flash is shared between the application’s code and asset storage. If the application code and graphics assets (fonts, strings,
images) won’t fit into the available flash memory then the linker will be unable to build the application and an error will be generated in MPLAB X
IDE.
The Output File Name must be compatible with the operating system hosting MPLAB X IDE. In most cases the default name (gfx_asset.c) will
suffice, but this is provided for additional flexibility in building the application.
Optimization Sub-tab
The Optimization sub-tab for the Aria Quickstart demonstration is shown in the following figure.
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 46
The Size column shows the bytes allocated for storage in internal flash for the images, fonts, and binaries of the application.
The References column shows the number of known references for these assets by the application’s widgets. A references count of zero
suggests that the asset is not used by the application, but it could also mean that the asset is only used in real-time when it is dynamically
assigned to a widget by the application. Clicking the title of a column (Name, Size, or References) sorts the lists of graphics assets by that column.
Clicking the same column again reverses the sort order.
The window’s tools icons support:
1. Edit Selected Asset – This brings up the edit dialog for the image, font, or binary chosen
2. Delete Selected Assets – Removes the selected assets
3. Move Selected Assets – Move assets from one location to another. This is useful for moving assets to/from internal memory from/to external
memory.
4. Show Only Images – Show image assets toggle on/off
5. Show Only Fonts – Show font assets toggle on/off
6. Show Only Binaries – Show binary assets toggle on/off
DDR Organizer
The DDR Organizer tool supports managing buffers, raw images, and other memory resources in the DDR memory of DA devices and only
DDR-enabled DA devices. This tool also requires that the DA’s built-in 2D graphics processor be enabled. Under Harmony Framework
Configuration > Graphics Stack > Graphics Processor, select the NANO 2D processor:
The DDR Organizer tool is launched from the Assets Management pull-down menu:
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 47
The following window will appear if the tool has not been used before for the active project target configuration:
Select the memory profile that corresponds to the target DDR-enabled DA device:
Then select the Load Button to load that memory configuration into the tool.
When Preprocessing is enabled for an image under the Image Assets tool:
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 48
An entry for the image appears in the DDR Organizer window:
When the memory profile is loaded, the tool automatically reserves DDR memory for the GLCD Frame Buffers sufficient for three double-buffered
layers, allocating 32 bits (4 bytes) for RGBA_8888 format for each pixel. This provides 384,000 pixels (800x480) per frame buffer.
The tool icons support adding non-image memory allocations to the DDR memory map. To add or remove the memory allocation belonging to an
image, the Preprocessing enabled property for that image is enabled/disabled using the Image Asset tool.
Image Assets
Provides information on the Image Assets features.
Description
The Image Assets window is launched from the Graphics Composer’s Asset menu.
The Image Assets window lets you import images, select different image formats/color modes for each image, select compression methods (for
example, RLE) for each image, and displays the memory footprint of each. Images can be imported as a BMP, GIF, JPEG, and PNG (but not
TIFF). Images can be stored as Raw (BMP, GIF), JPEG, and PNG.
Note:
MHGC does not support image motion that can be found in GIF (.gif) files. GIF images are stored in the raw image format,
meaning that there is no image header information stored with the image.
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 49
When an image is imported into MGHC, the Graphics Asset Converter (GAC) stores the input format and color mode along with any relevant
header data. The image’s pixel data is then promoted from its native format into a Java Image using 32 bits/pixel (8 bits for each color, RGB, and 8
bits for Alpha Blending). If the image contains Alpha Blending then this information is stored in the “A” of RGBA, otherwise the “A” is set to
maximum opacity. When the application is built each image is stored in the image format and color mode selected. Images displayed in the Screen
Designer are converted from Java Image format into the format/color mode selected so that the Screen Designer accurately represents what the
application will show when running.
The images are decoded on the fly by the graphics library and rendered on the screen. This provides the designer with considerable flexibility to
import using one format and store resources using another format, thus exploring and maximizing the best memory utilization for their application
and hardware. This supports trading a smaller memory footprint at the cost of additional processing (for static or drawn-once) or reducing
processing at the cost of a larger memory footprint (dynamic or drawn many times).
The following figure shows the Image Assets window for the Aria Quickstart demonstration.
Window Toolbar
There are five icons on the toolbar below the Images tab:
1. Add Image Asset – Brings up “Import Image File” dialog window to select image file to add to the graphics application.
2. Replace Existing Image with New Image File – Brings up the same “Import Image File” dialog but instead of creating a new image, the file’s
content replaces the currently selected image.
3. Rename Selected Image – Renames the selected image.
4. Create New Virtual Folder – Creates a new virtual folder, allowing you to organize images in a hierarchy.
5. Delete Selected Images – removes the selected images from the application.
Selecting the Add Image Asset or Replace Existing Image icon opens the Import Image File dialog that can be used to select and import an image.
After selecting the file and clicking Open, the Image Assets window opens.
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 50
The size of the memory used for this image based on its color mode, format, compression, and global palette usage is shown by Size (bytes). See
Image Format Options below for more details.
The File Name of the original source file is also shown, but may be blank if the image was imported under MPLAB Harmony v2.03b or earlier. The
format and color mode of the stored image can be changed to reduce the image’s memory footprint. (If using an LCC controller, you can also turn
on the Global Palette, replacing each pixel in the image with just an 8 bit LUT index.)
The three internal image formats are:
• Raw – binary bit map with no associated header information. GIF and BMP images are imported into this format.
• PNG – lossless image format with compression, 24 bits/pixel (RBG_888) or 32bits/pixel (RGBA_8888). A good choice for line drawings, text,
and icons.
• JPEG (JPG) – loss compressed format, uses much less storage than the equivalent bit map (raw). Good for photos and realistic images.
New to Harmony 2.06 is the option to preprocess an image into raw pixels at boot-up, which will greatly improve image draw/redraw times though
the use of the high performance 2-D graphics processing unit (GPU) that is available on DDR-enabled DA devices. Be sure that this feature is
enabled in MPLAB Harmony Configurator. Under Harmony Framework Configuration > Graphics Stack > Graphics Processor, select the NANO
2D processor:
Note:
Do not enable image preprocessing except on DDR-enabled DA devices with the NANO 2D graphics processor enabled. To do so
will produce an application that builds but does not run.
With Preprocessing of the image enabled, additional options become available:
• DDR Memory allocation for the image is automatically handled when the Managed option is selected
• The Output Mode should be selected to match the GLCD’s color mode, typically RGBA_8888
• The Padding option expands the image size to the nearest power of two. For example, a 480x212 image would be increased to 512x256 pixels.
• The expected size of the preprocessed image in DDR memory is shown in the Expected Size entry
For more information on how images are stored within DDR memory, see the section on the Asset Management DDR Memory tool above.
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 51
The Image Assets window supports resizing, cropping, or resetting an image:
• Resize – Brings up a dialog window to change the pixel dimensions of the image. The image is interpolated from the original pixel array into the
new pixel array.
• Crop – Places a cropping rectangle on the image. Click and drag a rectangle across the image to select the new image. Then click Ok to crop
the image.
• Reset – Allows undoing of a resize or crop. The original image is always stored in the project, so a Reset is always available to return the
image to its original state.
Original images are retained by MHGC by the superset Java Image format. So an image crop will change how the image is stored in the
application but not how it is stored in MHGC. Reset will always restore the image back to the original pixels. (Reset is not an “undo”.)
Example Images
Example images are available from many sites on the internet. One of the best sites is found at the USC-SIPI Image Database
(http://sipi.usc.edu/database/). There are many canonical test images, such as Lena, The Mandrill (Baboon), and other favorites, all in the TIFF
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 52
format. The TIFF format is not supported by the Graphics Composer, but you can easily convert from TIFF to BMP, GIF, JPEG, or PNG using the
export feature found in the GNU Image Manipulation Program (GIMP), which is available for free download at: https://www.gimp.org. GIMP also
allows you to change the pixel size of these images, usually 512x512, to something that will fit on the MEB II display (either 256x256 or smaller).
The following figure shows the Graphics Composer Screen Designer for the pic32mz_da_sk_meb2 configuration of the Aria Quick Start project
after adding three images.
The following figure shows the Optimization Tab after adding these images.
Selecting the Baboon_GIF image and the Edit Selected Asset icon ( ) opens an Image Assets window, as shown in the following figure.
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 53
Because this image had only 253 unique pixel colors (Unique Pixel Count = 253) the Enable Palette option was automatically enabled. This
feature, which works on an image by image basis, is separate from enabling a Global Palette. The image is stored using 8 bits of indexing into an
image-specific lookup table (LUT). If the image has more than 256 unique colors then the Enable Palette option is not available and is not shown.
Image Format Options
Raw Format Images
Raw format images have the following options:
Regardless of the Color Mode of the imported the image, the stored image can be stored in a different color mode. For example, a JPEG image
could be in 24 bits/pixel RGB format but stored in the application using RGB_565 or even RBG_332 to save space. The Project Color Mode (set
through the File > Settings menu) is different from the Color Mode of images. This is determined by the capabilities of the projects graphics
controller. The graphics library converts images from the stored color mode to the project’s color mode before output.
If the image has 256 or less unique pixel colors an option to Enable Palette is set by default. If the image has more than 256 unique colors this
option is not displayed. This replaces the palette pixels with 8-bit indices into the image’s palette look up table (LUT). NOTE: Enabling the Global
Palette disables this for all images and all image pixels are replaced by 8-bit indices into the global palette LUT.
The Compression Mode for a raw format image is either None (no compression) or RLE for run-length encoding.
Image masking is a form of cheap blending. For example, given the following image, you may want to show the image without having to match the
lime green background. With image masking you can specify that the lime green color as the “mask color”, causing it to be ignored when drawing
this image. The rasterizer will simply match a pixel to be drawn with the mask. If they match, the pixel is not rendered.
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 54
PNG Format Images
For PNG format images you can change the image format and the image color mode:
JPEG Format Images
For JPEG format images you can change from JPEG format to Raw or PNG:
Once changed from JPEG into another format, the new format will have other options.
Managing Complex Designs
The Image assets tool lists the images in the order of their creation. In a future version of MPLAB Harmony this will be sortable by image name.
For now, it is recommended that you use the Memory Locations asset tool, and use the Optimization sub-tab instead to manage a complex set of
images. The Optimization sub-tab allows you to sort graphics assets (fonts, images, binaries) by Name, Size, and number of widget References.
This makes it much easier to find and edit an image by its name rather than order of creation.
Font Assets
Provides information on the Font Assets features.
Description
The Font Assets window is launched from the Graphics Composer’s Asset menu.
Note:
There are three dimensions to text support: Languages, Fonts, and Strings. Language “ID” strings are identified when an
application supports more than one language. (In the case of single language support, the language default is provided.) Fonts are
imported and organized using the Font Assets window. Strings are defined by a string name, and this name is used by widgets to
reference the string. For each string and each language supported the glyphs are defined to spell out the string’s text and the font
is chosen for that text.
• Languages are managed within the String Table Configuration window
• Fonts are managed within the Font Assets window (this topic)
• Strings are managed within the String Assets window
The following figure shows the Font Assets window from the Aria Coffee Maker demonstration.
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 55
The Size (bytes): for a Font asset shows how much memory is needed to store all the glyphs used by the application from this font. For static
strings MHGC determines which glyphs are used by the application’s pre-defined strings and builds these glyphs into the application. For dynamic
strings (i.e. strings created during run time) ranges of glyphs are selected by the designer and these ranges are also included in the application by
MHGC. The memory needed to store all these glyphs is shown by Size (bytes): .
Window Toolbar
There are five icons on the toolbar below the Images tab:
1. Add Font From File – Adds a font asset from a file.
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 56
2. Add Installed Font – Add a font installed on your computer.
3. Replace Existing Font Data with New Source Font – Both Add Font From File and Add Installed Font create a new font asset. This icon
allows you to update an existing font asset, importing from a file or using a font installed on your computer.
4. Rename Selected Font – Renames an existing font asset. In the example above, the Arial font was installed twice, first as a 16 point font and
second as a 12 point font. If added to the fonts assets in this order, the 12 point font will have the name Arial_1. This font asset was renamed to
Arial_Small using this tool.
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 57
5. Delete Selected Fonts – Removes selected font assets from the application.
Sub-tabs
There are three sub-tabs to this window.
Style Sub-tab
The Size (bytes): shown represents the memory needed to store all the font’s glyphs. The application only stores the glyphs that are used by static
(build-time) strings and by predefined glyph ranges to support dynamic (run-time) strings.
The choices for Memory Location must be defined before the font can be assigned. Go to the Memory Configuration window to add a new location
before using it in this sub-tab.
Each font asset consists of a font, size, and some combination of the { Bold, Italic, Anti-Aliasing } options, including selecting none of these
options. If you need bold for one set of strings and italic for another, then you will need two font assets, one with Bold checked and a second with
Italic checked. The same applies for font sizes. Each font size requires its own font asset. Thus if you need two sizes of Arial, with plain, bold, and
italic for each size, you will need 6 separate assets (6 = 2 Sizes x 3 ).
Glyphs are normally (Anti-Aliasing off) stored as a pixel bit array, with each pixel represented by only one bit. Turning on Anti-Aliasing replaces
each pixel bit with an 8-bit gray scale, thereby increasing font storage by a factor of 8!
What if a font is chosen that does not support the character types of the text used for a particular language in the application? How can you test
and debug this? There a basically two ways:
• Use an external font viewer to examine if the needed glyphs exist
• Configure, build, and run the application and verify the strings are correctly rendered
If the glyphs are not available they will be rendered as rectangles ( ).
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 58
Strings Sub-tab
The Bound check box accomplishes the same thing as assigning a font to a text string in the Strings Assets window (Window:Strings menu).
Assigning a string to a font means that the font will generate glyphs for that string. This is just another way to accomplish the binding of the string
text to font.
This sub-tab is also useful in a complicated graphics design to see how many strings use a particular font. Lightly-used or unused fonts can be
eliminated to free up internal Flash memory.
Glyphs Sub-tab
Note:
The word “glyph” comes from the Greek for “carving”, as seen in the word hieroglyph – Greek for “sacred writing”. In modern
usage a glyph is an elemental or atomic symbol representing a readable character for purposes of communicating via writing.
The Glyph sub-tab is only used when your application supports dynamic strings. For static (build-time) strings MHGC automatically determines
which font glyphs are used based on the characters present in all the strings used by the application’s graphics widgets. Only these glyphs are
included as part of the application’s font assets. With dynamic (i.e. run-time) strings this is not possible. This sub-tab allows you to specify which
range of glyphs will be used by run-time strings. Once glyph ranges are defined, these glyphs are added to the font glyphs used by static strings.
The Create New Custom Import Range icon ( ) allows you to input a new glyph range for the font. Selecting this icon opens the Font Assets
window.
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 59
String Table Configuration
Provides information on the String Assets features.
Description
The String Table Configuration window is launched from the Graphics Composer’s Asset menu.
Note:
There are three dimensions to text support: Languages, Fonts, and Strings. Language “ID” strings are identified when an
application supports more than one language. (In the case of single language support, the language default is provided.) Fonts are
imported and organized using the Font Assets window. Strings are defined by a string name, and this name is used by widgets to
reference the string. For each string and each language supported the glyphs are defined to spell out the string’s text and the font
is chosen for that text.
• Languages are managed within the String Table Configuration window (this topic)
• Fonts are managed within the Font Assets window
• Strings are managed within the String Assets window
Within this window, the Languages supported by the application are defined and the encoding for all application glyphs selected.
The “ID” string used for each language is merely for ease of use in building the texts to be used. “English”, “American”, or any other string can be
used to identity that language, as long as it is understood by the application’s creator when selecting the text to be used for that particular
language. Then the application can switch to supporting one of its languages using “ID” strings defined.
Here is an example string asset definition, taken from the Aria Coffee Maker demonstration. This application supports English, French, Italian, and
German. The text string “InfoText_Desc9” uses the Arial font, and text for each language is specified within the String Assets window.
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 60
Any number of languages can be defined as long as there is memory to store the strings needed.
The following figure shows the String Table Configuration for an application that uses English, Spanish, and Chinese.
The size of all the strings for each language is shown in the Size column. String size represents the memory allocated for glyph indices for all the
strings supporting that language. A language can be enabled/disabled via the check box in the Enabled column. Disabling a language removes it
from the application build but keeps it in the project.
Window Toolbar
There are three icons on the toolbar:
1. Add New Language – Adds a new Language.
2. Set Default Language – Sets the application’s default language. Note, this is different than the abc tool on the Graphics Composer Window
toolbar. The abc icon sets the preview language for the Screen Designer panel only. This icon sets the language used by the application after
boot-up.
3. Remove Selected Language – Removes language from the application.
Clicking Add New Language opens a new line, allowing you to select and edit the new language’s “ID” string.
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 61
Then, for every string defined in the application there will be a line to define the needed text, and to specify the font to be used.
If you don’t provide a value for the new language the string will be output as a null (empty string). If you don’t provide a Font selection then the
string will be output as a series of blocks (?).
The Aria User Interface Library primitive, LIB_EXPORT void laContext_SetStringLanguage(uint32_t id), allows the application to
switch between languages using the Language ID #defines are specified in the application’s gfx_assets.h file.
Sub-tabs
There are two sub-tabs to this window.
Language Definitions Sub-tab
This sub-tab shows the languages defined for the application. A Language can be enabled/disabled to include or exclude it from the application’s
generation/regeneration under MPLAB Harmony Configurator (MHC). New languages can be added by specifying a text string for the language.
With a new language, go to the String Assets window to specify the text and fonts for all defined strings.
Encoding Sub-tab
Selecting the Character Encoding Format Selection Dialog icon gives you three choices for how the characters in all strings in the graphics
application are encoded:
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 62
The default is ASCII. It is typically the most efficient in terms of memory and processing, but it does not support as many glyphs. Chinese text
should be encoded in UTF-8 or UTF-16, but Western language text can be encoded in ASCII to save memory. The trade-off between ASCII,
UTF-8, and UTF-16 depends on the application. Changing from UTF-8 to UTF-16 will double the size of all strings in the application. This is
because the sizes of all glyph indices double in size. (String sizes are the sizes of glyph reference indices, not the size of the particular font glyphs
used to write out the string.)
The memory utilization resulting from an encoding choice can be seen in the Summary sub-tab of the Memory Configuration window.
String Assets
Provides information on the String Assets features.
Description
The String Assets window is launched from the Graphics Composer’s Asset menu.
The String Assets window supports managing the strings in the application. Strings are referenced by graphic widgets using an application-wide
unique name. This unique name is built into an enumeration that the application’s C code uses. For each language supported text is defined and a
font asset selected.
Note:
There are three dimensions to text support: Languages, Fonts, and Strings. Language “ID” strings are identified when an
application supports more than one language. (In the case of single language support, the language default is provided.) Fonts are
imported and organized using the Font Assets window. Strings are defined by a string name, and this name is used by widgets to
reference the string. For each string and each language supported the glyphs are defined to spell out the string’s text and the font
is chosen for that text.
• Languages are managed within the String Table Configuration window
• Fonts are managed within the Font Assets window
• Strings are managed within the String Assets window (this topic)
The following figure shows an example taken from the Aria Coffee Maker demonstration. The string name, InfoText_Desc9, defines a string asset
that is used by the application.
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 63
The Total Size in Byte: for a string asset represents the memory needed to store the glyph indices for all the text defined for that string asset.
Adding more text will increase the number of glyph indices needed thus increasing the size of the string’s memory. Adding another language will
do the same, since the number of glyph indices also increases. Changing the font does not increase the size of the string’s memory, but may
increase the size of the font chosen if it is a “bigger” font and adds more glyphs to the new font. (By “bigger” we mean a font with more pixels, for
example because it is bigger in size, or perhaps because it is anti-aliased and the original font was not.)
Note:
The Reference Count shown reflects the number of build-time references to the string. Dynamic uses of a string, such as through
macros or events, is not reflected in this number.
Window Toolbar
There are four icons on the toolbar:
1. Add New String – Adds a new string.
2. Rename Selected Item – Allows renaming the string.
3. Describe Selected String - Provides a Description field value for selected string.
4. Create New Virtual Folder – Creates a new virtual folder, allowing you to organize strings in a hierarchy. Here’s an example reorganization of
the existing strings. Note the order of virtual folders or items in the list is strictly alphabetical. Virtual folders and string asset organization is
merely for the convenience of the developer. Neither has an effect on how the application is built.
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 64
5. Delete Selected Items – Deletes selected strings from the application.
6. Import String Table - Imports an Excel CSV (Comma Separated Value) file to replace the current string table.
7. Export String Table - Exports the current string table as an Excel CSV (Comma Separated Value) text file.
Creating New Strings
To create a new string, click Add New String ( ).
Selecting this icon opens the Add String dialog to name the string. The text chosen for the string name should be acceptable as a C variable.
After entering the new string’s name and click Create, the following String Assets window appears.
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 65
In the String Assets window, there will be a line for each of the languages defined for the application. Provide the string text and font for each of
the languages. An empty string will be used if the text is not provided. Not providing a font causes the string to be rendered as a string of boxes (
).
Importing and Exporting String Tables
Importing an Excel CSV (Comma Separated Values) file replaces the existing string assets table. Exporting creates an Excel CSV file that can be
imported into another project or target configuration. Exported string tables can be manipulated in Excel, even combining multiple string tables into
a single string table that can then be imported.
If the string asset table contains UTF-8 then the file cannot be directly loaded into Excel. Instead, within Excel create a new sheet. Import the string
table using Get Data, selecting From File, From Text, or CSV. Then in the dialog window change the File Origin to Unicode (UTF-8).
Note:
Excel does not support importing UTF-16.
Binary Assets
Provides information on the Binary Assets features.
Description
The Binary Assets window is launched from the Graphics Composer’s Asset menu.
Selecting the Add Binary File icon ( opens the Import File dialog.
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 66
This supports any formatted binary file. Developers can then add a custom-coded decoder to support the format implied by the imported file. (A
future version of the GFX library will include a bin2code utility in support of this feature.)
MHGC Tools
The Tools menu supports managing all graphics events, using a global palette, and estimating heap memory usage.
Event Manager
This section provide information on the Event Manager.
Description
The Graphics Composer Event Manager provides a GUI interface to manage all of the events associated with a graphics application. In a general
sense, an event is an action or occurrence that is processed by software using an “event handler”. Button pushes or keystrokes are widely
recognized and handled events. Events related to a touch screen are commonly called “gestures”. This GUI allows the assignment of actions to
events associated with graphics widgets and to events outside of the graphics library. Under the Graphics Composer Event Manager tab there are
two sub-tabs, one for “Events” and a second for “Macros”.
The following table summarizes the difference between "events" and "macros" and provides examples of each instance of source to destination:
Differences Between Events and Macros
Source Inside of Graphics (Destination) Outside of Graphics (Destination)
Inside of Graphics "Event"
Example: Button changes button text
"Event"
Example: Button changes MEB2 LED color
Outside of Graphics "Macro"
Example: Mounting SD card changes screen
Not supported by Event Manager Tool
“Events” under the first tab are generated from within graphics widgets and can manipulate the properties of screen widgets or set semaphores
that engage with the rest of the application. “Macros” are executed outside of graphics widgets by other parts of the application. “Macros” allow the
application to change widget properties or behavior.
Both “Events” and “Macros” event handlers can be built using collections of “Template” actions or using “Custom” developer-provided code. Most
widget properties have an associated Template action that can be used to manipulate that property in an event handler (either “Event” or “Macro”).
For more information on properties and related actions, see the discussion on the Properties Window below.
To explore these capabilities, let’s look at the Aria Quickstart project after the completion of the Adding an Event to the Aria Quickstart
Demonstration Quick Start Guide.
Graphics Composer Events
The Graphics Composer Screen Designer shows that there is one layer and three widgets in this demonstration.
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 67
Of the three widgets shown above, only ButtonWidget1 can have events associated with it, one for button pressed and a second for button
released. This can be seen in the Graphics Composer Event Manager window, which is available from the Tools menu:
The events shown under “ButtonWidget1” are mirrored in the widget’s properties. Selecting or clearing an event in one window does the same in
the other window, thus enabling (selecting) or disabling (clearing) the corresponding event.
We can add a Check Box widget to the applications display and then use the Event Manager to assign actions to the widget’s events. A Check
Box widget has two events, one for being “Checked” (i.e., selected) and another for being “Unchecked” (i.e., cleared). Enabling the “Checked”
event then allows the selection of the action or actions for that event.
The Actions: sub-window has five tool icons for managing the actions associated with an event:
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 68
Clicking the Create New Action icon ( ) opens the Action Edit dialog.
If you select Custom and click Next, you will see the following dialog. Unfortunately, there is no C code error checking with this window. It just
copies the code into libaria.c and libaria.h. If there is a problem with the code you will not know about it until you try to build your
application. An alternative is just to type a comment such as /*My event goes here*/, generate the code, and then find out where this
comment landed in the code. (Typically, inside libaria_events.c, or libaria_macros.c) You can then write the action routine from within
the MPLAB X IDE editor and compile just that file to debug the code written.
If you select Template, the Action Edit dialog will update, as follows. Select ButtonWidget1.
As shown previously, you next need to select the widget that you want to manipulate with this action. Note that the event originated with
CheckBoxWidget1, but the event’s action can manipulate any of the existing widgets. In this case, ButtonWidget1 has been selected. Clicking Next
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 69
will then bring up a list of the actions available in manipulating a button widget.
You can select the “Set Text” action, which will then change the button’s text property, followed by NEXT, which will open a dialog to select the text
string for this action.
You can then select from the available (already defined) strings which text to use for the button’s text field. Press the Finish button to complete the
definition of this action.
Screen Events
As shown previously, the Graphics Composer Event Manager, Events sub-tab supports screen events when the screen is visible (On Show) and
hidden (On Hide). These events can define event handlers based on Template actions or Custom, user-defined code.
Widget Events
Not all widgets can generate an event. For example, a Label Widget has nothing to generate, it just sits there on the screen, labeling. Here is a list
of the widgets that can generate an event:
• Button – Pressed and Released events
• Check Box – Checked and Unchecked events
• Draw Surface – Draw Notification event
• Image Sequence – Image Changed event
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 70
• Key Pad – Key Click event
• List Wheel – Select Item Changed event
• List – Selection Changed event
• Progress Bar – Value Changed event
• Radio Button – Selected and Deselected event
• Scroll Bar – Value Changed event
• Slider Widget – Value Changed event
• Text Field – Text Changed event
• Touch Test – Point Added event
Graphics Composer Macros
Macros implement event handlers for events that originate outside of graphics primitives such as widgets and are designed to change or
manipulate widgets inside of the graphics part of an application. (Events that originate outside of graphics and don’t touch the graphics part of the
application are outside of the scope of the Graphics Event Manager and are not discussed here.)
The following figure shows a simple example of a macro.
The toolbar for Macros has three icons.
Creating a new macro and selecting its actions is just like that of a widget event:
1. Create a new macro using the “Create New Macro” tool. The check box to the left of the new macro’s name enables/disables the macro.
Clearing it removes the macro from the next code generation.
2. Select the new macro and edit it using the second icon (shown previously).
3. In the Actions: window, select Create New Action. An optional name can be provided in the Name: box. You can then choose to use a
Template and select a predefined action or Custom to create a customized action.
4. If you chose a “Custom” action, proceed as discussed previous in Graphics Composer Events. When using templates the next step is to
choose the target widget for the action. This choice is limited to those only the widgets in the currently “active” screen. If your application has
multiple screens and the widget you are targeting is not part of the currently active screen you need to change the active screen.
• Changing the active screen can be done by selecting the corresponding screen tab at the bottom of the Graphics Composer Screen
Designer
• Alternately, you can switch using the Graphics Composer Manager:Screens tab
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 71
5. After selecting the target widget for this macro, click Next button to select an action related to this widget. (Just as with template-based widget
events.) The macro can contain more than one action, targeting more than one widget.
Graphics Events Test Bed
Additional examples of events and macros can be found in the MPLAB Harmony project found in ./apps/examples/events_testbed. This project is
based on the Quick Start Guide “Adding an Event to the Aria Quickstart Demonstration” found in Volume 1 of MPLAB Harmony’s built-in
documentation.
This project has target configurations for PIC32MZ DA and EF starter kits with the MEB2 graphics board. It demonstrates the following
events/macros:
Event Testbed
Source Inside of Graphics (Destination) Outside of Graphics (Destination)
Inside of
Graphics
"Event"
Button changes button text from "Make Changes. Generate. Run" to
"Ouch! Ouch! Ouch!"
"Event"
Virtual Switch S1 changes MED2 LEDs D6 and D7 on/off
via boolean semaphore
Outside of
Graphics
"Macro"
APP_Tasks changes color scheme for Virtual LEDs D6 and D7
between LED_OFF and LED_ON
Not supported by Event Manager Tool
MEB2 S1 changes MEB2 LEDs D6 and D7
Asserting the “Make Changes. Generate. Run” button on the display changes its text to “Ouch! Ouch! Ouch!”. Pressing the MEB2’s Switch S1
changes the LED D6 and D7 on the MEB2 board as well as changing the virtual LEDs D6 and D7 on the display. Pressing the display’s virtual S1
switch does the same.
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 72
The application’s events are defined in libaria_events.c:
#include "gfx/libaria/libaria_events.h"
// CUSTOM CODE - DO NOT DELETE
extern bool bDisplay_S1State;
// END OF CUSTOM CODE
// ButtonWidget1 - PressedEvent
void ButtonWidget1_PressedEvent(laButtonWidget* btn)
{
// ButtonDown - Set Text - ButtonWidget1
laButtonWidget_SetText((laButtonWidget*)ButtonWidget1,
laString_CreateFromID(string_OuchOuchOuch));
}
// ButtonWidget1 - ReleasedEvent
void ButtonWidget1_ReleasedEvent(laButtonWidget* btn)
{
// ButtonUp - Set Text - ButtonWidget1
laButtonWidget_SetText((laButtonWidget*)ButtonWidget1,
laString_CreateFromID(string_Instructions));
}
// Display_S1 - PressedEvent
void Display_S1_PressedEvent(laButtonWidget* btn)
{
// CUSTOM CODE - DO NOT DELETE
bDisplay_S1State = true;
// END OF CUSTOM CODE
}
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 73
// Display_S1 - ReleasedEvent
void Display_S1_ReleasedEvent(laButtonWidget* btn)
{
// CUSTOM CODE - DO NOT DELETE
bDisplay_S1State = false;
// END OF CUSTOM CODE
}
The ButtonWidget1 changes the text using the laButtonWidget_SetText function. Details on how this is accomplished are discussed in the
Quick Start Guide “Adding an Event to the Aria Quickstart Demonstration”.
The Display_S1 widget just sets a Boolean semaphore bDisplay_S1State. Creating the events for the Display_S1 virtual switch is easy, just
enable the widget’s events in the widget’s properties:
This will create empty event handlers in libaria_events.c, which can then be modified to change the boolean semaphore
bDisplay_S1State as shown above.
The application’s macros are defined in libaria_macros.c change the coloring scheme for the display’s virtual LEDs:
#include "gfx/libaria/libaria_macros.h"
void LEDsTurnOn(void)
{
if(laContext_GetActiveScreenIndex() != default_ID)
return;
// TurnOnDisplayD6 - Set Scheme - MEB2_LED_D6
laWidget_SetScheme((laWidget*)MEB2_LED_D6, &LED_ON);
// TurnOnDisplayD7 - Set Scheme - MEB2_LED_D7
laWidget_SetScheme((laWidget*)MEB2_LED_D7, &LED_ON);
}
void LEDsTurnOff(void)
{
if(laContext_GetActiveScreenIndex() != default_ID)
return;
// TurnOffDisplayD6 - Set Scheme - MEB2_LED_D6
laWidget_SetScheme((laWidget*)MEB2_LED_D6, &LED_OFF);
// TurnOffDisplayD7 - Set Scheme - MEB2_LED_D7
laWidget_SetScheme((laWidget*)MEB2_LED_D7, &LED_OFF);
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 74
}
The difference between the color scheme LED_OFF and LED_ON is only in the base color:
The macros LEDsTurnOn and LEDsTurnOff are called from the application’s main task loop, APP_Tasks. The work of controlling the LEDs is
done in the APP_STATE_SERVICE_TASKS case.:
#include "gfx/libaria/libaria_macros.h"
bool bMEB2_S1State = false;
bool bDisplay_S1State = false;
bool bLED_State = false;
bool bLED_StateNow;
void APP_Tasks ( void )
{
/* Check the application's current state. */
switch ( appData.state )
{
/* Application's initial state. */
case APP_STATE_INIT:
{
bool appInitialized = true;
if (appInitialized)
{
appData.state = APP_STATE_SERVICE_TASKS;
}
break;
}
case APP_STATE_SERVICE_TASKS:
{
bMEB2_S1State = !BSP_SWITCH_S1StateGet(); // Closed --> grounded
bLED_StateNow = bMEB2_S1State || bDisplay_S1State;
if ( bLED_State != bLED_StateNow )
{// LED state has changed
if ( bLED_StateNow )
{
BSP_LED_D6On(); // MEB2 LED D6 On
BSP_LED_D7On(); // MEB2 LED D7 On
LEDsTurnOn(); // Turn display LEDs on
}
else
{
BSP_LED_D6Off(); // MEB2 LED D6 Off
BSP_LED_D7Off(); // MEB2 LED D7 Off
LEDsTurnOff(); // Turn display LEDs off
}//end if ( bMEB2_S1State || bDisplay_S1State )
bLED_State = bLED_StateNow; // Remember new state
}
break;
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 75
}
/* TODO: implement your application state machine.*/
/* The default state should never be executed. */
default:
{
/* TODO: Handle error in application's state machine. */
break;
}
}
}
Heap Estimator
Provides information on heap space allocation.
Description
Many parts of a graphics design are implemented using memory allocated from the application’s heap space. Therefore, it is important to allocate
sufficient memory for the heap. This tool can estimate heap usage by the allocation based on the widgets, layers, screens, and decoders currently
in the design.
When launching the tool from the Tools menu, the Heap Configuration window appears.
Clicking Calculate estimates heap usage. The following figure shows what occurs within the Aria Quickstart demonstration if the heap space is
only 4096 bytes:
The Summary tab shows how the estimated heap requirements was derived by summing up all the sizes shown under the “Size (Bytes)” column.
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 76
Note that the largest contribution comes from the screen requiring the largest heap allocation (in this case MainMenu).
If there is insufficient memory allocated to the heap, an exclamation point ( ! ) appears in the window. If you hold your mouse pointer over this icon,
the following message appears:
You can click Set MHC Heap Value to reset the heap allocation to match the estimated requirements. Selecting Add to MHC Heap Value adds
the estimated heap requirements to the current heap value. (In the case above, this would change the heap allocation to 4096+10664 bytes.)
Alternately, you can set the heap allocation to a larger value by going to the MPLAB Harmony Configurator window, selecting the Options tab and
setting the Heap Size within Device & Project Configuration > Project Configuration.
The Screen Details tab (from the Aria Showcase demonstration) shows screen-by-screen the heap space needed for each layer and widget on the
screen selected.
Note:
After you have updated the Heap Size, either using the Heap Estimator tool or by directly editing the value as shown above, you
must regenerate the project using the Generate Code button. This will update the actual heap size value used in building the
application.
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 77
Clicking the “Name” column will alphabetize the list. Clicking the “Size (Bytes)” column sorts the assets by size, with the largest at the top and
smallest at the bottom.
This sub-tab can help in managing the application’s utilization of heap space. For example, excess use of cached backgrounds for widgets can
become ruinously expensive, expanding the application’s need for heap well beyond the capabilities of the device. As an example, consider a
screen label from the Aria Showcase demonstration.
The Heap Estimator tool shows that if caching is enabled for the label’s background, this widget requires 23699 bytes of heap to store the widget.
Note that the label is twice the size of the text it contains, so one way of reducing the cost of the widget is to make it smaller, thereby reducing the
number of background pixels that must be stored. If the label is resized, the heap allocation is reduced to 11688 bytes, which is a drop of
appoximately 50%. Finally, if the background is changed from “Cache” to “Fill” the widget only needs 188 bytes.
The lesson learned is to use Cache as a background only for widgets where it is absolutely necessary and to make the “cached” widgets as small
as possible.
Global Palette
Provides information on the Global Palette features.
Description
The Global Palette window is launched from the Graphics Composer’s Asset pull-down menu.
Using a Global Palette enables frame buffer compression for the LCC graphics controller. It creates a 256 color look up table (LUT) and then
changes the entire user interface design to adhere to that LUT. Frame buffers are stored as 8 bits/pixel (bpp) indices rather than 16-32 bpp colors.
The display driver performs a LUT operation to change each LUT index into a color before writing to the display/controller memory. This enables
the use of double buffering, without using external memory, on devices that could not support it before. It also supports single buffering on larger
displays. Of course, running the LUT requires more processing on the host. Currently only the LCC graphics controller supports this feature. The
Aria demonstration Aria Basic Motion is an example of how using a Global Palette greatly improves the efficiency and capabilities of a design.
Enable the Global Palette by clicking on the Enable Global Palette check box in the window or using the File > Settings menu. the Global palette
can always be disabled. MHGC will then restore the project back to its original configuration.
If the global palette is enabled you will have to change the MHC configuration of the Graphics Controller to match. For the LCC controller, enable
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 78
"Palette Mode". For the GLCD controller, change the Driver Settings > Fame Buffer Color Mode to "LUT8".
The results of enabling the Global Palette:
• 8bpp frame buffers. In the case of the most common demonstrations this means a 50% reduction in the size of the frame buffer.
• This also opens up the capability to support a single frame buffer for some larger displays.
What is lost by enabling the Global Palette:
• First and foremost - No Dynamic Colors. Dynamic colors are unlikely to match up with an entry in the global palette’s look-up table.
• No alpha blending capability. The level of alpha blending can be changed during run-time. (See No Dynamic Colors.)
• No JPEGs or PNGs. Again, no dynamic colors. All images in MGHC will be changed to the color mode of the project, and generated as Raw.
• No font anti-aliasing. Again, no dynamic colors. While the 8-bits/pixel for each glyph is known, the color of the text depends on the color
scheme used, and color schemes can change at run time.
• Additional overhead when performing LUT (index->color) operations in the display driver.
The following figure shows the default “Global Palette” when Project Color Mode is set to RGB_888.
This default palette is good for designs that use a wide array of colors. MHGC also supports developing a custom palette by importing an image
defining the palette or by analyzing the pixel colors already in use by the application’s images. The palette’s color mode is determined by the
Project Color Mode, which is determined by the graphics controller.
Clicking on an entry in the palette with bring up the Color Picker dialog window, allowing you to edit the entry’s color.
Window Toolbar
There are four icons on the toolbar:
1. Import From Image File - Importing a global palette from an image file. Selecting this brings up the following warning. Images can be imported
as a BMP,.GIF, JPEG, and PNG (but not TIFF).
2. Auto-Calculate Palette – Calculates a new palette using the current design. Selecting this brings up the following warning.
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 79
• Selecting Yes opens a status window that shows the progress made in selecting a palette of 256 colors
• This can be lengthy operation, but it will effectively generate a palette better tailored to the design. However, extreme (or rare) colors will be
changed to nearby, more-plentiful colors, thereby eliminating some of the contrast in images. Whites will tend to darken and blacks lighten. This
can be remedied by editing the calculated palette to whiten the whites, darken the blacks, and make other colors closer to the original. This of
course may increase the posterization of the image, but that is a natural trade-off in using only 256 colors.
3. Reset to Default – This returns the Global Palette to its default values, which opens the Reset Global Palette dialog.
4. Enable Global Palette – This performs the same function as File > Settings: Using a Global Palette. Selecting this opens the Enable Global
Palette Mode warning.
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 80
Widget Colors
Provides information on widget coloring.
Description
Widget Colors
Widget coloring can be customized by creating additional color schemes and assigning these customized schemes to a subset of the widgets
uses. For example, a ButtonColorScheme could be customized and used only for Button Widgets.
To help highlight the different colors available for each widget, a “CrazyScheme”, with extreme contrast among the 16 available colors, was used
as the color scheme for each widget:
Use this color scheme to help identify the relevant colors for the widgets listed below.
The left column shows the coloring assignments for a Bezel boarder. The right side shows Line/No Border color assignments.
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 81
Widget With Bezel Border Widget With Line or No Borders
Arc Widget:
Bar Graph:
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 82
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 83
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 84
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 85
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 86
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 87
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Graphics Composer Window User Interface
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 88
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Code Generation
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 89
Code Generation
This topic describes using the graphics composer to generate code.
Description
MPLAB Harmony Graphics Composer data is generated the same way as the rest of the project within MHC through the Generate button.
libaria_harmony.h/c – These files provide the interface that binds libaria to the overall MPLAB Harmony framework. They contain the
implementations for the standard state management, variable storage, and initialization and tasks functions. If the touch functionality is enabled
then the touch bindings are also generated in libaria_harmony.c.
libaria_init.h/c - These files contain the main initialization functions for the library state and screens. The header file contains all predefined
information for the library state including screen IDs, schemes, and widget pointers. The main initialization function initializes all schemes and
screens, creates all screen objects, and sets the initial state of the library context. As each screen must be capable of being created at any time,
each screen has a unique create function that can be called at any time by the library. The libaria_init.c file contains these create functions.
libaria_events.h/c – The event files contain the definitions and implementations of all enabled MHGC events. Each event implementation will
contain all generated actions for that event.
libaria_macros.h/c – The macro files contain the definitions and implementations of all defined MHGC screen macros. A macro is similar to an
event in that it can contain actions. However, it is meant to be called from an external source such as the main application.
libaria_config.h – This file contains configuration values for the library. These are controlled through settings defined in the MHC settings tree.
gfx_display_def.c – This file contains generated definitions for enabled graphics displays.
gfx_driver_def.c – This file contains generated definitions for enabled graphics drivers.
gfx_processor_def.c – This file contains generated definitions for enabled graphics processors.
gfx_assets.h/c – These files contain generated asset data.
Advanced Topics
This section provides advanced information topics for MHGC.
Adding Third-Party Graphics Products Using the Hardware Abstsraction Layer (HAL)
This topic provides information on using the Hardware Abstraction Layer (HAL) to add third-party graphics products.
Description
The architecture of the MPLAB Harmony Graphics Stack is shown in the following diagram.
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Advanced Topics
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 90
Hardware Abstraction Layer (HAL)
The HAL is a software layer that serves as a gatekeeper for all graphics controller and accelerator drivers. This layer is configured at initialization
by the underlying graphics drivers and provides functionality such as buffer management, primitive shape drawing, hardware abstraction, and draw
state management. This layer serves as a means of protection for the drivers, frame buffers, and draw state in order to prevent state
mismanagement by the application.
Third-Party Graphics Library
The third-party graphics library can be used with the MPLAB Harmony framework to perform the graphics operations desired by the application.
The third-party library has access to the HAL, which has been configured to service the frame buffer which is filled by the third-party graphics
library.
The third-party graphics library can access the MPLAB Harmony framework drivers such as touch drivers, graphics controller driver, and display
driver through the HAL. The draw pipeline and the user interface (UI) design files come from the third-party graphics library. The third-party
graphics library needs the frame buffer location to fill the frame buffer with the pixel values. Or, in case of external controllers, it would need a
function to access the controller drivers to output pixels on the display. The HAL provides the third-party graphics library with the frame buffer
location or the API to communicate the pixel values to the external controllers.
The following figure from the MPLAB Harmony Configurator (MHC), shows the selections made in the Graphics Stack to enable the needed
graphics display and controller features. Note that the Draw Pipeline for the MPLAB Harmony Graphics Stack has been disabled to assure that the
third-party graphics alone is taking effect. The MPLAB Harmony Graphics Configurator (MHGC) is also not enabled, as the design tools from the
third-party graphics library are used to generate the UI graphics. The LCDConf.c file has appropriate APIs for the third-party graphics library to
communicate through the HAL with the display drivers and the framebuffer.
Example Demonstration Project
The Aria demonstration project, emwin_quickstart, has three configurations. Each configuration has an API named LCD_X_Config, which is
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Advanced Topics
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 91
generated with the relevant calls for SEGGER emWin to communicate with the display driver and obtain the frame buffer location pointer to write
the pixel data to it. For PIC32MZ DA and PIC32MZ EF configurations, the frame buffer pointer address is provided to SEGGER emWin by the
HAL. For the S1D controller on PIC32MX devices (pic32mx_usb_sk2_s1d_pictail_wqvga), The pixel write function pointers are assigned to the
appropriate S1D driver APIs, which allow SEGGER emWin to write to the display controller.
Speed and Performance of Different Image Decode Formats in MHGC
Provides information and recommendations for image decode formats.
Description
MHGC supports various image formats and the MHGC Image Assets Manager provides the ability to convert and store a source image into to the
following formats
• Bitmap RAW
• Bitmap Raw Run-Length Encoded (RLE)
• JPEG
• PNG
• Predecoded RAW Bitmap in DDR (PIC32MZ DA)
The following table shows the relative rendering time and Flash memory requirements of the different image formats in the MPLAB Harmony
Graphics Library. The rendering time includes decoding the image and drawing it to the screen. This information is helpful when optimizing a
MPLAB Harmony graphics project for performance and/or Flash memory space. For example, as shown by the red highlighted text in the table, a
40x40 pixel 16-bit RAW image renders 2.38 times faster and uses 2.59 times more Flash space than a JPEG image.
Predecoded Images in DDR (RAW)
For PIC32MZ DA devices with DDR, the MHGC Image Asset Manager provides an option to predecode images from Flash and store them into
DDR as RAW images. The GPU is used to render the decoded image from DDR to the frame buffer. This provides a faster render time than an
equivalent RAW image in Flash memory, specifically for large images (up to 10 times faster for a 200x200 image). Conversely, predecoding small
images 40x40 pixels or smaller in DDR may not render faster due to the additional overhead of setting up the GPU.
Recommendations:
• If there is adequate DDR memory available, consider predecoding images to DDR for best performance
• Using JPEG images and predecoding them into DDR can provide the best rendering performance and most Flash memory savings.
Note:
The images are decoded from Flash to DDR memory by the Graphics Library during initialization and may introduce delay at
boot-up, depending on the number and size of the images.
RAW Images
RAW images provide fast rendering time, as there is no decoding needed. However, depending on image content, it can be two times larger than a
Run-Length Encoded (RLE) image and about 3 to 10 times larger than a JPEG.
Recommendation:
For small images that are to be rendered frequently, consider using a RAW image for better performance
JPEG Images
JPEG images provide the most Flash space savings, but are slower to render compared to RAW and RAW RLE.
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Advanced Topics
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 92
Recommendations:
• If images are large and not used frequently, consider using the JPEG image format to save flash memory space
• If DDR memory is available, consider predecoding JPEG images in DDR for better rendering performance
Run-Length Encoded RAW Images
In terms of rendering speed and size, RAW RLE images are in between RAW and other compressed formats like JPEG or PNG. Depending on the
image contents, RAW RLE can be approximately 1.5 times faster than JPEG, but could be significantly larger in size for large images. Again,
depending on the image content, RAW RLE can be about half the size and performance of a RAW image.
Recommendation:
If optimizing your application for both speed and flash size consider using RAW RLE images
PNG Images
Among the image formats, PNG is slowest to render and requires more memory to decode.
Recommendations:
• Unless fine levels of alpha-blending are needed, it is better to use other image formats to achieve the best performance. Use the MHGC Asset
Manager to convert the source PNG image and store it in a different image format.
• If you would like to use an image with a transparent background, it may be better to use a RAW RLE image with background color masking to
achieve the same effect with better performance than a PNG. Color masking is supported in the MHGC Image Asset Manager.
Draw Pipeline Options
This section details how to use the Graphics Pipeline.
Description
The nominal rendering pipeline for an image is shown in the following figure.
The order of rendering for other widgets may differ. For example, for a colored rectangle the color mask is first checked. If the rectangle’s fill
matches the mask color defined then there is nothing to draw.
Graphics Pipeline
Provides information on the graphics pipeline.
Description
Layer Clipping
In order of the processing, Layer Clipping is first applied to the image. If the image extends beyond the edges of the layer that contains it then
those pixels are not drawn. Failure to clip out-of-bound pixels can cause the application to crash. The following figures shows an example of layer
clipping:
Before applying layer boundaries:
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Advanced Topics
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 93
After applying layer boundaries:
Rectangle Clipping
Next, the image is clipped to the boundaries of any widgets that contain it as a parent, such as a rectangle.
Before applying the clipping rectangle.:
After applying the clipping rectangle:
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Advanced Topics
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 94
Color Masking of Pixels
Pixels in the image are matched to a mask color. If the colors match the pixel is discarded (not drawn). In the following example, the black border
of the image is removed by defining the mask color to be black.
Before applying color mask:
After applying color mask:
Orientation and Mirroring
The logical orientation of the graphics design may not match the physical layout of the display. Pixels may need to be reoriented from logical to
physical space before being rendered.
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Advanced Topics
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 95
Pixels may also need to be flipped (mirrored) before being rendered.
Alpha Blending
Each pixel drawn is a composite of the image color and the background color based on the alpha blend value defined by a global alpha value, the
pixels alpha value, or both.
Before alpha blending:
After alpha blending:
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Advanced Topics
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 96
Color Conversion
The image color format may not be the same as the destination frame buffer. Each pixel must be converted before it is written. In the following
example, the image is stored using 24 bits per pixel; however, the frame buffer uses 16 bits per pixel.
Frame Buffer Write
The final stage in rendering an image is to write each-color converted pixel to the frame buffer.
Graphics Pipeline Options
Provides information graphics pipeline options.
Description
Each stage in the graphics pipeline adds overhead to the rendering. Stages can be removed from processing using MPLAB Harmony Configurator
(MHC) options for the Draw Pipeline, found by selecting MPLAB Harmony Framework Configuration > Graphics Stack.
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Advanced Topics
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 97
For example, the Alpha Blending stage can be disabled if your graphics application does not use alpha blending. If the color mode of the display
matches the color mode of all images you can disable Color Conversion. Disabling unneeded stages can improve performance and reduce code
size.
Also, a graphics controller driver may add additional stages, or opt to bypass stages completely depending on the capabilities of the graphics
hardware supported by the driver.
Improved Touch Performance with Phantom Buttons
This topic provides information on the use of phantom buttons to improve touch performance.
aria_coffeemaker Demonstration Example
Provides image examples with buttons in the aria_coffeemaker demonstration.
Description
Small buttons are hard to activate on the screen. The use of phantom (invisible) buttons can improve touch performance without increasing the
size of the visible footprint of the button on the display.
The aria_coffee_maker has a sliding tray on each side of the display. Sliding a tray in, or out, is accomplished by a phantom (invisible) button.
Looking at the left tray, we see the three parts of this phantom button.
1. LeftTrayLid: An invisible button widget, whose outline is shown in blue. This area is the touch field.
2. ImageWidget5: An image widget containing a hand icon, providing a visual clue as to how to manipulate the tray.
3. The Release Image and Pressed Image: These are defined as part of the button widget properties. The Pressed Image has a darker coloring
than the Released Image. This difference is what shows the user that the button has been pressed.
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Advanced Topics
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 98
The drawing hierarchy for this part of the design is shows that ImageWidget5 is a daughter widget to the LeftTrayLid button widget.
Examining the properties of the LeftTrayLid button widget reveals more about how this works. The following figure demonstrates these three
properties.
1. The Border is defined as None.
2. Background Type is defined as None.
3. The different images used will show when the button is Pressed or Released.
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Advanced Topics
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 99
By setting the border and background to None, the button is invisible. Only by providing different images for Released versus Pressed does the
user know when the button has been pressed.
The actual touch region defined by the button is much larger than the images shown on the display. This extra area increases the touch response
of the display.
Small Buttons Controlled by Phantom Buttons
Provides information on phantom button control of small buttons.
Description
When the border is not set to None, and the background is not set to None, the button widget provides a direct visible clue to the user when it is
pressed. Which can be seen in the following figure with the button from aria_quickstart. In aria_quickstart, ButtonWidget1 has a bevel border, and
a fill background.
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Advanced Topics
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 100
Let’s use aria_quickstart to demonstrate how to control ButtonWidget1 using a phantom button to surround it, thereby increasing touch
responsiveness.
When using a bevel border and filled background, the button provides visible feedback when it is asserted.
To use this feedback mechanism instead of images, there is a way to have a small button on the display, with a larger touch zone provided by
another phantom button.
Steps:
1. Click on ButtonWidget1 in the Screen Designer panel. Go to the Properties Editor panel for the widget and uncheck the Enabled property to
disable the button. Enable Toggleable so that this button will have a memory.
2. Drag a new button from the Widget Tool Box panel and center it around ButtonWidget1. In the Properties Editor panel for this new button,
change the name of the widget to PhantomButton. Change the Background Type to None. Leave the Border set as Bevel for now. The
following figure displays the new button in the Screen Designer panel:
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Advanced Topics
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 101
The Properties Editor panel should display the following information.
3. In the Tree View panel, drag ButtonWidget1 to be a daughter widget of PhantomWidget. When PhantomWidget is moved, ButtonWidget1 will
move along with the parent.
4. Click on PhantomButton again in the Screen Designer panel and move to the Properties Editor. Enable both the Pressed and Released events.
Then click on the (…) icon to define the events. (See the following two steps.)
5. Defining the Pressed Event.
Click on the (…) icon. In the Event Editor, under Pressed dialog, click the New icon to define a new event. In the Action Edit Dialog that next
appears, leave the selection on the template and hit the Next button. In the next window, select the target of the event. We want to change the
state of ButtonWidget1, so select it and hit Next. The next dialog shows all the template actions that we can use to modify ButtonWidget1. Choose
Set Pressed State and hit Next. Set the Argument to Enable Pressed. Name this event Set Press state for ButtonWidget1 then hit Finish. Leave
the Event Editor by hitting Ok.
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Advanced Topics
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 102
6. Defining the Released Event.
Click on the (…) icon. In the Event Editor, under Released dialog, click the New icon to define a new event. In the Action Edit Dialog that next
appears, leave the selection on the template and hit the Next button. In the next window, select the target of the event. We want to change the
state of ButtonWidget1, so select it and hit Next. Choose Set Pressed State and hit Next. Leave the Argument disabled. Name this event Unset
Press state for ButtonWidget1 then hit Finish. Leave the Event Editor by hitting Ok.
7. Generate the application from the MPLAB Harmony Configurator main menu.
8. From the MPLAB main menu, build and run the project. To verify that ButtonWidget1 does change, click outside of the original boundaries.
9. As a final step, hide the PhantomButton by changing its border to None. Next, Generate the code again from MHC. Finally, build and run the
project from MPLAB and see how much easier it is to assert ButtonWidget1 using a phantom button.
GPU Hardware Accelerated Features
This section details how to configure the GPU hardware accelerated features.
Description
On the PIC32MZ DA devices, the on-board 2D Graphics Processing Unit (GPU) peripheral allows certain features to be accelerated. These
features are:
• Line draw
• Single-color rectangle fill
• Image Blit
Once configured, these features are supported by the Hardware Abstraction Layer (HAL) and can be enabled or disabled at run-time. When
disabled, the HAL falls back to the software-based algorithms, and relies on the CPU to perform the features.
Configuring for GPU Hardware Acceleration
The Nano2D library, is the driver library that permits hardware acceleration via the GPU. To make sure the Nano2D library is configured as part of
your application, make sure to enable this in the MPLAB Harmony Configurator (MHC) under Graphics Stack > Use Graphics Stack > Graphics
Processor > Select Processor Type > NANO 2D.
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Advanced Topics
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 103
Enabling/Disabling GPU Hardware Acceleration at Runtime
Once configured, the hardware acceleration via the GPU is enabled by default at launch. The hardware acceleration can subsequently be turned
on or off at runtime by calling the following lines of code:
Enable acceleration:
GFX_Set(GFXF_DRAW_PIPELINE_MODE, GFX_PIPELINE_GCUGPU);
Disable acceleration:
GFX_Set(GFXF_DRAW_PIPELINE_MODE, GFX_PIPELINE_GCU);
This change takes effect immediately for subsequent draw instructions into HAL.
Line Draw and Rectangle Fill Hardware Acceleration
When the GPU hardware acceleration is enabled, line draw and rectangle fill features are automatically supported. This is supported by HAL
function calls GFX_DrawLine and GFX_RectFill. The actual routing of the call between the hardware accelerated support versus the
software-based algorithmic support is abstracted from the caller.
The following table displays performance improvement by comparing the frame update rate of rectangular fills of varying sizes with, and without
hardware acceleration. The table shows that the higher the frame update rate, the better the performance. The measurement is performed using
the entire Harmony Graphics Stack but with most Aria draw pipeline features disabled, so that the focus is on HAL performance.
Rect Fill Size No Acceleration Frame Update
Frequency (Hz)
Hardware accelerated Frame Update
Frequency (Hz)
Performance Improvement
60x60 101 160 58.4%
100x100 37 158 327.0%
140x140 19 157 726.3%
180x180 11 156 1318.2%
220x220 8 155 1837.5%
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Advanced Topics
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 104
Note:
The HAL uses a software algorithm for rectangle fill sizes below 50x50, as the CPU is able to perform the operation faster than the
GPU below that size.
Image Blit Hardware Acceleration
The only way Image Blits significantly leverage hardware acceleration is via the block transfer of image data that has been preprocessed into
DDR/Internal SRAM memory into frame buffer memory.
Note:
The GPU is able to interpret and transfer pixel data in RGB565 or RGBA8888 format only.
The following table displays performance improvement by comparing the frame update rate of the image blit of the same 100x100 image in varying
formats with, and without GPU acceleration. The table shows that the higher the frame update rate, the better the performance. There is a marked
performance increase when using the preprocessing method (despite the amount of image data is doubled in RGBA8888 versus RGB565).
Image Format (100x100) No Acceleration Frame
Update Frequency (Hz)
GPU Frame Update
Frequency (Hz)
Performance
Improvement
RGB565 raw pixels 37 60 62.1%
RGB565 with RLE compression 26 34 30.8%
JPEG (24-bit) 17 22 29.4%
PNG (32-bit) 13 15 15.4%
Preprocessed RGBA8888 raw pixels 29 161 455.2%
The GPU works best with image sizes in powers of two (such as 128x128 instead of 125x105). Images with sizes that are not a power of two may
be rendered with artifacts. This is often a case-by-case situation and the way to remedy this is to pad the memory footprint up to the nearest power
of two.
Prior to application use, images stored in flash storage will need to be preprocessed, converting them from the original format into a raw bitmap.
There are two methods to achieve this:
1. Calling from application code: The API GFXU_Preprocess Image can be used to preprocess an image asset to a target memory location (DDR
or internal SRAM) while specifying the destination color mode (RGB565 or RGBA8888). The application developer will need to manage the
target memory and be careful not to stomp on other critical memory structures such as the frame buffer, or the GPU’s command buffer. Power
of two padding can be enabled via the API.
2. The application developer can also use the Image Assets options within the MPLAB Harmony Graphics Composer User's Guide (MHGC) to
specify that certain image assets should be preprocessed at application launch. This can be achieved by enabling image preprocessing as
shown under the Preprocessing sub-section of the Image Asset window as shown in the following figure:
For more information, see Image Assets and DDR Organizer under the Graphics Composer Asset Management section above.
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Advanced Topics
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 105
Image Preprocessing Memory Management
This sections describes preprocessing.
Description
Whether using internal SRAM only or DDR memory, care must be taken when allocating memory for preprocessing images. For more information,
see Image Assets and DDR Organizer under the Graphics Composer Asset Management section above.
Preprocessing using DDR
For PIC32MZ DA devices with access to DDR memory, the frame buffer and the command buffer for the GPU is also located on the DDR. It is
important for the application developer to select the appropriate memory location in DDR for image preprocessing without trampling on these other
memory structures.
The following table specifies the available addressing region to access the DDR memory.
Device Type Address Range Begin (KSEG1) Address Range End (KSEG1)
Internal DDR (maximum size 32 MB) 0xA8000000 0xA9FFFFFF
External DDR (maximum size 128 MB) 0xA8000000 0xAFFFFFFF
At configuration time, MHGC generates the frame buffer allocation in the application’s system configuration code.
This allocation is targeting a WVGA RGBA8888 3-overlay double-buffered configuration; therefore, six buffer allocations are specified. More DDR
memory can be freed up for image preprocessing using the following:
• WVGA Resolution is not required
• Enable all three overlays
• Double frame buffering
The application developer may choose to change the allocation manually in system_config.h.
The following table breaks down the allocation:
Frame Buffer Address Range Begin Address Range End
Layer0 Buffer 0 0xA8000000 0xA8176FFF
Layer0 Buffer 1 0xA8465000 0xA85DBFFF
Layer1 Buffer 0 0xA8177000 0xA82EDFFF
Layer1 Buffer 1 0xA85DC000 0xA8752FFF
Layer2 Buffer0 0xA82EE000 0xA8464FFF
Layer2 Buffer1 0xA8753000 0xA88CBFFF
For an example on using image preprocessing using DDR memory, please refer to the aria_coffee_maker application.
Internal SRAM Only
When operating with only the internal SRAM, the frame buffer can take up a significant portion of available memory. To avoid system stability
issues with dynamically allocating memory for the preprocessing, the application developer may want to predetermine the memory footprint
required for the image and assign the memory statically.
For an example of image preprocessing using internal SRAM, please refer to the aria_radial_menu application.
Creating a MPLAB Harmony Graphics Application Using a Third-Party Display
This demonstration provides a step-by-step example of how to create a MPLAB Harmony graphics application using a non-Microchip (third-party)
display.
Description
Introduction
Creating a new MPLAB Harmony graphics application using a Microchip board and a Microchip display is very simple: A new MPLAB Harmony
application is created and the Board Support Package (BSP) belonging to the hardware configuration is selected. If the project is using a
third-party display then there are more steps and this tutorial will provide an example of the process.
This tutorial shows how to connect a third-party display to the PIC32MZ Embedded Connectivity with Floating Point Unit (EF) Starter Kit board (EF
Starter Kit) using two Microchip Adapter boards and a custom ribbon cable. It shows how to setup the pinouts, configure graphics, and adapt an
existing MPLAB Harmony capacitive touch driver to support the display board’s capacitive touch controller.
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Advanced Topics
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 106
Prerequisites
Before beginning this tutorial, ensure that the MPLAB X IDE is installed along with the necessary language tools as described in Volume I: Getting
Started With MPLAB Harmony > Prerequisites. In addition, ensure that MPLAB Harmony is installed on the hard drive, and that the correct MPLAB
Harmony Configurator (MHC) plug-in is installed in the MPLAB X IDE.
A basic familiarity with application development under MPLAB X and MPLAB Harmony is required, including how to use MPLAB Harmony
Configurator (MHC). There are introductory videos on Microchip’s YouTube channel for those who have never used MPLAB Harmony. The first
video to watch is Getting Started with MPLAB Harmony. There is also a Creating Your First Project tutorial in Volume 1 of MPLAB Harmony’s
documentation.
For first time users of MPLAB Harmony Graphics there is a video series on YouTube. The first video is MM MPLAB® Harmony Edition - Ep. 7 -
MPLAB Harmony Graphics Composer Suite. In Volume 1 of MPLAB Harmony’s documentation there are Quick Start tutorials covering graphics,
located at Quick Start Guides > Graphics and Touch Quick Start Guides.
Tutorial Resources
The folder ./apps/examples in MPLAB Harmony has a project that can be copied and used as the base of this tutorial,
3rd_party_display_start, and a project that represents the completed project from this tutorial, 3rd_party_display.
This is what you will find in the ./apps/examples folder under Harmony 2.06:
3rd_party_display
3rd_party_display_start
creating_your_first_project
peripheral
events_testbed
system
If there are difficulties then compare the completed project with the current project.
Tutorial Hardware
Of all the PIC32MZ devices available today, the PIC32MZ EF family is the best candidate for this effort. The EF family does not have on-chip
graphics controller or Graphics Processing Unit (GPU), which makes it a less expensive and lower power solution for use with a display that has a
built-in controller.
Mikroelektronika (Mikroe) offers a prototype display that can be used using a ribbon cable between the display and the EF host. This third party
(non-Microchip) board serves as the basis for this tutorial. The ‘TFT PROTO 5" Capacitive’ display costs around 100USD and is available for order
online (https://www.mikroe.com/tft-proto-5-capacitive-board). It has an 800x480 pixel WVGA display, driven by an SSD1963 graphics controller.
The SSD1963 graphics controller is already supported in MPLAB Harmony. It has a Focal Tech FT5x06 capacitive touch controller. This tutorial
will cover how to design the pin-out between the EF host and display board, as well as how to adapt an existing MPLAB Harmony capacitive touch
driver (MTCH6303) to support the Focal Tech touch controller.
For this tutorial the following hardware will be used:
1. PIC32MZ Embedded Connectivity with Floating Point Unit (EF) Starter Kit board (Part # DM320007).
2. Starter Kit I/O Expansion Board (Part # DM320002) – this provides the 0.1” headers we need to connect up the display using a ribbon cable or
0.1" jumpers.
3. PIC32MZ Starter Kit Adaptor Board (Part # AC320006) – this provides an 168 to 132 pin adapter to adapt the 168-pin connector on the EF
starter kit with the 132 pin connector on the I/O Expansion Board.
4. Mikroelektronika TFT PROTO 5" Capacitive display.
5. 40 to 50 pin ribbon cable to connect the I/O Expansion Board to the display, or a set of colored 0.1" jumpers.
Here is how the hardware is assembled:
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Advanced Topics
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 107
The connectors that route signals from the EF pins to the display’s ribbon cable are:
The EF Starter Kit + 168-132 Pin Adapter + I/0 Expansion board can host any number of prototype hardware configurations. A spreadsheet has
been developed that maps every pin of the EF device to a pin on the I/O Expansion board, with one final spreadsheet tab that provides the pin
outs for the ribbon cable that connects the display to the I/O Expansion Board. (The spreadsheet is found in the Zip file
.\apps\examples\3rd_party_display\pinouts.zip.) The picture above shows the board connectors used in getting from a pin on the EF
device to a pin on the display’s ribbon connector.
This spreadsheet has the following tabs:
1. Sorted by Skit J1 Pins – This tab maps EF pins to pins on the J1 (168 pin) connector on the 168-132 pin adapter. It also maps the 168-pin J1
connecter to the J2 132-pin connecter. Pins are sorted by the pin order on the Starter Kit 168-pin J1 connector.
2. Sorted by Device Pins – A copy of the first tab, sorted by EF device pins.
3. Sorted by Adaptor J2 Pins – A copy of the first tab, sorted by the pins on the J2 132-pin adaptor.
4. PIC32 IO Expansion Pin Out – Provides the pin out of the I/O Expansion Board from the 132-pin J1 connector to the 0.1” pitch headers on the
board (J10,J11).
5. End to End – maps the EF device pins to the 0.1” pitch headers on the I/O Expansion Board. This tab can be reused to map out other
application pin outs.
6. Mikroe Display – Provides the pin outs for the 40-pin ribbon cable connector (CN3) on the display board.
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Advanced Topics
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 108
7. End to End by Device Pins – This tab combines Tab 4 with Tab 6. It shows how to build a ribbon cable between the I/O Expansion Board and
the display. On this tab the rows belonging to EF device pins that aren’t part of the ribbon cable are hidden for the sake of simplicity.
Tab 7 of the spreadsheet shows:
The ribbon cable for this project is constructed using the map from J10 Pin#/J11 Pin # to the TFT Proto 5” Pin #. For example, the first line of the
Tab 7 shows that pin 7 of the J10 header on the I/O expansion board is connected to pin 18 of the display connector, thereby connecting PMPD5
(PMP data pin 5) on the device to TFT-D5 on the display.
Note: display pins with a “#” suffix indicate that the signal is active low (# = bar).
TFT-Dn display pins are part of the SSD1963 display controller’s Parallel Master Port (PMP) interface. Other TFT-* pins are part of the controller to
host interface. For example, TFT-WR# is connected to the controller’s WRbar (write strobe bar) pin, which is called WR_STROBE_BAR in the
MPLAB Harmony Graphical Pin Manager. (Setting up the project’s pins using the Pin Manager is discussed later in the tutorial.)
On the display connector FT5x06 capacitive touch controller pins are called CTP-*. There is an I2C clock pin (CTP-SCL), I2C data pin (CTP-SDA),
an interrupt pin to alert the host of a touch event (CTP-INT#), and reset/wakeup pins (CTP-RST#/CTP-WAKE#).
Creating the Project in MPLAB and MPLAB Harmony
Getting Started
The pre-installed project, 3rd_party_display_start can be used as a basis for the work discussed in this tutorial. Be sure to copy this project to a
place in the MPLAB Harmony directory hierarchy that is just as deep. If this is not done, all the relative paths in the project’s configuration will no
longer find the project’s files and nothing will build.
For example, copying 3rd_party_display_start into a directory .\apps\3rd_party_display will not work, since the target directory is
one level higher in MPLAB Harmony’s directory hierarchy. The directory .\apps\gfx\3rd_party_display will work since it is at the same
level in the hierarchy.
There is an extra file in the .\apps\examples\3rd_party_display_start file (xc32_vm.nn_pic32mx_include_assert.h) , which
provides the modification to the compiler’s assert.h as discussed in Volume 1 of MPLAB Harmony’s documentation (Creating Your First
Project). This modification supports producing breakpoints under the debugger when an assert fails, which can be very useful in debugging the
code. Simply use this file to replace ./xc32/vm.nn/pic32mx/include/assert.h,where m.nn represents the version number of
the compiler you are using.
For first time users of the PIC32MZ product line and MPLAB Harmony should create the starting the project from scratch. Follow the instructions in
“Creating Your First Project”, which is found in Volume 1: Getting Started With MPLAB Harmony Libraries and Applications. Call the new project
3rdPartyDisplay instead of Heartbeat.
In Part 1, Step 3 of the Creating Your First Project, use a different application name than “heartbeat." For example accept the default “app”, then
replace “heartbeat” with the new application name in the tutorial code examples. If the default application name “app” is used then “heartbeat” is
replaced by “app” in the code examples. The header file heartbeat.h would be named app.h instead and it should contain:
typedef enum
{
/* Application's state machine's initial state. */
APP_STATE_INIT=0,
APP_STATE_SERVICE_TASKS,
/* TODO: Define states used by the application state machine. */
APP_RESTART_TIMER
} APP_STATES;
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Advanced Topics
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 109
Here the enum is called APP_STATES instead of HEARTBEAT_STATES and the state APP_RESTART_TIMER replaces the state
HEARTBEAT_RESTART_TIMER. The structure HEARTBEAT_DATA is now called APP_DATA:
typedef struct
{
/* The application's current state */
APP_STATES state;
/* TODO: Define any additional data used by the application. */
SYS_TMR_HANDLE hDelayTimer; // Handle for delay timer
} APP_DATA;
The same principle applies to app.c (instead of heartbeat.c in the tutorial). The structure heartbeatData is now called appData. The source
file app.c should contain:
{
/* Check the application's current state. */
switch ( appData.state )
{
/* Application's initial state. */
case APP_STATE_INIT:
{
bool appInitialized = true;
if (appInitialized)
{
appData.hDelayTimer = SYS_TMR_DelayMS(HEARTBEAT_DELAY);
if (appData.hDelayTimer != SYS_TMR_HANDLE_INVALID)
{ // Valid handle returned
BSP_LEDOn(HEARTBEAT_LED);
appData.state = APP_STATE_SERVICE_TASKS;
}
appData.state = APP_STATE_SERVICE_TASKS;
}
break;
}
case APP_STATE_SERVICE_TASKS:
{
if (SYS_TMR_DelayStatusGet(appData.hDelayTimer))
{ // Single shot timer has now timed out.
BSP_LEDToggle(HEARTBEAT_LED);
appData.state = APP_RESTART_TIMER;
}
break;
}
/* TODO: implement your application state machine.*/
case APP_RESTART_TIMER:
{ // Create a new timer
appData.hDelayTimer = SYS_TMR_DelayMS(HEARTBEAT_DELAY);
if (appData.hDelayTimer != SYS_TMR_HANDLE_INVALID)
{ // Valid handle returned
appData.state = APP_STATE_SERVICE_TASKS;
}
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Advanced Topics
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 110
break;
}
/* The default state should never be executed. */
default:
{
/* TODO: Handle error in application's state machine. */
break;
}
}
}
At the end of the Creating Your First Project tutorial, the project supports a HyperTerminal console on a PC, which can be used to display
diagnostic messages. The project will also support the advanced error handling (asserts and exceptions) that MPLAB Harmony provides.
When running this application, verify that the HyperTerminal application (115200 baud, 8 bits, no stop bits) sees an initialization message of,
Application created Mar 1 2018 15:09:50 initialized! at startup, where the date and time report when the app.c file was last compiled. This
message originates in the application initialization function:
void APP_Initialize ( void )
{
SYS_MESSAGE("\r\nApplication created " __DATE__ " " __TIME__ " initialized!\r\n");
//Test out error handling
// assert(0);
// {
// uint8_t x, y, z;
// x = 1;
// y = 0;
// z = x/y;
// SYS_DEBUG_PRINT(SYS_ERROR_DEBUG,"x: %d, y: %d, z: %d\r\n",x,y,z);
// }
/* Place the App state machine in its initial state. */
appData.state = APP_STATE_INIT;
/* TODO: Initialize your application's state machine and other
* parameters.
*/
}
Verify that asserts and exception handling work before proceeding. Uncomment the assert and test. Then comment out the assert and uncomment
the {…} clause to test out exceptions.
Note:
If this is the first time hooking up a HyperTerminal session to the EF Starter Kit using the MCP2221, see Part 3 of the Creating
Your First Project tutorial in Volume 1 of MPLAB Harmony’s documentation. This part of the tutorial shows how to hookup the EF
Starter Kit to your PC. It also discusses in Steps 11 and 12 how to setup your HyperTerminal application.
Setting Up Pins using the MPLAB Harmony Graphical Pin Manager
Since a pre-defined Board Support Package is not available, pin assignments will have to be manually entered into the Pin Manger using the “Pin
Settings” tab. Load the startup project, either from a copy made from .\apps\examples\3rd_party_display_start or one created from
scratch. Then run MPLAB Harmony Configurator:
From MPLAB Harmony Configurator, select the Pin Settings tab:
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Advanced Topics
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 111
Make these modifications to the pin table:
The pins labeled USART to USB Bridge (BSP) support the MCP2221 USART to USB device on the EF Starter Kit board. It provides a
HyperTerminal interface on the PC. This is setup in the 3rd_party_diaplay_start project.
Be sure the touch interrupt event interrupt (pin 104, CTP_INT_BAR) pin is pulled high (CNPU enabled), otherwise touch event interrupts will never
fire:
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Advanced Topics
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 112
Setting up Graphics
In MPLAB Harmony Configurator, under the Options tab:
open Harmony Framework Configuration > Graphics Stack and enable the Graphics Stack with the following settings.
First select a “Custom Display” as the display type.
Then enter the dimensions of the Mikroe display (800x480).
Note:
The display can be set in MHC’s Display Manager.
Enable the Graphics Stack using the MHC’s Options tab, it is easier to do the basic display setup here. Later the Display Manager will be used to
tune the display’s timing (syncs plus front porches and back porches) so that all 800x480 pixels are correctly displayed. For now, accept the
default display timings.The equivalent setup using the Display Manager is:
The Mikroe display uses a SSD1963 graphics controller to run the TFT display, which is supported in MPLAB Harmony. This graphics controller is
connected to the EF host using the Parallel Master Port (PMP), I2C, and GPIO peripherals. (For details, see the Setting Up Pins using the MPLAB
Harmony Graphical Pin Manager section above.)
Under Graphics Stack > Graphics Controller, select the SSD1963 graphics controller, enable the controller’s backlight PWM. Change the pixel
clock from the default to 30 MHz and click “Execute” to compute the Pixel Clock Prescaler value. Finally, since the system clock for the EF host
runs at 200 MHz, add an additional NOP for correct Write Strobe timing.
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Advanced Topics
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 113
Finally, verify Use Touch System Service? (Deprecated) is enabled:
When finished, re-generate the code to capture these new settings using the Generate Code button in MPLAB Harmony Configurator.
Be sure to use the Prompt Merge For All Differences merge strategy to maintain code customizations installed outside of MHC.
After regenerating the project, you will have to customize the system_init.c file, found in the project under Source Files / app /
system_config / , where is typically "default". Move the
SYS_PORTS_Initialize call from the middle of SYS_Initialize to between SYS_DEVCON_PerformanceConfig and BSP_Initialize.
The Old location:
The New location is:
Tuning Display Timing Using Display Manager
The next step is to tune the timing of the display using the Display Manger to prevent the edges of the screen from being clipped. A rectangle
needs to be drawn on the edges of the screen. Then by building and running the application, we can see if any parts of the border rectangle are
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Advanced Topics
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 114
clipped or missing. A different color is needed for each of the four sides of the border rectangle, as in some cases the display controller’s memory
pointers can “wrap” a pixel from one side of the display to the opposite side. If all the sides are the same color this would not be apparent. Here is
the screen to implement in the Screen Designer panel:
Each side of the border will require a custom color scheme. The border is created by drawing four separate lines using four separate line widgets.
Examine how line widgets are colored by dragging a line widget from the Widget Toolbox panel onto the Screen Designer panel and then pick the
Properties Editor Panel for that widget. Click on the “?” to the right of the Scheme property.
This will bring up the “Line Widget Scheme Helper” window:
If the Background and Shape of the widget are colored with the same color, different for each side, then the four edges of the display are easily
marked. Using the same colors for the line, and the widget’s background, allows the use of the size and position of the line widget rather than the
line’s coordinates to mark that edge of the display.
To create the display, within MHC, launch the Graphics Composer.
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Advanced Topics
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 115
Using the Scheme panel, create four new color schemes.
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Advanced Topics
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 116
Next, drag a line widget onto the display four times and edit each widget’s properties to create and position each edge of the display’s border:
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Advanced Topics
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 117
Note that the “Line” coordinates are set to [0,0,0,0] since it is the size of the widget rather than the widget’s line that marks each border line. The
lines in these widgets are not used. Each widget’s position and size mark an edge of the display, not the line. Re-generate the application and then
run it.
The HyperTerminal application (115200 baud, 8 bits, no stop bits) should show the following when the application boots up:
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Advanced Topics
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 118
Examine the border of the resulting display,note that the top edge of the border is completely missing and the left edge is about half the width
desired, compared to the right and bottom edges. To fix this the display timings need to be adjusted using the Display Manager:
If this is the first time using the Display Manger, Volume 1 of MPLAB Harmony’s documentation has a Display Manager Quick Start Guide and
Volume III has the MPLAB Harmony Display Manager User’s Guide. Increase the Horizonal Pulse Width by two clocks, re-generate, and then run.
The left border should be fully visible.
Next, tune the Vertical Pulse Width. Gradually increasing it to move the top border line down until it is fully visible. (22 H-syncs seems to be the
correct value.)
After each adjustment re-generate, build and run, then examine the resulting display. Stop when all borders are fully visible and there are no
“dead” (black) pixels on the display.
In the Display Manger, the final, optimal, settings for the display are:
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Advanced Topics
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 119
When finished, the display should be:
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Advanced Topics
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 120
A picture of each edge through a 10x power loupe verifies that each edge is exactly 4 pixels wide and there are no “dead” (black) pixels between
the edges of the display and the colored border.
The Mikroe board uses a Riverdi RVT50AQTNWC00 display.
Table 8.3 of its datasheet covers display timing:
Some explanation is required to match up this data with the Display Manager’s settings. Back porch timings are not shown in the table, but can be
calculated by subtracting the HS/VS pulse width from the HS/VS Blanking:
HS Back Porch = HS Blanking – HS pulse width = Thbp = Thb – Thfp
VS Back Porch = VS Blanking – VS pulse width = Tvbp = Tvb – Tvfp
The DCLK Frequency typical value of 30 MHz has already been used in setting up the display pixel clock speed. However, using the “Typ”
(Typical) values, and the calculated Thbp and Tvbp values from the equations above, the timing will not work. The timing values that work for this
tutorial meet the minimum or maximum range shown above with one exception:
The “One Horizontal Line” timing, Th, has a minimum of 889 pixel clocks, but the one in use is:
Th = Thpw + Thbp + 800 pixels+ Thfp = 44 + 2 +800 + 2 = 848 pixel clocks < 889
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Advanced Topics
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 121
which is 41 pixel clocks (4.6%) below the minimum Th of 889 shown in Table 8.3 above.
Results may vary on your display. This was tested on two different boards with the same results. Starting out with the default display timings and
then iteratively tuning them to reduce pixel clipping and dead pixels, as discussed above, will provide the optimal display timings for the hardware
regardless of the final settings.
Supporting the Focal Tech FT5x06 Capacitive Touch Controller
Microchip (Atmel) and Focal Tech are key providers of capacitive touch controllers. Focal Tech FT5x06 touch controllers are found on many of the
displays used by Microchip customers, so a third-party display with a Focal Tech capacitive touch controller is a good choice for this tutorial.
MPLAB Harmony provides these touch controller drivers:
The Generic Touch Driver outlines the generic Touch Driver API supported by MPLAB Harmony. It provides a template that can serve as the base
for a custom-built driver for the FT5x06 touch controller.
A faster way to support the Focal Tech FT5x06 is to find a similar device that is already supported in MPLAB Harmony and simply modify the
driver code for that device. This eliminates having to write all the supporting code needed to fit the new driver into MPLAB Harmony. Capacitive
touch devices typically have an I2C interface with the host, and an interrupt signal that is driven low to alert the host that a touch event has been
detected. In response to this external interrupt the host uses the I2C interface with the device to query the device and read the (x,y) pixel
coordinates of the touch event.
The FT5x06 command interface is closest to the MTCH6303 interface since it requires a write command followed by a read command to get the
touch event. (The MTCH6301 only requires the read message.) The other thing to be aware of is the data order coming from the chip.
FT5x06 Memory:
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Advanced Topics
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 122
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Advanced Topics
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 123
Modifying MPLAB Harmony’s MTCH6303 Touch Driver for the Focal Tech FT5x06
The first step towards supporting the FT5x06 is to add a MTCH6303 driver to the application, and then modify the MTCH6303’s code to support
the FT5x06. To support the FT5x06, we will add a C preprocessor #if defined(FT_SUPPORT)…#else…#endif clauses to the code and then define
FT_SUPPORT in the project’s C compiler properties.
To add the MTCH6303 touch driver, make the following changes to the project’s MHC settings:
Be sure to increase the event queue depth from the default of 10 to something larger, here it is 25. The controller’s CTP-INT# (CTP_INT_BAR in
the Pin Settings table) is connected to INT0, so change the external interrupt source to INT_SOURCE_EXTERNAL_0.
Next, enable the I2C driver, using a bit-banged implementation:
The Interrupt System Service is enabled, with an Interrupt Priority of 5, connected to INT0, and triggered on a falling edge (since CTP-INT# is
active low):
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Advanced Topics
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 124
Re-generate the application to implement these changes to the application.
Rather than edit the application’s MTCH6303 driver code, install the modified driver from the tutorial project found in
.\apps\examples\3rdPartyDisplay. Copy the code found in directory
.\apps\examples\3rdPartyDisplay\firmware\src\system_config\default\framework\driver\touch\mtch6303
into the same folder in the project.
To keep these changes in the code whenever the project is regenerated, always choose the “Prompt Merge For All Differences” merge strategy
and simply close all the windows related to the MTCH6303 driver. These changes are identified by // CUSTOM CODE – DO NOT DELETE … //
END OF CUSTOM CODE flags in the code.
Note:
Ignore all proposed changes for the following files:
• drv_mtch6303_static.h
• drv_mtch6303_static.c
• drv_mtch6303_static_local.h
To enable Focal Tech support in the modified driver, open the project’s configuration and define FT_SUPPORT in the C compiler section.
Adding a Touch Test Widget
Bring up MHC’s Graphics Composer again and add a Touch Test widget to the screen. Resize the widget to cover most of the display. Next,
create another color scheme, and customize it to see the cross hairs for all touch measurements reported by the widget.
The TouchTest Widget has the following color scheme:
First, create a new scheme, call it TouchTestScheme:
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Advanced Topics
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 125
Edit the Foreground and Background colors so that both are red.
Finally, edit the properties for the Touch Test widget to have a Line border, and to use the TouchTestScheme color scheme:
The Screen Designer panel should show:
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Advanced Topics
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 126
Close the Graphics Composer window and save the modifications to the graphics design. Re-generate the application’s code and then build and
load the application.
Testing the Final Application
Here is what the display should look like during a touch event:
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Advanced Topics
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 127
Completed Tutorial Project
The completed tutorial project can be found in .\apps\examples\3rdPartyDisplay.
Importing and Exporting Graphics Data
This topic provides information on importing and exporting graphics composer-related data.
Description
The MPLAB Harmony Graphics Composer (MHGC) provides the capability for users to import and export graphics designs. The user can export
the state of an existing graphics composer configuration or import another graphics composer configuration from another project.
Importing Data
1. To import a graphics design into MHGC, select File > Import. The Browse for MPLAB Harmony Graphics Composer XML file dialog appears,
which allows the selection of a previously exported Graphics Composer .xml file, or the configuration.xml file that contains the desired
graphics image.
2. After selecting a file and clicking Open, you will be prompted whether to overwrite existing data.
3. If you selected a composer_export.xml file, clicking Yes will replace the current graphics design with the new design.
4. Otherwise, if you selected a configuration.xml file, you will be prompted to import the data into the current graphics design. Click Yes to
replace the current graphics design with the new design.
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Importing and Exporting Graphics Data
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 128
Exporting Data
1. To export a graphics design from MHGC, select File > Export. The Select File Location for MPLAB Harmony Graphics Composer XML file
dialog appears.
2. To export a graphics design using a configuration.xml file, use the Save Configuration utility from the MPLAB Harmony Configurator
(MHC) toolbar.
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer User's Importing and Exporting Graphics Data
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 129
MPLAB Harmony Graphics Composer Suite
This section provides user information about using the MPLAB Harmony Graphics Composer Suite (MHGS).
Description
Please see Volume IV: MPLAB Harmony Framework Reference > Graphics Libraries Help > MPLAB Harmony Graphics Composer Suite for
detailed information.
Volume III: MPLAB Harmony Configurator (MHC) MPLAB Harmony Graphics Composer Suite
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 130
Index
A
Adding Third-Party Graphics Products Using the Hardware Abstsraction
Layer (HAL) 90
Advanced Topics 90
aria_coffeemaker Demonstration Example 98
B
Binary Assets 66
C
Code Generation 90
Creating a MPLAB Harmony Graphics Application Using a Third-Party
Display 106
Creating the Project in MPLAB and MPLAB Harmony 109
D
DDR Organizer 47
Draw Pipeline Options 93
E
Event Manager 67
F
Font Assets 55
G
Global Palette 78
GPU Hardware Accelerated Features 103
Graphics Composer Asset Management 42
Graphics Composer Window User Interface 3
Graphics Pipeline 93
Graphics Pipeline Options 97
H
Heap Estimator 76
I
Image Assets 49
Image Preprocessing Memory Management 106
Importing and Exporting Graphics Data 128
Improved Touch Performance with Phantom Buttons 98
Introduction 3
M
Memory Configuration 43
Menus 10
MHGC Tools 67
MPLAB Harmony Graphics Composer Suite 130
MPLAB Harmony Graphics Composer User's Guide 3
N
New Project Wizard 14
O
Object Properties 30
Options 26
P
Properties Editor Panel 29
S
Schemes Panel 24
Screen Designer Window 6
Screens Panel 22
Small Buttons Controlled by Phantom Buttons 100
Speed and Performance of Different Image Decode Formats in MHGC 92
String Assets 63
String Table Configuration 60
Supporting the Focal Tech FT5x06 Capacitive Touch Controller 122
T
Tree View Panel 18
V
Volume III: MPLAB Harmony Configurator (MHC) 2
W
Widget Colors 81
Widget Tool Box Panel 26
Index
© 2013-2017 Microchip Technology Inc. MPLAB Harmony v2.06 131
www.microchip.com/partners
Authorized Design Partner Program
Design Partner Program
A UTHORIZED
Consulting Services
Hardware Design
Software Design
Reference Designs
Manufacturing
2 Design Partner Program
Design Partner Program Overview
Program Overview
Microchip’s Design Partner Program (DPP) capitalizes
on the joint strengths of Microchip and its world-class
Design Partner network, which ranges from small design
houses to large international corporations. Through the
Microchip DPP, Microchip identifies, recruits and supports
partners who provide market-leading embedded software
and hardware design services, reference designs and full
turnkey manufacturing services implementing Microchip’s
embedded technology solutions.
Authorized design partners get access to priority support,
hands-on technical trainings, joint marketing and PR
opportunities and are highlighted on Microchip’s Design
Partner website. Information supplied to our customers
and Microchip’s worldwide sale force includes a detailed
partner profile of each partner, their location(s) and areas
of technological expertise. Our customers receive access
to a network of experts needed throughout their design life
cycle and service engagement, while partners benefit from
an expanded customer base, increased revenue stream
and the ability to differentiate themselves in today’s
competitive marketplace.
Authorized Design Partner Logo
Program participants can
use this official logo to
demonstrate their affiliation
with Microchip.
Program Benefi ts
More Complete Solutions
■ Access to Microchip's diverse product portfolio
■ Full range of easy-to-use development tools
■ Enhanced technical support
Improved Time to Market
■ Seamless migration path
■ Shared integration resources
■ Optimized reference designs
■ Access to predeveloped software components
Shared Risk and Lower System Cost
■ Reduced research and development
■ World-class quality and reliability
■ Access to technology experts
Leverage Microchip's Resources
■ Engage more customers
■ Share insights, expertise and feedback
■ Access to more opportunities and design wins
A UTHORIZED
Design Partner Program 3
Get Rewarded by Microchip
Microchip’s Design Partner Program offers two compensation options. Depending on
your company’s business model, Microchip offers financial compensation for designing
with Microchip’s broad product portfolio; or participants can receive special discounts on
development tools, silicon products and Microchip’s annual MASTERs Conference. These
rewards are applicable to qualified design partners who specify Microchip products for their
end customers and/or to those who include Microchip’s devices in reference designs used
by third parties.
Microchip's Authorized Design Partner Program Benefi ts
Option 1: Compensation-Based Program
Financial Compensation Program Benefi ts Bronze Silver Gold Platinum
Acceptance Level Required Agreement
Signed
Microchip
Field
Nomination
and Approval
25 Design
Wins per
Calendar Year
40 Design
Wins per
Calendar Year
Design Partner Certifi cate Issued Every Calendar Year ü ü ü ü
45% discount coupon for development tools at
www.microchipDIRECT.com ü – – –
Use of Microchip's Design Partner Program logo ü ü ü ü
Partner profi le posted on Microchip's website at
www.microchip.com/partners – ü ü ü
Priority technical support at www.microchip.com/support ü ü ü ü
Opportunity to become a third-party developer at
www.EmbeddedCodeSource.com ü ü ü ü
Free expanded sample counts at www.microchip.com/samples ü ü ü ü
Free technical training at www.microchip.com/training ü ü ü ü
Participation in special Microchip projects
(articles, reference designs, etc.) – – ü ü
Increased joint marketing and PR opportunities – – – ü
Option 2: Discount-Based Program
Discount-Based Program Benefi ts Bronze Silver Gold Platinum
Acceptance Level Points Required 250 500 750 1000
Design Partner Certifi cate Issued Every Calendar Year ü ü ü ü
Free MPLAB® ICD 3 In-Circuit Debugger
(upon acceptance into the program) ü ü ü ü
On-going discount on development tools at
www.microchipDIRECT.com 45% 45% 45% 45%
Discount on attendance at MASTERs Conference at
www.microchip.com/MASTERs 20% 40% 60% 75%
Use of Microchip's Design Partner Program logo ü ü ü ü
Partner profi le posted on Microchip's website at
www.microchip.com/partners ü ü ü ü
Priority Technical Support at www.microchip.com/support ü ü ü ü
Opportunity to become a third-party developer at
www.EmbeddedCodeSource.com ü ü ü ü
Free expanded sample counts at www.microchip.com/samples ü ü ü ü
Free technical training at www.microchip.com/training ü ü ü ü
Participation in special Microchip projects
(articles, reference designs, etc.) – – ü ü
Increased joint marketing and PR opportunities – – – ü
Interested in Applying?
Send us an email at designpartners@microchip.com or contact your local Microchip sales representative for
more information.
Microchip Technology Inc.
2355 W. Chandler Blvd.
Chandler, AZ 85224-6199
www.microchip.com
Support
Microchip is committed to supporting its customers
in developing products faster and more efficiently. We
maintain a worldwide network of field applications
engineers and technical support ready to provide product
and system assistance. In addition, the following service
areas are available at www.microchip.com:
■ Support link provides a way to get questions
answered fast: http://support.microchip.com
■ Sample link offers evaluation samples of any
Microchip device: http://sample.microchip.com
■ Forum link provides access to knowledge base and
peer help: http://forum.microchip.com
■ Buy link provides locations of Microchip Sales Channel
Partners: www.microchip.com/sales
Training
If additional training interests you, then Microchip can
help. We continue to expand our technical training options,
offering a growing list of courses and in-depth curriculum
locally, as well as significant online resources – whenever
you want to use them.
■ Technical Training and other Resources:
www.microchip.com/training
■ MASTERs Conferences: www.microchip.com/masters
■ Worldwide Seminars: www.microchip.com/seminars
■ eLearning: www.microchip.com/webseminars
The Microchip name and logo, the Microchip logo and MPLAB are registered trademarks of Microchip Technology Incorporated
in the U.S.A. and other countries. All other trademarks mentioned herein are property of their respective companies. © 2015,
Microchip Technology Incorporated. All Rights Reserved. Printed in the U.S.A. 9/15
DS00001077D
Sales Offi ce Listing
ASIA/PACIFIC
Australia - Sydney
Tel: 61-2-9868-6733
China - Beijing
Tel: 86-10-8569-7000
China - Chengdu
Tel: 86-28-8665-5511
China - Chongqing
Tel: 86-23-8980-9588
China - Dongguan
Tel: 86-769-8702-9880
China - Hangzhou
Tel: 86-571-87928115
China - Hong Kong SAR
Tel: 852-2943-5100
China - Nanjing
Tel: 86-25-8473-2460
China - Qingdao
Tel: 86-532-8502-7355
China - Shanghai
Tel: 86-21-5407-5533
China - Shenyang
Tel: 86-24-2334-2829
China - Shenzhen
Tel: 86-755-8864-2200
China - Wuhan
Tel: 86-27-5980-5300
China - Xiamen
Tel: 86-592-2388138
China - Xian
Tel: 86-29-8833-7252
China - Zhuhai
Tel: 86-756-3210040
AMERICAS
Atlanta
Tel: 678-957-9614
Austin
Tel: 512-257-3370
Boston
Tel: 774-760-0087
Chandler
Tel: 480-792-7200
Chicago
Tel: 630-285-0071
Cleveland
Tel: 216-447-0464
Dallas
Tel: 972-818-7423
Detroit
Tel: 248-538-2250
Houston
Tel: 281-894-5983
Indianapolis
Tel: 317-773-8323
Los Angeles
Tel: 949-462-9523
New York
Tel: 631-435-6000
San Jose
Tel: 408-735-9110
Toronto
Tel: 905-673-0699
EUROPE
Austria - Wels
Tel: 43-7242-2244-39
Denmark - Copenhagen
Tel: 45-4450-2828
France - Paris
Tel: 33-1-69-53-63-20
Germany - Dusseldorf
Tel: 49-2129-3766400
Germany - Karlsruhe
Tel: 49-721-625370
Germany - Munich
Tel: 49-89-627-144-0
Italy - Milan
Tel: 39-0331-742611
Italy - Venice
Tel: 39-049-7625286
Netherlands - Drunen
Tel: 31-416-690399
Poland - Warsaw
Tel: 48-22-3325737
Spain - Madrid
Tel: 34-91-708-08-90
Sweden - Stockholm
Tel: 46-8-5090-4654
UK - Wokingham
Tel: 44-118-921-5800
ASIA/PACIFIC
India - Bangalore
Tel: 91-80-3090-4444
India - New Delhi
Tel: 91-11-4160-8631
India - Pune
Tel: 91-20-3019-1500
Japan - Osaka
Tel: 81-6-6152-7160
Japan - Tokyo
Tel: 81-3-6880-3770
Korea - Daegu
Tel: 82-53-744-4301
Korea - Seoul
Tel: 82-2-554-7200
Malaysia - Kuala Lumpur
Tel: 60-3-6201-9857
Malaysia - Penang
Tel: 60-4-227-8870
Philippines - Manila
Tel: 63-2-634-9065
Singapore
Tel: 65-6334-8870
Taiwan - Hsin Chu
Tel: 886-3-5778-366
Taiwan - Kaohsiung
Tel: 886-7-213-7828
Taiwan - Taipei
Tel: 886-2-2508-8600
Thailand - Bangkok
Tel: 66-2-694-1351
7/14/15
Features
• High-performance, Low-power 32-bit Atmel® AVR® Microcontroller
– Compact Single-cycle RISC Instruction Set Including DSP Instructions
– Read-modify-write Instructions and Atomic Bit Manipulation
– Performance
• Up to 64DMIPS Running at 50MHz from Flash (1 Flash Wait State)
• Up to 36DMIPS Running at 25MHz from Flash (0 Flash Wait State)
– Memory Protection Unit (MPU)
• Secure Access Unit (SAU) providing User-defined Peripheral Protection
• picoPower® Technology for Ultra-low Power Consumption
• Multi-hierarchy Bus System
– High-performance Data Transfers on Separate Buses for Increased Performance
– 12 Peripheral DMA Channels improve Speed for Peripheral Communication
• Internal High-speed Flash
– 256Kbytes, 128Kbytes, and 64Kbytes Versions
– Single-cycle Access up to 25MHz
– FlashVault Technology Allows Pre-programmed Secure Library Support for End
User Applications
– Prefetch Buffer Optimizing Instruction Execution at Maximum Speed
– 100,000 Write Cycles, 15-year Data Retention Capability
– Flash Security Locks and User-defined Configuration Area
• Internal High-speed SRAM, Single-cycle Access at Full Speed
– 32Kbytes (256Kbytes and 128Kbytes Flash) and 16Kbytes (64Kbytes Flash)
• Interrupt Controller (INTC)
– Autovectored Low-latency Interrupt Service with Programmable Priority
• External Interrupt Controller (EIC)
• Peripheral Event System for Direct Peripheral to Peripheral Communication
• System Functions
– Power and Clock Manager
– SleepWalking Power Saving Control
– Internal System RC Oscillator (RCSYS)
– 32 KHz Oscillator
– Multipurpose Oscillator, Phase Locked Loop (PLL), and Digital Frequency Locked
Loop (DFLL)
• Windowed Watchdog Timer (WDT)
• Asynchronous Timer (AST) with Real-time Clock Capability
– Counter or Calendar Mode Supported
• Frequency Meter (FREQM) for Accurate Measuring of Clock Frequency
• Universal Serial Bus (USBC)
– Full Speed and Low Speed USB Device Support
– Multi-packet Ping-pong Mode
• Six 16-bit Timer/Counter (TC) Channels
– External Clock Inputs, PWM, Capture, and Various Counting Capabilities
• 36 PWM Channels (PWMA)
– 12-bit PWM with a Source Clock up to 150MHz
• Four Universal Synchronous/Asynchronous Receiver/Transmitters (USART)
– Independent Baudrate Generator, Support for SPI
– Support for Hardware Handshaking
32142D–06/2013
32-bit Atmel
AVR
Microcontroller
ATUC256L3U
ATUC128L3U
ATUC64L3U
ATUC256L4U
ATUC128L4U
ATUC64L4U
2
32142D–06/2013
ATUC64/128/256L3/4U
• One Master/Slave Serial Peripheral Interface (SPI) with Chip Select Signals
– Up to 15 SPI Slaves can be Addressed
• Two Master and Two Slave Two-wire Interfaces (TWI), 400kbit/s I2
C-compatible
• One 8-channel Analog-to-digital Converter (ADC) with up to 12 Bits Resolution
– Internal Temperature Sensor
• Eight Analog Comparators (AC) with Optional Window Detection
• Capacitive Touch (CAT) Module
– Hardware-assisted Atmel® AVR® QTouch® and Atmel® AVR® QMatrix Touch Acquisition
– Supports QTouch and QMatrix Capture from Capacitive Touch Sensors
• QTouch Library Support
– Capacitive Touch Buttons, Sliders, and Wheels
– QTouch and QMatrix Acquisition
• Audio Bitstream DAC (ABDACB) Suitable for Stereo Audio
• Inter-IC Sound (IISC) Controller
– Compliant with Inter-IC Sound (I2
S) Specification
• On-chip Non-intrusive Debug System
– Nexus Class 2+, Runtime Control, Non-intrusive Data and Program Trace
– aWire Single-pin Programming Trace and Debug Interface, Muxed with Reset Pin
– NanoTrace Provides Trace Capabilities through JTAG or aWire Interface
• 64-pin TQFP/QFN (51 GPIO Pins), 48-pin TQFP/QFN/TLLGA (36 GPIO Pins)
• Six High-drive I/O Pins (64-pin Packages), Four High-drive I/O Pins (48-pin Packages)
• Single 1.62-3.6V Power Supply
3
32142D–06/2013
ATUC64/128/256L3/4U
1. Description
The Atmel® AVR® ATUC64/128/256L3/4U is a complete system-on-chip microcontroller based
on the AVR32 UC RISC processor running at frequencies up to 50MHz. AVR32 UC is a highperformance
32-bit RISC microprocessor core, designed for cost-sensitive embedded applications,
with particular emphasis on low power consumption, high code density, and high
performance.
The processor implements a Memory Protection Unit (MPU) and a fast and flexible interrupt controller
for supporting modern and real-time operating systems. The Secure Access Unit (SAU) is
used together with the MPU to provide the required security and integrity.
Higher computation capability is achieved using a rich set of DSP instructions.
The ATUC64/128/256L3/4U embeds state-of-the-art picoPower technology for ultra-low power
consumption. Combined power control techniques are used to bring active current consumption
down to 174µA/MHz, and leakage down to 220nA while still retaining a bank of backup registers.
The device allows a wide range of trade-offs between functionality and power consumption,
giving the user the ability to reach the lowest possible power consumption with the feature set
required for the application.
The Peripheral Direct Memory Access (DMA) controller enables data transfers between peripherals
and memories without processor involvement. The Peripheral DMA controller drastically
reduces processing overhead when transferring continuous and large data streams.
The ATUC64/128/256L3/4U incorporates on-chip Flash and SRAM memories for secure and
fast access. The FlashVault technology allows secure libraries to be programmed into the
device. The secure libraries can be executed while the CPU is in Secure State, but not read by
non-secure software in the device. The device can thus be shipped to end customers, who will
be able to program their own code into the device to access the secure libraries, but without risk
of compromising the proprietary secure code.
The External Interrupt Controller (EIC) allows pins to be configured as external interrupts. Each
external interrupt has its own interrupt request and can be individually masked.
The Peripheral Event System allows peripherals to receive, react to, and send peripheral events
without CPU intervention. Asynchronous interrupts allow advanced peripheral operation in low
power sleep modes.
The Power Manager (PM) improves design flexibility and security. The Power Manager supports
SleepWalking functionality, by which a module can be selectively activated based on peripheral
events, even in sleep modes where the module clock is stopped. Power monitoring is supported
by on-chip Power-on Reset (POR), Brown-out Detector (BOD), and Supply Monitor (SM). The
device features several oscillators, such as Phase Locked Loop (PLL), Digital Frequency
Locked Loop (DFLL), Oscillator 0 (OSC0), and system RC oscillator (RCSYS). Either of these
oscillators can be used as source for the system clock. The DFLL is a programmable internal
oscillator from 20 to 150MHz. It can be tuned to a high accuracy if an accurate reference clock is
running, e.g. the 32KHz crystal oscillator.
The Watchdog Timer (WDT) will reset the device unless it is periodically serviced by the software.
This allows the device to recover from a condition that has caused the system to be
unstable.
The Asynchronous Timer (AST) combined with the 32KHz crystal oscillator supports powerful
real-time clock capabilities, with a maximum timeout of up to 136 years. The AST can operate in
counter or calendar mode.
4
32142D–06/2013
ATUC64/128/256L3/4U
The Frequency Meter (FREQM) allows accurate measuring of a clock frequency by comparing it
to a known reference clock.
The Full-speed USB 2.0 device interface (USBC) supports several USB classes at the same
time, thanks to the rich end-point configuration.
The device includes six identical 16-bit Timer/Counter (TC) channels. Each channel can be independently
programmed to perform frequency measurement, event counting, interval
measurement, pulse generation, delay timing, and pulse width modulation.
The Pulse Width Modulation controller (PWMA) provides 12-bit PWM channels which can be
synchronized and controlled from a common timer. 36 PWM channels are available, enabling
applications that require multiple PWM outputs, such as LCD backlight control. The PWM channels
can operate independently, with duty cycles set individually, or in interlinked mode, with
multiple channels changed at the same time.
The ATUC64/128/256L3/4U also features many communication interfaces, like USART, SPI,
and TWI, for communication intensive applications. The USART supports different communication
modes, like SPI Mode and LIN Mode.
A general purpose 8-channel ADC is provided, as well as eight analog comparators (AC). The
ADC can operate in 10-bit mode at full speed or in enhanced mode at reduced speed, offering
up to 12-bit resolution. The ADC also provides an internal temperature sensor input channel.
The analog comparators can be paired to detect when the sensing voltage is within or outside
the defined reference window.
The Capacitive Touch (CAT) module senses touch on external capacitive touch sensors, using
the QTouch technology. Capacitive touch sensors use no external mechanical components,
unlike normal push buttons, and therefore demand less maintenance in the user application.
The CAT module allows up to 17 touch sensors, or up to 16 by 8 matrix sensors to be interfaced.
All touch sensors can be configured to operate autonomously without software interaction,
allowing wakeup from sleep modes when activated.
Atmel offers the QTouch library for embedding capacitive touch buttons, sliders, and wheels
functionality into AVR microcontrollers. The patented charge-transfer signal acquisition offers
robust sensing and includes fully debounced reporting of touch keys as well as Adjacent Key
Suppression® (AKS®) technology for unambiguous detection of key events. The easy-to-use
QTouch Suite toolchain allows you to explore, develop, and debug your own touch applications.
The Audio Bitstream DAC (ABDACB) converts a 16-bit sample value to a digital bitstream with
an average value proportional to the sample value. Two channels are supported, making the
ABDAC particularly suitable for stereo audio.
The Inter-IC Sound Controller (IISC) provides a 5-bit wide, bidirectional, synchronous, digital
audio link with external audio devices. The controller is compliant with the Inter-IC Sound (I2S)
bus specification.
The ATUC64/128/256L3/4U integrates a class 2+ Nexus 2.0 On-chip Debug (OCD) System,
with non-intrusive real-time trace and full-speed read/write memory access, in addition to basic
runtime control. The NanoTrace interface enables trace feature for aWire- or JTAG-based
debuggers. The single-pin aWire interface allows all features available through the JTAG interface
to be accessed through the RESET pin, allowing the JTAG pins to be used for GPIO or
peripherals.
5
32142D–06/2013
ATUC64/128/256L3/4U
2. Overview
2.1 Block Diagram
Figure 2-1. Block Diagram
INTERRUPT
CONTROLLER
ASYNCHRONOUS
TIMER
PERIPHERAL
DMA
CONTROLLER
HSB-PB
BRIDGE B
HSB-PB
BRIDGE A
S
MM M
S
S
M
EXTERNAL INTERRUPT
CONTROLLER
HIGH SPEED
BUS MATRIX
GENERALPURPOSE I/Os
GENERAL PURPOSE I/Os
PA
PB
EXTINT[5..1]
NMI
PA
PB
SPI
DMA
MISO, MOSI
NPCS[3..0]
USART0
USART1
USART2
USART3
DMA
RXD
TXD
CLK
RTS, CTS
WATCHDOG
TIMER
SCK
JTAG
INTERFACE
MCKO
MDO[5..0]
MSEO[1..0]
EVTI_N
TDO
TDI
TMS
CONFIGURATION REGISTERS BUS
256/128/64
KB S FLASH
FLASH
CONTROLLER
EVTO_N
AVR32UC CPU
NEXUS
CLASS 2+
OCD
INSTR
INTERFACE
DATA
INTERFACE
MEMORY INTERFACE
LOCAL BUS
32/16 KB
SRAM
MEMORY PROTECTION UNIT
LOCAL BUS
INTERFACE
FREQUENCY METER
PWMA[35..0] PWM CONTROLLER
TWI MASTER 0
DMA
TWI MASTER 1
TWI SLAVE 0
DMA
TWI SLAVE 1
8-CHANNEL ADC
DMA
INTERFACE
POWER MANAGER
RESET
CONTROLLER
SLEEP
CONTROLLER
CLOCK
CONTROLLER
TCK
RESET_N aWire
CAPACITIVE TOUCH
DMA
MODULE
AC INTERFACE
ACREFN
ACAN[3..0]
ACBN[3..0]
ACBP[3..0]
ACAP[3..0]
TWCK
TWD
TWALM
TWCK
TWD
TWALM
GLUE LOGIC
CONTROLLER IN[7..0]
OUT[1..0]
USB 2.0
Interface 8EP
DMA
INTER-IC SOUND
CONTROLLER
TIMER/COUNTER 0
TIMER/COUNTER 1
A[2..0]
B[2..0]
AUDIO BITSTREAM
DMA
DAC DAC0, DAC1
DACN0, DACN1
ISCK
IWS
ISDI
ISDO
IMCK
CLK
SAU S/M
S
DM
DP
SYSTEM CONTROL
INTERFACE
GCLK[9..0]
XIN32
XOUT32 OSC32K
RCSYS
XIN0
XOUT0 OSC0
DFLL
RC32K
RC120M
RC32OUT
PLL
GCLK_IN[2..0]
CSB[16:0]
SMP
CSA[16:0]
SYNC
VDIVEN
DIS
TRIGGER
ADP[1..0]
AD[8..0]
DATAOUT
ADVREFP
CLK[2..0]
6
32142D–06/2013
ATUC64/128/256L3/4U
2.2 Configuration Summary
Table 2-1. Configuration Summary
Feature ATUC256L3U ATUC128L3U ATUC64L3U ATUC256L4U ATUC128L4U ATUC64L4U
Flash 256KB 128KB 64KB 256KB 128KB 64KB
SRAM 32KB 16KB 32KB 16KB
GPIO 51 36
High-drive pins 6 4
External Interrupts 6
TWI 2
USART 4
Peripheral DMA Channels 12
Peripheral Event System 1
SPI 1
Asynchronous Timers 1
Timer/Counter Channels 6
PWM channels 36
Frequency Meter 1
Watchdog Timer 1
Power Manager 1
Secure Access Unit 1
Glue Logic Controller 1
Oscillators
Digital Frequency Locked Loop 20-150MHz (DFLL)
Phase Locked Loop 40-240MHz (PLL)
Crystal Oscillator 0.45-16MHz (OSC0)
Crystal Oscillator 32KHz (OSC32K)
RC Oscillator 120MHz (RC120M)
RC Oscillator 115kHz (RCSYS)
RC Oscillator 32kHz (RC32K)
ADC 8-channel 12-bit
Temperature Sensor 1
Analog Comparators 8
Capacitive Touch Module 1
JTAG 1
aWire 1
USB 1
Audio Bitstream DAC 1 0
IIS Controller 1 0
Max Frequency 50MHz
Packages TQFP64/QFN64 TQFP48/QFN48/TLLGA48
7
32142D–06/2013
ATUC64/128/256L3/4U
3. Package and Pinout
3.1 Package
The device pins are multiplexed with peripheral functions as described in Section .
Figure 3-1. ATUC64/128/256L4U TQFP48/QFN48 Pinout GND 1 PA09
2
PA08
3
PA03
4
PB12
5
PB00
6
PB02
7
PB03
8
PA22
9
PA06 10
PA00 11
PA05 12
13 PA02
14 PA01
15 PB13
16 PB14
17 VDDIN
18 VDDCORE
19 GND
20 PB05
21 PB04
22 RESET_N
23 PB10
24 PA21
PA14 36
VDDANA 35
ADVREFP 34
GNDANA 33
PB08 32
PB07 31
PB06 30
PB09 29
PA04 28
PA11 27
PA13 26
PA20 25
PA15 37
PA16 38
PA17 39
PA19 40
PA18 41
VDDIO 42
GND 43
PB11 44
GND 45
PA10 46
PA12 47
VDDIO 48
8
32142D–06/2013
ATUC64/128/256L3/4U
Figure 3-2. ATUC64/128/256L4U TLLGA48 Pinout GND 1 PA09
2
PA08
3
PA03
4
PB12
5
PB00
6
PB02
7
PB03
8
PA22
9
PA06 10
PA00 11
PA05 12
PA02 13
14 PA01
15 PB13
16 PB14
17 VDDIN
18 VDDCORE
19 GND
20 PB05
21 PB04
22 RESET_N
23 PB10
24 PA21
PA14 36
VDDANA 35
ADVREFP 34
GNDANA 33
PB08 32
PB07 31
PB06 30
PB09 29
PA04 28
PA11 27
PA13 26
PA20 25
PA15 37
PA16 38
PA17 39
PA19 40
PA18 41
VDDIO 42
GND 43
PB11 44
GND 45
PA10 46
PA12 47
VDDIO 48
9
32142D–06/2013
ATUC64/128/256L3/4U
Figure 3-3. ATUC64/128/256L3U TQFP64/QFN64 Pinout GND 1 PA09
2
PA08
3
PB19
4
PB20
5
PA03
6
PB12
7
PB00
8
PB02
9
PB03 10
VDDIO 11
GND 12
PA22 13
PA06 14
PA00 15
PA05 16
17 PA02
18 PA01
19 PA07
20 PB01
21 PB26
22 PB13
23 PB14
24 PB27
PB08 44
PB07 43
PB06 42
PB22 41
PB21 40
PB09 39
PA04 38
VDDIO 37
GND 36
PA11 35
PA13 34
PA20 33
PA15 49
PA16 50
PA17 51
PA19 52
PA18 53
PB23 54
PB24 55
PB11 56
PB15 57
PB16 58
PB17 59
PB18 60
25 VDDIN
26
27 GND
28 PB05
29 PB04
30
31 PB10
32 PA21
PA14 48
VDDANA 47
ADVREFP 46
GNDANA 45
PB25 61
PA10 62
PA12 63
VDDIO 64
VDDCORE
RESET_N
10
32142D–06/2013
ATUC64/128/256L3/4U
Peripheral Multiplexing on I/O lines
3.1.1 Multiplexed Signals
Each GPIO line can be assigned to one of the peripheral functions. The following table
describes the peripheral signals multiplexed to the GPIO lines.
Table 3-1. GPIO Controller Function Multiplexing
48-
pin
64-
pin
Pin
Name
G
PI
O Supply
Pad
Type
GPIO Function
ABCDE F GH
11 15 PA00 0 VDDIO Normal
I/O
USART0-
TXD
USART1-
RTS
SPINPCS[2]
PWMAPWMA[0]
SCIFGCLK[0]
CATCSA[2]
14 18 PA01 1 VDDIO Normal
I/O
USART0-
RXD
USART1-
CTS
SPINPCS[3]
USART1-
CLK
PWMAPWMA[1]
ACIFBACAP[0]
TWIMS0-
TWALM
CATCSA[1]
13 17 PA02 2 VDDIO Highdrive
I/O
USART0-
RTS
ADCIFBTRIGGER
USART2-
TXD TC0-A0 PWMAPWMA[2]
ACIFBACBP[0]
USART0-
CLK
CATCSA[3]
4 6 PA03 3 VDDIO Normal
I/O
USART0-
CTS
SPINPCS[1]
USART2-
TXD TC0-B0 PWMAPWMA[3]
ACIFBACBN[3]
USART0-
CLK
CATCSB[3]
28 38 PA04 4 VDDIO Normal
I/O SPI-MISO TWIMS0-
TWCK
USART1-
RXD TC0-B1 PWMAPWMA[4]
ACIFBACBP[1]
CATCSA[7]
12 16 PA05 5 VDDIO Normal
I/O (TWI) SPI-MOSI TWIMS1-
TWCK
USART1-
TXD TC0-A1 PWMAPWMA[5]
ACIFBACBN[0]
TWIMS0-
TWD
CATCSB[7]
10 14 PA06 6 VDDIO
Highdrive
I/O,
5V
tolerant
SPI-SCK USART2-
TXD
USART1-
CLK TC0-B0 PWMAPWMA[6]
EICEXTINT[2]
SCIFGCLK[1]
CATCSB[1]
19 PA07 7 VDDIO Normal
I/O (TWI)
SPINPCS[0]
USART2-
RXD
TWIMS1-
TWALM
TWIMS0-
TWCK
PWMAPWMA[7]
ACIFBACAN[0]
EICNMI
(EXTINT[0])
CATCSB[2]
3 3 PA08 8 VDDIO Highdrive
I/O
USART1-
TXD
SPINPCS[2]
TC0-A2 ADCIFBADP[0]
PWMAPWMA[8]
CATCSA[4]
2 2 PA09 9 VDDIO Highdrive
I/O
USART1-
RXD
SPINPCS[3]
TC0-B2 ADCIFBADP[1]
PWMAPWMA[9]
SCIFGCLK[2]
EICEXTINT[1]
CATCSB[4]
46 62 PA10 10 VDDIO Normal
I/O
TWIMS0-
TWD TC0-A0 PWMAPWMA[10]
ACIFBACAP[1]
SCIFGCLK[2]
CATCSA[5]
27 35 PA11 11 VDDIN Normal
I/O
PWMAPWMA[11]
47 63 PA12 12 VDDIO Normal
I/O
USART2-
CLK TC0-CLK1 CAT-SMP PWMAPWMA[12]
ACIFBACAN[1]
SCIFGCLK[3]
CATCSB[5]
26 34 PA13 13 VDDIN Normal
I/O
GLOCOUT[0]
GLOCIN[7]
TC0-A0 SCIFGCLK[2]
PWMAPWMA[13]
CAT-SMP EICEXTINT[2]
CATCSA[0]
36 48 PA14 14 VDDIO Normal
I/O
ADCIFBAD[0]
TC0-CLK2 USART2-
RTS CAT-SMP PWMAPWMA[14]
SCIFGCLK[4]
CATCSA[6]
37 49 PA15 15 VDDIO Normal
I/O
ADCIFBAD[1]
TC0-CLK1 GLOCIN[6]
PWMAPWMA[15]
CATSYNC
EICEXTINT[3]
CATCSB[6]
38 50 PA16 16 VDDIO Normal
I/O
ADCIFBAD[2]
TC0-CLK0 GLOCIN[5]
PWMAPWMA[16]
ACIFBACREFN
EICEXTINT[4]
CATCSA[8]
11
32142D–06/2013
ATUC64/128/256L3/4U
39 51 PA17 17 VDDIO Normal
I/O (TWI) TC0-A1 USART2-
CTS
TWIMS1-
TWD
PWMAPWMA[17]
CAT-SMP CAT-DIS CATCSB[8]
41 53 PA18 18 VDDIO Normal
I/O
ADCIFBAD[4]
TC0-B1 GLOCIN[4]
PWMAPWMA[18]
CATSYNC
EICEXTINT[5]
CATCSB[0]
40 52 PA19 19 VDDIO Normal
I/O
ADCIFBAD[5]
TC0-A2 TWIMS1-
TWALM
PWMAPWMA[19]
SCIFGCLK_IN[
0]
CAT-SYNC CATCSA[10]
25 33 PA20 20 VDDIN Normal
I/O
USART2-
TXD TC0-A1 GLOCIN[3]
PWMAPWMA[20]
SCIFRC32OUT
CATCSA[12]
24 32 PA21 21 VDDIN
Normal
I/O (TWI,
5V
tolerant,
SMBus)
USART2-
RXD
TWIMS0-
TWD TC0-B1 ADCIFBTRIGGER
PWMAPWMA[21]
PWMAPWMAOD
[21]
SCIFGCLK[0]
CATSMP
9 13 PA22 22 VDDIO Normal
I/O
USART0-
CTS
USART2-
CLK TC0-B2 CAT-SMP PWMAPWMA[22]
ACIFBACBN[2]
CATCSB[10]
6 8 PB00 32 VDDIO Normal
I/O
USART3-
TXD
ADCIFBADP[0]
SPINPCS[0]
TC0-A1 PWMAPWMA[23]
ACIFBACAP[2]
TC1-A0 CATCSA[9]
20 PB01 33 VDDIO Highdrive
I/O
USART3-
RXD
ADCIFBADP[1]
SPI-SCK TC0-B1 PWMAPWMA[24]
TC1-A1 CATCSB[9]
7 9 PB02 34 VDDIO Normal
I/O
USART3-
RTS
USART3-
CLK SPI-MISO TC0-A2 PWMAPWMA[25]
ACIFBACAN[2]
SCIFGCLK[1]
CATCSB[11]
8 10 PB03 35 VDDIO Normal
I/O
USART3-
CTS
USART3-
CLK SPI-MOSI TC0-B2 PWMAPWMA[26]
ACIFBACBP[2]
TC1-A2 CATCSA[11]
21 29 PB04 36 VDDIN
Normal
I/O (TWI,
5V
tolerant,
SMBus)
TC1-A0 USART1-
RTS
USART1-
CLK
TWIMS0-
TWALM
PWMAPWMA[27]
PWMAPWMAOD
[27]
TWIMS1-
TWCK
CATCSA[14]
20 28 PB05 37 VDDIN
Normal
I/O (TWI,
5V
tolerant,
SMBus)
TC1-B0 USART1-
CTS
USART1-
CLK
TWIMS0-
TWCK
PWMAPWMA[28]
PWMAPWMAOD
[28]
SCIFGCLK[3]
CATCSB[14]
30 42 PB06 38 VDDIO Normal
I/O TC1-A1 USART3-
TXD
ADCIFBAD[6]
GLOCIN[2]
PWMAPWMA[29]
ACIFBACAN[3]
EICNMI
(EXTINT[0])
CATCSB[13]
31 43 PB07 39 VDDIO Normal
I/O TC1-B1 USART3-
RXD
ADCIFBAD[7]
GLOCIN[1]
PWMAPWMA[30]
ACIFBACAP[3]
EICEXTINT[1]
CATCSA[13]
32 44 PB08 40 VDDIO Normal
I/O TC1-A2 USART3-
RTS
ADCIFBAD[8]
GLOCIN[0]
PWMAPWMA[31]
CATSYNC
EICEXTINT[2]
CATCSB[12]
29 39 PB09 41 VDDIO Normal
I/O TC1-B2 USART3-
CTS
USART3-
CLK
PWMAPWMA[32]
ACIFBACBN[1]
EICEXTINT[3]
CATCSB[15]
23 31 PB10 42 VDDIN Normal
I/O TC1-CLK0 USART1-
TXD
USART3-
CLK
GLOCOUT[1]
PWMAPWMA[33]
SCIFGCLK_IN[
1]
EICEXTINT[4]
CATCSB[16]
44 56 PB11 43 VDDIO Normal
I/O TC1-CLK1 USART1-
RXD
ADCIFBTRIGGER
PWMAPWMA[34]
CATVDIVEN
EICEXTINT[5]
CATCSA[16]
5 7 PB12 44 VDDIO Normal
I/O TC1-CLK2 TWIMS1-
TWALM
CATSYNC
PWMAPWMA[35]
ACIFBACBP[3]
SCIFGCLK[4]
CATCSA[15]
15 22 PB13 45 VDDIN USB I/O USBC-DM USART3-
TXD TC1-A1 PWMAPWMA[7]
ADCIFBADP[1]
SCIFGCLK[5]
CATCSB[2]
16 23 PB14 46 VDDIN USB I/O USBC-DP USART3-
RXD TC1-B1 PWMAPWMA[24]
SCIFGCLK[5]
CATCSB[9]
Table 3-1. GPIO Controller Function Multiplexing
12
32142D–06/2013
ATUC64/128/256L3/4U
3.2 See Section 3.3 for a description of the various peripheral signals.
Refer to ”Electrical Characteristics” on page 897 for a description of the electrical properties of
the pin types used.
3.2.1 TWI, 5V Tolerant, and SMBUS Pins
Some normal I/O pins offer TWI, 5V tolerance, and SMBUS features. These features are only
available when either of the TWI functions or the PWMAOD function in the PWMA are selected
for these pins.
Refer to the ”Electrical Characteristics” on page 897 for a description of the electrical properties
of the TWI, 5V tolerance, and SMBUS pins.
57 PB15 47 VDDIO Highdrive
I/O
ABDACBCLK
IISCIMCK
SPI-SCK TC0-CLK2 PWMAPWMA[8]
SCIFGCLK[3]
CATCSB[4]
58 PB16 48 VDDIO Normal
I/O
ABDACBDAC[0]
IISC-ISCK USART0-
TXD
PWMAPWMA[9]
SCIFGCLK[2]
CATCSA[5]
59 PB17 49 VDDIO Normal
I/O
ABDACBDAC[1]
IISC-IWS USART0-
RXD
PWMAPWMA[10]
CATCSB[5]
60 PB18 50 VDDIO Normal
I/O
ABDACBDACN[0]
IISC-ISDI USART0-
RTS
PWMAPWMA[12]
CATCSA[0]
4 PB19 51 VDDIO Normal
I/O
ABDACBDACN[1]
IISC-ISDO USART0-
CTS
PWMAPWMA[20]
EICEXTINT[1]
CATCSA[12]
5 PB20 52 VDDIO Normal
I/O
TWIMS1-
TWD
USART2-
RXD
SPINPCS[1]
TC0-A0 PWMAPWMA[21]
USART1-
RTS
USART1-
CLK
CATCSA[14]
40 PB21 53 VDDIO Normal
I/O
TWIMS1-
TWCK
USART2-
TXD
SPINPCS[2]
TC0-B0 PWMAPWMA[28]
USART1-
CTS
USART1-
CLK
CATCSB[14]
41 PB22 54 VDDIO Normal
I/O
TWIMS1-
TWALM
SPINPCS[3]
TC0-CLK0 PWMAPWMA[27]
ADCIFBTRIGGER
SCIFGCLK[0]
CATCSA[8]
54 PB23 55 VDDIO Normal
I/O SPI-MISO USART2-
RTS
USART2-
CLK TC0-A2 PWMAPWMA[0]
CAT-SMP SCIFGCLK[6]
CATCSA[4]
55 PB24 56 VDDIO Normal
I/O SPI-MOSI USART2-
CTS
USART2-
CLK TC0-B2 PWMAPWMA[1]
ADCIFBADP[1]
SCIFGCLK[7]
CATCSA[2]
61 PB25 57 VDDIO Normal
I/O
SPINPCS[0]
USART1-
RXD TC0-A1 PWMAPWMA[2]
SCIFGCLK_IN[
2]
SCIFGCLK[8]
CATCSA[3]
21 PB26 58 VDDIO Normal
I/O SPI-SCK USART1-
TXD TC0-B1 PWMAPWMA[3]
ADCIFBADP[0]
SCIFGCLK[9]
CATCSB[3]
24 PB27 59 VDDIN Normal
I/O
USART1-
RXD TC0-CLK1 PWMAPWMA[4]
ADCIFBADP[1]
EICNMI
(EXTINT[0])
CATCSA[9]
Table 3-1. GPIO Controller Function Multiplexing
13
32142D–06/2013
ATUC64/128/256L3/4U
3.2.2 Peripheral Functions
Each GPIO line can be assigned to one of several peripheral functions. The following table
describes how the various peripheral functions are selected. The last listed function has priority
in case multiple functions are enabled on the same pin.
3.2.3 JTAG Port Connections
If the JTAG is enabled, the JTAG will take control over a number of pins, irrespectively of the I/O
Controller configuration.
3.2.4 Nexus OCD AUX Port Connections
If the OCD trace system is enabled, the trace system will take control over a number of pins, irrespectively
of the I/O Controller configuration. Two different OCD trace pin mappings are
possible, depending on the configuration of the OCD AXS register. For details, see the AVR32
UC Technical Reference Manual.
Table 3-2. Peripheral Functions
Function Description
GPIO Controller Function multiplexing GPIO and GPIO peripheral selection A to H
Nexus OCD AUX port connections OCD trace system
aWire DATAOUT aWire output in two-pin mode
JTAG port connections JTAG debug port
Oscillators OSC0, OSC32
Table 3-3. JTAG Pinout
48-pin 64-pin Pin name JTAG pin
11 15 PA00 TCK
14 18 PA01 TMS
13 17 PA02 TDO
4 6 PA03 TDI
Table 3-4. Nexus OCD AUX Port Connections
Pin AXS=1 AXS=0
EVTI_N PA05 PB08
MDO[5] PA10 PB00
MDO[4] PA18 PB04
MDO[3] PA17 PB05
MDO[2] PA16 PB03
MDO[1] PA15 PB02
MDO[0] PA14 PB09
14
32142D–06/2013
ATUC64/128/256L3/4U
3.2.5 Oscillator Pinout
The oscillators are not mapped to the normal GPIO functions and their muxings are controlled
by registers in the System Control Interface (SCIF). Please refer to the SCIF chapter for more
information about this.
3.2.6 Other Functions
The functions listed in Table 3-6 are not mapped to the normal GPIO functions. The aWire DATA
pin will only be active after the aWire is enabled. The aWire DATAOUT pin will only be active
after the aWire is enabled and the 2_PIN_MODE command has been sent. The WAKE_N pin is
always enabled. Please refer to Section 6.1.4.2 on page 44 for constraints on the WAKE_N pin.
EVTO_N PA04 PA04
MCKO PA06 PB01
MSEO[1] PA07 PB11
MSEO[0] PA11 PB12
Table 3-4. Nexus OCD AUX Port Connections
Pin AXS=1 AXS=0
Table 3-5. Oscillator Pinout
48-pin 64-pin Pin Name Oscillator Pin
3 3 PA08 XIN0
46 62 PA10 XIN32
26 34 PA13 XIN32_2
2 2 PA09 XOUT0
47 63 PA12 XOUT32
25 33 PA20 XOUT32_2
Table 3-6. Other Functions
48-pin 64-pin Pin Name Function
27 35 PA11 WAKE_N
22 30 RESET_N aWire DATA
11 15 PA00 aWire DATAOUT
15
32142D–06/2013
ATUC64/128/256L3/4U
3.3 Signal Descriptions
The following table gives details on signal name classified by peripheral.
Table 3-7. Signal Descriptions List
Signal Name Function Type
Active
Level Comments
Audio Bitstream DAC - ABDACB
CLK D/A Clock out Output
DAC1 - DAC0 D/A Bitstream out Output
DACN1 - DACN0 D/A Inverted bitstream out Output
Analog Comparator Interface - ACIFB
ACAN3 - ACAN0 Negative inputs for comparators "A" Analog
ACAP3 - ACAP0 Positive inputs for comparators "A" Analog
ACBN3 - ACBN0 Negative inputs for comparators "B" Analog
ACBP3 - ACBP0 Positive inputs for comparators "B" Analog
ACREFN Common negative reference Analog
ADC Interface - ADCIFB
AD8 - AD0 Analog Signal Analog
ADP1 - ADP0 Drive Pin for resistive touch screen Output
TRIGGER External trigger Input
aWire - AW
DATA aWire data I/O
DATAOUT aWire data output for 2-pin mode I/O
Capacitive Touch Module - CAT
CSA16 - CSA0 Capacitive Sense A I/O
CSB16 - CSB0 Capacitive Sense B I/O
DIS Discharge current control Analog
SMP SMP signal Output
SYNC Synchronize signal Input
VDIVEN Voltage divider enable Output
External Interrupt Controller - EIC
NMI (EXTINT0) Non-Maskable Interrupt Input
EXTINT5 - EXTINT1 External interrupt Input
Glue Logic Controller - GLOC
IN7 - IN0 Inputs to lookup tables Input
OUT1 - OUT0 Outputs from lookup tables Output
Inter-IC Sound (I2S) Controller - IISC
16
32142D–06/2013
ATUC64/128/256L3/4U
IMCK I2S Master Clock Output
ISCK I2S Serial Clock I/O
ISDI I2S Serial Data In Input
ISDO I2S Serial Data Out Output
IWS I2S Word Select I/O
JTAG module - JTAG
TCK Test Clock Input
TDI Test Data In Input
TDO Test Data Out Output
TMS Test Mode Select Input
Power Manager - PM
RESET_N Reset Input Low
Pulse Width Modulation Controller - PWMA
PWMA35 - PWMA0 PWMA channel waveforms Output
PWMAOD35 -
PWMAOD0
PWMA channel waveforms, open drain
mode Output Not all channels support open
drain mode
System Control Interface - SCIF
GCLK9 - GCLK0 Generic Clock Output Output
GCLK_IN2 - GCLK_IN0 Generic Clock Input Input
RC32OUT RC32K output at startup Output
XIN0 Crystal 0 Input Analog/
Digital
XIN32 Crystal 32 Input (primary location) Analog/
Digital
XIN32_2 Crystal 32 Input (secondary location) Analog/
Digital
XOUT0 Crystal 0 Output Analog
XOUT32 Crystal 32 Output (primary location) Analog
XOUT32_2 Crystal 32 Output (secondary location) Analog
Serial Peripheral Interface - SPI
MISO Master In Slave Out I/O
MOSI Master Out Slave In I/O
NPCS3 - NPCS0 SPI Peripheral Chip Select I/O Low
SCK Clock I/O
Timer/Counter - TC0, TC1
A0 Channel 0 Line A I/O
A1 Channel 1 Line A I/O
A2 Channel 2 Line A I/O
Table 3-7. Signal Descriptions List
17
32142D–06/2013
ATUC64/128/256L3/4U
Note: 1. ADCIFB: AD3 does not exist.
B0 Channel 0 Line B I/O
B1 Channel 1 Line B I/O
B2 Channel 2 Line B I/O
CLK0 Channel 0 External Clock Input Input
CLK1 Channel 1 External Clock Input Input
CLK2 Channel 2 External Clock Input Input
Two-wire Interface - TWIMS0, TWIMS1
TWALM SMBus SMBALERT I/O Low
TWCK Two-wire Serial Clock I/O
TWD Two-wire Serial Data I/O
Universal Synchronous Asynchronous Receiver Transmitter - USART0, USART1, USART2, USART3
CLK Clock I/O
CTS Clear To Send Input Low
RTS Request To Send Output Low
RXD Receive Data Input
TXD Transmit Data Output
Table 3-7. Signal Descriptions List
Table 3-8. Signal Description List, Continued
Signal Name Function Type
Active
Level Comments
Power
VDDCORE Core Power Supply / Voltage Regulator Output Power
Input/Output 1.62V to 1.98V
VDDIO I/O Power Supply Power Input
1.62V to 3.6V. VDDIO should
always be equal to or lower than
VDDIN.
VDDANA Analog Power Supply Power Input 1.62V to 1.98V
ADVREFP Analog Reference Voltage Power Input 1.62V to 1.98V
VDDIN Voltage Regulator Input Power Input 1.62V to 3.6V(1)
GNDANA Analog Ground Ground
GND Ground Ground
Auxiliary Port - AUX
MCKO Trace Data Output Clock Output
MDO5 - MDO0 Trace Data Output Output
18
32142D–06/2013
ATUC64/128/256L3/4U
Note: 1. See Section 6. on page 39
3.4 I/O Line Considerations
3.4.1 JTAG Pins
The JTAG is enabled if TCK is low while the RESET_N pin is released. The TCK, TMS, and TDI
pins have pull-up resistors when JTAG is enabled. The TCK pin always has pull-up enabled during
reset. The TDO pin is an output, driven at VDDIO, and has no pull-up resistor. The JTAG
pins can be used as GPIO pins and multiplexed with peripherals when the JTAG is disabled.
Please refer to Section 3.2.3 on page 13 for the JTAG port connections.
3.4.2 PA00
Note that PA00 is multiplexed with TCK. PA00 GPIO function must only be used as output in the
application.
3.4.3 RESET_N Pin
The RESET_N pin is a schmitt input and integrates a permanent pull-up resistor to VDDIN. As
the product integrates a power-on reset detector, the RESET_N pin can be left unconnected in
case no reset from the system needs to be applied to the product.
The RESET_N pin is also used for the aWire debug protocol. When the pin is used for debugging,
it must not be driven by external circuitry.
3.4.4 TWI Pins PA21/PB04/PB05
When these pins are used for TWI, the pins are open-drain outputs with slew-rate limitation and
inputs with spike filtering. When used as GPIO pins or used for other peripherals, the pins have
the same characteristics as other GPIO pins. Selected pins are also SMBus compliant (refer to
Section on page 10). As required by the SMBus specification, these pins provide no leakage
path to ground when the ATUC64/128/256L3/4U is powered down. This allows other devices on
the SMBus to continue communicating even though the ATUC64/128/256L3/4U is not powered.
After reset a TWI function is selected on these pins instead of the GPIO. Please refer to the
GPIO Module Configuration chapter for details.
MSEO1 - MSEO0 Trace Frame Control Output
EVTI_N Event In Input Low
EVTO_N Event Out Output Low
General Purpose I/O pin
PA22 - PA00 Parallel I/O Controller I/O Port 0 I/O
PB27 - PB00 Parallel I/O Controller I/O Port 1 I/O
Table 3-8. Signal Description List, Continued
Signal Name Function Type
Active
Level Comments
19
32142D–06/2013
ATUC64/128/256L3/4U
3.4.5 TWI Pins PA05/PA07/PA17
When these pins are used for TWI, the pins are open-drain outputs with slew-rate limitation and
inputs with spike filtering. When used as GPIO pins or used for other peripherals, the pins have
the same characteristics as other GPIO pins.
After reset a TWI function is selected on these pins instead of the GPIO. Please refer to the
GPIO Module Configuration chapter for details.
3.4.6 GPIO Pins
All the I/O lines integrate a pull-up resistor Programming of this pull-up resistor is performed
independently for each I/O line through the GPIO Controllers. After reset, I/O lines default as
inputs with pull-up resistors disabled, except PA00 which has the pull-up resistor enabled. PA20
selects SCIF-RC32OUT (GPIO Function F) as default enabled after reset.
3.4.7 High-drive Pins
The six pins PA02, PA06, PA08, PA09, PB01, and PB15 have high-drive output capabilities.
Refer to Section 35. on page 897 for electrical characteristics.
3.4.8 USB Pins PB13/PB14
When these pins are used for USB, the pins are behaving according to the USB specification.
When used as GPIO pins or used for other peripherals, the pins have the same behaviour as
other normal I/O pins, but the characteristics are different. Refer to Section 35. on page 897 for
electrical characteristics.
To be able to use the USB I/O the VDDIN power supply must be 3.3V nominal.
3.4.9 RC32OUT Pin
3.4.9.1 Clock output at startup
After power-up, the clock generated by the 32kHz RC oscillator (RC32K) will be output on PA20,
even when the device is still reset by the Power-On Reset Circuitry. This clock can be used by
the system to start other devices or to clock a switching regulator to rise the power supply voltage
up to an acceptable value.
The clock will be available on PA20, but will be disabled if one of the following conditions are
true:
• PA20 is configured to use a GPIO function other than F (SCIF-RC32OUT)
• PA20 is configured as a General Purpose Input/Output (GPIO)
• The bit FRC32 in the Power Manager PPCR register is written to zero (refer to the Power
Manager chapter)
The maximum amplitude of the clock signal will be defined by VDDIN.
Once the RC32K output on PA20 is disabled it can never be enabled again.
3.4.9.2 XOUT32_2 function
PA20 selects RC32OUT as default enabled after reset. This function is not automatically disabled
when the user enables the XOUT32_2 function on PA20. This disturbs the oscillator and
may result in the wrong frequency. To avoid this, RC32OUT must be disabled when XOUT32_2
is enabled.
20
32142D–06/2013
ATUC64/128/256L3/4U
3.4.10 ADC Input Pins
These pins are regular I/O pins powered from the VDDIO. However, when these pins are used
for ADC inputs, the voltage applied to the pin must not exceed 1.98V. Internal circuitry ensures
that the pin cannot be used as an analog input pin when the I/O drives to VDD. When the pins
are not used for ADC inputs, the pins may be driven to the full I/O voltage range.
21
32142D–06/2013
ATUC64/128/256L3/4U
4. Processor and Architecture
Rev: 2.1.2.0
This chapter gives an overview of the AVR32UC CPU. AVR32UC is an implementation of the
AVR32 architecture. A summary of the programming model, instruction set, and MPU is presented.
For further details, see the AVR32 Architecture Manual and the AVR32UC Technical
Reference Manual.
4.1 Features
• 32-bit load/store AVR32A RISC architecture
– 15 general-purpose 32-bit registers
– 32-bit Stack Pointer, Program Counter and Link Register reside in register file
– Fully orthogonal instruction set
– Privileged and unprivileged modes enabling efficient and secure operating systems
– Innovative instruction set together with variable instruction length ensuring industry leading
code density
– DSP extension with saturating arithmetic, and a wide variety of multiply instructions
• 3-stage pipeline allowing one instruction per clock cycle for most instructions
– Byte, halfword, word, and double word memory access
– Multiple interrupt priority levels
• MPU allows for operating systems with memory protection
• Secure State for supporting FlashVault technology
4.2 AVR32 Architecture
AVR32 is a new, high-performance 32-bit RISC microprocessor architecture, designed for costsensitive
embedded applications, with particular emphasis on low power consumption and high
code density. In addition, the instruction set architecture has been tuned to allow a variety of
microarchitectures, enabling the AVR32 to be implemented as low-, mid-, or high-performance
processors. AVR32 extends the AVR family into the world of 32- and 64-bit applications.
Through a quantitative approach, a large set of industry recognized benchmarks has been compiled
and analyzed to achieve the best code density in its class. In addition to lowering the
memory requirements, a compact code size also contributes to the core’s low power characteristics.
The processor supports byte and halfword data types without penalty in code size and
performance.
Memory load and store operations are provided for byte, halfword, word, and double word data
with automatic sign- or zero extension of halfword and byte data. The C-compiler is closely
linked to the architecture and is able to exploit code optimization features, both for size and
speed.
In order to reduce code size to a minimum, some instructions have multiple addressing modes.
As an example, instructions with immediates often have a compact format with a smaller immediate,
and an extended format with a larger immediate. In this way, the compiler is able to use
the format giving the smallest code size.
Another feature of the instruction set is that frequently used instructions, like add, have a compact
format with two operands as well as an extended format with three operands. The larger
format increases performance, allowing an addition and a data move in the same instruction in a
22
32142D–06/2013
ATUC64/128/256L3/4U
single cycle. Load and store instructions have several different formats in order to reduce code
size and speed up execution.
The register file is organized as sixteen 32-bit registers and includes the Program Counter, the
Link Register, and the Stack Pointer. In addition, register R12 is designed to hold return values
from function calls and is used implicitly by some instructions.
4.3 The AVR32UC CPU
The AVR32UC CPU targets low- and medium-performance applications, and provides an
advanced On-Chip Debug (OCD) system, no caches, and a Memory Protection Unit (MPU).
Java acceleration hardware is not implemented.
AVR32UC provides three memory interfaces, one High Speed Bus master for instruction fetch,
one High Speed Bus master for data access, and one High Speed Bus slave interface allowing
other bus masters to access data RAMs internal to the CPU. Keeping data RAMs internal to the
CPU allows fast access to the RAMs, reduces latency, and guarantees deterministic timing.
Also, power consumption is reduced by not needing a full High Speed Bus access for memory
accesses. A dedicated data RAM interface is provided for communicating with the internal data
RAMs.
A local bus interface is provided for connecting the CPU to device-specific high-speed systems,
such as floating-point units and I/O controller ports. This local bus has to be enabled by writing a
one to the LOCEN bit in the CPUCR system register. The local bus is able to transfer data
between the CPU and the local bus slave in a single clock cycle. The local bus has a dedicated
memory range allocated to it, and data transfers are performed using regular load and store
instructions. Details on which devices that are mapped into the local bus space is given in the
CPU Local Bus section in the Memories chapter.
Figure 4-1 on page 23 displays the contents of AVR32UC.
23
32142D–06/2013
ATUC64/128/256L3/4U
Figure 4-1. Overview of the AVR32UC CPU
4.3.1 Pipeline Overview
AVR32UC has three pipeline stages, Instruction Fetch (IF), Instruction Decode (ID), and Instruction
Execute (EX). The EX stage is split into three parallel subsections, one arithmetic/logic
(ALU) section, one multiply (MUL) section, and one load/store (LS) section.
Instructions are issued and complete in order. Certain operations require several clock cycles to
complete, and in this case, the instruction resides in the ID and EX stages for the required number
of clock cycles. Since there is only three pipeline stages, no internal data forwarding is
required, and no data dependencies can arise in the pipeline.
Figure 4-2 on page 24 shows an overview of the AVR32UC pipeline stages.
AVR32UC CPU pipeline
Instruction memory controller
MPU
High Speed Bus
High Speed Bus
OCD
systemOCD interface
Interrupt controller interface
High
Speed
Bus slave High Speed Bus
High Speed Bus master
Power/
Reset
control Reset interface
CPU Local
Bus
master CPU Local Bus
Data memory controller
CPU RAM High Speed
Bus master
24
32142D–06/2013
ATUC64/128/256L3/4U
Figure 4-2. The AVR32UC Pipeline
4.3.2 AVR32A Microarchitecture Compliance
AVR32UC implements an AVR32A microarchitecture. The AVR32A microarchitecture is targeted
at cost-sensitive, lower-end applications like smaller microcontrollers. This
microarchitecture does not provide dedicated hardware registers for shadowing of register file
registers in interrupt contexts. Additionally, it does not provide hardware registers for the return
address registers and return status registers. Instead, all this information is stored on the system
stack. This saves chip area at the expense of slower interrupt handling.
4.3.2.1 Interrupt Handling
Upon interrupt initiation, registers R8-R12 are automatically pushed to the system stack. These
registers are pushed regardless of the priority level of the pending interrupt. The return address
and status register are also automatically pushed to stack. The interrupt handler can therefore
use R8-R12 freely. Upon interrupt completion, the old R8-R12 registers and status register are
restored, and execution continues at the return address stored popped from stack.
The stack is also used to store the status register and return address for exceptions and scall.
Executing the rete or rets instruction at the completion of an exception or system call will pop
this status register and continue execution at the popped return address.
4.3.2.2 Java Support
AVR32UC does not provide Java hardware acceleration.
4.3.2.3 Memory Protection
The MPU allows the user to check all memory accesses for privilege violations. If an access is
attempted to an illegal memory address, the access is aborted and an exception is taken. The
MPU in AVR32UC is specified in the AVR32UC Technical Reference manual.
4.3.2.4 Unaligned Reference Handling
AVR32UC does not support unaligned accesses, except for doubleword accesses. AVR32UC is
able to perform word-aligned st.d and ld.d. Any other unaligned memory access will cause an
IF ID ALU
MUL
Regfile
write
Prefetch unit Decode unit
ALU unit
Multiply unit
Load-store
unit LS
Regfile
Read
25
32142D–06/2013
ATUC64/128/256L3/4U
address exception. Doubleword-sized accesses with word-aligned pointers will automatically be
performed as two word-sized accesses.
The following table shows the instructions with support for unaligned addresses. All other
instructions require aligned addresses.
4.3.2.5 Unimplemented Instructions
The following instructions are unimplemented in AVR32UC, and will cause an Unimplemented
Instruction Exception if executed:
• All SIMD instructions
• All coprocessor instructions if no coprocessors are present
• retj, incjosp, popjc, pushjc
• tlbr, tlbs, tlbw
• cache
4.3.2.6 CPU and Architecture Revision
Three major revisions of the AVR32UC CPU currently exist. The device described in this
datasheet uses CPU revision 3.
The Architecture Revision field in the CONFIG0 system register identifies which architecture
revision is implemented in a specific device.
AVR32UC CPU revision 3 is fully backward-compatible with revisions 1 and 2, ie. code compiled
for revision 1 or 2 is binary-compatible with revision 3 CPUs.
Table 4-1. Instructions with Unaligned Reference Support
Instruction Supported Alignment
ld.d Word
st.d Word
26
32142D–06/2013
ATUC64/128/256L3/4U
4.4 Programming Model
4.4.1 Register File Configuration
The AVR32UC register file is shown below.
Figure 4-3. The AVR32UC Register File
4.4.2 Status Register Configuration
The Status Register (SR) is split into two halfwords, one upper and one lower, see Figure 4-4
and Figure 4-5. The lower word contains the C, Z, N, V, and Q condition code flags and the R, T,
and L bits, while the upper halfword contains information about the mode and state the processor
executes in. Refer to the AVR32 Architecture Manual for details.
Figure 4-4. The Status Register High Halfword
Application
Bit 0
Supervisor
Bit 31
PC
SR
INT0PC
FINTPC
INT1PC
SMPC
R7
R5
R6
R4
R3
R1
R2
R0
Bit 31 Bit 0
PC
SR
R12
INT0PC
FINTPC
INT1PC
SMPC
R7
R5
R6
R4
R11
R9
R10
R8
R3
R1
R2
R0
INT0
SP_APP SP_SYS
R12
R11
R9
R10
R8
INT1 INT2 INT3 Exception NMI
LR LR
Bit 31 Bit 0
PC
SR
R12
INT0PC
FINTPC
INT1PC
SMPC
R7
R5
R6
R4
R11
R9
R10
R8
R3
R1
R2
R0
SP_SYS
LR
Bit 31 Bit 0
PC
SR
R12
INT0PC
FINTPC
INT1PC
SMPC
R7
R5
R6
R4
R11
R9
R10
R8
R3
R1
R2
R0
SP_SYS
LR
Bit 31 Bit 0
PC
SR
R12
INT0PC
FINTPC
INT1PC
SMPC
R7
R5
R6
R4
R11
R9
R10
R8
R3
R1
R2
R0
SP_SYS
LR
Bit 31 Bit 0
PC
SR
R12
INT0PC
FINTPC
INT1PC
SMPC
R7
R5
R6
R4
R11
R9
R10
R8
R3
R1
R2
R0
SP_SYS
LR
Bit 31 Bit 0
PC
SR
R12
INT0PC
FINTPC
INT1PC
SMPC
R7
R5
R6
R4
R11
R9
R10
R8
R3
R1
R2
R0
SP_SYS
LR
Bit 31 Bit 0
PC
SR
R12
INT0PC
FINTPC
INT1PC
SMPC
R7
R5
R6
R4
R11
R9
R10
R8
R3
R1
R2
R0
SP_SYS
LR
Secure
Bit 31 Bit 0
PC
SR
R12
INT0PC
FINTPC
INT1PC
SMPC
R7
R5
R6
R4
R11
R9
R10
R8
R3
R1
R2
R0
SP_SEC
LR
SS_STATUS
SS_ADRF
SS_ADRR
SS_ADR0
SS_ADR1
SS_SP_SYS
SS_SP_APP
SS_RAR
SS_RSR
Bit 31
0 0 0
Bit 16
Interrupt Level 0 Mask
Interrupt Level 1 Mask
Interrupt Level 3 Mask
Interrupt Level 2 Mask
0 0 0 0 0 0 1 1 0 0 0 0 1
- DM D - M2 M1 M0 EM I2MFE I0M GM LC
1 SS
Initial value
I1M Bit name
Mode Bit 0
Mode Bit 1
-
Mode Bit 2
Reserved
Debug State
- I3M
Reserved
Exception Mask
Global Interrupt Mask
Debug State Mask
Secure State
27
32142D–06/2013
ATUC64/128/256L3/4U
Figure 4-5. The Status Register Low Halfword
4.4.3 Processor States
4.4.3.1 Normal RISC State
The AVR32 processor supports several different execution contexts as shown in Table 4-2.
Mode changes can be made under software control, or can be caused by external interrupts or
exception processing. A mode can be interrupted by a higher priority mode, but never by one
with lower priority. Nested exceptions can be supported with a minimal software overhead.
When running an operating system on the AVR32, user processes will typically execute in the
application mode. The programs executed in this mode are restricted from executing certain
instructions. Furthermore, most system registers together with the upper halfword of the status
register cannot be accessed. Protected memory areas are also not available. All other operating
modes are privileged and are collectively called System Modes. They have full access to all privileged
and unprivileged resources. After a reset, the processor will be in supervisor mode.
4.4.3.2 Debug State
The AVR32 can be set in a debug state, which allows implementation of software monitor routines
that can read out and alter system information for use during application development. This
implies that all system and application registers, including the status registers and program
counters, are accessible in debug state. The privileged instructions are also available.
All interrupt levels are by default disabled when debug state is entered, but they can individually
be switched on by the monitor routine by clearing the respective mask bit in the status register.
Bit 15 Bit 0
Reserved
Carry
Zero
Sign
0 0 0 0 0 0 0 0 0 0 0 0 0 0
- T - - - - Bit name
0 0 Initial value
- L Q V N Z C
Overflow
Saturation
- - -
Lock
Reserved
Scratch
Table 4-2. Overview of Execution Modes, their Priorities and Privilege Levels.
Priority Mode Security Description
1 Non Maskable Interrupt Privileged Non Maskable high priority interrupt mode
2 Exception Privileged Execute exceptions
3 Interrupt 3 Privileged General purpose interrupt mode
4 Interrupt 2 Privileged General purpose interrupt mode
5 Interrupt 1 Privileged General purpose interrupt mode
6 Interrupt 0 Privileged General purpose interrupt mode
N/A Supervisor Privileged Runs supervisor calls
N/A Application Unprivileged Normal program execution mode
28
32142D–06/2013
ATUC64/128/256L3/4U
Debug state can be entered as described in the AVR32UC Technical Reference Manual.
Debug state is exited by the retd instruction.
4.4.3.3 Secure State
The AVR32 can be set in a secure state, that allows a part of the code to execute in a state with
higher security levels. The rest of the code can not access resources reserved for this secure
code. Secure State is used to implement FlashVault technology. Refer to the AVR32UC Technical
Reference Manual for details.
4.4.4 System Registers
The system registers are placed outside of the virtual memory space, and are only accessible
using the privileged mfsr and mtsr instructions. The table below lists the system registers specified
in the AVR32 architecture, some of which are unused in AVR32UC. The programmer is
responsible for maintaining correct sequencing of any instructions following a mtsr instruction.
For detail on the system registers, refer to the AVR32UC Technical Reference Manual.
Table 4-3. System Registers
Reg # Address Name Function
0 0 SR Status Register
1 4 EVBA Exception Vector Base Address
2 8 ACBA Application Call Base Address
3 12 CPUCR CPU Control Register
4 16 ECR Exception Cause Register
5 20 RSR_SUP Unused in AVR32UC
6 24 RSR_INT0 Unused in AVR32UC
7 28 RSR_INT1 Unused in AVR32UC
8 32 RSR_INT2 Unused in AVR32UC
9 36 RSR_INT3 Unused in AVR32UC
10 40 RSR_EX Unused in AVR32UC
11 44 RSR_NMI Unused in AVR32UC
12 48 RSR_DBG Return Status Register for Debug mode
13 52 RAR_SUP Unused in AVR32UC
14 56 RAR_INT0 Unused in AVR32UC
15 60 RAR_INT1 Unused in AVR32UC
16 64 RAR_INT2 Unused in AVR32UC
17 68 RAR_INT3 Unused in AVR32UC
18 72 RAR_EX Unused in AVR32UC
19 76 RAR_NMI Unused in AVR32UC
20 80 RAR_DBG Return Address Register for Debug mode
21 84 JECR Unused in AVR32UC
22 88 JOSP Unused in AVR32UC
23 92 JAVA_LV0 Unused in AVR32UC
29
32142D–06/2013
ATUC64/128/256L3/4U
24 96 JAVA_LV1 Unused in AVR32UC
25 100 JAVA_LV2 Unused in AVR32UC
26 104 JAVA_LV3 Unused in AVR32UC
27 108 JAVA_LV4 Unused in AVR32UC
28 112 JAVA_LV5 Unused in AVR32UC
29 116 JAVA_LV6 Unused in AVR32UC
30 120 JAVA_LV7 Unused in AVR32UC
31 124 JTBA Unused in AVR32UC
32 128 JBCR Unused in AVR32UC
33-63 132-252 Reserved Reserved for future use
64 256 CONFIG0 Configuration register 0
65 260 CONFIG1 Configuration register 1
66 264 COUNT Cycle Counter register
67 268 COMPARE Compare register
68 272 TLBEHI Unused in AVR32UC
69 276 TLBELO Unused in AVR32UC
70 280 PTBR Unused in AVR32UC
71 284 TLBEAR Unused in AVR32UC
72 288 MMUCR Unused in AVR32UC
73 292 TLBARLO Unused in AVR32UC
74 296 TLBARHI Unused in AVR32UC
75 300 PCCNT Unused in AVR32UC
76 304 PCNT0 Unused in AVR32UC
77 308 PCNT1 Unused in AVR32UC
78 312 PCCR Unused in AVR32UC
79 316 BEAR Bus Error Address Register
80 320 MPUAR0 MPU Address Register region 0
81 324 MPUAR1 MPU Address Register region 1
82 328 MPUAR2 MPU Address Register region 2
83 332 MPUAR3 MPU Address Register region 3
84 336 MPUAR4 MPU Address Register region 4
85 340 MPUAR5 MPU Address Register region 5
86 344 MPUAR6 MPU Address Register region 6
87 348 MPUAR7 MPU Address Register region 7
88 352 MPUPSR0 MPU Privilege Select Register region 0
89 356 MPUPSR1 MPU Privilege Select Register region 1
Table 4-3. System Registers (Continued)
Reg # Address Name Function
30
32142D–06/2013
ATUC64/128/256L3/4U
4.5 Exceptions and Interrupts
In the AVR32 architecture, events are used as a common term for exceptions and interrupts.
AVR32UC incorporates a powerful event handling scheme. The different event sources, like Illegal
Op-code and interrupt requests, have different priority levels, ensuring a well-defined
behavior when multiple events are received simultaneously. Additionally, pending events of a
higher priority class may preempt handling of ongoing events of a lower priority class.
When an event occurs, the execution of the instruction stream is halted, and execution is passed
to an event handler at an address specified in Table 4-4 on page 34. Most of the handlers are
placed sequentially in the code space starting at the address specified by EVBA, with four bytes
between each handler. This gives ample space for a jump instruction to be placed there, jumping
to the event routine itself. A few critical handlers have larger spacing between them, allowing
the entire event routine to be placed directly at the address specified by the EVBA-relative offset
generated by hardware. All interrupt sources have autovectored interrupt service routine (ISR)
addresses. This allows the interrupt controller to directly specify the ISR address as an address
90 360 MPUPSR2 MPU Privilege Select Register region 2
91 364 MPUPSR3 MPU Privilege Select Register region 3
92 368 MPUPSR4 MPU Privilege Select Register region 4
93 372 MPUPSR5 MPU Privilege Select Register region 5
94 376 MPUPSR6 MPU Privilege Select Register region 6
95 380 MPUPSR7 MPU Privilege Select Register region 7
96 384 MPUCRA Unused in this version of AVR32UC
97 388 MPUCRB Unused in this version of AVR32UC
98 392 MPUBRA Unused in this version of AVR32UC
99 396 MPUBRB Unused in this version of AVR32UC
100 400 MPUAPRA MPU Access Permission Register A
101 404 MPUAPRB MPU Access Permission Register B
102 408 MPUCR MPU Control Register
103 412 SS_STATUS Secure State Status Register
104 416 SS_ADRF Secure State Address Flash Register
105 420 SS_ADRR Secure State Address RAM Register
106 424 SS_ADR0 Secure State Address 0 Register
107 428 SS_ADR1 Secure State Address 1 Register
108 432 SS_SP_SYS Secure State Stack Pointer System Register
109 436 SS_SP_APP Secure State Stack Pointer Application Register
110 440 SS_RAR Secure State Return Address Register
111 444 SS_RSR Secure State Return Status Register
112-191 448-764 Reserved Reserved for future use
192-255 768-1020 IMPL IMPLEMENTATION DEFINED
Table 4-3. System Registers (Continued)
Reg # Address Name Function
31
32142D–06/2013
ATUC64/128/256L3/4U
relative to EVBA. The autovector offset has 14 address bits, giving an offset of maximum 16384
bytes. The target address of the event handler is calculated as (EVBA | event_handler_offset),
not (EVBA + event_handler_offset), so EVBA and exception code segments must be set up
appropriately. The same mechanisms are used to service all different types of events, including
interrupt requests, yielding a uniform event handling scheme.
An interrupt controller does the priority handling of the interrupts and provides the autovector offset
to the CPU.
4.5.1 System Stack Issues
Event handling in AVR32UC uses the system stack pointed to by the system stack pointer,
SP_SYS, for pushing and popping R8-R12, LR, status register, and return address. Since event
code may be timing-critical, SP_SYS should point to memory addresses in the IRAM section,
since the timing of accesses to this memory section is both fast and deterministic.
The user must also make sure that the system stack is large enough so that any event is able to
push the required registers to stack. If the system stack is full, and an event occurs, the system
will enter an UNDEFINED state.
4.5.2 Exceptions and Interrupt Requests
When an event other than scall or debug request is received by the core, the following actions
are performed atomically:
1. The pending event will not be accepted if it is masked. The I3M, I2M, I1M, I0M, EM, and
GM bits in the Status Register are used to mask different events. Not all events can be
masked. A few critical events (NMI, Unrecoverable Exception, TLB Multiple Hit, and
Bus Error) can not be masked. When an event is accepted, hardware automatically
sets the mask bits corresponding to all sources with equal or lower priority. This inhibits
acceptance of other events of the same or lower priority, except for the critical events
listed above. Software may choose to clear some or all of these bits after saving the
necessary state if other priority schemes are desired. It is the event source’s responsability
to ensure that their events are left pending until accepted by the CPU.
2. When a request is accepted, the Status Register and Program Counter of the current
context is stored to the system stack. If the event is an INT0, INT1, INT2, or INT3, registers
R8-R12 and LR are also automatically stored to stack. Storing the Status
Register ensures that the core is returned to the previous execution mode when the
current event handling is completed. When exceptions occur, both the EM and GM bits
are set, and the application may manually enable nested exceptions if desired by clearing
the appropriate bit. Each exception handler has a dedicated handler address, and
this address uniquely identifies the exception source.
3. The Mode bits are set to reflect the priority of the accepted event, and the correct register
file bank is selected. The address of the event handler, as shown in Table 4-4 on
page 34, is loaded into the Program Counter.
The execution of the event handler routine then continues from the effective address calculated.
The rete instruction signals the end of the event. When encountered, the Return Status Register
and Return Address Register are popped from the system stack and restored to the Status Register
and Program Counter. If the rete instruction returns from INT0, INT1, INT2, or INT3,
registers R8-R12 and LR are also popped from the system stack. The restored Status Register
contains information allowing the core to resume operation in the previous execution mode. This
concludes the event handling.
32
32142D–06/2013
ATUC64/128/256L3/4U
4.5.3 Supervisor Calls
The AVR32 instruction set provides a supervisor mode call instruction. The scall instruction is
designed so that privileged routines can be called from any context. This facilitates sharing of
code between different execution modes. The scall mechanism is designed so that a minimal
execution cycle overhead is experienced when performing supervisor routine calls from timecritical
event handlers.
The scall instruction behaves differently depending on which mode it is called from. The behaviour
is detailed in the instruction set reference. In order to allow the scall routine to return to the
correct context, a return from supervisor call instruction, rets, is implemented. In the AVR32UC
CPU, scall and rets uses the system stack to store the return address and the status register.
4.5.4 Debug Requests
The AVR32 architecture defines a dedicated Debug mode. When a debug request is received by
the core, Debug mode is entered. Entry into Debug mode can be masked by the DM bit in the
status register. Upon entry into Debug mode, hardware sets the SR.D bit and jumps to the
Debug Exception handler. By default, Debug mode executes in the exception context, but with
dedicated Return Address Register and Return Status Register. These dedicated registers
remove the need for storing this data to the system stack, thereby improving debuggability. The
Mode bits in the Status Register can freely be manipulated in Debug mode, to observe registers
in all contexts, while retaining full privileges.
Debug mode is exited by executing the retd instruction. This returns to the previous context.
4.5.5 Entry Points for Events
Several different event handler entry points exist. In AVR32UC, the reset address is
0x80000000. This places the reset address in the boot flash memory area.
TLB miss exceptions and scall have a dedicated space relative to EVBA where their event handler
can be placed. This speeds up execution by removing the need for a jump instruction placed
at the program address jumped to by the event hardware. All other exceptions have a dedicated
event routine entry point located relative to EVBA. The handler routine address identifies the
exception source directly.
AVR32UC uses the ITLB and DTLB protection exceptions to signal a MPU protection violation.
ITLB and DTLB miss exceptions are used to signal that an access address did not map to any of
the entries in the MPU. TLB multiple hit exception indicates that an access address did map to
multiple TLB entries, signalling an error.
All interrupt requests have entry points located at an offset relative to EVBA. This autovector offset
is specified by an interrupt controller. The programmer must make sure that none of the
autovector offsets interfere with the placement of other code. The autovector offset has 14
address bits, giving an offset of maximum 16384 bytes.
Special considerations should be made when loading EVBA with a pointer. Due to security considerations,
the event handlers should be located in non-writeable flash memory, or optionally in
a privileged memory protection region if an MPU is present.
If several events occur on the same instruction, they are handled in a prioritized way. The priority
ordering is presented in Table 4-4 on page 34. If events occur on several instructions at different
locations in the pipeline, the events on the oldest instruction are always handled before any
events on any younger instruction, even if the younger instruction has events of higher priority
33
32142D–06/2013
ATUC64/128/256L3/4U
than the oldest instruction. An instruction B is younger than an instruction A if it was sent down
the pipeline later than A.
The addresses and priority of simultaneous events are shown in Table 4-4 on page 34. Some of
the exceptions are unused in AVR32UC since it has no MMU, coprocessor interface, or floatingpoint
unit.
34
32142D–06/2013
ATUC64/128/256L3/4U
Table 4-4. Priority and Handler Addresses for Events
Priority Handler Address Name Event source Stored Return Address
1 0x80000000 Reset External input Undefined
2 Provided by OCD system OCD Stop CPU OCD system First non-completed instruction
3 EVBA+0x00 Unrecoverable exception Internal PC of offending instruction
4 EVBA+0x04 TLB multiple hit MPU PC of offending instruction
5 EVBA+0x08 Bus error data fetch Data bus First non-completed instruction
6 EVBA+0x0C Bus error instruction fetch Data bus First non-completed instruction
7 EVBA+0x10 NMI External input First non-completed instruction
8 Autovectored Interrupt 3 request External input First non-completed instruction
9 Autovectored Interrupt 2 request External input First non-completed instruction
10 Autovectored Interrupt 1 request External input First non-completed instruction
11 Autovectored Interrupt 0 request External input First non-completed instruction
12 EVBA+0x14 Instruction Address CPU PC of offending instruction
13 EVBA+0x50 ITLB Miss MPU PC of offending instruction
14 EVBA+0x18 ITLB Protection MPU PC of offending instruction
15 EVBA+0x1C Breakpoint OCD system First non-completed instruction
16 EVBA+0x20 Illegal Opcode Instruction PC of offending instruction
17 EVBA+0x24 Unimplemented instruction Instruction PC of offending instruction
18 EVBA+0x28 Privilege violation Instruction PC of offending instruction
19 EVBA+0x2C Floating-point UNUSED
20 EVBA+0x30 Coprocessor absent Instruction PC of offending instruction
21 EVBA+0x100 Supervisor call Instruction PC(Supervisor Call) +2
22 EVBA+0x34 Data Address (Read) CPU PC of offending instruction
23 EVBA+0x38 Data Address (Write) CPU PC of offending instruction
24 EVBA+0x60 DTLB Miss (Read) MPU PC of offending instruction
25 EVBA+0x70 DTLB Miss (Write) MPU PC of offending instruction
26 EVBA+0x3C DTLB Protection (Read) MPU PC of offending instruction
27 EVBA+0x40 DTLB Protection (Write) MPU PC of offending instruction
28 EVBA+0x44 DTLB Modified UNUSED
35
32142D–06/2013
ATUC64/128/256L3/4U
5. Memories
5.1 Embedded Memories
• Internal high-speed flash
– 256Kbytes (ATUC256L3U, ATUC256L4U)
– 128Kbytes (ATUC128L3U, ATUC128L4U)
– 64Kbytes (ATUC64L3U, ATUC64L4U)
• 0 wait state access at up to 25MHz in worst case conditions
• 1 wait state access at up to 50MHz in worst case conditions
• Pipelined flash architecture, allowing burst reads from sequential flash locations, hiding
penalty of 1 wait state access
• Pipelined flash architecture typically reduces the cycle penalty of 1 wait state operation
to only 8% compared to 0 wait state operation
• 100 000 write cycles, 15-year data retention capability
• Sector lock capabilities, bootloader protection, security bit
• 32 fuses, erased during chip erase
• User page for data to be preserved during chip erase
• Internal high-speed SRAM, single-cycle access at full speed
– 32Kbytes (ATUC256L3U, ATUC256L4U, ATUC128L3U, ATUC128L4U)
– 16Kbytes (ATUC64L3U, ATUC64L4U)
5.2 Physical Memory Map
The system bus is implemented as a bus matrix. All system bus addresses are fixed, and they
are never remapped in any way, not even during boot. Note that AVR32 UC CPU uses unsegmented
translation, as described in the AVR32 Architecture Manual. The 32-bit physical address
space is mapped as follows:
Table 5-1. ATUC64/128/256L3/4U Physical Memory Map
Memory Start Address
Size
ATUC256L3U, ATUC256L4U ATUC128L3U, ATUC128L4U ATUC64L3U, ATUC64L4U
Embedded SRAM 0x00000000 32Kbytes 32Kbytes 16Kbytes
Embedded Flash 0x80000000 256Kbytes 128Kbytes 64Kbytes
SAU Channels 0x90000000 256 bytes 256 bytes 256 bytes
HSB-PB Bridge B 0xFFFE0000 64Kbytes 64Kbytes 64Kbytes
HSB-PB Bridge A 0xFFFF0000 64Kbytes 64Kbytes 64Kbytes
Table 5-2. Flash Memory Parameters
Device Flash Size (FLASH_PW) Number of Pages (FLASH_P) Page Size (FLASH_W)
ATUC256L3U,
ATUC256L4U 256Kbytes 512 512 bytes
ATUC128L3U,
ATUC128L4U 128Kbytes 256 512 bytes
ATUC64L3U,
ATUC64L4U 64Kbytes 128 512 bytes
36
32142D–06/2013
ATUC64/128/256L3/4U
5.3 Peripheral Address Map
Table 5-3. Peripheral Address Mapping
Address Peripheral Name
0xFFFE0000
FLASHCDW Flash Controller - FLASHCDW
0xFFFE0400
HMATRIX HSB Matrix - HMATRIX
0xFFFE0800
SAU Secure Access Unit - SAU
0xFFFE1000
USBC USB 2.0 Interface - USBC
0xFFFF0000
PDCA Peripheral DMA Controller - PDCA
0xFFFF1000
INTC Interrupt controller - INTC
0xFFFF1400
PM Power Manager - PM
0xFFFF1800
SCIF System Control Interface - SCIF
0xFFFF1C00
AST Asynchronous Timer - AST
0xFFFF2000
WDT Watchdog Timer - WDT
0xFFFF2400
EIC External Interrupt Controller - EIC
0xFFFF2800
FREQM Frequency Meter - FREQM
0xFFFF2C00
GPIO General-Purpose Input/Output Controller - GPIO
0xFFFF3000
USART0 Universal Synchronous Asynchronous Receiver
Transmitter - USART0
0xFFFF3400
USART1 Universal Synchronous Asynchronous Receiver
Transmitter - USART1
0xFFFF3800
USART2 Universal Synchronous Asynchronous Receiver
Transmitter - USART2
0xFFFF3C00
USART3 Universal Synchronous Asynchronous Receiver
Transmitter - USART3
0xFFFF4000
SPI Serial Peripheral Interface - SPI
37
32142D–06/2013
ATUC64/128/256L3/4U
5.4 CPU Local Bus Mapping
Some of the registers in the GPIO module are mapped onto the CPU local bus, in addition to
being mapped on the Peripheral Bus. These registers can therefore be reached both by
accesses on the Peripheral Bus, and by accesses on the local bus.
Mapping these registers on the local bus allows cycle-deterministic toggling of GPIO pins since
the CPU and GPIO are the only modules connected to this bus. Also, since the local bus runs at
CPU speed, one write or read operation can be performed per clock cycle to the local busmapped
GPIO registers.
0xFFFF4400
TWIM0 Two-wire Master Interface - TWIM0
0xFFFF4800
TWIM1 Two-wire Master Interface - TWIM1
0xFFFF4C00
TWIS0 Two-wire Slave Interface - TWIS0
0xFFFF5000
TWIS1 Two-wire Slave Interface - TWIS1
0xFFFF5400
PWMA Pulse Width Modulation Controller - PWMA
0xFFFF5800
TC0 Timer/Counter - TC0
0xFFFF5C00
TC1 Timer/Counter - TC1
0xFFFF6000
ADCIFB ADC Interface - ADCIFB
0xFFFF6400
ACIFB Analog Comparator Interface - ACIFB
0xFFFF6800
CAT Capacitive Touch Module - CAT
0xFFFF6C00
GLOC Glue Logic Controller - GLOC
0xFFFF7000
AW aWire - AW
0xFFFF7400
ABDACB Audio Bitstream DAC - ABDACB
0xFFFF7800
IISC Inter-IC Sound (I2S) Controller - IISC
Table 5-3. Peripheral Address Mapping
38
32142D–06/2013
ATUC64/128/256L3/4U
The following GPIO registers are mapped on the local bus:
Table 5-4. Local Bus Mapped GPIO Registers
Port Register Mode
Local Bus
Address Access
0 Output Driver Enable Register (ODER) WRITE 0x40000040 Write-only
SET 0x40000044 Write-only
CLEAR 0x40000048 Write-only
TOGGLE 0x4000004C Write-only
Output Value Register (OVR) WRITE 0x40000050 Write-only
SET 0x40000054 Write-only
CLEAR 0x40000058 Write-only
TOGGLE 0x4000005C Write-only
Pin Value Register (PVR) - 0x40000060 Read-only
1 Output Driver Enable Register (ODER) WRITE 0x40000140 Write-only
SET 0x40000144 Write-only
CLEAR 0x40000148 Write-only
TOGGLE 0x4000014C Write-only
Output Value Register (OVR) WRITE 0x40000150 Write-only
SET 0x40000154 Write-only
CLEAR 0x40000158 Write-only
TOGGLE 0x4000015C Write-only
Pin Value Register (PVR) - 0x40000160 Read-only
39
32142D–06/2013
ATUC64/128/256L3/4U
6. Supply and Startup Considerations
6.1 Supply Considerations
6.1.1 Power Supplies
The ATUC64/128/256L3/4U has several types of power supply pins:
• VDDIO: Powers I/O lines. Voltage is 1.8 to 3.3V nominal.
• VDDIN: Powers I/O lines, the USB pins, and the internal regulator. Voltage is 1.8 to 3.3V
nominal if USB is not used, and 3.3V nominal when USB is used.
• VDDANA: Powers the ADC. Voltage is 1.8V nominal.
• VDDCORE: Powers the core, memories, and peripherals. Voltage is 1.8V nominal.
The ground pins GND are common to VDDCORE, VDDIO, and VDDIN. The ground pin for
VDDANA is GNDANA.
When VDDCORE is not connected to VDDIN, the VDDIN voltage must be higher than 1.98V.
Refer to Section 35. on page 897 for power consumption on the various supply pins.
For decoupling recommendations for the different power supplies, please refer to the schematic
checklist.
Refer to Section on page 10 for power supply connections for I/O pins.
6.1.2 Voltage Regulator
The ATUC64/128/256L3/4U embeds a voltage regulator that converts from 3.3V nominal to
1.8V with a load of up to 60 mA. The regulator supplies the output voltage on VDDCORE. The
regulator may only be used to drive internal circuitry in the device. VDDCORE should be externally
connected to the 1.8V domains. See Section 6.1.3 for regulator connection figures.
Adequate output supply decoupling is mandatory for VDDCORE to reduce ripple and avoid
oscillations. The best way to achieve this is to use two capacitors in parallel between VDDCORE
and GND as close to the device as possible. Please refer to Section 35.8 on page 911 for
decoupling capacitors values and regulator characteristics.
Figure 6-1. Supply Decoupling.
The voltage regulator can be turned off in the shutdown mode to power down the core logic and
keep a small part of the system powered in order to reduce power consumption. To enter this
mode the 3.3V supply mode, with 1.8V regulated I/O lines power supply configuration must be
used.
3.3V
1.8V
VDDIN
VDDCORE
1.8V
Regulator
CIN1
COUT1 COUT2
C IN3 IN2 C
40
32142D–06/2013
ATUC64/128/256L3/4U
6.1.3 Regulator Connection
The ATUC64/128/256L3/4U supports three power supply configurations:
• 3.3V single supply mode
– Shutdown mode is not available
• 1.8V single supply mode
– Shutdown mode is not available
• 3.3V supply mode, with 1.8V regulated I/O lines
– Shutdown mode is available
41
32142D–06/2013
ATUC64/128/256L3/4U
6.1.3.1 3.3V Single Supply Mode
In 3.3V single supply mode the internal regulator is connected to the 3.3V source (VDDIN pin)
and its output feeds VDDCORE. Figure 6-2 shows the power schematics to be used for 3.3V
single supply mode. All I/O lines will be powered by the same power (VDDIN=VDDIO).
Figure 6-2. 3.3V Single Supply Mode
VDDIO
VDDCORE
+
- 1.98-3.6V
VDDANA ADC
VDDIN GND
GNDANA
CPU,
Peripherals,
Memories,
SCIF, BOD,
RCSYS,
DFLL, PLL
OSC32K,
RC32K,
POR33,
SM33
I/O Pins I/O Pins
OSC32K_2,
AST, Wake,
Regulator
control
Linear
regulator
42
32142D–06/2013
ATUC64/128/256L3/4U
6.1.3.2 1.8V Single Supply Mode
In 1.8V single supply mode the internal regulator is not used, and VDDIO and VDDCORE are
powered by a single 1.8V supply as shown in Figure 6-3. All I/O lines will be powered by the
same power (VDDIN = VDDIO = VDDCORE).
Figure 6-3. 1.8V Single Supply Mode
VDDIO
VDDCORE
+
-
1.62-1.98V
VDDANA ADC
VDDIN GND
GNDANA
CPU,
Peripherals,
Memories,
SCIF, BOD,
RCSYS,
DFLL, PLL
OSC32K,
RC32K,
POR33,
SM33
I/O Pins I/O Pins
OSC32K_2,
AST, Wake,
Regulator
control
43
32142D–06/2013
ATUC64/128/256L3/4U
6.1.3.3 3.3V Supply Mode with 1.8V Regulated I/O Lines
In this mode, the internal regulator is connected to the 3.3V source and its output is connected
to both VDDCORE and VDDIO as shown in Figure 6-4. This configuration is required in order to
use Shutdown mode.
Figure 6-4. 3.3V Supply Mode with 1.8V Regulated I/O Lines
In this mode, some I/O lines are powered by VDDIN while other I/O lines are powered by VDDIO.
Refer to Section on page 10 for description of power supply for each I/O line.
Refer to the Power Manager chapter for a description of what parts of the system are powered in
Shutdown mode.
Important note: As the regulator has a maximum output current of 60 mA, this mode can only be
used in applications where the maximum I/O current is known and compatible with the core and
peripheral power consumption. Typically, great care must be used to ensure that only a few I/O
lines are toggling at the same time and drive very small loads.
VDDIO
VDDCORE
+
- 1.98-3.6V
VDDANA ADC
VDDIN GND
GNDANA
CPU,
Peripherals,
Memories,
SCIF, BOD,
RCSYS,
DFLL, PLL
OSC32K,
RC32K,
POR33,
SM33
I/O Pins I/O Pins
OSC32K_2,
AST, Wake,
Regulator
control
Linear
regulator
44
32142D–06/2013
ATUC64/128/256L3/4U
6.1.4 Power-up Sequence
6.1.4.1 Maximum Rise Rate
To avoid risk of latch-up, the rise rate of the power supplies must not exceed the values
described in Table 35-3 on page 898.
Recommended order for power supplies is also described in this chapter.
6.1.4.2 Minimum Rise Rate
The integrated Power-on Reset (POR33) circuitry monitoring the VDDIN powering supply
requires a minimum rise rate for the VDDIN power supply.
See Table 35-3 on page 898 for the minimum rise rate value.
If the application can not ensure that the minimum rise rate condition for the VDDIN power supply
is met, one of the following configurations can be used:
• A logic “0” value is applied during power-up on pin PA11 (WAKE_N) until VDDIN rises above
1.2V.
• A logic “0” value is applied during power-up on pin RESET_N until VDDIN rises above 1.2V.
6.2 Startup Considerations
This chapter summarizes the boot sequence of the ATUC64/128/256L3/4U. The behavior after
power-up is controlled by the Power Manager. For specific details, refer to the Power Manager
chapter.
6.2.1 Starting of Clocks
After power-up, the device will be held in a reset state by the Power-on Reset (POR18 and
POR33) circuitry for a short time to allow the power to stabilize throughout the device. After
reset, the device will use the System RC Oscillator (RCSYS) as clock source. Please refer to
Table 35-17 on page 910 for the frequency for this oscillator.
On system start-up, all high-speed clocks are disabled. All clocks to all modules are running. No
clocks have a divided frequency; all parts of the system receive a clock with the same frequency
as the System RC Oscillator.
When powering up the device, there may be a delay before the voltage has stabilized, depending
on the rise time of the supply used. The CPU can start executing code as soon as the supply
is above the POR18 and POR33 thresholds, and before the supply is stable. Before switching to
a high-speed clock source, the user should use the BOD to make sure the VDDCORE is above
the minimum level (1.62V).
6.2.2 Fetching of Initial Instructions
After reset has been released, the AVR32 UC CPU starts fetching instructions from the reset
address, which is 0x80000000. This address points to the first address in the internal Flash.
The code read from the internal flash is free to configure the clock system and clock sources.
Please refer to the PM and SCIF chapters for more details.
45
32142D–06/2013
ATUC64/128/256L3/4U
7. Peripheral DMA Controller (PDCA)
Rev: 1.2.3.1
7.1 Features
• Multiple channels
• Generates transfers between memories and peripherals such as USART and SPI
• Two address pointers/counters per channel allowing double buffering
• Performance monitors to measure average and maximum transfer latency
• Optional synchronizing of data transfers with extenal peripheral events
• Ring buffer functionality
7.2 Overview
The Peripheral DMA Controller (PDCA) transfers data between on-chip peripheral modules such
as USART, SPI and memories (those memories may be on- and off-chip memories). Using the
PDCA avoids CPU intervention for data transfers, improving the performance of the microcontroller.
The PDCA can transfer data from memory to a peripheral or from a peripheral to memory.
The PDCA consists of multiple DMA channels. Each channel has:
• A Peripheral Select Register
• A 32-bit memory pointer
• A 16-bit transfer counter
• A 32-bit memory pointer reload value
• A 16-bit transfer counter reload value
The PDCA communicates with the peripheral modules over a set of handshake interfaces. The
peripheral signals the PDCA when it is ready to receive or transmit data. The PDCA acknowledges
the request when the transmission has started.
When a transmit buffer is empty or a receive buffer is full, an optional interrupt request can be
generated.
46
32142D–06/2013
ATUC64/128/256L3/4U
7.3 Block Diagram
Figure 7-1. PDCA Block Diagram
7.4 Product Dependencies
In order to use this module, other parts of the system must be configured correctly, as described
below.
7.4.1 Power Management
If the CPU enters a sleep mode that disables the PDCA clocks, the PDCA will stop functioning
and resume operation after the system wakes up from sleep mode.
7.4.2 Clocks
The PDCA has two bus clocks connected: One High Speed Bus clock (CLK_PDCA_HSB) and
one Peripheral Bus clock (CLK_PDCA_PB). These clocks are generated by the Power Manager.
Both clocks are enabled at reset, and can be disabled in the Power Manager. It is
recommended to disable the PDCA before disabling the clocks, to avoid freezing the PDCA in
an undefined state.
7.4.3 Interrupts
The PDCA interrupt request lines are connected to the interrupt controller. Using the PDCA
interrupts requires the interrupt controller to be programmed first.
HSB to PB
Bridge
Peripheral DMA
Controller
(PDCA)
Peripheral
0
High Speed
Bus Matrix
Handshake Interfaces Peripheral Bus
IRQ
HSB
HSB
Interrupt
Controller
Peripheral
1
Peripheral
2
Peripheral
(n-1) ...
Memory
HSB
47
32142D–06/2013
ATUC64/128/256L3/4U
7.4.4 Peripheral Events
The PDCA peripheral events are connected via the Peripheral Event System. Refer to the
Peripheral Event System chapter for details.
7.5 Functional Description
7.5.1 Basic Operation
The PDCA consists of multiple independent PDCA channels, each capable of handling DMA
requests in parallel. Each PDCA channels contains a set of configuration registers which must
be configured to start a DMA transfer.
In this section the steps necessary to configure one PDCA channel is outlined.
The peripheral to transfer data to or from must be configured correctly in the Peripheral Select
Register (PSR). This is performed by writing the Peripheral Identity (PID) value for the corresponding
peripheral to the PID field in the PSR register. The PID also encodes the transfer
direction, i.e. memory to peripheral or peripheral to memory. See Section 7.5.6.
The transfer size must be written to the Transfer Size field in the Mode Register (MR.SIZE). The
size must match the data size produced or consumed by the selected peripheral. See Section
7.5.7.
The memory address to transfer to or from, depending on the PSR, must be written to the Memory
Address Register (MAR). For each transfer the memory address is increased by either a
one, two or four, depending on the size set in MR. See Section 7.5.2.
The number of data items to transfer is written to the TCR register. If the PDCA channel is
enabled, a transfer will start immediately after writing a non-zero value to TCR or the reload version
of TCR, TCRR. After each transfer the TCR value is decreased by one. Both MAR and TCR
can be read while the PDCA channel is active to monitor the DMA progress. See Section 7.5.3.
The channel must be enabled for a transfer to start. A channel is enable by writing a one to the
EN bit in the Control Register (CR).
7.5.2 Memory Pointer
Each channel has a 32-bit Memory Address Register (MAR). This register holds the memory
address for the next transfer to be performed. The register is automatically updated after each
transfer. The address will be increased by either one, two or four depending on the size of the
DMA transfer (byte, halfword or word). The MAR can be read at any time during transfer.
7.5.3 Transfer Counter
Each channel has a 16-bit Transfer Counter Register (TCR). This register must be written with
the number of transfers to be performed. The TCR register should contain the number of data
items to be transferred independently of the transfer size. The TCR can be read at any time during
transfer to see the number of remaining transfers.
7.5.4 Reload Registers
Both the MAR and the TCR have a reload register, respectively Memory Address Reload Register
(MARR) and Transfer Counter Reload Register (TCRR). These registers provide the
possibility for the PDCA to work on two memory buffers for each channel. When one buffer has
completed, MAR and TCR will be reloaded with the values in MARR and TCRR. The reload logic
is always enabled and will trigger if the TCR reaches zero while TCRR holds a non-zero value.
After reload, the MARR and TCRR registers are cleared.
48
32142D–06/2013
ATUC64/128/256L3/4U
If TCR is zero when writing to TCRR, the TCR and MAR are automatically updated with the
value written in TCRR and MARR.
7.5.5 Ring Buffer
When Ring Buffer mode is enabled the TCRR and MARR registers will not be cleared when
TCR and MAR registers reload. This allows the PDCA to read or write to the same memory
region over and over again until the transfer is actively stopped by the user. Ring Buffer mode is
enabled by writing a one to the Ring Buffer bit in the Mode Register (MR.RING).
7.5.6 Peripheral Selection
The Peripheral Select Register (PSR) decides which peripheral should be connected to the
PDCA channel. A peripheral is selected by writing the corresponding Peripheral Identity (PID) to
the PID field in the PSR register. Writing the PID will both select the direction of the transfer
(memory to peripheral or peripheral to memory), which handshake interface to use, and the
address of the peripheral holding register. Refer to the Peripheral Identity (PID) table in the Module
Configuration section for the peripheral PID values.
7.5.7 Transfer Size
The transfer size can be set individually for each channel to be either byte, halfword or word (8-
bit, 16-bit or 32-bit respectively). Transfer size is set by writing the desired value to the Transfer
Size field in the Mode Register (MR.SIZE).
When the PDCA moves data between peripherals and memory, data is automatically sized and
aligned. When memory is accessed, the size specified in MR.SIZE and system alignment is
used. When a peripheral register is accessed the data to be transferred is converted to a word
where bit n in the data corresponds to bit n in the peripheral register. If the transfer size is byte or
halfword, bits greater than 8 and16 respectively are set to zero.
Refer to the Module Configuration section for information regarding what peripheral registers are
used for the different peripherals and then to the peripheral specific chapter for information
about the size option available for the different registers.
7.5.8 Enabling and Disabling
Each DMA channel is enabled by writing a one to the Transfer Enable bit in the Control Register
(CR.TEN) and disabled by writing a one to the Transfer Disable bit (CR.TDIS). The current status
can be read from the Status Register (SR).
While the PDCA channel is enabled all DMA request will be handled as long the TCR and TCRR
is not zero.
7.5.9 Interrupts
Interrupts can be enabled by writing a one to the corresponding bit in the Interrupt Enable Register
(IER) and disabled by writing a one to the corresponding bit in the Interrupt Disable Register
(IDR). The Interrupt Mask Register (IMR) can be read to see whether an interrupt is enabled or
not. The current status of an interrupt source can be read through the Interrupt Status Register
(ISR).
The PDCA has three interrupt sources:
• Reload Counter Zero - The TCRR register is zero.
• Transfer Finished - Both the TCR and TCRR registers are zero.
• Transfer Error - An error has occurred in accessing memory.
49
32142D–06/2013
ATUC64/128/256L3/4U
7.5.10 Priority
If more than one PDCA channel is requesting transfer at a given time, the PDCA channels are
prioritized by their channel number. Channels with lower numbers have priority over channels
with higher numbers, giving channel zero the highest priority.
7.5.11 Error Handling
If the Memory Address Register (MAR) is set to point to an invalid location in memory, an error
will occur when the PDCA tries to perform a transfer. When an error occurs, the Transfer Error
bit in the Interrupt Status Register (ISR.TERR) will be set and the DMA channel that caused the
error will be stopped. In order to restart the channel, the user must program the Memory
Address Register to a valid address and then write a one to the Error Clear bit in the Control
Register (CR.ECLR). If the Transfer Error interrupt is enabled, an interrupt request will be generated
when a transfer error occurs.
7.5.12 Peripheral Event Trigger
Peripheral events can be used to trigger PDCA channel transfers. Peripheral Event synchronizations
are enabled by writing a one to the Event Trigger bit in the Mode Register (MR.ETRIG).
When set, all DMA requests will be blocked until a peripheral event is received. For each peripheral
event received, only one data item is transferred. If no DMA requests are pending when a
peripheral event is received, the PDCA will start a transfer as soon as a peripheral event is
detected. If multiple events are received while the PDCA channel is busy transferring data, an
overflow condition will be signaled in the Peripheral Event System. Refer to the Peripheral Event
System chapter for more information.
7.6 Performance Monitors
Up to two performance monitors allow the user to measure the activity and stall cycles for PDCA
transfers. To monitor a PDCA channel, the corresponding channel number must be written to
one of the MON0/1CH fields in the Performance Control Register (PCONTROL) and a one must
be written to the corresponding CH0/1EN bit in the same register.
Due to performance monitor hardware resource sharing, the two monitor channels should NOT
be programmed to monitor the same PDCA channel. This may result in UNDEFINED performance
monitor behavior.
7.6.1 Measuring mechanisms
Three different parameters can be measured by each channel:
• The number of data transfer cycles since last channel reset, both for read and write
• The number of stall cycles since last channel reset, both for read and write
• The maximum latency since last channel reset, both for read and write
These measurements can be extracted by software and used to generate indicators for bus
latency, bus load, and maximum bus latency.
Each of the counters has a fixed width, and may therefore overflow. When an overflow is
encountered in either the Performance Channel Data Read/Write Cycle registers (PRDATA0/1
and PWDATA0/1) or the Performance Channel Read/Write Stall Cycles registers (PRSTALL0/1
and PWSTALL0/1) of a channel, all registers in the channel are reset. This behavior is altered if
the Channel Overflow Freeze bit is one in the Performance Control register (PCONTROL.CH0/1OVF).
If this bit is one, the channel registers are frozen when either DATA or
STALL reaches its maximum value. This simplifies one-shot readout of the counter values.
50
32142D–06/2013
ATUC64/128/256L3/4U
The registers can also be manually reset by writing a one to the Channel Reset bit in the PCONTROL
register (PCONTROL.CH0/1RES). The Performance Channel Read/Write Latency
registers (PRLAT0/1 and PWLAT0/1) are saturating when their maximum count value is
reached. The PRLAT0/1 and PWLAT0/1 registers can only be reset by writing a one to the corresponding
reset bit in PCONTROL (PCONTROL.CH0/1RES).
A counter is enabled by writing a one to the Channel Enable bit in the Performance Control Register
(PCONTROL.CH0/1EN).
51
32142D–06/2013
ATUC64/128/256L3/4U
7.7 User Interface
7.7.1 Memory Map Overview
The channels are mapped as shown in Table 7-1. Each channel has a set of configuration registers,
shown in Table 7-2, where n is the channel number.
7.7.2 Channel Memory Map
Note: 1. The reset values are device specific. Please refer to the Module Configuration section at the
end of this chapter.
Table 7-1. PDCA Register Memory Map
Address Range Contents
0x000 - 0x03F DMA channel 0 configuration registers
0x040 - 0x07F DMA channel 1 configuration registers
... ...
(0x000 - 0x03F)+m*0x040 DMA channel m configuration registers
0x800-0x830 Performance Monitor registers
0x834 Version register
Table 7-2. PDCA Channel Configuration Registers
Offset Register Register Name Access Reset
0x000 + n*0x040 Memory Address Register MAR Read/Write 0x00000000
0x004 + n*0x040 Peripheral Select Register PSR Read/Write - (1)
0x008 + n*0x040 Transfer Counter Register TCR Read/Write 0x00000000
0x00C + n*0x040 Memory Address Reload Register MARR Read/Write 0x00000000
0x010 + n*0x040 Transfer Counter Reload Register TCRR Read/Write 0x00000000
0x014 + n*0x040 Control Register CR Write-only 0x00000000
0x018 + n*0x040 Mode Register MR Read/Write 0x00000000
0x01C + n*0x040 Status Register SR Read-only 0x00000000
0x020 + n*0x040 Interrupt Enable Register IER Write-only 0x00000000
0x024 + n*0x040 Interrupt Disable Register IDR Write-only 0x00000000
0x028 + n*0x040 Interrupt Mask Register IMR Read-only 0x00000000
0x02C + n*0x040 Interrupt Status Register ISR Read-only 0x00000000
52
32142D–06/2013
ATUC64/128/256L3/4U
7.7.3 Performance Monitor Memory Map
Note: 1. The number of performance monitors is device specific. If the device has only one performance
monitor, the Channel1 registers are not available. Please refer to the Module
Configuration section at the end of this chapter for the number of performance monitors on this
device.
7.7.4 Version Register Memory Map
Note: 1. The reset values are device specific. Please refer to the Module Configuration section at the end of this chapter.
Table 7-3. PDCA Performance Monitor Registers(1)
Offset Register Register Name Access Reset
0x800 Performance Control Register PCONTROL Read/Write 0x00000000
0x804 Channel0 Read Data Cycles PRDATA0 Read-only 0x00000000
0x808 Channel0 Read Stall Cycles PRSTALL0 Read-only 0x00000000
0x80C Channel0 Read Max Latency PRLAT0 Read-only 0x00000000
0x810 Channel0 Write Data Cycles PWDATA0 Read-only 0x00000000
0x814 Channel0 Write Stall Cycles PWSTALL0 Read-only 0x00000000
0x818 Channel0 Write Max Latency PWLAT0 Read-only 0x00000000
0x81C Channel1 Read Data Cycles PRDATA1 Read-only 0x00000000
0x820 Channel1 Read Stall Cycles PRSTALL1 Read-only 0x00000000
0x824 Channel1 Read Max Latency PRLAT1 Read-only 0x00000000
0x828 Channel1 Write Data Cycles PWDATA1 Read-only 0x00000000
0x82C Channel1 Write Stall Cycles PWSTALL1 Read-only 0x00000000
0x830 Channel1 Write Max Latency PWLAT1 Read-only 0x00000000
Table 7-4. PDCA Version Register Memory Map
Offset Register Register Name Access Reset
0x834 Version Register VERSION Read-only - (1)
53
32142D–06/2013
ATUC64/128/256L3/4U
7.7.5 Memory Address Register
Name: MAR
Access Type: Read/Write
Offset: 0x000 + n*0x040
Reset Value: 0x00000000
• MADDR: Memory Address
Address of memory buffer. MADDR should be programmed to point to the start of the memory buffer when configuring the
PDCA. During transfer, MADDR will point to the next memory location to be read/written.
31 30 29 28 27 26 25 24
MADDR[31:24]
23 22 21 20 19 18 17 16
MADDR[23:16]
15 14 13 12 11 10 9 8
MADDR[15:8]
76543210
MADDR[7:0]
54
32142D–06/2013
ATUC64/128/256L3/4U
7.7.6 Peripheral Select Register
Name: PSR
Access Type: Read/Write
Offset: 0x004 + n*0x040
Reset Value: -
• PID: Peripheral Identifier
The Peripheral Identifier selects which peripheral should be connected to the DMA channel. Writing a PID will select both which
handshake interface to use, the direction of the transfer and also the address of the Receive/Transfer Holding Register for the
peripheral. See the Module Configuration section of PDCA for details. The width of the PID field is device specific and
dependent on the number of peripheral modules in the device.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
--------
76543210
PID
55
32142D–06/2013
ATUC64/128/256L3/4U
7.7.7 Transfer Counter Register
Name: TCR
Access Type: Read/Write
Offset: 0x008 + n*0x040
Reset Value: 0x00000000
• TCV: Transfer Counter Value
Number of data items to be transferred by the PDCA. TCV must be programmed with the total number of transfers to be made.
During transfer, TCV contains the number of remaining transfers to be done.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
TCV[15:8]
76543210
TCV[7:0]
56
32142D–06/2013
ATUC64/128/256L3/4U
7.7.8 Memory Address Reload Register
Name: MARR
Access Type: Read/Write
Offset: 0x00C + n*0x040
Reset Value: 0x00000000
• MARV: Memory Address Reload Value
Reload Value for the MAR register. This value will be loaded into MAR when TCR reaches zero if the TCRR register has a nonzero
value.
31 30 29 28 27 26 25 24
MARV[31:24]
23 22 21 20 19 18 17 16
MARV[23:16]
15 14 13 12 11 10 9 8
MARV[15:8]
76543210
MARV[7:0]
57
32142D–06/2013
ATUC64/128/256L3/4U
7.7.9 Transfer Counter Reload Register
Name: TCRR
Access Type: Read/Write
Offset: 0x010 + n*0x040
Reset Value: 0x00000000
• TCRV: Transfer Counter Reload Value
Reload value for the TCR register. When TCR reaches zero, it will be reloaded with TCRV if TCRV has a positive value. If TCRV
is zero, no more transfers will be performed for the channel. When TCR is reloaded, the TCRR register is cleared.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
TCRV[15:8]
76543210
TCRV[7:0]
58
32142D–06/2013
ATUC64/128/256L3/4U
7.7.10 Control Register
Name: CR
Access Type: Write-only
Offset: 0x014 + n*0x040
Reset Value: 0x00000000
• ECLR: Transfer Error Clear
Writing a zero to this bit has no effect.
Writing a one to this bit will clear the Transfer Error bit in the Status Register (SR.TERR). Clearing the SR.TERR bit will allow the
channel to transmit data. The memory address must first be set to point to a valid location.
• TDIS: Transfer Disable
Writing a zero to this bit has no effect.
Writing a one to this bit will disable transfer for the DMA channel.
• TEN: Transfer Enable
Writing a zero to this bit has no effect.
Writing a one to this bit will enable transfer for the DMA channel.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
- - - - - - - ECLR
76543210
- - - - - - TDIS TEN
59
32142D–06/2013
ATUC64/128/256L3/4U
7.7.11 Mode Register
Name: MR
Access Type: Read/Write
Offset: 0x018 + n*0x040
Reset Value: 0x00000000
• RING: Ring Buffer
0:The Ring buffer functionality is disabled.
1:The Ring buffer functionality is enabled. When enabled, the reload registers, MARR and TCRR will not be cleared after reload.
• ETRIG: Event Trigger
0:Start transfer when the peripheral selected in Peripheral Select Register (PSR) requests a transfer.
1:Start transfer only when or after a peripheral event is received.
• SIZE: Size of Transfer
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
--------
76543210
- - - - RING ETRIG SIZE
Table 7-5. Size of Transfer
SIZE Size of Transfer
0 Byte
1 Halfword
2 Word
3 Reserved
60
32142D–06/2013
ATUC64/128/256L3/4U
7.7.12 Status Register
Name: SR
Access Type: Read-only
Offset: 0x01C + n*0x040
Reset Value: 0x00000000
• TEN: Transfer Enabled
This bit is cleared when the TDIS bit in CR is written to one.
This bit is set when the TEN bit in CR is written to one.
0: Transfer is disabled for the DMA channel.
1: Transfer is enabled for the DMA channel.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
--------
76543210
- - - - - - - TEN
61
32142D–06/2013
ATUC64/128/256L3/4U
7.7.13 Interrupt Enable Register
Name: IER
Access Type: Write-only
Offset: 0x020 + n*0x040
Reset Value: 0x00000000
Writing a zero to a bit in this register has no effect.
Writing a one to a bit in this register will set the corresponding bit in IMR.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
--------
76543210
- - - - - TERR TRC RCZ
62
32142D–06/2013
ATUC64/128/256L3/4U
7.7.14 Interrupt Disable Register
Name: IDR
Access Type: Write-only
Offset: 0x024 + n*0x040
Reset Value: 0x00000000
Writing a zero to a bit in this register has no effect.
Writing a one to a bit in this register will clear the corresponding bit in IMR.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
--------
76543210
- - - - - TERR TRC RCZ
63
32142D–06/2013
ATUC64/128/256L3/4U
7.7.15 Interrupt Mask Register
Name: IMR
Access Type: Read-only
Offset: 0x028 + n*0x040
Reset Value: 0x00000000
0: The corresponding interrupt is disabled.
1: The corresponding interrupt is enabled.
A bit in this register is cleared when the corresponding bit in IDR is written to one.
A bit in this register is set when the corresponding bit in IER is written to one.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
--------
76543210
- - - - - TERR TRC RCZ
64
32142D–06/2013
ATUC64/128/256L3/4U
7.7.16 Interrupt Status Register
Name: ISR
Access Type: Read-only
Offset: 0x02C + n*0x040
Reset Value: 0x00000000
• TERR: Transfer Error
This bit is cleared when no transfer errors have occurred since the last write to CR.ECLR.
This bit is set when one or more transfer errors has occurred since reset or the last write to CR.ECLR.
• TRC: Transfer Complete
This bit is cleared when the TCR and/or the TCRR holds a non-zero value.
This bit is set when both the TCR and the TCRR are zero.
• RCZ: Reload Counter Zero
This bit is cleared when the TCRR holds a non-zero value.
This bit is set when TCRR is zero.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
--------
76543210
- - - - - TERR TRC RCZ
65
32142D–06/2013
ATUC64/128/256L3/4U
7.7.17 Performance Control Register
Name: PCONTROL
Access Type: Read/Write
Offset: 0x800
Reset Value: 0x00000000
• MON1CH: Performance Monitor Channel 1
• MON0CH: Performance Monitor Channel 0
The PDCA channel number to monitor with counter n
Due to performance monitor hardware resource sharing, the two performance monitor channels should NOT be programmed to
monitor the same PDCA channel. This may result in UNDEFINED monitor behavior.
• CH1RES: Performance Channel 1 Counter Reset
Writing a zero to this bit has no effect.
Writing a one to this bit will reset the counter in the channel specified in MON1CH.
This bit always reads as zero.
• CH0RES: Performance Channel 0 Counter Reset
Writing a zero to this bit has no effect.
Writing a one to this bit will reset the counter in the channel specified in MON0CH.
This bit always reads as zero.
• CH1OF: Channel 1 Overflow Freeze
0: The performance channel registers are reset if DATA or STALL overflows.
1: All performance channel registers are frozen just before DATA or STALL overflows.
• CH1OF: Channel 0 Overflow Freeze
0: The performance channel registers are reset if DATA or STALL overflows.
1: All performance channel registers are frozen just before DATA or STALL overflows.
• CH1EN: Performance Channel 1 Enable
0: Performance channel 1 is disabled.
1: Performance channel 1 is enabled.
• CH0EN: Performance Channel 0 Enable
0: Performance channel 0 is disabled.
1: Performance channel 0 is enabled.
31 30 29 28 27 26 25 24
- - MON1CH
23 22 21 20 19 18 17 16
- - MON0CH
15 14 13 12 11 10 9 8
- - - - - - CH1RES CH0RES
76543210
- - CH1OF CH0OF - - CH1EN CH0EN
66
32142D–06/2013
ATUC64/128/256L3/4U
7.7.18 Performance Channel 0 Read Data Cycles
Name: PRDATA0
Access Type: Read-only
Offset: 0x804
Reset Value: 0x00000000
• DATA: Data Cycles Counted Since Last Reset
Clock cycles are counted using the CLK_PDCA_HSB clock
31 30 29 28 27 26 25 24
DATA[31:24]
23 22 21 20 19 18 17 16
DATA[23:16]
15 14 13 12 11 10 9 8
DATA[15:8]
76543210
DATA[7:0]
67
32142D–06/2013
ATUC64/128/256L3/4U
7.7.19 Performance Channel 0 Read Stall Cycles
Name: PRSTALL0
Access Type: Read-only
Offset: 0x808
Reset Value: 0x00000000
• STALL: Stall Cycles Counted Since Last Reset
Clock cycles are counted using the CLK_PDCA_HSB clock
31 30 29 28 27 26 25 24
STALL[31:24]
23 22 21 20 19 18 17 16
STALL[23:16]
15 14 13 12 11 10 9 8
STALL[15:8]
76543210
STALL[7:0]
68
32142D–06/2013
ATUC64/128/256L3/4U
7.7.20 Performance Channel 0 Read Max Latency
Name: PRLAT0
Access Type: Read/Write
Offset: 0x80C
Reset Value: 0x00000000
• LAT: Maximum Transfer Initiation Cycles Counted Since Last Reset
Clock cycles are counted using the CLK_PDCA_HSB clock
This counter is saturating. The register is reset only when PCONTROL.CH0RES is written to one.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
LAT[15:8]
76543210
LAT[7:0]
69
32142D–06/2013
ATUC64/128/256L3/4U
7.7.21 Performance Channel 0 Write Data Cycles
Name: PWDATA0
Access Type: Read-only
Offset: 0x810
Reset Value: 0x00000000
• DATA: Data Cycles Counted Since Last Reset
Clock cycles are counted using the CLK_PDCA_HSB clock
31 30 29 28 27 26 25 24
DATA[31:24]
23 22 21 20 19 18 17 16
DATA[23:16]
15 14 13 12 11 10 9 8
DATA[15:8]
76543210
DATA[7:0]
70
32142D–06/2013
ATUC64/128/256L3/4U
7.7.22 Performance Channel 0 Write Stall Cycles
Name: PWSTALL0
Access Type: Read-only
Offset: 0x814
Reset Value: 0x00000000
• STALL: Stall Cycles Counted Since Last Reset
Clock cycles are counted using the CLK_PDCA_HSB clock
31 30 29 28 27 26 25 24
STALL[31:24]
23 22 21 20 19 18 17 16
STALL[23:16]
15 14 13 12 11 10 9 8
STALL[15:8]
76543210
STALL[7:0]
71
32142D–06/2013
ATUC64/128/256L3/4U
7.7.23 Performance Channel 0 Write Max Latency
Name: PWLAT0
Access Type: Read/Write
Offset: 0x818
Reset Value: 0x00000000
• LAT: Maximum Transfer Initiation Cycles Counted Since Last Reset
Clock cycles are counted using the CLK_PDCA_HSB clock
This counter is saturating. The register is reset only when PCONTROL.CH0RES is written to one.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
LAT[15:8]
76543210
LAT[7:0]
72
32142D–06/2013
ATUC64/128/256L3/4U
7.7.24 Performance Channel 1 Read Data Cycles
Name: PRDATA1
Access Type: Read-only
Offset: 0x81C
Reset Value: 0x00000000
• DATA: Data Cycles Counted Since Last Reset
Clock cycles are counted using the CLK_PDCA_HSB clock
31 30 29 28 27 26 25 24
DATA[31:24]
23 22 21 20 19 18 17 16
DATA[23:16]
15 14 13 12 11 10 9 8
DATA[15:8]
76543210
DATA[7:0]
73
32142D–06/2013
ATUC64/128/256L3/4U
7.7.25 Performance Channel 1 Read Stall Cycles
Name: PRSTALL1
Access Type: Read-only
Offset: 0x820
Reset Value: 0x00000000
• STALL: Stall Cycles Counted Since Last Reset
Clock cycles are counted using the CLK_PDCA_HSB clock
31 30 29 28 27 26 25 24
STALL[31:24]
23 22 21 20 19 18 17 16
STALL[23:16]
15 14 13 12 11 10 9 8
STALL[15:8]
76543210
STALL[7:0]
74
32142D–06/2013
ATUC64/128/256L3/4U
7.7.26 Performance Channel 1 Read Max Latency
Name: PRLAT1
Access Type: Read/Write
Offset: 0x824
Reset Value: 0x00000000
• LAT: Maximum Transfer Initiation Cycles Counted Since Last Reset
Clock cycles are counted using the CLK_PDCA_HSB clock
This counter is saturating. The register is reset only when PCONTROL.CH1RES is written to one.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
LAT[15:8]
76543210
LAT[7:0]
75
32142D–06/2013
ATUC64/128/256L3/4U
7.7.27 Performance Channel 1 Write Data Cycles
Name: PWDATA1
Access Type: Read-only
Offset: 0x828
Reset Value: 0x00000000
• DATA: Data Cycles Counted Since Last Reset
Clock cycles are counted using the CLK_PDCA_HSB clock
31 30 29 28 27 26 25 24
DATA[31:24]
23 22 21 20 19 18 17 16
DATA[23:16]
15 14 13 12 11 10 9 8
DATA[15:8]
76543210
DATA[7:0]
76
32142D–06/2013
ATUC64/128/256L3/4U
7.7.28 Performance Channel 1 Write Stall Cycles
Name: PWSTALL1
Access Type: Read-only
Offset: 0x82C
Reset Value: 0x00000000
• STALL: Stall Cycles Counted Since Last Reset
Clock cycles are counted using the CLK_PDCA_HSB clock
31 30 29 28 27 26 25 24
STALL[31:24]
23 22 21 20 19 18 17 16
STALL[23:16]
15 14 13 12 11 10 9 8
STALL[15:8]
76543210
STALL[7:0]
77
32142D–06/2013
ATUC64/128/256L3/4U
7.7.29 Performance Channel 1 Write Max Latency
Name: PWLAT1
Access Type: Read/Write
Offset: 0x830
Reset Value: 0x00000000
• LAT: Maximum Transfer Initiation Cycles Counted Since Last Reset
Clock cycles are counted using the CLK_PDCA_HSB clock
This counter is saturating. The register is reset only when PCONTROL.CH1RES is written to one.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
LAT[15:8]
76543210
LAT[7:0]
78
32142D–06/2013
ATUC64/128/256L3/4U
7.7.30 PDCA Version Register
Name: VERSION
Access Type: Read-only
Offset: 0x834
Reset Value: -
• VARIANT: Variant Number
Reserved. No functionality associated.
• VERSION: Version Number
Version number of the module. No functionality associated.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
- - - - VARIANT
15 14 13 12 11 10 9 8
- - - - VERSION[11:8]
76543210
VERSION[7:0]
79
32142D–06/2013
ATUC64/128/256L3/4U
7.8 Module Configuration
The specific configuration for each PDCA instance is listed in the following tables.The module
bus clocks listed here are connected to the system bus clocks. Please refer to the Power Manager
chapter for details.
The PDCA and the peripheral modules communicate through a set of handshake signals. The
following table defines the valid settings for the Peripheral Identifier (PID) in the PDCA Peripheral
Select Register (PSR). The direction is specified as observed from the memory, so RX
means transfers from peripheral to memory, and TX means from memory to peripheral.
Table 7-6. PDCA Configuration
Feature PDCA
Number of channels 12
Number of performance monitors 1
Table 7-7. PDCA Clocks
Clock Name Description
CLK_PDCA_HSB Clock for the PDCA HSB interface
CLK_PDCA_PB Clock for the PDCA PB interface
Table 7-8. Register Reset Values
Register Reset Value
PSR CH 0 0
PSR CH 1 1
PSR CH 2 2
PSR CH 3 3
PSR CH 4 4
PSR CH 5 5
PSR CH 6 6
PSR CH 7 7
PSR CH 8 8
PSR CH 9 9
PSR CH 10 10
PSR CH 11 11
VERSION 123
Table 7-9. Peripheral Identity Values
PID Direction Peripheral Instance Peripheral Register
0 RX USART0 RHR
1 RX USART1 RHR
2 RX USART2 RHR
80
32142D–06/2013
ATUC64/128/256L3/4U
3 RX USART3 RHR
4 RX SPI RDR
5 RX TWIM0 RHR
6 RX TWIM1 RHR
7 RX TWIS0 RHR
8 RX TWIS1 RHR
9 RX ADCIFB LCDR
10 RX AW RHR
11 RX CAT ACOUNT
12 TX USART0 THR
13 TX USART1 THR
14 TX USART2 THR
15 TX USART3 THR
16 TX SPI TDR
17 TX TWIM0 THR
18 TX TWIM1 THR
19 TX TWIS0 THR
20 TX TWIS1 THR
21 TX AW THR
22 TX CAT MBLEN
23 TX ABDACB SDR0
24 TX ABDACB SDR1
25 RX IISC RHR (CH0)
26 RX IISC RHR (CH1)
27 TX IISC THR (CH0)
28 TX IISC THR (CH1)
29 RX CAT DMATSR
30 TX CAT DMATSW
Table 7-9. Peripheral Identity Values
PID Direction Peripheral Instance Peripheral Register
81
32142D–06/2013
ATUC64/128/256L3/4U
8. USB Interface (USBC)
Rev: 2.0.0.15
8.1 Features
• Compatible with the USB 2.0 specification
• Supports full (12Mbit/s) and low (1.5Mbit/s) speed communication
• Seven physical pipes/endpoints in ping-pong mode
• Flexible pipe/endpoint configuration and reallocation of data buffers in embedded RAM
• Up to two memory banks per pipe/endpoint
• Built-in DMA with multi-packet support through ping-pong mode
• On-chip transceivers with built-in pull-ups and pull-downs
8.2 Overview
The Universal Serial Bus interface (USBC) module complies with the Universal Serial Bus (USB)
2.0 specification.
Each pipe/endpoint can be configured into one of several transfer types. It can be associated
with one or more memory banks (located inside the embedded system or CPU RAM) used to
store the current data payload. If two banks are used (“ping-pong” mode), then one bank is read
or written by the CPU (or any other HSB master) while the other is read or written by the USBC
core.
Table 8-1 describes the hardware configuration of the USBC module.
8.3 Block Diagram
The USBC interfaces a USB link with a data flow stored in the embedded ram (CPU or HSB).
The USBC requires a 48MHz ± 0.25% reference clock, which is the USB generic clock. For
more details see ”Clocks” on page 84. The 48MHz clock is used to generate either a 12MHz fullspeed
or a 1.5MHz low-speed bit clock from the received USB differential data, and to transmit
data according to full- or low-speed USB device tolerances. Clock recovery is achieved by a digital
phase-locked loop (a DPLL, not represented) in the USBC module, which complies with the
USB jitter specifications.
The USBC module consists of:
• HSB master interface
Table 8-1. Description of USB pipes/endpoints
pipe/endpoint Mnemonic Max. size
Number of
available banks Type
0 PEP0 1023 bytes 1 Control/Isochronous/Bulk/Interrupt
1 PEP1 1023 bytes 2 Control/Isochronous/Bulk/Interrupt
2 PEP2 1023 bytes 2 Control/Isochronous/Bulk/Interrupt
... ... ... ... ...
6 PEP6 1023 bytes 2 Control/Isochronous/Bulk/Interrupt
82
32142D–06/2013
ATUC64/128/256L3/4U
• User interface
• USB Core
• Transceiver pads
Figure 8-1. USBC Block Diagram
Note: in the block diagram is symbolic, it is mapped to a GPIO pin (See Section “8.5.1” on page 84.).
The VBUS detection (rising edge detection on the GPIO pin) should be handled by software.
Interrupt
Controller
USB interrupts
DM
USB_VBUS (1)
USB
DP
User interface
SCIF GCLK_USBC @ 48 MHz
PB
USB 2.0
Core
USB clock
domain
System clock
domain
HSB
HSB Master
83
32142D–06/2013
ATUC64/128/256L3/4U
8.4 I/O Lines Description
Table 8-2. I/O Lines Description
PIn Name Pin Description Type Active Level
DM Data -: Differential Data Line - Port Input/Output
DP Data +: Differential Data Line + Port Input/Output
84
32142D–06/2013
ATUC64/128/256L3/4U
8.5 Product Dependencies
In order to use this module, other parts of the system must be configured correctly, as described
below.
8.5.1 I/O Lines
The USBC pins may be multiplexed with the I/O Controller lines. The user must first configure
the I/O Controller to assign the desired USBC pins to their peripheral functions.
The USB VBUS line should be connected to a GPIO pin and the user should monitor this with
software.
8.5.2 Power Management
If the CPU enters a sleep mode that disables clocks used by the USBC, the USBC will stop functioning
and resume operation after the system wakes up from sleep mode.
8.5.3 Clocks
The USBC has two bus clocks connected: One High Speed Bus clock (CLK_USBC_HSB) and
one Peripheral Bus clock (CLK_USBC_PB). These clocks are generated by the Power Manager.
Both clocks are enabled at reset, and can be disabled by the Power Manager. It is
recommended to disable the USBC before disabling the clocks, to avoid freezing the USBC in
an undefined state.
The 48MHz USB clock is generated by a dedicated generic clock from the SCIF module. Before
using the USB, the user must ensure that the USB generic clock (GCLK_USBC) is enabled at
48MHz in the SCIF module.
8.5.4 Interrupts
The USBC interrupt request line is connected to the interrupt controller. Using the USBC interrupt
requires the interrupt controller to be programmed first.
The USBC asynchronous interrupt can wake the CPU from any sleep mode:
• The Wakeup Interrupt (WAKEUP)
85
32142D–06/2013
ATUC64/128/256L3/4U
8.6 Functional Description
8.6.1 USB General Operation
8.6.1.1 Initialization
After a hardware reset, the USBC is in the Reset state. In this state:
• The module is disabled. The USBC Enable bit in the General Control register
(USBCON.USBE) is reset.
• The module clock is stopped in order to minimize power consumption. The Freeze USB Clock
bit in USBCON (USBCON.FRZCLK) is set.
• The USB pad is in suspend mode.
• The internal states and registers of the device are reset.
• The Freeze USB Clock (FRZCLK), USBC Enable (USBE), in USBCON and the Low-Speed
mode bit in the Device General Control register (UDCON.LS) can be written to by software,
so that the user can configure pads and speed before enabling the module. These values are
only taken into account once the module has been enabled and unfrozen.
After writing a one to USBCON.USBE, the USBC enters device mode in idle state.
Refer to Section 8.6.2 for the basic operation of the device mode.
The USBC can be disabled at any time by writing a zero to USBCON.USBE, this acts as a hardware
reset, except that the FRZCLK,bit in USBCON, and the LS bits in UDCON are not reset.
8.6.1.2 Interrupts
One interrupt vector is assigned to the USBC.
See Section 8.6.2.18 for further details about device interrupts.
See Section 8.5.4 for asynchronous interrupts.
8.6.1.3 Frozen clock
When the USB clock is frozen, it is still possible to access the following bits: FRZCLK, and USBE
in the USBCON register, and LS in the UDCON register.
When FRZCLK is set, only the asynchronous interrupt can trigger a USB interrupt (see Section
8.5.4).
8.6.1.4 Speed control
• Device mode
When the USBC interface is in device mode, the speed selection is done by the UDCON.LS bit,
connecting an internal pull-up resistor to either DP (full-speed mode) or DM (low-speed mode).
The LS bit shall be written before attaching the device, which can be simulated by clearing the
UDCON.DETACH bit.
86
32142D–06/2013
ATUC64/128/256L3/4U
Figure 8-2. Speed Selection in device mode
8.6.1.5 Data management
Endpoints and pipe buffers can be allocated anywhere in the embedded memory (CPU RAM or
HSB RAM).
See ”RAM management” on page 90.
8.6.1.6 Pad Suspend
Figure 8-3 illustrates the behavior of the USB pad in device mode.
Figure 8-3. Pad Behavior
• In Idle state, the pad is in low power consumption mode.
• In Active state, the pad is working.
Figure 8-4 illustrates the pad events leading to a PAD state change.
RPU
UDCON.DETACH
DP
DM
UDCON.LS
VBUS
Idle
Active
USBE = 1
& DETACH = 0
& Suspend
USBE = 0
| DETACH = 1
| Suspend
87
32142D–06/2013
ATUC64/128/256L3/4U
Figure 8-4. Pad events
The Suspend Interrupt bit in the Device Global Interrupt register (UDINT.SUSP) is set and the
Wakeup Interrupt (UDINT.WAKEUP) bit is cleared when a USB Suspend state has been
detected on the USB bus. This event automatically puts the USB pad in the Idle state. The
detection of a non-idle event sets WAKEUP, clears SUSP, and wakes the USB pad.
The pad goes to the Idle state if the module is disabled or if UDCON.DETACH is written to one.
It returns to the Active state when USBCON.USBE is written to one and DETACH is written to
zero.
SUSP Suspend detected Cleared on Wakeup
WAKEUP Wakeup detected Cleared by software to acknowledge the interrupt
PAD state
Active Idle Active
88
32142D–06/2013
ATUC64/128/256L3/4U
8.6.2 USBC Device Mode Operation
8.6.2.1 Device Enabling
In device mode, the USBC supports full- and low-speed data transfers.
Including the default control endpoint, a total of seven endpoints are provided. They can be configured
as isochronous, bulk or interrupt types, as described in Table 8-1 on page 81
After a hardware reset, the USBC device mode is in the reset state (see Section 8.6.1.1). In this
state, the endpoint banks are disabled and neither DP nor DM are pulled up (DETACH is one).
DP or DM will be pulled up according to the selected speed as soon as the DETACH bit is written
to zero. See “Device mode” for further details.
When the USBC is enabled (USBE is one) in device mode, it enters the Idle state, minimizing
power consumption. Being in Idle state does not require the USB clocks to be activated.
The USBC device mode can be disabled or reset at any time by disabling the USBC (by writing
a zero to USBE).
8.6.2.2 USB reset
The USB bus reset is initiated by a connected host and managed by hardware.
When a USB reset state is detected on the USB bus, the following operations are performed by
the controller:
• UDCON register is reset except for the DETACH and SPDCONF bits.
• Device Frame Number Register (UDFNUM), Endpoint n Configuration Register (UECFGn),
and Endpoint n Control Register (UECONn) registers are cleared.
• The data toggle sequencing in all the endpoints are cleared.
• At the end of the reset process, the End of Reset (EORST) bit in the UDINT register is set.
8.6.2.3 Endpoint activation
When an endpoint is disabled (UERST.EPENn = 0) the data toggle sequence, Endpoint n Status
Set (UESTAn), and UECONn registers will be reset. The controller ignores all transactions to
this endpoint as long as it is inactive.
To complete an endpoint activation, the user should fill out the endpoint descriptor: see Figure 8-
5 on page 91.
8.6.2.4 Data toggle sequence
In order to respond to a CLEAR_FEATURE USB request without disabling the endpoint, the
user can clear the data toggle sequence by writing a one to the Reset Data Toggle Set bit in the
Endpoint n Control Set register (UECONnSET.RSTDTS)
8.6.2.5 Busy bank enable
In order to make an endpoint bank look busy regardless of its actual state, the user can write a
one to the Busy Bank Enable bit in the Endpoint n Control Register (UECONnSET.BUSY0/1ES).
If a BUSYnE bit is set, any transaction to this bank will be rejected with a NAK reply.
8.6.2.6 Address setup
The USB device address is set up according to the USB protocol.
89
32142D–06/2013
ATUC64/128/256L3/4U
• After all kinds of resets, the USB device address is 0.
• The host starts a SETUP transaction with a SET_ADDRESS(addr) request.
• The user writes this address to the USB Address field (UDCON.UADD), and writes a zero to
the Address Enable bit (UDCON.ADDEN), resulting in the address remaining zero.
• The user sends a zero-length IN packet from the control endpoint.
• The user enables the stored USB device address by writing a one to ADDEN.
Once the USB device address is configured, the controller filters the packets to only accept
those targeting the address stored in UADD.
UADD and ADDEN should not be written to simultaneously. They should be written sequentially,
UADD field first.
If UADD or ADDEN is cleared, the default device address 0 is used. UADD and ADDEN are
cleared:
• On a hardware reset.
• When the USBC is disabled (USBE written to zero).
• When a USB reset is detected.
8.6.2.7 Suspend and Wakeup
When an idle USB bus state has been detected for 3 ms, the controller sets the Suspend
(SUSP) interrupt bit in UDINT. In this case, the transceiver is suspended, reducing power
consumption.
To further reduce power consumption it is recommended to freeze the USB clock by writing a
one to the Freeze USB Clock (FRZCLK) bit in USBCON when the USB bus is in suspend mode.
The MCU can also enter the idle or frozen sleep mode to further lower power consumption.
To recover from the suspend mode, the user shall wait for the Wakeup (WAKEUP) interrupt bit,
which is set when a non-idle event is detected, and then write a zero to FRZCLK.
As the WAKEUP interrupt bit in UDINT is set when a non-idle event is detected, it can occur
regardless of whether the controller is in the suspend mode or not. The SUSP and WAKEUP
interrupts are thus independent of each other except for that one bit is cleared when the other is
set.
8.6.2.8 Detach
The reset value of the DETACH bit located in the UDCON register, is one.
It is possible to initiate a device re-enumeration simply by writing a one and then a zero to
DETACH.
DETACH acts on the pull-up connections of the DP and DM pads. See “Device mode” for further
details.
8.6.2.9 Remote wakeup
The remote wakeup request (also known as upstream resume) is the only request the device
may send on its own initiative. This should be preceded by a DEVICE_REMOTE_WAKEUP
request from the host.
• First, the USBC must have detected a “Suspend” state on the bus, i.e. the remote wakeup
request can only be sent after a SUSP interrupt has been set.
90
32142D–06/2013
ATUC64/128/256L3/4U
• The user may then write a one to the remote wakeup (RMWKUP) bit in UDCON to send an
Upstream Resume to the host initiating the wakeup. This will automatically be done by the
controller after 5ms of inactivity on the USB bus.
• When the controller sends the Upstream Resume, the Upstream Resume (UPRSM) interrupt
is set and SUSP is cleared.
• RMWKUP is cleared at the end of the transmitting Upstream Resume.
• In case of a rebroadcast resume initiated by the host, the End of Resume (EORSM) interrupt
is set when the rebroadcast resume is completed.
8.6.2.10 RAM management
Endpoint data can be physically allocated anywhere in the embedded RAM. The USBC controller
accesses these endpoints directly through the HSB master (built-in DMA).
The USBC controller reads the USBC descriptors to know where each endpoint is located. The
base address of the USBC descriptor (UDESC.UDESCA) needs to be written by the user. The
descriptors can also be allocated anywhere in the embedded RAM.
Before using an endpoint, the user should setup the endpoint address for each bank. Depending
on the direction, the type, and the packet-mode (single or multi-packet), the user should also initialize
the endpoint packet size, and the endpoint control and status fields, so that the USBC
controller does not compute random values from the RAM.
When using an endpoint the user should read the UESTAX.CURRBK field to know which bank
is currently being processed.
91
32142D–06/2013
ATUC64/128/256L3/4U
Figure 8-5. Memory organization
Each descriptor of an endpoint n consists of four words.
• The address of the endpoint and the bank used (EPn_ADDR_BK0/1).
• The packet size information for the endpoint and bank (EPn_PCKSIZE_BK0/1):
Table 8-3. EPn_PCKSIZE_BK0/1 structure
– AUTO_ZLP: Auto zero length packet, see ”Multi packet mode for IN endpoints” on
page 96.
– MULTI_PACKET_SIZE: see ”Multi packet mode and single packet mode.” on page
93.
– BYTE_COUNT: see ”Multi packet mode and single packet mode.” on page 93.
31 30:16 15 14:0
AUTO_ZLP MULTI_PACKET_SIZE - BYTE_COUNT
EPn BK0
EP0_CTR_STA_BK0
E P 0 _ P C K S IZ E _ B K 0
EP0_ADDR_BK0 UDESCA
Growing Memory Addresses
Descriptor EP0
R e se rve d
EP0_CTR _STA_BK1
E P 0 _ P C K S IZ E _ B K 1
EP0_ADDR_BK1
R e se rve d
Bank0
Bank1
+0x000
+0x004
+0x008
+0x00C
+0x010
+0x014
+0x018
+0x01C
EP1_CTR_STA_BK0
E P 1 _ P C K S IZ E _ B K 0
EP1_ADDR_BK0
Descriptor EP1
R e se rve d
EP1_CTR _STA_BK1
E P 1 _ P C K S IZ E _ B K 1
EP1_ADDR_BK1
R e se rve d
Bank0
Bank1
+0x020
+0x024
+0x028
+0x02C
+0x030
+0x034
+0x038
+0x03C
EPn_CTR_STA_BK0
E P n _ P C K S IZ E _ B K 0
EPn_ADDR_BK0
R e se rve d
EPn_CTR _STA_BK1
E P n _ P C K S IZ E _ B K 1
EPn_ADDR_BK1
R e se rve d
Bank0
Bank1
Descriptor EPn
EPn BK1
U S B d e s c rip to rs
U S B B u ffe rs
92
32142D–06/2013
ATUC64/128/256L3/4U
• The control and status fields for the endpoint and bank (EPn_CTR_STA_BK0/1):
Table 8-4. EPn_CTR_STA_BK0/1 structure
– UNDERF: Underflow status for isochronous IN transfer. See ”Data flow error” on
page 99.
– OVERF: Overflow status for isochronous OUT transfer. See ”Data flow error” on
page 99.
– CRCERR: CRC error status for isochronous OUT transfer. See ”CRC error” on page
99.
– STALLRQ_NEXT: Stall request for the next transfer. See ”STALL request” on page
92.
8.6.2.11 STALL request
For each endpoint, the STALL management is performed using:
• The STALL Request (STALLRQ) bit in UECONn is set to initiate a STALL request.
• The STALLed Interrupt (STALLEDI) bit in UESTAn is set when a STALL handshake has been
sent.
To answer requests with a STALL handshake, STALLRQ has to be set by writing a one to the
STALL Request Set (STALLRQS) bit. All following requests will be discarded (RXOUTI, etc. will
not be set) and handshaked with a STALL until the STALLRQ bit is cleared, by receiving a new
SETUP packet (for control endpoints) or by writing a one to the STALL Request Clear (STALLRQC)
bit.
Each time a STALL handshake is sent, the STALLEDI bit is set by the USBC and the EPnINT
interrupt is set.
The user can use the descriptor to manage STALL requests. The USBC controller reads the
EPn_CTR_STA_BK0/1.STALLRQ_NEXT bit after successful transactions and if it is one the
USBC controller will set UECON.STALLRQ. The STALL_NEXT bit will be cleared upon receiving
a SETUP transaction and the USBC controller will then clear the STALLRQ bit.
• Special considerations for control endpoints
If a SETUP packet is received at a control endpoint where a STALL request is active, the
Received SETUP Interrupt (RXSTPI) bit in UESTAn is set, and the STALLRQ and STALLEDI
bits are cleared. It allows the SETUP to be always ACKed as required by the USB standard.
This management simplifies the enumeration process management. If a command is not supported
or contains an error, the user requests a STALL and can return to the main task, waiting
for the next SETUP request.
• STALL handshake and retry mechanism
The retry mechanism has priority over the STALL handshake. A STALL handshake is sent if the
STALLRQ bit is set and if there is no retry required.
31:19 18 17 16 15:1 0
Status elements Control elements
- UNDERF OVERF CRCERR - STALLRQ_NEXT
93
32142D–06/2013
ATUC64/128/256L3/4U
8.6.2.12 Multi packet mode and single packet mode.
Single packet mode is the default mode where one USB packet is managed per bank.
The multi-packet mode allows the user to manage data exceeding the maximum endpoint size
(UECFGn.EPSIZE) for an endpoint bank across multiple packets without software intervention.
This mode can also be coupled with the ping-pong mode.
• For an OUT endpoint, the EPn_PCKSIZE_BK0/1.MULTI_PACKET_SIZE field should be
configured correctly to enable the multi-packet mode. See ”Multi packet mode for OUT
endpoints” on page 98. For single packet mode, the MULTI_PACKET_SIZE should be
initialized to 0.
• For an IN endpoint, the EPn_PCKSIZE_BK0/1.BYTE_COUNT field should be configured
correctly to enable the multi-packet mode. See”Multi packet mode for IN endpoints” on page
96. For single packet mode, the BYTE_COUNT should be less than EPSIZE.
8.6.2.13 Management of control endpoints
• Overview
A SETUP request is always ACKed. When a new SETUP packet is received, the RXSTPI is set,
but not the Received OUT Data Interrupt (RXOUTI) bit.
The FIFO Control (FIFOCON) bit in UECONn is irrelevant for control endpoints. The user should
therefore never use it for these endpoints. When read, this value is always zero.
Control endpoints are managed using:
• The RXSTPI bit: is set when a new SETUP packet is received. This has to be cleared by
firmware in order to acknowledge the packet and to free the bank.
• The RXOUTI bit: is set when a new OUT packet is received. This has to be cleared by
firmware in order to acknowledge the packet and to free the bank.
• The Transmitted IN Data Interrupt (TXINI) bit: is set when the current bank is ready to accept
a new IN packet. This has to be cleared by firmware in order to send the packet.
• Control write
Figure 8-6 on page 94 shows a control write transaction. During the status stage, the controller
will not necessarily send a NAK on the first IN token:
• If the user knows the exact number of descriptor bytes that will be read, the status stage can
be predicted, and a zero-length packet can be sent after the next IN token.
• Alternatively the bytes can be read until the NAKed IN Interrupt (NAKINI) is triggered,
notifying that all bytes are sent by the host and that the transaction is now in the status stage.
94
32142D–06/2013
ATUC64/128/256L3/4U
Figure 8-6. Control Write
• Control read
Figure 8-7 on page 94 shows a control read transaction. The USBC has to manage the simultaneous
write requests from the CPU and USB host.
Figure 8-7. Control Read
A NAK handshake is always generated as the first status stage command. The UESTAn.NAKINI
bit is set. It allows the user to know that the host aborts the IN data stage. As a consequence,
the user should stop processing the IN data stage and should prepare to receive the OUT status
stage by checking the UESTAn.RXOUTI bit.
The OUT retry is always ACKed. This OUT reception sets RXOUTI. Handle this with the following
software algorithm:
// process the IN data stage
set TXINI
wait for RXOUTI (rising) OR TXINI (falling)
if RXOUTI is high, then process the OUT status stage
if TXINI is low, then return to process the IN data stage
Once the OUT status stage has been received, the USBC waits for a SETUP request. The
SETUP request has priority over all other requests and will be ACKed.
SETUP
RXSTPI
RXOUTI
TXINI
USB Bus
HW SW
OUT
HW SW
OUT
HW SW
IN IN
NAK
SW
SETUP STATUS DATA
SETUP
RXSTPI
RXOUTI
TXINI
USB Bus
HW SW
IN
HW SW
IN OUT OUT
NAK
SW
SW
HW
Wr Enable
HOST
Wr Enable
CPU
SETUP STATUS DATA
95
32142D–06/2013
ATUC64/128/256L3/4U
8.6.2.14 Management of IN endpoints
• Overview
IN packets are sent by the USBC device controller upon IN requests from the host.
The endpoint and its descriptor in RAM must be pre configured (see section ”RAM management”
on page 90 for more details).
When the current bank is clear, the TXINI and FIFO Control (UECONn.FIFOCON) bits will be set
simultaneously. This triggers an EPnINT interrupt if the Transmitted IN Data Interrupt Enable
(TXINE) bit in UECONn is one.
TXINI shall be cleared by software (by writing a one to the Transmitted IN Data Interrupt Enable
Clear bit in the Endpoint n Control Clear register (UECONnCLR.TXINIC)) to acknowledge the
interrupt. This has no effect on the endpoint FIFO.
The user writes the IN data to the bank referenced by the EPn descriptor and allows the USBC
to send the data by writing a one to the FIFO Control Clear (UECONnCLR.FIFOCONC) bit. This
will also cause a switch to the next bank if the IN endpoint is composed of multiple banks. The
TXINI and FIFOCON bits will be updated accordingly.
TXINI should always be cleared before clearing FIFOCON to avoid missing an TXINI event.
Figure 8-8. Example of an IN endpoint with one data bank
Figure 8-9. Example of an IN endpoint with two data banks
IN DATA
(bank 0) ACK
TXINI
FIFOCON
HW
write data to CPU
BANK 0
SW
SW SW
SW
IN
NAK
write data to CPU
BANK 0
IN DATA
(bank 0) ACK
TXINI
FIFOCON write data to CPU
BANK 0
SW
SW SW
SW
IN DATA
(bank 1) ACK
write data to CPU
BANK 1
SW
HW
write data to CPU
BANK0
96
32142D–06/2013
ATUC64/128/256L3/4U
• Detailed description
The data is written according to this sequence:
• When the bank is empty, TXINI and FIFOCON are set, which triggers an EPnINT interrupt if
TXINE is one.
• The user acknowledges the interrupt by clearing TXINI.
• The user reads the UESTAX.CURRBK field to see which the current bank is.
• The user writes the data to the current bank, located in RAM as described by its descriptor:
EPn_ADDR_BK0/1.
• The user should write the size of the IN packet into the USB descriptor:
EPn_PCKSIZE_BK0/1.BYTE_COUNT.
• The user allows the controller to send the bank contents and switches to the next bank (if
any) by clearing FIFOCON.
If the endpoint uses several banks, the current one can be written while the previous one is
being read by the host. When the user clears FIFOCON, the next current bank may already be
clear and TXINI is set immediately.
An “Abort” stage can be produced when a zero-length OUT packet is received during an IN
stage of a control or isochronous IN transaction. The Kill IN Bank (KILLBK) bit in UECONn is
used to kill the last written bank. The best way to manage this abort is to apply the algorithm represented
on Figure 8-10 on page 96. See ”Endpoint n Control Register” on page 130 for more
details about the KILLBK bit.
Figure 8-10. Abort Algorithm
• Multi packet mode for IN endpoints
In multi packet mode, the user can prepare n USB packets in the bank to be sent on a multiple
IN transaction. The packet sizes will equal UECFGn.EPSIZE unless the AUTO_ZLP option is
Endpoint
Abort
Abort Done
Abort is based on the fact
that no bank is busy, i.e.,
that nothing has to be sent
Disable the TXINI interrupt.
EPRSTn = 1
NBUSYBK
== 0?
Yes
TXINEC = 1
No
KILLBKS = 1
KILLBK
Yes == 1?
Kill the last written bank.
Wait for the end of the
procedure
No
97
32142D–06/2013
ATUC64/128/256L3/4U
set, or if the total byte count is not an integral multiple of EPSIZE, whereby the last packet
should be short.
To enable the multi packet mode, the user should configure the endpoint descriptor
(EPn_PCKSIZE_BK0/1.BYTE_COUNT) to the total size of the multi packet, which should be
larger than the endpoint size (EPSIZE).
Since the EPn_PCKSIZE_BK0/1.MULTI_PACKET_SIZE is incremented (by the transmitted
packet size) after each successful transaction, it should be set to zero when setting up a new
multi packet transfer.
The EPn_PCKSIZE_BK0/1.MULTI_PACKET_SIZE is cleared by hardware when all the bank
contents have been sent. The bank is considered as ready and the TX_IN flag is set when:
• A short packet (smaller than EPSIZE) has been transmitted.
• A packet has been successfully transmitted, the updated MULTI_PACKET_SIZE equals the
BYTE_COUNT, and the AUTO_ZLP field is not set.
• An extra zero length packet has been automatically sent for the last transfer of the current
bank, if BYTE_COUNT is a multiple of EPSIZE and AUTO_ZLP is set.
8.6.2.15 Management of OUT endpoints
• Overview
The endpoint and its descriptor in RAM must be pre configured, see section ”RAM management”
on page 90 for more details.
When the current bank is full, the RXOUTI and FIFO Control (UECONn.FIFOCON) bits will be
set simultaneously. This triggers an EPnINT interrupt if the Received OUT Data Interrupt Enable
(RXOUTE) bit in UECONn is one.
RXOUTI shall be cleared by software (by writing a one to the Received OUT Data Interrupt Clear
(RXOUTIC) bit) to acknowledge the interrupt. This has no effect on the endpoint FIFO.
The user reads the OUT data from the RAM and clears the FIFOCON bit to free the bank. This
will also cause a switch to the next bank if the OUT endpoint is composed of multiple banks.
RXOUTI should always be cleared before clearing FIFOCON to avoid missing an RXOUTI
event.
Figure 8-11. Example of an OUT endpoint with one data bank
OUT DATA
(bank 0) ACK
RXOUTI
FIFOCON
HW
OUT DATA
(bank 0) ACK
HW
SW
SW
SW
read data from CPU
BANK 0
read data from CPU
BANK 0
NAK
98
32142D–06/2013
ATUC64/128/256L3/4U
Figure 8-12. Example of an OUT endpoint with two data banks
• Detailed description
Before using the OUT endpoint, one should properly initialize its descriptor for each bank. See
Figure 8-5 on page 91.
The data is read, according to this sequence:
• When the bank is full, RXOUTI and FIFOCON are set, which triggers an EPnINT interrupt if
RXOUTE is one.
• The user acknowledges the interrupt by writing a one to RXOUTIC in order to clear RXOUTI.
• The user reads the UESTAX.CURRBK field to know the current bank number.
• The user reads the byte count of the current bank from the descriptor in RAM
(EPn_PCKSIZE_BK0/1.BYTE_COUNT) to know how many bytes to read.
• The user reads the data in the current bank, located in RAM as described by its descriptor:
EPn_ADDR_BK0/1.
• The user frees the bank and switches to the next bank (if any) by clearing FIFOCON.
If the endpoint uses several banks, the current one can be read while the next is being written by
the host. When the user clears FIFOCON, the following bank may already be ready and RXOUTI
will be immediately set.
• Multi packet mode for OUT endpoints
In multi packet mode, the user can extend the size of the bank allowing the storage of n USB
packets in the bank.
To enable the multi packet mode, the user should configure the endpoint descriptor
(EPn_PCKSIZE_BK0/1.MULTI_PACKET_SIZE) to match the size of the multi packet.This value
should be a multiple of the endpoint size (UECFGn.EPSIZE).
Since the EPn_PCKSIZE_BK0/1.BYTE_COUNT is incremented (by the received packet size)
after each successful transaction, it should be set to zero when setting up a new multi packet
transfer.
As for single packet mode, the number of received data bytes is stored in the BYTE_CNT field.
The bank is considered as “valid” and the RX_OUT flag is set when:
OUT DATA
(bank 0)
ACK
RXOUTI
FIFOCON
HW
OUT DATA
(bank 1) ACK
SW
read data from CPU SW
BANK 0
HW
SW
read data from CPU
BANK 1
99
32142D–06/2013
ATUC64/128/256L3/4U
• A packet has been successfully received and the updated BYTE_COUNT equals the
MULTI_PACKET_SIZE.
• A short packet (smaller than EPSIZE) has been received.
8.6.2.16 Data flow error
This error exists only for isochronous IN/OUT endpoints. It sets the Errorflow Interrupt
(ERRORFI) bit in UESTAn, which triggers an EPnINT interrupt if the Errorflow Interrupt Enable
(ERRORFE) bit is one. The user can check the EPn_CTR_STA_BK0/1.UNDERF and OVERF
bits in the endpoint descriptor to see which current bank has been affected.
• An underflow can occur during IN stage if the host attempts to read from an empty bank. A
zero-length packet is then automatically sent by the USBC. The endpoint descriptor
EPn_CTR_STA_BK0/1.UNDERF points out the bank from which the IN data should have
originated. If a new successful transaction occurs, the UNDERF bit is overwritten to 0 only if
the UESTAn.ERRORFI is cleared.
• An overflow can occur during the OUT stage if the host tries to send a packet while the bank
is full. Typically this occurs when a CPU is not fast enough. The packet data is not written to
the bank and is lost. The endpoint descriptor EPn_CTR_STA_BK0/1.OVERF points out
which bank the OUT data was destined to. If the UESTAn.ERRORFI bit is cleared and a new
transaction is successful, the OVERF bit will be overwritten to zero.
8.6.2.17 CRC error
This error exists only for isochronous OUT endpoints. It sets the CRC Error Interrupt (CRCERRI)
bit in UESTAn, which triggers an EPnINT interrupt if the CRC Error Interrupt Enable
(CRCERRE) bit is one.
A CRC error can occur during an isochronous OUT stage if the USBC detects a corrupted
received packet. The OUT packet is stored in the bank as if no CRC error had occurred
(RXOUTI is set).
The user can also check the endpoint descriptor to see which current bank is impacted by the
CRC error by reading EPn_CTR_STA_BK0/1.CRCERR.
8.6.2.18 Interrupts
There are two kinds of device interrupts: processing, i.e. their generation is part of the normal
processing, and exception, i.e. errors not related to CPU exceptions.
• Global interrupts
The processing device global interrupts are:
• The Suspend (SUSP) interrupt
• The Start of Frame (SOF) interrupt with no frame number CRC error (the Frame Number
CRC Error (FNCERR) bit in the Device Frame Number (UDFNUM) register is zero)
• The End of Reset (EORST) interrupt
• The Wakeup (WAKEUP) interrupt
• The End of Resume (EORSM) interrupt
• The Upstream Resume (UPRSM) interrupt
• The Endpoint n (EPnINT) interrupt
The exception device global interrupts are:
100
32142D–06/2013
ATUC64/128/256L3/4U
• The Start of Frame (SOF) interrupt with a frame number CRC error (FNCERR is one)
• Endpoint interrupts
The processing device endpoint interrupts are:
• The Transmitted IN Data Interrupt (TXINI)
• The Received OUT Data Interrupt (RXOUTI)
• The Received SETUP Interrupt (RXSTPI)
• The Number of Busy Banks (NBUSYBK) interrupt
The exception device endpoint interrupts are:
• The Errorflow Interrupt (ERRORFI)
• The NAKed OUT Interrupt (NAKOUTI)
• The NAKed IN Interrupt (NAKINI)
• The STALLed Interrupt (STALLEDI)
• The CRC Error Interrupt (CRCERRI)
101
32142D–06/2013
ATUC64/128/256L3/4U
8.7 User Interface
Note: 1. The reset values are device specific. Please refer to the Module Configuration section at the end of this chapter.
Table 8-5. USBC Register Memory Map
Offset Register Name Access Reset Value
0x0000 Device General Control Register UDCON Read/Write 0x00000100
0x0004 Device Global Interrupt Register UDINT Read-Only 0x00000000
0x0008 Device Global Interrupt Clear Register UDINTCLR Write-Only 0x00000000
0x000C Device Global Interrupt Set Register UDINTSET Write-Only 0x00000000
0x0010 Device Global Interrupt Enable Register UDINTE Read-Only 0x00000000
0x0014 Device Global Interrupt Enable Clear Register UDINTECLR Write-Only 0x00000000
0x0018 Device Global Interrupt Enable Set Register UDINTESET Write-Only 0x00000000
0x001C Endpoint Enable/Reset Register UERST Read/Write 0x00000000
0x0020 Device Frame Number Register UDFNUM Read-Only 0x00000000
0x0100 + n*4 Endpoint n Configuration Register UECFGn Read/Write 0x00000000
0x0130 + n*4 Endpoint n Status Register UESTAn Read-Only 0x00000100
0x0160 + n*4 Endpoint n Status Clear Register UESTAnCLR Write-Only 0x00000000
0x0190 + n*4 Endpoint n Status Set Register UESTAnSET Write-Only 0x00000000
0x01C0 + n*4 Endpoint n Control Register UECONn Read-Only 0x00000000
0x01F0 + n*4 Endpoint n Control Set Register UECONnSET Write-Only 0x00000000
0x0220 + n*4 Endpoint n Control Clear Register UECONnCLR Write-Only 0x00000000
0x0800 General Control Register USBCON Read/Write 0x00004000
0x0804 General Status Register USBSTA Read-Only 0x00000000
0x0808 General Status Clear Register USBSTACLR Write-Only 0x00000000
0x080C General Status Set Register USBSTASET Write-Only 0x00000000
0x0818 IP Version Register UVERS Read-Only -(1)
0x081C IP Features Register UFEATURES Read-Only -(1)
0x0820 IP PB Address Size Register UADDRSIZE Read-Only -(1)
0x0824 IP Name Register 1 UNAME1 Read-Only -(1)
0x0828 IP Name Register 2 UNAME2 Read-Only -(1)
0x082C USB Finite State Machine Status Register USBFSM Read-Only 0x00000009
0x0830 USB Descriptor address UDESC Read/Write 0x00000000
102
32142D–06/2013
ATUC64/128/256L3/4U
8.7.1 USB General Registers
8.7.1.1 General Control Register
Name: USBCON
Access Type: Read/Write
Offset: 0x0800
Reset Value: 0x00004000
• USBE: USBC Enable
Writing a zero to this bit will disable the USBC, USB transceiver, and USB clock inputs. This will over-ride FRZCLK settings but
not affect the value. Unless explicitly stated, all registers will become reset and read-only.
Writing a one to this bit will enable the USBC.
0: The USBC is disabled.
1: The USBC is enabled.
This bit can be written to even if FRZCLK is one.
• FRZCLK: Freeze USB Clock
Writing a zero to this bit will enable USB clock inputs.
Writing a one to this bit will disable USB clock inputs. The resume detection will remain active. Unless explicitly stated, all
registers will become read-only.
0: The clock inputs are enabled.
1: The clock inputs are disabled.
This bit can be written to even if USBE is zero.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
-- - -- -
15 14 13 12 11 10 9 8
USBE FRZCLK - - - - - -
76543210
--------
103
32142D–06/2013
ATUC64/128/256L3/4U
8.7.1.2 General Status Register
Register Name: USBSTA
Access Type: Read-Only
Offset: 0x0804
Reset Value: 0x00000000
• CLKUSABLE: Generic Clock Usable
This bit is cleared when the USB generic clock is not usable.
This bit is set when the USB generic clock (that should be 48 Mhz) is usable.
• SPEED: Speed Status
This field is set according to the controller speed mode.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
- CLKUSABLE SPEED - - - -
76543210
--------
SPEED Speed Status
00 full-speed mode
01 Reserved
10 low-speed mode
11 Reserved
104
32142D–06/2013
ATUC64/128/256L3/4U
8.7.1.3 General Status Clear Register
Register Name: USBSTACLR
Access Type: Write-Only
Offset: 0x0808
Reset Value: 0x00000000
Writing a zero to a bit in this register has no effect.
Writing a one to a bit in this register will clear the corresponding bit in USBSTA.
These bits always read as zero.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
--------
76543210
--------
105
32142D–06/2013
ATUC64/128/256L3/4U
8.7.1.4 General Status Set Register
Register Name: USBSTASET
Access Type: Write-Only
Offset: 0x080C
Reset Value: 0x00000000
Writing a zero to a bit in this register has no effect.
Writing a one to a bit in this register will set the corresponding bit in USBSTA.
These bits always read as zero.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
--------
76543210
--------
106
32142D–06/2013
ATUC64/128/256L3/4U
8.7.1.5 Version Register
Register Name: UVERS
Access Type: Read-Only
Offset: 0x0818
Reset Value: -
• VARIANT: Variant Number
Reserved. No functionality associated.
• VERSION: Version Number
Version number of the module. No functionality associated.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
- - - - VARIANT
15 14 13 12 11 10 9 8
- - - - VERSION[11:8]
76543210
VERSION[7:0]
107
32142D–06/2013
ATUC64/128/256L3/4U
8.7.1.6 Features Register
Register Name: UFEATURES
Access Type: Read-Only
Offset: 0x081C
Reset Value: -
• EPTNBRMAX: Maximal Number of pipes/endpoints
This field indicates the number of hardware-implemented pipes/endpoints:
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
--------
76543210
- - - - EPTNBRMAX
108
32142D–06/2013
ATUC64/128/256L3/4U
8.7.1.7 Address Size Register
Register Name: UADDRSIZE
Access Type: Read-Only
Offset: 0x0820
Reset Value: -
• UADDRSIZE: IP PB Address Size
This field indicates the size of the PB address space reserved for the USBC IP interface.
31 30 29 28 27 26 25 24
UADDRSIZE[31:24]
23 22 21 20 19 18 17 16
UADDRSIZE[23:16]
15 14 13 12 11 10 9 8
UADDRSIZE[15:8]
76543210
UADDRSIZE[7:0]
109
32142D–06/2013
ATUC64/128/256L3/4U
8.7.1.8 IP Name Register 1
Register Name: UNAME1
Access Type: Read-Only
Offset: 0x0824
Reset Value: -
• UNAME1: IP Name Part One
This field indicates the first part of the ASCII-encoded name of the USBC IP.
31 30 29 28 27 26 25 24
UNAME1[31:24]
23 22 21 20 19 18 17 16
UNAME1[23:16]
15 14 13 12 11 10 9 8
UNAME1[15:8]
76543210
UNAME1[7:0]
110
32142D–06/2013
ATUC64/128/256L3/4U
8.7.1.9 IP Name Register 2
Register Name: UNAME2
Access Type: Read-Only
Offset: 0x0828
Reset Value:
• UNAME2: IP Name Part Two
This field indicates the second part of the ASCII-encoded name of the USBC IP.
31 30 29 28 27 26 25 24
UNAME2[31:24]
23 22 21 20 19 18 17 16
UNAME2[23:16]
15 14 13 12 11 10 9 8
UNAME2[15:8]
76543210
UNAME2[7:0]
111
32142D–06/2013
ATUC64/128/256L3/4U
8.7.1.10 Finite State Machine Status Register
Register Name: USBFSM
Access Type: Read-Only
Offset: 0x082C
Reset Value: 0x00000009
• DRDSTATE: Dual Role Device State
This field indicates the state of the USBC.
For Device mode it should always read 9.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
--------
76543210
- - - - DRDSTATE
112
32142D–06/2013
ATUC64/128/256L3/4U
8.7.1.11 USB Descriptor Address
Register Name: UDESC
Access Type: Read-Write
Offset: 0x0830
Reset Value: -
• UDESCA: USB Descriptor Address
This field contains the address of the USB descriptor. The three least significant bits are always zero.
31 30 29 28 27 26 25 24
UDESCA[31:24]
23 22 21 20 19 18 17 16
UDESCA[23:16]
15 14 13 12 11 10 9 8
UDESCA[15:8]
76543210
UDESCA[7:0]
113
32142D–06/2013
ATUC64/128/256L3/4U
8.7.2 USB Device Registers
8.7.2.1 Device General Control Register
Register Name: UDCON
Access Type: Read/Write
Offset: 0x0000
Reset Value: 0x00000100
• GNAK: Global NAK
0: Normal mode.
1: A NAK handshake is answered for each USB transaction regardless of the current endpoint memory bank status.
• LS: low-speed mode force
0: The full-speed mode is active.
1: The low-speed mode is active.
This bit can be written to even if USBE is zero or FRZCLK is one. Disabling the USBC (by writing a zero to the USBE bit) does
not reset this bit.
• RMWKUP: Remote wakeup
Writing a zero to this bit has no effect.
Writing a one to this bit will send an upstream resume to the host for a remote wakeup.
This bit is cleared when the USBC receives a USB reset or once the upstream resume has been sent.
• DETACH: Detach
Writing a zero to this bit will reconnect the device.
Writing a one to this bit will physically detach the device (disconnect internal pull-up resistor from DP and DM).
• ADDEN: Address Enable
Writing a zero to this bit has no effect.
Writing a one to this bit will activate the UADD field (USB address).
This bit is cleared when a USB reset is received.
• UADD: USB Address
This field contains the device address.
This field is cleared when a USB reset is received.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
- - - - - - GNAK -
15 14 13 12 11 10 9 8
- - - LS - - RMWKUP DETACH
76543210
ADDEN UADD
114
32142D–06/2013
ATUC64/128/256L3/4U
8.7.2.2 Device Global Interrupt Register
Register Name: UDINT
Access Type: Read-Only
Offset: 0x0004
Reset Value: 0x00000000
Note: 1. EPnINT bits are within the range from EP0INT to EP6INT.
• EPnINT: Endpoint n Interrupt
This bit is cleared when the interrupt source is serviced.
This bit is set when an interrupt is triggered by the endpoint n (UESTAn, UECONn). This triggers a USB interrupt if EPnINTE is
one.
• UPRSM: Upstream Resume Interrupt
This bit is cleared when the UDINTCLR.UPRSMC bit is written to one to acknowledge the interrupt (USB clock inputs must be
enabled before).
This bit is set when the USBC sends a resume signal called “Upstream Resume”. This triggers a USB interrupt if UPRSME is
one.
• EORSM: End of Resume Interrupt
This bit is cleared when the UDINTCLR.EORSMC bit is written to one to acknowledge the interrupt.
This bit is set when the USBC detects a valid “End of Resume” signal initiated by the host. This triggers a USB interrupt if
EORSME is one.
• WAKEUP: Wakeup Interrupt
This bit is cleared when the UDINTCLR.WAKEUPC bit is written to one to acknowledge the interrupt (USB clock inputs must be
enabled before) or when the Suspend (SUSP) interrupt bit is set.
This bit is set when the USBC is reactivated by a filtered non-idle signal from the lines (not by an upstream resume). This
triggers an interrupt if WAKEUPE is one.
This interrupt is generated even if the clock is frozen by the FRZCLK bit.
• EORST: End of Reset Interrupt
This bit is cleared when the UDINTCLR.EORSTC bit is written to one to acknowledge the interrupt.
This bit is set when a USB “End of Reset” has been detected. This triggers a USB interrupt if EORSTE is one.
• SOF: Start of Frame Interrupt
This bit is cleared when the UDINTCLR.SOFC bit is written to one to acknowledge the interrupt.
This bit is set when a USB “Start of Frame” PID (SOF) has been detected (every 1 ms). This triggers a USB interrupt if SOFE is
one. The FNUM field is updated.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
- - - EP8INT(1) EP7INT(1) EP6INT(1) EP5INT(1) EP4INT(1)
15 14 13 12 11 10 9 8
EP3INT(1) EP2INT(1) EP1INT(1) EP0INT - - - -
76543210
- UPRSM EORSM WAKEUP EORST SOF - SUSP
115
32142D–06/2013
ATUC64/128/256L3/4U
• SUSP: Suspend Interrupt
This bit is cleared when the UDINTCLR.SUSPC bit is written to one to acknowledge the interrupt or when the Wakeup
(WAKEUP) interrupt bit is set.
This bit is set when a USB “Suspend” idle bus state has been detected for 3 frame periods (J state for 3 ms). This triggers a
USB interrupt if SUSPE is one.
116
32142D–06/2013
ATUC64/128/256L3/4U
8.7.2.3 Device Global Interrupt Clear Register
Register Name: UDINTCLR
Access Type: Write-Only
Offset: 0x0008
Reset Value: 0x00000000
Writing a zero to a bit in this register has no effect.
Writing a one to a bit in this register will clear the corresponding bit in UDINT.
These bits always read as zero.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
--------
76543210
- UPRSMC EORSMC WAKEUPC EORSTC SOFC - SUSPC
117
32142D–06/2013
ATUC64/128/256L3/4U
8.7.2.4 Device Global Interrupt Set Register
Register Name: UDINTSET
Access Type: Write-Only
Offset: 0x000C
Reset Value: 0x00000000
Writing a zero to a bit in this register has no effect.
Writing a one to a bit in this register will set the corresponding bit in UDINT, which may be useful for test or debug purposes.
These bits always read as zero.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
--------
76543210
- UPRSMS EORSMS WAKEUPS EORSTS SOFS - SUSPS
118
32142D–06/2013
ATUC64/128/256L3/4U
8.7.2.5 Device Global Interrupt Enable Register
Register Name: UDINTE
Access Type: Read-Only
Offset: 0x0010
Reset Value: 0x00000000
Note: 1. EPnINTE bits are within the range from EP0INTE to EP6INTE.
0: The corresponding interrupt is disabled.
1: The corresponding interrupt is enabled.
A bit in this register is cleared when the corresponding bit in UDINTECLR is written to one.
A bit in this register is set when the corresponding bit in UDINTESET is written to one.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
- - - EP8INTE(1) EP7INTE(1) EP6INTE(1) EP5INTE(1) EP4INTE(1)
15 14 13 12 11 10 9 8
EP3INTE(1) EP2INTE(1) EP1INTE(1) EP0INTE - - - -
76543210
- UPRSME EORSME WAKEUPE EORSTE SOFE - SUSPE
119
32142D–06/2013
ATUC64/128/256L3/4U
8.7.2.6 Device Global Interrupt Enable Clear Register
Register Name: UDINTECLR
Access Type: Write-Only
Offset: 0x0014
Reset Value: 0x00000000
Note: 1. EPnINTEC bits are within the range from EP0INTEC to EP6INTEC.
Writing a zero to a bit in this register has no effect.
Writing a one to a bit in this register will clear the corresponding bit in UDINTE.
These bits always read as zero.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
- - - EP8INTEC(1) EP7INTEC(1) EP6INTEC(1) EP5INTEC(1) EP4INTEC(1)
15 14 13 12 11 10 9 8
EP3INTEC(1) EP2INTEC(1) EP1INTEC(1) EP0INTEC - - - -
76543210
- UPRSMEC EORSMEC WAKEUPEC EORSTEC SOFEC - SUSPEC
120
32142D–06/2013
ATUC64/128/256L3/4U
8.7.2.7 Device Global Interrupt Enable Set Register
Register Name: UDINTESET
Access Type: Write-Only
Offset: 0x0018
Reset Value: 0x00000000
Note: 1. EPnINTES bits are within the range from EP0INTES to EP6INTES.
Writing a zero to a bit in this register has no effect.
Writing a one to a bit in this register will set the corresponding bit in UDINTE.
These bits always read as zero.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
- - - EP8INTES(1) EP7INTES(1) EP6INTES(1) EP5INTES(1) EP4INTES(1)
15 14 13 12 11 10 9 8
EP3INTES(1) EP2INTES(1) EP1INTES(1) EP0INTES - - - -
76543210
- UPRSMES EORSMES WAKEUPES EORSTES SOFES - SUSPES
121
32142D–06/2013
ATUC64/128/256L3/4U
8.7.2.8 Endpoint Enable/Reset Register
Register Name: UERST
Access Type: Read/Write
Offset: 0x001C
Reset Value: 0x00000000
• EPENn: Endpoint n Enable
Note: 1. EPENn bits are within the range from EPEN0 to EPEN6.
Writing a zero to this bit will disable the endpoint n (USB requests will be ignored), and resets the endpoints registers (UECFGn,
UESTAn, UECONn), but not the endpoint configuration (EPBK, EPSIZE, EPDIR, EPTYPE).
Writing a one to this bit will enable the endpoint n.
0: The endpoint n is disabled.
1: The endpoint n is enabled.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
- - - - - - - EPEN8(1)
76543210
EPEN7(1) EPEN6(1) EPEN5(1) EPEN4(1) EPEN3(1) EPEN2(1) EPEN1(1) EPEN0
122
32142D–06/2013
ATUC64/128/256L3/4U
8.7.2.9 Device Frame Number Register
Register Name: UDFNUM
Access Type: Read-Only
Offset: 0x0020
Reset Value: 0x00000000
• FNCERR: Frame Number CRC Error
This bit is cleared upon receiving a USB reset.
This bit is set when a corrupted frame number is received. This bit and the SOF interrupt bit are updated at the same time.
• FNUM: Frame Number
This field is cleared upon receiving a USB reset.
This field contains the 11-bit frame number information, as provided from the last SOF packet.
FNUM is updated even if a corrupted SOF is received.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
FNCERR - FNUM[10:5]
76543210
FNUM[4:0] - - -
123
32142D–06/2013
ATUC64/128/256L3/4U
8.7.2.10 Endpoint n Configuration Register
Register Name: UECFGn, n in [0..6]
Access Type: Read/Write
Offset: 0x0100 + (n * 0x04)
Reset Value: 0x00000000
• EPTYPE: Endpoint Type
This field selects the endpoint type:
This field is cleared upon receiving a USB reset.
• EPDIR: Endpoint Direction
0: The endpoint direction is OUT.
1: The endpoint direction is IN (nor for control endpoints).
This bit is cleared upon receiving a USB reset.
• EPSIZE: Endpoint Size
This field determines the size of each endpoint bank:
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
- - - EPTYPE - - EPDIR
76543210
- EPSIZE - EPBK - -
EPTYPE Endpoint Type
0 0 Control
0 1 Isochronous
1 0 Bulk
1 1 Interrupt
EPSIZE Endpoint Size
0 0 0 8 bytes
0 0 1 16 bytes
0 1 0 32 bytes
0 1 1 64 bytes
1 0 0 128 bytes
124
32142D–06/2013
ATUC64/128/256L3/4U
This field is cleared upon receiving a USB reset (except for the endpoint 0).
• EPBK: Endpoint Banks
This bit selects the number of banks for the endpoint:
0: single-bank endpoint
1: double-bank endpoint
For control endpoints, a single-bank endpoint shall be selected.
This field is cleared upon receiving a USB reset (except for the endpoint 0).
1 0 1 256 bytes
1 1 0 512 bytes
1 1 1 1024 bytes
EPSIZE Endpoint Size
125
32142D–06/2013
ATUC64/128/256L3/4U
8.7.2.11 Endpoint n Status Register
Register Name: UESTAn, n in [0..6]
Access Type: Read-Only 0x0100
Offset: 0x0130 + (n * 0x04)
Reset Value: 0x00000000
• CTRLDIR: Control Direction
Writing a zero or a one to this bit has no effect.
This bit is cleared after a SETUP packet to indicate that the following packet is an OUT packet.
This bit is set after a SETUP packet to indicate that the following packet is an IN packet.
• CURRBK: Current Bank
This bit is set for non-control endpoints, indicating the current bank:
This field may be updated one clock cycle after the RWALL bit changes, so the user should not poll this field as an interrupt bit.
• NBUSYBK: Number of Busy Banks
This field is set to indicate the number of busy banks:
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
- - - - - - CTRLDIR -
15 14 13 12 11 10 9 8
CURRBK NBUSYBK RAMACERI - DTSEQ
76543210
- STALLEDI/
CRCERRI - NAKINI NAKOUTI RXSTPI/
ERRORFI RXOUTI TXINI
CURRBK Current Bank
0 0 Bank0
0 1 Bank1
1 0 Reserved
1 1 Reserved
NBUSYBK Number of Busy Banks
0 0 0 (all banks free)
0 11
1 02
1 1 Reserved
126
32142D–06/2013
ATUC64/128/256L3/4U
For IN endpoints, this indicates the number of banks filled by the user and ready for IN transfers. When all banks are free an
EPnINT interrupt will be triggered if NBUSYBKE is one.
For OUT endpoints, this indicates the number of banks filled by OUT transactions from the host. When all banks are busy an
EPnINT interrupt will be triggered if NBUSYBKE is one.
• RAMACERI: Ram Access Error Interrupt
This bit is cleared when the RAMACERIC bit is written to one, acknowledging the interrupt.
This bit is set when a RAM access underflow error occurs during an IN data stage.
• DTSEQ: Data Toggle Sequence
This field is set to indicate the PID of the current bank:
For IN transfers, this indicates the data toggle sequence that will be used for the next packet to be sent.
For OUT transfers, this value indicates the data toggle sequence of the data received in the current bank.
• STALLEDI: STALLed Interrupt
This bit is cleared when the STALLEDIC bit is written to one, acknowledging the interrupt.
This bit is set when a STALL handshake has been sent and triggers an EPnINT interrupt if STALLEDE is one.
• CRCERRI: CRC Error Interrupt
This bit is cleared when the CRCERRIC bit is written to one, acknowledging the interrupt.
This bit is set when a CRC error has been detected in an isochronous OUT endpoint bank, and triggers an EPnINT interrupt if
CRCERRE is one.
• NAKINI: NAKed IN Interrupt
This bit is cleared when the NAKINIC bit is written to one, acknowledging the interrupt.
This bit is set when a NAK handshake has been sent in response to an IN request from the host, and triggers an EPnINT
interrupt if NAKINE is one.
• NAKOUTI: NAKed OUT Interrupt
This bit is cleared when the NAKOUTIC bit is written to one, acknowledging the interrupt.
This bit is set when a NAK handshake has been sent in response to an OUT request from the host, and triggers an EPnINT
interrupt if NAKOUTE is one.
• ERRORFI: Isochronous Error flow Interrupt
This bit is cleared when the ERRORFIC bit is written to one, acknowledging the interrupt.
This bit is set, for isochronous IN/OUT endpoints, when an errorflow (underflow or overflow) error occurs, and triggers an
EPnINT interrupt if ERRORFE is one.
An underflow can occur during IN stage if the host attempts to read from an empty bank. A zero-length packet is then
automatically sent by the USBC.
An overflow can also occur during OUT stage if the host sends a packet while the bank is already full, resulting in the packet
being lost. This is typically due to a CPU not being fast enough.
This bit is inactive (cleared) for bulk and interrupt IN/OUT endpoints and it means RXSTPI for control endpoints.
• RXSTPI: Received SETUP Interrupt
This bit is cleared when the RXSTPIC bit is written to one, acknowledging the interrupt and freeing the bank.
This bit is set, for control endpoints, to signal that the current bank contains a new valid SETUP packet, and triggers an EPnINT
interrupt if RXSTPE is one.
This bit is inactive (cleared) for bulk and interrupt IN/OUT endpoints and it means UNDERFI for isochronous IN/OUT endpoints.
• RXOUTI: Received OUT Data Interrupt
This bit is cleared when the RXOUTIC bit is written to one, acknowledging the interrupt. For control endpoints, it releases the
bank. For other endpoint types, the user should clear the FIFOCON bit to free the bank. RXOUTI shall always be cleared before
clearing FIFOCON to avoid missing an interrupt.
DTSEQ Data Toggle Sequence
0 0 Data0
0 1 Data1
1 X Reserved
127
32142D–06/2013
ATUC64/128/256L3/4U
This bit is set, for control endpoints, when the current bank contains a bulk OUT packet (data or status stage). This triggers an
EPnINT interrupt if RXOUTE is one.
This bit is set for isochronous, bulk and, interrupt OUT endpoints, at the same time as FIFOCON when the current bank is full.
This triggers an EPnINT interrupt if RXOUTE is one.
This bit is inactive (cleared) for isochronous, bulk and interrupt IN endpoints.
• TXINI: Transmitted IN Data Interrupt
This bit is cleared when the TXINIC bit is written to one, acknowledging the interrupt. For control endpoints, this will send the
packet. For other endpoint types, the user should clear the FIFOCON to allow the USBC to send the data. TXINI shall always be
cleared before clearing FIFOCON to avoid missing an interrupt.
This bit is set for control endpoints, when the current bank is ready to accept a new IN packet. This triggers an EPnINT interrupt
if TXINE is one.
This bit is set for isochronous, bulk and interrupt IN endpoints, at the same time as FIFOCON when the current bank is free.
This triggers an EPnINT interrupt if TXINE is one.
This bit is inactive (cleared) for isochronous, bulk and interrupt OUT endpoints.
128
32142D–06/2013
ATUC64/128/256L3/4U
8.7.2.12 Endpoint n Status Clear Register
Register Name: UESTAnCLR, n in [0..6]
Access Type: Write-Only
Offset: 0x0160 + (n * 0x04)
Reset Value: 0x00000000
Writing a zero to a bit in this register has no effect.
Writing a one to a bit in this register will clear the corresponding bit in UESTA.
These bits always read as zero.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
- - - - RAMACERIC - - -
76543210
- STALLEDIC/
CRCERRIC - NAKINIC NAKOUTIC RXSTPIC/
ERRORFIC RXOUTIC TXINIC
129
32142D–06/2013
ATUC64/128/256L3/4U
8.7.2.13 Endpoint n Status Set Register
Register Name: UESTAnSET, n in [0..6]
Access Type: Write-Only
Offset: 0x0190 + (n * 0x04)
Reset Value: 0x00000000
Writing a zero to a bit in this register has no effect.
Writing a one to a bit in this register will set the corresponding bit in UESTA.
These bits always read as zero.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
- - - NBUSYBKS RAMACERIS - -
76543210
- STALLEDIS/
CRCERRIS - NAKINIS NAKOUTIS RXSTPIS/
ERRORFIS RXOUTIS TXINIS
130
32142D–06/2013
ATUC64/128/256L3/4U
8.7.2.14 Endpoint n Control Register
Register Name: UECONn, n in [0..6]
Access Type: Read-Only
Offset: 0x01C0 + (n * 0x04)
Reset Value: 0x00000000
• BUSY0E: Busy Bank0 Enable
This bit is cleared when the BUSY0C bit is written to one.
This bit is set when the BUSY0ES bit is written to one. This will set the bank 0 as “busy”. All transactions, except SETUP,
destined to this bank will be rejected (i.e: NAK token will be answered).
• BUSY1E: Busy Bank1 Enable
This bit is cleared when the BUSY1C bit is written to one.
This bit is set when the BUSY1ES bit is written to one. This will set the bank 1 as “busy”. All transactions, except SETUP,
destined to this bank will be rejected (i.e: NAK token will be answered).
• STALLRQ: STALL Request
This bit is cleared when a new SETUP packet is received or when the STALLRQC bit is written to zero.
This bit is set when the STALLRQS bit is written to one, requesting a STALL handshake to be sent to the host.
• RSTDT: Reset Data Toggle
The data toggle sequence is cleared when the RSTDTS bit is written to one (i.e., Data0 data toggle sequence will be selected
for the next sent (IN endpoints) or received (OUT endpoints) packet.
This bit is always read as zero.
• FIFOCON: FIFO Control
For control endpoints:
The FIFOCON and RWALL bits are irrelevant. The software shall therefore never use them for these endpoints. When read,
their value is always 0.
For IN endpoints:
This bit is cleared when the FIFOCONC bit is written to one, sending the FIFO data and switching to the next bank.
This bit is set simultaneously to TXINI, when the current bank is free.
For OUT endpoints:
This bit is cleared when the FIFOCONC bit is written to one, freeing the current bank and switching to the next.
This bit is set simultaneously to RXINI, when the current bank is full.
31 30 29 28 27 26 25 24
- - - - - - BUSY1E BUSY0E
23 22 21 20 19 18 17 16
- - - - STALLRQ RSTDT - -
15 14 13 12 11 10 9 8
- FIFOCON KILLBK NBUSYBKE RAMACERE - -
76543210
- STALLEDE/
CRCERRE - NAKINE NAKOUTE RXSTPE/
ERRORFE RXOUTE TXINE
131
32142D–06/2013
ATUC64/128/256L3/4U
• KILLBK: Kill IN Bank
This bit is cleared by hardware after the completion of the “kill packet procedure”.
This bit is set when the KILLBKS bit is written to one, killing the last written bank.
The user shall wait for this bit to be cleared before trying to process another IN packet.
Caution: The bank is cleared when the “kill packet” procedure is completed by the USBC core:
If the bank is really killed, the NBUSYBK field is decremented.
If the bank sent instead of killed (IN transfer), the NBUSYBK field is decremented and the TXINI flag is set. This specific case
can occur if an IN token comes while the user tries to kill the bank.
Note: If two banks are ready to be sent, the above specific case will not occur, since the first bank is sent (IN transfer) while the
last bank is killed.
• NBUSYBKE: Number of Busy Banks Interrupt Enable
This bit is cleared when the NBUSYBKEC bit is written to zero, disabling the Number of Busy Banks interrupt (NBUSYBK).
This bit is set when the NBUSYBKES bit is written to one, enabling the Number of Busy Banks interrupt (NBUSYBK).
• RAMACERE: RAMACER Interrupt Enable
This bit is cleared when the RAMACEREC bit is written to one, disabling the RAMACER interrupt (RAMACERI).
This bit is set when the RAMACERES bit is written to one, enabling the RAMACER interrupt (RAMACERI).
• STALLEDE: STALLed Interrupt Enable
This bit is cleared when the STALLEDEC bit is written to one, disabling the STALLed interrupt (STALLEDI).
This bit is set when the STALLEDES bit is written to one, enabling the STALLed interrupt (STALLEDI).
• CRCERRE: CRC Error Interrupt Enable
This bit is cleared when the CRCERREC bit is written to one, disabling the CRC Error interrupt (CRCERRI).
This bit is set when the CRCERRES bit is written to one, enabling the CRC Error interrupt (CRCERRI).
• NAKINE: NAKed IN Interrupt Enable
This bit is cleared when the NAKINEC bit is written to one, disabling the NAKed IN interrupt (NAKINI).
This bit is set when the NAKINES bit is written to one, enabling the NAKed IN interrupt (NAKINI).
• NAKOUTE: NAKed OUT Interrupt Enable
This bit is cleared when the NAKOUTEC bit is written to one, disabling the NAKed OUT interrupt (NAKOUTI).
This bit is set when the NAKOUTES bit is written to one, enabling the NAKed OUT interrupt (NAKOUTI).
• RXSTPE: Received SETUP Interrupt Enable
This bit is cleared when the RXSTPEC bit is written to one, disabling the Received SETUP interrupt (RXSTPI).
This bit is set when the RXSTPES bit is written to one, enabling the Received SETUP interrupt (RXSTPI).
• ERRORFE: Errorflow Interrupt Enable
This bit is cleared when the ERRORFEC bit is written to one, disabling the Underflow interrupt (ERRORFI).
This bit is set when the ERRORFES bit is written to one, enabling the Underflow interrupt (ERRORFI).
• RXOUTE: Received OUT Data Interrupt Enable
This bit is cleared when the RXOUTEC bit is written to one, disabling the Received OUT Data interrupt (RXOUT).
This bit is set when the RXOUTES bit is written to one, enabling the Received OUT Data interrupt (RXOUT).
• TXINE: Transmitted IN Data Interrupt Enable
This bit is cleared when the TXINEC bit is written to one, disabling the Transmitted IN Data interrupt (TXINI).
This bit is set when the TXINES bit is written to one, enabling the Transmitted IN Data interrupt (TXINI).
132
32142D–06/2013
ATUC64/128/256L3/4U
8.7.2.15 Endpoint n Control Clear Register
Register Name: UECONnCLR, n in [0..6]
Access Type: Write-Only
Offset: 0x0220 + (n * 0x04)
Reset Value: 0x00000000
Writing a zero to a bit in this register has no effect.
Writing a one to a bit in this register will clear the corresponding bit in UECONn.
These bits always read as zero.
31 30 29 28 27 26 25 24
- - - - - - BUSY1EC BUSY0EC
23 22 21 20 19 18 17 16
- - - - STALLRQC - - -
15 14 13 12 11 10 9 8
- FIFOCONC - NBUSYBKEC RAMACEREC - - -
76543210
- STALLEDEC/
CRCERREC - NAKINEC NAKOUTEC RXSTPEC/
ERRORFEC RXOUTEC TXINEC
133
32142D–06/2013
ATUC64/128/256L3/4U
8.7.2.16 Endpoint n Control Set Register
Register Name: UECONnSET, n in [0..6]
Access Type: Write-Only
Offset: 0x01F0 + (n * 0x04)
Reset Value: 0x00000000
Writing a zero to a bit in this register has no effect.
Writing a one to a bit in this register will set the corresponding bit in UECONn.
These bits always read as zero.
•
•
31 30 29 28 27 26 25 24
- - - - - - BUSY1ES BUSY0ES
23 22 21 20 19 18 17 16
- - - - STALLRQS RSTDTS - -
15 14 13 12 11 10 9 8
- - KILLBKS NBUSYBKES RAMACERES ---
76543210
- STALLEDES/
CRCERRES - NAKINES NAKOUTES RXSTPES/
ERRORFES RXOUTES TXINES
134
32142D–06/2013
ATUC64/128/256L3/4U
8.8 Module Configuration
The specific configuration for each USBC instance is listed in the following tables. The module
bus clocks listed here are connected to the system bus clocks. Please refer to the Power Manager
chapter for details.
Table 8-6. USBC Clocks
Clock Name Description
CLK_USBC_PB Clock for the USBC PB interface
CLK_USBC_HSB Clock for the USBC HSB interface
GCLK_USBC The generic clock used for the USBC is GCLK7
Table 8-7. Register Reset Values
Register Reset Value
UVERS 0x00000200
UFEATURES 0x00000007
UADDRSIZE 0x00001000
UNAME1 0x48555342
UNAME2 0x00000000
135
32142D–06/2013
ATUC64/128/256L3/4U
9. Flash Controller (FLASHCDW)
Rev: 1.2.0.0
9.1 Features
• Controls on-chip flash memory
• Supports 0 and 1 wait state bus access
• Buffers reducing penalty of wait state in sequential code or loops
• Allows interleaved burst reads for systems with one wait state, outputting one 32-bit word per
clock cycle for sequential reads
• Secure State for supporting FlashVault technology
• 32-bit HSB interface for reads from flash and writes to page buffer
• 32-bit PB interface for issuing commands to and configuration of the controller
• Flash memory is divided into 16 regions can be individually protected or unprotected
• Additional protection of the Boot Loader pages
• Supports reads and writes of general-purpose Non Volatile Memory (NVM) bits
• Supports reads and writes of additional NVM pages
• Supports device protection through a security bit
• Dedicated command for chip-erase, first erasing all on-chip volatile memories before erasing
flash and clearing security bit
9.2 Overview
The Flash Controller (FLASHCDW) interfaces the on-chip flash memory with the 32-bit internal
HSB bus. The controller manages the reading, writing, erasing, locking, and unlocking
sequences.
9.3 Product Dependencies
In order to use this module, other parts of the system must be configured correctly, as described
below.
9.3.1 Power Management
If the CPU enters a sleep mode that disables clocks used by the FLASHCDW, the FLASHCDW
will stop functioning and resume operation after the system wakes up from sleep mode.
9.3.2 Clocks
The FLASHCDW has two bus clocks connected: One High Speed Bus clock
(CLK_FLASHCDW_HSB) and one Peripheral Bus clock (CLK_FLASHCDW_PB). These clocks
are generated by the Power Manager. Both clocks are enabled at reset, and can be disabled by
writing to the Power Manager. The user has to ensure that CLK_FLASHCDW_HSB is not turned
off before reading the flash or writing the pagebuffer and that CLK_FLASHCDW_PB is not
turned off before accessing the FLASHCDW configuration and control registers. Failing to do so
may deadlock the bus.
9.3.3 Interrupts
The FLASHCDW interrupt request lines are connected to the interrupt controller. Using the
FLASHCDW interrupts requires the interrupt controller to be programmed first.
136
32142D–06/2013
ATUC64/128/256L3/4U
9.3.4 Debug Operation
When an external debugger forces the CPU into debug mode, the FLASHCDW continues normal
operation. If the FLASHCDW is configured in a way that requires it to be periodically
serviced by the CPU through interrupts or similar, improper operation or data loss may result
during debugging.
9.4 Functional Description
9.4.1 Bus Interfaces
The FLASHCDW has two bus interfaces, one High Speed Bus (HSB) interface for reads from the
flash memory and writes to the page buffer, and one Peripheral Bus (PB) interface for issuing
commands and reading status from the controller.
9.4.2 Memory Organization
The flash memory is divided into a set of pages. A page is the basic unit addressed when programming
the flash. A page consists of several words. The pages are grouped into 16 regions of
equal size. Each of these regions can be locked by a dedicated fuse bit, protecting it from accidental
modification.
• p pages (FLASH_P)
• w bytes in each page and in the page buffer (FLASH_W)
• pw bytes in total (FLASH_PW)
• f general-purpose fuse bits (FLASH_F), used as region lock bits and for other device-specific
purposes
• 1 security fuse bit
• 1 User page
9.4.3 User Page
The User page is an additional page, outside the regular flash array, that can be used to store
various data, such as calibration data and serial numbers. This page is not erased by regular
chip erase. The User page can only be written and erased by a special set of commands. Read
accesses to the User page are performed just as any other read accesses to the flash. The
address map of the User page is given in Figure 9-1 on page 138.
9.4.4 Read Operations
The on-chip flash memory is typically used for storing instructions to be executed by the CPU.
The CPU will address instructions using the HSB bus, and the FLASHCDW will access the flash
memory and return the addressed 32-bit word.
In systems where the HSB clock period is slower than the access time of the flash memory, the
FLASHCDW can operate in 0 wait state mode, and output one 32-bit word on the bus per clock
cycle. If the clock frequency allows, the user should use 0 wait state mode, because this gives
the highest performance as no stall cycles are encountered.
The FLASHCDW can also operate in systems where the HSB bus clock period is faster than the
access speed of the flash memory. Wait state support and a read granularity of 64 bits ensure
efficiency in such systems.
Performance for systems with high clock frequency is increased since the internal read word
width of the flash memory is 64 bits. When a 32-bit word is to be addressed, the word itself and
137
32142D–06/2013
ATUC64/128/256L3/4U
also the other word in the same 64-bit location is read. The first word is output on the bus, and
the other word is put into an internal buffer. If a read to a sequential address is to be performed
in the next cycle, the buffered word is output on the bus, while the next 64-bit location is read
from the flash memory. Thus, latency in 1 wait state mode is hidden for sequential fetches.
The programmer can select the wait states required by writing to the FWS field in the Flash Control
Register (FCR). It is the responsibility of the programmer to select a number of wait states
compatible with the clock frequency and timing characteristics of the flash memory.
In 0ws mode, no wait states are encountered on any flash read operations. In 1 ws mode, one
stall cycle is encountered on the first access in a single or burst transfer. In 1 ws mode, if the first
access in a burst access is to an address that is not 64-bit aligned, an additional stall cycle is
also encountered when reading the second word in the burst. All subsequent words in the burst
are accessed without any stall cycles.
The Flash Controller provides two sets of buffers that can be enabled in order to speed up
instruction fetching. These buffers can be enabled by writing a one to the FCR.SEQBUF and
FCR.BRBUF bits. The SEQBUF bit enables buffering hardware optimizing sequential instruction
fetches. The BRBUF bit enables buffering hardware optimizing tight inner loops. These buffers
are never used when the flash is in 0 wait state mode. Usually, both these buffers should be
enabled when operating in 1 wait state mode. Some users requiring absolute cycle determinism
may want to keep the buffers disabled.
The Flash Controller address space is displayed in Figure 9-1. The memory space between
address pw and the User page is reserved, and reading addresses in this space returns an
undefined result. The User page is permanently mapped to an offset of 0x00800000 from the
start address of the flash memory.
Table 9-1. User Page Addresses
Memory type Start address, byte sized Size
Main array 0 pw bytes
User 0x00800000 w bytes
138
32142D–06/2013
ATUC64/128/256L3/4U
Figure 9-1. Memory Map for the Flash Memories
9.4.5 High Speed Read Mode
The flash provides a High Speed Read Mode, offering slightly higher flash read speed at the
cost of higher power consumption. Two dedicated commands, High Speed Read Mode Enable
(HSEN) and High Speed Read Mode Disable (HSDIS) control the speed mode. The High Speed
Mode (HSMODE) bit in the Flash Status Register (FSR) shows which mode the flash is in. After
reset, the High Speed Mode is disabled, and must be manually enabled if the user wants to.
Refer to the Electrical Characteristics chapter at the end of this datasheet for details on the maximum
clock frequencies in Normal and High Speed Read Mode.
0
pw
Reserved Flash data array
Reserved User Page
Flash with User Page
0x0080 0000
All addresses are byte addresses
Flash base address
Offset from
base address
139
32142D–06/2013
ATUC64/128/256L3/4U
Figure 9-2. High Speed Mode
9.4.6 Quick Page Read
A dedicated command, Quick Page Read (QPR), is provided to read all words in an addressed
page. All bits in all words in this page are AND’ed together, returning a 1-bit result. This result is
placed in the Quick Page Read Result (QPRR) bit in Flash Status Register (FSR). The QPR
command is useful to check that a page is in an erased state. The QPR instruction is much
faster than performing the erased-page check using a regular software subroutine.
9.4.7 Quick User Page Read
A dedicated command, Quick User Page Read (QPRUP), is provided to read all words in the
user page. All bits in all words in this page are AND’ed together, returning a 1-bit result. This
result is placed in the Quick Page Read Result (QPRR) bit in Flash Status Register (FSR). The
QPRUP command is useful to check that a page is in an erased state. The QPRUP instruction is
much faster than performing the erased-page check using a regular software subroutine.
9.4.8 Page Buffer Operations
The flash memory has a write and erase granularity of one page; data is written and erased in
chunks of one page. When programming a page, the user must first write the new data into the
Page Buffer. The contents of the entire Page Buffer is copied into the desired page in flash
memory when the user issues the Write Page command, Refer to Section 9.5.1 on page 141.
In order to program data into flash page Y, write the desired data to locations Y0 to Y31 in the
regular flash memory map. Writing to an address A in the flash memory map will not update the
flash memory, but will instead update location A%32 in the page buffer. The PAGEN field in the
Flash Command (FCMD) register will at the same time be updated with the value A/32.
Frequency
Frequency limit
for 0 wait state
operation
Normal
High
Speed mode
1 wait state
0 wait state
140
32142D–06/2013
ATUC64/128/256L3/4U
Figure 9-3. Mapping from Page Buffer to Flash
Internally, the flash memory stores data in 64-bit doublewords. Therefore, the native data size of
the Page Buffer is also a 64-bit doubleword. All locations shown in Figure 9-3 are therefore doubleword
locations. Since the HSB bus only has a 32-bit data width, two 32-bit HSB transfers
must be performed to write a 64-bit doubleword into the Page Buffer. The FLASHCDW has logic
to combine two 32-bit HSB transfers into a 64-bit data before writing this 64-bit data into the
Page Buffer. This logic requires the word with the low address to be written to the HSB bus
before the word with the high address. To exemplify, to write a 64-bit value to doubleword X0
residing in page X, first write a 32-bit word to the byte address pointing to address X0, thereafter
write a word to the byte address pointing to address (X0+4).
The page buffer is word-addressable and should only be written with aligned word transfers,
never with byte or halfword transfers. The page buffer can not be read.
The page buffer is also used for writes to the User page.
Page buffer write operations are performed with 4 wait states. Any accesses attempted to the
FLASHCDW on the HSB bus during these cycles will be automatically stalled.
Writing to the page buffer can only change page buffer bits from one to zero, i.e. writing
0xAAAAAAAA to a page buffer location that has the value 0x00000000 will not change the page
buffer value. The only way to change a bit from zero to one is to erase the entire page buffer with
the Clear Page Buffer command.
Z3 Z2 Z1 Z0
Z7 Z6 Z5 Z4
Z11 Z10 Z9 Z8
Z15 Z14 Z13 Z12
Z19 Z18 Z17 Z16
Z23 Z22 Z21 Z20
Z27 Z26 Z25 Z24
Z31 Z30 Z29 Z28
Y3 Y2 Y1 Y0
Y7 Y6 Y5 Y4
Y11 Y10 Y9 Y8
Y15 Y14 Y13 Y12
Y19 Y18 Y17 Y16
Y23 Y22 Y21 Y20
Y27 Y26 Y25 Y24
Y31 Y30 Y29 Y28
X3 X2 X1 X0
X7 X6 X5 X4
X11 X10 X9 X8
X15 X14 X13 X12
X19 X18 X17 X16
X23 X22 X21 X20
X27 X26 X25 X24
X31 X30 X29 X28
3 2 1 0
7 6 5 4
11 10 9 8
15 14 13 12
19 18 17 16
23 22 21 20
27 26 25 24
31 30 29 28
Page X
Page Y
Page Z
Page Buffer
64-bit data
Flash
All locations are doubleword locations
141
32142D–06/2013
ATUC64/128/256L3/4U
The page buffer is not automatically reset after a page write. The programmer should do this
manually by issuing the Clear Page Buffer flash command. This can be done after a page write,
or before the page buffer is loaded with data to be stored to the flash page.
9.5 Flash Commands
The FLASHCDW offers a command set to manage programming of the flash memory, locking
and unlocking of regions, and full flash erasing. See Section 9.8.2 for a complete list of
commands.
To run a command, the CMD field in the Flash Command Register (FCMD) has to be written
with the command number. As soon as the FCMD register is written, the FRDY bit in the Flash
Status Register (FSR) is automatically cleared. Once the current command is complete, the
FSR.FRDY bit is automatically set. If an interrupt has been enabled by writing a one to
FCR.FRDY, the interrupt request line of the Flash Controller is activated. All flash commands
except for Quick Page Read (QPR) and Quick User Page Read (QPRUP) will generate an interrupt
request upon completion if FCR.FRDY is one.
Any HSB bus transfers attempting to read flash memory when the FLASHCDW is busy executing
a flash command will be stalled, and allowed to continue when the flash command is
complete.
After a command has been written to FCMD, the programming algorithm should wait until the
command has been executed before attempting to read instructions or data from the flash or
writing to the page buffer, as the flash will be busy. The waiting can be performed either by polling
the Flash Status Register (FSR) or by waiting for the flash ready interrupt. The command
written to FCMD is initiated on the first clock cycle where the HSB bus interface in FLASHCDW
is IDLE. The user must make sure that the access pattern to the FLASHCDW HSB interface
contains an IDLE cycle so that the command is allowed to start. Make sure that no bus masters
such as DMA controllers are performing endless burst transfers from the flash. Also, make sure
that the CPU does not perform endless burst transfers from flash. This is done by letting the
CPU enter sleep mode after writing to FCMD, or by polling FSR for command completion. This
polling will result in an access pattern with IDLE HSB cycles.
All the commands are protected by the same keyword, which has to be written in the eight highest
bits of the FCMD register. Writing FCMD with data that does not contain the correct key
and/or with an invalid command has no effect on the flash memory; however, the PROGE bit is
set in the Flash Status Register (FSR). This bit is automatically cleared by a read access to the
FSR register.
Writing a command to FCMD while another command is being executed has no effect on the
flash memory; however, the PROGE bit is set in the Flash Status Register (FSR). This bit is
automatically cleared by a read access to the FSR register.
If the current command writes or erases a page in a locked region, or a page protected by the
BOOTPROT fuses, the command has no effect on the flash memory; however, the LOCKE bit is
set in the FSR register. This bit is automatically cleared by a read access to the FSR register.
9.5.1 Write/Erase Page Operation
Flash technology requires that an erase must be done before programming. The entire flash can
be erased by an Erase All command. Alternatively, pages can be individually erased by the
Erase Page command.
The User page can be written and erased using the mechanisms described in this chapter.
142
32142D–06/2013
ATUC64/128/256L3/4U
After programming, the page can be locked to prevent miscellaneous write or erase sequences.
Locking is performed on a per-region basis, so locking a region locks all pages inside the region.
Additional protection is provided for the lowermost address space of the flash. This address
space is allocated for the Boot Loader, and is protected both by the lock bit(s) corresponding to
this address space, and the BOOTPROT[2:0] fuses.
Data to be written is stored in an internal buffer called the page buffer. The page buffer contains
w words. The page buffer wraps around within the internal memory area address space and
appears to be repeated by the number of pages in it. Writing of 8-bit and 16-bit data to the page
buffer is not allowed and may lead to unpredictable data corruption.
Data must be written to the page buffer before the programming command is written to the Flash
Command Register (FCMD). The sequence is as follows:
• Reset the page buffer with the Clear Page Buffer command.
• Fill the page buffer with the desired contents as described in Section 9.4.8 on page 139.
• Programming starts as soon as the programming key and the programming command are
written to the Flash Command Register. The PAGEN field in the Flash Command Register
(FCMD) must contain the address of the page to write. PAGEN is automatically updated
when writing to the page buffer, but can also be written to directly. The FRDY bit in the Flash
Status Register (FSR) is automatically cleared when the page write operation starts.
• When programming is completed, the FRDY bit in the Flash Status Register (FSR) is set. If
an interrupt was enabled by writing FCR.FRDY to one, an interrupt request is generated.
Two errors can be detected in the FSR register after a programming sequence:
• Programming Error: A bad keyword and/or an invalid command have been written in the
FCMD register.
• Lock Error: Can have two different causes:
– The page to be programmed belongs to a locked region. A command must be
executed to unlock the corresponding region before programming can start.
– A bus master without secure status attempted to program a page requiring secure
privileges.
9.5.2 Erase All Operation
The entire memory is erased if the Erase All command (EA) is written to the Flash Command
Register (FCMD). Erase All erases all bits in the flash array. The User page is not erased. All
flash memory locations, the general-purpose fuse bits, and the security bit are erased (reset to
0xFF) after an Erase All.
The EA command also ensures that all volatile memories, such as register file and RAMs, are
erased before the security bit is erased.
Erase All operation is allowed only if no regions are locked, and the BOOTPROT fuses are configured
with a BOOTPROT region size of 0. Thus, if at least one region is locked, the bit LOCKE
in FSR is set and the command is cancelled. If the LOCKE bit in FCR is one, an interrupt request
is set generated.
When the command is complete, the FRDY bit in the Flash Status Register (FSR) is set. If an
interrupt has been enabled by writing FCR.FRDY to one, an interrupt request is generated. Two
errors can be detected in the FSR register after issuing the command:
143
32142D–06/2013
ATUC64/128/256L3/4U
• Programming Error: A bad keyword and/or an invalid command have been written in the
FCMD register.
• Lock Error: At least one lock region is protected, or BOOTPROT is different from 0. The erase
command has been aborted and no page has been erased. A “Unlock region containing
given page” (UP) command must be executed to unlock any locked regions.
9.5.3 Region Lock Bits
The flash memory has p pages, and these pages are grouped into 16 lock regions, each region
containing p/16 pages. Each region has a dedicated lock bit preventing writing and erasing
pages in the region. After production, the device may have some regions locked. These locked
regions are reserved for a boot or default application. Locked regions can be unlocked to be
erased and then programmed with another application or other data.
To lock or unlock a region, the commands Lock Region Containing Page (LP) and Unlock
Region Containing Page (UP) are provided. Writing one of these commands, together with the
number of the page whose region should be locked/unlocked, performs the desired operation.
One error can be detected in the FSR register after issuing the command:
• Programming Error: A bad keyword and/or an invalid command have been written in the
FCMD register.
The lock bits are implemented using the lowest 16 general-purpose fuse bits. This means that
lock bits can also be set/cleared using the commands for writing/erasing general-purpose fuse
bits, see Section 9.6. The general-purpose bit being in an erased (1) state means that the region
is unlocked.
The lowermost pages in the flash can additionally be protected by the BOOTPROT fuses, see
Section 9.6.
9.6 General-purpose Fuse Bits
The flash memory has a number of general-purpose fuse bits that the application programmer
can use freely. The fuse bits can be written and erased using dedicated commands, and read
144
32142D–06/2013
ATUC64/128/256L3/4U
through a dedicated Peripheral Bus address. Some of the general-purpose fuse bits are
reserved for special purposes, and should not be used for other functions:
The BOOTPROT fuses protects the following address space for the Boot Loader:
Table 9-2. General-purpose Fuses with Special Functions
GeneralPurpose
fuse
number Name Usage
15:0 LOCK Region lock bits.
16 EPFL
External Privileged Fetch Lock. Used to prevent the CPU from
fetching instructions from external memories when in privileged
mode. This bit can only be changed when the security bit is
cleared. The address range corresponding to external
memories is device-specific, and not known to the Flash
Controller. This fuse bit is simply routed out of the CPU or bus
system, the Flash Controller does not treat this fuse in any
special way, except that it can not be altered when the security
bit is set.
If the security bit is set, only an external JTAG or aWire Chip
Erase can clear EPFL. No internal commands can alter EPFL if
the security bit is set.
When the fuse is erased (i.e. "1"), the CPU can execute
instructions fetched from external memories. When the fuse is
programmed (i.e. "0"), instructions can not be executed from
external memories.
This fuse has no effect in devices with no External Memory
Interface (EBI).
19:17 BOOTPROT
Used to select one of eight different bootloader sizes. Pages
included in the bootloader area can not be erased or
programmed except by a JTAG or aWire chip erase.
BOOTPROT can only be changed when the security bit is
cleared.
If the security bit is set, only an external JTAG or aWire Chip
Erase can clear BOOTPROT, and thereby allow the pages
protected by BOOTPROT to be programmed. No internal
commands can alter BOOTPROT or the pages protected by
BOOTPROT if the security bit is set.
21:20 SECURE
Used to configure secure state and secure state debug
capabilities. Decoded into SSE and SSDE signals as shown in
Table 9-5. Refer to the AVR32 Architecture Manual and the
AVR32UC Technical Reference Manual for more details on
SSE and SSDE.
22 UPROT
If programmed (i.e. “0”), the JTAG USER PROTECTION
feature is enabled. If this fuse is programmed some HSB
addresses will be accessible by JTAG access even if the flash
security fuse is programmed. Refer to the JTAG documentation
for more information on this functionality. This bit can only be
changed when the security bit is cleared.
145
32142D–06/2013
ATUC64/128/256L3/4U
The SECURE fuses have the following functionality:
To erase or write a general-purpose fuse bit, the commands Write General-Purpose Fuse Bit
(WGPB) and Erase General-Purpose Fuse Bit (EGPB) are provided. Writing one of these commands,
together with the number of the fuse to write/erase, performs the desired operation.
An entire General-Purpose Fuse byte can be written at a time by using the Program GP Fuse
Byte (PGPFB) instruction. A PGPFB to GP fuse byte 2 is not allowed if the flash is locked by the
security bit. The PFB command is issued with a parameter in the PAGEN field:
• PAGEN[2:0] - byte to write
• PAGEN[10:3] - Fuse value to write
All general-purpose fuses can be erased by the Erase All General-Purpose fuses (EAGP) command.
An EAGP command is not allowed if the flash is locked by the security bit.
Two errors can be detected in the FSR register after issuing these commands:
• Programming Error: A bad keyword and/or an invalid command have been written in the
FCMD register.
• Lock Error:
– A write or erase of the BOOTPROT or EPFL or UPROT fuse bits was attempted
while the flash is locked by the security bit.
– A write or erase of the SECURE fuse bits was attempted when SECURE mode was
enabled.
The lock bits are implemented using the lowest 16 general-purpose fuse bits. This means that
the 16 lowest general-purpose fuse bits can also be written/erased using the commands for
locking/unlocking regions, see Section 9.5.3.
Table 9-3. Boot Loader Area Specified by BOOTPROT
BOOTPROT
Pages protected by
BOOTPROT
Size of protected
memory
7 None 0
6 0-1 1Kbyte
5 0-3 2Kbyte
4 0-7 4Kbyte
3 0-15 8Kbyte
2 0-31 16Kbyte
1 0-63 32Kbyte
0 0-127 64Kbyte
Table 9-5. Secure State Configuration
SECURE Functionality SSE SSDE
00 Secure state disabled 0 0
01 Secure enabled, secure state debug enabled 1 1
10 Secure enabled, secure state debug disabled 1 0
11 Secure state disabled 0 0
146
32142D–06/2013
ATUC64/128/256L3/4U
9.7 Security Bit
The security bit allows the entire device to be locked from external JTAG, aWire, or other debug
access for code security. The security bit can be written by a dedicated command, Set Security
Bit (SSB). Once set, the only way to clear the security bit is through the JTAG or aWire Chip
Erase command.
Once the security bit is set, the following Flash Controller commands will be unavailable and
return a lock error if attempted:
• Write General-Purpose Fuse Bit (WGPB) to BOOTPROT or EPFL fuses
• Erase General-Purpose Fuse Bit (EGPB) to BOOTPROT or EPFL fuses
• Program General-Purpose Fuse Byte (PGPFB) of fuse byte 2
• Erase All General-Purpose Fuses (EAGPF)
One error can be detected in the FSR register after issuing the command:
• Programming Error: A bad keyword and/or an invalid command have been written in the
FCMD register.
147
32142D–06/2013
ATUC64/128/256L3/4U
9.8 User Interface
Note: 1. The value of the Lock bits depend on their programmed state. All other bits in FSR are 0.
2. All bits in FGPRHI/LO are dependent on the programmed state of the fuses they map to. Any bits in these registers not
mapped to a fuse read as 0.
3. The reset values for these registers are device specific. Please refer to the Module Configuration section at the end of this
chapter.
Table 9-6. FLASHCDW Register Memory Map
Offset Register Register Name Access Reset
0x00 Flash Control Register FCR Read/Write 0x00000000
0x04 Flash Command Register FCMD Read/Write 0x00000000
0x08 Flash Status Register FSR Read-only -(1)
0x0C Flash Parameter Register FPR Read-only -(3)
0x10 Flash Version Register FVR Read-only -(3)
0x14 Flash General Purpose Fuse Register Hi FGPFRHI Read-only -(2)
0x18 Flash General Purpose Fuse Register Lo FGPFRLO Read-only -(2)
148
32142D–06/2013
ATUC64/128/256L3/4U
9.8.1 Flash Control Register
Name: FCR
Access Type: Read/Write
Offset: 0x00
Reset Value: 0x00000000
• BRBUF: Branch Target Instruction Buffer Enable
0: The Branch Target Instruction Buffer is disabled.
1: The Branch Target Instruction Buffer is enabled.
• SEQBUF: Sequential Instruction Fetch Buffer Enable
0: The Sequential Instruction Fetch Buffer is disabled.
1: The Sequential Instruction Fetch Buffer is enabled.
• FWS: Flash Wait State
0: The flash is read with 0 wait states.
1: The flash is read with 1 wait state.
• PROGE: Programming Error Interrupt Enable
0: Programming Error does not generate an interrupt request.
1: Programming Error generates an interrupt request.
• LOCKE: Lock Error Interrupt Enable
0: Lock Error does not generate an interrupt request.
1: Lock Error generates an interrupt request.
• FRDY: Flash Ready Interrupt Enable
0: Flash Ready does not generate an interrupt request.
1: Flash Ready generates an interrupt request.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
- - - - - BRBUF SEQBUF -
76543210
- FWS - - PROGE LOCKE - FRDY
149
32142D–06/2013
ATUC64/128/256L3/4U
9.8.2 Flash Command Register
Name: FCMD
Access Type: Read/Write
Offset: 0x04
Reset Value: 0x00000000
The FCMD can not be written if the flash is in the process of performing a flash command. Doing
so will cause the FCR write to be ignored, and the PROGE bit in FSR to be set.
• KEY: Write protection key
This field should be written with the value 0xA5 to enable the command defined by the bits of the register. If the field is written
with a different value, the write is not performed and no action is started.
This field always reads as 0.
• PAGEN: Page number
The PAGEN field is used to address a page or fuse bit for certain operations. In order to simplify programming, the PAGEN field
is automatically updated every time the page buffer is written to. For every page buffer write, the PAGEN field is updated with the
page number of the address being written to. Hardware automatically masks writes to the PAGEN field so that only bits
representing valid page numbers can be written, all other bits in PAGEN are always 0. As an example, in a flash with 1024
pages (page 0 - page 1023), bits 15:10 will always be 0.
31 30 29 28 27 26 25 24
KEY
23 22 21 20 19 18 17 16
PAGEN [15:8]
15 14 13 12 11 10 9 8
PAGEN [7:0]
76543210
- - CMD
Table 9-7. Semantic of PAGEN field in different commands
Command PAGEN description
No operation Not used
Write Page The number of the page to write
Clear Page Buffer Not used
Lock region containing given Page Page number whose region should be locked
Unlock region containing given Page Page number whose region should be unlocked
Erase All Not used
Write General-Purpose Fuse Bit GPFUSE #
Erase General-Purpose Fuse Bit GPFUSE #
Set Security Bit Not used
150
32142D–06/2013
ATUC64/128/256L3/4U
• CMD: Command
This field defines the flash command. Issuing any unused command will cause the Programming Error bit in FSR to be set, and
the corresponding interrupt to be requested if the PROGE bit in FCR is one.
Program GP Fuse Byte WriteData[7:0], ByteAddress[2:0]
Erase All GP Fuses Not used
Quick Page Read Page number
Write User Page Not used
Erase User Page Not used
Quick Page Read User Page Not used
High Speed Mode Enable Not used
High Speed Mode Disable Not used
Table 9-8. Set of commands
Command Value Mnemonic
No operation 0 NOP
Write Page 1 WP
Erase Page 2 EP
Clear Page Buffer 3 CPB
Lock region containing given Page 4 LP
Unlock region containing given Page 5 UP
Erase All 6 EA
Write General-Purpose Fuse Bit 7 WGPB
Erase General-Purpose Fuse Bit 8 EGPB
Set Security Bit 9 SSB
Program GP Fuse Byte 10 PGPFB
Erase All GPFuses 11 EAGPF
Quick Page Read 12 QPR
Write User Page 13 WUP
Erase User Page 14 EUP
Quick Page Read User Page 15 QPRUP
High Speed Mode Enable 16 HSEN
High Speed Mode Disable 17 HSDIS
RESERVED 16-31
Table 9-7. Semantic of PAGEN field in different commands
Command PAGEN description
151
32142D–06/2013
ATUC64/128/256L3/4U
9.8.3 Flash Status Register
Name: FSR
Access Type: Read-only
Offset: 0x08
Reset Value: 0x00000000
• LOCKx: Lock Region x Lock Status
0: The corresponding lock region is not locked.
1: The corresponding lock region is locked.
• HSMODE: High-Speed Mode
0: High-speed mode disabled.
1: High-speed mode enabled.
• QPRR: Quick Page Read Result
0: The result is zero, i.e. the page is not erased.
1: The result is one, i.e. the page is erased.
• SECURITY: Security Bit Status
0: The security bit is inactive.
1: The security bit is active.
• PROGE: Programming Error Status
Automatically cleared when FSR is read.
0: No invalid commands and no bad keywords were written in the Flash Command Register FCMD.
1: An invalid command and/or a bad keyword was/were written in the Flash Command Register FCMD.
• LOCKE: Lock Error Status
Automatically cleared when FSR is read.
0: No programming of at least one locked lock region has happened since the last read of FSR.
1: Programming of at least one locked lock region has happened since the last read of FSR.
• FRDY: Flash Ready Status
0: The Flash Controller is busy and the application must wait before running a new command.
1: The Flash Controller is ready to run a new command.
31 30 29 28 27 26 25 24
LOCK15 LOCK14 LOCK13 LOCK12 LOCK11 LOCK10 LOCK9 LOCK8
23 22 21 20 19 18 17 16
LOCK7 LOCK6 LOCK5 LOCK4 LOCK3 LOCK2 LOCK1 LOCK0
15 14 13 12 11 10 9 8
--------
76543210
- HSMODE QPRR SECURITY PROGE LOCKE - FRDY
152
32142D–06/2013
ATUC64/128/256L3/4U
9.8.4 Flash Parameter Register
Name: FPR
Access Type: Read-only
Offset: 0x0C
Reset Value: -
• PSZ: Page Size
The size of each flash page.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
- - - - - PSZ
76543210
- - - - FSZ
Table 9-9. Flash Page Size
PSZ Page Size
0 32 Byte
1 64 Byte
2 128 Byte
3 256 Byte
4 512 Byte
5 1024 Byte
6 2048 Byte
7 4096 Byte
153
32142D–06/2013
ATUC64/128/256L3/4U
• FSZ: Flash Size
The size of the flash. Not all device families will provide all flash sizes indicated in the table.
Table 9-10. Flash Size
FSZ Flash Size FSZ Flash Size
0 4 Kbyte 8 192 Kbyte
1 8 Kbyte 9 256 Kbyte
2 16 Kbyte 10 384 Kbyte
3 32 Kbyte 11 512 Kbyte
4 48 Kbyte 12 768 Kbyte
5 64 Kbyte 13 1024 Kbyte
6 96 Kbyte 14 2048 Kbyte
7 128 Kbyte 15 Reserved
154
32142D–06/2013
ATUC64/128/256L3/4U
9.8.5 Flash Version Register
Name: FVR
Access Type: Read-only
Offset: 0x10
Reset Value: 0x00000000
• VARIANT: Variant Number
Reserved. No functionality associated.
• VERSION: Version Number
Version number of the module. No functionality associated.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
- - - - VARIANT
15 14 13 12 11 10 9 8
- - - - VERSION[11:8]
76543210
VERSION[7:0]
155
32142D–06/2013
ATUC64/128/256L3/4U
9.8.6 Flash General Purpose Fuse Register High
Name: FGPFRHI
Access Type: Read-only
Offset: 0x14
Reset Value: -
This register is only used in systems with more than 32 GP fuses.
• GPFxx: General Purpose Fuse xx
0: The fuse has a written/programmed state.
1: The fuse has an erased state.
31 30 29 28 27 26 25 24
GPF63 GPF62 GPF61 GPF60 GPF59 GPF58 GPF57 GPF56
23 22 21 20 19 18 17 16
GPF55 GPF54 GPF53 GPF52 GPF51 GPF50 GPF49 GPF48
15 14 13 12 11 10 9 8
GPF47 GPF46 GPF45 GPF44 GPF43 GPF42 GPF41 GPF40
76543210
GPF39 GPF38 GPF37 GPF36 GPF35 GPF34 GPF33 GPF32
156
32142D–06/2013
ATUC64/128/256L3/4U
9.8.7 Flash General Purpose Fuse Register Low
Name: FGPFRLO
Access Type: Read-only
Offset: 0x18
Reset Value: -
• GPFxx: General Purpose Fuse xx
0: The fuse has a written/programmed state.
1: The fuse has an erased state.
31 30 29 28 27 26 25 24
GPF31 GPF30 GPF29 GPF28 GPF27 GPF26 GPF25 GPF24
23 22 21 20 19 18 17 16
GPF23 GPF22 GPF21 GPF20 GPF19 GPF18 GPF17 GPF16
15 14 13 12 11 10 9 8
GPF15 GPF14 GPF13 GPF12 GPF11 GPF10 GPF09 GPF08
76543210
GPF07 GPF06 GPF05 GPF04 GPF03 GPF02 GPF01 GPF00
157
32142D–06/2013
ATUC64/128/256L3/4U
9.9 Fuse Settings
The flash contains 32 general purpose fuses. These 32 fuses can be found in the Flash General
Purpose Fuse Register Low (FGPFRLO). The Flash General Purpose Fuse Register High
(FGPFRHI) is not used. In addition to the general purpose fuses, parts of the flash user page
can have a defined meaning outside of the flash controller and will also be described in this
section.
Note that when writing to the user page the values do not get loaded by the other modules on
the device until a chip reset occurs.
The general purpose fuses are erased by a JTAG or aWire chip erase.
158
32142D–06/2013
ATUC64/128/256L3/4U
9.9.1 Flash General Purpose Fuse Register Low (FGPFRLO)
• BODEN: Brown Out Detector Enable
• BODHYST: Brown Out Detector Hysteresis
0: The Brown out detector hysteresis is disabled
1: The Brown out detector hysteresis is enabled
• BODLEVEL: Brown Out Detector Trigger Level
This controls the voltage trigger level for the Brown out detector. Refer to ”Electrical Characteristics” on page 897.
• UPROT, SECURE, BOOTPROT, EPFL, LOCK
These are Flash Controller fuses and are described in the FLASHCDW section.
9.9.1.1 Default Fuse Value
The devices are shipped with the FGPFRLO register value:0xE07FFFFF:
• BODEN fuses set to 11. BOD is disabled.
• BODHYST fuse set to 1. The BOD hysteresis is enabled.
• BODLEVEL fuses set to 000000. This is the minimum voltage trigger level for BOD. This level
is lower than the POR level, so when BOD is enabled, it will never trigger with this default
value.
• UPROT fuse set to 1.
• SECURE fuse set to 11.
• BOOTPROT fuses set to 111. The bootloader protection is disabled.
• EPFL fuse set to 1. External privileged fetch is not locked.
• LOCK fuses set to 1111111111111111. No region locked.
After the JTAG or aWire chip erase command, the FGPFR register value is 0xFFFFFFFF.
31 30 29 28 27 26 25 24
BODEN BODHYST BODLEVEL[5:1]
23 22 21 20 19 18 17 16
BODLEVEL[0] UPROT SECURE BOOTPROT EPFL
15 14 13 12 11 10 9 8
LOCK[15:8]
7 6543210
LOCK[7:0]
BODEN Description
00 BOD disabled
01 BOD enabled, BOD reset enabled
10 BOD enabled, BOD reset disabled
11 BOD disabled
159
32142D–06/2013
ATUC64/128/256L3/4U
9.9.2 First Word of the User Page (Address 0x80800000)
• WDTAUTO: WatchDog Timer Auto Enable at Startup
0: The WDT is automatically enabled at startup.
1: The WDT is not automatically enabled at startup.
Please refer to the WDT chapter for detail about timeout settings when the WDT is automatically enabled.
9.9.2.1 Default user page first word value
The devices are shipped with the user page erased (all bits 1):
• WDTAUTO set to 1, WDT disabled.
31 30 29 28 27 26 25 24
- -------
23 22 21 20 19 18 17 16
- -------
15 14 13 12 11 10 9 8
- -------
7 6543210
- - - - - - - WDTAUTO
160
32142D–06/2013
ATUC64/128/256L3/4U
9.9.3 Second Word of the User Page (Address 0x80800004)
• SSADRR: Secure State End Address for the RAM
• SSADRF: Secure State End Address for the Flash
9.9.3.1 Default user page second word value
The devices are shipped with the User page erased (all bits 1).
9.10 Serial Number
Each device has a unique 120 bits serial number readable from address 0x8080020C to
0x8080021A.
9.11 Module Configuration
The specific configuration for each FLASHCDW instance is listed in the following tables.The
module bus clocks listed here are connected to the system bus clocks. Please refer to the Power
Manager chapter for details.
31 30 29 28 27 26 25 24
SSADRR[15:8]
23 22 21 20 19 18 17 16
SSADRR[7:0]
15 14 13 12 11 10 9 8
SSADRF[15:8]
7 6543210
SSADRF[7:0]
Table 9-11. Module Configuration
Feature
ATUC256L3U,
ATUC256L4U
ATUC128L3U,
ATUC128L4U
ATUC64L3U,
ATUC64L4U
Flash size 256Kbytes 128Kbytes 64Kbytes
Number of pages 512 256 128
Page size 512 bytes 512 bytes 512 bytes
Table 9-12. Module Clock Name
Module Name Clock Name Description
FLASHCDW
CLK_FLASHCDW_HSB Clock for the FLASHCDW HSB interface
CLK_FLASHCDW_PB Clock for the FLASHCDW PB interface
161
32142D–06/2013
ATUC64/128/256L3/4U
Table 9-13. Register Reset Values
Register
ATUC256L3U,
ATUC256L4U
ATUC128L3U,
ATUC128L4U
ATUC64L3U,
ATUC64L4U
FVR 0x00000120 0x00000120 0x00000120
FPR 0x00000409 0x00000407 0x00000405
162
32142D–06/2013
ATUC64/128/256L3/4U
10. Secure Access Unit (SAU)
Rev: 1.1.1.3
10.1 Features
• Remaps registers in memory regions protected by the MPU to regions not protected by the MPU
• Programmable physical address for each channel
• Two modes of operation: Locked and Open
– In Locked Mode, access to a channel must be preceded by an unlock action
• An unlocked channel remains open only for a specific amount of time, if no access is
performed during this time, the channel is relocked
• Only one channel can be open at a time, opening a channel while another one is open
locks the first one
• Access to a locked channel is denied, a bus error and optionally an interrupt is returned
• If a channel is relocked due to an unlock timeout, an interrupt can optionally be
generated
– In Open Mode, all channels are permanently unlocked
10.2 Overview
In many systems, erroneous access to peripherals can lead to catastrophic failure. An example
of such a peripheral is the Pulse Width Modulator (PWM) used to control electric motors. The
PWM outputs a pulse train that controls the motor. If the control registers of the PWM module
are inadvertently updated with wrong values, the motor can start operating out of control, possibly
causing damage to the application and the surrounding environment. However, sometimes
the PWM control registers must be updated with new values, for example when modifying the
pulse train to accelerate the motor. A mechanism must be used to protect the PWM control registers
from inadvertent access caused by for example:
• Errors in the software code
• Transient errors in the CPU caused by for example electrical noise altering the execution path
of the program
To improve the security in a computer system, the AVR32UC implements a Memory Protection
Unit (MPU). The MPU can be set up to limit the accesses that can be performed to specific
memory addresses. The MPU divides the memory space into regions, and assigns a set of
access restrictions on each region. Access restrictions can for example be read/write if the CPU
is in supervisor mode, and read-only if the CPU is in application mode. The regions can be of different
size, but each region is usually quite large, e.g. protecting 1 kilobyte of address space or
more. Furthermore, access to each region is often controlled by the execution state of the CPU,
i.e. supervisor or application mode. Such a simple control mechanism is often too inflexible (too
coarse-grained chunks) and with too much overhead (often requiring system calls to access protected
memory locations) for simple or real-time systems such as embedded microcontrollers.
Usually, the Secure Access Unit (SAU) is used together with the MPU to provide the required
security and integrity. The MPU is set up to protect regions of memory, while the SAU is set up
to provide a secure channel into specific memory locations that are protected by the MPU.
These specific locations can be thought of as fine-grained overrides of the general coarsegrained
protection provided by the MPU.
163
32142D–06/2013
ATUC64/128/256L3/4U
10.3 Block Diagram
Figure 10-1 presents the SAU integrated in an example system with a CPU, some memories,
some peripherals, and a bus system. The SAU is connected to both the Peripheral Bus (PB) and
the High Speed Bus (HSB). Configuration of the SAU is done via the PB, while memory
accesses are done via the HSB. The SAU receives an access on its HSB slave interface,
remaps it, checks that the channel is unlocked, and if so, initiates a transfer on its HSB master
interface to the remapped address.
The thin arrows in Figure 10-1 exemplifies control flow when using the SAU. The CPU wants to
read the RX Buffer in the USART. The MPU has been configured to protect all registers in the
USART from user mode access, while the SAU has been configured to remap the RX Buffer into
a memory space that is not protected by the MPU. This unprotected memory space is mapped
into the SAU HSB slave space. When the CPU reads the appropriate address in the SAU, the
SAU will perform an access to the desired RX buffer register in the USART, and thereafter return
the read results to the CPU. The return data flow will follow the opposite direction of the control
flow arrows in Figure 10-1.
Figure 10-1. SAU Block Diagram
SAU Channel
Bus master
MPU
CPU
Bus slave
USART
PWM
Bus slave Bus master
Bus slave
Flash
Bus slave
RAM
Bus bridge
SAU Configuration
Interrupt
request
High Speed Bus
SAU
Peripheral Bus
164
32142D–06/2013
ATUC64/128/256L3/4U
10.4 Product Dependencies
In order to use this module, other parts of the system must be configured correctly, as described
below.
10.4.1 Power Management
If the CPU enters a sleep mode that disables clocks used by the SAU, the SAU will stop functioning
and resume operation after the system wakes up from sleep mode.
10.4.2 Clocks
The SAU has two bus clocks connected: One High Speed Bus clock (CLK_SAU_HSB) and one
Peripheral Bus clock (CLK_SAU_PB). These clocks are generated by the Power Manager. Both
clocks are enabled at reset, and can be disabled by writing to the Power Manager. The user has
to ensure that CLK_SAU_HSB is not turned off before accessing the SAU. Likewise, the user
must ensure that no bus access is pending in the SAU before disabling CLK_SAU_HSB. Failing
to do so may deadlock the High Speed Bus.
10.4.3 Interrupt
The SAU interrupt request line is connected to the interrupt controller. Using the SAU interrupt
requires the interrupt controller to be programmed first.
10.4.4 Debug Operation
When an external debugger forces the CPU into debug mode, the SAU continues normal operation.
If the SAU is configured in a way that requires it to be periodically serviced by the CPU
through interrupts or similar, improper operation or data loss may result during debugging.
10.5 Functional Description
10.5.1 Enabling the SAU
The SAU is enabled by writing a one to the Enable (EN) bit in the Control Register (CR). This will
set the SAU Enabled (EN) bit in the Status Register (SR).
10.5.2 Configuring the SAU Channels
The SAU has a set of channels, mapped in the HSB memory space. These channels can be
configured by a Remap Target Register (RTR), located at the same memory address. When the
SAU is in normal mode, the SAU channel is addressed, and when the SAU is in setup mode, the
RTR can be addressed.
Before the SAU can be used, the channels must be configured and enabled. To configure a
channel, the corresponding RTR must be programmed with the Remap Target Address. To do
this, make sure the SAU is in setup mode by writing a one to the Setup Mode Enable (SEN) bit
in CR. This makes sure that a write to the RTR address accesses the RTR, not the SAU channel.
Thereafter, the RTR is written with the address to remap to, typically the address of a
specific PB register. When all channels have been configured, return to normal mode by writing
a one to the Setup Mode Disable (SDIS) in CR. The channels can now be enabled by writing
ones to the corresponding bits in the Channel Enable Registers (CERH/L).
The SAU is only able to remap addresses above 0xFFFC0000.
165
32142D–06/2013
ATUC64/128/256L3/4U
10.5.2.1 Protecting SAU configuration registers
In order to prevent the SAU configuration registers to be changed by malicious or runaway code,
they should be protected by the MPU as soon as they have been configured. Maximum security
is provided in the system if program memory does not contain any code to unprotect the configuration
registers in the MPU. This guarantees that runaway code can not accidentally unprotect
and thereafter change the SAU configuration registers.
10.5.3 Lock Mechanism
The SAU can be configured to use two different access mechanisms: Open and Locked. In
Open Mode, SAU channels can be accessed freely after they have been configured and
enabled. In order to prevent accidental accesses to remapped addresses, it is possible to configure
the SAU in Locked Mode. Writing a one to the Open Mode bit in the CONFIG register
(CONFIG.OPEN) will enable Open Mode. Writing a zero to CONFIG.OPEN will enable Locked
Mode.
When using Locked Mode, the lock mechanism must be configured by writing a user defined key
value to the Unlock Key (UKEY) field in the Configuration Register (CONFIG). The number of
CLK_SAU_HSB cycles the channel remains unlocked must be written to the Unlock Number of
Clock Cycles (UCYC) field in CONFIG.
Access control to the SAU channels is enabled by means of the Unlock Register (UR), which
resides in the same address space as the SAU channels. Before a channel can be accessed,
the unlock register must be written with th correct key and channel number (single write access).
Access to the channel is then permitted for the next CONFIG.UCYC clock cycles, or until a successful
access to the unlocked channel has been made.
Only one channel can be unlocked at a time. If any other channel is unlocked at the time of writing
UR, this channel will be automatically locked before the channel addressed by the UR write
is unlocked.
An attempted access to a locked channel will be aborted, and the Channel Access Unsuccessful
bit (SR.CAU) will be set.
Any pending errors bits in SR must be cleared before it is possible to access UR. The following
SR bits are defined as error bits: EXP, CAU, URREAD, URKEY, URES, MBERROR, RTRADR.
If any of these bits are set while writing to UR, the write is aborted and the Unlock Register Error
Status (URES) bit in SR is set.
10.5.4 Normal Operation
The following sequence must be used in order to access a SAU channel in normal operation
(CR.SEN=0):
1. If not in Open Mode, write the unlock key to UR.KEY and the channel number to
UR.CHANNEL.
2. Perform the read or write operation to the SAU channel. If not in Open Mode, this must
be done within CONFIG.UCYC clock cycles of unlocking the channel. The SAU will use
its HSB master interface to remap the access to the target address pointed to by the
corresponding RTR.
3. To confirm that the access was successful, wait for the IDLE transfer status bit
(SR.IDLE) to indicate the operation is completed. Then check SR for possible error conditions.
The SAU can be configured to generate interrupt requests or a Bus Error
Exception if the access failed.
166
32142D–06/2013
ATUC64/128/256L3/4U
10.5.4.1 Operation example
Figure 10-2 shows a typical memory map, consisting of some memories, some simple peripherals,
and a SAU with multiple channels and an Unlock Register (UR). Imagine that the MPU has
been set up to disallow all accesses from the CPU to the grey modules. Thus the CPU has no
way of accessing for example the Transmit Holding register in the UART, present on address X
on the bus. Note that the SAU RTRs are not protected by the MPU, thus the RTRs can be
accessed. If for example RTR0 is configured to point to address X, an access to RTR0 will be
remapped by the SAU to address X according to the algorithm presented above. By programming
the SAU RTRs, specific addresses in modules that have generally been protected by the
MPU can be performed.
Figure 10-2. Example Memory Map for a System with SAU
10.5.5 Interrupts
The SAU can generate an interrupt request to signal different events. All events that can generate
an interrupt request have dedicated bits in the Status Register (SR). An interrupt request will
be generated if the corresponding bit in the Interrupt Mask Register (IMR) is set. Bits in IMR are
set by writing a one to the corresponding bit in the Interrupt Enable Register (IER), and cleared
by writing a one to the corresponding bit in the Interrupt Disable Register (IDR). The interrupt
request remains active until the corresponding bit in SR is cleared by writing a one to the corresponding
bit in the Interrupt Clear Register (ICR).
The following SR bits are used for signalling the result of SAU accesses:
• RTR Address Error (RTRADR) is set if an illegal address is written to the RTRs. Only
addresses in the range 0xFFFC0000-0xFFFFFFFF are allowed.
• Master Interface Bus Error (MBERROR) is set if any of the conditions listed in Section 10.5.7
occurred.
Transmit Holding
Baudrate
Control
Receive Holding
Channel 1
RTR0
RTR1
Address X
Address Z
UART
SAU
CONFIG
SAU
CHANNEL
UR
RTR62 ...
167
32142D–06/2013
ATUC64/128/256L3/4U
• Unlock Register Error Status (URES) is set if an attempt was made to unlock a channel by
writing to the Unlock Register while one or more error bits in SR were set (see Section
10.5.6). The unlock operation was aborted.
• Unlock Register Key Error (URKEY) is set if the Unlock Register was attempted written with
an invalid key.
• Unlock Register Read (URREAD) is set if the Unlock Register was attempted read.
• Channel Access Unsuccessful (CAU) is set if the channel access was unsuccessful.
• Channel Access Successful (CAS) is set if the channel access was successful.
• Channel Unlock Expired (EXP) is set if the channel lock expired, with no channel being
accessed after the channel was unlocked.
10.5.6 Error bits
If error bits are set when attempting to unlock a channel, SR.URES will be set. The following SR
bits are considered error bits:
• EXP
• CAU
• URREAD
• URKEY
• URES
• MBERROR
• RTRADR
10.5.7 Bus Error Responses
By writing a one to the Bus Error Response Enable bit (CR.BERREN), serious access errors will
be configured to return a bus error to the CPU. This will cause the CPU to execute its Bus Error
Data Fetch exception routine.
The conditions that can generate a bus error response are:
• Reading the Unlock Register
• Trying to access a locked channel
• The SAU HSB master receiving a bus error response from its addressed slave
10.5.8 Disabling the SAU
To disable the SAU, the user must first ensure that no SAU bus operations are pending. This
can be done by checking that the SR.IDLE bit is set.
The SAU may then be disabled by writing a one to the Disable (DIS) bit in CR.
168
32142D–06/2013
ATUC64/128/256L3/4U
10.6 User Interface
The following addresses are used by SAU channel configuration registers. All offsets are relative to the SAU’s PB base
address.
Note: 1. The reset values are device specific. Please refer to the Module Configuration section at the end of this chapter.
The following addresses are used by SAU channel registers. All offsets are relative to the SAU’s HSB base address. The
number of channels implemented is device specific, refer to the Module Configuration section at the end of this chapter.
Table 10-1. SAU Configuration Register Memory Map
Offset Register Register Name Access Reset
0x00 Control Register CR Write-only 0x00000000
0x04 Configuration Register CONFIG Write-only 0x00000000
0x08 Channel Enable Register High CERH Read/Write 0x00000000
0x0C Channel Enable Register Low CERL Read/Write 0x00000000
0x10 Status Register SR Read-only 0x00000400
0x14 Interrupt Enable Register IER Write-only 0x00000000
0x18 Interrupt Disable Register IDR Write-only 0x00000000
0x1C Interrupt Mask Register IMR Read-only 0x00000000
0x20 Interrupt Clear Register ICR Write-only 0x00000000
0x24 Parameter Register PARAMETER Read-only -(1)
0x28 Version Register VERSION Read-only -(1)
Table 10-2. SAU Channel Register Memory Map
Offset Register Register Name Access Reset
0x00 Remap Target Register 0 RTR0 Read/Write N/A
0x04 Remap Target Register 1 RTR1 Read/Write N/A
0x08 Remap Target Register 2 RTR2 Read/Write N/A
... ... ... ... ...
0x04*n Remap Target Register n RTRn Read/Write N/A
0xFC Unlock Register UR Write-only N/A
169
32142D–06/2013
ATUC64/128/256L3/4U
10.6.1 Control Register
Name: CR
Access Type: Write-only
Offset: 0x00
Reset Value: 0x00000000
• BERRDIS: Bus Error Response Disable
Writing a zero to this bit has no effect.
Writing a one to this bit disables Bus Error Response from the SAU.
• BERREN: Bus Error Response Enable
Writing a zero to this bit has no effect.
Writing a one to this bit enables Bus Error Response from the SAU.
• SDIS: Setup Mode Disable
Writing a zero to this bit has no effect.
Writing a one to this bit exits setup mode.
• SEN: Setup Mode Enable
Writing a zero to this bit has no effect.
Writing a one to this bit enters setup mode.
• DIS: SAU Disable
Writing a zero to this bit has no effect.
Writing a one to this bit disables the SAU.
• EN: SAU Enable
Writing a zero to this bit has no effect.
Writing a one to this bit enables the SAU.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
--------
76543210
- - BERRDIS BERREN SDIS SEN DIS EN
170
32142D–06/2013
ATUC64/128/256L3/4U
10.6.2 Configuration Register
Name: CONFIG
Access Type: Write-only
Offset: 0x04
Reset Value: 0x00000000
• OPEN: Open Mode Enable
Writing a zero to this bit disables open mode.
Writing a one to this bit enables open mode.
• UCYC: Unlock Number of Clock Cycles
Once a channel has been unlocked, it remains unlocked for this amount of CLK_SAU_HSB clock cycles or until one access to a
channel has been made.
• UKEY: Unlock Key
The value in this field must be written to UR.KEY to unlock a channel.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
- - - - - - - OPEN
15 14 13 12 11 10 9 8
UCYC
76543210
UKEY
171
32142D–06/2013
ATUC64/128/256L3/4U
10.6.3 Channel Enable Register High
Name: CERH
Access Type: Read/Write
Offset: 0x08
Reset Value: 0x00000000
• CERH[n]: Channel Enable Register High
0: Channel (n+32) is not enabled.
1: Channel (n+32) is enabled.
31 30 29 28 27 26 25 24
- CERH[30:24]
23 22 21 20 19 18 17 16
CERH[23:16]
15 14 13 12 11 10 9 8
CERH[15:8]
76543210
CERH[7:0]
172
32142D–06/2013
ATUC64/128/256L3/4U
10.6.4 Channel Enable Register Low
Name: CERL
Access Type: Read/Write
Offset: 0x0C
Reset Value: 0x00000000
• CERL[n]: Channel Enable Register Low
0: Channel n is not enabled.
1: Channel n is enabled.
31 30 29 28 27 26 25 24
CERL[31:24]
23 22 21 20 19 18 17 16
CERL[23:16]
15 14 13 12 11 10 9 8
CERL[15:8]
76543210
CERL[7:0]
173
32142D–06/2013
ATUC64/128/256L3/4U
10.6.5 Status Register
Name: SR
Access Type: Read-only
Offset: 0x10
Reset Value: 0x00000400
• IDLE
This bit is cleared when a read or write operation to the SAU channel is started.
This bit is set when the operation is completed and no SAU bus operations are pending.
• SEN: SAU Setup Mode Enable
This bit is cleared when the SAU exits setup mode.
This bit is set when the SAU enters setup mode.
• EN: SAU Enabled
This bit is cleared when the SAU is disabled.
This bit is set when the SAU is enabled.
• RTRADR: RTR Address Error
This bit is cleared when the corresponding bit in ICR is written to one.
This bit is set if, in the configuration phase, an RTR was written with an illegal address, i.e. the upper 16 bits in the address were
different from 0xFFFC, 0xFFFD, 0xFFFE or 0xFFFF.
• MBERROR: Master Interface Bus Error
This bit is cleared when the corresponding bit in ICR is written to one.
This bit is set if a channel access generated a transfer on the master interface that received a bus error response from the
addressed slave.
• URES: Unlock Register Error Status
This bit is cleared when the corresponding bit in ICR is written to one.
This bit is set if an attempt was made to unlock a channel by writing to the Unlock Register while one or more error bits were set
in SR. The unlock operation was aborted.
• URKEY: Unlock Register Key Error
This bit is cleared when the corresponding bit in ICR is written to one.
This bit is set if the Unlock Register was attempted written with an invalid key.
• URREAD: Unlock Register Read
This bit is cleared when the corresponding bit in ICR is written to one.
This bit is set if the Unlock Register was read.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
- - - - - IDLE SEN EN
76543210
RTRADR MBERROR URES URKEY URREAD CAU CAS EXP
174
32142D–06/2013
ATUC64/128/256L3/4U
• CAU: Channel Access Unsuccessful
This bit is cleared when the corresponding bit in ICR is written to one.
This bit is set if channel access was unsuccessful, i.e. an access was attempted to a locked or disabled channel.
• CAS: Channel Access Successful
This bit is cleared when the corresponding bit in ICR is written to one.
This bit is set if channel access successful, i.e. one access was made after the channel was unlocked.
• EXP: Channel Unlock Expired
This bit is cleared when the corresponding bit in ICR is written to one.
This bit is set if channel unlock has expired, i.e. no access being made after the channel was unlocked.
175
32142D–06/2013
ATUC64/128/256L3/4U
10.6.6 Interrupt Enable Register
Name: IER
Access Type: Write-only
Offset: 0x14
Reset Value: 0x00000000
Writing a zero to a bit in this register has no effect.
Writing a one to a bit in this register will set the corresponding bit in IMR.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
--------
76543210
RTRADR MBERROR URES URKEY URREAD CAU CAS EXP
176
32142D–06/2013
ATUC64/128/256L3/4U
10.6.7 Interrupt Disable Register
Name: IDR
Access Type: Write-only
Offset: 0x18
Reset Value: 0x00000000
Writing a zero to a bit in this register has no effect.
Writing a one to a bit in this register will clear the corresponding bit in IMR.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
--------
76543210
RTRADR MBERROR URES URKEY URREAD CAU CAS EXP
177
32142D–06/2013
ATUC64/128/256L3/4U
10.6.8 Interrupt Mask Register
Name: IMR
Access Type: Read-only
Offset: 0x1C
Reset Value: 0x00000000
0: The corresponding interrupt is disabled.
1: The corresponding interrupt is enabled.
A bit in this register is cleared when the corresponding bit in IDR is written to one.
A bit in this register is set when the corresponding bit in IER is written to one.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
--------
76543210
RTRADR MBERROR URES URKEY URREAD CAU CAS EXP
178
32142D–06/2013
ATUC64/128/256L3/4U
10.6.9 Interrupt Clear Register
Name: ICR
Access Type: Write-only
Offset: 0x20
Reset Value: 0x00000000
Writing a zero to a bit in this register has no effect.
Writing a one to a bit in this register will clear the corresponding bit in SR and any corresponding interrupt request.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
--------
76543210
RTRADR MBERROR URES URKEY URREAD CAU CAS EXP
179
32142D–06/2013
ATUC64/128/256L3/4U
10.6.10 Parameter Register
Name: PARAMETER
Access Type: Read-only
Offset: 0x24
Reset Value: -
• CHANNELS:
Number of channels implemented.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
--------
76543210
- - CHANNELS
180
32142D–06/2013
ATUC64/128/256L3/4U
10.6.11 Version Register
Name: VERSION
Access Type: Write-only
Offset: 0x28
Reset Value: -
• VARIANT: Variant Number
Reserved. No functionality associated.
• VERSION: Version Number
Version number of the module. No functionality associated.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
- - - - VARIANT
15 14 13 12 11 10 9 8
- - - - VERSION[11:8]
76543210
VERSION[7:0]
181
32142D–06/2013
ATUC64/128/256L3/4U
10.6.12 Remap Target Register n
Name: RTRn
Access Type: Read/Write
Offset: n*4
Reset Value: 0x00000000
• RTR: Remap Target Address for Channel n
RTR[31:16] must have one of the following values, any other value will result in UNDEFINED behavior:
0xFFFC
0xFFFD
0xFFFE
0xFFFF
RTR[1:0] must be written to 00, any other value will result in UNDEFINED behavior.
31 30 29 28 27 26 25 24
RTR[31:24]
23 22 21 20 19 18 17 16
RTR[23:16]
15 14 13 12 11 10 9 8
RTR[15:8]
76543210
RTR[7:0]
182
32142D–06/2013
ATUC64/128/256L3/4U
10.6.13 Unlock Register
Name: UR
Access Type : Write-only
Offset: 0xFC
Reset Value: 0x00000000
• KEY: Unlock Key
The correct key must be written in order to unlock a channel. The key value written must correspond to the key value defined in
CONFIG.UKEY.
• CHANNEL: Channel Number
Number of the channel to unlock.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
KEY
76543210
- - CHANNEL
183
32142D–06/2013
ATUC64/128/256L3/4U
10.7 Module Configuration
The specific configuration for each SAU instance is listed in the following tables.The module bus
clocks listed here are connected to the system bus clocks. Please refer to the Power Manager
chapter for details.
Table 10-3. SAU configuration
Feature SAU
SAU Channels 16
Table 10-4. SAU clock name
Module name Clock name Description
SAU CLK_SAU_HSB Clock for the SAU HSB interface
SAU CLK_SAU_PB Clock for the SAU PB interface
Table 10-5. Register Reset Values
Register Reset Value
VERSION 0x00000111
PARAMETER 0x00000010
184
32142D–06/2013
ATUC64/128/256L3/4U
11. HSB Bus Matrix (HMATRIXB)
Rev: 1.3.0.3
11.1 Features
• User Interface on peripheral bus
• Configurable number of masters (up to 16)
• Configurable number of slaves (up to 16)
• One decoder for each master
• Programmable arbitration for each slave
– Round-Robin
– Fixed priority
• Programmable default master for each slave
– No default master
– Last accessed default master
– Fixed default master
• One cycle latency for the first access of a burst
• Zero cycle latency for default master
• One special function register for each slave (not dedicated)
11.2 Overview
The Bus Matrix implements a multi-layer bus structure, that enables parallel access paths
between multiple High Speed Bus (HSB) masters and slaves in a system, thus increasing the
overall bandwidth. The Bus Matrix interconnects up to 16 HSB Masters to up to 16 HSB Slaves.
The normal latency to connect a master to a slave is one cycle except for the default master of
the accessed slave which is connected directly (zero cycle latency). The Bus Matrix provides 16
Special Function Registers (SFR) that allow the Bus Matrix to support application specific
features.
11.3 Product Dependencies
In order to configure this module by accessing the user registers, other parts of the system must
be configured correctly, as described below.
11.3.1 Clocks
The clock for the HMATRIX bus interface (CLK_HMATRIX) is generated by the Power Manager.
This clock is enabled at reset, and can be disabled in the Power Manager.
11.4 Functional Description
11.4.1 Special Bus Granting Mechanism
The Bus Matrix provides some speculative bus granting techniques in order to anticipate access
requests from some masters. This mechanism reduces latency at first access of a burst or single
transfer. This bus granting mechanism sets a different default master for every slave.
At the end of the current access, if no other request is pending, the slave remains connected to
its associated default master. A slave can be associated with three kinds of default masters: no
default master, last access master, and fixed default master.
185
32142D–06/2013
ATUC64/128/256L3/4U
To change from one kind of default master to another, the Bus Matrix user interface provides the
Slave Configuration Registers, one for each slave, that set a default master for each slave. The
Slave Configuration Register contains two fields: DEFMSTR_TYPE and FIXED_DEFMSTR. The
2-bit DEFMSTR_TYPE field selects the default master type (no default, last access master, fixed
default master), whereas the 4-bit FIXED_DEFMSTR field selects a fixed default master provided
that DEFMSTR_TYPE is set to fixed default master. Please refer to the Bus Matrix user
interface description.
11.4.1.1 No Default Master
At the end of the current access, if no other request is pending, the slave is disconnected from
all masters. No Default Master suits low-power mode.
11.4.1.2 Last Access Master
At the end of the current access, if no other request is pending, the slave remains connected to
the last master that performed an access request.
11.4.1.3 Fixed Default Master
At the end of the current access, if no other request is pending, the slave connects to its fixed
default master. Unlike last access master, the fixed master does not change unless the user
modifies it by a software action (field FIXED_DEFMSTR of the related SCFG).
11.4.2 Arbitration
The Bus Matrix provides an arbitration mechanism that reduces latency when conflict cases
occur, i.e. when two or more masters try to access the same slave at the same time. One arbiter
per HSB slave is provided, thus arbitrating each slave differently.
The Bus Matrix provides the user with the possibility of choosing between 2 arbitration types for
each slave:
1. Round-Robin Arbitration (default)
2. Fixed Priority Arbitration
This is selected by the ARBT field in the Slave Configuration Registers (SCFG).
Each algorithm may be complemented by selecting a default master configuration for each
slave.
When a re-arbitration must be done, specific conditions apply. This is described in “Arbitration
Rules” .
11.4.2.1 Arbitration Rules
Each arbiter has the ability to arbitrate between two or more different master requests. In order
to avoid burst breaking and also to provide the maximum throughput for slave interfaces, arbitration
may only take place during the following cycles:
1. Idle Cycles: When a slave is not connected to any master or is connected to a master
which is not currently accessing it.
2. Single Cycles: When a slave is currently doing a single access.
3. End of Burst Cycles: When the current cycle is the last cycle of a burst transfer. For
defined length burst, predicted end of burst matches the size of the transfer but is managed
differently for undefined length burst. This is described below.
4. Slot Cycle Limit: When the slot cycle counter has reached the limit value indicating that
the current master access is too long and must be broken. This is described below.
186
32142D–06/2013
ATUC64/128/256L3/4U
• Undefined Length Burst Arbitration
In order to avoid long slave handling during undefined length bursts (INCR), the Bus Matrix provides
specific logic in order to re-arbitrate before the end of the INCR transfer. A predicted end
of burst is used as a defined length burst transfer and can be selected among the following five
possibilities:
1. Infinite: No predicted end of burst is generated and therefore INCR burst transfer will
never be broken.
2. One beat bursts: Predicted end of burst is generated at each single transfer inside the
INCP transfer.
3. Four beat bursts: Predicted end of burst is generated at the end of each four beat
boundary inside INCR transfer.
4. Eight beat bursts: Predicted end of burst is generated at the end of each eight beat
boundary inside INCR transfer.
5. Sixteen beat bursts: Predicted end of burst is generated at the end of each sixteen beat
boundary inside INCR transfer.
This selection can be done through the ULBT field in the Master Configuration Registers
(MCFG).
• Slot Cycle Limit Arbitration
The Bus Matrix contains specific logic to break long accesses, such as very long bursts on a
very slow slave (e.g., an external low speed memory). At the beginning of the burst access, a
counter is loaded with the value previously written in the SLOT_CYCLE field of the related Slave
Configuration Register (SCFG) and decreased at each clock cycle. When the counter reaches
zero, the arbiter has the ability to re-arbitrate at the end of the current byte, halfword, or word
transfer.
11.4.2.2 Round-Robin Arbitration
This algorithm allows the Bus Matrix arbiters to dispatch the requests from different masters to
the same slave in a round-robin manner. If two or more master requests arise at the same time,
the master with the lowest number is first serviced, then the others are serviced in a round-robin
manner.
There are three round-robin algorithms implemented:
1. Round-Robin arbitration without default master
2. Round-Robin arbitration with last default master
3. Round-Robin arbitration with fixed default master
• Round-Robin Arbitration without Default Master
This is the main algorithm used by Bus Matrix arbiters. It allows the Bus Matrix to dispatch
requests from different masters to the same slave in a pure round-robin manner. At the end of
the current access, if no other request is pending, the slave is disconnected from all masters.
This configuration incurs one latency cycle for the first access of a burst. Arbitration without
default master can be used for masters that perform significant bursts.
• Round-Robin Arbitration with Last Default Master
This is a biased round-robin algorithm used by Bus Matrix arbiters. It allows the Bus Matrix to
remove the one latency cycle for the last master that accessed the slave. At the end of the cur-
187
32142D–06/2013
ATUC64/128/256L3/4U
rent transfer, if no other master request is pending, the slave remains connected to the last
master that performed the access. Other non privileged masters still get one latency cycle if they
want to access the same slave. This technique can be used for masters that mainly perform single
accesses.
• Round-Robin Arbitration with Fixed Default Master
This is another biased round-robin algorithm. It allows the Bus Matrix arbiters to remove the one
latency cycle for the fixed default master per slave. At the end of the current access, the slave
remains connected to its fixed default master. Every request attempted by this fixed default master
will not cause any latency whereas other non privileged masters will still get one latency
cycle. This technique can be used for masters that mainly perform single accesses.
11.4.2.3 Fixed Priority Arbitration
This algorithm allows the Bus Matrix arbiters to dispatch the requests from different masters to
the same slave by using the fixed priority defined by the user. If two or more master requests are
active at the same time, the master with the highest priority number is serviced first. If two or
more master requests with the same priority are active at the same time, the master with the
highest number is serviced first.
For each slave, the priority of each master may be defined through the Priority Registers for
Slaves (PRAS and PRBS).
11.4.3 Slave and Master assignation
The index number assigned to Bus Matrix slaves and masters are described in the Module Configuration
section at the end of this chapter.
188
32142D–06/2013
ATUC64/128/256L3/4U
11.5 User Interface
Table 11-1. HMATRIX Register Memory Map
Offset Register Name Access Reset Value
0x0000 Master Configuration Register 0 MCFG0 Read/Write 0x00000002
0x0004 Master Configuration Register 1 MCFG1 Read/Write 0x00000002
0x0008 Master Configuration Register 2 MCFG2 Read/Write 0x00000002
0x000C Master Configuration Register 3 MCFG3 Read/Write 0x00000002
0x0010 Master Configuration Register 4 MCFG4 Read/Write 0x00000002
0x0014 Master Configuration Register 5 MCFG5 Read/Write 0x00000002
0x0018 Master Configuration Register 6 MCFG6 Read/Write 0x00000002
0x001C Master Configuration Register 7 MCFG7 Read/Write 0x00000002
0x0020 Master Configuration Register 8 MCFG8 Read/Write 0x00000002
0x0024 Master Configuration Register 9 MCFG9 Read/Write 0x00000002
0x0028 Master Configuration Register 10 MCFG10 Read/Write 0x00000002
0x002C Master Configuration Register 11 MCFG11 Read/Write 0x00000002
0x0030 Master Configuration Register 12 MCFG12 Read/Write 0x00000002
0x0034 Master Configuration Register 13 MCFG13 Read/Write 0x00000002
0x0038 Master Configuration Register 14 MCFG14 Read/Write 0x00000002
0x003C Master Configuration Register 15 MCFG15 Read/Write 0x00000002
0x0040 Slave Configuration Register 0 SCFG0 Read/Write 0x00000010
0x0044 Slave Configuration Register 1 SCFG1 Read/Write 0x00000010
0x0048 Slave Configuration Register 2 SCFG2 Read/Write 0x00000010
0x004C Slave Configuration Register 3 SCFG3 Read/Write 0x00000010
0x0050 Slave Configuration Register 4 SCFG4 Read/Write 0x00000010
0x0054 Slave Configuration Register 5 SCFG5 Read/Write 0x00000010
0x0058 Slave Configuration Register 6 SCFG6 Read/Write 0x00000010
0x005C Slave Configuration Register 7 SCFG7 Read/Write 0x00000010
0x0060 Slave Configuration Register 8 SCFG8 Read/Write 0x00000010
0x0064 Slave Configuration Register 9 SCFG9 Read/Write 0x00000010
0x0068 Slave Configuration Register 10 SCFG10 Read/Write 0x00000010
0x006C Slave Configuration Register 11 SCFG11 Read/Write 0x00000010
0x0070 Slave Configuration Register 12 SCFG12 Read/Write 0x00000010
0x0074 Slave Configuration Register 13 SCFG13 Read/Write 0x00000010
0x0078 Slave Configuration Register 14 SCFG14 Read/Write 0x00000010
0x007C Slave Configuration Register 15 SCFG15 Read/Write 0x00000010
0x0080 Priority Register A for Slave 0 PRAS0 Read/Write 0x00000000
0x0084 Priority Register B for Slave 0 PRBS0 Read/Write 0x00000000
0x0088 Priority Register A for Slave 1 PRAS1 Read/Write 0x00000000
189
32142D–06/2013
ATUC64/128/256L3/4U
0x008C Priority Register B for Slave 1 PRBS1 Read/Write 0x00000000
0x0090 Priority Register A for Slave 2 PRAS2 Read/Write 0x00000000
0x0094 Priority Register B for Slave 2 PRBS2 Read/Write 0x00000000
0x0098 Priority Register A for Slave 3 PRAS3 Read/Write 0x00000000
0x009C Priority Register B for Slave 3 PRBS3 Read/Write 0x00000000
0x00A0 Priority Register A for Slave 4 PRAS4 Read/Write 0x00000000
0x00A4 Priority Register B for Slave 4 PRBS4 Read/Write 0x00000000
0x00A8 Priority Register A for Slave 5 PRAS5 Read/Write 0x00000000
0x00AC Priority Register B for Slave 5 PRBS5 Read/Write 0x00000000
0x00B0 Priority Register A for Slave 6 PRAS6 Read/Write 0x00000000
0x00B4 Priority Register B for Slave 6 PRBS6 Read/Write 0x00000000
0x00B8 Priority Register A for Slave 7 PRAS7 Read/Write 0x00000000
0x00BC Priority Register B for Slave 7 PRBS7 Read/Write 0x00000000
0x00C0 Priority Register A for Slave 8 PRAS8 Read/Write 0x00000000
0x00C4 Priority Register B for Slave 8 PRBS8 Read/Write 0x00000000
0x00C8 Priority Register A for Slave 9 PRAS9 Read/Write 0x00000000
0x00CC Priority Register B for Slave 9 PRBS9 Read/Write 0x00000000
0x00D0 Priority Register A for Slave 10 PRAS10 Read/Write 0x00000000
0x00D4 Priority Register B for Slave 10 PRBS10 Read/Write 0x00000000
0x00D8 Priority Register A for Slave 11 PRAS11 Read/Write 0x00000000
0x00DC Priority Register B for Slave 11 PRBS11 Read/Write 0x00000000
0x00E0 Priority Register A for Slave 12 PRAS12 Read/Write 0x00000000
0x00E4 Priority Register B for Slave 12 PRBS12 Read/Write 0x00000000
0x00E8 Priority Register A for Slave 13 PRAS13 Read/Write 0x00000000
0x00EC Priority Register B for Slave 13 PRBS13 Read/Write 0x00000000
0x00F0 Priority Register A for Slave 14 PRAS14 Read/Write 0x00000000
0x00F4 Priority Register B for Slave 14 PRBS14 Read/Write 0x00000000
0x00F8 Priority Register A for Slave 15 PRAS15 Read/Write 0x00000000
0x00FC Priority Register B for Slave 15 PRBS15 Read/Write 0x00000000
0x0110 Special Function Register 0 SFR0 Read/Write –
0x0114 Special Function Register 1 SFR1 Read/Write –
0x0118 Special Function Register 2 SFR2 Read/Write –
0x011C Special Function Register 3 SFR3 Read/Write –
0x0120 Special Function Register 4 SFR4 Read/Write –
0x0124 Special Function Register 5 SFR5 Read/Write –
0x0128 Special Function Register 6 SFR6 Read/Write –
Table 11-1. HMATRIX Register Memory Map (Continued)
Offset Register Name Access Reset Value
190
32142D–06/2013
ATUC64/128/256L3/4U
0x012C Special Function Register 7 SFR7 Read/Write –
0x0130 Special Function Register 8 SFR8 Read/Write –
0x0134 Special Function Register 9 SFR9 Read/Write –
0x0138 Special Function Register 10 SFR10 Read/Write –
0x013C Special Function Register 11 SFR11 Read/Write –
0x0140 Special Function Register 12 SFR12 Read/Write –
0x0144 Special Function Register 13 SFR13 Read/Write –
0x0148 Special Function Register 14 SFR14 Read/Write –
0x014C Special Function Register 15 SFR15 Read/Write –
Table 11-1. HMATRIX Register Memory Map (Continued)
Offset Register Name Access Reset Value
191
32142D–06/2013
ATUC64/128/256L3/4U
11.5.1 Master Configuration Registers
Name: MCFG0...MCFG15
Access Type: Read/Write
Offset: 0x00 - 0x3C
Reset Value: 0x00000002
• ULBT: Undefined Length Burst Type
31 30 29 28 27 26 25 24
––––––––
23 22 21 20 19 18 17 16
––––––––
15 14 13 12 11 10 9 8
––––––––
76543210
– – – – – ULBT
Table 11-2. Undefined Length Burst Type
ULBT Undefined Length Burst Type Description
000 Inifinite Length Burst No predicted end of burst is generated and therefore INCR bursts coming from this
master cannot be broken.
001 Single-Access The undefined length burst is treated as a succession of single accesses, allowing rearbitration
at each beat of the INCR burst.
010 4 Beat Burst The undefined length burst is split into a four-beat burst, allowing re-arbitration at each
four-beat burst end.
011 8 Beat Burst The undefined length burst is split into an eight-beat burst, allowing re-arbitration at
each eight-beat burst end.
100 16 Beat Burst The undefined length burst is split into a sixteen-beat burst, allowing re-arbitration at
each sixteen-beat burst end.
192
32142D–06/2013
ATUC64/128/256L3/4U
11.5.2 Slave Configuration Registers
Name: SCFG0...SCFG15
Access Type: Read/Write
Offset: 0x40 - 0x7C
Reset Value: 0x00000010
• ARBT: Arbitration Type
0: Round-Robin Arbitration
1: Fixed Priority Arbitration
• FIXED_DEFMSTR: Fixed Default Master
This is the number of the Default Master for this slave. Only used if DEFMSTR_TYPE is 2. Specifying the number of a master
which is not connected to the selected slave is equivalent to setting DEFMSTR_TYPE to 0.
• DEFMSTR_TYPE: Default Master Type
0: No Default Master
At the end of the current slave access, if no other master request is pending, the slave is disconnected from all masters.
This results in a one cycle latency for the first access of a burst transfer or for a single access.
1: Last Default Master
At the end of the current slave access, if no other master request is pending, the slave stays connected to the last master having
accessed it.
This results in not having one cycle latency when the last master tries to access the slave again.
2: Fixed Default Master
At the end of the current slave access, if no other master request is pending, the slave connects to the fixed master the number
that has been written in the FIXED_DEFMSTR field.
This results in not having one cycle latency when the fixed master tries to access the slave again.
• SLOT_CYCLE: Maximum Number of Allowed Cycles for a Burst
When the SLOT_CYCLE limit is reached for a burst, it may be broken by another master trying to access this slave.
This limit has been placed to avoid locking a very slow slave when very long bursts are used.
This limit must not be very small. Unreasonably small values break every burst and the Bus Matrix arbitrates without performing
any data transfer. 16 cycles is a reasonable value for SLOT_CYCLE.
31 30 29 28 27 26 25 24
– – – – – – – ARBT
23 22 21 20 19 18 17 16
– – FIXED_DEFMSTR DEFMSTR_TYPE
15 14 13 12 11 10 9 8
––––––––
76543210
SLOT_CYCLE
193
32142D–06/2013
ATUC64/128/256L3/4U
11.5.3 Bus Matrix Priority Registers A For Slaves
Register Name: PRAS0...PRAS15
Access Type: Read/Write
Offset: -
Reset Value: 0x00000000
• MxPR: Master x Priority
Fixed priority of Master x for accessing the selected slave. The higher the number, the higher the priority.
31 30 29 28 27 26 25 24
- - M7PR - - M6PR
23 22 21 20 19 18 17 16
- - M5PR - - M4PR
15 14 13 12 11 10 9 8
- - M3PR - - M2PR
76543210
- - M1PR - - M0PR
194
32142D–06/2013
ATUC64/128/256L3/4U
11.5.4 Priority Registers B For Slaves
Name: PRBS0...PRBS15
Access Type: Read/Write
Offset: -
Reset Value: 0x00000000
• MxPR: Master x Priority
Fixed priority of Master x for accessing the selected slave. The higher the number, the higher the priority.
31 30 29 28 27 26 25 24
- - M15PR - - M14PR
23 22 21 20 19 18 17 16
- - M13PR - - M12PR
15 14 13 12 11 10 9 8
- - M11PR - - M10PR
76543210
- - M9PR - - M8PR
195
32142D–06/2013
ATUC64/128/256L3/4U
11.5.5 Special Function Registers
Name: SFR0...SFR15
Access Type: Read/Write
Offset: 0x110 - 0x14C
Reset Value: -
• SFR: Special Function Register Fields
Those registers are not a HMATRIX specific register. The field of those will be defined where they are used.
31 30 29 28 27 26 25 24
SFR
23 22 21 20 19 18 17 16
SFR
15 14 13 12 11 10 9 8
SFR
76543210
SFR
196
32142D–06/2013
ATUC64/128/256L3/4U
11.6 Module Configuration
The specific configuration for each HMATRIX instance is listed in the following tables.The module
bus clocks listed here are connected to the system bus clocks. Please refer to the Power
Manager chapter for details.
11.6.1 Bus Matrix Connections
The bus matrix has the several masters and slaves. Each master has its own bus and its own
decoder, thus allowing a different memory mapping per master. The master number in the table
below can be used to index the HMATRIX control registers. For example, HMATRIX MCFG0
register is associated with the CPU Data master interface.
Each slave has its own arbiter, thus allowing a different arbitration per slave. The slave number
in the table below can be used to index the HMATRIX control registers. For example, SCFG3 is
associated with the Internal SRAM Slave Interface.
Accesses to unused areas returns an error result to the master requesting such an access.
Table 11-3. HMATRIX Clocks
Clock Name Description
CLK_HMATRIX Clock for the HMATRIX bus interface
Table 11-4. High Speed Bus Masters
Master 0 CPU Data
Master 1 CPU Instruction
Master 2 CPU SAB
Master 3 SAU
Master 4 PDCA
Master 5 USBC
Table 11-5. High Speed Bus Slaves
Slave 0 Internal Flash
Slave 1 HSB-PB Bridge A
Slave 2 HSB-PB Bridge B
Slave 3 Internal SRAM
Slave 4 SAU
197
32142D–06/2013
ATUC64/128/256L3/4U
Figure 11-1. HMatrix Master / Slave Connections
CPU Data 0
CPU
Instruction 1
CPU SAB 2
SAU 3
Internal Flash
0
HSB-PB
Bridge 0
1
HSB-PB
Bridge 1
2
Internal SRAM
3
HMATRIX SLAVES
HMATRIX MASTERS
SAU
4
PDCA 4
USBC 5
198
32142D–06/2013
ATUC64/128/256L3/4U
12. Interrupt Controller (INTC)
Rev: 1.0.2.5
12.1 Features
• Autovectored low latency interrupt service with programmable priority
– 4 priority levels for regular, maskable interrupts
– One Non-Maskable Interrupt
• Up to 64 groups of interrupts with up to 32 interrupt requests in each group
12.2 Overview
The INTC collects interrupt requests from the peripherals, prioritizes them, and delivers an interrupt
request and an autovector to the CPU. The AVR32 architecture supports 4 priority levels for
regular, maskable interrupts, and a Non-Maskable Interrupt (NMI).
The INTC supports up to 64 groups of interrupts. Each group can have up to 32 interrupt request
lines, these lines are connected to the peripherals. Each group has an Interrupt Priority Register
(IPR) and an Interrupt Request Register (IRR). The IPRs are used to assign a priority level and
an autovector to each group, and the IRRs are used to identify the active interrupt request within
each group. If a group has only one interrupt request line, an active interrupt group uniquely
identifies the active interrupt request line, and the corresponding IRR is not needed. The INTC
also provides one Interrupt Cause Register (ICR) per priority level. These registers identify the
group that has a pending interrupt of the corresponding priority level. If several groups have a
pending interrupt of the same level, the group with the lowest number takes priority.
12.3 Block Diagram
Figure 12-1 gives an overview of the INTC. The grey boxes represent registers that can be
accessed via the user interface. The interrupt requests from the peripherals (IREQn) and the
NMI are input on the left side of the figure. Signals to and from the CPU are on the right side of
the figure.
199
32142D–06/2013
ATUC64/128/256L3/4U
Figure 12-1. INTC Block Diagram
12.4 Product Dependencies
In order to use this module, other parts of the system must be configured correctly, as described
below.
12.4.1 Power Management
If the CPU enters a sleep mode that disables CLK_SYNC, the INTC will stop functioning and
resume operation after the system wakes up from sleep mode.
12.4.2 Clocks
The clock for the INTC bus interface (CLK_INTC) is generated by the Power Manager. This
clock is enabled at reset, and can be disabled in the Power Manager.
The INTC sampling logic runs on a clock which is stopped in any of the sleep modes where the
system RC oscillator is not running. This clock is referred to as CLK_SYNC. This clock is
enabled at reset, and only turned off in sleep modes where the system RC oscillator is stopped.
12.4.3 Debug Operation
When an external debugger forces the CPU into debug mode, the INTC continues normal
operation.
12.5 Functional Description
All of the incoming interrupt requests (IREQs) are sampled into the corresponding Interrupt
Request Register (IRR). The IRRs must be accessed to identify which IREQ within a group that
is active. If several IREQs within the same group are active, the interrupt service routine must
prioritize between them. All of the input lines in each group are logically ORed together to form
the GrpReqN lines, indicating if there is a pending interrupt in the corresponding group.
The Request Masking hardware maps each of the GrpReq lines to a priority level from INT0 to
INT3 by associating each group with the Interrupt Level (INTLEVEL) field in the corresponding
Request
Masking
OR
IREQ0
IREQ1
IREQ2
IREQ31
GrpReq0
Masks SREG
Masks
I[3-0]M
GM
INTLEVEL
AUTOVECTOR
Prioritizer
Interrupt Controller CPU
OR GrpReqN
NMIREQ
OR
IREQ32
IREQ33
IREQ34
IREQ63
GrpReq1
IRR Registers IPR Registers ICR Registers
INT_level,
offset
INT_level,
offset
INT_level,
offset
IPR0
IPR1
IPRn
IRR0
IRR1
IRRn
ValReq0
ValReq1
ValReqN
.
.
.
.
.
.
.
.
.
200
32142D–06/2013
ATUC64/128/256L3/4U
Interrupt Priority Register (IPR). The GrpReq inputs are then masked by the mask bits from the
CPU status register. Any interrupt group that has a pending interrupt of a priority level that is not
masked by the CPU status register, gets its corresponding ValReq line asserted.
Masking of the interrupt requests is done based on five interrupt mask bits of the CPU status
register, namely Interrupt Level 3 Mask (I3M) to Interrupt Level 0 Mask (I0M), and Global Interrupt
Mask (GM). An interrupt request is masked if either the GM or the corresponding interrupt
level mask bit is set.
The Prioritizer hardware uses the ValReq lines and the INTLEVEL field in the IPRs to select the
pending interrupt of the highest priority. If an NMI interrupt request is pending, it automatically
gets the highest priority of any pending interrupt. If several interrupt groups of the highest pending
interrupt level have pending interrupts, the interrupt group with the lowest number is
selected.
The INTLEVEL and handler autovector offset (AUTOVECTOR) of the selected interrupt are
transmitted to the CPU for interrupt handling and context switching. The CPU does not need to
know which interrupt is requesting handling, but only the level and the offset of the handler
address. The IRR registers contain the interrupt request lines of the groups and can be read via
user interface registers for checking which interrupts of the group are actually active.
The delay through the INTC from the peripheral interrupt request is set until the interrupt request
to the CPU is set is three cycles of CLK_SYNC.
12.5.1 Non-Maskable Interrupts
A NMI request has priority over all other interrupt requests. NMI has a dedicated exception vector
address defined by the AVR32 architecture, so AUTOVECTOR is undefined when
INTLEVEL indicates that an NMI is pending.
12.5.2 CPU Response
When the CPU receives an interrupt request it checks if any other exceptions are pending. If no
exceptions of higher priority are pending, interrupt handling is initiated. When initiating interrupt
handling, the corresponding interrupt mask bit is set automatically for this and lower levels in status
register. E.g, if an interrupt of level 3 is approved for handling, the interrupt mask bits I3M,
I2M, I1M, and I0M are set in status register. If an interrupt of level 1 is approved, the masking
bits I1M and I0M are set in status register. The handler address is calculated by logical OR of
the AUTOVECTOR to the CPU system register Exception Vector Base Address (EVBA). The
CPU will then jump to the calculated address and start executing the interrupt handler.
Setting the interrupt mask bits prevents the interrupts from the same and lower levels to be
passed through the interrupt controller. Setting of the same level mask bit prevents also multiple
requests of the same interrupt to happen.
It is the responsibility of the handler software to clear the interrupt request that caused the interrupt
before returning from the interrupt handler. If the conditions that caused the interrupt are not
cleared, the interrupt request remains active.
12.5.3 Clearing an Interrupt Request
Clearing of the interrupt request is done by writing to registers in the corresponding peripheral
module, which then clears the corresponding NMIREQ/IREQ signal.
The recommended way of clearing an interrupt request is a store operation to the controlling
peripheral register, followed by a dummy load operation from the same register. This causes a
201
32142D–06/2013
ATUC64/128/256L3/4U
pipeline stall, which prevents the interrupt from accidentally re-triggering in case the handler is
exited and the interrupt mask is cleared before the interrupt request is cleared.
202
32142D–06/2013
ATUC64/128/256L3/4U
12.6 User Interface
Table 12-1. INTC Register Memory Map
Offset Register Register Name Access Reset
0x000 Interrupt Priority Register 0 IPR0 Read/Write 0x00000000
0x004 Interrupt Priority Register 1 IPR1 Read/Write 0x00000000
... ... ... ... ...
0x0FC Interrupt Priority Register 63 IPR63 Read/Write 0x00000000
0x100 Interrupt Request Register 0 IRR0 Read-only N/A
0x104 Interrupt Request Register 1 IRR1 Read-only N/A
... ... ... ... ...
0x1FC Interrupt Request Register 63 IRR63 Read-only N/A
0x200 Interrupt Cause Register 3 ICR3 Read-only N/A
0x204 Interrupt Cause Register 2 ICR2 Read-only N/A
0x208 Interrupt Cause Register 1 ICR1 Read-only N/A
0x20C Interrupt Cause Register 0 ICR0 Read-only N/A
203
32142D–06/2013
ATUC64/128/256L3/4U
12.6.1 Interrupt Priority Registers
Name: IPR0...IPR63
Access Type: Read/Write
Offset: 0x000 - 0x0FC
Reset Value: 0x00000000
• INTLEVEL: Interrupt Level
Indicates the EVBA-relative offset of the interrupt handler of the corresponding group:
00: INT0: Lowest priority
01: INT1
10: INT2
11: INT3: Highest priority
• AUTOVECTOR: Autovector Address
Handler offset is used to give the address of the interrupt handler. The least significant bit should be written to zero to give
halfword alignment.
31 30 29 28 27 26 25 24
INTLEVEL - - - - - -
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
- - AUTOVECTOR[13:8]
76543210
AUTOVECTOR[7:0]
204
32142D–06/2013
ATUC64/128/256L3/4U
12.6.2 Interrupt Request Registers
Name: IRR0...IRR63
Access Type: Read-only
Offset: 0x0FF - 0x1FC
Reset Value: N/A
• IRR: Interrupt Request line
This bit is cleared when no interrupt request is pending on this input request line.
This bit is set when an interrupt request is pending on this input request line.
The are 64 IRRs, one for each group. Each IRR has 32 bits, one for each possible interrupt request, for a total of 2048 possible
input lines. The IRRs are read by the software interrupt handler in order to determine which interrupt request is pending. The
IRRs are sampled continuously, and are read-only.
31 30 29 28 27 26 25 24
IRR[32*x+31] IRR[32*x+30] IRR[32*x+29] IRR[32*x+28] IRR[32*x+27] IRR[32*x+26] IRR[32*x+25] IRR[32*x+24]
23 22 21 20 19 18 17 16
IRR[32*x+23] IRR[32*x+22] IRR[32*x+21] IRR[32*x+20] IRR[32*x+19] IRR[32*x+18] IRR[32*x+17] IRR[32*x+16]
15 14 13 12 11 10 9 8
IRR[32*x+15] IRR[32*x+14] IRR[32*x+13] IRR[32*x+12] IRR[32*x+11] IRR[32*x+10] IRR[32*x+9] IRR[32*x+8]
76543210
IRR[32*x+7] IRR[32*x+6] IRR[32*x+5] IRR[32*x+4] IRR[32*x+3] IRR[32*x+2] IRR[32*x+1] IRR[32*x+0]
205
32142D–06/2013
ATUC64/128/256L3/4U
12.6.3 Interrupt Cause Registers
Name: ICR0...ICR3
Access Type: Read-only
Offset: 0x200 - 0x20C
Reset Value: N/A
• CAUSE: Interrupt Group Causing Interrupt of Priority n
ICRn identifies the group with the highest priority that has a pending interrupt of level n. This value is only defined when at least
one interrupt of level n is pending.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
--------
76543210
- - CAUSE
206
32142D–06/2013
ATUC64/128/256L3/4U
12.7 Module Configuration
The specific configuration for each INTC instance is listed in the following tables.The module
bus clocks listed here are connected to the system bus clocks. Please refer to the Power Manager
chapter for details.
12.7.1 Interrupt Request Signal Map
12.8 Interrupt Request Signal Map
The various modules may output Interrupt request signals. These signals are routed to the Interrupt
Controller (INTC), described in a later chapter. The Interrupt Controller supports up to 64
groups of interrupt requests. Each group can have up to 32 interrupt request signals. All interrupt
signals in the same group share the same autovector address and priority level. Refer to the
documentation for the individual submodules for a description of the semantics of the different
interrupt requests.
The interrupt request signals are connected to the INTC as follows.
Table 12-2. INTC Clock Name
Module Name Clock Name Description
INTC CLK_INTC Clock for the INTC bus interface
Table 12-3. Interrupt Request Signal Map
Group Line Module Signal
0 0 AVR32UC3 CPU SYSREG COMPARE
1
0 AVR32UC3 CPU OCD DCEMU_DIRTY
1 AVR32UC3 CPU OCD DCCPU_READ
2 0 Flash Controller FLASHCDW
3 0 Secure Access Unit SAU
4
0 Peripheral DMA Controller PDCA 0
1 Peripheral DMA Controller PDCA 1
2 Peripheral DMA Controller PDCA 2
3 Peripheral DMA Controller PDCA 3
5
0 Peripheral DMA Controller PDCA 4
1 Peripheral DMA Controller PDCA 5
2 Peripheral DMA Controller PDCA 6
3 Peripheral DMA Controller PDCA 7
6
0 Peripheral DMA Controller PDCA 8
1 Peripheral DMA Controller PDCA 9
2 Peripheral DMA Controller PDCA 10
3 Peripheral DMA Controller PDCA 11
7 0 Power Manager PM
207
32142D–06/2013
ATUC64/128/256L3/4U
8 0 System Control Interface SCIF
9 0 Asynchronous Timer AST ALARM
10
0 Asynchronous Timer AST PER
1 Asynchronous Timer AST OVF
2 Asynchronous Timer AST READY
3 Asynchronous Timer AST CLKREADY
11
0 External Interrupt Controller EIC 1
1 External Interrupt Controller EIC 2
2 External Interrupt Controller EIC 3
3 External Interrupt Controller EIC 4
12 0 External Interrupt Controller EIC 5
13 0 Frequency Meter FREQM
14
0 General-Purpose Input/Output Controller GPIO 0
1 General-Purpose Input/Output Controller GPIO 1
2 General-Purpose Input/Output Controller GPIO 2
3 General-Purpose Input/Output Controller GPIO 3
4 General-Purpose Input/Output Controller GPIO 4
5 General-Purpose Input/Output Controller GPIO 5
6 General-Purpose Input/Output Controller GPIO 6
7 General-Purpose Input/Output Controller GPIO 7
15 0 Universal Synchronous Asynchronous
Receiver Transmitter USART0
16 0 Universal Synchronous Asynchronous
Receiver Transmitter USART1
17 0 Universal Synchronous Asynchronous
Receiver Transmitter USART2
18 0 Universal Synchronous Asynchronous
Receiver Transmitter USART3
19 0 Serial Peripheral Interface SPI
20 0 Two-wire Master Interface TWIM0
21 0 Two-wire Master Interface TWIM1
22 0 Two-wire Slave Interface TWIS0
23 0 Two-wire Slave Interface TWIS1
24 0 Pulse Width Modulation Controller PWMA
25
0 Timer/Counter TC00
1 Timer/Counter TC01
2 Timer/Counter TC02
Table 12-3. Interrupt Request Signal Map
208
32142D–06/2013
ATUC64/128/256L3/4U
26
0 Timer/Counter TC10
1 Timer/Counter TC11
2 Timer/Counter TC12
27 0 ADC Interface ADCIFB
28 0 Analog Comparator Interface ACIFB
29 0 Capacitive Touch Module CAT
30 0 aWire AW
31 0 Audio Bitstream DAC ABDACB
32 0 USB 2.0 Interface USBC
33 0 Inter-IC Sound (I2S) Controller IISC
Table 12-3. Interrupt Request Signal Map
209
32142D–06/2013
ATUC64/128/256L3/4U
13. Power Manager (PM)
Rev: 4.2.0.4
13.1 Features
• Generates clocks and resets for digital logic
• On-the-fly frequency change of CPU, HSB and PBx clocks
• Sleep modes allow simple disabling of logic clocks and clock sources
• Module-level clock gating through maskable peripheral clocks
• Wake-up from internal or external interrupts
• Automatic identification of reset sources
• Supports advanced Shutdown sleep mode
13.2 Overview
The Power Manager (PM) provides synchronous clocks used to clock the main digital logic in the
device, namely the CPU, and the modules and peripherals connected to the High Speed Bus
(HSB) and the Peripheral Buses (PBx).
The PM contains advanced power-saving features, allowing the user to optimize the power consumption
for an application. The synchronous clocks are divided into a number of clock
domains, one for the CPU and HSB, and one for each PBx. The clocks can run at different
speeds, allowing the user to save power by running peripherals relatively slow, whilst maintaining
high CPU performance. The clocks can be independently changed on-the-fly, without halting
any peripherals. The user may adjust CPU and memory speeds according to the dynamic application
load, without disturbing or re-configuring active peripherals.
Each module has a separate clock, enabling the user to save power by switching off clocks to
inactive modules. Clocks and oscillators can be automatically switched off during idle periods by
the CPU sleep instruction. The system will return to normal operation when interrupts occur.
To achieve minimal power usage, a special sleep mode, called Shutdown is available, where
power on all internal logic (CPU, peripherals) and most of the I/O lines is removed, reducing current
leakage. Only a small amount of logic, including the 32KHz crystal oscillator (OSC32K) and
the AST remain powered.
The Power Manager also contains a Reset Controller, which collects all possible reset sources,
generates hard and soft resets, and allows the reset source to be identified by software.
210
32142D–06/2013
ATUC64/128/256L3/4U
13.3 Block Diagram
Figure 13-1. PM Block Diagram
13.4 I/O Lines Description
13.5 Product Dependencies
13.5.1 Interrupt
The PM interrupt line is connected to one of the interrupt controllers internal sources. Using the
PM interrupt requires the interrupt controller to be configured first.
13.5.2 Clock Implementation
In ATUC64/128/256L3/4U, the HSB shares source clock with the CPU. Write attempts to the
HSB Clock Select register (HSBSEL) will be ignored, and it will always read the same as the
CPU Clock Select register (CPUSEL).
The PM bus interface clock (CLK_PM) is generated by the Power Manager. This clock is
enabled at reset, and can be disabled in the Power Manager. If disabled it can only be reenabled
by a reset.
13.5.3 Power Considerations
The Shutdown mode is only available for the “3.3V supply mode, with 1.8V regulated I/O lines“
power configuration.
Table 13-1. I/O Lines Description
Name Description Type Active Level
RESET_N Reset Input Low
Sleep Controller
Synchronous
Clock Generator
Reset Controller
Main Clock Sources
Sleep
Instruction
Power-on Reset
Detector(s)
Resets
Synchronous
clocks
CPU, HSB,
PBx
Interrupts
External Reset Pin
Reset Sources
211
32142D–06/2013
ATUC64/128/256L3/4U
13.6 Functional Description
13.6.1 Synchronous Clocks
The System RC Oscillator (RCSYS) and a selection of other clock sources can provide the
source for the main clock, which is the origin for the synchronous CPU/HSB and PBx module
clocks. For details about the other main clock sources, please refer to the Main Clock Control
(MCCTRL) register description. The synchronous clocks can run of the main clock and all the 8-
bit prescaler settings as long as fCPU fPBx,. The synchronous clock source can be changed onthe
fly, according to variations in application load. The clock domains can be shut down in sleep
mode, as described in Section 13.6.3. The module clocks in every synchronous clock domain
can be individually masked to minimize power consumption in inactive modules.
Figure 13-2. Synchronous Clock Generation
13.6.1.1 Selecting the main clock source
The common main clock can be connected to RCSYS or a selection of other clock sources. For
details about the other main clock sources, please refer to the MCCTRL register description. By
default, the main clock will be connected to RCSYS. The user can connect the main clock to
another source by writing to the Main Clock Select (MCCTRL.MCSEL) field. The user must first
assure that the source is enabled and ready in order to avoid a deadlock. Care should also be
taken so that the new synchronous clock frequencies do not exceed the maximum frequency for
each clock domain.
13.6.1.2 Selecting synchronous clock division ratio
The main clock feeds an 8-bit prescaler, which can be used to generate the synchronous clocks.
By default, the synchronous clocks run on the undivided main clock. The user can select a prescaler
division for the CPU clock by writing a one to the CPU Division bit in the CPU Clock Select
register (CPUSEL.CPUDIV), and a value to the CPU Clock Select field (CPUSEL.CPUSEL),
resulting in a CPU clock frequency:
fCPU = fmain / 2(CPUSEL+1)
Mask
Prescaler Main Clock
Sources
MCSEL
0
1
CPUSEL
CPUDIV
Main Clock
Sleep
Controller
CPUMASK
CPU Clocks
HSB Clocks
PBx Clocks
Sleep
Instruction
212
32142D–06/2013
ATUC64/128/256L3/4U
Similarly, the PBx clocks can be divided by writing their respective Clock Select (PBxSEL) registers
to get the divided PBx frequency:
fPBx = fmain / 2(PBSEL+1)
The PBx clock frequency can not exceed the CPU clock frequency. The user must select a PBxSEL.PBSEL
value greater than or equal to the CPUSEL.CPUSEL value, so that fCPU fPBx. If the
user selects division factors that will result in fCPU< fPBx, the Power Manager will automatically
change the PBxSEL.PBSEL/PBDIV values to ensure correct operation (fCPU fPBx).
The HSB clock will always be forced to the same division as the CPU clock.
To ensure correct operation, the frequencies must never exceed the specified maximum frequency
for each clock domain.
For modules connected to the HSB bus, the PB clock frequency must be the same as the CPU
clock frequency.
13.6.1.3 Clock Ready flag
There is a slight delay from CPUSEL and PBxSEL being written to the new clock setting taking
effect. During this interval, the Clock Ready bit in the Status Register (SR.CKRDY) will read as
zero. When the clock settings change is completed, the bit will read as one. The Clock Select
registers (CPUSEL, PBxSEL) must not be written to while SR.CKRDY is zero, or the system
may become unstable or hang.
The Clock Ready bit in the Interrupt Status Register (ISR.CKRDY) is set on a SR.CKRDY zeroto-one
transition. If the Clock Ready bit in the Interrupt Mask Register (IMR.CKRDY) is set, an
interrupt request is generated. IMR.CKRDY is set by writing a one to the corresponding bit in the
Interrupt Enable Register (IER.CKRDY).
13.6.2 Peripheral Clock Masking
By default, the clocks for all modules are enabled, regardless of which modules are actually
being used. It is possible to disable the clock for a module in the CPU, HSB, or PBx clock
domain by writing a zero to the corresponding bit in the corresponding Clock Mask (CPUMASK/HSBMASK/PBxMASK)
register. When a module is not clocked, it will cease operation,
and its registers cannot be read nor written. The module can be re-enabled later by writing a one
to the corresponding mask bit. A module may be connected to several clock domains, in which
case it will have several mask bits. The Maskable Module Clocks table in the Clock Mask register
description contains a list of implemented maskable clocks.
13.6.2.1 Cautionary note
Note that clocks should only be switched off if it is certain that the module will not be used.
Switching off the clock for the Flash Controller will cause a problem if the CPU needs to read
from the flash. Switching off the clock to the Power Manager, which contains the mask registers,
or the corresponding PBx bridge, will make it impossible to write to the mask registers again. In
this case, they can only be re-enabled by a system reset.
13.6.3 Sleep Modes
In normal operation, all clock domains are active, allowing software execution and peripheral
operation. When the CPU is idle, it is possible to switch it and other (optional) clock domains off
to save power. This is done by the sleep instruction, which takes the sleep mode index number
from Table 13-2 on page 213 as argument.
213
32142D–06/2013
ATUC64/128/256L3/4U
13.6.3.1 Entering and exiting sleep modes
The sleep instruction will halt the CPU and all modules belonging to the stopped clock domains.
The modules will be halted regardless of the bit settings in the mask registers.
Clock sources can also be switched off to save power. Some of these have a relatively long
start-up time, and are only switched off when very low power consumption is required.
The CPU and affected modules are restarted when the sleep mode is exited. This occurs when
an interrupt triggers. Note that even if an interrupt is enabled in sleep mode, it may not trigger if
the source module is not clocked.
13.6.3.2 Supported sleep modes
The following sleep modes are supported. These are detailed in Table 13-2 on page 213.
• Idle: The CPU is stopped, the rest of the device is operational.
• Frozen: The CPU and HSB modules are stopped, peripherals are operational.
• Standby: All synchronous clocks are stopped, and the clock sources are running, allowing for
a quick wake-up to normal mode.
• Stop: As Standby, but oscillators, and other clock sources are also stopped. 32KHz Oscillator
OSC32K(2), RCSYS, AST, and WDT will remain operational.
• DeepStop: All synchronous clocks and clock sources are stopped. Bandgap voltage
reference and BOD are turned off. OSC32K(2) and RCSYS remain operational.
• Static: All clock sources, including RCSYS are stopped. Bandgap voltage reference and BOD
are turned off. OSC32K(2) remains operational.
• Shutdown: All clock sources, including RCSYS are stopped. Bandgap voltage reference,
BOD detector, and Voltage regulator are turned off. OSC32K(2) remains operational. This
mode can only be used in the “3.3V supply mode, with 1.8V regulated I/O lines“
configuration (described in Power Considerations chapter). Refer to Section 13.6.4 for more
details.
Notes: 1. The sleep mode index is used as argument for the sleep instruction.
2. OSC32K will only remain operational if pre-enabled.
3. Clock sources other than those specifically listed in the table.
4. SYSTIMER is the clock for the CPU COUNT and COMPARE registers.
The internal voltage regulator is also adjusted according to the sleep mode in order to reduce its
power consumption.
Table 13-2. Sleep Modes
Index(1) Sleep Mode CPU HSB
PBx,
GCLK
Clock Sources(3),
SYSTIMER(4) OSC32K(2) RCSYS
BOD &
Bandgap
Voltage
Regulator
0 Idle Stop Run Run Run Run Run On Normal mode
1 Frozen Stop Stop Run Run Run Run On Normal mode
2 Standby Stop Stop Stop Run Run Run On Normal mode
3 Stop Stop Stop Stop Stop Run Run On Low power mode
4 DeepStop Stop Stop Stop Stop Run Run Off Low power mode
5 Static Stop Stop Stop Stop Run Stop Off Low power mode
6 Shutdown Stop Stop Stop Stop Run Stop Off Off
214
32142D–06/2013
ATUC64/128/256L3/4U
13.6.3.3 Waking from sleep modes
There are two types of wake-up sources from sleep mode, synchronous and asynchronous.
Synchronous wake-up sources are all non-masked interrupts. Asynchronous wake-up sources
are AST, WDT, external interrupts from EIC, external reset, external wake pin (WAKE_N), and
all asynchronous wake-ups enabled in the Asynchronous Wake Up Enable (AWEN) register. The
valid wake-up sources for each sleep mode are detailed in Table 13-3 on page 214.
In Shutdown the only wake-up sources are external reset, external wake-up pin or AST. See
Section 13.6.4.3 on page 216.
Notes: 1. The sleep mode index is used as argument for the sleep instruction.
2. Only PB modules operational, as HSB module clocks are stopped.
3. WDT only available if clocked from pre-enabled OSC32K.
13.6.3.4 SleepWalking
In all sleep modes where the PBx clocks are stopped, except for Shutdown mode, the device
can partially wake up if a PBx module asynchronously discovers that it needs its clock. Only the
requested clocks and clock sources needed will be started, all other clocks will remain masked
to zero. E.g. if the main clock source is OSC0, only OSC0 will be started even if other clock
sources were enabled in normal mode. Generic clocks can also be started in a similar way. The
state where only requested clocks are running is referred to as SleepWalking.
The time spent to start the requested clock is mostly limited by the startup time of the given clock
source. This allows PBx modules to handle incoming requests, while still keeping the power consumption
at a minimum.
When the device is SleepWalking any asynchronous wake-up can wake the device up at any
time without stopping the requested PBx clock.
All requests to start clocks can be masked by writing to the Peripheral Power Control Register
(PPCR), all requests are enabled at reset.
During SleepWalking the interrupt controller clock will be running. If an interrupt is pending when
entering SleepWalking, it will wake the whole device up.
13.6.3.5 Precautions when entering sleep mode
Modules communicating with external circuits should normally be disabled before entering a
sleep mode that will stop the module operation. This will prevent erratic behavior caused by
entering or exiting sleep modes. Please refer to the relevant module documentation for recommended
actions.
Table 13-3. Wake-up Sources
Index(1) Sleep Mode Wake-up Sources
0 Idle Synchronous, Asynchronous
1 Frozen Synchronous(2), Asynchronous
2 Standby Asynchronous
3 Stop Asynchronous
4 DeepStop Asynchronous
5 Static Asynchronous(3)
6 Shutdown External reset, External wake-up pin
215
32142D–06/2013
ATUC64/128/256L3/4U
Communication between the synchronous clock domains is disturbed when entering and exiting
sleep modes. Bus transactions over clock domains affected by the sleep mode are therefore not
recommended. The system may hang if the bus clocks are stopped during a bus transaction.
The CPU is automatically stopped in a safe state to ensure that all CPU bus operations are complete
when the sleep mode goes into effect. Thus, when entering Idle mode, no further action is
necessary.
When entering a sleep mode (except Idle mode), all HSB masters must be stopped before
entering the sleep mode. In order to let potential PBx write operations complete, the user should
let the CPU perform a PBx register read operation before issuing the sleep instruction. This will
stall the CPU until pending PBx operations have completed.
The Shutdown sleep mode requires extra care. Please refer to Section 13.6.4.
13.6.4 Shutdown Sleep Mode
13.6.4.1 Description
The Shutdown sleep mode is available only when the device is used in the “3.3V supply mode,
with 1.8V regulated I/O lines“ configuration (refer to the Power Considerations chapter). In this
configuration, the voltage regulator supplies both VDDCORE and VDDIO power supplies.
When the device enters Shutdown mode, the regulator is turned off and only the following logic
is kept powered by VDDIN:
– OSC32K using alternate pinout PA13/PA20
– AST core logic (internal counter and alarm detection logic)
– Backup Registers
– I/O lines PA11, PA13, PA20, PA21, PB04, PB05, and PB10
– RESET_N line
The table below lists I/O line functionality that remains operational during Shutdown sleep mode.
If no special function is used the I/O line will keep its setting when entering the sleep mode
13.6.4.2 Entering Shutdown sleep mode
Before entering the Shutdown sleep mode, a few actions are required:
– All modules should normally be disabled before entering Shutdown sleep mode (see
Section 13.6.3.5)
Table 13-4. I/O Lines Usage During Shutdown Mode
Pin Possible Usage During Shutdown Sleep Mode
PA11 WAKE_N signal (active low wake-up)
PA13 XIN32_2 (OSC32K using alternate pinout)
PA20 XOUT32_2 (OSC32K using alternate pinout)
PA21
PB04
PB05
PB10
RESET_N Reset pin
216
32142D–06/2013
ATUC64/128/256L3/4U
– The POR33 must be masked to avoid spurious resets when the power is back. This
must also be done when POR33 is disabled, as POR33 will be enabled
automatically when the device wakes up from Shutdown mode. Disable the POR33
by writing a one to the POR33MASK bit in the SCIF.VREGCR register. Due to
internal synchronisation, this bit must be read as a one before the sleep instruction is
executed by the CPU. Refer to the System Control Interface (SCIF) chapter for more
details.
– The 32KHz RC oscillator (RC32K) must be running and stable. This is done by
writing a one to the EN bit in the SCIF.RC32KCR register. Due to internal
synchronisation, this bit must be read as a one to ensure that the oscillator is stable
before the sleep instruction is executed by the CPU.
As soon as the Shutdown sleep mode is entered, all CPU and peripherals are reset to ensure a
consistent state. POR33 and RC32K are automatically disabled to save extra power.
13.6.4.3 Leaving Shutdown sleep mode
Exiting Shutdown sleep mode can be done by the events described in Table 13-5.
When a wake-up event occurs, the regulator is turned on and the device will wait for VDDCORE
to be valid before starting. The Sleep Reset bit in the Reset Cause register (RCAUSE.SLEEP) is
then set, allowing software running on the device to distinguish between the first power-up and a
wake-up from Shutdown mode.
13.6.4.4 Special consideration regarding waking up from Shutdown sleep mode using the WAKE_N pin
By default, the WAKE_N pin will only wake the device up if it is pulled low after entering Shutdown
mode. If the WAKE_N is pulled low before the Shutdown mode is entered, it will not wake
the device from the Shutdown sleep mode. In order to wake the device by pulling WAKE_N low
before entering Shutdown mode, the user has to write a one to the bit corresponding to the
WAKEN wake-up source in the AWEN register. In this scenario, the CPU execution will proceed
with the next instruction, and the RCAUSE register content will not be altered.
13.6.5 Divided PB Clocks
The clock generator in the Power Manager provides divided PBx clocks for use by peripherals
that require a prescaled PBx clock. This is described in the documentation for the relevant modules.
The divided clocks are directly maskable, and are stopped in sleep modes where the PBx
clocks are stopped.
Table 13-5. Events That Can Wake up the Device from Shutdown Mode
Source How
PA11 (WAKE_N) Pulling-down PA11 will wake up the device
RESET_N
Pulling-down RESET_N pin will wake up the device
The device is kept under reset until RESET_N is tied high
again
AST
OSC32K must be set-up to use alternate pinout (XIN32_2
and XOUT32_2) Refer to the SCIF Chapter
AST must be configured to use the clock from OSC32K
AST must be configured to allow alarm, periodic, or
overflow wake-up
217
32142D–06/2013
ATUC64/128/256L3/4U
13.6.6 Reset Controller
The Reset Controller collects the various reset sources in the system and generates hard and
soft resets for the digital logic.
The device contains a Power-on Reset (POR) detector, which keeps the system reset until
power is stable. This eliminates the need for external reset circuitry to guarantee stable operation
when powering up the device.
It is also possible to reset the device by pulling the RESET_N pin low. This pin has an internal
pull-up, and does not need to be driven externally during normal operation. Table 13-6 on page
217 lists these and other reset sources supported by the Reset Controller.
Figure 13-3. Reset Controller Block Diagram
In addition to the listed reset types, the JTAG & aWire can keep parts of the device statically
reset. See JTAG and aWire documentation for details.
Table 13-6. Reset Description
Reset Source Description
Power-on Reset Supply voltage below the Power-on Reset detector threshold
voltage VPOT
External Reset RESET_N pin asserted
Brown-out Reset VDDCORE supply voltage below the Brown-out detector
threshold voltage
JTAG
Reset
Controller
RESET_N
Power-on Reset
Detector(s)
OCD
Watchdog Reset
RCAUSE
CPU, HSB, PBx
OCD, AST, WDT,
Clock Generator
Brown-out
Detector
AWIRE
SM33 Detector
218
32142D–06/2013
ATUC64/128/256L3/4U
Depending on the reset source, when a reset occurs, some parts of the device are not always
reset. Only the Power-on Reset (POR) will force a whole device reset. Refer to the table in the
Module Configuration section at the end of this chapter for further details. The latest reset cause
can be read in the RCAUSE register, and can be read during the applications boot sequence in
order to determine proper action.
13.6.6.1 Power-on Reset Detector
The Power-on Reset 1.8V (POR18) detector monitors the VDDCORE supply pin and generates
a Power-on Reset (POR) when the device is powered on. The POR is active until the
VDDCORE voltage is above the power-on threshold level (VPOT). The POR will be re-generated
if the voltage drops below the power-on threshold level. See Electrical Characteristics for parametric
details.
The Power-on Reset 3.3V (POR33) detector monitors the internal regulator supply pin and generates
a Power-on Reset (POR) when the device is powered on. The POR is active until the
internal regulator supply voltage is above the regulator power-on threshold level (VPOT). The
POR will be re-generated if the voltage drops below the regulator power-on threshold level. See
Electrical Characteristics for parametric details.
13.6.6.2 External Reset
The external reset detector monitors the RESET_N pin state. By default, a low level on this pin
will generate a reset.
13.6.7 Clock Failure Detector
This mechanism automatically switches the main clock source to the safe RCSYS clock when
the main clock source fails. This may happen when an external crystal is selected as a source
for the main clock and the crystal is not mounted on the board. The main clock is compared with
RCSYS, and if no rising edge of the main clock is detected during one RCSYS period, the clock
is considered to have failed.
The detector is enabled by writing a one to the Clock Failure Detection Enable bit in the Clock
Failure Detector Control Register (CFDCTRL.CFDEN). As soon as the detector is enabled, the
clock failure detector will monitor the divided main clock. Note that the detector does not monitor
the main clock if RCSYS is the source of the main clock, or if the main clock is temporarily not
available (startup-time after a wake-up, switching timing etc.), or in sleep mode where the main
clock is driven by the RCSYS (Stop and DeepStop mode). When a clock failure is detected, the
main clock automatically switches to the RCSYS clock and the Clock Failure Detected (CFD)
interrupt is generated if enabled. The MCCTRL register is also changed by hardware to indicate
that the main clock comes from RCSYS.
13.6.8 Interrupts
The PM has a number of interrupt sources:
• AE - Access Error,
SM33 Reset Internal regulator supply voltage below the SM33 threshold
voltage. This generates a Power-on Reset.
Watchdog Timer See Watchdog Timer documentation
OCD See On-Chip Debug documentation
Reset Source Description
219
32142D–06/2013
ATUC64/128/256L3/4U
– A lock protected register is written to without first being unlocked.
• CKRDY - Clock Ready:
– New Clock Select settings in the CPUSEL/PBxSEL registers have taken effect. (A
zero-to-one transition on SR.CKRDY is detected).
• CFD - Clock Failure Detected:
– The system detects that the main clock is not running.
The Interrupt Status Register contains one bit for each interrupt source. A bit in this register is
set on a zero-to-one transition of the corresponding bit in the Status Register (SR), and cleared
by writing a one to the corresponding bit in the Interrupt Clear Register (ICR). The interrupt
sources will generate an interrupt request if the corresponding bit in the Interrupt Mask Register
is set. The interrupt sources are ORed together to form one interrupt request. The Power Manager
will generate an interrupt request if at least one of the bits in the Interrupt Mask Register
(IMR) is set. Bits in IMR are set by writing a one to the corresponding bit in the Interrupt Enable
Register (IER), and cleared by writing a one to the corresponding bit in the Interrupt Disable
Register (IDR). The interrupt request remains active until the corresponding bit in the Interrupt
Status Register (ISR) is cleared by writing a one to the corresponding bit in the Interrupt Clear
Register (ICR). Because all the interrupt sources are ORed together, the interrupt request from
the Power Manager will remain active until all the bits in ISR are cleared.
220
32142D–06/2013
ATUC64/128/256L3/4U
13.7 User Interface
Note: 1. The reset value is device specific. Please refer to the Module Configuration section at the end of this chapter.
2. Latest Reset Source.
3. Latest Wake Source.
Table 13-7. PM Register Memory Map
Offset Register Register Name Access Reset
0x000 Main Clock Control MCCTRL Read/Write 0x00000000
0x004 CPU Clock Select CPUSEL Read/Write 0x00000000
0x008 HSB Clock Select HSBSEL Read-only 0x00000000
0x00C PBA Clock Select PBASEL Read/Write 0x00000000
0x010 PBB Clock Select PBBSEL Read/Write 0x00000000
0x014 - 0x01C Reserved
0x020 CPU Mask CPUMASK Read/Write 0x00010001
0x024 HSB Mask HSBMASK Read/Write 0x0000007F
0x028 PBA Mask PBAMASK Read/Write 0x0FFFFFFF
0x02C PBB Mask PBBMASK Read/Write 0x0000000F
0x030- 0x03C Reserved
0x040 PBA Divided Mask PBADIVMASK Read/Write 0x0000007F
0x044 - 0x050 Reserved
0x054 Clock Failure Detector Control CFDCTRL Read/Write 0x00000000
0x058 Unlock Register UNLOCK Write-only 0x00000000
0x05C - 0x0BC Reserved
0x0C0 Interrupt Enable Register IER Write-only 0x00000000
0x0C4 Interrupt Disable Register IDR Write-only 0x00000000
0x0C8 Interrupt Mask Register IMR Read-only 0x00000000
0x0CC Interrupt Status Register ISR Read-only 0x00000000
0x0D0 Interrupt Clear Register ICR Write-only 0x00000000
0x0D4 Status Register SR Read-only 0x00000020
0x0D8 - 0x15C Reserved
0x160 Peripheral Power Control Register PPCR Read/Write 0x000001FA
0x164 - 0x17C Reserved
0x180 Reset Cause Register RCAUSE Read-only -(2)
0x184 Wake Cause Register WCAUSE Read-only -(3)
0x188 Asynchronous Wake Up Enable Register AWEN Read/Write 0x00000000
0x18C - 0x3F4 Reserved
0x3F8 Configuration Register CONFIG Read-only 0x00000043
0x3FC Version Register VERSION Read-only -(1)
221
32142D–06/2013
ATUC64/128/256L3/4U
13.7.1 Main Clock Control
Name: MCCTRL
Access Type: Read/Write
Offset: 0x000
Reset Value: 0x00000000
• MCSEL: Main Clock Select
Note: 1. If the 120MHz RC oscillator is selected as main clock source, it must be divided by at least 4 before being used as clock
source for the CPU. This division is selected by writing to the CPUSEL and CPUDIV bits in the CPUSEL register, before
switching to RC120M as main clock source.
Note that this register is protected by a lock. To write to this register the UNLOCK register has to be written first. Please
refer to the UNLOCK register description for details.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
--------
76543210
- - - - - MCSEL
Table 13-8. Main clocks in ATUC64/128/256L3/4U.
MCSEL[2:0] Main clock source
0 System RC oscillator (RCSYS)
1 Oscillator0 (OSC0)
2 DFLL
3 120MHz RC oscillator
(RC120M)(1)
222
32142D–06/2013
ATUC64/128/256L3/4U
13.7.2 CPU Clock Select
Name: CPUSEL
Access Type: Read/Write
Offset: 0x004
Reset Value: 0x00000000
• CPUDIV, CPUSEL: CPU Division and Clock Select
CPUDIV = 0: CPU clock equals main clock.
CPUDIV = 1: CPU clock equals main clock divided by 2(CPUSEL+1).
Note that if CPUDIV is written to 0, CPUSEL should also be written to 0 to ensure correct operation.
Also note that writing this register clears POSCSR.CKRDY. The register must not be re-written until CKRDY goes high.
Note that this register is protected by a lock. To write to this register the UNLOCK register has to be written first. Please
refer to the UNLOCK register description for details.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
--------
76543210
CPUDIV - - - - CPUSEL
223
32142D–06/2013
ATUC64/128/256L3/4U
13.7.3 HSB Clock Select
Name: HSBSEL
Access Type: Read
Offset: 0x008
Reset Value: 0x00000000
This register is read-only and its content is always equal to CPUSEL.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
--------
76543210
HSBDIV - - - - HSBSEL
224
32142D–06/2013
ATUC64/128/256L3/4U
13.7.4 PBx Clock Select
Name: PBxSEL
Access Type: Read/Write
Offset: 0x00C-0x010
Reset Value: 0x00000000
• PBDIV, PBSEL: PBx Division and Clock Select
PBDIV = 0: PBx clock equals main clock.
PBDIV = 1: PBx clock equals main clock divided by 2(PBSEL+1).
Note that if PBDIV is written to 0, PBSEL should also be written to 0 to ensure correct operation.
Also note that writing this register clears SR.CKRDY. The register must not be re-written until SR.CKRDY is set.
Note that this register is protected by a lock. To write to this register the UNLOCK register has to be written first. Please
refer to the UNLOCK register description for details.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
--------
76543210
PBDIV - - - - PBSEL
225
32142D–06/2013
ATUC64/128/256L3/4U
13.7.5 Clock Mask
Name: CPUMASK/HSBMASK/PBAMASK/PBBMASK
Access Type: Read/Write
Offset: 0x020-0x02C
Reset Value: -
• MASK: Clock Mask
If bit n is cleared, the clock for module n is stopped. If bit n is set, the clock for module n is enabled according to the current
power mode. The number of implemented bits in each mask register, as well as which module clock is controlled by each bit, is
shown in Table 13-9.
31 30 29 28 27 26 25 24
MASK[31:24]
23 22 21 20 19 18 17 16
MASK[23:16]
15 14 13 12 11 10 9 8
MASK[15:8]
76543210
MASK[7:0]
Table 13-9. Maskable Module Clocks in ATUC64/128/256L3/4U.
Bit CPUMASK HSBMASK PBAMASK PBBMASK
0 OCD PDCA PDCA FLASHCDW
1 - FLASHCDW INTC HMATRIX
2 - SAU PM SAU
3 - PBB bridge SCIF USBC
4 - PBA bridge AST -
5 - Peripheral Event System WDT -
6 - USBC EIC -
7 - - FREQM -
8 - - GPIO -
9 - - USART0 -
10 - - USART1 -
11 - - USART2 -
226
32142D–06/2013
ATUC64/128/256L3/4U
Note that this register is protected by a lock. To write to this register the UNLOCK register has to be written first. Please
refer to the UNLOCK register description for details.
12 - - USART3 -
13 - - SPI -
14 - - TWIM0 -
15 - - TWIM1 -
16 SYSTIMER - TWIS0 -
17 - - TWIS1 -
18 - - PWMA -
19 - - TC0 -
20 - - TC1 -
21 - - ADCIFB -
22 - - ACIFB -
23 - - CAT -
24 - - GLOC -
25 - - AW -
26 - - ABDACB -
27 - - IISC -
31:28 - - - -
Table 13-9. Maskable Module Clocks in ATUC64/128/256L3/4U.
Bit CPUMASK HSBMASK PBAMASK PBBMASK
227
32142D–06/2013
ATUC64/128/256L3/4U
13.7.6 PBA Divided Mask
Name: PBADIVMASK
Access Type: Read/Write
Offset: 0x040
Reset Value: 0x0000007F
• MASK: Clock Mask
If bit n is written to zero, the clock divided by 2(n+1) is stopped. If bit n is written to one, the clock divided by 2(n+1) is enabled
according to the current power mode. Table 13-10 shows what clocks are affected by the different MASK bits.
Note that this register is protected by a lock. To write to this register the UNLOCK register has to be written first. Please
refer to the UNLOCK register description for details.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
- ------
15 14 13 12 11 10 9 8
--------
76543210
- MASK[6:0]
Table 13-10. Divided Clock Mask
Bit USART0 USART1 USART2 USART3 TC0 TC1
0 - - - - TIMER_CLOCK2 TIMER_CLOCK2
1- - - - - -
2 CLK_USART/
DIV
CLK_USART/
DIV
CLK_USART/
DIV
CLK_USART/
DIV TIMER_CLOCK3 TIMER_CLOCK3
3- - - - - -
4 - - - - TIMER_CLOCK4 TIMER_CLOCK4
5- - - - - -
6 - - - - TIMER_CLOCK5 TIMER_CLOCK5
228
32142D–06/2013
ATUC64/128/256L3/4U
13.7.7 Clock Failure Detector Control Register
Name: CFDCTRL
Access Type: Read/Write
Offset: 0x054
Reset Value: 0x00000000
• SFV: Store Final Value
0: The register is read/write
1: The register is read-only, to protect against further accidental writes.
• CFDEN: Clock Failure Detection Enable
0: Clock Failure Detector is disabled
1: Clock Failure Detector is enabled
Note that this register is protected by a lock. To write to this register the UNLOCK register has to be written first. Please
refer to the UNLOCK register description for details.
31 30 29 28 27 26 25 24
SFV - - - - - - -
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
--------
76543210
- - - - - - - CFDEN
229
32142D–06/2013
ATUC64/128/256L3/4U
13.7.8 Unlock Register
Name: UNLOCK
Access Type: Write-only
Offset: 0x058
Reset Value: 0x00000000
To unlock a write protected register, first write to the UNLOCK register with the address of the register to unlock in the
ADDR field and 0xAA in the KEY field. Then, in the next PB access write to the register specified in the ADDR field.
• KEY: Unlock Key
Write this bit field to 0xAA to enable unlock.
• ADDR: Unlock Address
Write the address of the register to unlock to this field.
31 30 29 28 27 26 25 24
KEY
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
- - - - - - ADDR[9:8]
76543210
ADDR[7:0]
230
32142D–06/2013
ATUC64/128/256L3/4U
13.7.9 Interrupt Enable Register
Name: IER
Access Type: Write-only
Offset: 0x0C0
Reset Value: 0x00000000
Writing a zero to a bit in this register has no effect.
Writing a one to a bit in this register will set the corresponding bit in IMR.
31 30 29 28 27 26 25 24
AE - - - - - - -
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
--------
76543210
- - CKRDY - - - - CFD
231
32142D–06/2013
ATUC64/128/256L3/4U
13.7.10 Interrupt Disable Register
Name: IDR
Access Type: Write-only
Offset: 0x0C4
Reset Value: 0x00000000
Writing a zero to a bit in this register has no effect.
Writing a one to a bit in this register will clear the corresponding bit in IMR.
31 30 29 28 27 26 25 24
AE - - - - - - -
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
--------
76543210
- - CKRDY - - - - CFD
232
32142D–06/2013
ATUC64/128/256L3/4U
13.7.11 Interrupt Mask Register
Name: IMR
Access Type: Read-only
Offset: 0x0C8
Reset Value: 0x00000000
0: The corresponding interrupt is disabled.
1: The corresponding interrupt is enabled.
This bit is cleared when the corresponding bit in IDR is written to one.
This bit is set when the corresponding bit in IER is written to one.
31 30 29 28 27 26 25 24
AE - - - - - - -
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
--------
76543210
- - CKRDY - - - - CFD
233
32142D–06/2013
ATUC64/128/256L3/4U
13.7.12 Interrupt Status Register
Name: ISR
Access Type: Read-only
Offset: 0x0CC
Reset Value: 0x00000000
0: The corresponding interrupt is cleared.
1: The corresponding interrupt is pending.
This bit is cleared when the corresponding bit in ICR is written to one.
This bit is set on a zero-to-one transition of the corresponding bit in the Status Register (SR).
31 30 29 28 27 26 25 24
AE - - - - - - -
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
--------
76543210
- - CKRDY - - - - CFD
234
32142D–06/2013
ATUC64/128/256L3/4U
13.7.13 Interrupt Clear Register
Name: ICR
Access Type: Write-only
Offset: 0x0D0
Reset Value: 0x00000000
Writing a zero to a bit in this register has no effect.
Writing a one to a bit in this register will clear the corresponding bit in ISR.
31 30 29 28 27 26 25 24
AE - - - - - - -
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
--------
76543210
- - CKRDY - - - - CFD
235
32142D–06/2013
ATUC64/128/256L3/4U
13.7.14 Status Register
Name: SR
Access Type: Read-only
Offset: 0x0D4
Reset Value: 0x00000020
• AE: Access Error
0: No access error has occurred.
1: A write to lock protected register without unlocking it has occurred.
• CKRDY: Clock Ready
0: One of the CPUSEL/PBxSEL registers has been written, and the new clock setting is not yet effective.
1: The synchronous clocks have frequencies as indicated in the CPUSEL/PBxSEL registers.
• CFD: Clock Failure Detected
0: Main clock is running correctly.
1: Failure on main clock detected. Main clock is now running on RCSYS.
31 30 29 28 27 26 25 24
AE - - - - - - -
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
--------
76543210
- - CKRDY - - - - CFD
236
32142D–06/2013
ATUC64/128/256L3/4U
13.7.15 Peripheral Power Control Register
Name: PPCR
Access Type: Read/Write
Offset: 0x004
Reset Value: 0x000001FA
• RSTTM: Reset test mode
0: External reset not in test mode
1: External reset in test mode
• FRC32: Force RC32 out
0: RC32 signal is not forced as output
1: RC32 signal is forced as output
• RSTPUN: Reset Pull-up, active low
0: Pull-up for external reset on
1: Pull-up for external reset off
31 30 29 28 27 26 25 24
PPC[31:24]
23 22 21 20 19 18 17 16
PPC[23:16]
15 14 13 12 11 10 9 8
PPC[15:8]
76543210
PPC[7:0]
Table 13-11. Peripheral Power Control
Bit Name
0 RSTPUN
1 FRC32
2 RSTTM
3 CATRCMASK
4 ACIFBCRCMASK
5 ADCIFBRCMASK
6 ASTRCMASK
7 TWIS0RCMASK
8 TWIS1RCMASK
31:9 -
237
32142D–06/2013
ATUC64/128/256L3/4U
• CATRCMASK: CAT Request Clock Mask
0: CAT Request Clock is disabled
1: CAT Request Clock is enabled
• ACIFBRCMASK: ACIFB Request Clock Mask
0: ACIFB Request Clock is disabled
1: ACIFB Request Clock is enabled
• ADCIFBRCMASK: ADCIFB Request Clock Mask
0: ADCIFB Request Clock is disabled
1: ADCIFB Request Clock is enabled
• ASTRCMASK: AST Request Clock Mask
0: AST Request Clock is disabled
1: AST Request Clock is enabled
• TWIS0RCMASK: TWIS0 Request Clock Mask
0: TWIS0 Request Clock is disabled
1: TWIS0 Request Clock is enabled
• TWIS1RCMASK: TWIS1 Request Clock Mask
0: TWIS1 Request Clock is disabled
1: TWIS1 Request Clock is enabled
Note that this register is protected by a lock. To write to this register the UNLOCK register has to be written first. Please
refer to the UNLOCK register description for details.
238
32142D–06/2013
ATUC64/128/256L3/4U
13.7.16 Reset Cause Register
Name: RCAUSE
Access Type: Read-only
Offset: 0x180
Reset Value: Latest Reset Source
• AWIRE: aWire Reset
This bit is set when the last reset was caused by the aWire.
• JTAG: JTAG Reset
This bit is set when the last reset was caused by the JTAG.
• OCDRST: OCD Reset
This bit is set when the last reset was due to the RES bit in the OCD Development Control register having been written to one.
• SLEEP: Sleep Reset
This bit is set when the last reset was due to the device waking up from the Shutdown sleep mode.
• WDT: Watchdog Reset
This bit is set when the last reset was due to a watchdog time-out.
• EXT: External Reset Pin
This bit is set when the last reset was due to the RESET_N pin being pulled low.
• BOD: Brown-out Reset
This bit is set when the last reset was due to the core supply voltage being lower than the brown-out threshold level.
• POR: Power-on Reset
This bit is set when the last reset was due to the core supply voltage VDDCORE being lower than the power-on threshold level
(the reset is generated by the POR18 detector), or the internal regulator supply voltage being lower than the regulator power-on
threshold level (generated by the POR33 detector), or the internal regulator supply voltage being lower than the minimum
required input voltage (generated by the 3.3V supply monitor SM33).
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
- - - AWIRE - JTAG OCDRST
76543210
- SLEEP - - WDT EXT BOD POR
239
32142D–06/2013
ATUC64/128/256L3/4U
13.7.17 Wake Cause Register
Name: WCAUSE
Access Type: Read-only
Offset: 0x184
Reset Value: Latest Wake Source
A bit in this register is set on wake up caused by the peripheral referred to in Table 13-12 on page 239.
31 30 29 28 27 26 25 24
WCAUSE[31:24]
23 22 21 20 19 18 17 16
WCAUSE[23:16]
15 14 13 12 11 10 9 8
WCAUSE[15:8]
76543210
WCAUSE[7:0]
Table 13-12. Wake Cause
Bit Wake Cause
0 CAT
1 ACIFB
2 ADCIFB
3 TWI Slave 0
4 TWI Slave 1
5 WAKE_N
6 ADCIFB Pen Detect
7 USBC
15:8 -
16 EIC
17 AST
31:18 -
240
32142D–06/2013
ATUC64/128/256L3/4U
13.7.18 Asynchronous Wake Up Enable Register
Name: AWEN
Access Type: Read/Write
Offset: 0x188
Reset Value: 0x00000000
Each bit in this register corresponds to an asynchronous wake-up source, according to Table 13-13 on page 240.
0: The corresponding wake up is disabled.
1: The corresponding wake up is enabled
31 30 29 28 27 26 25 24
AWEN[31:24]
23 22 21 20 19 18 17 16
AWEN[23:16]
15 14 13 12 11 10 9 8
AWEN[15:8]
76543210
AWEN[7:0]
Table 13-13. Asynchronous Wake-up Sources
Bit Asynchronous Wake-up Source
0 CAT
1 ACIFB
2 ADCIFB
3 TWIS0
4 TWIS1
5 WAKEN
6 ADCIFBPD
7 USBC
31:8 -
241
32142D–06/2013
ATUC64/128/256L3/4U
13.7.19 Configuration Register
Name: CONFIG
Access Type: Read-Only
Offset: 0x3F8
Reset Value: -
This register shows the configuration of the PM.
• HSBPEVC:HSB PEVC Clock Implemented
0: HSBPEVC not implemented.
1: HSBPEVC implemented.
• PBD: PBD Implemented
0: PBD not implemented.
1: PBD implemented.
• PBC: PBC Implemented
0: PBC not implemented.
1: PBC implemented.
• PBB: PBB Implemented
0: PBB not implemented.
1: PBB implemented.
• PBA: PBA Implemented
0: PBA not implemented.
1: PBA implemented.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
--------
76543210
HSBPEVC - - - PBD PBC PBB PBA
242
32142D–06/2013
ATUC64/128/256L3/4U
13.7.20 Version Register
Name: VERSION
Access Type: Read-Only
Offset: 0x3FC
Reset Value: -
• VARIANT: Variant Number
Reserved. No functionality associated.
• VERSION: Version Number
Version number of the module. No functionality associated.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
- - - - VARIANT
15 14 13 12 11 10 9 8
- - - - VERSION[11:8]
76543210
VERSION[7:0]
243
32142D–06/2013
ATUC64/128/256L3/4U
13.8 Module Configuration
The specific configuration for each PM instance is listed in the following tables. The module bus
clocks listed here are connected to the system bus clocks. Please refer to the “Synchronous
Clocks”, “Peripheral Clock Masking” and “Sleep Modes” sections for details.
Table 13-14. Power Manager Clocks
Clock Name Description
CLK_PM Clock for the PM bus interface
Table 13-15. Register Reset Values
Register Reset Value
VERSION 0x00000420
Table 13-16. Effect of the Different Reset Events
Power-on
Reset
External
Reset
Watchdog
Reset
BOD
Reset
SM33
Reset
CPU Error
Reset
OCD
Reset
JTAG
Reset
CPU/HSB/PBx
(excluding Power Manager)
Y Y Y YY Y YY
32KHz oscillator Y N N N N N N N
RC Oscillator Calibration register Y N N N N N N N
Other oscillator control registers Y Y Y Y Y Y Y Y
AST registers, except interrupt
registers
Y N N NN N NN
Watchdog control register Y Y N Y Y Y Y Y
Voltage Calibration register Y N N N N N N N
SM33 control register Y Y Y Y Y Y Y Y
BOD control register Y Y Y N Y Y Y Y
Clock control registers Y Y Y Y Y Y Y Y
OCD system and OCD registers Y Y N Y Y Y N Y
244
32142D–06/2013
ATUC64/128/256L3/4U
14. System Control Interface (SCIF)
Rev: 1.1.0.0
14.1 Features
• Supports crystal oscillator 0.45-16MHz (OSC0)
• Supports Digital Frequency Locked Loop 20-150MHz (DFLL)
• Supports Phase Locked Loop 80-240MHz (PLL)
• Supports 32KHz ultra-low-power oscillator (OSC32K)
• Supports 32kHz RC oscillator (RC32K)
• Integrated low-power RC oscillator (RCSYS)
• Generic clocks (GCLK) with wide frequency range provided
• Generic Clock Prescaler
• Controls Bandgap
• Controls Brown-out detectors (BOD) and supply monitors
• Controls Voltage Regulator (VREG) behavior and calibration
• Controls Temperature Sensor
• Controls Supply Monitor 33 (SM33) operating modes and calibration
• Controls 120MHz integrated RC Oscillator (RC120M)
• Four 32-bit general-purpose backup registers
14.2 Overview
The System Control Interface (SCIF) controls the oscillators, Generic Clocks, BODs, Bandgap,
VREG, Temperature Sensor, and Backup Registers.
14.3 I/O Lines Description
14.4 Product Dependencies
In order to use this module, other parts of the system must be configured correctly, as described
below.
Table 14-1. I/O Lines Description
Pin Name Pin Description Type
RC32OUT RC32 output at startup Output
XIN0 Crystal 0 Input Analog/Digital
XIN32 Crystal 32 Input (primary location) Analog/Digital
XIN32_2 Crystal 32 Input (secondary location) Analog/Digital
XOUT0 Crystal 0 Output Analog
XOUT32 Crystal 32 Output (primary location) Analog
XOUT32_2 Crystal 32 Output (secondary location) Analog
GCLK9-GCLK0 Generic Clock Output Output
GCLK_IN2-GCLK_IN0 Generic Clock Input Input
245
32142D–06/2013
ATUC64/128/256L3/4U
14.4.1 I/O Lines
The SCIF provides a number of generic clock outputs, which can be connected to output pins,
multiplexed with GPIO lines. The programmer must first program the GPIO controller to assign
these pins to their peripheral function. If the I/O pins of the SCIF are not used by the application,
they can be used for other purposes by the GPIO controller. Oscillator pins are also multiplexed
with GPIO. When oscillators are used, the related pins are controlled directly by the SCIF, overriding
GPIO settings.
RC32OUT will be output after reset, and the GPIO controller can assign this pin to other peripheral
function after start-up.
14.4.2 Power Management
The BODs and all the oscillators, except the 32KHz oscillator (OSC32K) are turned off in some
sleep modes and turned automatically on when the device wakes up. The Voltage Regulator is
set in low power mode in some sleep modes and automatically set back in normal mode when
the device wakes up. Please refer to the Power Manager chapter for details.
The BOD control registers will not be reset by the Power Manager on a BOD reset.
14.4.3 Clocks
The SCIF controls all oscillators in the device. The oscillators can be used as source for the CPU
and peripherals. Selection of source is done in the Power Manager. The oscillators can also be
used as source for generic clocks.
14.4.4 Interrupts
The SCIF interrupt request line is connected to the interrupt controller. Using the SCIF interrupt
requires the interrupt controller to be programmed first.
14.4.5 Debug Operation
The SCIF does not interact with debug operations.
14.5 Functional Description
14.5.1 Oscillator (OSC) Operation
Rev: 1.1.1.0
The main oscillator (OSCn) is designed to be used with an external 0.450 to 16MHz crystal and
two biasing capacitors, as shown in the Electrical Characteristics chapter, or with an external
clock connected to the XIN. The oscillator can be used as source for the main clock in the
device, as described in the Power Manager chapter. The oscillator can be used as source for the
generic clocks, as described in the Generic Clocks section.
The oscillator is disabled by default after reset. When the oscillator is disabled, the XIN and
XOUT pins can be used as general purpose I/Os. When the oscillator is enabled, the XIN and
XOUT pins are controlled directly by the SCIF, overriding GPIO settings. When the oscillator is
configured to use an external clock, the clock must be applied to the XIN pin while the XOUT pin
can be used as general purpose I/O.
The oscillator is enabled by writing a one to the Oscillator Enable bit in the Oscillator Control register
(OSCCTRLn.OSCEN). Operation mode (external clock or crystal) is selected by writing to
the Oscillator Mode bit in OSCCTRLn (OSCCTRLn.MODE). The oscillator is automatically dis-
246
32142D–06/2013
ATUC64/128/256L3/4U
abled in certain sleep modes to reduce power consumption, as described in the Power Manager
chapter.
After a hard reset, or when waking up from a sleep mode where the oscillators were disabled,
the oscillator will need a certain amount of time to stabilize on the correct frequency. This startup
time can be set in the OSCCTRLn register.
The SCIF masks the oscillator outputs during the start-up time, to ensure that no unstable clocks
propagate to the digital logic.
The OSCn Ready bit in the Power and Clock Status Register (PCLKSR.OSCnRDY) is set when
the oscillator is stable and ready to be used as clock source. An interrupt can be generated on a
zero-to-one transition on OSCnRDY if the OSCnRDY bit in the Interrupt Mask Register
(IMR.OSCnRDY) is set. This bit is set by writing a one to the corresponding bit in the Interrupt
Enable Register (IER.OSCnRDY).
14.5.2 32KHz Oscillator (OSC32K) Operation
Rev: 1.1.0.1
The 32KHz oscillator operates as described for the oscillator above. The 32KHz oscillator can
be used as source clock for the Asynchronous Timer (AST) and the Watchdog Timer (WDT).
The 32KHz oscillator can also be used as source for the generic clocks.
The oscillator is disabled by default after reset. When the oscillator is disabled, the XIN32 and
XOUT32 pins can be used as general-purpose I/Os. When the oscillator is enabled, the XIN32
and XOUT32 pins are controlled directly by the SCIF, overriding GPIO settings. When the oscillator
is configured to use an external clock, the clock must be applied to the XIN32 pin while the
XOUT32 pin can be used as general-purpose I/O.
The oscillator is enabled writing a one to the OSC32 Enable bit in the 32KHz Oscillator Control
Register (OSCCTRL32OSC32EN). The oscillator is disabled by writing a zero to the OSC32EN
bit, while keeping the other bits unchanged. Writing to OSC32EN while also writing to other bits
may result in unpredictable behavior. Operation mode (external clock or crystal) is selected by
writing to the Oscillator Mode bit in OSCCTRL32 (OSCCTRL32.MODE). The oscillator is an
ultra-low-power design and remains enabled in all sleep modes.
The start-up time of the 32KHz oscillator is selected by writing to the Oscillator Start-up Time
field in the OSCCTRL32 register (OSCCTRL32.STARTUP). The SCIF masks the oscillator output
during the start-up time, to ensure that no unstable clock cycles propagate to the digital logic.
The OSC32 Ready bit in the Power and Clock Status Register (PCLKSR.OSC32RDY) is set
when the oscillator is stable and ready to be used as clock source. An interrupt can be generated
on a zero-to-one transition on PCLKSR.OSC32RDY if the OSC32RDY bit in the Interrupt
Mask Register (IMR.OSC32RDY) is set. This bit is set by writing a one to the corresponding bit
in the Interrupt Enable Register (IER.OSC32RDY).
.As a crystal oscillator usually requires a very long start-up time (up to 1 second), the 32KHz
oscillator will keep running across resets, except a Power-on Reset (POR).
The 32KHz oscillator also has a 1KHz output. This is enabled by writing a one to the Enable
1KHz output bit in OSCCTRL32 register (OSCCTRL32.EN1K). If the 32KHz output clock is not
needed when 1K is enabled, this can be disabled by writing a zero to the Enable 32KHz output
bit in the OSCCTRL32 register (OSCCTRL32.EN32K). OSCCTRL32.EN32K is set after a POR.
The 32KHz oscillator has two possible sets of pins. To select between them write to the Pin
Select bit in the OSCCTRL32 register (OSCCTRL32.PINSEL). If the 32KHz oscillator is to be
247
32142D–06/2013
ATUC64/128/256L3/4U
used in Shutdown mode, PINSEL must be written to one, and XIN32_2 and XOUT32_2 must be
used.
14.5.3 PLL Operation
Rev: 1.1.0.0
The device contains one Phase Locked Loop (PLL), which is controlled by the Phase Locked
Loop Interface (PLLIF). The PLL is disabled by default, but can be enabled to provide high frequency
source clocks for synchronous or generic clocks. The PLL can use different clock
sources as reference clock, please refer to the “PLL Clock Sources” table in the SCIF Module
Configuration section for details. The PLL output is divided by a multiplication factor, and the
PLL compares the phase of the resulting clock to the reference clock. The PLL will adjust its output
frequency until the two compared clocks phases are equal, thus locking the output frequency
to a multiple of the reference clock frequency.
When the PLL is switched on, or when changing the clock source or multiplication factor for the
PLL, the PLL is unlocked and the output frequency is undefined. The PLL clock for the digital
logic is automatically masked when the PLL is unlocked, to prevent the connected digital logic
from receiving a too high frequency and thus become unstable.
The PLL can be configured by writing the PLL Control Register (PLLn). To prevent unexpected
writes due to software bugs, write access to the PLLn register is protected by a locking mechanism,
for details please refer to the UNLOCK register description.
Figure 14-1. PLL with Control Logic and Filters
14.5.3.1 Enabling the PLL
Before the PLL is enabled it must be set up correctly. The PLL Oscillator Select field (PLLOSC)
selects a source for the reference clock. The PLL Multiply Factor (PLLMUL) and PLL Division
Phase
Detector
Output
Divider
Source
clocks
PLLOSC PLLOPT[0]
PLLMUL
Lock bit
Mask PLL clock
Input
Divider
PLLDIV
1/2
PLLOPT[1]
0
1
VCO
fvco fPLL
Lock
Counter
fREF
248
32142D–06/2013
ATUC64/128/256L3/4U
Factor (PLLDIV) fields must be written with the multiplication and division factors, respectively.
The PLLMUL must always be greater than 1, creating the PLL frequency:
fvco = (PLLMUL+1)/PLLDIV • fREF, if PLLDIV >0
fvco = 2•(PLLMUL+1) • fREF, if PLLDIV = 0
The PLL Options (PLLOPT) field should be configured to proper values according to the PLL
operating frequency. The PLLOPT field can also be configured to divide the output frequency of
the PLL by 2 and Wide-Bandwidth mode, which allows faster startup time and out-of-lock time.
It is not possible to change any of the PLL configuration bits when the PLL is enabled, Any write
to PLLn while the PLL is enabled will be discarded.
After setting up the PLL, the PLL is enabled by writing a one to the PLL Enable (PLLEN) bit in
the PLLn register.
14.5.3.2 Disabling the PLL
The PLL is disabled by writing a zero to the PLL Enable (PLLEN) bit in the PLLn register. After
disabling the PLL, the PLL configuration fields becomes writable.
14.5.3.3 PLL Lock
The lock signal for each PLL is available as a PLLLOCKn flag in the PCLKSR register. If the lock
for some reason is lost, the PLLLOCKLOSTn flag in PCLKSR register will be set. An interrupt
can be generated on a 0 to 1 transition of these bits.
14.5.4 Digital Frequency Locked Loop (DFLL) Operation
Rev: 2.1.0.1
The DFLL is controlled by the Digital Frequency Locked Loop Interface (DFLLIF). The DFLL is
disabled by default, but can be enabled to provide a high-frequency source clock for synchronous
and generic clocks.
Features:
• Internal oscillator with no external components
• 20-150MHz frequency in closed loop mode
• Can operate standalone as a high-frequency programmable oscillator in open loop mode
• Can operate as an accurate frequency multiplier against a known frequency in closed loop
mode
• Optional spread-spectrum clock generation
• Very high-frequency multiplication supported - can generate all frequencies from a 32KHz
clock
The DFLL can operate in both open loop mode and closed loop mode. In closed loop mode a
low frequency clock with high accuracy can be used as reference clock to get high accuracy on
the output clock (CLK_DFLL).
To prevent unexpected writes due to software bugs, write access to the configuration registers is
protected by a locking mechanism. For details please refer to the UNLOCK register description.
249
32142D–06/2013
ATUC64/128/256L3/4U
Figure 14-2. DFLLIF Block Diagram
14.5.4.1 Enabling the DFLL
The DFLL is enabled by writing a one to the Enable bit (EN) in the DFLLn Configuration Register
(DFLLnCONF). No other bits or fields in DFLLnCONF must be changed simultaneously, or
before the DFLL is enabled.
14.5.4.2 Internal synchronization
Due to multiple clock domains in the DFLLIF, values in the DFLLIF configuration registers need
to be synchronized to other clock domains. The status of this synchronization can be read from
the Power and Clocks Status Register (PCLKSR). Before writing to a DFLLIF configuration register,
the user must check that the DFLLn Synchronization Ready bit (DFLLnRDY) in PCLKSR is
set. When this bit is set, the DFLL can be configured, and CLK_DFLL is ready to be used. Any
write to a DFLLIF configuration register while DFLLnRDY is cleared will be ignored.
Before reading the value in any of the DFLL configuration registers a one must be written to the
Synchronization bit (SYNC) in the DFLLn Synchronization Register (DFLLnSYNC). The DFLL
configuration registers are ready to be read when PCLKSR.DFLLnRDY is set.
14.5.4.3 Disabling the DFLL
The DFLL is disabled by writing a zero to DFLLnCONF.EN. No other bits or fields in DFLLnCONF
must be changed simultaneously.
After disabling the DFLL, PCLKSR.DFLLnRDY will not be set. It is not required to wait for
PCLKSR.DFLLnRDY to be set before re-enabling the DFLL.
14.5.4.4 Open loop operation
After enabling the DFLL, open loop mode is selected by writing a zero to the Mode Selection bit
(MODE) in DFLLnCONF. When operating in open loop mode the output frequency of the DFLL
will be determined by the values written to the Coarse Calibration Value field (COARSE) and the
Fine Calibration Value field (FINE) in the DFLLnCONF register. When writing to COARSE and
DFLL
COARSE
FINE
8
9
CLK_DFLL
IMUL
FMUL 32
CLK_DFLLIF_REF
FREQUENCY
TUNER
DFLLLOCKC
DFLLLOCKLOSTC
DFLLLOCKF
DFLLLOCKLOSTF
DFLLLOCKA
DFLLLOCKLOSTA
CSTEP
FSTEP 8+9 CLK_DFLLIF_DITHER
250
32142D–06/2013
ATUC64/128/256L3/4U
FINE, be aware that the output frequency must not exceed the maximum frequency of the
device after the division in the clock generator. It is possible to change the value of COARSE
and FINE, and thereby the output frequency of the DFLL, while the DFLL is enabled and in use.
The DFLL clock is ready to be used when PCLKSR.DFLLnRDY is cleared after enabling the
DFLL.
The frequency range in open loop mode is 20-150MHz, but maximum frequency can be higher,
and the minimum frequency can be lower. The best way to start the DFLL at a specific frequency
in open loop mode is to first configure it for closed loop mode, see Section 14.5.4.5. When a lock
is achieved, read back the COARSE and FINE values and switch to open loop mode using these
values. An alternative approach is to use the Frequency Meter (FREQM) to monitor the DFLL
frequency and adjust the COARSE and FINE values based on measurement results form the
FREQM. Please refer to the FREQM chapter for more information on how to use it. Note that the
output frequency of the DFLL will drift when in open loop mode due to temperature and voltage
changes. Please refer to the Electrical Characteristics chapter for details.
14.5.4.5 Closed loop operation
The DFLL must be correctly configured before closed loop operation can be enabled. After
enabling the DFLL, enable and select a reference clock (CLK_DFLLIF_REF).
CLK_DFLLIF_REF is a generic clock, please refer to Generic Clocks section for details. Then
set the maximum step size allowed in finding the COARSE and FINE values by setting the
Coarse Maximum Step field (CSTEP) and Fine Maximum Step field (FSTEP) in the DFLLn Maximum
Step Register (DFLLnSTEP). A small step size will ensure low overshoot on the output
frequency, but can typically result in longer lock times. A high value might give a big overshoot,
but can typically give faster locking. DFLLnSTEP.CSTEP and DFLLnSTEP.FSTEP must be
lower than 50% of the maximum value of DFLLnCONF.COARSE and DFLLnCONF.FINE
respectively. Then select the multiplication factor in the Integer Multiply Factor field (IMUL) and
the Fractional Multiply field (FMUL) in the DFLLn Multiplier Register (DFLLnMUL). Care must be
taken when choosing IMUL and FMUL so the output frequency does not exceed the maximum
frequency of the device. Start the closed loop mode by writing a one to DFLLnCONF.MODE bit.
The frequency of CLK_DFLL (fDFLL) is given by:
where fREF is the frequency of CLK_DFLLIF_REF. COARSE and FINE in DFLLnCONF are readonly
in closed loop mode, and are controlled by the DFLLIF to meet user specified frequency.
The values in COARSE when the closed loop mode is enabled is used by the frequency tuner as
a starting point for COARSE. Setting COARSE to a value close to the final value will reduce the
time needed to get a lock on COARSE.
Frequency locking
The locking of the frequency in closed loop mode is divided into three stages. In the COARSE
stage the control logic quickly finds the correct value for DFLLnCONF.COARSE and thereby
sets the output frequency to a value close to the correct frequency. The DFLLn Locked on
Coarse Value bit (DFLLnLOCKC) in PCLKSR will be set when this is done. In the FINE stage the
control logic tunes the value in DFLLnCONF.FINE so the output frequency will be very close to
the desired frequency. DFLLn Locked on Fine Value bit (DFLLnLOCKF) in PCLKSR will be set
when this is done. In the ACCURATE stage the DFLL frequency tuning mechanism uses dithering
on the FINE bits to obtain an accurate average output frequency. DFLLn Locked on Accurate
Value bit (DFLLnLOCKA) in PCLKSR will be set when this is done. The ACCURATE stage will
f
DFLL IMUL FMUL
216
+ ----------------- f
REF =
251
32142D–06/2013
ATUC64/128/256L3/4U
only be executed if the Dithering Enable bit (DITHER) in DFLLnCONF has been written to a one.
If DITHER is written to a zero DFLLnLOCKA will never occur. If dithering is enabled, the frequency
of the dithering is decided by a generic clock (CLK_DFLLIF_DITHER). This clock has to
be set up correctly before enabling dithering. Please refer to the Generic Clocks section for
details.
Figure 14-3. DFLL Closed loop State Diagram
When dithering is enabled the accuracy of the average output frequency of the DFLL will be
higher. However, the actual frequency will be alternating between two frequencies. If a fixed frequency
is required, the dithering should not be enabled.
Figure 14-4. DFLL Locking in Closed loop
CLK_DFLL is ready to be used when the DFLLn Synchronization Ready bit (DFLLnRDY) in
PCLKSR is set after enabling the DFLL. However, the accuracy of the output frequency depends
on which locks are set.
For lock times, please refer to the Electrical Characteristics chapter.
Measure
fDFLLn
Calculate
new
COARSE
value
DFLLnLOCKC
0
Calculate
new FINE
value
DFLLnLOCKF
0
1 1 DFLLnLOCKA
Calculate
new
dithering
dutycycle
0
Compensate
for
drift
1 DITHER 1
Compensate
for
drift
0
Initial
frequency
Target
frequency
DFLLnLOCKC DFLLnLOCKF DFLLnLOCKA
252
32142D–06/2013
ATUC64/128/256L3/4U
Drift compensation
The frequency tuner will automatically compensate for drift in the fDFLL without losing either of the
locks. If the FINE value overflows or underflows, which should normally not happen, but could
occur due to large drift in temperature and voltage, all locks will be lost, and the COARSE and
FINE values will be recalibrated as described earlier. If any lock is lost the corresponding bit in
PCLKSR will be set, DFLLn Lock Lost on Coarse Value bit (DFLLnLOCKLOSTC) for lock lost on
COARSE value, DFLLn Lock Lost on Fine Value bit (DFLLnLOCKLOSTF) for lock lost on FINE
value and DFLLn Lock Lost on Accurate Value bit (DFLLnLOCKLOSTA) for lock lost on ACCURATE
value. The corresponding lock status bit will be cleared when the lock lost bit is set, and
vice versa.
Reference clock stop detection
If CLK_DFLLIF_REF stops or is running at a very slow frequency, the DFLLn Reference Clock
Stopped bit (DFLLnRCS) in PCLKSR will be set. Note that the detection of the clock stop will
take a long time. The DFLLIF operate as if it was in open loop mode if it detects that the reference
clock has stopped. This means that the COARSE and FINE values will be kept constant
while PCLKSR.DFLLnRCS is set. Closed loop mode operation will automatically resume if the
CLK_DFLLIF_REF is restarted, and compensate for any drift during the time CLK_DFLLIF_REF
was stopped. No locks will be lost.
Frequency error measurement
The ratio between CLK_DFLLIF_REF and CLK_DFLL is measured automatically by the DFLLIF.
The difference between this ratio and DFLLnMUL is stored in the Multiplication Ratio Difference
field (RATIODIFF) in the DFLLn Ratio Register (DFLLnRATIO). The relative error on CLK_DFLL
compared to the target frequency can be calculated as follows:
where is the number of reference clock cycles the DFLLIF is using for calculating the
ratio.
14.5.4.6 Dealing with delay in the DFLL
The time from selecting a new frequency until this frequency is output by the DFLL, can be up to
several micro seconds. If the difference between the desired output frequency (CLK_DFLL) and
the frequency of CLK_DFLLIF_REF is small this can lead to an instability in the DFLLIF locking
mechanism, which can prevent the DFLLIF from achieving locks. To avoid this, a chill cycle
where the CLK_DFLL frequency is not measured can be enabled. The chill cycle is enabled by
writing a one to the Chill Cycle Enable (CCEN) bit in the DFLLnCONF register. Enabling chill
cycles might double the lock time,
Another solution to the same problem can be to use less strict lock requirements. This is called
Quick Lock (QL), which is enabled by writing a one to the Quick Lock Enable (QLEN) bit in the
DFLLnCONF register. The QL might lead to bigger spread in the outputted frequency than chill
cycles, but the average output frequency is the same.
If the target frequency is below 40MHz, one of these methods should always be used.
14.5.4.7 Spread Spectrum Generator (SSG)
When the DFLL is used as the main clock source for the device, the EMI radiated from the
device will be synchronous to fDFLL. To provide better Electromagnetic Compatibility (EMC) the
error RATIODIFF fREF
2NUMREF f
DFLL = ------------------------------------------------
2NUMREF
253
32142D–06/2013
ATUC64/128/256L3/4U
DFLLIF can provide a clock with the energy spread in the frequency domain. This is done by
adding or subtracting values from the FINE value. SSG is enabled by writing a one to the Enable
bit (EN) in the DFLLn Spread Spectrum Generator Control Register (DFLLnSSG).
A generic clock sets the rate at which the SSG changes the frequency of the DFLL clock to generate
a spread spectrum (CLK_DFLLIF_DITHER). This is the same clock used by the dithering
mechanism. The frequency of this clock should be higher than fREF to ensure that the DFLLIF
can lock. Please refer to the Generic clocks section for details.
Optionally, the clock ticks can be qualified by a Pseudo Random Binary Sequence (PRBS) if the
PRBS bit in DFLLnSSG is one. This reduces the modulation effect of CLK_DFLLIF_DITHER frequency
onto fDFLL.
The amplitude of the frequency variation can be selected by setting the SSG Amplitude field
(AMPLITUDE) in DFLLnSSG. If AMPLITUDE is zero the SSG will toggle on the LSB of the FINE
value. If AMPLITUDE is one the SSG will add the sequence {1,-1, 0} to FINE.
The step size of the SSG is selected by writing to the SSG Step Size field (STEPSIZE) in
DFLLnSSG. STEPSIZE equal to zero or one will result in a step size equal to one. If the step
size is set to n, the output value from the SSG will be incremented/decremented by n on every
tick of the source clock.
The Spread Spectrum Generator is available in both open and closed loop mode.
When spread spectrum is enabled in closed loop mode, and the AMPLITUDE is high, an overflow/underflow
in FINE is more likely to occur.
Figure 14-5. Spread Spectrum Generator Block Diagram.
14.5.4.8 Wake from sleep modes
The DFLLIF may optionally reset its lock bits when waking from a sleep mode which disables the
DFLL. This is configured by the Lose Lock After Wake (LLAW) bit in DFLLnCONF register. If
DFLLnCONF.LLAW is written to zero the DFLL will be re-enabled and start running with the
same configuration as before going to sleep even if the reference clock is not available. The
locks will not be lost. When the reference clock has restarted, the FINE tracking will quickly compensate
for any frequency drift during sleep. If a one is written to DFLLnCONF.LLAW before
going to a sleep mode where the DFLL is turned off, the DFLLIF will lose all its locks when waking
up, and needs to regain these through the full lock sequence.
14.5.4.9 Accuracy
There are mainly three factors that decide the accuracy of the fDFLL. These can be tuned to
obtain maximum accuracy when fine lock is achieved.
Pseudorandom
Binary Sequence Spread Spectrum
Generator
FINE
9
To DFLL CLK_DFLLIF_DITHER
AMPLITUDE,
STEPSIZE PRBS
1
0
254
32142D–06/2013
ATUC64/128/256L3/4U
• FINE resolution: The frequency step between two FINE values. This is relatively smaller for
high output frequencies.
• Resolution of the measurement: If the resolution of the measured fDFLL is low, i.e. the ratio
between CLK_DFLL frequency and CLK_DFLLIF_REF is small, then the DFLLIF might lock
at a frequency that is lower than the targeted frequency. It is recommended to use a
reference clock frequency of 32 KHz or lower to avoid this issue for low target frequencies.
• The accuracy of the reference clock.
14.5.4.10 Interrupts
A interrupt can be generated on a zero-to-one transaction on DFLLnLOCKC, DFLLnLOCKF,
DFLLnLOCKA, DFLLnLOCKLOSTC, DFLLnLOCKLOSTF, DFLLnLOCKLOSTA, DFLLnRDY or
DFLLnRCS.
14.5.5 Brown-Out Detection (BOD)
Rev: 1.2.0.0
The Brown-Out Detector monitors the VDDCORE supply pin and compares the supply voltage
to the brown-out detection level.
The BOD is disabled by default, and is enabled by writing to the BOD Control field in the BOD
Control Register (BOD.CTRL). This field can also be updated by flash fuses.
The BOD is powered by VDDIO and will not be powered during Shutdown sleep mode.
To prevent unexpected writes to the BOD register due to software bugs, write access to this register
is protected by a locking mechanism. For details please refer to the UNLOCK register
description.
To prevent further modifications by software, the content of the BOD register can be set as readonly
by writing a one to the Store Final Value bit (BOD.SFV). When this bit is one, software can
not change the BOD register content. This bit is cleared after flash calibration and after a reset
except after a BOD reset.
The brown-out detection level is selected by writing to the BOD Level field in BOD
(BOD.LEVEL). Please refer to the Electrical Characteristics chapter for parametric details.
If the BOD is enabled (BOD.CTRL is one or two) and the supply voltage goes below the detection
level, the Brown-Out Detection bit in the Power and Clocks Status Register
(PCLKSR.BODDET) is set. This bit is cleared when the supply voltage goes above the detection
level. An interrupt request will be generated on a zero-to-one transition on PCLKSR.BODDET if
the Brown-Out Detection bit in the Interrupt Mask Register (IMR.BODDET) is set. This bit is set
by writing a one to the corresponding bit in the Interrupt Enable Register (IER.BODDET).
If BOD.CTRL is one, a BOD reset will be generated when the supply voltage goes below the
detection level. If BOD.CTRL is two, the device will not be reset.
Writing a one to the BOD Hysteresis bit in BOD (BOD.HYST) will add a hysteresis on the BOD
detection level.
Note that the BOD must be disabled before changing BOD.LEVEL, to avoid spurious reset or
interrupt. After enabling the BOD, the BOD output will be masked during one half of a RCSYS
clock cycle and two main clocks cycles to avoid false results.
When the JTAG or aWire is enabled, the BOD reset and interrupt are masked.
255
32142D–06/2013
ATUC64/128/256L3/4U
The CTRL, HYST, and LEVEL fields in the BOD Control Register are loaded factory defined calibration
values from flash fuses after a reset. If the Flash Calibration Done bit in the BOD Control
Register (BOD.FCD) is zero, the flash calibration will be redone after any reset, and the
BOD.FCD bit will be set before program execution starts in the CPU. If BOD.FCD is one, the
flash calibration is redone after any reset except for a BOD reset. The BOD.FCD bit is cleared
after a reset, except for a BOD reset. BOD.FCD is set when these fields have been updated after
a flash calibration. It is possible to override the values in the BOD.CTRL, BOD.HYST, and
BOD.LEVEL fields after reset by writing to the BOD Control Register. Please refer to the Fuse
Settings chapter for more details about BOD fuses and how to program the fuses.
Figure 14-6. BOD Block Diagram
14.5.6 Bandgap
Rev: 1.2.0.0
The flash memory, the BOD, and the Temperature Sensor need a stable voltage reference to
operate. This reference voltage is provided by an internal Bandgap voltage reference. This reference
is automatically turned on at start-up and turned off during some sleep modes to save
power. The Bandgap reference is powered by the internal regulator supply voltage and will not
be powered during Shutdown sleep mode. Please refer to the Power Manager chapter for
details.
VDDCORE
POR18 BOD
SCIF
POWER MANAGER(PM) INTC
Reset
Bod
Detected
Enable
BO
D Hyst
BOD
Level
Reset
In et rrupt
256
32142D–06/2013
ATUC64/128/256L3/4U
14.5.7 System RC Oscillator (RCSYS)
Rev: 1.1.1.0
The system RC oscillator has a startup time of three cycles, and is always available except in
some sleep modes. Please refer to the Power Manager chapter for details. The system RC oscillator
operates at a nominal frequency of 115kHz, and is calibrated using the Calibration Value
field (CALIB) in the RC Oscillator Calibration Register (RCCR). After a Power-on Reset (POR),
the RCCR.CALIB field is loaded with a factory defined value stored in the Flash fuses. Please
refer to the Fuse setting chapter for more details about RCCR fuses and how to program the
fuses.
If the Flash Calibration Done (FCD) bit in the RCCR is zero at any reset, the flash calibration will
be redone and the RCCR.FCD bit will be set before program execution starts in the CPU. If the
RCCR.FCD is one, the flash calibration will only be redone after a Power-on Reset.
To prevent unexpected writes to RCCR due to software bugs, write access to this register is protected
by a locking mechanism. For details please refer to the UNLOCK register description.
Although it is not recommended to override default factory settings, it is still possible to override
the default values by writing to RCCR.CALIB.
14.5.8 Voltage Regulator (VREG)
Rev: 1.1.0.0
The embedded voltage regulator can be used to provide the VDDCORE voltage from the internal
regulator supply voltage. It is controlled by the Voltage Regulator Calibration Register
(VREGCR). The voltage regulator is enabled by default at start-up but can be disabled by software
if an external voltage is provided on the VDDCORE pin. The VREGCR also contains bits to
control the POR18 detector and the POR33 detector.
14.5.8.1 Register protection
To prevent unexpected writes to VREGCR due to software bugs, write access to this register is
protected by a locking mechanism. For details please refer to the UNLOCK register description.
To prevent further modifications by software, the content of the VREGCR register can be set as
read-only by writing a one to the Store Final Value bit (VREGCR.SFV). Once this bit is set, software
can not change the VREGCR content until a Power-on Reset (POR) is applied.
14.5.8.2 Controlling voltage regulator output
The voltage regulator is always enabled at start-up, i.e. after a POR or when waking up from
Shutdown mode. It can be disabled by software by writing a zero to the Enable bit
(VREGCR.EN). This bit is set after a POR. Because of internal synchronization, the voltage regulator
is not immediately enabled or disabled. The actual state of the voltage regulator can be
read from the ON bit (VREGCR.ON).
The voltage regulator output level is controlled by the Select VDD field (SELVDD) in VREGCR.
The default value of this field corresponds to a regulator output voltage of 1.8V. Other values of
this field are not defined, and it is not recommended to change the value of this field.
The Voltage Regulator OK bit (VREGCR.VREGOK) bit indicates when the voltage regulator output
has reached the voltage threshold level.
257
32142D–06/2013
ATUC64/128/256L3/4U
14.5.8.3 Factory calibration
After a Power-on Reset (POR) the VREGCR.CALIB field is loaded with a factory defined calibration
value. This value is chosen so that the normal output voltage of the regulator after a powerup
is 1.8V.
Although it is not recommended to override default factory settings, it is still possible to override
these default values by writing to VREGCR.CALIB.
If the Flash Calibration Done bit in VREGCR (VREGCR.FCD) is zero, the flash calibration will be
redone after any reset, and the VREGCR.FCD bit will be set before program execution starts in
the CPU. If VREGCR.FCD is one, the flash calibration will only be redone after a POR.
14.5.8.4 POR33 control
VREGCR includes control bits for the Power-on Reset 3.3V (POR33) detector that monitors the
internal regulator supply voltage. The POR33 detector is enabled by default but can be disabled
by software to reduce power consumption. The 3.3V Supply Monitor (SM33) can then be used to
monitor the regulator power supply.
The POR33 detector is disabled by writing a zero to the POR33 Enable bit
(VREGCR.POR33EN). Because of internal synchronisation, the POR33 detector is not immediately
enabled or disabled. The actual state of the POR33 detector can be read from the POR33
Status bit (VREGCR.POR33STATUS).
The 32kHz RC oscillator (RC32K) must be enabled before disabling the POR33 detector. Once
the POR33 detector has been disabled, the RC32K oscillator can be disabled again.
To avoid spurious resets, it is mandatory to mask the Power-on Reset when enabling or disabling
the POR33 detector. The Power-on Reset generated by the POR33 detector can be
ignored by writing a one to the POR33 Mask bit (VREGCR.POR33MASK). Because of internal
synchronization, the masking is not immediately effective, so software should wait for the
VREGCR.POR33MASK to read as a one before assuming the masking is effective.
The output of the POR33 detector is zero if the internal regulator supply voltage is below the
POR33 power-on threshold level, and one if the internal regulator supply voltage is above the
POR33 power-on threshold level. This output (before masking) can be read from the POR33
Value bit (VREGCR.POR33VALUE).
14.5.8.5 POR18 control
VREGCR includes control bits for the Power-on Reset 1.8V (POR18) detector that monitors the
VDDCORE voltage. The POR18 detector is enabled by default but can be disabled by software
to reduce power consumption.
The POR18 detector is disabled by writing a zero to the POR18 Enable bit
(VREGCR.POR18EN). Because of internal synchronization, the POR18 detector is not immediately
enabled or disabled. The actual state of the POR18 detector can be read from the POR18
Status bit (VREGCR.POR18STATUS).
Please note that the POR18 detector cannot be disabled while the JTAG or aWire debug interface
is used. Writing a zero to VREGCR.POR18EN bit will have no effect.
To avoid spurious resets, it is mandatory to mask the Power-on Reset when enabling or disabling
the POR18 detector. The Power-on Reset generated by the POR18 detector can be
ignored by writing a one to the POR18 Mask bit (VREGCR.POR18MASK). Because of internal
258
32142D–06/2013
ATUC64/128/256L3/4U
synchronisation, the masking is not immediately effective, so software should wait for the
VREGCR.POR18MASK to read as one before assuming the masking is effective.
The output of the POR18 detector is zero if the VDDCORE voltage is below the POR18 poweron
threshold level, and one if the VDDCORE voltage is above the POR18 power-on threshold
level. The output of the POR18 detector (before masking) can be read from the POR18 Value bit
(VREGCR.POR18VALUE).
14.5.9 3.3 V Supply Monitor (SM33)
Rev: 1.1.0.0
The 3.3V supply monitor is a specific voltage detector for the internal regulator supply voltage. It
will indicate if the internal regulator supply voltage is above the minimum required input voltage
threshold. The user can choose to generate either a Power-on Reset (POR) and an interrupt
request, or only an interrupt request, when the internal regulator supply voltage drops below this
threshold.
Please refer to the Electrical Characteristics chapter for parametric details.
14.5.9.1 Register protection
To prevent unexpected writes to SM33 register due to software bugs, write access to this register
is protected by a locking mechanism. For details please refer to the UNLOCK register
description.
To prevent further modifications by software, the content of the register can be set as read-only
by writing a one to the Store Final Value bit (SM33.SFV). When this bit is one, software can not
change the SM33 register content until the device is reset.
14.5.9.2 Operating modes
The SM33 is disabled by default and is enabled by writing to the Supply Monitor Control field in
the SM33 control register (SM33.CTRL). The current state of the SM33 can be read from the
Supply Monitor On Indicator bit in SM33 (SM33.ONSM). Enabling the SM33 will disable the
POR33 detector.
The SM33 can operate in continuous mode or in sampling mode. In sampling mode, the SM33 is
periodically enabled for a short period of time, just enough to make a a measurement, and then
disabled for a longer time to reduce power consumption.
By default, the SM33 operates in sampling mode during DeepStop and Static mode and in continuous
mode for other sleep modes. Sampling mode can also be forced during sleep modes
other than DeepStop and Static, and during normal operation, by writing a one to the Force
Sampling Mode bit in the SM33 register (SM33.FS).
The user can select the sampling frequency by writing to the Sampling Frequency field in SM33
(SM33.SAMPFREQ). The sampling mode uses the 32kHz RC oscillator (RC32K) as clock
source. The 32kHz RC oscillator is automatically enabled when the SM33 operates in sampling
mode.
14.5.9.3 Interrupt and reset generation
If the SM33 is enabled (SM33.CTRL is one or two) and the regulator supply voltage drops below
the SM33 threshold, the SM33DET bit in the Power and Clocks Status Register
(PCLKSR.SM33DET) is set. This bit is cleared when the supply voltage goes above the threshold.
An interrupt request is generated on a zer-to-one transition of PCLKSR.SM33DET if the
259
32142D–06/2013
ATUC64/128/256L3/4U
Supply Monitor 3.3V Detection bit in the Interrupt Mask Register (IMR.SM33DET) is set. This bit
is set by writing a one to the corresponding bit in the Interrupt Enable Register (IER.SM33DET).
If SM33.CTRL is one, a POR will be generated when the voltage drops below the threshold. If
SM33.CTRL is two, the device will not be reset.
14.5.9.4 Factory calibration
After a reset the SM33.CALIB field is loaded with a factory defined value. This value is chosen
so that the nominal threshold value is 1.75V. The flash calibration is redone after any reset, and
the Flash Calibration Done bit in SM33 (SM33.FCD) is set before program execution starts in the
CPU.
Although it is not recommended to override default factory settings, it is still possible to override
the default value by writing to SM33.CALIB
14.5.10 Temperature Sensor
Rev: 1.0.0.0
The Temperature Sensor is connected to an ADC channel, please refer to the ADC chapter for
details. It is enabled by writing one to the Enable bit (EN) in the Temperature Sensor Configuration
Register (TSENS). The Temperature Sensor can not be calibrated.
Please refer to the Electrical Characteristics chapter for more details.
14.5.11 120MHz RC Oscillator (RC120M)
Rev: 1.1.0.0
The 120MHz RC Oscillator can be used as source for the main clock in the device, as described
in the Power Manager chapter. The oscillator can also be used as source for the generic clocks,
as described in Generic Clock section. The RC120M must be enabled before it is used as a
source clock. To enable the clock, the user must write a one to the Enable bit in the 120MHz RC
Oscillator Control Register (RC120MCR.EN), and read back the RC120MCR register until the
EN bit reads one. The clock is disabled by writing a zero to RC120MCR.EN. The EN bit must be
read back as zero before the RC120M is re-enabled. If not, undefined behavior may occur.
The oscillator is automatically disabled in certain sleep modes to reduce power consumption, as
described in the Power Manager chapter.
14.5.12 Backup Registers (BR)
Rev: 1.0.0.1
Four 32-bit backup registers are available to store values when the device is in Shutdown
mode. These registers will keep their content even when the VDDCORE supply and the internal
regulator supply voltage supplies are removed. The backup registers can be accessed by reading
from and writing to the BR0, BR1, BR2, and BR3 registers.
After writing to one of the backup registers the user must wait until the Backup Register Interface
Ready bit in tne Power and Clocks Status Register (PCLKSR.BRIFARDY) is set before writing to
another backup register. Writes to the backup register while PCLKSR.BRIFARDY is zero will be
discarded. An interrupt can be generated on a zero-to-one transition on PCLKSR.BRIFARDY if
260
32142D–06/2013
ATUC64/128/256L3/4U
the BRIFARDY bit in the Interrupt Mask Register (IMR.BRIFARDY) is set. This bit is set by writing
a one to the corresponding bit in the Interrupt Enable Register (IER.BRIFARDY).
After powering up the device the Backup Register Interface Valid bit in PCLKSR (PCLKSR.BRIFAVALID)
is cleared, indicating that the content of the backup registers has not been written and
contains the reset value. After writing to one of the backup registers the PCLKSR.BRIFAVALID
bit is set. During writes to the backup registers (when BRIFARDY is zero) BRIFAVALID will be
zero. If a reset occurs when BRIFARDY is zero, BRIFAVALID will be cleared after the reset, indicating
that the content of the backup registers is not valid. If BRIFARDY is one when a reset
occurs, BRIFAVALID will be one and the content is the same as before the reset.
The user must ensure that BRIFAVALID and BRIFARDY are both set before reading the backup
register values.
14.5.13 32kHz RC Oscillator (RC32K)
Rev: 1.1.0.0
The RC32K can be used as source for the generic clocks, as described in The Generic Clocks
section.
The 32kHz RC oscillator (RC32K) is forced on after reset, and output on PA20. The clock is
available on the pad until the PPCR.FRC32 bit in the Power Manager has been cleared or a different
peripheral function has been chosen on PA20 (PA20 will start with peripheral function F
by default). Note that the forcing will only enable the clock output. To be able to use the RC32K
normally the oscillator must be enabled as described below.
The oscillator is enabled by writing a one to the Enable bit in the 32kHz RC Oscillator Configuration
Register (RC32KCR.EN) and disabled by writing a zero to RC32KCR.EN. The oscillator is
also automatically enabled when the sampling mode is requested for the SM33. In this case,
writing a zero to RC32KCR.EN will not disable the RC32K until the sampling mode is no longer
requested.
14.5.14 Generic Clock Prescalers
Rev: 1.0.0.0
The generic clocks can be sourced by two special prescalers to increase the generic clock frequency
precision.
These prescalers are named the High Resolution Prescaler (HRP) and the Fractional Prescaler
(FP).
14.5.14.1 High resolution prescaler
The HRP is a 24-bit counter that can generate a very accurate clock waveform. The clock
obtained has 50% duty cycle.
261
32142D–06/2013
ATUC64/128/256L3/4U
Figure 14-7. High Resolution Prescaler Generation
The HRP is enabled by writing a one to the High Resolution Prescaler Enable (HRPEN) bit in the
High Resolution Prescaler Control Register (HRPCR).
The user can select a clock source for the HRP by writing to the Clock Selection (CKSEL) field of
the HRPCR register.
The user must configure the High Resolution Prescaler Clock (HRPCLK) frequency by writing to
the High Resolution Count (HRCOUNT) field of the High Resolution Counter (HRPCR) register.
This results in the output frequency:
fHRPCLK = fSRC / (2*(HRCOUNT+1))
The CKSEL field can not be changed dynamically but the HRCOUNT field can be changed onthe-fly.
14.5.14.2 Fractional prescaler
The FP generates a clock whose average frequency is more precise than the HRP. However,
this clock frequency is subject to jitter around the target clock frequency. This jitter influence can
be decreased by dividing this clock with the GCLK divider. Moreover the duty cycle of this clock
is not precisely 50%.
Figure 14-8. Fractional Prescaler Generation
The FP is enabled by writing a one to the FPEN bit in the Fractional Prescaler Control Register
(FPCR).
The user can select a clock source for the FP by writing to the CKSEL field of the FPCR register.
Divider
CKSEL
HRPCLK
HRCOUNT
Mask
HRPEN
Divider
CKSEL
FPCLK
FPDIV
Mask
FPMUL FPEN
262
32142D–06/2013
ATUC64/128/256L3/4U
The user must configure the FP frequency by writing to the FPMUL and FPDIV fields of the
FPMUL and FPDIV registers. FPMUL and FPDIV must not be equal to zero and FPDIV must be
greater or equal to FPMUL. This results in the output frequency:
fFPCLK = fSRC * FPMUL/ (2*FPDIV)
The CKSEL field can not be changed dynamically but the FPMUL and FPDIV fields can be
changed on-the-fly.
• Jitter description
As described in Figure 14-9, the CLKFP half period lengths are integer multiples of the source
clock period but are not always equals. However the difference between the low level half period
length and the high level half period length is at the most one source clock period.
This induces when FPDIV is not an integer multiple of FPMUL a jitter on the FPCLK. The more
the FPCLK frequency is low, the more the jitter incidence is reduced.
Figure 14-9. Fractional Prescaler Jitter Examples
14.5.15 Generic Clocks
Rev: 1.1.0.0
Timers, communication modules, and other modules connected to external circuitry may require
specific clock frequencies to operate correctly. The SCIF defines a number of generic clocks that
can provide a wide range of accurate clock frequencies.
Each generic clock runs from either clock source listed in the “Generic Clock Sources” table in
the SCIF Module Configuration section. The selected source can optionally be divided by any
even integer up to 512. Each clock can be independently enabled and disabled, and is also
automatically disabled along with peripheral clocks by the Sleep Controller in the Power
Manager.
SRC clock
FPCLK
FMUL= 5
FDIV=5
FMUL=3
FDIV=10
FMUL=7
FDIV=9
263
32142D–06/2013
ATUC64/128/256L3/4U
Figure 14-10. Generic Clock Generation
14.5.15.1 Enabling a generic clock
A generic clock is enabled by writing a one to the Clock Enable bit (CEN) in the Generic Clock
Control Register (GCCTRL). Each generic clock can individually select a clock source by writing
to the Oscillator Select field (OSCSEL). The source clock can optionally be divided by writing a
one to the Divide Enable bit (DIVEN) and the Division Factor field (DIV), resulting in the output
frequency:
where fSRC is the frequency of the selected source clock, and fGCLK is the output frequency of the
generic clock.
14.5.15.2 Disabling a generic clock
A generic clock is disabled by writing a zero to CEN or entering a sleep mode that disables the
PB clocks. In either case, the generic clock will be switched off on the first falling edge after the
disabling event, to ensure that no glitches occur. After CEN has been written to zero, the bit will
still read as one until the next falling edge occurs, and the clock is actually switched off. When
writing a zero to CEN the other bits in GCCTRL should not be changed until CEN reads as zero,
to avoid glitches on the generic clock. The generic clocks will be automatically re-enabled when
waking from sleep.
14.5.15.3 Changing clock frequency
When changing the generic clock frequency by changing OSCSEL or DIV, the clock should be
disabled before being re-enabled with the new clock source or division setting. This prevents
glitches during the transition.
14.5.15.4 Generic clock allocation
The generic clocks are allocated to different functions as shown in the “Generic Clock Allocation”
table in the SCIF Module Configuration section.
14.5.16 Interrupts
The SCIF has the following interrupt sources:
• AE - Access Error:
– A protected SCIF register was accessed without first being correctly unlocked.
Divider
OSCSEL
Generic Clock
DIV
0
1
DIVEN
Mask
CEN
Sleep Controller
fSRC fGCLK
Generic
Clock
Sources
f
GCLK
f
SRC
2 DIV + 1 = ----------------------------
264
32142D–06/2013
ATUC64/128/256L3/4U
• PLLLOCK - PLL Lock
– A 0 to 1 transition on the PCLKSR.PLLLOCK bit is detected.
• PLLLOCKLOST - PLL Lock Lost
– A to 1 transition on the PCLKSR.PLLLOCKLOST bit is detected.
• BRIFARDY - Backup Register Interface Ready.
– A 0 to 1 transition on the PCLKSR.BRIFARDY bit is detected.
• DFLL0RCS - DFLL Reference Clock Stopped:
– A 0 to 1 transition on the PCLKSR.DFLLRCS bit is detected.
• DFLL0RDY - DFLL Ready:
– A 0 to 1 transition on the PCLKSR.DFLLRDY bit is detected.
• DFLL0LOCKLOSTA - DFLL lock lost on Accurate value:
– A 0 to 1 transition on the PCLKSR.DFLLLOCKLOSTA bit is detected.
• DFLL0LOCKLOSTF - DFLL lock lost on Fine value:
– A 0 to 1 transition on the PCLKSR.DFLLLOCKLOSTF bit is detected.
• DFLL0LOCKLOSTC - DFLL lock lost on Coarse value:
– A 0 to 1 transition on the PCLKSR.DFLLLOCKLOSTC bit is detected.
• DFLL0LOCKA - DFLL Locked on Accurate value:
– A 0 to 1 transition on the PCLKSR.DFLLLOCKA bit is detected.
• DFLL0LOCKF - DFLL Locked on Fine value:
– A 0 to 1 transition on the PCLKSR.DFLLLOCKF bit is detected.
• DFLL0LOCKC - DFLL Locked on Coarse value:
– A 0 to 1 transition on the PCLKSR.DFLLLOCKC bit is detected.
• BODDET - Brown out detection:
– A 0 to 1 transition on the PCLKSR.BODDET bit is detected.
• SM33DET - Supply Monitor 3.3V Detector:
– A 0 to 1 transition on the PCLKSR.SM33DET bit is detected.
• VREGOK - Voltage Regulator OK:
– A 0 to 1 transition on the PCLKSR.VREGOK bit is detected.
• OSC0RDY - Oscillator Ready:
– A 0 to 1 transition on the PCLKSR.OSC0RDY bit is detected.
• OSC32RDY - 32KHz Oscillator Ready:
– A 0 to 1 transition on the PCLKSR.OSC32RDY bit is detected.
The interrupt sources will generate an interrupt request if the corresponding bit in the Interrupt
Mask Register is set. The interrupt sources are ORed together to form one interrupt request. The
SCIF will generate an interrupt request if at least one of the bits in the Interrupt Mask Register
(IMR) is set. Bits in IMR are set by writing a one to the corresponding bit in the Interrupt Enable
Register (IER), and cleared by writing a one to the corresponding bit in the Interrupt Disable
Register (IDR). The interrupt request remains active until the corresponding bit in the Interrupt
Status Register (ISR) is cleared by writing a one to the corresponding bit in the Interrupt Clear
Register (ICR). Because all the interrupt sources are ORed together, the interrupt request from
the SCIF will remain active until all the bits in ISR are cleared.
265
32142D–06/2013
ATUC64/128/256L3/4U
14.6 User Interface
Table 14-2. SCIF Register Memory Map
Offset Register Register Name Access Reset
0x0000 Interrupt Enable Register IER Write-only 0x00000000
0x0004 Interrupt Disable Register IDR Write-only 0x00000000
0x0008 Interrupt Mask Register IMR Read-only 0x00000000
0x000C Interrupt Status Register ISR Read-only 0x00000000
0x0010 Interrupt Clear Register ICR Write-only 0x00000000
0x0014 Power and Clocks Status Register PCLKSR Read-only 0x00000000
0x0018 Unlock Register UNLOCK Write-only 0x00000000
0x001C Oscillator 0 Control Register OSCCTRL0 Read/Write 0x00000000
0x0020 Oscillator 32 Control Register OSCCTRL32 Read/Write 0x00000004
0x0024 DFLL Config Register DFLL0CONF Read/Write 0x00000000
0x0028 DFLL Multiplier Register DFLL0MUL Write-only 0x00000000
0x002C DFLL Step Register DFLL0STEP Write-only 0x00000000
0x0030 DFLL Spread Spectrum Generator Control
Register DFLL0SSG Write-only 0x00000000
0x0034 DFLL Ratio Register DFLL0RATIO Read-only 0x00000000
0x0038 DFLL Synchronization Register DFLL0SYNC Write-only 0x00000000
0x003C BOD Level Register BOD Read/Write -(2)
0x0044 Voltage Regulator Calibration Register VREGCR Read/Write -(2)
0x0048 System RC Oscillator Calibration Register RCCR Read/Write -(2)
0x004C Supply Monitor 33 Calibration Register SM33 Read/Write -(2)
0x0050 Temperature Sensor Calibration Register TSENS Read/Write 0x00000000
0x0058 120MHz RC Oscillator Control Register RC120MCR Read/Write 0x00000000
0x005C-0x0068 Backup Registers BR Read/Write 0x00000000
0x006C 32kHz RC Oscillator Control Register RC32KCR Read/Write 0x00000000
0x0070 Generic Clock Control0 GCCTRL0 Read/Write 0x00000000
0x0074 Generic Clock Control1 GCCTRL1 Read/Write 0x00000000
0x0078 Generic Clock Control2 GCCTRL2 Read/Write 0x00000000
0x007C Generic Clock Control3 GCCTRL3 Read/Write 0x00000000
0x0080 Generic Clock Control4 GCCTRL4 Read/Write 0x00000000
0x0084 Generic Clock Control5 GCCTRL5 Read/Write 0x00000000
0x0088 Generic Clock Control6 GCCTRL6 Read/Write 0x00000000
0x008C Generic Clock Control7 GCCTRL7 Read/Write 0x00000000
0x0090 Generic Clock Control8 GCCTRL8 Read/Write 0x00000000
0x0094 Generic Clock Control9 GCCTRL9 Read/Write 0x00000000
266
32142D–06/2013
ATUC64/128/256L3/4U
Note: 1. The reset value is device specific. Please refer to the Module Configuration section at the end of this chapter.
2. The reset value of this register depends on factory calibration.
0x0098 PLL0 Control Register PLL0 Read/Write 0x00000000
0x009C High Resolution Prescaler Control Register HRPCR Read/Write 0x00000000
0x00A0 Fractional Prescaler Control Register FPCR Read/Write 0x00000000
0x00A4 Fractional Prescaler Multiplier Register FPMUL Read/Write 0x00000000
0x00A8 Fractional Prescaler DIVIDER Register FPDIV Read/Write 0x00000000
0x03BC Commonly used Modules Version Register CMVERSION Read-only -(1)
0x03C0 Generic Clock Prescaler Version Register GCLKPRESCVERSION Read-only -(1)
0x03C4 PLL Version Register PLLVERSION Read-only -(1)
0x03C8 Oscillator0 Version Register OSC0VERSION Read-only -(1)
0x03CC 32 KHz Oscillator Version Register OSC32VERSION Read-only -(1)
0x03D0 DFLL Version Register DFLLIFVERSION Read-only -(1)
0x03D4 BOD Version Register BODIFAVERSION Read-only -(1)
0x03D8 Voltage Regulator Version Register VREGIFBVERSION Read-only -(1)
0x03DC System RC Oscillator Version Register RCOSCIFAVERSION Read-only -(1)
0x03E0 3.3V Supply Monitor Version Register SM33IFAVERSION Read-only -(1)
0x03E4 Temperature Sensor Version Register TSENSIFAVERSION Read-only -(1)
0x03EC 120MHz RC Oscillator Version Register RC120MIFAVERSION Read-only -(1)
0x03F0 Backup Register Interface Version Register BRIFAVERSION Read-only -(1)
0x03F4 32kHz RC Oscillator Version Register RC32KIFAVERSION Read-only -(1)
0x03F8 Generic Clock Version Register GCLKVERSION Read-only -(1)
0x03FC SCIF Version Register VERSION Read-only -(1)
Table 14-2. SCIF Register Memory Map
Offset Register Register Name Access Reset
267
32142D–06/2013
ATUC64/128/256L3/4U
14.6.1 Interrupt Enable Register
Name: IER
Access Type: Write-only
Offset: 0x0000
Reset Value: 0x00000000
Writing a zero to a bit in this register has no effect.
Writing a one to a bit in this register will set the corresponding bit in IMR.
31 30 29 28 27 26 25 24
AE - - - - - - -
23 22 21 20 19 18 17 16
----- PLLLOCKLO
ST0 PLLLOCK0 BRIFARDY
15 14 13 12 11 10 9 8
DFLL0RCS DFLL0RDY DFLL0LOCK
LOSTA
DFLL0LOCK
LOSTF
DFLL0LOCK
LOSTC
DFLL0LOCK
A
DFLL0LOCK
F
DFLL0LOCK
C
76543210
BODDET SM33DET VREGOK - - - OSC0RDY OSC32RDY
268
32142D–06/2013
ATUC64/128/256L3/4U
14.6.2 Interrupt Disable Register
Name: IDR
Access Type: Write-only
Offset: 0x0004
Reset Value: 0x00000000
Writing a zero to a bit in this register has no effect.
Writing a one to a bit in this register will clear the corresponding bit in IMR.
31 30 29 28 27 26 25 24
AE - - - - - - -
23 22 21 20 19 18 17 16
----- PLLLOCKLO
ST0 PLLLOCK0 BRIFARDY
15 14 13 12 11 10 9 8
DFLL0RCS DFLL0RDY DFLL0LOCK
LOSTA
DFLL0LOCK
LOSTF
DFLL0LOCK
LOSTC
DFLL0LOCK
A
DFLL0LOCK
F
DFLL0LOCK
C
76543210
BODDET SM33DET VREGOK - - - OSC0RDY OSC32RDY
269
32142D–06/2013
ATUC64/128/256L3/4U
14.6.3 Interrupt Mask Register
Name: IMR
Access Type: Read-only
Offset: 0x0008
Reset Value: 0x00000000
0: The corresponding interrupt is disabled.
1: The corresponding interrupt is enabled.
A bit in this register is cleared when the corresponding bit in IDR is written to one.
A bit in this register is set when the corresponding bit in IER is written to one.
31 30 29 28 27 26 25 24
AE - - - - - - -
23 22 21 20 19 18 17 16
----- PLLLOCKLO
ST0 PLLLOCK0 BRIFARDY
15 14 13 12 11 10 9 8
DFLL0RCS DFLL0RDY DFLL0LOCK
LOSTA
DFLL0LOCK
LOSTF
DFLL0LOCK
LOSTC
DFLL0LOCK
A
DFLL0LOCK
F
DFLL0LOCK
C
76543210
BODDET SM33DET VREGOK - - - OSC0RDY OSC32RDY
270
32142D–06/2013
ATUC64/128/256L3/4U
14.6.4 Interrupt Status Register
Name: ISR
Access Type: Read-only
Offset: 0x000C
Reset Value: 0x00000000
0: The corresponding interrupt is cleared.
1: The corresponding interrupt is pending.
A bit in this register is cleared when the corresponding bit in ICR is written to one.
A bit in this register is set when the corresponding interrupt occurs.
31 30 29 28 27 26 25 24
AE - - - - - - -
23 22 21 20 19 18 17 16
----- PLLLOCKLO
ST0 PLLLOCK0 BRIFARDY
15 14 13 12 11 10 9 8
DFLL0RCS DFLL0RDY DFLL0LOCK
LOSTA
DFLL0LOCK
LOSTF
DFLL0LOCK
LOSTC
DFLL0LOCK
A
DFLL0LOCK
F
DFLL0LOCK
C
76543210
BODDET SM33DET VREGOK - - - OSC0RDY OSC32RDY
271
32142D–06/2013
ATUC64/128/256L3/4U
14.6.5 Interrupt Clear Register
Name: ICR
Access Type: Write-only
Offset: 0x0010
Reset Value: 0x00000000
Writing a zero to a bit in this register has no effect.
Writing a one to a bit in this register will clear the corresponding bit in ISR.
31 30 29 28 27 26 25 24
AE - - - - - - -
23 22 21 20 19 18 17 16
----- PLLLOCKLO
ST0 PLLLOCK0 BRIFARDY
15 14 13 12 11 10 9 8
DFLL0RCS DFLL0RDY DFLL0LOCK
LOSTA
DFLL0LOCK
LOSTF
DFLL0LOCK
LOSTC
DFLL0LOCK
A
DFLL0LOCK
F
DFLL0LOCK
C
76543210
BODDET SM33DET VREGOK - - - OSC0RDY OSC32RDY
272
32142D–06/2013
ATUC64/128/256L3/4U
14.6.6 Power and Clocks Status Register
Name: PCLKSR
Access Type: Read-only
Offset: 0x0014
Reset Value: 0x00000000
• BRIFAVALID: Backup Register Interface Valid
0: The values in the backup registers are not valid.
1: The values in the backup registers are valid.
• PLLL0LOCKLOST: PLL0 lock lost value
0: PLL0 has not lost it’s lock or has never been enabled.
1: PLL0 has lost it’s lock, either by disabling the PLL0 or due to faulty operation.
• PLL0LOCK: PLL0 Locked on Accurate value
0: PLL0 is unlocked on accurate value.
1: PLL0 is locked on accurate value, and is ready to be selected as clock source with an accurate output clock.
• BRIFARDY: Backup Register Interface Ready
0: The backup register interface is busy updating the backup registers. Writes to BRn will be discarded.
1: The backup register interface is ready to accept new writes to the backup registers.
• DFLL0RCS: DFLL0 Reference Clock Stopped
0: The DFLL reference clock is running, or has never been enabled.
1: The DFLL reference clock has stopped or is too slow.
• DFLL0RDY: DFLL0 Synchronization Ready
0: Read or write to DFLL registers is invalid
1: Read or write to DFLL registers is valid
• DFLL0LOCKLOSTA: DFLL0 Lock Lost on Accurate Value
0: DFLL has not lost its Accurate lock or has never been enabled.
1: DFLL has lost its Accurate lock, either by disabling the DFLL or due to faulty operation.
• DFLL0LOCKLOSTF: DFLL0 Lock Lost on Fine Value
0: DFLL has not lost its Fine lock or has never been enabled.
1: DFLL has lost its Fine lock, either by disabling the DFLL or due to faulty operation.
31 30 29 28 27 26 25 24
- BRIFAVALID - - - - - -
23 22 21 20 19 18 17 16
----- PLLLOCKLO
ST0 PLLLOCK0 BRIFARDY
15 14 13 12 11 10 9 8
DFLL0RCS DFLL0RDY DFLL0LOCK
LOSTA
DFLL0LOCK
LOSTF
DFLL0LOCK
LOSTC
DFLL0LOCK
A
DFLL0LOCK
F
DFLL0LOCK
C
76543210
BODDET SM33DET VREGOK - - - OSC0RDY OSC32RDY
273
32142D–06/2013
ATUC64/128/256L3/4U
• DFLL0LOCKLOSTC: DFLL0 Lock Lost on Coarse Value
0: DFLL has not lost its Coarse lock or has never been enabled.
1: DFLL has lost its Coarse lock, either by disabling the DFLL or due to faulty operation.
• DFLL0LOCKA: DFLL0 Locked on Accurate Value
0: DFLL is unlocked on Accurate value.
1: DFLL is locked on Accurate value, and is ready to be selected as clock source with an accurate output clock.
• DFLL0LOCKF: DFLL0 Locked on Fine Value
0: DFLL is unlocked on Fine value.
1: DFLL is locked on Fine value, and is ready to be selected as clock source with a high accuracy on the output clock.
• DFLL0LOCKC: DFLL0 Locked on Coarse Value
0: DFLL is unlocked on Coarse value.
1: DFLL is locked on Coarse value, and is ready to be selected as clock source with medium accuracy on the output clock.
• BODDET: Brown-Out Detection
0: No BOD Event.
1: BOD has detected that the supply voltage is below the BOD reference value.
• SM33DET: Supply Monitor 3.3V Detector
0: SM33 not enabled or the supply voltage is above the SM33 threshold.
1: SM33 enabled and the supply voltage is below the SM33 threshold.
• VREGOK: Voltage Regulator OK
0: Voltage regulator not enabled or not ready.
1: Voltage regulator has reached its output threshold value after being enabled.
• OSC0RDY: OSC0 Ready
0: Oscillator not enabled or not ready.
1: Oscillator is stable and ready to be used as clock source.
• OSC32RDY: 32 KHz oscillator Ready
0: OSC32K not enabled or not ready.
1: OSC32K is stable and ready to be used as clock source.
274
32142D–06/2013
ATUC64/128/256L3/4U
14.6.7 Unlock Register
Name: UNLOCK
Access Type: Write-only
Offset: 0x0018
Reset Value: 0x00000000
To unlock a write protected register, first write to the UNLOCK register with the address of the register to unlock in the ADDR
field and 0xAA in the KEY field. Then, in the next PB access write to the register specified in the ADDR field.
The LOCK is by default off. To turn on the LOCK, first write 0xAA to the KEY field and UNLOCK address offset to the ADDR field
in the UNLOCK register, followed by writing 0x5A5A5A5A to the UNLOCK register. To turn off the LOCK, first write 0xAA to the
KEY field and UNLOCK address offset to the ADDR field in the UNLOCK register, followed by writing 0xA5AA5A55 to the
UNLOCK register.
• KEY: Unlock Key
Write this bit field to 0xAA to enable unlock.
• ADDR: Unlock Address
Write the address offset of the register to unlock to this field.
31 30 29 28 27 26 25 24
KEY
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
- - - - - - ADDR[9:8]
76543210
ADDR[7:0]
275
32142D–06/2013
ATUC64/128/256L3/4U
14.6.8 Oscillator Control Register
Name: OSCCTRLn
Access Type: Read/Write
Reset Value: 0x00000000
• OSCEN: Oscillator Enable
0: The oscillator is disabled.
1: The oscillator is enabled.
• STARTUP: Oscillator Start-up Time
Select start-up time for the oscillator. Please refer to the “Oscillator Startup Time” table in the SCIF Module Configuration
section for details.
• AGC: Automatic Gain Control
For test purposes.
• GAIN: Gain
Selects the gain for the oscillator. Please refer to the “Oscillator Gain Settings” table in the SCIF Module Configuration section
for details.
• MODE: Oscillator Mode
0: External clock connected on XIN. XOUT can be used as general-purpose I/O (no crystal).
1: Crystal is connected to XIN/XOUT.
Note that this register is protected by a lock. To write to this register the UNLOCK register has to be written first. Please
refer to the UNLOCK register description for details.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
- - - - - - - OSCEN
15 14 13 12 11 10 9 8
- - - - STARTUP[3:0]
76543210
- - - - AGC GAIN[1:0] MODE
276
32142D–06/2013
ATUC64/128/256L3/4U
14.6.9 32KHz Oscillator Control Register
Name: OSCCTRL32
Access Type: Read/Write
Reset Value: 0x00000004
Note: This register is only reset by Power-On Reset
• RESERVED
This bit must always be written to zero.
• STARTUP: Oscillator Start-up Time
Select start-up time for 32 KHz oscillator
31 30 29 28 27 26 25 24
RESERVED -------
23 22 21 20 19 18 17 16
- - - - - STARTUP[2:0]
15 14 13 12 11 10 9 8
- - - - - MODE[2:0]
76543210
- - - - EN1K EN32K PINSEL OSC32EN
Table 14-3. Start-up Time for 32 KHz Oscillator
STARTUP
Number of RCSYS Clock
Cycle
Approximative Equivalent Time
(RCOSC = 115 kHz)
00 0
1 128 1.1 ms
2 8192 72.3 ms
3 16384 143 ms
4 65536 570 ms
5 131072 1.1 s
6 262144 2.3 s
7 524288 4.6 s
277
32142D–06/2013
ATUC64/128/256L3/4U
• MODE: Oscillator Mode
• EN1K: 1 KHz output Enable
0: The 1 KHz output is disabled.
1: The 1 KHz output is enabled.
• EN32K: 32 KHz output Enable
0: The 32 KHz output is disabled.
1: The 32 KHz output is enabled.
• PINSEL: Pins Select
0: Default pins used.
1: Alternate pins: XIN32_2 pin is used instead of XIN32 pin, XOUT32_2 pin is used instead of XOUT32.
• OSC32EN: 32 KHz Oscillator Enable
0: The 32 KHz Oscillator is disabled
1: The 32 KHz Oscillator is enabled
Table 14-4. Operation Mode for 32 KHz Oscillator
MODE Description
0 External clock connected to XIN32, XOUT32 can be used as general-purpose I/O (no crystal)
1 Crystal mode. Crystal is connected to XIN32/XOUT32.
2 Reserved
3 Reserved
4 Crystal and high current mode. Crystal is connected to XIN32/XOUT32.
5 Reserved
6 Reserved
7 Reserved
278
32142D–06/2013
ATUC64/128/256L3/4U
14.6.10 DFLLn Configuration Register
Name: DFLLnCONF
Access Type: Read/Write
Reset Value: 0x00000000
• COARSE: Coarse Calibration Value
Set the value of the coarse calibration register. If in closed loop mode, this field is Read-only.
• FINE: FINE Calibration Value
Set the value of the fine calibration register. If in closed loop mode, this field is Read-only.
• QLEN: Quick Lock Enable
0: Quick Lock is disabled.
1: Quick Lock is enabled.
• CCEN: Chill Cycle Enable
0: Chill Cycle is disabled.
1: Chill Cycle is enabled.
• LLAW: Lose Lock After Wake
0: Locks will not be lost after waking up from sleep modes.
1: Locks will be lost after waking up from sleep modes where the DFLL clock has been stopped.
• DITHER: Enable Dithering
0: The fine LSB input to the VCO is constant.
1: The fine LSB input to the VCO is dithered to achieve sub-LSB approximation to the correct multiplication ratio.
• MODE: Mode Selection
0: The DFLL is in open loop operation.
1: The DFLL is in closed loop operation.
• EN: Enable
0: The DFLL is disabled.
1: The DFLL is enabled.
Note that this register is protected by a lock. To write to this register the UNLOCK register has to be written first. Please
refer to the UNLOCK register description for details.
31 30 29 28 27 26 25 24
COARSE[7:0]
23 22 21 20 19 18 17 16
- - - - - - - FINE[8]
15 14 13 12 11 10 9 8
FINE[7:0]
76543210
- QLEN CCEN - LLAW DITHER MODE EN
279
32142D–06/2013
ATUC64/128/256L3/4U
14.6.11 DFLLn Multiplier Register
Name: DFLLnMUL
Access Type: Read/Write
Reset Value: 0x00000000
• IMUL: Integer Multiply Factor
This field, together with FMUL, determines the ratio between fDFLL and fREFthe DFLL. IMUL is the integer part, while the FMUL is
the fractional part.
In open loop mode, writing to this register has no effect.
• FMUL: Fractional Multiply Factor
This field, together with IMUL, determines the ratio between fDFLL and fREFthe DFLL. IMUL is the integer part, while the FMUL is
the fractional part.
In open loop mode, writing to this register has no effect.
Note that this register is protected by a lock. To write to this register the UNLOCK register has to be written first. Please
refer to the UNLOCK register description for details.
31 30 29 28 27 26 25 24
IMUL[15:8]
23 22 21 20 19 18 17 16
IMUL[7:0]
15 14 13 12 11 10 9 8
FMUL[15:8]
76543210
FMUL[7:0]
280
32142D–06/2013
ATUC64/128/256L3/4U
14.6.12 DFLLn Maximum Step Register
Name: DFLLnSTEP
Access Type: Read/Write
Reset Value: 0x00000000
• FSTEP: Fine Maximum Step
This indicates the maximum step size during fine adjustment in closed-loop mode. When adjusting to a new frequency, the
expected overshoot of that frequency depends on this step size.
• CSTEP: Coarse Maximum Step
This indicates the maximum step size during coarse adjustment in closed-loop mode. When adjusting to a new frequency, the
expected overshoot of that frequency depends on this step size.
Note that this register is protected by a lock. To write to this register the UNLOCK register has to be written first. Please
refer to the UNLOCK register description for details.
31 30 29 28 27 26 25 24
- - - - - - - FSTEP[8]
23 22 21 20 19 18 17 16
FSTEP[7:0]
15 14 13 12 11 10 9 8
--------
76543210
CSTEP[7:0]
281
32142D–06/2013
ATUC64/128/256L3/4U
14.6.13 DFLLn Spread Spectrum Generator Control Register
Name: DFLLnSSG
Access Type: Read/Write
Reset Value: 0x00000000
• STEPSIZE: SSG Step Size
Sets the step size of the spread spectrum.
• AMPLITUDE: SSG Amplitude
Sets the amplitude of the spread spectrum.
• PRBS: Pseudo Random Bit Sequence
0: Each spread spectrum frequency is applied at constant intervals
1: Each spread spectrum frequency is applied at pseudo-random intervals
• EN: Enable
0: SSG is disabled.
1: SSG is enabled.
Note that this register is protected by a lock. To write to this register the UNLOCK register has to be written first. Please
refer to the UNLOCK register description for details.
31 30 29 28 27 26 25 24
- -------
23 22 21 20 19 18 17 16
- - - STEPSIZE[4:0]
15 14 13 12 11 10 9 8
- - - AMPLITUDE[4:0]
76543210
- - - - - - PRBS EN
282
32142D–06/2013
ATUC64/128/256L3/4U
14.6.14 DFLLn Ratio Register
Name: DFLLnRATIO
Access Type: Read-only
Reset Value: 0x00000000
• RATIODIFF: Multiplication Ratio Difference
In closed-loop mode, this field indicates the error in the ratio between the VCO frequency and the target frequency.
• NUMREF: Numerical Reference
The number of reference clock cycles used to measure the VCO frequency equals 2^NUMREF.
31 30 29 28 27 26 25 24
RATIODIFF[15:8]
23 22 21 20 19 18 17 16
RATIODIFF[7:0]
15 14 13 12 11 10 9 8
- -------
76543210
- - - NUMREF[4:0]
283
32142D–06/2013
ATUC64/128/256L3/4U
14.6.15 DFLLn Synchronization Register
Name: DFLLnSYNC
Access Type: Write-only
Reset Value: 0x00000000
• SYNC: Synchronization
To be able to read the current value of DFLLnCONF or DFLLnRATIO in closed-loop mode, this bit should be written to one. The
updated value is available in DFLLnCONF and DFLLnRATIO when PCLKSR.DFLLnRDY is set.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
--------
76543210
- - - - - - - SYNC
284
32142D–06/2013
ATUC64/128/256L3/4U
14.6.16 BOD Control Register
Name: BOD
Access Type: Read/Write
Reset Value: -
• SFV: Store Final Value
0: The register is read/write
1: The register is read-only, to protect against further accidental writes.
This bit is cleared after any reset except for a BOD reset, and during flash calibration.
• FCD: Fuse Calibration Done
0: The flash calibration will be redone after any reset.
1: The flash calibration will be redone after any reset except for a BOD reset.
This bit is cleared after any reset, except for a BOD reset.
This bit is set when the CTRL, HYST and LEVEL fields have been updated by the flash fuses after a reset.
• CTRL: BOD Control
• HYST: BOD Hysteresis
0: No hysteresis.
1: Hysteresis on.
• LEVEL: BOD Level
This field sets the triggering threshold of the BOD. See Electrical Characteristics for actual voltage levels.
Note that any change to the LEVEL field of the BOD register should be done with the BOD deactivated to avoid spurious reset
or interrupt.
31 30 29 28 27 26 25 24
SFV - - - - - - -
23 22 21 20 19 18 17 16
- - - - - - - FCD
15 14 13 12 11 10 9 8
- - - - - - CTRL
76543210
- HYST LEVEL
Table 14-5. Operation Mode for BOD
CTRL Description
0 BOD is disabled.
1 BOD is enabled and can reset the device. An interrupt request will be generated, if enabled in the IMR
register.
2 BOD is enabled but cannot reset the device. An interrupt request will be generated, if enabled in the IMR
register.
3 Reserved.
285
32142D–06/2013
ATUC64/128/256L3/4U
Note that this register is protected by a lock. To write to this register the UNLOCK register has to be written first. Please
refer to the UNLOCK register description for details.
286
32142D–06/2013
ATUC64/128/256L3/4U
14.6.17 Voltage Regulator Calibration Register
Name: VREGCR
Access Type: Read/Write
Reset Value: -
• SFV: Store Final Value
0: The register is read/write.
1: The register is read-only, to protect against further accidental writes.
This bit is cleared by a Power-on Reset.
• INTPD: Internal Pull-down
This bit is used for test purposes only.
0: The voltage regulator output is not pulled to ground.
1: The voltage regulator output has a pull-down to ground.
• POR18VALUE: Power-on Reset 1.8V Output Value
0: VDDCORE voltage is below the POR18 power-on threshold level.
1: VDDCORE voltage is above the POR18 power-on threshold level.
This bit is read-only. Writing to this bit has no effect.
• POR33VALUE: Power-on Reset 3.3V Output Value
0: Internal regulator supply voltage is below the POR33 power-on threshold level.
1: Internal regulator supply voltage is above the POR33 power-on threshold level.
This bit is read-only. Writing to this bit has no effect.
• POR18MASK: Power-on Reset 1.8V Output Mask
0: Power-on Reset is not masked.
1: Power-on Reset is masked.
• POR18STATUS: Power-on Reset 1.8V Status
0: Power-on Reset is disabled.
1: Power-on Reset is enabled.
This bit is read-only. Writing to this bit has no effect.
• POR18EN: Power-on Reset 1.8V Enable
Writing a zero to this bit disables the POR18 detector.
Writing a one to this bit enables the POR18 detector.
• POR33MASK: Power-on Reset 3.3V Output Mask
0: Power-on Reset 3.3V is not masked.
31 30 29 28 27 26 25 24
SFV INTPD - - - DBG- POR18VALUE POR33VALUE
23 22 21 20 19 18 17 16
POR18MASK POR18STAT
US POR18EN POR33MASK POR33STAT
US POR33EN DEEPDIS FCD
15 14 13 12 11 10 9 8
- - - - CALIB
76543210
ON VREGOK EN - - SELVDD
287
32142D–06/2013
ATUC64/128/256L3/4U
1: Power-on Reset 3.3V is masked.
• POR33STATUS: Power-on Reset 3.3V Status
0: Power-on Reset is disabled.
1: Power-on Reset is enabled.
This bit is read-only. Writing to this bit has no effect.
• POR33EN: Power-on Reset 3.3V Enable
0: Writing a zero to this bit disables the POR33 detector.
1: Writing a one to this bit enables the POR33 detector.
• DEEPDIS: Disable Regulator Deep Mode
0: Regulator will enter deep mode in low-power sleep modes for lower power consumption.
1: Regulator will stay in full-power mode in all sleep modes for shorter start-up time.
• FCD: Flash Calibration Done
0: The flash calibration will be redone after any reset.
1: The flash calibration will only be redone after a Power-on Reset.
This bit is cleared after a Power-on Reset.
This bit is set when the CALIB field has been updated by flash calibration after a reset.
• CALIB: Calibration Value
Calibration value for Voltage Regulator. This is calibrated during production and should not be changed.
• ON: Voltage Regulator On Status
0: The voltage regulator is currently disabled.
1: The voltage regulator is currently enabled.
This bit is read-only. Writing to this bit has no effect.
• VREGOK: Voltage Regulator OK Status
0: The voltage regulator is disabled or has not yet reached a stable output voltage.
1: The voltage regulator has reached the output voltage threshold level after being enabled.
This bit is read-only. Writing to this bit has no effect.
• EN: Enable
0: The voltage regulator is disabled.
1: The voltage regulator is enabled.
Note: This bit is set after a Power-on Reset (POR).
• SELVDD: Select VDD
Output voltage of the Voltage Regulator. The default value of this bit corresponds to an output voltage of 1.8V.
Note that this register is protected by a lock. To write to this register the UNLOCK register has to be written first. Please
refer to the UNLOCK register description for details.
288
32142D–06/2013
ATUC64/128/256L3/4U
14.6.18 System RC Oscillator Calibration Register
Name: RCCR
Access Type: Read/Write
Reset Value: -
• FCD: Flash Calibration Done
0: The flash calibration will be redone after any reset.
1: The flash calibration will only be redone after a Power-on Reset.
This bit is cleared after a POR.
This bit is set when the CALIB field has been updated by the flash fuses after a reset.
• CALIB: Calibration Value
Calibration Value for the System RC oscillator (RCSYS).
Note that this register is protected by a lock. To write to this register the UNLOCK register has to be written first. Please
refer to the UNLOCK register description for details.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
- - - - - - - FCD
15 14 13 12 11 10 9 8
- - - - - - CALIB[9:8]
76543210
CALIB[7:0]
289
32142D–06/2013
ATUC64/128/256L3/4U
14.6.19 Supply Monitor 33 Calibration Register
Name: SM33
Access Type: Read/Write
Reset Value: -
• SAMPFREQ: Sampling Frequency
Selects the sampling mode frequency of the 3.3V supply monitor. In sampling mode, the SM33 performs a measurement every
2(SAMPFREQ+5) cycles of the internal 32kHz RC oscillator.
• ONSM: Supply Monitor On Indicator
0: The supply monitor is disabled.
1: The supply monitor is enabled.
This bit is read-only. Writing to this bit has no effect.
• SFV: Store Final Value
0: The register is read/write
1: The register is read-only, to protect against further accidental writes.
This bit is cleared after a reset.
• FCD: Flash Calibration Done
This bit is cleared after a reset.
This bit is set when CALIB field has been updated after a reset.
• CALIB: Calibration Value
Calibration Value for the SM33.
• FS: Force Sampling Mode
0: Sampling mode is enabled in DeepStop and Static mode only.
1: Sampling mode is always enabled.
• CTRL: Supply Monitor Control
31 30 29 28 27 26 25 24
- - - - SAMPFREQ
23 22 21 20 19 18 17 16
- - - - - ONSM SFV FCD
15 14 13 12 11 10 9 8
- - - - CALIB
76543210
FS - - - CTRL
290
32142D–06/2013
ATUC64/128/256L3/4U
Selects the operating mode for the SM33.
Note that this register is protected by a lock. To write to this register the UNLOCK register has to be written first. Please
refer to the UNLOCK register description for details.
Table 14-6. Operation Mode for SM33
CTRL Description
0 SM33 is disabled.
1 SM33 is enabled and can reset the device. An interrupt request will be generated if the corresponding
interrupt is enabled in the IMR register.
2 SM33 is enabled and cannot reset the device. An interrupt request will be generated if the corresponding
interrupt is enabled in the IMR register.
3 SM33 is disabled
4-7 Reserved
291
32142D–06/2013
ATUC64/128/256L3/4U
14.6.20 Temperature Sensor Configuration Register
Name: TSENS
Access Type: Read/Write
Reset Value: 0x00000000
• EN: Temperature Sensor Enable
0: The Temperature Sensor is disabled.
1: The Temperature Sensor is enabled.
Note that this register is protected by a lock. To write to this register the UNLOCK register has to be written first. Please
refer to the UNLOCK register description for details.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
--------
76543210
- - - - - EN
292
32142D–06/2013
ATUC64/128/256L3/4U
14.6.21 120MHz RC Oscillator Configuration Register
Name: RC120MCR
Access Type: Read/Write
Reset Value: 0x00000000
• EN: RC120M Enable
0: The 120 MHz RC oscillator is disabled.
1: The 120 MHz RC oscillator is enabled.
Note that this register is protected by a lock. To write to this register the UNLOCK register has to be written first. Please
refer to the UNLOCK register description for details.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
--------
76543210
- - - - - - - EN
293
32142D–06/2013
ATUC64/128/256L3/4U
14.6.22 Backup Register n
Name: BRn
Access Type: Read/Write
Reset Value: 0x00000000
This is a set of general-purpose read/write registers. Data stored in these registers is retained when the device is in Shutdown.
Before writing to these registers the user must ensure that PCLKSR.BRIFARDY is not set.
Note that this registers are protected by a lock. To write to these registers the UNLOCK register has to be written first.
Please refer to the UNLOCK register description for details.
31 30 29 28 27 26 25 24
DATA[31:24]
23 22 21 20 19 18 17 16
DATA[23:16]
15 14 13 12 11 10 9 8
DATA[15:8]
76543210
DATA[7:0]
294
32142D–06/2013
ATUC64/128/256L3/4U
14.6.23 32kHz RC Oscillator Configuration Register
Name: RC32KCR
Access Type: Read/Write
Reset Value: 0x00000000
• EN: RC32K Enable
0: The 32 kHz RC oscillator is disabled.
1: The 32 kHz RC oscillator is enabled.
Note that this register is protected by a lock. To write to this register the UNLOCK register has to be written first. Please
refer to the UNLOCK register description for details.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
--------
76543210
- - - - - - - EN
295
32142D–06/2013
ATUC64/128/256L3/4U
14.6.24 Generic Clock Control
Name: GCCTRL
Access Type: Read/Write
Reset Value: 0x00000000
There is one GCCTRL register per generic clock in the design.
• DIV: Division Factor
The number of DIV bits for each generic clock is as shown in the “Generic Clock number of DIV bits” table in the SCIF Module
Configuration section.
• OSCSEL: Oscillator Select
Selects the source clock for the generic clock. Please refer to the “Generic Clock Sources” table in the SCIF Module
Configuration section.
• DIVEN: Divide Enable
0: The generic clock equals the undivided source clock.
1: The generic clock equals the source clock divided by 2*(DIV+1).
• CEN: Clock Enable
0: The generic clock is disabled.
1: The generic clock is enabled.
31 30 29 28 27 26 25 24
DIV[15:8]
23 22 21 20 19 18 17 16
DIV[7:0]
15 14 13 12 11 10 9 8
- - - OSCSEL[4:0]
76543210
- - - - - - DIVEN CEN
296
32142D–06/2013
ATUC64/128/256L3/4U
14.6.25 PLL Control Register
Name: PLLn
Access Type: Read/Write
Reset Value: 0x00000000
• PLLCOUNT: PLL Count
Specifies the number of RCSYS clock cycles before ISR.PLLLOCKn will be set after PLLn has been written, or after PLLn has
been automatically re-enabled after exiting a sleep mode.
• PLLMUL: PLL Multiply Factor
• PLLDIV: PLL Division Factor
These fields determine the ratio of the PLL output frequency to the source oscillator frequency:
fvco = (PLLMUL+1)/PLLDIV • fREF if PLLDIV >0
fvco = 2•(PLLMUL+1) • fREF if PLLDIV = 0
Note that the PLLMUL field should always be greater than 1 or the behavior of the PLL will be undefined.
• PLLOPT: PLL Option
PLLOPT[0]: Selects the VCO frequency range (fvco).
0: 80MHz1
1
1
0
0
BaudRate SelectedClock
8 2 – OVER CD = -----------------------------------------------
438
32142D–06/2013
ATUC64/128/256L3/4U
The baud rate is calculated with the following formula (OVER=0):
The baud rate error is calculated with the following formula. It is not recommended to work with
an error higher than 5%.
20.6.1.3 Fractional Baud Rate in Asynchronous Mode
The baud rate generator has a limitation: the source frequency is always a multiple of the baud
rate. An approach to this problem is to integrate a high resolution fractional N clock generator,
outputting fractional multiples of the reference source clock. This fractional part is selected with
the Fractional Part field (BRGR.FP), and is activated by giving it a non-zero value. The resolution
is one eighth of CD. The resulting baud rate is calculated using the following formula:
The modified architecture is presented below:
Table 20-3. Baud Rate Example (OVER=0)
Source Clock (Hz)
Expected Baud
Rate (bit/s) Calculation Result CD Actual Baud Rate (bit/s) Error
3 686 400 38 400 6.00 6 38 400.00 0.00%
4 915 200 38 400 8.00 8 38 400.00 0.00%
5 000 000 38 400 8.14 8 39 062.50 1.70%
7 372 800 38 400 12.00 12 38 400.00 0.00%
8 000 000 38 400 13.02 13 38 461.54 0.16%
12 000 000 38 400 19.53 20 37 500.00 2.40%
12 288 000 38 400 20.00 20 38 400.00 0.00%
14 318 180 38 400 23.30 23 38 908.10 1.31%
14 745 600 38 400 24.00 24 38 400.00 0.00%
18 432 000 38 400 30.00 30 38 400.00 0.00%
24 000 000 38 400 39.06 39 38 461.54 0.16%
24 576 000 38 400 40.00 40 38 400.00 0.00%
25 000 000 38 400 40.69 40 38 109.76 0.76%
32 000 000 38 400 52.08 52 38 461.54 0.16%
32 768 000 38 400 53.33 53 38 641.51 0.63%
33 000 000 38 400 53.71 54 38 194.44 0.54%
40 000 000 38 400 65.10 65 38 461.54 0.16%
50 000 000 38 400 81.38 81 38 580.25 0.47%
60 000 000 38 400 97.66 98 38 265.31 0.35%
BaudRate CLKUSART = CD 16
Error 1 ExpectedBaudRate
ActualBaudRate
-------------------------------------------------- = –
BaudRate SelectedClock
8 2 – OVER CD FP
8
+ -------
= --------------------------------------------------------------------
439
32142D–06/2013
ATUC64/128/256L3/4U
Figure 20-3. Fractional Baud Rate Generator
20.6.1.4 Baud Rate in Synchronous and SPI Mode
If the USART is configured to operate in synchronous mode, the selected clock is divided by the
BRGR.CD field. This does not apply when CLK is selected.
When CLK is selected the external frequency must be at least 4.5 times lower than the system
clock, and when either CLK or CLK_USART/DIV are selected, CD must be even to ensure a
50/50 duty cycle. If CLK_USART is selected, the generator ensures this regardless of value.
20.6.2 Receiver and Transmitter Control
After a reset, the transceiver is disabled. The receiver/transmitter is enabled by writing a one to
either the Receiver Enable, or Transmitter Enable bit in the Control Register (CR.RXEN, or
CR.TXEN). They may be enabled together and can be configured both before and after they
have been enabled. The user can reset the USART receiver/transmitter at any time by writing a
one to either the Reset Receiver (CR.RSTRX), or Reset Transmitter (CR.RSTTX) bit. This software
reset clears status bits and resets internal state machines, immediately halting any
communication. The user interface configuration registers will retain their values.
The user can disable the receiver/transmitter by writing a one to either the Receiver Disable, or
Transmitter Disable bit (CR.RXDIS, or CR.TXDIS). If the receiver is disabled during a character
reception, the USART will wait for the current character to be received before disabling. If the
transmitter is disabled during transmission, the USART will wait until both the current character
and the character stored in the Transmitter Holding Register (THR) are transmitted before disabling.
If a timeguard has been implemented it will remain functional during the transaction.
USCLKS CD Modulus
Control
FP
FP
CD
glitch-free
logic
16-bit Counter
OVER
FIDI
SYNC
Sampling
Divider
CLK_USART
CLK_USART/DIV
Reserved CLK
CLK
BaudRate
Clock
Sampling
Clock
SYNC
USCLKS = 3
>1
1
2
3
0
0
1
0
1
1
0
0
BaudRate SelectedClock
CD = -------------------------------------
440
32142D–06/2013
ATUC64/128/256L3/4U
20.6.3 Synchronous and Asynchronous Modes
20.6.3.1 Transmitter Operations
The transmitter performs equally in both synchronous and asynchronous operating modes
(MR.SYNC). One start bit, up to 9 data bits, an optional parity bit, and up to two stop bits are
successively shifted out on the TXD pin at each falling edge of the serial clock. The number of
data bits is selected by the Character Length field (MR.CHRL) and the MR.MODE9 bit. Nine bits
are selected by writing a one to MODE9, overriding any value in CHRL. The parity bit configuration
is selected in the MR.PAR field. The Most Significant Bit First bit (MR.MSBF) selects which
data bit to send first. The number of stop bits is selected by the MR.NBSTOP field. The 1.5 stop
bit configuration is only supported in asynchronous mode.
Figure 20-4. Character Transmit
The characters are sent by writing to the Character to be Transmitted field (THR.TXCHR). The
transmitter reports status with the Transmitter Ready (TXRDY) and Transmitter Empty
(TXEMPTY) bits in the Channel Status Register (CSR). TXRDY is set when THR is empty.
TXEMPTY is set when both THR and the transmit shift register are empty (transmission complete).
Both TXRDY and TXEMPTY are cleared when the transmitter is disabled. Writing a
character to THR while TXRDY is zero has no effect and the written character will be lost.
Figure 20-5. Transmitter Status
20.6.3.2 Asynchronous Receiver
If the USART is configured in an asynchronous operating mode (MR.SYNC = 0), the receiver will
oversample the RXD input line by either 8 or 16 times the baud rate clock, as selected by the
Oversampling Mode bit (MR.OVER). If the line is zero for half a bit period (four or eight consecutive
samples, respectively), a start bit will be assumed, and the following 8th or 16th sample will
determine the logical value on the line, in effect resulting in bit values being determined at the
middle of the bit period.
D0 D1 D2 D3 D4 D5 D6 D7
TXD
Start
Bit
Parity
Bit
Stop
Bit
Example: 8-bit, Parity Enabled One Stop
Baud Rate
Clock
D0 D1 D2 D3 D4 D5 D6 D7
TXD
Start
Bit
Parity
Bit
Stop
Bit
Baud Rate
Clock
Start
Bit
Write
THR
D0 D1 D2 D3 D4 D5 D6 D7 Parity
Bit
Stop
Bit
TXRDY
TXEMPTY
441
32142D–06/2013
ATUC64/128/256L3/4U
The number of data bits, endianess, parity mode, and stop bits are selected by the same bits
and fields as for the transmitter (MR.CHRL, MODE9, MSBF, PAR, and NBSTOP). The synchronization
mechanism will only consider one stop bit, regardless of the used protocol, and when
the first stop bit has been sampled, the receiver will automatically begin looking for a new start
bit, enabling resynchronization even if there is a protocol miss-match. Figure 20-6 and Figure
20-7 illustrate start bit detection and character reception in asynchronous mode.
Figure 20-6. Asynchronous Start Bit Detection
Figure 20-7. Asynchronous Character Reception
20.6.3.3 Synchronous Receiver
In synchronous mode (SYNC=1), the receiver samples the RXD signal on each rising edge of
the Baud Rate Clock. If a low level is detected, it is considered as a start bit. Configuration bits
and fields are the same as in asynchronous mode.
Sampling
Clock (x16)
RXD
Start
Detection
Sampling
Baud Rate
Clock
RXD
Start
Rejection
Sampling
12345678
12345670 1234
12345678 9 10 11 12 13 14 15 16 D0
Sampling
D0 D1 D2 D3 D4 D5 D6 D7
RXD
Parity
Bit
Stop
Bit
Example: 8-bit, Parity Enabled
Baud Rate
Clock
Start
Detection
16
samples
16
samples
16
samples
16
samples
16
samples
16
samples
16
samples
16
samples
16
samples
16
samples
442
32142D–06/2013
ATUC64/128/256L3/4U
Figure 20-8. Synchronous Mode Character Reception
20.6.3.4 Receiver Operations
When a character reception is completed, it is transferred to the Received Character field in the
Receive Holding Register (RHR.RXCHR), and the Receiver Ready bit in the Channel Status
Register (CSR.RXRDY) is set. If RXRDY is already set, RHR will be overwritten and the Overrun
Error bit (CSR.OVRE) is set. Reading RHR will clear RXRDY, and writing a one to the Reset
Status bit in the Control Register (CR.RSTSTA) will clear OVRE.
Figure 20-9. Receiver Status
20.6.3.5 Parity
The USART supports five parity modes selected by MR.PAR. The PAR field also enables the
Multidrop mode, see ”Multidrop Mode” on page 443. If even parity is selected, the parity bit will
be a zero if there is an even number of ones in the data character, and if there is an odd number
it will be a one. For odd parity the reverse applies. If space or mark parity is chosen, the parity bit
will always be a zero or one, respectively. See Table 20-4.
D0 D1 D2 D3 D4 D5 D6 D7
RXD
Start Sampling
Parity Bit
Stop Bit
Example: 8-bit, Parity Enabled 1 Stop
Baud Rate
Clock
D0 D1 D2 D3 D4 D5 D6 D7
RXD
Start
Bit
Parity
Bit
Stop
Bit
Baud Rate
Clock
Write
CR
RXRDY
OVRE
D0 D1 D2 D3 D4 D5 D6 D7 Start
Bit
Parity
Bit
Stop
Bit
RSTSTA = 1
Read
RHR
Table 20-4. Parity Bit Examples
Alphanum
Character Hex Bin
Parity Mode
Odd Even Mark Space None
A 0x41 0100 0001 1 0 1 0 -
V 0x56 0101 0110 1 0 1 0 -
R 0x52 0101 0010 0 1 1 0 -
443
32142D–06/2013
ATUC64/128/256L3/4U
The receiver will report parity errors in CSR.PARE, unless parity is disabled. Writing a one to
CR.RSTSTA will clear PARE. See Figure 20-10
Figure 20-10. Parity Error
20.6.3.6 Multidrop Mode
If PAR is either 0x6 or 0x7, the USART runs in Multidrop mode. This mode differentiates data
and address characters. Data has the parity bit zero and addresses have a one. By writing a one
to the Send Address bit (CR.SENDA) the user will cause the next character written to THR to be
transmitted as an address. Receiving a character with a one as parity bit will set PARE.
20.6.3.7 Transmitter Timeguard
The timeguard feature enables the USART to interface slow devices by inserting an idle state on
the TXD line in between two characters. This idle state corresponds to a long stop bit, whose
duration is selected by the Timeguard Value field in the Transmitter Timeguard Register
(TTGR.TG). The transmitter will hold the TXD line high for TG bit periods, in addition to the number
of stop bits. As illustrated in Figure 20-11, the behavior of TXRDY and TXEMPTY is modified
when TG has a non-zero value. If a pending character has been written to THR, the TXRDY bit
will not be set until this characters start bit has been sent. TXEMPTY will remain low until the
timeguard transmission has completed.
Figure 20-11. Timeguard Operation
D0 D1 D2 D3 D4 D5 D6 D7
RXD
Start
Bit
Bad
Parity
Bit
Stop
Bit
Baud Rate
Clock
Write
CR
PARE
RXRDY
RSTSTA = 1
D0 D1 D2 D3 D4 D5 D6 D7
TXD
Start
Bit
Parity
Bit
Stop
Bit
Baud Rate
Clock
Start
Bit
TG = 4
Write
THR
D0 D1 D2 D3 D4 D5 D6 D7 Parity
Bit
Stop
Bit
TXRDY
TXEMPTY
TG = 4
444
32142D–06/2013
ATUC64/128/256L3/4U
Table 20-5. Maximum Baud Rate Dependent Timeguard Durations
20.6.3.8 Receiver Time-out
The Time-out Value field in the Receiver Time-out Register (RTOR.TO) enables handling of variable-length
frames by detection of selectable idle durations on the RXD line. The value written to
TO is loaded to a decremental counter, and unless it is zero, a time-out will occur when the
amount of inactive bit periods match the initial counter value. If a time-out has not occurred, the
counter will reload and restart every time a new character arrives. A time-out sets the TIMEOUT
bit in CSR. Clearing TIMEOUT can be done in two ways:
• Writing a one to the Start Time-out bit (CR.STTTO). This also aborts count down until the
next character has been received.
• Writing a one to the Reload and Start Time-out bit (CR.RETTO). This also reloads the
counter and restarts count down immediately.
Figure 20-12. Receiver Time-out Block Diagram
Table 20-6. Maximum Time-out Period
Baud Rate (bit/sec) Bit time (µs) Timeguard (ms)
1 200 833 212.50
9 600 104 26.56
14400 69.4 17.71
19200 52.1 13.28
28800 34.7 8.85
33400 29.9 7.63
56000 17.9 4.55
57600 17.4 4.43
115200 8.7 2.21
Baud Rate (bit/sec) Bit Time (µs) Time-out (ms)
600 1 667 109 225
1 200 833 54 613
2 400 417 27 306
4 800 208 13 653
16-bit Time-out
Counter
0
TO
TIMEOUT
Baud Rate
Clock
=
Character
Received
RETTO
Load
Clock
16-bit
Value
STTTO
1 D Q
Clear
445
32142D–06/2013
ATUC64/128/256L3/4U
20.6.3.9 Framing Error
The receiver is capable of detecting framing errors. A framing error has occurred if a stop bit
reads as zero. This can occur if the transmitter and receiver are not synchronized. A framing
error is reported by CSR.FRAME as soon as the error is detected, at the middle of the stop bit.
Figure 20-13. Framing Error Status
20.6.3.10 Transmit Break
When TXRDY is set, the user can request the transmitter to generate a break condition on the
TXD line by writing a one to The Start Break bit (CR.STTBRK). The break is treated as a normal
0x00 character transmission, clearing TXRDY and TXEMPTY, but with zeroes for preambles,
start, parity, stop, and time guard bits. Writing a one to the Stop Break bit (CR.STBRK) will stop
the generation of new break characters, and send ones for TG duration or at least 12 bit periods,
ensuring that the receiver detects end of break, before resuming normal operation. Figure 20-14
illustrates STTBRK and STPBRK effect on the TXD line.
Writing to STTBRK and STPBRK simultaneously can lead to unpredictable results. Writes to
THR before a pending break has started will be ignored.
9 600 104 6 827
14400 69 4 551
19200 52 3 413
28800 35 2 276
33400 30 1 962
56000 18 1 170
57600 17 1 138
200000 5 328
Baud Rate (bit/sec) Bit Time (µs) Time-out (ms)
D0 D1 D2 D3 D4 D5 D6 D7
RXD
Start
Bit
Parity
Bit
Stop
Bit
Baud Rate
Clock
Write
CR
FRAME
RXRDY
RSTSTA = 1
446
32142D–06/2013
ATUC64/128/256L3/4U
Figure 20-14. Break Transmission
20.6.3.11 Receive Break
A break condition is assumed when incoming data, parity, and stop bits are zero. This corresponds
to a framing error, but FRAME will remain zero while the Break Received/End Of Break
bit (CSR.RXBRK) is set. Writing a one to CR.RSTSTA will clear RXBRK. An end of break will
also set RXBRK, and is assumed when TX is high for at least 2/16 of a bit period in asynchronous
mode, or when a high level is sampled in synchronous mode.
20.6.3.12 Hardware Handshaking
The USART features an out-of-band hardware handshaking flow control mechanism, implementable
by connecting the RTS and CTS pins with the remote device, as shown in Figure 20-
15.
Figure 20-15. Connection with a Remote Device for Hardware Handshaking
Writing 0x2 to the MR.MODE field configures the USART to operate in this mode. The receiver
will drive its RTS pin high when disabled or when the Reception Buffer Full bit (CSR.RXBUFF) is
set by the Buffer Full signal from the Peripheral DMA controller. If the receivers RTS pin is high,
the transmitters CTS pin will also be high and only the active character transactions will be completed.
Allocating a new buffer to the DMA controller by clearing RXBUFF, will drive the RTS pin
low, allowing the transmitter to resume transmission. Detected level changes on the CTS pin
can trigger interrupts, and are reported by the CTS Input Change bit in the Channel Status Register
(CSR.CTSIC).
Figure 20-16 illustrates receiver functionality, and Figure 20-17 illustrates transmitter
functionality.
D0 D1 D2 D3 D4 D5 D6 D7
TXD
Start
Bit
Parity
Bit
Stop
Bit
Baud Rate
Clock
Write
CR
TXRDY
TXEMPTY
STTBRK = 1 STPBRK = 1
Break Transmission End of Break
USART
TXD
CTS
Remote
Device
RXD
RXD TXD
RTS
RTS
CTS
447
32142D–06/2013
ATUC64/128/256L3/4U
Figure 20-16. Receiver Behavior when Operating with Hardware Handshaking
Figure 20-17. Transmitter Behavior when Operating with Hardware Handshaking
Figure 20-18.
20.6.4 SPI Mode
The USART features a Serial Peripheral Interface (SPI) link compliant mode, supporting synchronous,
full-duplex communication, in both master and slave mode. Writing 0xE (master) or
0xF (slave) to MR.MODE will enable this mode. A SPI in master mode controls the data flow to
and from the other SPI devices, who are in slave mode. It is possible to let devices take turns
being masters (aka multi-master protocol), and one master may shift data simultaneously into
several slaves, but only one slave may respond at a time. A slave is selected when its slave
select (NSS) signal has been raised by the master. The USART can only generate one NSS signal,
and it is possible to use standard I/O lines to address more than one slave.
20.6.4.1 Modes of Operation
The SPI system consists of two data lines and two control lines:
• Master Out Slave In (MOSI): This line supplies the data shifted from master to slave. In
master mode this is connected to TXD, and in slave mode to RXD.
• Master In Slave Out (MISO): This line supplies the data shifted from slave to master. In
master mode this is connected to RXD, and in slave mode to TXD.
• Serial Clock (CLK): This is controlled by the master. One period per bit transmission. In both
modes this is connected to CLK.
• Slave Select (NSS): This control line allows the master to select or deselect a slave. In
master mode this is connected to RTS, and in slave mode to CTS.
Changing SPI mode after initial configuration has to be followed by a transceiver software reset
in order to avoid unpredictable behavior.
20.6.4.2 Baud Rate
The baud rate generator operates as described in ”Baud Rate in Synchronous and SPI Mode”
on page 439, with the following requirements:
In SPI Master Mode:
RTS
RXBUFF
Write
CR
RXEN = 1
RXD
RXDIS = 1
CTS
TXD
448
32142D–06/2013
ATUC64/128/256L3/4U
• The Clock Selection field (MR.USCLKS) must not equal 0x3 (external clock, CLK).
• The Clock Output Select bit (MR.CLKO) must be one.
• The BRGR.CD field must be at least 0x4.
• If USCLKS is one (internal divided clock, CLK_USART/DIV), the value in CD has to be even,
ensuring a 50:50 duty cycle. CD can be odd if USCLKS is zero (internal clock, CLK_USART).
In SPI Slave Mode:
• CLK frequency must be at least four times lower than the system clock.
20.6.4.3 Data Transfer
• Up to nine data bits are successively shifted out on the TXD pin at each edge. There are no
start, parity, or stop bits, and MSB is always sent first. The SPI Clock Polarity (MR.CPOL),
and SPI Clock Phase (MR.CPHA) bits configure CLK by selecting the edges upon which bits
are shifted and sampled, resulting in four non-interoperable protocol modes see Table 20-7.
A master/slave pair must use the same configuration, and the master must be reconfigured if
it is to communicate with slaves using different configurations. See Figures 20-19 and 20-20.
Figure 20-19. SPI Transfer Format (CPHA=1, 8 bits per transfer)
Table 20-7. SPI Bus Protocol Modes
SPI Bus Protocol Mode CPOL CPHA
0 01
1 00
2 11
3 10
CLK cycle (for reference)
CLK
(CPOL= 1)
MOSI
SPI Master ->TXD
SPI Slave ->RXD
MISO
SPI Master ->RXD
SPI Slave ->TXD
NSS
SPI Master ->RTS
SPI Slave ->CTS
MSB
MSB
1
CLK
(CPOL= 0)
3 5 6 7 8
4 3 2 1 LSB
6
6 5
5 4 3 2 1 LSB
2 4
449
32142D–06/2013
ATUC64/128/256L3/4U
Figure 20-20. SPI Transfer Format (CPHA=0, 8 bits per transfer)
20.6.4.4 Receiver and Transmitter Control
See ”Transmitter Operations” on page 440, and ”Receiver Operations” on page 442.
20.6.4.5 Character Transmission and Reception
In SPI master mode, the slave select line (NSS) is asserted low one bit period before the start of
transmission, and released high one bit period after every character transmission. A delay for at
least three bit periods is always inserted in between characters. In order to address slave
devices supporting the Chip Select Active After Transfer (CSAAT) mode, NSS can be forced low
by writing a one to the Force SPI Chip Select bit (CR.RTSEN/FCS). Releasing NSS when FCS
is one, is only possible by writing a one to the Release SPI Chip Select bit (CR.RTSDIS/RCS).
In SPI slave mode, a low level on NSS for at least one bit period will allow the slave to initiate a
transmission or reception. The Underrun Error bit (CSR.UNRE) is set if a character must be sent
while THR is empty, and TXD will be high during character transmission, as if 0xFF was being
sent. If a new character is written to THR it will be sent correctly during the next transmission
slot. Writing a one to CR.RSTSTA will clear UNRE. To ensure correct behavior of the receiver in
SPI slave mode, the master device sending the frame must ensure a minimum delay of one bit
period in between each character transmission.
20.6.4.6 Receiver Time-out
Receiver Time-out’s are not possible in SPI mode as the baud rate clock is only active during
data transfers.
20.6.5 LIN Mode
The USART features a LIN (Local Interconnect Network) 1.3 and 2.0 compliant mode, embedding
full error checking and reporting, automatic frame processing with up to 256 data bytes,
CLK cycle (for reference)
CLK
(CPOL= 0)
CLK
(CPOL= 1)
MOSI
SPI Master -> TXD
SPI Slave -> RXD
MISO
SPI Master -> RXD
SPI Slave -> TXD
NSS
SPI Master -> RTS
SPI Slave -> CTS
MSB 6 5
MSB 6 5
4
4 3
3 2
2 1
1 LSB
LSB
1 2 3 4 5 6 7 8
450
32142D–06/2013
ATUC64/128/256L3/4U
customizable response data lengths, and requires minimal CPU resources. Writing 0xA (master)
or 0xB (slave) to MR.MODE enables this mode.
20.6.5.1 Modes of operation
Changing LIN mode after initial configuration has to be followed by a transceiver software reset
in order to avoid unpredictable behavior.
20.6.5.2 Receiver and Transmitter Control
See Section “20.6.2” on page 439.
20.6.5.3 Baud Rate Configuration
The LIN nodes baud rate is configured in the Baud Rate Generator Register (BRGR), See Section
“20.6.1.1” on page 437.
20.6.5.4 Character Transmission and Reception
See ”Transmitter Operations” on page 440, and ”Receiver Operations” on page 442.
20.6.5.5 Header Transmission (Master Node Configuration)
All LIN frames start with a header sent by the master. As soon as the identifier has been written
to the Identifier Character field in the LIN Identifier Register (LINIR.IDCHR), TXRDY is cleared
and the header is sent. The header consists of a Break, Sync, and Identifier field. TXRDY is set
when the identifier has been transferred into the transmitters shift register.
The Break field consists of 13 dominant bits, the break, and one recessive bit, the break delimiter.
The Sync field is the character 0x55. The Identifier field contains the Identifier as written to
IDCHR. The identifier parity bits can be generated automatically (see Section 20.6.5.8).
Figure 20-21. Header Transmission
20.6.5.6 Header Reception (Slave Node Configuration)
The USART stays idle until it detects a break field, consisting of at least 11 consecutive dominant
bits (zeroes) on the bus. A received break will set the Lin Break bit (CSR.LINBK). The Sync
field is used to synchronize the baud rate (see Section 20.6.5.7). IDCHR is updated and the LIN
Identifier bit (CSR.LINID) is set when the Identifier has been received. The Identifier parity bits
can be automatically checked (see Section 20.6.5.8). Writing a one to RSTSTA will clear LINBK
and LINID.
TXD
Baud Rate
Clock
Start
Bit
Write
LINIR
10101010
TXRDY
Stop
Bit
Start
Bit Break Field ID0 ID1 ID2 ID3 ID4 ID5 ID6 ID7
13 dominant bits (at 0)
Stop
Bit
Break
Delimiter
1 recessive bit
(at 1)
Synch Byte = 0x55
LINIR ID
451
32142D–06/2013
ATUC64/128/256L3/4U
Figure 20-22. Header Reception
20.6.5.7 Slave Node Synchronization
Synchronization is only done by the slave. If the Sync field is not 0x55, an Inconsistent Sync
Field error (CSR.LINISFE) is generated. The time between falling edges is measured by a 19-bit
counter, driven by the sampling clock (see Section 20.6.1).
Figure 20-23. Sync Field
The counter starts when the Sync field start bit is detected, and continues for eight bit periods.
The 16 most significant bits (counter value divided by 8) becomes the new clock divider
(BRGR.CD), and the three least significant bits (the remainder) becomes the new fractional part
(BRGR.FP).
Figure 20-24. Slave Node Synchronization
The synchronization accuracy depends on:
• The theoretical slave node clock frequency; nominal clock frequency (FNom)
• The baud rate
Break Field
13 dominant bits (at 0)
Break
Delimiter
1 recessive bit
(at 1)
Start
Bit 10101010 Stop
Bit
Start
Bit ID0 ID1 ID2 ID4 ID3 ID6 ID5 ID7 Stop
Bit
Synch Byte = 0x55
Baud Rate
Clock
RXD
Write US_CR
With RSTSTA=1
US_LINIR
LINID
Start
bit
Stop
bit
Synch Field
8 Tbit
2 Tbit 2 Tbit 2 Tbit 2 Tbit
RXD
Baud Rate
Clock
LINIDRX
Synchro Counter 000_0011_0001_0110_1101
BRGR
Clcok Divider (CD)
0000_0110_0010_1101
BRGR
Fractional Part (FP)
101
Initial CD
Initial FP
Reset
Start
Bit 10101010 Stop
Bit
Start
Bit Break Field ID0 ID1 ID2 ID3 ID4 ID5 ID6 ID7
13 dominant bits (at 0)
Stop
Bit
Break
Delimiter
1 recessive bit
(at 1)
Synch Byte = 0x55
452
32142D–06/2013
ATUC64/128/256L3/4U
• The oversampling mode (OVER=0 => 16x, or OVER=1 => 8x)
The following formula is used to calculate synchronization deviation, where FSLAVE is the real
slave node clock frequency, and FTOL_UNSYNC is the difference between FNom and FSLAVE According
to the LIN specification, FTOL_UNSYNCH may not exceed ±15%, and the bit rates between two
nodes must be within ±2% of each other, resulting in a maximal BaudRate_deviation of ±1%.
Minimum nominal clock frequency with a fractional part:
Examples:
• Baud rate = 20 kbit/s, OVER=0 (Oversampling 16x) => FNom(min) = 2.64 MHz
• Baud rate = 20 kbit/s, OVER=1 (Oversampling 8x) => FNom(min) = 1.47 MHz
• Baud rate = 1 kbit/s, OVER=0 (Oversampling 16x) => FNom(min) = 132 kHz
• Baud rate = 1 kbit/s, OVER=1 (Oversampling 8x) => FNom(min) = 74 kHz
If the fractional part is not used, the synchronization accuracy is much lower. The 16 most significant
bits, added with the first least significant bit, becomes the new clock divider (CD). The
equation of the baud rate deviation is the same as above, but the constants are:
Minimum nominal clock frequency without a fractional part:
Examples:
• Baud rate = 20 kbit/s, OVER=0 (Oversampling 16x) => FNom(min) = 19.12 MHz
• Baud rate = 20 kbit/s, OVER=1 (Oversampling 8x) => FNom(min) = 9.71 MHz
• Baud rate = 1 kbit/s, OVER=0 (Oversampling 16x) => FNom(min) = 956 kHz
• Baud rate = 1 kbit/s, OVER=1 (Oversampling 8x) => FNom(min) = 485 kHz
20.6.5.8 Identifier Parity
An identifier field consists of two sub-fields; the identifier and its parity. Bits 0 to 5 are assigned
to the identifier, while bits 6 and 7 are assigned to parity. Automatic parity management is disabled
by writing a one to the Parity Disable bit in the LIN Mode register (LINMR.PARDIS).
BaudRate_deviation 100 8 2 OVER – + BaudRate
8 FSLAVE -------------------------------------------------------------------------------------------------- = %
BaudRate_deviation 100 8 2 OVER – + BaudRate
8
FTOL_UNSYNC
100 ----------------------------------- xFNom
--------------------------------------------------------------------------------------------------
= %
–0.5 +0.5 -1 +1
FNom min 100 0.5 8 2 OVER – + 1 BaudRate
8 –15
100
--------- + 1 1%
------------------------------------------------------------------------------------------------------
= Hz
–4 +4 -1 +1
FNom min 100 4 8 2 OVER – + 1 Baudrate
8 –15
100
--------- + 1 1%
-----------------------------------------------------------------------------------------------
= Hz
453
32142D–06/2013
ATUC64/128/256L3/4U
• PARDIS=0: During header transmission, the parity bits are computed and in the shift register
they replace bits six and seven from IDCHR. During header reception, the parity bits are
checked and can generate a LIN Identifier Parity Error (see Section 20.6.6). Bits six and
seven in IDCHR read as zero when receiving.
• PARDIS=1: During header transmission, all the bits in IDCHR are sent on the bus. During
header reception, all the bits in IDCHR are updated with the received Identifier.
20.6.5.9 Node Action
After an identifier transaction, a LIN response mode has to be selected. This is done in the Node
Action field (LINMR.NACT). Below are some response modes exemplified in a small LIN cluster:
• Response, from master to slave1:
Master: NACT=PUBLISH
Slave1: NACT=SUBSCRIBE
Slave2: NACT=IGNORE
• Response, from slave1 to master:
Master: NACT=SUBSCRIBE
Slave1: NACT=PUBLISH
Slave2: NACT=IGNORE
• Response, from slave1 to slave2:
Master: NACT=IGNORE
Slave1: NACT=PUBLISH
Slave2: NACT=SUBSCRIBE
20.6.5.10 LIN Response Data Length
The response data length is the number of data fields (bytes), excluding the checksum.
Figure 20-25. Response Data Length
The response data length can be configured, either by the user, or automatically by bits 4 and 5
in the Identifier (IDCHR), in accordance to LIN 1.1. The user selects mode by writing to the Data
Length Mode bit (LINMR.DML):
• DLM=0: the response data length is configured by the user by writing to the 8-bit Data Length
Control field (LINMR.DLC). The response data length equals DLC + 1 bytes.
User configuration: 1 - 256 data fields (DLC+1)
Identifier configuration: 2/4/8 data fields
Sync
Break
Sync
Field
Identifier
Field
Checksum
Field
Data
Field
Data
Field
Data
Field
Data
Field
454
32142D–06/2013
ATUC64/128/256L3/4U
• DLM=1: the response data length is defined by the Identifier bits according to the table below.
20.6.5.11 Checksum
The last frame field is the checksum. It is configured by the Checksum Type (LINMR.CHKTYP),
and the Checksum Disable (LINMR.CHKDIS) bits. TXRDY will not be set after the last THR data
write if enabled. Writing a one to CHKDIS will disable the automatic checksum generation/checking,
and the user may send/check this last byte manually, disguised as a normal data.
The checksum is an inverted 8-bit sum with carry, either:
• over all data bytes, called a classic checksum. This is used for LIN 1.3 compliant slaves, and
automatically managed when CHKDIS=0, and CHKTYP=1.
• over all data bytes and the protected identifier, called an enhanced checksum. This is used
for LIN 2.0 compliant slaves, and automatically managed when CHKDIS=0, and CHKTYP=0.
20.6.5.12 Frame Slot Mode
A LIN master can be configured to use frame slots with a pre-defined minimum length. Writing a
one to the Frame Slot Mode Disable bit (LINMR.FSDIS) disables this mode. This mode will not
allow TXRDY to be set after a frame transfer until the entire frame slot duration has elapsed, in
effect preventing the master from sending a new header. The LIN Transfer Complete bit
(CSR.LINTC) will still be set after the checksum has been sent. Writing a one to CR.RSTST
clears LINTC.
Figure 20-26. Frame Slot Mode with Automatic Checksum
The minimum frame slot size is determined by TFrame_Maximum, and calculated below (all values
in bit periods):
• THeader_Nominal = 34
Table 20-8. Response Data Length if DLM = 1
IDCHR[5] IDCHR[4] Response Data Length [bytes]
00 2
01 2
10 4
11 8
Break Synch Protected
Identifier
Data N Checksum
Header
Interframe
space Response
space
Frame
Frame slot = TFrame_Maximum
Response
TXRDY
Write
THR
Write
LINID
Data 1 Data 2 Data 3
Data3
Data N-1
Data N
Frame Slot Mode
Disabled
Frame Slot Mode
Enabled
LINTC
Data 1
455
32142D–06/2013
ATUC64/128/256L3/4U
• TFrame_Maximum = 1.4 x (THeader_Nominal + TResponse_Nominal + 1)(Note:)
Note: The term “+1” leads to an integer result for TFrame_Max (LIN Specification 1.3)
If the Checksum is sent (CHKDIS=0):
• TResponse_Nominal = 10 x (NData + 1)
• TFrame_Maximum = 1.4 x (34 + 10 x (DLC + 1 + 1) + 1)
• TFrame_Maximum = 77 + 14 x DLC
If the Checksum is not sent (CHKDIS=1):
• TResponse_Nominal = 10 x NData
• TFrame_Maximum = 1.4 x (34 + 10 x (DLC + 1) + 1)
• TFrame_Maximum = 63 + 14 x DLC
20.6.6 LIN Errors
These error bits are cleared by writing a one to CSR.RSTSTA.
20.6.6.1 Slave Not Responding Error (CSR.LINSNRE)
This error is generated if no valid message appears within the TFrame_Maximum time frame
slot, while the USART is expecting a response from another node (NACT=SUBSCRIBE).
20.6.6.2 Checksum Error (CSR.LINCE)
This error is generated if the received checksum is wrong. This error can only be generated if the
checksum feature is enabled (CHKDIS=0).
20.6.6.3 Identifier Parity Error (CSR.LINIPE)
This error is generated if the identifier parity is wrong. This error can only be generated if parity is
enabled (PARDIS=0).
20.6.6.4 Inconsistent Sync Field Error (CSR.LINISFE)
This error is generated in slave mode if the Sync Field character received is not 0x55. Synchronization
procedure is aborted.
20.6.6.5 Bit Error (CSR.LINBE)
This error is generated if the value transmitted by the USART on Tx differs from the value sampled
on Rx. If a bit error is detected, the transmission is aborted at the next byte border.
20.6.7 LIN Frame Handling
20.6.7.1 Master Node Configuration
• Write a one to CR.TXEN and CR.RXEN to enable both transmitter and receiver
• Select LIN mode and master node by writing to MR.MODE
• Configure the baud rate by writing to CD and FP in BRGR
• Configure the frame transfer by writing to NACT, PARDIS, CHKDIS, CHKTYPE, DLCM,
FSDIS, and DLC in LINMR
• Check that CSR.TXRDY is one
• Send the header by writing to LINIR.IDCHR
The following procedure depends on the NACT setting:
456
32142D–06/2013
ATUC64/128/256L3/4U
• Case 1: NACT=PUBLISH, the USART sends a response
– Wait until TXRDY is a one
– Send a byte by writing to THR.TXCHR
– Repeat the two previous steps until there is no more data to send
– Wait until CSR.LINTC is a one
– Check for LIN errors
• Case 2: NACT=SUBSCRIBE, the USART receives a response
– Wait until RXRDY is a one
– Read RHR.RXCHR
– Repeat the two previous steps until there is no more data to read
– Wait until LINTC is a one
– Check for LIN errors
• Case 3: NACT=IGNORE, the USART is not concerned by a response
– Wait until LINTC is a one
– Check for LIN errors
Figure 20-27. Master Node Configuration, NACT=PUBLISH
Frame
Break Synch Protected
Identifier
Data 1 Data N Checksum
TXRDY
Write
THR
Write
LINIR
Data 1 Data 2 Data 3
Data N-1
Data N
RXRDY
Header
Interframe
space Response
space
Frame slot = TFrame_Maximum
Data3 Response
LINTC
FSDIS=1 FSDIS=0
457
32142D–06/2013
ATUC64/128/256L3/4U
Figure 20-28. Master Node Configuration, NACT=SUBSCRIBE
Figure 20-29. Master Node Configuration, NACT=IGNORE
20.6.7.2 Slave Node Configuration
This is identical to the master node configuration above, except for:
• LIN mode selected in MR.MODE is slave
• When the baud rate is configured, wait until CSR.LINID is a one, then;
• Check for LINISFE and LINPE errors, clear errors and LINIDby writing a one to RSTSTA
• Read IDCHR
• Configure the frame transfer by writing to NACT, PARDIS, CHKDIS, CHKTYPE, DLCM, and
DLC in LINMR
IMPORTANT: if NACT=PUBLISH, and this field is already correct, the LINMR register must still
be written with this value in order to set TXRDY, and to request the corresponding Peripheral
DMA Controller write transfer.
The different NACT settings result in the same procedure as for the master node, see page 455.
Break Synch Protected
Identifier
Data 1 Data N Checksum
TXRDY
Read
RHR
Write
LINIR
Data 1
Data N-1
Data N-1
RXRDY
Data N-2 Data N
Header
Interframe
Response space
space
Frame
Frame slot = TFrame_Maximum
Data3 Response
LINTC
FSDIS=1 FSDIS=0
TXRDY
Write
LINIR
RXRDY
LINTC
Break Synch Protected
Identifier
Data 1 Data N-1 Data N Checksum
Header
Interframe
Response space
space
Frame
Frame slot = TFrame_Maximum
Data3 Response
FSDIS=1 FSDIS=0
458
32142D–06/2013
ATUC64/128/256L3/4U
Figure 20-30. Slave Node Configuration, NACT=PUBLISH
Figure 20-31. Slave Node Configuration, NACT=SUBSCRIBE
Figure 20-32. Slave Node Configuration, NACT=IGNORE
20.6.8 LIN Frame Handling With The Peripheral DMA Controller
The USART can be used together with the Peripheral DMA Controller in order to transfer data
without processor intervention. The DMA Controller uses the TXRDY and RXRDY bits, to trigger
one byte writes or reads. It always writes to THR, and it always reads RHR.
Break Synch Protected
Identifier
Data 1 Data N Checksum
TXRDY
Write
THR
Read
LINID
Data 1 Data 3
Data N-1
Data N
RXRDY
LINIDRX
Data 2
LINTC
TXRDY
Read
RHR
Read
LINID
RXRDY
LINIDRX
LINTC
Break Synch Protected
Identifier
Data 1 Data N Checksum
Data 1
Data N-1
Data N-2 Data N-1 Data N
TXRDY
Read
RHR
Read
LINID
RXRDY
LINIDRX
LINTC
Break Synch Protected
Identifier
Data 1 Data N Checksum Data N-1
459
32142D–06/2013
ATUC64/128/256L3/4U
20.6.8.1 Master Node Configuration
The Peripheral DMA Controller Mode bit (LINMR.PDCM) allows the user to select configuration:
• PDCM=0: LIN configuration must be written to LINMR, it is not stored in the write buffer.
• PDCM=1: LIN configuration is written by the DMA Controller to THR, and is stored in the
write buffer. Since data transfer size is a byte, the transfer is split into two accesses. The first
writes the NACT, PARDIS, CHKDIS, CHKTYP, DLM and FSDIS bits, while the second writes
the DLC field. If NACT=PUBLISH, the write buffer will also contain the Identifier.
When NACT=SUBSCRIBE, the read buffer contains the data.
Figure 20-33. Master Node with Peripheral DMA Controller (PDCM=0)
Figure 20-34. Master Node with Peripheral DMA Controller (PDCM=1)
|
|
|
|
RXRDY
TXRDY
Peripheral
bus
USART LIN
CONTROLLER
DATA 0
DATA N
|
|
|
|
READ BUFFER
NODE ACTION = PUBLISH NODE ACTION = SUBSCRIBE
Peripheral DMA
Controller
RXRDY
Peripheral
bus
DATA 0
DATA 1
DATA N
WRITE BUFFER
Peripheral DMA
Controller
USART LIN
CONTROLLER
|
|
|
|
|
|
|
|
NACT
PARDIS
CHKDIS
CHKTYP DLM
FSDIS
DLC
IDENTIFIER
DATA 0
DATA N
WRITE BUFFER
RXRDY
Peripheral
bus
DLC
IDENTIFIER
DATA 0
DATA N
WRITE BUFFER
RXRDY READ BUFFER
NODE ACTION = PUBLISH NODE ACTION = SUBSCRIBE
Peripheral DMA
Controller
Peripheral DMA
Controller
USART LIN
CONTROLLER
NACT
PARDIS
CHKDIS
CHKTYP DLM
FSDIS
USART LIN
CONTROLLER
TXRDY
Peripheral
bus
460
32142D–06/2013
ATUC64/128/256L3/4U
20.6.8.2 Slave Node Configuration
In this mode, the Peripheral DMA Controller transfers only data. The user reads the Identifier
from LINIR, and selects LIN mode by writing to LINMR. When NACT=PUBLISH the data is in the
write buffer, while the read buffer contains the data when NACT=SUBSCRIBE.
IMPORTANT: if in slave mode, NACT is already configured correctly as PUBLISH, the LINMR
register must still be written with this value in order to set TXRDY, and to request the corresponding
Peripheral DMA Controller write transfer.
Figure 20-35. Slave Node with Peripheral DMA Controller
20.6.9 Wake-up Request
Any node in a sleeping LIN cluster may request a wake-up. By writing to the Wakeup Signal
Type bit (LINMR.WKUPTYP), the user can choose to send either a LIN 1.3 (WKUPTYP=1), or a
LIN 2.0 (WKUPTYP=0) compliant wakeup request. Writing a one to the Send LIN Wakeup Signal
bit (CR.LINWKUP), transmits a wakeup, and when completed sets LINTC.
According to LIN 1.3, the wakeup request should be generated with the character 0x80 in order
to impose eight successive dominant bits.
According to LIN 2.0, the wakeup request is issued by forcing the bus into the dominant state for
250µs to 5ms. Sending the character 0xF0 does this, regardless of baud rate.
• Baud rate max = 20 kbit/s -> one bit period = 50µs -> five bit periods = 250µs
• Baud rate min = 1 kbit/s -> one bit period = 1ms -> five bit periods = 5ms
20.6.10 Bus Idle Time-out
LIN bus inactivity should eventually cause slaves to time-out and enter sleep mode. LIN 1.3
specifies this to 25000 bit periods, whilst LIN 2.0 specifies 4seconds. For the time-out counter
operation see Section 20.6.3.8 ”Receiver Time-out” on page 444.
|
|
|
|
|
|
|
|
DATA 0
DATA N
RXRDY
Peripheral
Bus
READ BUFFER
NACT = SUBSCRIBE DATA 0
DATA N
TXRDY
Peripheral
bus
WRITE BUFFER
USART LIN
CONTROLLER
USART LIN
CONTROLLER
Peripheral DMA
Controller
Peripheral DMA
Controller
Table 20-9. Receiver Time-out Values (RTOR.TO)
LIN Specification Baud Rate Time-out period TO
2.0
1 000 bit/s
4s
4 000
2 400 bit/s 9 600
9 600 bit/s 38 400
19 200 bit/s 76 800
20 000 bit/s 80 000
1.3 - 25 000 bit periods 25 000
461
32142D–06/2013
ATUC64/128/256L3/4U
20.6.11 Test Modes
The internal loopback feature enables on-board diagnostics, and allows the USART to operate
in three different test modes, with reconfigured pin functionality, as shown below.
20.6.11.1 Normal Mode
During normal operation, a receivers RXD pin is connected to a transmitters TXD pin.
Figure 20-36. Normal Mode Configuration
20.6.11.2 Automatic Echo Mode
Automatic echo mode allows bit-by-bit retransmission. When a bit is received on the RXD pin, it
is also sent to the TXD pin, as shown in Figure 20-37. Transmitter configuration has no effect.
Figure 20-37. Automatic Echo Mode Configuration
20.6.11.3 Local Loopback Mode
Local loopback mode connects the output of the transmitter directly to the input of the receiver,
as shown in Figure 20-38. The TXD and RXD pins are not used. The RXD pin has no effect on
the receiver and the TXD pin is continuously driven high, as in idle state.
Figure 20-38. Local Loopback Mode Configuration
20.6.11.4 Remote Loopback Mode
Remote loopback mode connects the RXD pin to the TXD pin, as shown in Figure 20-39. The
transmitter and the receiver are disabled and have no effect. This mode allows bit-by-bit
retransmission.
Receiver
Transmitter
RXD
TXD
Receiver
Transmitter
RXD
TXD
Receiver
Transmitter
RXD
TXD
1
462
32142D–06/2013
ATUC64/128/256L3/4U
Figure 20-39. Remote Loopback Mode Configuration
20.6.12 Write Protection Registers
To prevent single software errors from corrupting USART behavior, certain address spaces can
be write-protected by writing the correct Write Protect KEY and a one to the Write Protect
Enable bit in the Write Protect Mode Register (WPMR.WPKEY, and WPMR.WPEN). Disabling
the write protection is done by writing the correct key, and a zero to WPEN.
Write attempts to a write protected register are detected and the Write Protect Violation Status
bit in the Write Protect Status Register (WPSR.WPVS) is set, while the Write Protect Violation
Source field (WPSR.WPVSRC) indicates the targeted register. Writing the correct key to the
Write Protect KEY bit (WPMR.WPKEY) clears WPVSRC and WPVS.
The protected registers are:
• ”Mode Register” on page 466
• ”Baud Rate Generator Register” on page 476
• ”Receiver Time-out Register” on page 477
• ”Transmitter Timeguard Register” on page 478
Receiver
Transmitter
RXD
TXD
1
463
32142D–06/2013
ATUC64/128/256L3/4U
20.7 User Interface
Note: 1. Values in the Version Register vary with the version of the IP block implementation.
Table 20-10. USART Register Memory Map
Offset Register Name Access Reset
0x0000 Control Register CR Write-only 0x00000000
0x0004 Mode Register MR Read-write 0x00000000
0x0008 Interrupt Enable Register IER Write-only 0x00000000
0x000C Interrupt Disable Register IDR Write-only 0x00000000
0x0010 Interrupt Mask Register IMR Read-only 0x00000000
0x0014 Channel Status Register CSR Read-only 0x00000000
0x0018 Receiver Holding Register RHR Read-only 0x00000000
0x001C Transmitter Holding Register THR Write-only 0x00000000
0x0020 Baud Rate Generator Register BRGR Read-write 0x00000000
0x0024 Receiver Time-out Register RTOR Read-write 0x00000000
0x0028 Transmitter Timeguard Register TTGR Read-write 0x00000000
0x0054 LIN Mode Register LINMR Read-write 0x00000000
0x0058 LIN Identifier Register LINIR Read-write 0x00000000
0x00E4 Write Protect Mode Register WPMR Read-write 0x00000000
0x00E8 Write Protect Status Register WPSR Read-only 0x00000000
0x00FC Version Register VERSION Read-only 0x–(1)
464
32142D–06/2013
ATUC64/128/256L3/4U
20.7.1 Control Register
Name: CR
Access Type: Write-only
Offset: 0x0
Reset Value: 0x00000000
• LINWKUP: Send LIN Wakeup Signal
Writing a zero to this bit has no effect.
Writing a one to this bit will sends a wakeup signal on the LIN bus.
• LINABT: Abort LIN Transmission
Writing a zero to this bit has no effect.
Writing a one to this bit will abort the current LIN transmission.
• RTSDIS/RCS: Request to Send Disable/Release SPI Chip Select
Writing a zero to this bit has no effect.
Writing a one to this bit when USART is not in SPI master mode drives RTS pin high.
Writing a one to this bit when USART is in SPI master mode releases NSS (RTS pin).
• RTSEN/FCS: Request to Send Enable/Force SPI Chip Select
Writing a zero to this bit has no effect.
Writing a one to this bit when USART is not in SPI master mode drives RTS low.
Writing a one to this bit when USART is in SPI master mode when;
FCS=0: has no effect.
FCS=1: forces NSS (RTS pin) low, even if USART is not transmitting, in order to address SPI slave devices supporting the
CSAAT Mode (Chip Select Active After Transfer).
• RETTO: Rearm Time-out
Writing a zero to this bit has no effect.
Writing a one to this bit reloads the time-out counter and clears CSR.TIMEOUT.
• RSTNACK: Reset Non Acknowledge
Writing a zero to this bit has no effect.
Writing a one to this bit clears CSR.NACK.
• SENDA: Send Address
Writing a zero to this bit has no effect.
Writing a one to this bit will in multidrop mode send the next character written to THR as an address.
• STTTO: Start Time-out
Writing a zero to this bit has no effect.
Writing a one to this bit will abort any current time-out count down, and trigger a new count down when the next character has
been received. CSR.TIMEOUT is also cleared.
31 30 29 28 27 26 25 24
––––––––
23 22 21 20 19 18 17 16
– – LINWKUP LINABT RTSDIS/RCS RTSEN/FCS – –
15 14 13 12 11 10 9 8
RETTO RSTNACK – SENDA STTTO STPBRK STTBRK RSTSTA
76543210
TXDIS TXEN RXDIS RXEN RSTTX RSTRX – –
465
32142D–06/2013
ATUC64/128/256L3/4U
• STPBRK: Stop Break
Writing a zero to this bit has no effect.
Writing a one to this bit will stop the generation of break signal characters, and then send ones for TTGR.TG duration, or at least
12 bit periods. No effect if no break is being transmitted.
• STTBRK: Start Break
Writing a zero to this bit has no effect.
Writing a one to this bit will start transmission of break characters when current characters present in THR and the transmit shift
register have been sent. No effect if a break signal is already being generated.
• RSTSTA: Reset Status Bits
Writing a zero to this bit has no effect.
Writing a one to this bit will clear the following bits in CSR: PARE, FRAME, OVRE, LINBE, LINSFE, LINIPE, LINCE, LINSNRE,
and RXBRK.
• TXDIS: Transmitter Disable
Writing a zero to this bit has no effect.
Writing a one to this bit disables the transmitter.
• TXEN: Transmitter Enable
Writing a zero to this bit has no effect.
Writing a one to this bit enables the transmitter if TXDIS is zero.
• RXDIS: Receiver Disable
Writing a zero to this bit has no effect.
Writing a one to this bit disables the receiver.
• RXEN: Receiver Enable
Writing a zero to this bit has no effect.
Writing a one to this bit enables the receiver if RXDIS is zero.
• RSTTX: Reset Transmitter
Writing a zero to this bit has no effect.
Writing a one to this bit will reset the transmitter.
• RSTRX: Reset Receiver
Writing a zero to this bit has no effect.
Writing a one to this bit will reset the receiver.
466
32142D–06/2013
ATUC64/128/256L3/4U
20.7.2 Mode Register
Name: MR
Access Type: Read-write
Offset: 0x4
Reset Value: 0x00000000
This register can only be written if the WPEN bit is cleared in the Write Protect Mode Register.
• INACK: Inhibit Non Acknowledge
0: The NACK is generated.
1: The NACK is not generated.
• OVER: Oversampling Mode
0: Oversampling at 16 times the baud rate.
1: Oversampling at 8 times the baud rate.
• CLKO: Clock Output Select
0: The USART does not drive the CLK pin.
1: The USART drives the CLK pin unless USCLKS selects the external clock.
• MODE9: 9-bit Character Length
0: CHRL defines character length.
1: 9-bit character length.
• MSBF/CPOL: Bit Order or SPI Clock Polarity
If USART does not operate in SPI Mode:
MSBF=0: Least Significant Bit is sent/received first.
MSBF=1: Most Significant Bit is sent/received first.
If USART operates in SPI Mode, CPOL is used with CPHA to produce the required clock/data relationship between devices.
CPOL=0: The inactive state value of CLK is logic level zero.
CPOL=1: The inactive state value of CLK is logic level one.
31 30 29 28 27 26 25 24
––––– –
23 22 21 20 19 18 17 16
– – – INACK OVER CLKO MODE9 MSBF/CPOL
15 14 13 12 11 10 9 8
CHMODE NBSTOP PAR SYNC/CPHA
76543210
CHRL USCLKS MODE
467
32142D–06/2013
ATUC64/128/256L3/4U
• CHMODE: Channel Mode
• NBSTOP: Number of Stop Bits
• PAR: Parity Type
• SYNC/CPHA: Synchronous Mode Select or SPI Clock Phase
If USART does not operate in SPI Mode (MODE is 0xE and 0xF):
SYNC = 0: USART operates in Asynchronous Mode.
SYNC = 1: USART operates in Synchronous Mode.
If USART operates in SPI Mode, CPHA determines which edge of CLK causes data to change and which edge causes data to
be captured. CPHA is used with CPOL to produce the required clock/data relationship between master and slave devices.
CPHA = 0: Data is changed on the leading edge of CLK and captured on the following edge of CLK.
CPHA = 1: Data is captured on the leading edge of CLK and changed on the following edge of CLK.
Table 20-11.
CHMODE Mode Description
0 0 Normal Mode
0 1 Automatic Echo. Receiver input is connected to the TXD pin.
1 0 Local Loopback. Transmitter output is connected to the Receiver input.
1 1 Remote Loopback. RXD pin is internally connected to the TXD pin.
Table 20-12.
NBSTOP Asynchronous (SYNC=0) Synchronous (SYNC=1)
0 0 1 stop bit 1 stop bit
0 1 1.5 stop bits Reserved
1 0 2 stop bits 2 stop bits
1 1 Reserved Reserved
Table 20-13.
PAR Parity Type
0 0 0 Even parity
0 0 1 Odd parity
0 1 0 Parity forced to 0 (Space)
0 1 1 Parity forced to 1 (Mark)
1 0 x No parity
1 1 x Multidrop mode
468
32142D–06/2013
ATUC64/128/256L3/4U
• CHRL: Character Length.
• USCLKS: Clock Selection
Note: 1. The value of DIV is device dependent. Please refer to the Module Configuration section at the end of this chapter.
• MODE
Table 20-14.
CHRL Character Length
0 0 5 bits
0 1 6 bits
1 0 7 bits
1 1 8 bits
Table 20-15.
USCLKS Selected Clock
0 0 CLK_USART
0 1 CLK_USART/DIV(1)
1 0 Reserved
1 1 CLK
Table 20-16.
MODE Mode of the USART
0 0 0 0 Normal
0 0 1 0 Hardware Handshaking
1 0 1 0 LIN Master
1 0 1 1 LIN Slave
1 1 1 0 SPI Master
1 1 1 1 SPI Slave
Others Reserved
469
32142D–06/2013
ATUC64/128/256L3/4U
20.7.3 Interrupt Enable Register
Name: IER
Access Type: Write-only
Offset: 0x8
Reset Value: 0x00000000
Writing a zero to a bit in this register has no effect.
Writing a one to a bit in this register will set the corresponding bit in IMR.
31 30 29 28 27 26 25 24
– – LINSNRE LINCE LINIPE LINISFE LINBE –
23 22 21 20 19 18 17 16
– – – – CTSIC – – –
15 14 13 12 11 10 9 8
LINTC LINID NACK/LINBK RXBUFF – ITER/UNRE TXEMPTY TIMEOUT
76543210
PARE FRAME OVRE – – RXBRK TXRDY RXRDY
470
32142D–06/2013
ATUC64/128/256L3/4U
20.7.4 Interrupt Disable Register
Name: IDR
Access Type: Write-only
Offset: 0xC
Reset Value: 0x00000000
Writing a zero to a bit in this register has no effect.
Writing a one to a bit in this register will clear the corresponding bit in IMR.
31 30 29 28 27 26 25 24
– – LINSNRE LINCE LINIPE LINISFE LINBE –
23 22 21 20 19 18 17 16
– – – – CTSIC – – –
15 14 13 12 11 10 9 8
LINTC LINID NACK/LINBK RXBUFF – ITER/UNRE TXEMPTY TIMEOUT
76543210
PARE FRAME OVRE – – RXBRK TXRDY RXRDY
471
32142D–06/2013
ATUC64/128/256L3/4U
20.7.5 Interrupt Mask Register
Name: IMR
Access Type: Read-only
Offset: 0x10
Reset Value: 0x00000000
0: The corresponding interrupt is disabled.
1: The corresponding interrupt is enabled.
A bit in this register is cleared when the corresponding bit in IDR is written to one.
A bit in this register is set when the corresponding bit in IER is written to one.
31 30 29 28 27 26 25 24
– – LINSNRE LINCE LINIPE LINISFE LINBE –
23 22 21 20 19 18 17 16
– – – – CTSIC – – –
15 14 13 12 11 10 9 8
LINTC LINID NACK/LINBK RXBUFF – ITER/UNRE TXEMPTY TIMEOUT
76543210
PARE FRAME OVRE – – RXBRK TXRDY RXRDY
472
32142D–06/2013
ATUC64/128/256L3/4U
20.7.6 Channel Status Register
Name: CSR
Access Type: Read-only
Offset: 0x14
Reset Value: 0x00000000
• LINSNRE: LIN Slave Not Responding Error
0: No LIN Slave Not Responding Error has been detected since the last RSTSTA.
1: A LIN Slave Not Responding Error has been detected since the last RSTSTA.
• LINCE: LIN Checksum Error
0: No LIN Checksum Error has been detected since the last RSTSTA.
1: A LIN Checksum Error has been detected since the last RSTSTA.
• LINIPE: LIN Identifier Parity Error
0: No LIN Identifier Parity Error has been detected since the last RSTSTA.
1: A LIN Identifier Parity Error has been detected since the last RSTSTA.
• LINISFE: LIN Inconsistent Sync Field Error
0: No LIN Inconsistent Sync Field Error has been detected since the last RSTSTA
1: The USART is configured as a Slave node and a LIN Inconsistent Sync Field Error has been detected since the last RSTSTA.
• LINBE: LIN Bit Error
0: No Bit Error has been detected since the last RSTSTA.
1: A Bit Error has been detected since the last RSTSTA.
• CTS: Image of CTS Input
0: CTS is low.
1: CTS is high.
• CTSIC: Clear to Send Input Change Flag
0: No change has been detected on the CTS pin since the last CSR read.
1: At least one change has been detected on the CTS pin since the last CSR read.
• LINTC: LIN Transfer Completed
0: The USART is either idle or a LIN transfer is ongoing.
1: A LIN transfer has been completed since the last RSTSTA.
• LINID: LIN Identifier
0: No LIN Identifier has been sent or received.
1: A LIN Identifier has been sent (master) or received (slave), since the last RSTSTA.
• NACK: Non Acknowledge
0: No Non Acknowledge has been detected since the last RSTNACK.
1: At least one Non Acknowledge has been detected since the last RSTNACK.
• RXBUFF: Reception Buffer Full
0: The Buffer Full signal from the Peripheral DMA Controller channel is inactive.
31 30 29 28 27 26 25 24
– – LINSNRE LINCE LINIPE LINISFE LINBE –
23 22 21 20 19 18 17 16
CTS – – – CTSIC – – –
15 14 13 12 11 10 9 8
LINTC LINID NACK/LINBK RXBUFF – ITER/UNRE TXEMPTY TIMEOUT
76543210
PARE FRAME OVRE – – RXBRK TXRDY RXRDY
473
32142D–06/2013
ATUC64/128/256L3/4U
1: The Buffer Full signal from the Peripheral DMA Controller channel is active.
• ITER/UNRE: Max number of Repetitions Reached or SPI Underrun Error
If USART does not operate in SPI Slave Mode:
ITER=0: Maximum number of repetitions has not been reached since the last RSTSTA.
ITER=1: Maximum number of repetitions has been reached since the last RSTSTA.
If USART operates in SPI Slave Mode:
UNRE=0: No SPI underrun error has occurred since the last RSTSTA.
UNRE=1: At least one SPI underrun error has occurred since the last RSTSTA.
• TXEMPTY: Transmitter Empty
0: The transmitter is either disabled or there are characters in THR, or in the transmit shift register.
1: There are no characters in neither THR, nor in the transmit shift register.
• TIMEOUT: Receiver Time-out
0: There has not been a time-out since the last Start Time-out command (CR.STTTO), or RTOR.TO is zero.
1: There has been a time-out since the last Start Time-out command.
• PARE: Parity Error
0: Either no parity error has been detected, or the parity bit is a zero in multidrop mode, since the last RSTSTA.
1: Either at least one parity error has been detected, or the parity bit is a one in multidrop mode, since the last RSTSTA.
• FRAME: Framing Error
0: No stop bit has been found as low since the last RSTSTA.
1: At least one stop bit has been found as low since the last RSTSTA.
• OVRE: Overrun Error
0: No overrun error has occurred since the last RSTSTA.
1: At least one overrun error has occurred since the last RSTSTA.
• RXBRK: Break Received/End of Break
0: No Break received or End of Break detected since the last RSTSTA.
1: Break received or End of Break detected since the last RSTSTA.
• TXRDY: Transmitter Ready
0: The transmitter is either disabled, or a character in THR is waiting to be transferred to the transmit shift register, or an
STTBRK command has been requested. As soon as the transmitter is enabled, TXRDY becomes one.
1: There is no character in the THR.
• RXRDY: Receiver Ready
0: The receiver is either disabled, or no complete character has been received since the last read of RHR. If characters were
being received when the receiver was disabled, RXRDY changes to 1 when the receiver is enabled.
1: At least one complete character has been received and RHR has not yet been read.
474
32142D–06/2013
ATUC64/128/256L3/4U
20.7.7 Receiver Holding Register
Name: RHR
Access Type: Read-only
Offset: 0x18
Reset Value: 0x00000000
• RXCHR: Received Character
Last received character.
31 30 29 28 27 26 25 24
––––––––
23 22 21 20 19 18 17 16
––––––––
15 14 13 12 11 10 9 8
– – – – – – – RXCHR[8]
76543210
RXCHR[7:0]
475
32142D–06/2013
ATUC64/128/256L3/4U
20.7.8 Transmitter Holding Register
Name: THR
Access Type: Write-only
Offset: 0x1C
Reset Value: 0x00000000
• TXCHR: Character to be Transmitted
If TXRDY is zero this field contains the next character to be transmitted.
31 30 29 28 27 26 25 24
––––––––
23 22 21 20 19 18 17 16
––––––––
15 14 13 12 11 10 9 8
– – – – – – – TXCHR[8]
76543210
TXCHR[7:0]
476
32142D–06/2013
ATUC64/128/256L3/4U
20.7.9 Baud Rate Generator Register
Name: BRGR
Access Type: Read-write
Offset: 0x20
Reset Value: 0x00000000
This register can only be written to if write protection is disabled, see ”Write Protect Mode Register” on page 482.
• FP: Fractional Part
0: Fractional divider is disabled.
1 - 7: Baud rate resolution, defined by FP x 1/8.
• CD: Clock Divider
31 30 29 28 27 26 25 24
––––––––
23 22 21 20 19 18 17 16
– – – – – FP
15 14 13 12 11 10 9 8
CD[15:8]
76543210
CD[7:0]
Table 20-17.
CD
SYNC = 0
SYNC = 1
or
MODE = SPI
(Master or Slave)
OVER = 0 OVER = 1
0 Baud Rate Clock Disabled
1 to 65535
Baud Rate =
Selected Clock/16/CD
Baud Rate =
Selected Clock/8/CD
Baud Rate =
Selected Clock /CD
477
32142D–06/2013
ATUC64/128/256L3/4U
20.7.10 Receiver Time-out Register
Name: RTOR
Access Type: Read-write
Offset: 0x24
Reset Value: 0x00000000
This register can only be written to if write protection is disabled, see ”Write Protect Mode Register” on page 482.
• TO: Time-out Value
0: The receiver Time-out is disabled.
1 - 131071: The receiver Time-out is enabled and the time-out delay is TO x bit period.
Note that the size of the TO counter is device dependent, see the Module Configuration section.
31 30 29 28 27 26 25 24
––––––––
23 22 21 20 19 18 17 16
– – – – – – – TO[16]
15 14 13 12 11 10 9 8
TO[15:8]
76543210
TO[7:0]
478
32142D–06/2013
ATUC64/128/256L3/4U
20.7.11 Transmitter Timeguard Register
Name: TTGR
Access Type: Read-write
Offset: 0x28
Reset Value: 0x00000000
This register can only be written to if write protection is disabled, see ”Write Protect Mode Register” on page 482.
• TG: Timeguard Value
0: The transmitter Timeguard is disabled.
1 - 255: The transmitter timeguard is enabled and the timeguard delay is TG x bit period.
31 30 29 28 27 26 25 24
––––––––
23 22 21 20 19 18 17 16
––––––––
15 14 13 12 11 10 9 8
––––––––
76543210
TG
479
32142D–06/2013
ATUC64/128/256L3/4U
20.7.12 LIN Mode Register
Name: LINMR
Access Type: Read-write
Offset: 0x54
Reset Value: 0x00000000
• PDCM: Peripheral DMA Controller Mode
0: The LIN mode register is not written by the Peripheral DMA Controller.
1: The LIN mode register is, except for this bit, written by the Peripheral DMA Controller.
• DLC: Data Length Control
0 - 255: If DLM=0 this field defines the response data length to DLC+1 bytes.
• WKUPTYP: Wakeup Signal Type
0: Writing a one to CR.LINWKUP will send a LIN 2.0 wakeup signal.
1: Writing a one to CR.LINWKUP will send a LIN 1.3 wakeup signal.
• FSDIS: Frame Slot Mode Disable
0: The Frame Slot mode is enabled.
1: The Frame Slot mode is disabled.
• DLM: Data Length Mode
0: The response data length is defined by DLC.
1: The response data length is defined by bits 4 and 5 of the Identifier (LINIR.IDCHR).
• CHKTYP: Checksum Type
0: LIN 2.0 “Enhanced” checksum
1: LIN 1.3 “Classic” checksum
• CHKDIS: Checksum Disable
0: Checksum is automatically computed and sent when master, and checked when slave.
1: Checksum is not computed and sent, nor checked.
• PARDIS: Parity Disable
0: Identifier parity is automatically computed and sent when master, and checked when slave.
1: Identifier parity is not computed and sent, nor checked.
• NACT: LIN Node Action
31 30 29 28 27 26 25 24
––––––––
23 22 21 20 19 18 17 16
– – – – – – – PDCM
15 14 13 12 11 10 9 8
DLC
76543210
WKUPTYP FSDIS DLM CHKTYP CHKDIS PARDIS NACT
Table 20-18.
NACT Mode Description
0 0 PUBLISH: The USART transmits the response.
480
32142D–06/2013
ATUC64/128/256L3/4U
0 1 SUBSCRIBE: The USART receives the response.
1 0 IGNORE: The USART does not transmit and does not receive the response.
1 1 Reserved
Table 20-18.
481
32142D–06/2013
ATUC64/128/256L3/4U
20.7.13 LIN Identifier Register
Name: LINIR
Access Type: Read-write or Read-only
Offset: 0x58
Reset Value: 0x00000000
• IDCHR: Identifier Character
If USART is in LIN master mode, the IDCHR field is read-write, and its value is the Identifier character to be transmitted.
If USART is in LIN slave mode, the IDCHR field is read-only, and its value is the last received Identifier character.
31 30 29 28 27 26 25 24
––––––––
23 22 21 20 19 18 17 16
––––––––
15 14 13 12 11 10 9 8
––––––––
76543210
IDCHR
482
32142D–06/2013
ATUC64/128/256L3/4U
20.7.14 Write Protect Mode Register
Register Name: WPMR
Access Type: Read-write
Offset: 0xE4
Reset Value: See Table 20-10
• WPKEY: Write Protect KEY
Has to be written to 0x555341 (“USA” in ASCII) in order to successfully write WPEN. Always reads as zero.
• WPEN: Write Protect Enable
0 = Write protection disabled.
1 = Write protection enabled.
Protects the registers:
• ”Mode Register” on page 466
• ”Baud Rate Generator Register” on page 476
• ”Receiver Time-out Register” on page 477
• ”Transmitter Timeguard Register” on page 478
31 30 29 28 27 26 25 24
WPKEY[23:16]
23 22 21 20 19 18 17 16
WPKEY[15:8]
15 14 13 12 11 10 9 8
WPKEY[7:0]
76543210
— — — — — — — WPEN
483
32142D–06/2013
ATUC64/128/256L3/4U
20.7.15 Write Protect Status Register
Register Name: WPSR
Access Type: Read-only
Offset: 0xE8
Reset Value: See Table 20-10
• WPVSRC: Write Protect Violation Source
If WPVS=1 this field indicates which write-protected register was unsuccessfully written to, either by address offset or code.
• WPVS: Write Protect Violation Status
0= No write protect violation has occurred since the last WPSR read.
1= A write protect violation has occurred since the last WPSR read.
Note: Reading WPSR automatically clears all fields.
31 30 29 28 27 26 25 24
————————
23 22 21 20 19 18 17 16
WPVSRC[15:8]
15 14 13 12 11 10 9 8
WPVSRC[7:0]
76543210
— — — — — — — WPVS
484
32142D–06/2013
ATUC64/128/256L3/4U
20.7.16 Version Register
Name: VERSION
Access Type: Read-only
Offset: 0xFC
Reset Value: -
• MFN
Reserved. No functionality associated.
• VERSION
Version of the module. No functionality associated.
31 30 29 28 27 26 25 24
––––––––
23 22 21 20 19 18 17 16
– – – – MFN
15 14 13 12 11 10 9 8
– – – – VERSION[11:8]
76543210
VERSION[7:0]
485
32142D–06/2013
ATUC64/128/256L3/4U
20.8 Module Configuration
The specific configuration for each USART instance is listed in the following tables.The module
bus clocks listed here are connected to the system bus clocks. Please refer to the Power Manager
chapter for details.
Table 20-19. USART Configuration
Feature USART0 USART1 USART2 USART3
Receiver Time-out Counter Size
(Size of the RTOR.TO field) 17 bit 17 bit 17 bit 17 bit
DIV Value for divided CLK_USART 8 8 8 8
Table 20-20. USART Clocks
Module Name Clock Name Description
USART0 CLK_USART0 Clock for the USART0 bus interface
USART1 CLK_USART1 Clock for the USART1 bus interface
USART2 CLK_USART2 Clock for the USART2 bus interface
USART3 CLK_USART3 Clock for the USART3 bus interface
Table 20-21. Register Reset Values
Register Reset Value
VERSION 0x00000440
486
32142D–06/2013
ATUC64/128/256L3/4U
21. Serial Peripheral Interface (SPI)
Rev: 2.1.1.3
21.1 Features
• Compatible with an embedded 32-bit microcontroller
• Supports communication with serial external devices
– Four chip selects with external decoder support allow communication with up to 15
peripherals
– Serial memories, such as DataFlash and 3-wire EEPROMs
– Serial peripherals, such as ADCs, DACs, LCD controllers, CAN controllers and Sensors
– External co-processors
• Master or Slave Serial Peripheral Bus Interface
– 4 - to 16-bit programmable data length per chip select
– Programmable phase and polarity per chip select
– Programmable transfer delays between consecutive transfers and between clock and data
per chip select
– Programmable delay between consecutive transfers
– Selectable mode fault detection
• Connection to Peripheral DMA Controller channel capabilities optimizes data transfers
– One channel for the receiver, one channel for the transmitter
– Next buffer support
– Four character FIFO in reception
21.2 Overview
The Serial Peripheral Interface (SPI) circuit is a synchronous serial data link that provides communication
with external devices in Master or Slave mode. It also enables communication
between processors if an external processor is connected to the system.
The Serial Peripheral Interface is essentially a shift register that serially transmits data bits to
other SPIs. During a data transfer, one SPI system acts as the “master”' which controls the data
flow, while the other devices act as “slaves'' which have data shifted into and out by the master.
Different CPUs can take turn being masters (Multiple Master Protocol opposite to Single Master
Protocol where one CPU is always the master while all of the others are always slaves) and one
master may simultaneously shift data into multiple slaves. However, only one slave may drive its
output to write data back to the master at any given time.
A slave device is selected when the master asserts its NSS signal. If multiple slave devices
exist, the master generates a separate slave select signal for each slave (NPCS).
The SPI system consists of two data lines and two control lines:
• Master Out Slave In (MOSI): this data line supplies the output data from the master shifted
into the input(s) of the slave(s).
• Master In Slave Out (MISO): this data line supplies the output data from a slave to the input of
the master. There may be no more than one slave transmitting data during any particular
transfer.
• Serial Clock (SPCK): this control line is driven by the master and regulates the flow of the
data bits. The master may transmit data at a variety of baud rates; the SPCK line cycles once
for each bit that is transmitted.
• Slave Select (NSS): this control line allows slaves to be turned on and off by hardware.
487
32142D–06/2013
ATUC64/128/256L3/4U
21.3 Block Diagram
Figure 21-1. SPI Block Diagram
21.4 Application Block Diagram
Figure 21-2. Application Block Diagram: Single Master/Multiple Slave Implementation
Spi Interface
Interrupt Control
Peripheral DMA
Controller
I/O
Controller
CLK_SPI
Peripheral Bus
SPI Interrupt
SPCK
NPCS3
NPCS2
NPCS1
NPCS0/NSS
MOSI
MISO
Slave 0
Slave 2
Slave 1
SPCK
NPCS3
NPCS2
NPCS1
NPCS0
MOSI
MISO
Spi Master
SPCK
NSS
MOSI
MISO
SPCK
NSS
MOSI
MISO
SPCK
NSS
MOSI
MISO
NC
488
32142D–06/2013
ATUC64/128/256L3/4U
21.5 I/O Lines Description
21.6 Product Dependencies
In order to use this module, other parts of the system must be configured correctly, as described
below.
21.6.1 I/O Lines
The pins used for interfacing the compliant external devices may be multiplexed with I/O lines.
The user must first configure the I/O Controller to assign the SPI pins to their peripheral
functions.
21.6.2 Clocks
The clock for the SPI bus interface (CLK_SPI) is generated by the Power Manager. This clock is
enabled at reset, and can be disabled in the Power Manager. It is recommended to disable the
SPI before disabling the clock, to avoid freezing the SPI in an undefined state.
21.6.3 Interrupts
The SPI interrupt request line is connected to the interrupt controller. Using the SPI interrupt
requires the interrupt controller to be programmed first.
21.7 Functional Description
21.7.1 Modes of Operation
The SPI operates in master mode or in slave mode.
Operation in master mode is configured by writing a one to the Master/Slave Mode bit in the
Mode Register (MR.MSTR). The pins NPCS0 to NPCS3 are all configured as outputs, the SPCK
pin is driven, the MISO line is wired on the receiver input and the MOSI line driven as an output
by the transmitter.
If the MR.MSTR bit is written to zero, the SPI operates in slave mode. The MISO line is driven by
the transmitter output, the MOSI line is wired on the receiver input, the SPCK pin is driven by the
transmitter to synchronize the receiver. The NPCS0 pin becomes an input, and is used as a
Slave Select signal (NSS). The pins NPCS1 to NPCS3 are not driven and can be used for other
purposes.
The data transfers are identically programmable for both modes of operations. The baud rate
generator is activated only in master mode.
Table 21-1. I/O Lines Description
Pin Name Pin Description
Type
Master Slave
MISO Master In Slave Out Input Output
MOSI Master Out Slave In Output Input
SPCK Serial Clock Output Input
NPCS1-NPCS3 Peripheral Chip Selects Output Unused
NPCS0/NSS Peripheral Chip Select/Slave Select Output Input
489
32142D–06/2013
ATUC64/128/256L3/4U
21.7.2 Data Transfer
Four combinations of polarity and phase are available for data transfers. The clock polarity is
configured with the Clock Polarity bit in the Chip Select Registers (CSRn.CPOL). The clock
phase is configured with the Clock Phase bit in the CSRn registers (CSRn.NCPHA). These two
bits determine the edges of the clock signal on which data is driven and sampled. Each of the
two bits has two possible states, resulting in four possible combinations that are incompatible
with one another. Thus, a master/slave pair must use the same parameter pair values to communicate.
If multiple slaves are used and fixed in different configurations, the master must
reconfigure itself each time it needs to communicate with a different slave.
Table 21-2 on page 489 shows the four modes and corresponding parameter settings.
Figure 21-3 on page 489 and Figure 21-4 on page 490 show examples of data transfers.
Figure 21-3. SPI Transfer Format (NCPHA = 1, 8 bits per transfer)
Table 21-2. SPI modes
SPI Mode CPOL NCPHA
0 01
1 00
2 11
3 10
SPCK cycle (for reference) 1 4 2 3 5 8 6 7
SPCK
(CPOL = 0)
NSS
(to slave)
MISO
(from slave)
MOSI
(from master)
SPCK
(CPOL = 1)
MSB 6 4 5 LSB 3 2 1
MSB 6 5 4 3 2 1 LSB ***
*** Not Defined, but normaly MSB of previous character received
490
32142D–06/2013
ATUC64/128/256L3/4U
Figure 21-4. SPI Transfer Format (NCPHA = 0, 8 bits per transfer)
21.7.3 Master Mode Operations
When configured in master mode, the SPI uses the internal programmable baud rate generator
as clock source. It fully controls the data transfers to and from the slave(s) connected to the SPI
bus. The SPI drives the chip select line to the slave and the serial clock signal (SPCK).
The SPI features two holding registers, the Transmit Data Register (TDR) and the Receive Data
Register (RDR), and a single Shift Register. The holding registers maintain the data flow at a
constant rate.
After enabling the SPI, a data transfer begins when the processor writes to the TDR register.
The written data is immediately transferred in the Shift Register and transfer on the SPI bus
starts. While the data in the Shift Register is shifted on the MOSI line, the MISO line is sampled
and shifted in the Shift Register. Transmission cannot occur without reception.
Before writing to the TDR, the Peripheral Chip Select field in TDR (TDR.PCS) must be written in
order to select a slave.
If new data is written to TDR during the transfer, it stays in it until the current transfer is completed.
Then, the received data is transferred from the Shift Register to RDR, the data in TDR is
loaded in the Shift Register and a new transfer starts.
The transfer of a data written in TDR in the Shift Register is indicated by the Transmit Data Register
Empty bit in the Status Register (SR.TDRE). When new data is written in TDR, this bit is
cleared. The SR.TDRE bit is used to trigger the Transmit Peripheral DMA Controller channel.
The end of transfer is indicated by the Transmission Registers Empty bit in the SR register
(SR.TXEMPTY). If a transfer delay (CSRn.DLYBCT) is greater than zero for the last transfer,
SR.TXEMPTY is set after the completion of said delay. The CLK_SPI can be switched off at this
time.
During reception, received data are transferred from the Shift Register to the reception FIFO.
The FIFO can contain up to 4 characters (both Receive Data and Peripheral Chip Select fields).
While a character of the FIFO is unread, the Receive Data Register Full bit in SR remains high
(SR.RDRF). Characters are read through the RDR register. If the four characters stored in the
FIFO are not read and if a new character is stored, this sets the Overrun Error Status bit in the
SR register (SR.OVRES). The procedure to follow in such a case is described in Section
21.7.3.8.
SPCK cycle (for reference) 1 4 2 3 5 8 6 7
SPCK
(CPOL = 0)
NSS
(to slave)
MISO
(from slave)
MOSI
(from master)
SPCK
(CPOL = 1)
MSB 6 4 5 LSB 3 2 1
6 5 4 3 2 1 LSB
*** Not Defined, but normaly LSB of previous character transmitted
*** MSB
491
32142D–06/2013
ATUC64/128/256L3/4U
Figure 21-5 on page 491shows a block diagram of the SPI when operating in master mode. Figure
21-6 on page 492 shows a flow chart describing how transfers are handled.
21.7.3.1 Master mode block diagram
Figure 21-5. Master Mode Block Diagram
Baud Rate Generator
RXFIFOEN
4 – Character FIFO
Shift Register
TDRE
RXFIFOEN
4 – Character FIFO
PS
PCSDEC
Current
Peripheral
MODF
MODFDIS
MSTR
SCBR
CSR0..3
CSR0..3
CPOL
NCPHA
BITS
RDR
RD
RDRF
OVRES
TD
TDR
RDR
CSAAT
CSNAAT
CSR0..3
PCS
MR
PCS
TDR
SPCK CLK_SPI
MISO MOSI LSB MSB
NPCS1
NPCS2
NPCS3
NPCS0
SPI
Clock
0
1
0
1
0
1
NPCS0
492
32142D–06/2013
ATUC64/128/256L3/4U
21.7.3.2 Master mode flow diagram
Figure 21-6. Master Mode Flow Diagram
SPI Enable
CSAAT ?
PS ?
1
0
0
1
1
NPCS = TDR(PCS) NPCS = MR(PCS)
Delay DLYBS
Serializer = TDR(TD)
TDRE = 1
Data Transfer
RDR(RD) = Serializer
RDRF = 1
TDRE ?
NPCS = 0xF
Delay DLYBCS
Fixed
peripheral
Variable
peripheral
Delay DLYBCT
0
1 CSAAT ?
0
TDRE ?
1
0
PS ?
0
1
TDR(PCS)
= NPCS ?
no
yes MR(PCS)
= NPCS ?
no
NPCS = 0xF
Delay DLYBCS
NPCS = TDR(PCS)
NPCS = 0xF
Delay DLYBCS
NPCS = MR(PCS),
TDR(PCS)
Fixed
peripheral
Variable
peripheral
- NPCS defines the current Chip Select
- CSAAT, DLYBS, DLYBCT refer to the fields of the
Chip Select Register corresponding to the Current Chip Select
- When NPCS is 0xF, CSAAT is 0.
493
32142D–06/2013
ATUC64/128/256L3/4U
21.7.3.3 Clock generation
The SPI Baud rate clock is generated by dividing the CLK_SPI , by a value between 1 and 255.
This allows a maximum operating baud rate at up to CLK_SPI and a minimum operating baud
rate of CLK_SPI divided by 255.
Writing the Serial Clock Baud Rate field in the CSRn registers (CSRn.SCBR) to zero is forbidden.
Triggering a transfer while CSRn.SCBR is zero can lead to unpredictable results.
At reset, CSRn.SCBR is zero and the user has to configure it at a valid value before performing
the first transfer.
The divisor can be defined independently for each chip select, as it has to be configured in the
CSRn.SCBR field. This allows the SPI to automatically adapt the baud rate for each interfaced
peripheral without reprogramming.
21.7.3.4 Transfer delays
Figure 21-7 on page 493 shows a chip select transfer change and consecutive transfers on the
same chip select. Three delays can be configured to modify the transfer waveforms:
• The delay between chip selects, programmable only once for all the chip selects by writing to
the Delay Between Chip Selects field in the MR register (MR.DLYBCS). Allows insertion of a
delay between release of one chip select and before assertion of a new one.
• The delay before SPCK, independently programmable for each chip select by writing the
Delay Before SPCK field in the CSRn registers (CSRn.DLYBS). Allows the start of SPCK to
be delayed after the chip select has been asserted.
• The delay between consecutive transfers, independently programmable for each chip select
by writing the Delay Between Consecutive Transfers field in the CSRn registers
(CSRn.DLYBCT). Allows insertion of a delay between two transfers occurring on the same
chip select
These delays allow the SPI to be adapted to the interfaced peripherals and their speed and bus
release time.
Figure 21-7. Programmable Delays
DLYBCS DLYBS DLYBCT DLYBCT
Chip Select 1
Chip Select 2
SPCK
494
32142D–06/2013
ATUC64/128/256L3/4U
21.7.3.5 Peripheral selection
The serial peripherals are selected through the assertion of the NPCS0 to NPCS3 signals. By
default, all the NPCS signals are high before and after each transfer.
The peripheral selection can be performed in two different ways:
• Fixed Peripheral Select: SPI exchanges data with only one peripheral
• Variable Peripheral Select: Data can be exchanged with more than one peripheral
Fixed Peripheral Select is activated by writing a zero to the Peripheral Select bit in MR (MR.PS).
In this case, the current peripheral is defined by the MR.PCS field and the TDR.PCS field has no
effect.
Variable Peripheral Select is activated by writing a one to the MR.PS bit . The TDR.PCS field is
used to select the current peripheral. This means that the peripheral selection can be defined for
each new data.
The Fixed Peripheral Selection allows buffer transfers with a single peripheral. Using the Peripheral
DMA Controller is an optimal means, as the size of the data transfer between the memory
and the SPI is either 4 bits or 16 bits. However, changing the peripheral selection requires the
Mode Register to be reprogrammed.
The Variable Peripheral Selection allows buffer transfers with multiple peripherals without reprogramming
the MR register. Data written to TDR is 32-bits wide and defines the real data to be
transmitted and the peripheral it is destined to. Using the Peripheral DMA Controller in this mode
requires 32-bit wide buffers, with the data in the LSBs and the PCS and LASTXFER fields in the
MSBs, however the SPI still controls the number of bits (8 to16) to be transferred through MISO
and MOSI lines with the CSRn registers. This is not the optimal means in term of memory size
for the buffers, but it provides a very effective means to exchange data with several peripherals
without any intervention of the processor.
21.7.3.6 Peripheral chip select decoding
The user can configure the SPI to operate with up to 15 peripherals by decoding the four Chip
Select lines, NPCS0 to NPCS3 with an external logic. This can be enabled by writing a one to
the Chip Select Decode bit in the MR register (MR.PCSDEC).
When operating without decoding, the SPI makes sure that in any case only one chip select line
is activated, i.e. driven low at a time. If two bits are defined low in a PCS field, only the lowest
numbered chip select is driven low.
When operating with decoding, the SPI directly outputs the value defined by the PCS field of
either the MR register or the TDR register (depending on PS).
As the SPI sets a default value of 0xF on the chip select lines (i.e. all chip select lines at one)
when not processing any transfer, only 15 peripherals can be decoded.
The SPI has only four Chip Select Registers, not 15. As a result, when decoding is activated,
each chip select defines the characteristics of up to four peripherals. As an example, the CRS0
register defines the characteristics of the externally decoded peripherals 0 to 3, corresponding to
the PCS values 0x0 to 0x3. Thus, the user has to make sure to connect compatible peripherals
on the decoded chip select lines 0 to 3, 4 to 7, 8 to 11 and 12 to 14.
21.7.3.7 Peripheral deselection
When operating normally, as soon as the transfer of the last data written in TDR is completed,
the NPCS lines all rise. This might lead to runtime error if the processor is too long in responding
495
32142D–06/2013
ATUC64/128/256L3/4U
to an interrupt, and thus might lead to difficulties for interfacing with some serial peripherals
requiring the chip select line to remain active during a full set of transfers.
To facilitate interfacing with such devices, the CSRn registers can be configured with the Chip
Select Active After Transfer bit written to one (CSRn.CSAAT) . This allows the chip select lines
to remain in their current state (low = active) until transfer to another peripheral is required.
When the CSRn.CSAAT bit is written to qero, the NPCS does not rise in all cases between two
transfers on the same peripheral. During a transfer on a Chip Select, the SR.TDRE bit rises as
soon as the content of the TDR is transferred into the internal shifter. When this bit is detected
the TDR can be reloaded. If this reload occurs before the end of the current transfer and if the
next transfer is performed on the same chip select as the current transfer, the Chip Select is not
de-asserted between the two transfers. This might lead to difficulties for interfacing with some
serial peripherals requiring the chip select to be de-asserted after each transfer. To facilitate
interfacing with such devices, the CSRn registers can be configured with the Chip Select Not
Active After Transfer bit (CSRn.CSNAAT) written to one. This allows to de-assert systematically
the chip select lines during a time DLYBCS. (The value of the CSRn.CSNAAT bit is taken into
account only if the CSRn.CSAAT bit is written to zero for the same Chip Select).
Figure 21-8 on page 496 shows different peripheral deselection cases and the effect of the
CSRn.CSAAT and CSRn.CSNAAT bits.
21.7.3.8 FIFO management
A FIFO has been implemented in Reception FIFO (both in master and in slave mode), in order to
be able to store up to 4 characters without causing an overrun error. If an attempt is made to
store a fifth character, an overrun error rises. If such an event occurs, the FIFO must be flushed.
There are two ways to Flush the FIFO:
• By performing four read accesses of the RDR (the data read must be ignored)
• By writing a one to the Flush Fifo Command bit in the CR register (CR.FLUSHFIFO).
After that, the SPI is able to receive new data.
496
32142D–06/2013
ATUC64/128/256L3/4U
Figure 21-8. Peripheral Deselection
Figure 21-8 on page 496 shows different peripheral deselection cases and the effect of the
CSRn.CSAAT and CSRn.CSNAAT bits.
21.7.3.9 Mode fault detection
The SPI is capable of detecting a mode fault when it is configured in master mode and NPCS0,
MOSI, MISO, and SPCK are configured as open drain through the I/O Controller with either
internal or external pullup resistors. If the I/O Controller does not have open-drain capability,
mode fault detection must be disabled by writing a one to the Mode Fault Detection bit in the MR
A
NPCS[0..3]
Write TDR
TDRE
NPCS[0..3]
Write TDR
TDRE
NPCS[0..3]
Write TDR
TDRE
DLYBCS
PCS = A
DLYBCS
DLYBCT
A
PCS = B
B
DLYBCS
PCS = A
DLYBCS
DLYBCT
A
PCS = B
B
DLYBCS
DLYBCT
PCS=A
A
DLYBCS
DLYBCT
A
PCS = A
A A
DLYBCT
A A
CSAAT = 0 and CSNAAT = 0
DLYBCT
A A
CSAAT = 1 and CSNAAT= 0 / 1
A
DLYBCS
PCS = A
DLYBCT
A A
CSAAT = 0 and CSNAAT = 1
NPCS[0..3]
Write TDR
TDRE
PCS = A
DLYBCT
A A
CSAAT = 0 and CSNAAT = 0
497
32142D–06/2013
ATUC64/128/256L3/4U
register (MR.MODFDIS). In systems with open-drain I/O lines, a mode fault is detected when a
low level is driven by an external master on the NPCS0/NSS signal.
When a mode fault is detected, the Mode Fault Error bit in the SR (SR.MODF) is set until the SR
is read and the SPI is automatically disabled until re-enabled by writing a one to the SPI Enable
bit in the CR register (CR.SPIEN).
By default, the mode fault detection circuitry is enabled. The user can disable mode fault detection
by writing a one to the Mode Fault Detection bit in the MR register (MR.MODFDIS).
21.7.4 SPI Slave Mode
When operating in slave mode, the SPI processes data bits on the clock provided on the SPI
clock pin (SPCK).
The SPI waits for NSS to go active before receiving the serial clock from an external master.
When NSS falls, the clock is validated on the serializer, which processes the number of bits
defined by the Bits Per Transfer field of the Chip Select Register 0 (CSR0.BITS). These bits are
processed following a phase and a polarity defined respectively by the CSR0.NCPHA and
CSR0.CPOL bits. Note that the BITS, CPOL, and NCPHA bits of the other Chip Select Registers
have no effect when the SPI is configured in Slave Mode.
The bits are shifted out on the MISO line and sampled on the MOSI line.
When all the bits are processed, the received data is transferred in the Receive Data Register
and the SR.RDRF bit rises. If the RDR register has not been read before new data is received,
the SR.OVRES bit is set. Data is loaded in RDR even if this flag is set. The user has to read the
SR register to clear the SR.OVRES bit.
When a transfer starts, the data shifted out is the data present in the Shift Register. If no data
has been written in the TDR register, the last data received is transferred. If no data has been
received since the last reset, all bits are transmitted low, as the Shift Register resets to zero.
When a first data is written in TDR, it is transferred immediately in the Shift Register and the
SR.TDRE bit rises. If new data is written, it remains in TDR until a transfer occurs, i.e. NSS falls
and there is a valid clock on the SPCK pin. When the transfer occurs, the last data written in
TDR is transferred in the Shift Register and the SR.TDRE bit rises. This enables frequent
updates of critical variables with single transfers.
Then, a new data is loaded in the Shift Register from the TDR. In case no character is ready to
be transmitted, i.e. no character has been written in TDR since the last load from TDR to the
Shift Register, the Shift Register is not modified and the last received character is retransmitted.
In this case the Underrun Error Status bit is set in SR (SR.UNDES).
Figure 21-9 on page 498 shows a block diagram of the SPI when operating in slave mode.
498
32142D–06/2013
ATUC64/128/256L3/4U
Figure 21-9. Slave Mode Functional Block Diagram
Shift Register
SPCK
SPIENS
LSB MSB
NSS
MOSI
SPI
Clock
TDRE
TDR
TD
RDRF
OVRES
CSR0
CPOL
NCPHA
BITS
SPIEN
SPIDIS
MISO
UNDES
RDR
RD
4 - Character FIFO
0
1
RXFIFOEN
499
32142D–06/2013
ATUC64/128/256L3/4U
21.8 User Interface
Note: 1. The reset values are device specific. Please refer to the Module Configuration section at the end of this chapter.
Table 21-3. SPI Register Memory Map
Offset Register Register Name Access Reset
0x00 Control Register CR Write-only 0x00000000
0x04 Mode Register MR Read/Write 0x00000000
0x08 Receive Data Register RDR Read-only 0x00000000
0x0C Transmit Data Register TDR Write-only 0x00000000
0x10 Status Register SR Read-only 0x00000000
0x14 Interrupt Enable Register IER Write-only 0x00000000
0x18 Interrupt Disable Register IDR Write-only 0x00000000
0x1C Interrupt Mask Register IMR Read-only 0x00000000
0x30 Chip Select Register 0 CSR0 Read/Write 0x00000000
0x34 Chip Select Register 1 CSR1 Read/Write 0x00000000
0x38 Chip Select Register 2 CSR2 Read/Write 0x00000000
0x3C Chip Select Register 3 CSR3 Read/Write 0x00000000
0x E4 Write Protection Control Register WPCR Read/Write 0X00000000
0xE8 Write Protection Status Register WPSR Read-only 0x00000000
0xF8 Features Register FEATURES Read-only - (1)
0xFC Version Register VERSION Read-only - (1)
500
32142D–06/2013
ATUC64/128/256L3/4U
21.8.1 Control Register
Name: CR
Access Type: Write-only
Offset: 0x00
Reset Value: 0x00000000
• LASTXFER: Last Transfer
1: The current NPCS will be deasserted after the character written in TD has been transferred. When CSRn.CSAAT is one, this
allows to close the communication with the current serial peripheral by raising the corresponding NPCS line as soon as TD
transfer has completed.
0: Writing a zero to this bit has no effect.
• FLUSHFIFO: Flush Fifo Command
1: If The FIFO Mode is enabled (MR.FIFOEN written to one) and if an overrun error has been detected, this command allows to
empty the FIFO.
0: Writing a zero to this bit has no effect.
• SWRST: SPI Software Reset
1: Writing a one to this bit will reset the SPI. A software-triggered hardware reset of the SPI interface is performed. The SPI is in
slave mode after software reset. Peripheral DMA Controller channels are not affected by software reset.
0: Writing a zero to this bit has no effect.
• SPIDIS: SPI Disable
1: Writing a one to this bit will disable the SPI. As soon as SPIDIS is written to one, the SPI finishes its transfer, all pins are set
in input mode and no data is received or transmitted. If a transfer is in progress, the transfer is finished before the SPI is
disabled. If both SPIEN and SPIDIS are equal to one when the CR register is written, the SPI is disabled.
0: Writing a zero to this bit has no effect.
• SPIEN: SPI Enable
1: Writing a one to this bit will enable the SPI to transfer and receive data.
0: Writing a zero to this bit has no effect.
31 30 29 28 27 26 25 24
- - - - - - - LASTXFER
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
- - - - - - - FLUSHFIFO
76543210
SWRST - - - - - SPIDIS SPIEN
501
32142D–06/2013
ATUC64/128/256L3/4U
21.8.2 Mode Register
Name: MR
Access Type: Read/Write
Offset: 0x04
Reset Value: 0x00000000
• DLYBCS: Delay Between Chip Selects
This field defines the delay from NPCS inactive to the activation of another NPCS. The DLYBCS time guarantees nonoverlapping
chip selects and solves bus contentions in case of peripherals having long data float times.
If DLYBCS is less than or equal to six, six CLK_SPI periods will be inserted by default.
Otherwise, the following equation determines the delay:
• PCS: Peripheral Chip Select
This field is only used if Fixed Peripheral Select is active (PS = 0).
If PCSDEC = 0:
PCS = xxx0NPCS[3:0] = 1110
PCS = xx01NPCS[3:0] = 1101
PCS = x011NPCS[3:0] = 1011
PCS = 0111NPCS[3:0] = 0111
PCS = 1111forbidden (no peripheral is selected)
(x = don’t care)
If PCSDEC = 1:
NPCS[3:0] output signals = PCS.
• LLB: Local Loopback Enable
1: Local loopback path enabled. LLB controls the local loopback on the data serializer for testing in master mode only (MISO is
internally connected on MOSI).
0: Local loopback path disabled.
• RXFIFOEN: FIFO in Reception Enable
1: The FIFO is used in reception (four characters can be stored in the SPI).
31 30 29 28 27 26 25 24
DLYBCS
23 22 21 20 19 18 17 16
- - - - PCS
15 14 13 12 11 10 9 8
--------
76543210
LLB RXFIFOEN - MODFDIS - PCSDEC PS MSTR
Delay Between Chip Selects DLYBCS
CLKSPI = -----------------------
502
32142D–06/2013
ATUC64/128/256L3/4U
0: The FIFO is not used in reception (only one character can be stored in the SPI).
• MODFDIS: Mode Fault Detection
1: Mode fault detection is disabled. If the I/O controller does not have open-drain capability, mode fault detection must be
disabled for proper operation of the SPI.
0: Mode fault detection is enabled.
• PCSDEC: Chip Select Decode
0: The chip selects are directly connected to a peripheral device.
1: The four chip select lines are connected to a 4- to 16-bit decoder.
When PCSDEC equals one, up to 15 Chip Select signals can be generated with the four lines using an external 4- to 16-bit
decoder. The CSRn registers define the characteristics of the 15 chip selects according to the following rules:
CSR0 defines peripheral chip select signals 0 to 3.
CSR1 defines peripheral chip select signals 4 to 7.
CSR2 defines peripheral chip select signals 8 to 11.
CSR3 defines peripheral chip select signals 12 to 14.
• PS: Peripheral Select
1: Variable Peripheral Select.
0: Fixed Peripheral Select.
• MSTR: Master/Slave Mode
1: SPI is in master mode.
0: SPI is in slave mode.
503
32142D–06/2013
ATUC64/128/256L3/4U
21.8.3 Receive Data Register
Name: RDR
Access Type: Read-only
Offset: 0x08
Reset Value: 0x00000000
• RD: Receive Data
Data received by the SPI Interface is stored in this register right-justified. Unused bits read zero.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
RD[15:8]
76543210
RD[7:0]
504
32142D–06/2013
ATUC64/128/256L3/4U
21.8.4 Transmit Data Register
Name: TDR
Access Type: Write-only
Offset: 0x0C
Reset Value: 0x00000000
• LASTXFER: Last Transfer
1: The current NPCS will be deasserted after the character written in TD has been transferred. When CSRn.CSAAT is one, this
allows to close the communication with the current serial peripheral by raising the corresponding NPCS line as soon as TD
transfer has completed.
0: Writing a zero to this bit has no effect.
This field is only used if Variable Peripheral Select is active (MR.PS = 1).
• PCS: Peripheral Chip Select
If PCSDEC = 0:
PCS = xxx0NPCS[3:0] = 1110
PCS = xx01NPCS[3:0] = 1101
PCS = x011NPCS[3:0] = 1011
PCS = 0111NPCS[3:0] = 0111
PCS = 1111forbidden (no peripheral is selected)
(x = don’t care)
If PCSDEC = 1:
NPCS[3:0] output signals = PCS
This field is only used if Variable Peripheral Select is active (MR.PS = 1).
• TD: Transmit Data
Data to be transmitted by the SPI Interface is stored in this register. Information to be transmitted must be written to the TDR
register in a right-justified format.
31 30 29 28 27 26 25 24
- - - - - - - LASTXFER
23 22 21 20 19 18 17 16
- - - - PCS
15 14 13 12 11 10 9 8
TD[15:8]
76543210
TD[7:0]
505
32142D–06/2013
ATUC64/128/256L3/4U
21.8.5 Status Register
Name: SR
Access Type: Read-only
Offset: 0x10
Reset Value: 0x00000000
• SPIENS: SPI Enable Status
1: This bit is set when the SPI is enabled.
0: This bit is cleared when the SPI is disabled.
• UNDES: Underrun Error Status (Slave Mode Only)
1: This bit is set when a transfer begins whereas no data has been loaded in the TDR register.
0: This bit is cleared when the SR register is read.
• TXEMPTY: Transmission Registers Empty
1: This bit is set when TDR and internal shifter are empty. If a transfer delay has been defined, TXEMPTY is set after the
completion of such delay.
0: This bit is cleared as soon as data is written in TDR.
• NSSR: NSS Rising
1: A rising edge occurred on NSS pin since last read.
0: This bit is cleared when the SR register is read.
• OVRES: Overrun Error Status
1: This bit is set when an overrun has occurred. An overrun occurs when RDR is loaded at least twice from the serializer since
the last read of the RDR.
0: This bit is cleared when the SR register is read.
• MODF: Mode Fault Error
1: This bit is set when a Mode Fault occurred.
0: This bit is cleared when the SR register is read.
• TDRE: Transmit Data Register Empty
1: This bit is set when the last data written in the TDR register has been transferred to the serializer.
0: This bit is cleared when data has been written to TDR and not yet transferred to the serializer.
TDRE equals zero when the SPI is disabled or at reset. The SPI enable command sets this bit to one.
• RDRF: Receive Data Register Full
1: Data has been received and the received data has been transferred from the serializer to RDR since the last read of RDR.
0: No data has been received since the last read of RDR
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
- - - - - - - SPIENS
15 14 13 12 11 10 9 8
- - - - - UNDES TXEMPTY NSSR
76543210
- - - - OVRES MODF TDRE RDRF
506
32142D–06/2013
ATUC64/128/256L3/4U
21.8.6 Interrupt Enable Register
Name: IER
Access Type: Write-only
Offset: 0x14
Reset Value: 0x00000000
Writing a zero to a bit in this register has no effect.
Writing a one to a bit in this register will set the corresponding bit in IMR.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
- - - - - UNDES TXEMPTY NSSR
76543210
- - - - OVRES MODF TDRE RDRF
507
32142D–06/2013
ATUC64/128/256L3/4U
21.8.7 Interrupt Disable Register
Name: IDR
Access Type: Write-only
Offset: 0x18
Reset Value: 0x00000000
Writing a zero to a bit in this register has no effect.
Writing a one to a bit in this register will clear the corresponding bit in IMR.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
- - - - - UNDES TXEMPTY NSSR
76543210
- - - - OVRES MODF TDRE RDRF
508
32142D–06/2013
ATUC64/128/256L3/4U
21.8.8 Interrupt Mask Register
Name: IMR
Access Type: Read-only
Offset: 0x1C
Reset Value: 0x00000000
0: The corresponding interrupt is disabled.
1: The corresponding interrupt is enabled.
A bit in this register is cleared when the corresponding bit in IDR is written to one.
A bit in this register is set when the corresponding bit in IER is written to one.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
- - - - - UNDES TXEMPTY NSSR
76543210
- - - - OVRES MODF TDRE RDRF
509
32142D–06/2013
ATUC64/128/256L3/4U
21.8.9 Chip Select Register 0
Name: CSR0
Access Type: Read/Write
Offset: 0x30
Reset Value: 0x00000000
• DLYBCT: Delay Between Consecutive Transfers
This field defines the delay between two consecutive transfers with the same peripheral without removing the chip select. The
delay is always inserted after each transfer and before removing the chip select if needed.
When DLYBCT equals zero, no delay between consecutive transfers is inserted and the clock keeps its duty cycle over the
character transfers.
Otherwise, the following equation determines the delay:
• DLYBS: Delay Before SPCK
This field defines the delay from NPCS valid to the first valid SPCK transition.
When DLYBS equals zero, the NPCS valid to SPCK transition is 1/2 the SPCK clock period.
Otherwise, the following equations determine the delay:
• SCBR: Serial Clock Baud Rate
In Master Mode, the SPI Interface uses a modulus counter to derive the SPCK baud rate from the CLK_SPI. The Baud rate is
selected by writing a value from 1 to 255 in the SCBR field. The following equations determine the SPCK baud rate:
Writing the SCBR field to zero is forbidden. Triggering a transfer while SCBR is zero can lead to unpredictable results.
At reset, SCBR is zero and the user has to write it to a valid value before performing the first transfer.
If a clock divider (SCBRn) field is set to one and the other SCBR fields differ from one, access on CSn is correct but no correct
access will be possible on other CS.
31 30 29 28 27 26 25 24
DLYBCT
23 22 21 20 19 18 17 16
DLYBS
15 14 13 12 11 10 9 8
SCBR
76543210
BITS CSAAT CSNAAT NCPHA CPOL
Delay Between Consecutive Transfers 32 DLYBCT
CLKSPI = ------------------------------------
Delay Before SPCK DLYBS
CLKSPI = ---------------------
SPCK Baudrate CLKSPI
SCBR = ---------------------
510
32142D–06/2013
ATUC64/128/256L3/4U
• BITS: Bits Per Transfer
The BITS field determines the number of data bits transferred. Reserved values should not be used.
• CSAAT: Chip Select Active After Transfer
1: The Peripheral Chip Select does not rise after the last transfer is achieved. It remains active until a new transfer is requested
on a different chip select.
0: The Peripheral Chip Select Line rises as soon as the last transfer is achieved.
• CSNAAT: Chip Select Not Active After Transfer (Ignored if CSAAT = 1)
0: The Peripheral Chip Select does not rise between two transfers if the TDR is reloaded before the end of the first transfer and
if the two transfers occur on the same Chip Select.
1: The Peripheral Chip Select rises systematically between each transfer performed on the same slave for a minimal duration of:
(if DLYBCT field is different from 0)
(if DLYBCT field equals 0)
• NCPHA: Clock Phase
1: Data is captured after the leading (inactive-to-active) edge of SPCK and changed on the trailing (active-to-inactive) edge of
SPCK.
0: Data is changed on the leading (inactive-to-active) edge of SPCK and captured after the trailing (active-to-inactive) edge of
SPCK.
NCPHA determines which edge of SPCK causes data to change and which edge causes data to be captured. NCPHA is used
with CPOL to produce the required clock/data relationship between master and slave devices.
• CPOL: Clock Polarity
1: The inactive state value of SPCK is logic level one.
0: The inactive state value of SPCK is logic level zero.
BITS Bits Per Transfer
0000 8
0001 9
0010 10
0011 11
0100 12
0101 13
0110 14
0111 15
1000 16
1001 4
1010 5
1011 6
1100 7
1101 Reserved
1110 Reserved
1111 Reserved
DLYBCS
CLKSPI
-----------------------
DLYBCS + 1
CLKSPI
--------------------------------
511
32142D–06/2013
ATUC64/128/256L3/4U
CPOL is used to determine the inactive state value of the serial clock (SPCK). It is used with NCPHA to produce the required
clock/data relationship between master and slave devices.
512
32142D–06/2013
ATUC64/128/256L3/4U
21.8.10 Chip Select Register 1
Name: CSR1
Access Type: Read/Write
Offset: 0x34
Reset Value: 0x00000000
• DLYBCT: Delay Between Consecutive Transfers
This field defines the delay between two consecutive transfers with the same peripheral without removing the chip select. The
delay is always inserted after each transfer and before removing the chip select if needed.
When DLYBCT equals zero, no delay between consecutive transfers is inserted and the clock keeps its duty cycle over the
character transfers.
Otherwise, the following equation determines the delay:
• DLYBS: Delay Before SPCK
This field defines the delay from NPCS valid to the first valid SPCK transition.
When DLYBS equals zero, the NPCS valid to SPCK transition is 1/2 the SPCK clock period.
Otherwise, the following equations determine the delay:
• SCBR: Serial Clock Baud Rate
In Master Mode, the SPI Interface uses a modulus counter to derive the SPCK baud rate from the CLK_SPI. The Baud rate is
selected by writing a value from 1 to 255 in the SCBR field. The following equations determine the SPCK baud rate:
Writing the SCBR field to zero is forbidden. Triggering a transfer while SCBR is zero can lead to unpredictable results.
At reset, SCBR is zero and the user has to write it to a valid value before performing the first transfer.
If a clock divider (SCBRn) field is set to one and the other SCBR fields differ from one, access on CSn is correct but no correct
access will be possible on other CS.
31 30 29 28 27 26 25 24
DLYBCT
23 22 21 20 19 18 17 16
DLYBS
15 14 13 12 11 10 9 8
SCBR
76543210
BITS CSAAT CSNAAT NCPHA CPOL
Delay Between Consecutive Transfers 32 DLYBCT
CLKSPI = ------------------------------------
Delay Before SPCK DLYBS
CLKSPI = ---------------------
SPCK Baudrate CLKSPI
SCBR = ---------------------
513
32142D–06/2013
ATUC64/128/256L3/4U
• BITS: Bits Per Transfer
The BITS field determines the number of data bits transferred. Reserved values should not be used.
• CSAAT: Chip Select Active After Transfer
1: The Peripheral Chip Select does not rise after the last transfer is achieved. It remains active until a new transfer is requested
on a different chip select.
0: The Peripheral Chip Select Line rises as soon as the last transfer is achieved.
• CSNAAT: Chip Select Not Active After Transfer (Ignored if CSAAT = 1)
0: The Peripheral Chip Select does not rise between two transfers if the TDR is reloaded before the end of the first transfer and
if the two transfers occur on the same Chip Select.
1: The Peripheral Chip Select rises systematically between each transfer performed on the same slave for a minimal duration of:
(if DLYBCT field is different from 0)
(if DLYBCT field equals 0)
• NCPHA: Clock Phase
1: Data is captured after the leading (inactive-to-active) edge of SPCK and changed on the trailing (active-to-inactive) edge of
SPCK.
0: Data is changed on the leading (inactive-to-active) edge of SPCK and captured after the trailing (active-to-inactive) edge of
SPCK.
NCPHA determines which edge of SPCK causes data to change and which edge causes data to be captured. NCPHA is used
with CPOL to produce the required clock/data relationship between master and slave devices.
• CPOL: Clock Polarity
1: The inactive state value of SPCK is logic level one.
0: The inactive state value of SPCK is logic level zero.
BITS Bits Per Transfer
0000 8
0001 9
0010 10
0011 11
0100 12
0101 13
0110 14
0111 15
1000 16
1001 4
1010 5
1011 6
1100 7
1101 Reserved
1110 Reserved
1111 Reserved
DLYBCS
CLKSPI
-----------------------
DLYBCS + 1
CLKSPI
--------------------------------
514
32142D–06/2013
ATUC64/128/256L3/4U
CPOL is used to determine the inactive state value of the serial clock (SPCK). It is used with NCPHA to produce the required
clock/data relationship between master and slave devices.
515
32142D–06/2013
ATUC64/128/256L3/4U
21.8.11 Chip Select Register 2
Name: CSR2
Access Type: Read/Write
Offset: 0x38
Reset Value: 0x00000000
• DLYBCT: Delay Between Consecutive Transfers
This field defines the delay between two consecutive transfers with the same peripheral without removing the chip select. The
delay is always inserted after each transfer and before removing the chip select if needed.
When DLYBCT equals zero, no delay between consecutive transfers is inserted and the clock keeps its duty cycle over the
character transfers.
Otherwise, the following equation determines the delay:
• DLYBS: Delay Before SPCK
This field defines the delay from NPCS valid to the first valid SPCK transition.
When DLYBS equals zero, the NPCS valid to SPCK transition is 1/2 the SPCK clock period.
Otherwise, the following equations determine the delay:
• SCBR: Serial Clock Baud Rate
In Master Mode, the SPI Interface uses a modulus counter to derive the SPCK baud rate from the CLK_SPI. The Baud rate is
selected by writing a value from 1 to 255 in the SCBR field. The following equations determine the SPCK baud rate:
Writing the SCBR field to zero is forbidden. Triggering a transfer while SCBR is zero can lead to unpredictable results.
At reset, SCBR is zero and the user has to write it to a valid value before performing the first transfer.
If a clock divider (SCBRn) field is set to one and the other SCBR fields differ from one, access on CSn is correct but no correct
access will be possible on other CS.
31 30 29 28 27 26 25 24
DLYBCT
23 22 21 20 19 18 17 16
DLYBS
15 14 13 12 11 10 9 8
SCBR
76543210
BITS CSAAT CSNAAT NCPHA CPOL
Delay Between Consecutive Transfers 32 DLYBCT
CLKSPI = ------------------------------------
Delay Before SPCK DLYBS
CLKSPI = ---------------------
SPCK Baudrate CLKSPI
SCBR = ---------------------
516
32142D–06/2013
ATUC64/128/256L3/4U
• BITS: Bits Per Transfer
The BITS field determines the number of data bits transferred. Reserved values should not be used.
• CSAAT: Chip Select Active After Transfer
1: The Peripheral Chip Select does not rise after the last transfer is achieved. It remains active until a new transfer is requested
on a different chip select.
0: The Peripheral Chip Select Line rises as soon as the last transfer is achieved.
• CSNAAT: Chip Select Not Active After Transfer (Ignored if CSAAT = 1)
0: The Peripheral Chip Select does not rise between two transfers if the TDR is reloaded before the end of the first transfer and
if the two transfers occur on the same Chip Select.
1: The Peripheral Chip Select rises systematically between each transfer performed on the same slave for a minimal duration of:
(if DLYBCT field is different from 0)
(if DLYBCT field equals 0)
• NCPHA: Clock Phase
1: Data is captured after the leading (inactive-to-active) edge of SPCK and changed on the trailing (active-to-inactive) edge of
SPCK.
0: Data is changed on the leading (inactive-to-active) edge of SPCK and captured after the trailing (active-to-inactive) edge of
SPCK.
NCPHA determines which edge of SPCK causes data to change and which edge causes data to be captured. NCPHA is used
with CPOL to produce the required clock/data relationship between master and slave devices.
• CPOL: Clock Polarity
1: The inactive state value of SPCK is logic level one.
0: The inactive state value of SPCK is logic level zero.
BITS Bits Per Transfer
0000 8
0001 9
0010 10
0011 11
0100 12
0101 13
0110 14
0111 15
1000 16
1001 4
1010 5
1011 6
1100 7
1101 Reserved
1110 Reserved
1111 Reserved
DLYBCS
CLKSPI
-----------------------
DLYBCS + 1
CLKSPI
--------------------------------
517
32142D–06/2013
ATUC64/128/256L3/4U
CPOL is used to determine the inactive state value of the serial clock (SPCK). It is used with NCPHA to produce the required
clock/data relationship between master and slave devices.
518
32142D–06/2013
ATUC64/128/256L3/4U
21.8.12 Chip Select Register 3
Name: CSR3
Access Type: Read/Write
Offset: 0x3C
Reset Value: 0x00000000
• DLYBCT: Delay Between Consecutive Transfers
This field defines the delay between two consecutive transfers with the same peripheral without removing the chip select. The
delay is always inserted after each transfer and before removing the chip select if needed.
When DLYBCT equals zero, no delay between consecutive transfers is inserted and the clock keeps its duty cycle over the
character transfers.
Otherwise, the following equation determines the delay:
• DLYBS: Delay Before SPCK
This field defines the delay from NPCS valid to the first valid SPCK transition.
When DLYBS equals zero, the NPCS valid to SPCK transition is 1/2 the SPCK clock period.
Otherwise, the following equations determine the delay:
• SCBR: Serial Clock Baud Rate
In Master Mode, the SPI Interface uses a modulus counter to derive the SPCK baud rate from the CLK_SPI. The Baud rate is
selected by writing a value from 1 to 255 in the SCBR field. The following equations determine the SPCK baud rate:
Writing the SCBR field to zero is forbidden. Triggering a transfer while SCBR is zero can lead to unpredictable results.
At reset, SCBR is zero and the user has to write it to a valid value before performing the first transfer.
If a clock divider (SCBRn) field is set to one and the other SCBR fields differ from one, access on CSn is correct but no correct
access will be possible on other CS.
31 30 29 28 27 26 25 24
DLYBCT
23 22 21 20 19 18 17 16
DLYBS
15 14 13 12 11 10 9 8
SCBR
76543210
BITS CSAAT CSNAAT NCPHA CPOL
Delay Between Consecutive Transfers 32 DLYBCT
CLKSPI = ------------------------------------
Delay Before SPCK DLYBS
CLKSPI = ---------------------
SPCK Baudrate CLKSPI
SCBR = ---------------------
519
32142D–06/2013
ATUC64/128/256L3/4U
• BITS: Bits Per Transfer
The BITS field determines the number of data bits transferred. Reserved values should not be used.
• CSAAT: Chip Select Active After Transfer
1: The Peripheral Chip Select does not rise after the last transfer is achieved. It remains active until a new transfer is requested
on a different chip select.
0: The Peripheral Chip Select Line rises as soon as the last transfer is achieved.
• CSNAAT: Chip Select Not Active After Transfer (Ignored if CSAAT = 1)
0: The Peripheral Chip Select does not rise between two transfers if the TDR is reloaded before the end of the first transfer and
if the two transfers occur on the same Chip Select.
1: The Peripheral Chip Select rises systematically between each transfer performed on the same slave for a minimal duration of:
(if DLYBCT field is different from 0)
(if DLYBCT field equals 0)
• NCPHA: Clock Phase
1: Data is captured after the leading (inactive-to-active) edge of SPCK and changed on the trailing (active-to-inactive) edge of
SPCK.
0: Data is changed on the leading (inactive-to-active) edge of SPCK and captured after the trailing (active-to-inactive) edge of
SPCK.
NCPHA determines which edge of SPCK causes data to change and which edge causes data to be captured. NCPHA is used
with CPOL to produce the required clock/data relationship between master and slave devices.
• CPOL: Clock Polarity
1: The inactive state value of SPCK is logic level one.
0: The inactive state value of SPCK is logic level zero.
BITS Bits Per Transfer
0000 8
0001 9
0010 10
0011 11
0100 12
0101 13
0110 14
0111 15
1000 16
1001 4
1010 5
1011 6
1100 7
1101 Reserved
1110 Reserved
1111 Reserved
DLYBCS
CLKSPI
-----------------------
DLYBCS + 1
CLKSPI
--------------------------------
520
32142D–06/2013
ATUC64/128/256L3/4U
CPOL is used to determine the inactive state value of the serial clock (SPCK). It is used with NCPHA to produce the required
clock/data relationship between master and slave devices.
521
32142D–06/2013
ATUC64/128/256L3/4U
21.8.13 Write Protection Control Register
Register Name: WPCR
Access Type: Read-write
Offset: 0xE4
Reset Value: 0x00000000
• SPIWPKEY: SPI Write Protection Key Password
If a value is written in SPIWPEN, the value is taken into account only if SPIWPKEY is written with “SPI” (SPI written in ASCII
Code, i.e. 0x535049 in hexadecimal).
• SPIWPEN: SPI Write Protection Enable
1: The Write Protection is Enabled
0: The Write Protection is Disabled
31 30 29 28 27 26 25 24
SPIWPKEY[23:16]
23 22 21 20 19 18 17 16
SPIWPKEY[15:8]
15 14 13 12 11 10 9 8
SPIWPKEY[7:0]
76543210
- - - - - - - SPIWPEN
522
32142D–06/2013
ATUC64/128/256L3/4U
21.8.14 Write Protection Status Register
Register Name: WPSR
Access Type: Read-only
Offset: 0xE8
Reset Value: 0x00000000
• SPIWPVSRC: SPI Write Protection Violation Source
This Field indicates the Peripheral Bus Offset of the register concerned by the violation (MR or CSRx)
• SPIWPVS: SPI Write Protection Violation Status
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
SPIWPVSRC
76543210
- - - - - SPIWPVS
SPIWPVS value Violation Type
1 The Write Protection has blocked a Write access to a protected register (since the last read).
2 Software Reset has been performed while Write Protection was enabled (since the last read
or since the last write access on MR, IER, IDR or CSRx).
3 Both Write Protection violation and software reset with Write Protection enabled have
occurred since the last read.
4 Write accesses have been detected on MR (while a chip select was active) or on CSRi (while
the Chip Select “i” was active) since the last read.
5
The Write Protection has blocked a Write access to a protected register and write accesses
have been detected on MR (while a chip select was active) or on CSRi (while the Chip Select
“i” was active) since the last read.
6
Software Reset has been performed while Write Protection was enabled (since the last read
or since the last write access on MR, IER, IDR or CSRx) and some write accesses have been
detected on MR (while a chip select was active) or on CSRi (while the Chip Select “i” was
active) since the last read.
7
- The Write Protection has blocked a Write access to a protected register.
and
- Software Reset has been performed while Write Protection was enabled.
and
- Write accesses have been detected on MR (while a chip select was active) or on CSRi
(while the Chip Select “i” was active) since the last read.
523
32142D–06/2013
ATUC64/128/256L3/4U
21.8.15 Features Register
Register Name: FEATURES
Access Type: Read-only
Offset: 0xF8
Reset Value: –
• SWIMPL: Spurious Write Protection Implemented
0: Spurious write protection is not implemented.
1: Spurious write protection is implemented.
• FIFORIMPL: FIFO in Reception Implemented
0: FIFO in reception is not implemented.
1: FIFO in reception is implemented.
• BRPBHSB: Bridge Type is PB to HSB
0: Bridge type is not PB to HSB.
1: Bridge type is PB to HSB.
• CSNAATIMPL: CSNAAT Features Implemented
0: CSNAAT (Chip select not active after transfer) features are not implemented.
1: CSNAAT features are implemented.
• EXTDEC: External Decoder True
0: External decoder capability is not implemented.
1: External decoder capability is implemented.
• LENNCONF: Character Length if not Configurable
If the character length is not configurable, this field specifies the fixed character length.
• LENCONF: Character Length Configurable
0: The character length is not configurable.
1: The character length is configurable.
• PHZNCONF: Phase is Zero if Phase not Configurable
0: If phase is not configurable, phase is non-zero.
1: If phase is not configurable, phase is zero.
• PHCONF: Phase Configurable
0: Phase is not configurable.
1: Phase is configurable.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
- - - SWIMPL FIFORIMPL BRPBHSB CSNAATIMPL EXTDEC
15 14 13 12 11 10 9 8
LENNCONF LENCONF
76543210
PHZNCONF PHCONF PPNCONF PCONF NCS
524
32142D–06/2013
ATUC64/128/256L3/4U
• PPNCONF: Polarity Positive if Polarity not Configurable
0: If polarity is not configurable, polarity is negative.
1: If polarity is not configurable, polarity is positive.
• PCONF: Polarity Configurable
0: Polarity is not configurable.
1: Polarity is configurable.
• NCS: Number of Chip Selects
This field indicates the number of chip selects implemented.
525
32142D–06/2013
ATUC64/128/256L3/4U
21.8.16 Version Register
Register Name: VERSION
Access Type: Read-only
Offset: 0xFC
Reset Value: –
• MFN
Reserved. No functionality associated.
• VERSION
Version number of the module. No functionality associated.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
- - - - MFN
15 14 13 12 11 10 9 8
VERSION[11:8]
76543210
VERSION[7:0]
526
32142D–06/2013
ATUC64/128/256L3/4U
21.9 Module Configuration
The specific configuration for each SPI instance is listed in the following tables.The module bus
clocks listed here are connected to the system bus clocks. Please refer to the Power Manager
chapter for details.
Table 21-4. SPI Clock Name
Module Name Clock Name Description
SPI CLK_SPI Clock for the SPI bus interface
Table 21-5.
Register Reset Value
FEATURES 0x001F0154
VERSION 0x00000211
527
32142D–06/2013
ATUC64/128/256L3/4U
22. Two-wire Master Interface (TWIM)
Rev.: 1.1.0.1
22.1 Features
• Compatible with I²C standard
– Multi-master support
– Transfer speeds of 100 and 400 kbit/s
– 7- and 10-bit and General Call addressing
• Compatible with SMBus standard
– Hardware Packet Error Checking (CRC) generation and verification with ACK control
– SMBus ALERT interface
– 25 ms clock low timeout delay
– 10 ms master cumulative clock low extend time
– 25 ms slave cumulative clock low extend time
• Compatible with PMBus
• Compatible with Atmel Two-wire Interface Serial Memories
• DMA interface for reducing CPU load
• Arbitrary transfer lengths, including 0 data bytes
• Optional clock stretching if transmit or receive buffers not ready for data transfer
22.2 Overview
The Atmel Two-wire Master Interface (TWIM) interconnects components on a unique two-wire
bus, made up of one clock line and one data line with speeds of up to 400 kbit/s, based on a
byte-oriented transfer format. It can be used with any Atmel Two-wire Interface bus serial
EEPROM and I²C compatible device such as a real time clock (RTC), dot matrix/graphic LCD
controller, and temperature sensor, to name a few. The TWIM is always a bus master and can
transfer sequential or single bytes. Multiple master capability is supported. Arbitration of the bus
is performed internally and relinquishes the bus automatically if the bus arbitration is lost.
A configurable baud rate generator permits the output data rate to be adapted to a wide range of
core clock frequencies.Table 22-1 lists the compatibility level of the Atmel Two-wire Interface in
Master Mode and a full I²C compatible device.
Note: 1. START + b000000001 + Ack + Sr
Table 22-1. Atmel TWIM Compatibility with I²C Standard
I²C Standard Atmel TWIM
Standard-mode (100 kbit/s) Supported
Fast-mode (400 kbit/s) Supported
Fast-mode Plus (1 Mbit/s) Supported
7- or 10-bits Slave Addressing Supported
START BYTE(1) Not Supported
Repeated Start (Sr) Condition Supported
ACK and NACK Management Supported
Slope Control and Input Filtering (Fast mode) Supported
Clock Stretching Supported
528
32142D–06/2013
ATUC64/128/256L3/4U
Table 22-2 lists the compatibility level of the Atmel Two-wire Master Interface and a full SMBus
compatible master.
22.3 List of Abbreviations
22.4 Block Diagram
Figure 22-1. Block Diagram
Table 22-2. Atmel TWIM Compatibility with SMBus Standard
SMBus Standard Atmel TWIM
Bus Timeouts Supported
Address Resolution Protocol Supported
Alert Supported
Host Functionality Supported
Packet Error Checking Supported
Table 22-3. Abbreviations
Abbreviation Description
TWI Two-wire Interface
A Acknowledge
NA Non Acknowledge
P Stop
S Start
Sr Repeated Start
SADR Slave Address
ADR Any address except SADR
R Read
W Write
Peripheral
Bus Bridge
Two-wire
Interface
I/O Controller
TWCK
TWD
INTC
TWI Interrupt
Power
Manager
CLK_TWIM
TWALM
529
32142D–06/2013
ATUC64/128/256L3/4U
22.5 Application Block Diagram
Figure 22-2. Application Block Diagram
22.6 I/O Lines Description
22.7 Product Dependencies
In order to use this module, other parts of the system must be configured correctly, as described
below.
22.7.1 I/O Lines
TWD and TWCK are bidirectional lines, connected to a positive supply voltage via a current
source or pull-up resistor (see Figure 22-4 on page 531). When the bus is free, both lines are
high. The output stages of devices connected to the bus must have an open-drain or open-collector
to perform the wired-AND function.
TWALM is used to implement the optional SMBus SMBALERT signal.
The TWALM, TWD, and TWCK pins may be multiplexed with I/O Controller lines. To enable the
TWIM, the user must perform the following steps:
• Program the I/O Controller to:
– Dedicate TWD, TWCK, and optionally TWALM as peripheral lines.
– Define TWD, TWCK, and optionally TWALM as open-drain.
22.7.2 Power Management
If the CPU enters a sleep mode that disables clocks used by the TWIM, the TWIM will stop functioning
and resume operation after the system wakes up from sleep mode.
TWI
Master
TWD
TWCK
Atmel TWI
serial EEPROM I
2
C RTC I
2
C LCD
controller
I
2
C temp
sensor
Slave 2 Slave 3 Slave 4
VDD
Rp: pull-up value as given by the I2C Standard
TWALM
Slave 1
Rp Rp Rp
Table 22-4. I/O Lines Description
Pin Name Pin Description Type
TWD Two-wire Serial Data Input/Output
TWCK Two-wire Serial Clock Input/Output
TWALM SMBus SMBALERT Input/Output
530
32142D–06/2013
ATUC64/128/256L3/4U
22.7.3 Clocks
The clock for the TWIM bus interface (CLK_TWIM) is generated by the Power Manager. This
clock is enabled at reset, and can be disabled in the Power Manager. It is recommended to disable
the TWIM before disabling the clock, to avoid freezing the TWIM in an undefined state.
22.7.4 DMA
The TWIM DMA handshake interface is connected to the Peripheral DMA Controller. Using the
TWIM DMA functionality requires the Peripheral DMA Controller to be programmed after setting
up the TWIM.
22.7.5 Interrupts
The TWIM interrupt request lines are connected to the interrupt controller. Using the TWIM interrupts
requires the interrupt controller to be programmed first.
22.7.6 Debug Operation
When an external debugger forces the CPU into debug mode, the TWIM continues normal operation.
If the TWIM is configured in a way that requires it to be periodically serviced by the CPU
through interrupts or similar, improper operation or data loss may result during debugging.
531
32142D–06/2013
ATUC64/128/256L3/4U
22.8 Functional Description
22.8.1 Transfer Format
The data put on the TWD line must be 8 bits long. Data is transferred MSB first; each byte must
be followed by an acknowledgement. The number of bytes per transfer is unlimited (see Figure
22-4).
Each transfer begins with a START condition and terminates with a STOP condition (see Figure
22-4).
• A high-to-low transition on the TWD line while TWCK is high defines the START condition.
• A low-to-high transition on the TWD line while TWCK is high defines a STOP condition.
Figure 22-3. START and STOP Conditions
Figure 22-4. Transfer Format
22.8.2 Operation
The TWIM has two modes of operation:
• Master transmitter mode
• Master receiver mode
The master is the device which starts and stops a transfer and generates the TWCK clock.
These modes are described in the following chapters.
TWD
TWCK
Start Stop
TWD
TWCK
Start Address R/W Ack Data Ack Data Ack Stop
532
32142D–06/2013
ATUC64/128/256L3/4U
22.8.2.1 Clock Generation
The Clock Waveform Generator Register (CWGR) is used to control the waveform of the TWCK
clock. CWGR must be written so that the desired TWI bus timings are generated. CWGR
describes bus timings as a function of cycles of a prescaled clock. The clock prescaling can be
selected through the Clock Prescaler field in CWGR (CWGR.EXP).
CWGR has the following fields:
LOW: Prescaled clock cycles in clock low count. Used to time TLOW and TBUF.
HIGH: Prescaled clock cycles in clock high count. Used to time THIGH.
STASTO: Prescaled clock cycles in clock high count. Used to time THD_STA, TSU_STA, TSU_STO.
DATA: Prescaled clock cycles for data setup and hold count. Used to time THD_DAT, TSU_DAT.
EXP: Specifies the clock prescaler setting.
Note that the total clock low time generated is the sum of THD_DAT + TSU_DAT + TLOW.
Any slave or other bus master taking part in the transfer may extend the TWCK low period at any
time.
The TWIM hardware monitors the state of the TWCK line as required by the I²C specification.
The clock generation counters are started when a high/low level is detected on the TWCK line,
not when the TWIM hardware releases/drives the TWCK line. This means that the CWGR settings
alone do not determine the TWCK frequency. The CWGR settings determine the clock low
time and the clock high time, but the TWCK rise and fall times are determined by the external circuitry
(capacitive load, etc.).
Figure 22-5. Bus Timing Diagram
f
PRESCALER
f
CLK_TWIM
2 EXP 1 + = -------------------------
S t
HD:STA
t LOW
t
SU:DAT
t HIGH
t
HD:DAT
t LOW
P
t
SU:STO
Sr
t
SU:STA
t
SU:DAT
533
32142D–06/2013
ATUC64/128/256L3/4U
22.8.2.2 Setting up and Performing a Transfer
Operation of the TWIM is mainly controlled by the Control Register (CR) and the Command Register
(CMDR). TWIM status is provided in the Status Register (SR). The following list presents
the main steps in a typical communication:
1. Before any transfers can be performed, bus timings must be configured by writing to the
Clock Waveform Generator Register (CWGR). If operating in SMBus mode, the SMBus
Timing Register (SMBTR) register must also be configured.
2. If the Peripheral DMA Controller is to be used for the transfers, it must be set up.
3. CMDR or NCMDR must be written with a value describing the transfer to be performed.
The interrupt system can be set up to give interrupt requests on specific events or error conditions
in the SR, for example when the transfer is complete or if arbitration is lost. The Interrupt
Enable Register (IER) and Interrupt Disable Register (IDR) can be written to specify which bits in
the SR will generate interrupt requests.
The SR.BUSFREE bit is set when activity is completed on the two-wire bus. The SR.CRDY bit is
set when CMDR and/or NCMDR is ready to receive one or more commands.
The controller will refuse to start a new transfer while ANAK, DNAK, or ARBLST in the Status
Register (SR) is one. This is necessary to avoid a race when the software issues a continuation
of the current transfer at the same time as one of these errors happen. Also, if ANAK or DNAK
occurs, a STOP condition is sent automatically. The user will have to restart the transmission by
clearing the error bits in SR after resolving the cause for the NACK.
After a data or address NACK from the slave, a STOP will be transmitted automatically. Note
that the VALID bit in CMDR is NOT cleared in this case. If this transfer is to be discarded, the
VALID bit can be cleared manually allowing any command in NCMDR to be copied into CMDR.
When a data or address NACK is returned by the slave while the master is transmitting, it is possible
that new data has already been written to the THR register. This data will be transferred out
as the first data byte of the next transfer. If this behavior is to be avoided, the safest approach is
to perform a software reset of the TWIM.
22.8.3 Master Transmitter Mode
A START condition is transmitted and master transmitter mode is initiated when the bus is free
and CMDR has been written with START=1 and READ=0. START and SADR+W will then be
transmitted. During the address acknowledge clock pulse (9th pulse), the master releases the
data line (HIGH), enabling the slave to pull it down in order to acknowledge the address. The
master polls the data line during this clock pulse and sets the Address Not Acknowledged bit
(ANAK) in the Status Register if no slave acknowledges the address.
After the address phase, the following is repeated:
while (NBYTES>0)
1. Wait until THR contains a valid data byte, stretching low period of TWCK. SR.TXRDY
indicates the state of THR. Software or the Peripheral DMA Controller must write the
data byte to THR.
2. Transmit this data byte
3. Decrement NBYTES
4. If (NBYTES==0) and STOP=1, transmit STOP condition
Writing CMDR with START=STOP=1 and NBYTES=0 will generate a transmission with no data
bytes, ie START, SADR+W, STOP.
534
32142D–06/2013
ATUC64/128/256L3/4U
TWI transfers require the slave to acknowledge each received data byte. During the acknowledge
clock pulse (9th pulse), the master releases the data line (HIGH), enabling the slave to pull
it down in order to generate the acknowledge. The master polls the data line during this clock
pulse and sets the Data Acknowledge bit (DNACK) in the Status Register if the slave does not
acknowledge the data byte. As with the other status bits, an interrupt can be generated if
enabled in the Interrupt Enable Register (IER).
TXRDY is used as Transmit Ready for the Peripheral DMA Controller transmit channel.
The end of a command is marked when the TWIM sets the SR.CCOMP bit. See Figure 22-6 and
Figure 22-7.
Figure 22-6. Master Write with One Data Byte
Figure 22-7. Master Write with Multiple Data Bytes
22.8.4 Master Receiver Mode
A START condition is transmitted and master receiver mode is initiated when the bus is free and
CMDR has been written with START=1 and READ=1. START and SADR+R will then be transmitted.
During the address acknowledge clock pulse (9th pulse), the master releases the data
line (HIGH), enabling the slave to pull it down in order to acknowledge the address. The master
polls the data line during this clock pulse and sets the Address Not Acknowledged bit (ANAK) in
the Status Register if no slave acknowledges the address.
After the address phase, the following is repeated:
while (NBYTES>0)
TWD
SR.IDLE
TXRDY
Write THR (DATA)
NBYTES set to 1
STOP sent automatically
(ACK received and NBYTES=0)
S DADR W A DATA A P
TWD
SR.IDLE
TXRDY
Write THR
(DATAn)
NBYTES set to n
STOP sent automatically
(ACK received and NBYTES=0)
S DADR W A DATAn A DATAn+5 A A DATAn+m P
Write THR
(DATAn+1)
Write THR
(DATAn+m)
Last data sent
535
32142D–06/2013
ATUC64/128/256L3/4U
1. Wait until RHR is empty, stretching low period of TWCK. SR.RXRDY indicates the state
of RHR. Software or the Peripheral DMA Controller must read any data byte present in
RHR.
2. Release TWCK generating a clock that the slave uses to transmit a data byte.
3. Place the received data byte in RHR, set RXRDY.
4. If NBYTES=0, generate a NAK after the data byte, otherwise generate an ACK.
5. Decrement NBYTES
6. If (NBYTES==0) and STOP=1, transmit STOP condition.
Writing CMDR with START=STOP=1 and NBYTES=0 will generate a transmission with no data
bytes, ie START, DADR+R, STOP
The TWI transfers require the master to acknowledge each received data byte. During the
acknowledge clock pulse (9th pulse), the slave releases the data line (HIGH), enabling the master
to pull it down in order to generate the acknowledge. All data bytes except the last are
acknowledged by the master. Not acknowledging the last byte informs the slave that the transfer
is finished.
RXRDY is used as Receive Ready for the Peripheral DMA Controller receive channel.
Figure 22-8. Master Read with One Data Byte
Figure 22-9. Master Read with Multiple Data Bytes
TWD
SR.IDLE
RXRDY
Write START &
STOP bit
NBYTES set to 1
Read RHR
S DADR R A DATA N P
TWD
SR.IDLE
RXRDY
Write START +
STOP bit
NBYTES set to m
S DADR R A DATAn A DATAn+m-1 A N DATAn+m P
Read RHR
DATAn
DATAn+1
Read RHR
DATAn+m-2
Read RHR
DATAn+m-1
Read RHR
DATAn+m
Send STOP
When NBYTES=0
536
32142D–06/2013
ATUC64/128/256L3/4U
22.8.5 Using the Peripheral DMA Controller
The use of the Peripheral DMA Controller significantly reduces the CPU load. The user can set
up ring buffers for the Peripheral DMA Controller, containing data to transmit or free buffer space
to place received data.
To assure correct behavior, respect the following programming sequences:
22.8.5.1 Data Transmit with the Peripheral DMA Controller
1. Initialize the transmit Peripheral DMA Controller (memory pointers, size, etc.).
2. Configure the TWIM (ADR, NBYTES, etc.).
3. Start the transfer by enabling the Peripheral DMA Controller to transmit.
4. Wait for the Peripheral DMA Controller end-of-transmit flag.
5. Disable the Peripheral DMA Controller.
22.8.5.2 Data Receive with the Peripheral DMA Controller
1. Initialize the receive Peripheral DMA Controller (memory pointers, size, etc.).
2. Configure the TWIM (ADR, NBYTES, etc.).
3. Start the transfer by enabling the Peripheral DMA Controller to receive.
4. Wait for the Peripheral DMA Controller end-of-receive flag.
5. Disable the Peripheral DMA Controller.
22.8.6 Multi-master Mode
More than one master may access the bus at the same time without data corruption by using
arbitration.
Arbitration starts as soon as two or more masters place information on the bus at the same time,
and stops (arbitration is lost) for the master that intends to send a logical one while the other
master sends a logical zero.
As soon as arbitration is lost by a master, it stops sending data and listens to the bus in order to
detect a STOP. The SR.ARBLST flag will be set. When the STOP is detected, the master who
lost arbitration may reinitiate the data transfer.
Arbitration is illustrated in Figure 22-11.
If the user starts a transfer and if the bus is busy, the TWIM automatically waits for a STOP condition
on the bus before initiating the transfer (see Figure 22-10).
Note: The state of the bus (busy or free) is not indicated in the user interface.
537
32142D–06/2013
ATUC64/128/256L3/4U
Figure 22-10. User Sends Data While the Bus is Busy
Figure 22-11. Arbitration Cases
22.8.7 Combined Transfers
CMDR and NCMDR may be used to generate longer sequences of connected transfers, since
generation of START and/or STOP conditions is programmable on a per-command basis.
Writing NCMDR with START=1 when the previous transfer was written with STOP=0 will cause
a REPEATED START on the bus. The ability to generate such connected transfers allows arbitrary
transfer lengths, since it is legal to write CMDR with both START=0 and STOP=0. If this is
done in master receiver mode, the CMDR.ACKLAST bit must also be controlled.
TWCK
TWD DATA sent by a master
STOP sent by the master START sent by the TWI
DATA sent by the TWI
Bus is busy
Bus is free
A transfer is programmed
(DADR + W + START + Write THR) Transfer is initiated
TWI DATA transfer Transfer is kept
Bus is considered as free
TWCK
Bus is busy Bus is free
A transfer is programmed
(DADR + W + START + Write THR) Transfer is initiated
TWI DATA transfer Transfer is kept
Bus is considered as free
Data from a Master
Data from TWI S 0
S 0 0
1
1
1
ARBLST
S 0
S 0 0
1
1
1
TWD S 1 0 0
1 1
1 1
Arbitration is lost
TWI stops sending data
P
P S 1 0 0
1 1
Data from the master 1 1 Data from the TWI
Arbitration is lost
The master stops sending data
Transfer is stopped
Transfer is programmed again
(DADR + W + START + Write THR)
TWCK
TWD
538
32142D–06/2013
ATUC64/128/256L3/4U
As for single data transfers, the TXRDY and RXRDY bits in the Status Register indicates when
data to transmit can be written to THR, or when received data can be read from RHR. Transfer
of data to THR and from RHR can also be done automatically by DMA, see Section 22.8.5
22.8.7.1 Write Followed by Write
Consider the following transfer:
START, DADR+W, DATA+A, DATA+A, REPSTART, DADR+W, DATA+A, DATA+A, STOP.
To generate this transfer:
1. Write CMDR with START=1, STOP=0, DADR, NBYTES=2 and READ=0.
2. Write NCMDR with START=1, STOP=1, DADR, NBYTES=2 and READ=0.
3. Wait until SR.TXRDY==1, then write first data byte to transfer to THR.
4. Wait until SR.TXRDY==1, then write second data byte to transfer to THR.
5. Wait until SR.TXRDY==1, then write third data byte to transfer to THR.
6. Wait until SR.TXRDY==1, then write fourth data byte to transfer to THR.
22.8.7.2 Read Followed by Read
Consider the following transfer:
START, DADR+R, DATA+A, DATA+NA, REPSTART, DADR+R, DATA+A, DATA+NA, STOP.
To generate this transfer:
1. Write CMDR with START=1, STOP=0, DADR, NBYTES=2 and READ=1.
2. Write NCMDR with START=1, STOP=1, DADR, NBYTES=2 and READ=1.
3. Wait until SR.RXRDY==1, then read first data byte received from RHR.
4. Wait until SR.RXRDY==1, then read second data byte received from RHR.
5. Wait until SR.RXRDY==1, then read third data byte received from RHR.
6. Wait until SR.RXRDY==1, then read fourth data byte received from RHR.
If combining several transfers, without any STOP or REPEATED START between them, remember
to write a one to the ACKLAST bit in CMDR to keep from ending each of the partial transfers
with a NACK.
22.8.7.3 Write Followed by Read
Consider the following transfer:
START, DADR+W, DATA+A, DATA+A, REPSTART, DADR+R, DATA+A, DATA+NA, STOP.
539
32142D–06/2013
ATUC64/128/256L3/4U
Figure 22-12. Combining a Write and Read Transfer
To generate this transfer:
1. Write CMDR with START=1, STOP=0, DADR, NBYTES=2 and READ=0.
2. Write NCMDR with START=1, STOP=1, DADR, NBYTES=2 and READ=1.
3. Wait until SR.TXRDY==1, then write first data byte to transfer to THR.
4. Wait until SR.TXRDY==1, then write second data byte to transfer to THR.
5. Wait until SR.RXRDY==1, then read first data byte received from RHR.
6. Wait until SR.RXRDY==1, then read second data byte received from RHR.
22.8.7.4 Read Followed by Write
Consider the following transfer:
START, DADR+R, DATA+A, DATA+NA, REPSTART, DADR+W, DATA+A, DATA+A, STOP.
Figure 22-13. Combining a Read and Write Transfer
To generate this transfer:
1. Write CMDR with START=1, STOP=0, DADR, NBYTES=2 and READ=1.
2. Write NCMDR with START=1, STOP=1, DADR, NBYTES=2 and READ=0.
3. Wait until SR.RXRDY==1, then read first data byte received from RHR.
4. Wait until SR.RXRDY==1, then read second data byte received from RHR.
5. Wait until SR.TXRDY==1, then write first data byte to transfer to THR.
6. Wait until SR.TXRDY==1, then write second data byte to transfer to THR.
TWD
SR.IDLE
TXRDY
S DADR W A DATA0 A DATA1 NA Sr DADR R A DATA2 A DATA3 A P
THR DATA0 DATA1
RXRDY
1
RHR DATA2 DATA3
TWD
SR.IDLE
TXRDY
S SADR R A DATA0 A DATA1 Sr DADR W A DATA2 A DATA3 NA P
THR DATA2
RXRDY
RHR DATA0 DATA3
A
1
2
DATA3
Read
TWI_RHR
540
32142D–06/2013
ATUC64/128/256L3/4U
22.8.8 Ten Bit Addressing
Writing a one to CMDR.TENBIT enables 10-bit addressing in hardware. Performing transfers
with 10-bit addressing is similar to transfers with 7-bit addresses, except that bits 9:7 of
CMDR.SADR must be written appropriately.
In Figure 22-14 and Figure 22-15, the grey boxes represent signals driven by the master, the
white boxes are driven by the slave.
22.8.8.1 Master Transmitter
To perform a master transmitter transfer:
1. Write CMDR with TENBIT=1, REPSAME=0, READ=0, START=1, STOP=1 and the
desired address and NBYTES value.
Figure 22-14. A Write Transfer with 10-bit Addressing
22.8.8.2 Master Receiver
When using master receiver mode with 10-bit addressing, CMDR.REPSAME must also be controlled.
CMDR.REPSAME must be written to one when the address phase of the transfer should
consist of only 1 address byte (the 11110xx byte) and not 2 address bytes. The I²C standard
specifies that such addressing is required when addressing a slave for reads using 10-bit
addressing.
To perform a master receiver transfer:
1. Write CMDR with TENBIT=1, REPSAME=0, READ=0, START=1, STOP=0,
NBYTES=0 and the desired address.
2. Write NCMDR with TENBIT=1, REPSAME=1, READ=1, START=1, STOP=1 and the
desired address and NBYTES value.
Figure 22-15. A Read Transfer with 10-bit Addressing
22.8.9 SMBus Mode
SMBus mode is enabled and disabled by writing to the SMEN and SMDIS bits in CR. SMBus
mode operation is similar to I²C operation with the following exceptions:
• Only 7-bit addressing can be used.
• The SMBus standard describes a set of timeout values to ensure progress and throughput on
the bus. These timeout values must be written into SMBTR.
• Transmissions can optionally include a CRC byte, called Packet Error Check (PEC).
• A dedicated bus line, SMBALERT, allows a slave to get a master’s attention.
• A set of addresses have been reserved for protocol handling, such as Alert Response
Address (ARA) and Host Header (HH) Address.
S SLAVE ADDRESS
1st 7 bits RW A1 A2 DATA A P SLAVE ADDRESS
2nd byte DATA AA
11110XX0
S SLAVE ADDRESS
1st 7 bits RW A1 A2 DATA A P SLAVE ADDRESS
2nd byte DATA A
11110XX0
Sr SLAVE ADDRESS
1st 7 bits RW A3
11110XX1
541
32142D–06/2013
ATUC64/128/256L3/4U
22.8.9.1 Packet Error Checking
Each SMBus transfer can optionally end with a CRC byte, called the PEC byte. Writing a one to
CMDR.PECEN enables automatic PEC handling in the current transfer. Transfers with and without
PEC can freely be intermixed in the same system, since some slaves may not support PEC.
The PEC LFSR is always updated on every bit transmitted or received, so that PEC handling on
combined transfers will be correct.
In master transmitter mode, the master calculates a PEC value and transmits it to the slave after
all data bytes have been transmitted. Upon reception of this PEC byte, the slave will compare it
to the PEC value it has computed itself. If the values match, the data was received correctly, and
the slave will return an ACK to the master. If the PEC values differ, data was corrupted, and the
slave will return a NACK value. The DNAK bit in SR reflects the state of the last received
ACK/NACK value. Some slaves may not be able to check the received PEC in time to return a
NACK if an error occurred. In this case, the slave should always return an ACK after the PEC
byte, and some other mechanism must be implemented to verify that the transmission was
received correctly.
In master receiver mode, the slave calculates a PEC value and transmits it to the master after all
data bytes have been transmitted. Upon reception of this PEC byte, the master will compare it to
the PEC value it has computed itself. If the values match, the data was received correctly. If the
PEC values differ, data was corrupted, and SR.PECERR is set. In master receiver mode, the
PEC byte is always followed by a NACK transmitted by the master, since it is the last byte in the
transfer.
The PEC byte is automatically inserted in a master transmitter transmission if PEC is enabled
when NBYTES reaches zero. The PEC byte is identified in a master receiver transmission if
PEC is enabled when NBYTES reaches zero. NBYTES must therefore be written with the total
number of data bytes in the transmission, including the PEC byte.
In combined transfers, the PECEN bit should only be written to one in the last of the combined
transfers. Consider the following transfer:
S, ADR+W, COMMAND_BYTE, ACK, SR, ADR+R, DATA_BYTE, ACK, PEC_BYTE, NACK, P
This transfer is generated by writing two commands to the command registers. The first command
is a write with NBYTES=1 and PECEN=0, and the second is a read with NBYTES=2 and
PECEN=1.
Writing a one to the STOP bit in CR will place a STOP condition on the bus after the current
byte. No PEC byte will be sent in this case.
22.8.9.2 Timeouts
The TLOWS and TLOWM fields in SMBTR configure the SMBus timeout values. If a timeout
occurs, the master will transmit a STOP condition and leave the bus. The SR.TOUT bit is set.
22.8.9.3 SMBus ALERT Signal
A slave can get the master’s attention by pulling the TWALM line low. The TWIM will then set the
SR.SMBALERT bit. This can be set up to trigger an interrupt, and software can then take the
appropriate action, as defined in the SMBus standard.
542
32142D–06/2013
ATUC64/128/256L3/4U
22.8.10 Identifying Bus Events
This chapter lists the different bus events, and how they affect bits in the TWIM registers. This is
intended to help writing drivers for the TWIM.
Table 22-5. Bus Events
Event Effect
Master transmitter has sent
a data byte SR.THR is cleared.
Master receiver has
received a data byte SR.RHR is set.
Start+Sadr sent, no ack
received from slave
SR.ANAK is set.
SR.CCOMP not set.
CMDR.VALID remains set.
STOP automatically transmitted on bus.
Data byte sent to slave, no
ack received from slave
SR.DNAK is set.
SR.CCOMP not set.
CMDR.VALID remains set.
STOP automatically transmitted on bus.
Arbitration lost
SR.ARBLST is set.
SR.CCOMP not set.
CMDR.VALID remains set.
TWCK and TWD immediately released to a pulled-up state.
SMBus Alert received SR.SMBALERT is set.
SMBus timeout received
SR.SMBTOUT is set.
SR.CCOMP not set.
CMDR.VALID remains set.
STOP automatically transmitted on bus.
Master transmitter receives
SMBus PEC Error
SR.DNAK is set.
SR.CCOMP not set.
CMDR.VALID remains set.
STOP automatically transmitted on bus.
Master receiver discovers
SMBus PEC Error
SR.PECERR is set.
SR.CCOMP not set.
CMDR.VALID remains set.
STOP automatically transmitted on bus.
CR.STOP is written by user
SR.STOP is set.
SR.CCOMP set.
CMDR.VALID remains set.
STOP transmitted on bus after current byte transfer has finished.
543
32142D–06/2013
ATUC64/128/256L3/4U
22.9 User Interface
Note: 1. The reset values for these registers are device specific. Please refer to the Module Configuration section at the end of this
chapter.
Table 22-6. TWIM Register Memory Map
Offset Register Register Name Access Reset
0x00 Control Register CR Write-only 0x00000000
0x04 Clock Waveform Generator Register CWGR Read/Write 0x00000000
0x08 SMBus Timing Register SMBTR Read/Write 0x00000000
0x0C Command Register CMDR Read/Write 0x00000000
0x10 Next Command Register NCMDR Read/Write 0x00000000
0x14 Receive Holding Register RHR Read-only 0x00000000
0x18 Transmit Holding Register THR Write-only 0x00000000
0x1C Status Register SR Read-only 0x00000002
0x20 Interrupt Enable Register IER Write-only 0x00000000
0x24 Interrupt Disable Register IDR Write-only 0x00000000
0x28 Interrupt Mask Register IMR Read-only 0x00000000
0x2C Status Clear Register SCR Write-only 0x00000000
0x30 Parameter Register PR Read-only -(1)
0x34 Version Register VR Read-only -(1)
544
32142D–06/2013
ATUC64/128/256L3/4U
22.9.1 Control Register
Name: CR
Access Type: Write-only
Offset: 0x00
Reset Value: 0x00000000
• STOP: Stop the Current Transfer
Writing a one to this bit terminates the current transfer, sending a STOP condition after the shifter has become idle. If there are
additional pending transfers, they will have to be explicitly restarted by software after the STOP condition has been successfully
sent.
Writing a zero to this bit has no effect.
• SWRST: Software Reset
If the TWIM master interface is enabled, writing a one to this bit resets the TWIM. All transfers are halted immediately, possibly
violating the bus semantics.
If the TWIM master interface is not enabled, it must first be enabled before writing a one to this bit.
Writing a zero to this bit has no effect.
• SMDIS: SMBus Disable
Writing a one to this bit disables SMBus mode.
Writing a zero to this bit has no effect.
• SMEN: SMBus Enable
Writing a one to this bit enables SMBus mode.
Writing a zero to this bit has no effect.
• MDIS: Master Disable
Writing a one to this bit disables the master interface.
Writing a zero to this bit has no effect.
• MEN: Master Enable
Writing a one to this bit enables the master interface.
Writing a zero to this bit has no effect.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
- - - - - - - STOP
76543210
SWRST - SMDIS SMEN - - MDIS MEN
545
32142D–06/2013
ATUC64/128/256L3/4U
22.9.2 Clock Waveform Generator Register
Name: CWGR
Access Type: Read/Write
Offset: 0x04
Reset Value: 0x00000000
• EXP: Clock Prescaler
Used to specify how to prescale the TWCK clock. Counters are prescaled according to the following formula
• DATA: Data Setup and Hold Cycles
Clock cycles for data setup and hold count. Prescaled by CWGR.EXP. Used to time THD_DAT, TSU_DAT.
• STASTO: START and STOP Cycles
Clock cycles in clock high count. Prescaled by CWGR.EXP. Used to time THD_STA, TSU_STA, TSU_STO
• HIGH: Clock High Cycles
Clock cycles in clock high count. Prescaled by CWGR.EXP. Used to time THIGH.
• LOW: Clock Low Cycles
Clock cycles in clock low count. Prescaled by CWGR.EXP. Used to time TLOW, TBUF.
31 30 29 28 27 26 25 24
- EXP DATA
23 22 21 20 19 18 17 16
STASTO
15 14 13 12 11 10 9 8
HIGH
76543210
LOW
f
PRESCALER
f
CLK_TWIM
2 EXP 1 + = -------------------------
546
32142D–06/2013
ATUC64/128/256L3/4U
22.9.3 SMBus Timing Register
Name: SMBTR
Access Type: Read/Write
Offset: 0x08
Reset Value: 0x00000000
• EXP: SMBus Timeout Clock Prescaler
Used to specify how to prescale the TIM and TLOWM counters in SMBTR. Counters are prescaled according to the following
formula
• THMAX: Clock High Maximum Cycles
Clock cycles in clock high maximum count. Prescaled by SMBTR.EXP. Used for bus free detection. Used to time THIGH:MAX.
NOTE: Uses the prescaler specified by CWGR, NOT the prescaler specified by SMBTR.
• TLOWM: Master Clock Stretch Maximum Cycles
Clock cycles in master maximum clock stretch count. Prescaled by SMBTR.EXP. Used to time TLOW:MEXT
• TLOWS: Slave Clock Stretch Maximum Cycles
Clock cycles in slave maximum clock stretch count. Prescaled by SMBTR.EXP. Used to time TLOW:SEXT.
31 30 29 28 27 26 25 24
EXP - - - -
23 22 21 20 19 18 17 16
THMAX
15 14 13 12 11 10 9 8
TLOWM
76543210
TLOWS
f
prescaled SMBus
f
CLKTWIM
2 EXP + 1 = ------------------------
547
32142D–06/2013
ATUC64/128/256L3/4U
22.9.4 Command Register
Name: CMDR
Access Type: Read/Write
Offset: 0x0C
Reset Value: 0x00000000
• ACKLAST: ACK Last Master RX Byte
0: Causes the last byte in master receive mode (when NBYTES has reached 0) to be NACKed. This is the standard way of
ending a master receiver transfer.
1: Causes the last byte in master receive mode (when NBYTES has reached 0) to be ACKed. Used for performing linked
transfers in master receiver mode with no STOP or REPEATED START between the subtransfers. This is needed when more
than 255 bytes are to be received in one single transmission.
• PECEN: Packet Error Checking Enable
0: Causes the transfer not to use PEC byte verification. The PEC LFSR is still updated for every bit transmitted or received. Must
be used if SMBus mode is disabled.
1: Causes the transfer to use PEC. PEC byte generation (if master transmitter) or PEC byte verification (if master receiver) will
be performed.
• NBYTES: Number of Data Bytes in Transfer
The number of data bytes in the transfer. After the specified number of bytes have been transferred, a STOP condition is
transmitted if CMDR.STOP is one. In SMBus mode, if PEC is used, NBYTES includes the PEC byte, i.e. there are NBYTES-1
data bytes and a PEC byte.
• VALID: CMDR Valid
0: Indicates that CMDR does not contain a valid command.
1: Indicates that CMDR contains a valid command. This bit is cleared when the command is finished.
• STOP: Send STOP Condition
0: Do not transmit a STOP condition after the data bytes have been transmitted.
1: Transmit a STOP condition after the data bytes have been transmitted.
• START: Send START Condition
0: The transfer in CMDR should not commence with a START or REPEATED START condition.
1: The transfer in CMDR should commence with a START or REPEATED START condition. If the bus is free when the command
is executed, a START condition is used. If the bus is busy, a REPEATED START is used.
• REPSAME: Transfer is to Same Address as Previous Address
Only used in 10-bit addressing mode, always write to 0 in 7-bit addressing mode.
31 30 29 28 27 26 25 24
- - - - ACKLAST PECEN
23 22 21 20 19 18 17 16
NBYTES
15 14 13 12 11 10 9 8
VALID STOP START REPSAME TENBIT SADR[9:7]
76543210
SADR[6:0] READ
548
32142D–06/2013
ATUC64/128/256L3/4U
Write this bit to one if the command in CMDR performs a repeated start to the same slave address as addressed in the previous
transfer in order to enter master receiver mode.
Write this bit to zero otherwise.
• TENBIT: Ten Bit Addressing Mode
0: Use 7-bit addressing mode.
1: Use 10-bit addressing mode. Must not be used when the TWIM is in SMBus mode.
• SADR: Slave Address
Address of the slave involved in the transfer. Bits 9-7 are don’t care if 7-bit addressing is used.
• READ: Transfer Direction
0: Allow the master to transmit data.
1: Allow the master to receive data.
549
32142D–06/2013
ATUC64/128/256L3/4U
22.9.5 Next Command Register
Name: NCMDR
Access Type: Read/Write
Offset: 0x10
Reset Value: 0x00000000
This register is identical to CMDR. When the VALID bit in CMDR becomes 0, the content of NCMDR is copied into CMDR,
clearing the VALID bit in NCMDR. If the VALID bit in CMDR is cleared when NCMDR is written, the content is copied
immediately.
31 30 29 28 27 26 25 24
- - - - ACKLAST PECEN
23 22 21 20 19 18 17 16
NBYTES
15 14 13 12 11 10 9 8
VALID STOP START REPSAME TENBIT SADR[9:7]
76543210
SADR[6:0] READ
550
32142D–06/2013
ATUC64/128/256L3/4U
22.9.6 Receive Holding Register
Name: RHR
Access Type: Read-only
Offset: 0x14
Reset Value: 0x00000000
• RXDATA: Received Data
When the RXRDY bit in the Status Register (SR) is one, this field contains a byte received from the TWI bus.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
--------
76543210
RXDATA
551
32142D–06/2013
ATUC64/128/256L3/4U
22.9.7 Transmit Holding Register
Name: THR
Access Type: Write-only
Offset: 0x18
Reset Value: 0x00000000
• TXDATA: Data to Transmit
Write data to be transferred on the TWI bus here.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
--------
76543210
TXDATA
552
32142D–06/2013
ATUC64/128/256L3/4U
22.9.8 Status Register
Name: SR
Access Type: Read-only
Offset: 0x1C
Reset Value: 0x00000002
• MENB: Master Interface Enable
0: Master interface is disabled.
1: Master interface is enabled.
• STOP: Stop Request Accepted
This bit is one when a STOP request caused by writing a one to CR.STOP has been accepted, and transfer has stopped.
This bit is cleared by writing 1 to the corresponding bit in the Status Clear Register (SCR).
• PECERR: PEC Error
This bit is one when a SMBus PEC error occurred.
This bit is cleared by writing 1 to the corresponding bit in the Status Clear Register (SCR).
• TOUT: Timeout
This bit is one when a SMBus timeout occurred.
This bit is cleared by writing 1 to the corresponding bit in the Status Clear Register (SCR).
• SMBALERT: SMBus Alert
This bit is one when an SMBus Alert was received.
This bit is cleared by writing 1 to the corresponding bit in the Status Clear Register (SCR).
• ARBLST: Arbitration Lost
This bit is one when the actual state of the SDA line did not correspond to the data driven onto it, indicating a higher-priority
transmission in progress by a different master.
This bit is cleared by writing 1 to the corresponding bit in the Status Clear Register (SCR).
• DNAK: NAK in Data Phase Received
This bit is one when no ACK was received form slave during data transmission.
This bit is cleared by writing 1 to the corresponding bit in the Status Clear Register (SCR).
• ANAK: NAK in Address Phase Received
This bit is one when no ACK was received from slave during address phase
This bit is cleared by writing 1 to the corresponding bit in the Status Clear Register (SCR).
• BUSFREE: Two-wire Bus is Free
This bit is one when activity has completed on the two-wire bus.
Otherwise, this bit is cleared.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
- - - - - - - MENB
15 14 13 12 11 10 9 8
- STOP PECERR TOUT SMBALERT ARBLST DNAK ANAK
76543210
- - BUSFREE IDLE CCOMP CRDY TXRDY RXRDY
553
32142D–06/2013
ATUC64/128/256L3/4U
• IDLE: Master Interface is Idle
This bit is one when no command is in progress, and no command waiting to be issued.
Otherwise, this bit is cleared.
• CCOMP: Command Complete
This bit is one when the current command has completed successfully.
This bit is zero if the command failed due to conditions such as a NAK receved from slave.
This bit is cleared by writing 1 to the corresponding bit in the Status Clear Register (SCR).
• CRDY: Ready for More Commands
This bit is one when CMDR and/or NCMDR is ready to receive one or more commands.
This bit is cleared when this is no longer true.
• TXRDY: THR Data Ready
This bit is one when THR is ready for one or more data bytes.
This bit is cleared when this is no longer true (i.e. THR is full or transmission has stopped).
• RXRDY: RHR Data Ready
This bit is one when RX data are ready to be read from RHR.
This bit is cleared when this is no longer true.
554
32142D–06/2013
ATUC64/128/256L3/4U
22.9.9 Interrupt Enable Register
Name: IER
Access Type: Write-only
Offset: 0x20
Reset Value: 0x00000000
Writing a zero to a bit in this register has no effect.
Writing a one to a bit in this register will set the corresponding bit in IMR
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
- STOP PECERR TOUT SMBALERT ARBLST DNAK ANAK
76543210
- - BUSFREE IDLE CCOMP CRDY TXRDY RXRDY
555
32142D–06/2013
ATUC64/128/256L3/4U
22.9.10 Interrupt Disable Register
Name: IDR
Access Type: Write-only
Offset: 0x24
Reset Value: 0x00000000
Writing a zero to a bit in this register has no effect.
Writing a one to a bit in this register will clear the corresponding bit in IMR
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
- STOP PECERR TOUT SMBALERT ARBLST DNAK ANAK
76543210
- - BUSFREE IDLE CCOMP CRDY TXRDY RXRDY
556
32142D–06/2013
ATUC64/128/256L3/4U
22.9.11 Interrupt Mask Register
Name: IMR
Access Type: Read-only
Offset: 0x28
Reset Value: 0x00000000
0: The corresponding interrupt is disabled.
1: The corresponding interrupt is enabled.
This bit is cleared when the corresponding bit in IDR is written to one.
This bit is set when the corresponding bit in IER is written to one.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
- STOP PECERR TOUT SMBALERT ARBLST DNAK ANAK
76543210
- - BUSFREE IDLE CCOMP CRDY TXRDY RXRDY
557
32142D–06/2013
ATUC64/128/256L3/4U
22.9.12 Status Clear Register
Name: SCR
Access Type : Write-only
Offset: 0x2C
Reset Value: 0x00000000
Writing a zero to a bit in this register has no effect.
Writing a one to a bit in this register will clear the corresponding bit in SR and the corresponding interrupt request.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
- STOP PECERR TOUT SMBALERT ARBLST DNAK ANAK
76543210
- - - - CCOMP - - -
558
32142D–06/2013
ATUC64/128/256L3/4U
22.9.13 Parameter Register (PR)
Name: PR
Access Type: Read-only
Offset: 0x30
Reset Value: -
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
--------
76543210
--------
559
32142D–06/2013
ATUC64/128/256L3/4U
22.9.14 Version Register (VR)
Name: VR
Access Type: Read-only
Offset: 0x34
Reset Value: -
• VARIANT: Variant Number
Reserved. No functionality associated.
• VERSION: Version Number
Version number of the module. No functionality associated.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
- - - - VARIANT
15 14 13 12 11 10 9 8
- - - - VERSION [11:8]
76543210
VERSION [7:0]
560
32142D–06/2013
ATUC64/128/256L3/4U
22.10 Module Configuration
The specific configuration for each TWIM instance is listed in the following tables.The module
bus clocks listed here are connected to the system bus clocks. Please refer to the Power Manager
chapter for details.
Table 22-7. Module Clock Name
Module Name Clock Name Description
TWIM0 CLK_TWIM0 Clock for the TWIM0 bus interface
TWIM1 CLK_TWIM1 Clock for the TWIM1 bus interface
Table 22-8. Register Reset Values
Register Reset Value
VERSION 0x00000110
PARAMETER 0x00000000
561
32142D–06/2013
ATUC64/128/256L3/4U
23. Two-wire Slave Interface (TWIS)
Rev.: 1.2.0.1
23.1 Features
• Compatible with I²C standard
– Transfer speeds of 100 and 400 kbit/s
– 7 and 10-bit and General Call addressing
• Compatible with SMBus standard
– Hardware Packet Error Checking (CRC) generation and verification with ACK response
– SMBALERT interface
– 25 ms clock low timeout delay
– 25 ms slave cumulative clock low extend time
• Compatible with PMBus
• DMA interface for reducing CPU load
• Arbitrary transfer lengths, including 0 data bytes
• Optional clock stretching if transmit or receive buffers not ready for data transfer
• 32-bit Peripheral Bus interface for configuration of the interface
23.2 Overview
The Atmel Two-wire Slave Interface (TWIS) interconnects components on a unique two-wire
bus, made up of one clock line and one data line with speeds of up to 400 kbit/s, based on a
byte-oriented transfer format. It can be used with any Atmel Two-wire Interface bus, I²C, or
SMBus-compatible master. The TWIS is always a bus slave and can transfer sequential or single
bytes.
Below, Table 23-1 lists the compatibility level of the Atmel Two-wire Slave Interface and a full I²C
compatible device.
Note: 1. START + b000000001 + Ack + Sr
Table 23-1. Atmel TWIS Compatibility with I²C Standard
I²C Standard Atmel TWIS
Standard-mode (100 kbit/s) Supported
Fast-mode (400 kbit/s) Supported
7 or 10 bits Slave Addressing Supported
START BYTE(1) Not Supported
Repeated Start (Sr) Condition Supported
ACK and NAK Management Supported
Slope control and input filtering (Fast mode) Supported
Clock stretching Supported
562
32142D–06/2013
ATUC64/128/256L3/4U
Below, Table 23-2 lists the compatibility level of the Atmel Two-wire Slave Interface and a full
SMBus compatible device.
23.3 List of Abbreviations
23.4 Block Diagram
Figure 23-1. Block Diagram
Table 23-2. Atmel TWIS Compatibility with SMBus Standard
SMBus Standard Atmel TWIS
Bus Timeouts Supported
Address Resolution Protocol Supported
Alert Supported
Packet Error Checking Supported
Table 23-3. Abbreviations
Abbreviation Description
TWI Two-wire Interface
A Acknowledge
NA Non Acknowledge
P Stop
S Start
Sr Repeated Start
SADR Slave Address
ADR Any address except SADR
R Read
W Write
Peripheral
Bus Bridge
Two-wire
Interface
I/O Controller
TWCK
TWD
Interrupt
Controller
TWI Interrupt
Power
Manager
CLK_TWIS
TWALM
563
32142D–06/2013
ATUC64/128/256L3/4U
23.5 Application Block Diagram
Figure 23-2. Application Block Diagram
23.6 I/O Lines Description
23.7 Product Dependencies
In order to use this module, other parts of the system must be configured correctly, as described
below.
23.7.1 I/O Lines
TWDand TWCK are bidirectional lines, connected to a positive supply voltage via a current
source or pull-up resistor (see Figure 23-5 on page 565). When the bus is free, both lines are
high. The output stages of devices connected to the bus must have an open-drain or open-collector
to perform the wired-AND function.
TWALM is used to implement the optional SMBus SMBALERT signal.
TWALM, TWD, and TWCK pins may be multiplexed with I/O Controller lines. To enable the
TWIS, the user must perform the following steps:
• Program the I/O Controller to:
– Dedicate TWD, TWCK, and optionally TWALM as peripheral lines.
– Define TWD, TWCK, and optionally TWALM as open-drain.
Host with
TWI
Interface
TWD
TWCK
Atmel TWI
serial EEPROM I²C RTC I²C LCD
controller
Slave 1 Slave 2 Slave 3
VDD
I²C temp.
sensor
Slave 4
Rp: Pull up value as given by the I²C Standard
Rp Rp
Table 23-4. I/O Lines Description
Pin Name Pin Description Type
TWD Two-wire Serial Data Input/Output
TWCK Two-wire Serial Clock Input/Output
TWALM SMBus SMBALERT Input/Output
564
32142D–06/2013
ATUC64/128/256L3/4U
23.7.2 Power Management
If the CPU enters a sleep mode that disables clocks used by the TWIS, the TWIS will stop functioning
and resume operation after the system wakes up from sleep mode. The TWIS is able to
wake the system from sleep mode upon address match, see Section 23.8.8 on page 572.
23.7.3 Clocks
The clock for the TWIS bus interface (CLK_TWIS) is generated by the Power Manager. This
clock is enabled at reset, and can be disabled in the Power Manager. It is recommended to disable
the TWIS before disabling the clock, to avoid freezing the TWIS in an undefined state.
23.7.4 DMA
The TWIS DMA handshake interface is connected to the Peripheral DMA Controller. Using the
TWIS DMA functionality requires the Peripheral DMA Controller to be programmed after setting
up the TWIS.
23.7.5 Interrupts
The TWIS interrupt request lines are connected to the interrupt controller. Using the TWIS interrupts
requires the interrupt controller to be programmed first.
23.7.6 Debug Operation
When an external debugger forces the CPU into debug mode, the TWIS continues normal operation.
If the TWIS is configured in a way that requires it to be periodically serviced by the CPU
through interrupts or similar, improper operation or data loss may result during debugging.
23.8 Functional Description
23.8.1 Transfer Format
The data put on the TWD line must be 8 bits long. Data is transferred MSB first; each byte must
be followed by an acknowledgement. The number of bytes per transfer is unlimited (see Figure
23-4 on page 565).
Each transfer begins with a START condition and terminates with a STOP condition (see Figure
23-3).
• A high-to-low transition on the TWD line while TWCK is high defines the START condition.
• A low-to-high transition on the TWD line while TWCK is high defines a STOP condition.
Figure 23-3. START and STOP Conditions
TWD
TWCK
Start Stop
565
32142D–06/2013
ATUC64/128/256L3/4U
Figure 23-4. Transfer Format
23.8.2 Operation
The TWIS has two modes of operation:
• Slave transmitter mode
• Slave receiver mode
A master is a device which starts and stops a transfer and generates the TWCK clock. A slave is
assigned an address and responds to requests from the master. These modes are described in
the following chapters.
Figure 23-5. Typical Application Block Diagram
23.8.2.1 Bus Timing
The Timing Register (TR) is used to control the timing of bus signals driven by the TWIS. TR
describes bus timings as a function of cycles of the prescaled CLK_TWIS. The clock prescaling
can be selected through TR.EXP.
TR has the following fields:
TLOWS: Prescaled clock cycles used to time SMBUS timeout TLOW:SEXT.
TWD
TWCK
Start Address R/W Ack Data Ack Data Ack Stop
Host with
TWI
Interface
TWD
TWCK
Atmel TWI
Serial EEPROM I²C RTC I²C LCD
Controller
Slave 1 Slave 2 Slave 3
VDD
I²C Temp.
Sensor
Slave 4
Rp: Pull up value as given by the I²C Standard
Rp Rp
fPRESCALED
f
CLK_TWIS
2 EXP 1 + = ------------------------
566
32142D–06/2013
ATUC64/128/256L3/4U
TTOUT: Prescaled clock cycles used to time SMBUS timeout TTIMEOUT.
SUDAT: Non-prescaled clock cycles for data setup and hold count. Used to time TSU_DAT.
EXP: Specifies the clock prescaler setting used for the SMBUS timeouts.
Figure 23-6. Bus Timing Diagram
23.8.2.2 Setting Up and Performing a Transfer
Operation of the TWIS is mainly controlled by the Control Register (CR). The following list presents
the main steps in a typical communication:
3. Before any transfers can be performed, bus timings must be configured by writing to the
Timing Register (TR).If the Peripheral DMA Controller is to be used for the transfers, it
must be set up.
4. The Control Register (CR) must be configured with information such as the slave
address, SMBus mode, Packet Error Checking (PEC), number of bytes to transfer, and
which addresses to match.
The interrupt system can be set up to generate interrupt request on specific events or error conditions,
for example when a byte has been received.
The NBYTES register is only used in SMBus mode, when PEC is enabled. In I²C mode or in
SMBus mode when PEC is disabled, the NBYTES register is not used, and should be written to
zero. NBYTES is updated by hardware, so in order to avoid hazards, software updates of
NBYTES can only be done through writes to the NBYTES register.
23.8.2.3 Address Matching
The TWIS can be set up to match several different addresses. More than one address match
may be enabled simultaneously, allowing the TWIS to be assigned to several addresses. The
address matching phase is initiated after a START or REPEATED START condition. When the
TWIS receives an address that generates an address match, an ACK is automatically returned
to the master.
S t
HD:STA
t LOW
t
SU:DAT
t HIGH
t
HD:DAT
t LOW
P
t
SU:STO
Sr
t
SU:STA
t
SU:DAT
567
32142D–06/2013
ATUC64/128/256L3/4U
In I²C mode:
• The address in CR.ADR is checked for address match if CR.SMATCH is one.
• The General Call address is checked for address match if CR.GCMATCH is one.
In SMBus mode:
• The address in CR.ADR is checked for address match if CR.SMATCH is one.
• The Alert Response Address is checked for address match if CR.SMAL is one.
• The Default Address is checked for address match if CR.SMDA is one.
• The Host Header Address is checked for address match if CR.SMHH is one.
23.8.2.4 Clock Stretching
Any slave or bus master taking part in a transfer may extend the TWCK low period at any time.
The TWIS may extend the TWCK low period after each byte transfer if CR.STREN is one and:
• Module is in slave transmitter mode, data should be transmitted, but THR is empty, or
• Module is in slave receiver mode, a byte has been received and placed into the internal
shifter, but the Receive Holding Register (RHR) is full, or
• Stretch-on-address-match bit CR.SOAM=1 and slave was addressed. Bus clock remains
stretched until all address match bits in the Status Register (SR) have been cleared.
If CR.STREN is zero and:
• Module is in slave transmitter mode, data should be transmitted but THR is empty: Transmit
the value present in THR (the last transmitted byte or reset value), and set SR.URUN.
• Module is in slave receiver mode, a byte has been received and placed into the internal
shifter, but RHR is full: Discard the received byte and set SR.ORUN.
23.8.2.5 Bus Errors
If a bus error (misplaced START or STOP) condition is detected, the SR.BUSERR bit is set and
the TWIS waits for a new START condition.
23.8.3 Slave Transmitter Mode
If the TWIS matches an address in which the R/W bit in the TWI address phase transfer is set, it
will enter slave transmitter mode and set the SR.TRA bit (note that SR.TRA is set one
CLK_TWIS cycle after the relevant address match bit in the same register is set).
After the address phase, the following actions are performed:
1. If SMBus mode and PEC is used, NBYTES must be set up with the number of bytes to
transmit. This is necessary in order to know when to transmit the PEC byte. NBYTES
can also be used to count the number of bytes received if using DMA.
2. Byte to transmit depends on I²C/SMBus mode and CR.PEC:
– If in I²C mode or CR.PEC is zero or NBYTES is non-zero: The TWIS waits until THR
contains a valid data byte, possibly stretching the low period of TWCK. After THR
contains a valid data byte, the data byte is transferred to a shifter, and then
SR.TXRDY is changed to one because the THR is empty again.
– SMBus mode and CR.PEC is one: If NBYTES is zero, the generated PEC byte is
automatically transmitted instead of a data byte from THR. TWCK will not be
stretched by the TWIS.
3. The data byte in the shifter is transmitted.
568
32142D–06/2013
ATUC64/128/256L3/4U
4. NBYTES is updated. If CR.CUP is one, NBYTES is incremented, otherwise NBYTES is
decremented.
5. After each data byte has been transmitted, the master transmits an ACK (Acknowledge)
or NAK (Not Acknowledge) bit. If a NAK bit is received by the TWIS, the SR.NAK bit is
set. Note that this is done two CLK_TWIS cycles after TWCK has been sampled by the
TWIS to be HIGH (see Figure 23-9). The NAK indicates that the transfer is finished, and
the TWIS will wait for a STOP or REPEATED START. If an ACK bit is received, the
SR.NAK bit remains LOW. The ACK indicates that more data should be transmitted,
jump to step 2. At the end of the ACK/NAK clock cycle, the Byte Transfer Finished
(SR.BTF) bit is set. Note that this is done two CLK_TWIS cycles after TWCK has been
sampled by the TWIS to be LOW (see Figure 23-9). Also note that in the event that
SR.NAK bit is set, it must not be cleared before the SR.BTF bit is set to ensure correct
TWIS behavior.
6. If STOP is received, SR.TCOMP and SR.STO will be set.
7. If REPEATED START is received, SR.REP will be set.
The TWI transfers require the receiver to acknowledge each received data byte. During the
acknowledge clock pulse (9th pulse), the slave releases the data line (HIGH), enabling the master
to pull it down in order to generate the acknowledge. The slave polls the data line during this
clock pulse and sets the NAK bit in SR if the master does not acknowledge the data byte. A NAK
means that the master does not wish to receive additional data bytes. As with the other status
bits, an interrupt can be generated if enabled in the Interrupt Enable Register (IER).
SR.TXRDY is used as Transmit Ready for the Peripheral DMA Controller transmit channel.
The end of the complete transfer is marked by the SR.TCOMP bit changing from zero to one.
See Figure 23-7 and Figure 23-8.
Figure 23-7. Slave Transmitter with One Data Byte
TCOMP
TXRDY
Write THR (DATA) STOP sent by master
TWD S DADR R P A DATA N
NBYTES set to 1
569
32142D–06/2013
ATUC64/128/256L3/4U
Figure 23-8. Slave Transmitter with Multiple Data Bytes
Figure 23-9. Timing Relationship between TWCK, SR.NAK, and SR.BTF
23.8.4 Slave Receiver Mode
If the TWIS matches an address in which the R/W bit in the TWI address phase transfer is
cleared, it will enter slave receiver mode and clear SR.TRA (note that SR.TRA is cleared one
CLK_TWIS cycle after the relevant address match bit in the same register is set).
After the address phase, the following is repeated:
1. If SMBus mode and PEC is used, NBYTES must be set up with the number of bytes to
receive. This is necessary in order to know which of the received bytes is the PEC byte.
NBYTES can also be used to count the number of bytes received if using DMA.
2. Receive a byte. Set SR.BTF when done.
3. Update NBYTES. If CR.CUP is written to one, NBYTES is incremented, otherwise
NBYTES is decremented. NBYTES is usually configured to count downwards if PEC is
used.
4. After a data byte has been received, the slave transmits an ACK or NAK bit. For ordinary
data bytes, the CR.ACK field controls if an ACK or NAK should be returned. If PEC
is enabled and the last byte received was a PEC byte (indicated by NBYTES equal to
zero), The TWIS will automatically return an ACK if the PEC value was correct, otherwise
a NAK will be returned.
5. If STOP is received, SR.TCOMP will be set.
6. If REPEATED START is received, SR.REP will be set.
The TWI transfers require the receiver to acknowledge each received data byte. During the
acknowledge clock pulse (9th pulse), the master releases the data line (HIGH), enabling the
S DADR R DATA n+5 A P A DATA n A DATA n+m N
TCOMP
TXRDY
Write THR (Data n)
NBYTES set to m
STOP sent by master
TWD
Write THR (Data n+1) Write THR (Data n+m)
Last data sent
DATA (LSB) N P
TWCK
SR.NAK
SR.BTF
t1 t1
t1: (CLK_TWIS period) x 2
TWD
570
32142D–06/2013
ATUC64/128/256L3/4U
slave to pull it down in order to generate the acknowledge. The master polls the data line during
this clock pulse.
The SR.RXRDY bit indicates that a data byte is available in the RHR. The RXRDY bit is also
used as Receive Ready for the Peripheral DMA Controller receive channel.
Figure 23-10. Slave Receiver with One Data Byte
Figure 23-11. Slave Receiver with Multiple Data Bytes
23.8.5 Interactive ACKing Received Data Bytes
When implementing a register interface over TWI, it may sometimes be necessary or just useful
to report reads and writes to invalid register addresses by sending a NAK to the host. To be able
to do this, one must first receive the register address from the TWI bus, and then tell the TWIS
whether to ACK or NAK it. In normal operation of the TWIS, this is not possible because the controller
will automatically ACK the byte at about the same time as the RXRDY bit changes from
zero to one. Writing a one to the Stretch on Data Byte Received bit (CR.SODR) will stretch the
clock allowing the user to update CR.ACK bit before returning the desired value. After the last bit
in the data byte is received, the TWI bus clock is stretched, the received data byte is transferred
to the RHR register, and SR.BTF is set. At this time, the user can examine the received byte and
write the desired ACK or NACK value to CR.ACK. When the user clears SR.BTF, the desired
ACK value is transferred on the TWI bus. This makes it possible to look at the byte received,
determine if it is valid, and then decide to ACK or NAK it.
23.8.6 Using the Peripheral DMA Controller
The use of the Peripheral DMA Controller significantly reduces the CPU load. The user can set
up ring buffers for the Peripheral DMA Controller, containing data to transmit or free buffer space
to place received data. By initializing NBYTES to zero before a transfer, and writing a one to
CR.CUP, NBYTES is incremented by one each time a data has been transmitted or received.
This allows the user to detect how much data was actually transferred by the DMA system.
S DADR W DATA A P A
TCOMP
RXRDY
Read RHR
TWD
TWD S DADR W DATA n A A A DATA (n+1) A DATA (n+m) DATA (n+m)-1 P A
TCOMP
RXRDY
Read RHR
DATA n
Read RHR
DATA (n+1)
Read RHR
DATA (n+m)-1
Read RHR
DATA (n+m)
571
32142D–06/2013
ATUC64/128/256L3/4U
To assure correct behavior, respect the following programming sequences:
23.8.6.1 Data Transmit with the Peripheral DMA Controller
1. Initialize the transmit Peripheral DMA Controller (memory pointers, size, etc.).
2. Configure the TWIS (ADR, NBYTES, etc.).
3. Start the transfer by enabling the Peripheral DMA Controller to transmit.
4. Wait for the Peripheral DMA Controller end-of-transmit flag.
5. Disable the Peripheral DMA Controller.
23.8.6.2 Data Receive with the Peripheral DMA Controller
1. Initialize the receive Peripheral DMA Controller (memory pointers, size - 1, etc.).
2. Configure the TWIS (ADR, NBYTES, etc.).
3. Start the transfer by enabling the Peripheral DMA Controller to receive.
4. Wait for the Peripheral DMA Controller end-of-receive flag.
5. Disable the Peripheral DMA Controller.
23.8.7 SMBus Mode
SMBus mode is enabled by writing a one to the SMBus Mode Enable (SMEN) bit in CR. SMBus
mode operation is similar to I²C operation with the following exceptions:
• Only 7-bit addressing can be used.
• The SMBus standard describes a set of timeout values to ensure progress and throughput on
the bus. These timeout values must be written to TR.
• Transmissions can optionally include a CRC byte, called Packet Error Check (PEC).
• A dedicated bus line, SMBALERT, allows a slave to get a master’s attention.
• A set of addresses have been reserved for protocol handling, such as Alert Response
Address (ARA) and Host Header (HH) Address. Address matching on these addresses can
be enabled by configuring CR appropriately.
23.8.7.1 Packet Error Checking (PEC)
Each SMBus transfer can optionally end with a CRC byte, called the PEC byte. Writing a one to
the Packet Error Checking Enable (PECEN) bit in CR enables automatic PEC handling in the
current transfer. The PEC generator is always updated on every bit transmitted or received, so
that PEC handling on following linked transfers will be correct.
In slave receiver mode, the master calculates a PEC value and transmits it to the slave after all
data bytes have been transmitted. Upon reception of this PEC byte, the slave will compare it to
the PEC value it has computed itself. If the values match, the data was received correctly, and
the slave will return an ACK to the master. If the PEC values differ, data was corrupted, and the
slave will return a NAK value. The SR.SMBPECERR bit is set automatically if a PEC error
occurred.
In slave transmitter mode, the slave calculates a PEC value and transmits it to the master after
all data bytes have been transmitted. Upon reception of this PEC byte, the master will compare
it to the PEC value it has computed itself. If the values match, the data was received correctly. If
the PEC values differ, data was corrupted, and the master must take appropriate action.
The PEC byte is automatically inserted in a slave transmitter transmission if PEC enabled when
NBYTES reaches zero. The PEC byte is identified in a slave receiver transmission if PEC
572
32142D–06/2013
ATUC64/128/256L3/4U
enabled when NBYTES reaches zero. NBYTES must therefore be set to the total number of
data bytes in the transmission, including the PEC byte.
23.8.7.2 Timeouts
The Timing Register (TR) configures the SMBus timeout values. If a timeout occurs, the slave
will leave the bus. The SR.SMBTOUT bit is also set.
23.8.7.3 SMBALERT
A slave can get the master’s attention by pulling the SMBALERT line low. This is done by writing
a one to the SMBus Alert (SMBALERT) bit in CR. This will also enable address match on the
Alert Response Address (ARA).
23.8.8 Wakeup from Sleep Modes by TWI Address Match
The TWIS is able to wake the device up from a sleep mode upon an address match, including
sleep modes where CLK_TWIS is stopped. After detecting the START condition on the bus, The
TWIS will stretch TWCK until CLK_TWIS has started. The time required for starting CLK_TWIS
depends on which sleep mode the device is in. After CLK_TWIS has started, the TWIS releases
its TWCK stretching and receives one byte of data on the bus. At this time, only a limited part of
the device, including the TWIS, receives a clock, thus saving power. The TWIS goes on to
receive the slave address. If the address phase causes a TWIS address match, the entire
device is wakened and normal TWIS address matching actions are performed. Normal TWI
transfer then follows. If the TWIS is not addressed, CLK_TWIS is automatically stopped and the
device returns to its original sleep mode.
23.8.9 Identifying Bus Events
This chapter lists the different bus events, and how these affects the bits in the TWIS registers.
This is intended to help writing drivers for the TWIS.
Table 23-5. Bus Events
Event Effect
Slave transmitter has sent a
data byte
SR.THR is cleared.
SR.BTF is set.
The value of the ACK bit sent immediately after the data byte is given
by CR.ACK.
Slave receiver has received
a data byte
SR.RHR is set.
SR.BTF is set.
SR.NAK updated according to value of ACK bit received from master.
Start+Sadr on bus, but
address is to another slave None.
Start+Sadr on bus, current
slave is addressed, but
address match enable bit in
CR is not set
None.
Start+Sadr on bus, current
slave is addressed,
corresponding address
match enable bit in CR set
Correct address match bit in SR is set.
SR.TRA updated according to transfer direction (updating is done one
CLK_TWIS cycle after address match bit is set)
Slave enters appropriate transfer direction mode and data transfer
can commence.
573
32142D–06/2013
ATUC64/128/256L3/4U
Start+Sadr on bus, current
slave is addressed,
corresponding address
match enable bit in CR set,
SR.STREN and SR.SOAM
are set.
Correct address match bit in SR is set.
SR.TRA updated according to transfer direction (updating is done one
CLK_TWIS cycle after address match bit is set).
Slave stretches TWCK immediately after transmitting the address
ACK bit. TWCK remains stretched until all address match bits in SR
have been cleared.
Slave enters appropriate transfer direction mode and data transfer
can commence.
Repeated Start received
after being addressed
SR.REP set.
SR.TCOMP unchanged.
Stop received after being
addressed
SR.STO set.
SR.TCOMP set.
Start, Repeated Start, or
Stop received in illegal
position on bus
SR.BUSERR set.
SR.STO and SR.TCOMP may or may not be set depending on the
exact position of an illegal stop.
Data is to be received in
slave receiver mode,
SR.STREN is set, and RHR
is full
TWCK is stretched until RHR has been read.
Data is to be transmitted in
slave receiver mode,
SR.STREN is set, and THR
is empty
TWCK is stretched until THR has been written.
Data is to be received in
slave receiver mode,
SR.STREN is cleared, and
RHR is full
TWCK is not stretched, read data is discarded.
SR.ORUN is set.
Data is to be transmitted in
slave receiver mode,
SR.STREN is cleared, and
THR is empty
TWCK is not stretched, previous contents of THR is written to bus.
SR.URUN is set.
SMBus timeout received SR.SMBTOUT is set.
TWCK and TWD are immediately released.
Slave transmitter in SMBus
PEC mode has transmitted
a PEC byte, that was not
identical to the PEC
calculated by the master
receiver.
Master receiver will transmit a NAK as usual after the last byte of a
master receiver transfer.
Master receiver will retry the transfer at a later time.
Slave receiver discovers
SMBus PEC Error
SR.SMBPECERR is set.
NAK returned after the data byte.
Table 23-5. Bus Events
Event Effect
574
32142D–06/2013
ATUC64/128/256L3/4U
23.9 User Interface
Note: 1. The reset values for these registers are device specific. Please refer to the Module Configuration section at the end of this
chapter.
Table 23-6. TWIS Register Memory Map
Offset Register Register Name Access Reset
0x00 Control Register CR Read/Write 0x00000000
0x04 NBYTES Register NBYTES Read/Write 0x00000000
0x08 Timing Register TR Read/Write 0x00000000
0x0C Receive Holding Register RHR Read-only 0x00000000
0x10 Transmit Holding Register THR Write-only 0x00000000
0x14 Packet Error Check Register PECR Read-only 0x00000000
0x18 Status Register SR Read-only 0x00000002
0x1C Interrupt Enable Register IER Write-only 0x00000000
0x20 Interrupt Disable Register IDR Write-only 0x00000000
0x24 Interrupt Mask Register IMR Read-only 0x00000000
0x28 Status Clear Register SCR Write-only 0x00000000
0x2C Parameter Register PR Read-only -(1)
0x30 Version Register VR Read-only -(1)
575
32142D–06/2013
ATUC64/128/256L3/4U
23.9.1 Control Register
Name: CR
Access Type: Read/Write
Offset: 0x00
Reset Value: 0x00000000
• TENBIT: Ten Bit Address Match
0: Disables Ten Bit Address Match.
1: Enables Ten Bit Address Match.
• ADR: Slave Address
Slave address used in slave address match. Bits 9:0 are used if in 10-bit mode, bits 6:0 otherwise.
• SODR: Stretch Clock on Data Byte Reception
0: Does not stretch bus clock immediately before ACKing a received data byte.
1: Stretches bus clock immediately before ACKing a received data byte.
• SOAM: Stretch Clock on Address Match
0: Does not stretch bus clock after address match.
1: Stretches bus clock after address match.
• CUP: NBYTES Count Up
0: Causes NBYTES to count down (decrement) per byte transferred.
1: Causes NBYTES to count up (increment) per byte transferred.
• ACK: Slave Receiver Data Phase ACK Value
0: Causes a low value to be returned in the ACK cycle of the data phase in slave receiver mode.
1: Causes a high value to be returned in the ACK cycle of the data phase in slave receiver mode.
• PECEN: Packet Error Checking Enable
0: Disables SMBus PEC (CRC) generation and check.
1: Enables SMBus PEC (CRC) generation and check.
• SMHH: SMBus Host Header
0: Causes the TWIS not to acknowledge the SMBus Host Header.
1: Causes the TWIS to acknowledge the SMBus Host Header.
• SMDA: SMBus Default Address
0: Causes the TWIS not to acknowledge the SMBus Default Address.
1: Causes the TWIS to acknowledge the SMBus Default Address.
• SMBALERT: SMBus Alert
0: Causes the TWIS to release the SMBALERT line and not to acknowledge the SMBus Alert Response Address (ARA).
1: Causes the TWIS to pull down the SMBALERT line and to acknowledge the SMBus Alert Response Address (ARA).
31 30 29 28 27 26 25 24
- - - - - TENBIT ADR[9:8]
23 22 21 20 19 18 17 16
ADR[7:0]
15 14 13 12 11 10 9 8
SODR SOAM CUP ACK PECEN SMHH SMDA SMBALERT
76543210
SWRST - - STREN GCMATCH SMATCH SMEN SEN
576
32142D–06/2013
ATUC64/128/256L3/4U
• SWRST: Software Reset
This bit will always read as 0.
Writing a zero to this bit has no effect.
Writing a one to this bit resets the TWIS.
• STREN: Clock Stretch Enable
0: Disables clock stretching if RHR/THR buffer full/empty. May cause over/underrun.
1: Enables clock stretching if RHR/THR buffer full/empty.
• GCMATCH: General Call Address Match
0: Causes the TWIS not to acknowledge the General Call Address.
1: Causes the TWIS to acknowledge the General Call Address.
• SMATCH: Slave Address Match
0: Causes the TWIS not to acknowledge the Slave Address.
1: Causes the TWIS to acknowledge the Slave Address.
• SMEN: SMBus Mode Enable
0: Disables SMBus mode.
1: Enables SMBus mode.
• SEN: Slave Enable
0: Disables the slave interface.
1: Enables the slave interface.
577
32142D–06/2013
ATUC64/128/256L3/4U
23.9.2 NBYTES Register
Name: NBYTES
Access Type: Read/Write
Offset: 0x04
Reset Value: 0x00000000
• NBYTES: Number of Bytes to Transfer
Writing to this field updates the NBYTES counter. The field can also be read to learn the progress of the transfer. NBYTES can
be incremented or decremented automatically by hardware.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
--------
76543210
NBYTES
578
32142D–06/2013
ATUC64/128/256L3/4U
23.9.3 Timing Register
Name: TR
Access Type: Read/Write
Offset: 0x08
Reset Value: 0x00000000
• EXP: Clock Prescaler
Used to specify how to prescale the SMBus TLOWS counter. The counter is prescaled according to the following formula:
• SUDAT: Data Setup Cycles
Non-prescaled clock cycles for data setup count. Used to time TSU_DAT. Data is driven SUDAT cycles after TWCK low detected.
This timing is used for timing the ACK/NAK bits, and any data bits driven in slave transmitter mode.
• TTOUT: SMBus TTIMEOUT Cycles
Prescaled clock cycles used to time SMBus TTIMEOUT.
• TLOWS: SMBus TLOW:SEXT Cycles
Prescaled clock cycles used to time SMBus TLOW:SEXT.
31 30 29 28 27 26 25 24
EXP - - - -
23 22 21 20 19 18 17 16
SUDAT
15 14 13 12 11 10 9 8
TTOUT
76543210
TLOWS
f
PRESCALED
f
CLK_TWIS
2 EXP 1 + = ------------------------
579
32142D–06/2013
ATUC64/128/256L3/4U
23.9.4 Receive Holding Register
Name: RHR
Access Type: Read-only
Offset: 0x0C
Reset Value: 0x00000000
• RXDATA: Received Data Byte
When the RXRDY bit in the Status Register (SR) is one, this field contains a byte received from the TWI bus.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
--------
76543210
RXDATA
580
32142D–06/2013
ATUC64/128/256L3/4U
23.9.5 Transmit Holding Register
Name: THR
Access Type: Write-only
Offset: 0x10
Reset Value: 0x00000000
• TXDATA: Data Byte to Transmit
Write data to be transferred on the TWI bus here.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
--------
76543210
TXDATA
581
32142D–06/2013
ATUC64/128/256L3/4U
23.9.6 Packet Error Check Register
Name: PECR
Access Type: Read-only
Offset: 0x14
Reset Value: 0x00000000
• PEC: Calculated PEC Value
The calculated PEC value. Updated automatically by hardware after each byte has been transferred. Reset by hardware after a
STOP condition. Provided if the user manually wishes to control when the PEC byte is transmitted, or wishes to access the PEC
value for other reasons. In ordinary operation, the PEC handling is done automatically by hardware.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
--------
76543210
PEC
582
32142D–06/2013
ATUC64/128/256L3/4U
23.9.7 Status Register
Name: SR
Access Type: Read-only
Offset: 0x18
Reset Value: 0x000000002
• BTF: Byte Transfer Finished
This bit is cleared when the corresponding bit in SCR is written to one.
This bit is set when byte transfer has completed.
• REP: Repeated Start Received
This bit is cleared when the corresponding bit in SCR is written to one.
This bit is set when a REPEATED START condition is received.
• STO: Stop Received
This bit is cleared when the corresponding bit in SCR is written to one.
This bit is set when the STOP condition is received.
• SMBDAM: SMBus Default Address Match
This bit is cleared when the corresponding bit in SCR is written to one.
This bit is set when the received address matched the SMBus Default Address.
• SMBHHM: SMBus Host Header Address Match
This bit is cleared when the corresponding bit in SCR is written to one.
This bit is set when the received address matched the SMBus Host Header Address.
• SMBALERTM: SMBus Alert Response Address Match
This bit is cleared when the corresponding bit in SCR is written to one.
This bit is set when the received address matched the SMBus Alert Response Address.
• GCM: General Call Match
This bit is cleared when the corresponding bit in SCR is written to one.
This bit is set when the received address matched the General Call Address.
• SAM: Slave Address Match
This bit is cleared when the corresponding bit in SCR is written to one.
This bit is set when the received address matched the Slave Address.
• BUSERR: Bus Error
This bit is cleared when the corresponding bit in SCR is written to one.
This bit is set when a misplaced START or STOP condition has occurred.
31 30 29 28 27 26 25 24
-- - -----
23 22 21 20 19 18 17 16
BTF REP STO SMBDAM SMBHHM SMBALERTM GCM SAM
15 14 13 12 11 10 9 8
- BUSERR SMBPECERR SMBTOUT - - - NAK
76 5 43210
ORUN URUN TRA - TCOMP SEN TXRDY RXRDY
583
32142D–06/2013
ATUC64/128/256L3/4U
• SMBPECERR: SMBus PEC Error
This bit is cleared when the corresponding bit in SCR is written to one.
This bit is set when a SMBus PEC error has occurred.
• SMBTOUT: SMBus Timeout
This bit is cleared when the corresponding bit in SCR is written to one.
This bit is set when a SMBus timeout has occurred.
• NAK: NAK Received
This bit is cleared when the corresponding bit in SCR is written to one.
This bit is set when a NAK was received from the master during slave transmitter operation.
• ORUN: Overrun
This bit is cleared when the corresponding bit in SCR is written to one.
This bit is set when an overrun has occurred in slave receiver mode. Can only occur if CR.STREN is zero.
• URUN: Underrun
This bit is cleared when the corresponding bit in SCR is written to one.
This bit is set when an underrun has occurred in slave transmitter mode. Can only occur if CR.STREN is zero.
• TRA: Transmitter Mode
0: The slave is in slave receiver mode.
1: The slave is in slave transmitter mode.
• TCOMP: Transmission Complete
This bit is cleared when the corresponding bit in SCR is written to one.
This bit is set when transmission is complete. Set after receiving a STOP after being addressed.
• SEN: Slave Enabled
0: The slave interface is disabled.
1: The slave interface is enabled.
• TXRDY: TX Buffer Ready
0: The TX buffer is full and should not be written to.
1: The TX buffer is empty, and can accept new data.
• RXRDY: RX Buffer Ready
0: No RX data ready in RHR.
1: RX data is ready to be read from RHR.
584
32142D–06/2013
ATUC64/128/256L3/4U
23.9.8 Interrupt Enable Register
Name: IER
Access Type: Write-only
Offset: 0x1C
Reset Value: 0x00000000
Writing a zero to a bit in this register has no effect.
Writing a one to a bit in this register will write a one to the corresponding bit in IMR.
31 30 29 28 27 26 25 24
-- - -----
23 22 21 20 19 18 17 16
BTF REP STO SMBDAM SMBHHM SMBALERTM GCM SAM
15 14 13 12 11 10 9 8
- BUSERR SMBPECERR SMBTOUT - - - NAK
76 5 43210
ORUN URUN - - TCOMP - TXRDY RXRDY
585
32142D–06/2013
ATUC64/128/256L3/4U
23.9.9 Interrupt Disable Register
Name: IDR
Access Type: Write-only
Offset: 0x20
Reset Value: 0x00000000
Writing a zero to a bit in this register has no effect.
Writing a one to a bit in this register will clear the corresponding bit in IMR.
31 30 29 28 27 26 25 24
-- - -----
23 22 21 20 19 18 17 16
BTF REP STO SMBDAM SMBHHM SMBALERTM GCM SAM
15 14 13 12 11 10 9 8
- BUSERR SMBPECERR SMBTOUT - - - NAK
76 5 43210
ORUN URUN - - TCOMP - TXRDY RXRDY
586
32142D–06/2013
ATUC64/128/256L3/4U
23.9.10 Interrupt Mask Register
Name: IMR
Access Type: Read-only
Offset: 0x24
Reset Value: 0x00000000
0: The corresponding interrupt is disabled.
1: The corresponding interrupt is enabled.
This bit is cleared when the corresponding bit in IDR is written to one.
This bit is set when the corresponding bit in IER is written to one.
31 30 29 28 27 26 25 24
-- - -----
23 22 21 20 19 18 17 16
BTF REP STO SMBDAM SMBHHM SMBALERTM GCM SAM
15 14 13 12 11 10 9 8
- BUSERR SMBPECERR SMBTOUT - - - NAK
76 5 43210
ORUN URUN - - TCOMP - TXRDY RXRDY
587
32142D–06/2013
ATUC64/128/256L3/4U
23.9.11 Status Clear Register
Name: SCR
Access Type: Write-only
Offset: 0x28
Reset Value: 0x00000000
Writing a zero to a bit in this register has no effect.
Writing a one to a bit in this register will clear the corresponding bit in SR and the corresponding interrupt request.
31 30 29 28 27 26 25 24
-- - -----
23 22 21 20 19 18 17 16
BTF REP STO SMBDAM SMBHHM SMBALERTM GCM SAM
15 14 13 12 11 10 9 8
- BUSERR SMBPECERR SMBTOUT - - - NAK
76 5 43210
ORUN URUN - - TCOMP - - -
588
32142D–06/2013
ATUC64/128/256L3/4U
23.9.12 Parameter Register
Name: PR
Access Type: Read-only
Offset: 0x2C
Reset Value: -
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
--------
76543210
--------
589
32142D–06/2013
ATUC64/128/256L3/4U
23.9.13 Version Register (VR)
Name: VR
Access Type: Read-only
Offset: 0x30
Reset Value: -
• VARIANT: Variant Number
Reserved. No functionality associated.
• VERSION: Version Number
Version number of the module. No functionality associated.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
- - - - VARIANT
15 14 13 12 11 10 9 8
- - - - VERSION [11:8]
76543210
VERSION [7:0]
590
32142D–06/2013
ATUC64/128/256L3/4U
23.10 Module Configuration
The specific configuration for each TWIS instance is listed in the following tables.The module
bus clocks listed here are connected to the system bus clocks. Please refer to the Power Manager
chapter for details.
Table 23-7. Module Clock Name
Module Name Clock Name Description
TWIS0 CLK_TWIS0 Clock for the TWIS0 bus interface
TWIS1 CLK_TWIS1 Clock for the TWIS1 bus interface
Table 23-8. Register Reset Values
Register Reset Value
VERSION 0x00000120
PARAMETER 0x00000000
591
32142D–06/2013
ATUC64/128/256L3/4U
24. Inter-IC Sound Controller (IISC)
Rev: 1.0.0.0
24.1 Features
• Compliant with Inter-IC Sound (I2
S) bus specification
• Master, slave, and controller modes:
– Slave: data received/transmitted
– Master: data received/transmitted and clocks generated
– Controller: clocks generated
• Individual enable and disable of receiver, transmitter, and clocks
• Configurable clock generator common to receiver and transmitter:
– Suitable for a wide range of sample frequencies (fs), including 32kHz, 44.1kHz, 48kHz,
88.2kHz, 96kHz, and 192kHz
– 16fs to 1024fs Master Clock generated for external oversampling ADCs
• Several data formats supported:
– 32-, 24-, 20-, 18-, 16-, and 8-bit mono or stereo format
– 16- and 8-bit compact stereo format, with left and right samples packed in the same word to
reduce data transfers
• DMA interfaces for receiver and transmitter to reduce processor overhead:
– Either one DMA channel for both audio channels, or
– One DMA channel per audio channel
• Smart holding registers management to avoid audio channels mix after overrun or underrun
24.2 Overview
The Inter-IC Sound Controller (IISC) provides a 5-wire, bidirectional, synchronous, digital audio
link with external audio devices: ISDI, ISDO, IWS, ISCK, and IMCK pins.
This controller is compliant with the Inter-IC Sound (I2
S) bus specification.
The IISC consists of a Receiver, a Transmitter, and a common Clock Generator, that can be
enabled separately, to provide Master, Slave, or Controller modes with Receiver, Transmitter, or
both active.
Peripheral DMA channels, separate for the Receiver and for the Transmitter, allow a continuous
high bitrate data transfer without processor intervention to the following:
• Audio CODECs in Master, Slave, or Controller mode
• Stereo DAC or ADC through dedicated I2
S serial interface
The IISC can use either a single DMA channel for both audio channels or one DMA channel per
audio channel.
The 8- and 16-bit compact stereo format allows reducing the required DMA bandwidth by transferring
the left and right samples within the same data word.
In Master Mode, the IISC allows outputting a 16 fs to 1024fs Master Clock, in order to provide an
oversampling clock to an external audio codec or digital signal processor (DSP).
592
32142D–06/2013
ATUC64/128/256L3/4U
24.3 Block Diagram
Figure 24-1. IISC Block Diagram
24.4 I/O Lines Description
24.5 Product Dependencies
In order to use this module, other parts of the system must be configured correctly, as described
below.
24.5.1 I/O lines
The IISC pins may be multiplexed with I/O Controller lines. The user must first program the I/O
Controller to assign the desired IISC pins to their peripheral function. If the IISC I/O lines are not
used by the application, they can be used for other purposes by the I/O Controller. It is required
to enable only the IISC inputs and outputs actually in use.
24.5.2 Power Management
If the CPU enters a sleep mode that disables clocks used by the IISC, the IISC will stop functioning
and resume operation after the system wakes up from sleep mode.I/O Controller
ISCK
IWS
ISDI
ISDO
IMCK
Receiver
Clocks
Transmitter
Peripheral Bus interface
Generic clock
PB Peripheral
Bus Bridge
Interrupt
Controller
SCIF
Power
Manager PB clock
IRQ
Peripheral
DMA
Controller
Rx
Tx
IISC
Table 24-1. I/O Lines Description
Pin Name Pin Description Type
IMCK Master Clock Output
ISCK Serial Clock Input/Output
IWS I2
S Word Select Input/Output
ISDI Serial Data Input Input
ISDO Serial Data Output Output
593
32142D–06/2013
ATUC64/128/256L3/4U
24.5.3 Clocks
The clock for the IISC bus interface (CLK_IISC) is generated by the Power Manager. This clock
is enabled at reset, and can be disabled in the Power Manager. It is recommended to disable the
IISC before disabling the clock, to avoid freezing the IISC in an undefined state.
One of the generic clocks is connected to the IISC. The generic clock (GCLK_IISC) can be set to
a wide range of frequencies and clock sources. The GCLK_IISC must be enabled and configured
before use. Refer to the module configuration section for details on the GCLK_IISC used
for the IISC. The frequency for this clock has to be set as described in Table.
24.5.4 DMA
The IISC DMA handshake interfaces are connected to the Peripheral DMA Controller. Using the
IISC DMA functionality requires the Peripheral DMA Controller to be programmed first.
24.5.5 Interrupts
The IISC interrupt line is connected to the Interrupt Controller. Using the IISC interrupt requires
the Interrupt Controller to be programmed first.
24.5.6 Debug Operation
When an external debugger forces the CPU into debug mode, the IISC continues normal operation.
If this module is configured in a way that requires it to be periodically serviced by the CPU
through interrupt requests or similar, improper operation or data loss may result during
debugging.
24.6 Functional Description
24.6.1 Initialization
The IISC features a Receiver, a Transmitter, and, for Master and Controller modes, a Clock
Generator. Receiver and Transmitter share the same Serial Clock and Word Select.
Before enabling the IISC, the chosen configuration must be written to the Mode Register (MR).
The IMCKMODE, MODE, and DATALENGTH fields in the MR register must be written. If the
IMCKMODE field is written as one, then the IMCKFS field should be written with the chosen
ratio, as described in Section 24.6.5 ”Serial Clock and Word Select Generation” on page 595.
Once the Mode Register has been written, the IISC Clock Generator, Receiver, and Transmitter
can be enabled by writing a one to the CKEN, RXEN, and TXEN bits in the Control Register
(CR). The Clock Generator can be enabled alone, in Controller Mode, to output clocks to the
IMCK, ISCK, and IWS pins. The Clock Generator must also be enabled if the Receiver or the
Transmitter is enabled.
The Clock Generator, Receiver, and Transmitter can be disabled independently by writing a one
to CR.CXDIS, CR.RXDIS and/or CR.TXDIS respectively. Once requested to stop, they will only
stop when the transmission of the pending frame transmission will be completed.
24.6.2 Basic Operation
The Receiver can be operated by reading the Receiver Holding Register (RHR), whenever the
Receive Ready (RXRDY) bit in the Status Register (SR) is set. Successive values read from
RHR will correspond to the samples from the left and right audio channels for the successive
frames.
594
32142D–06/2013
ATUC64/128/256L3/4U
The Transmitter can be operated by writing to the Transmitter Holding Register (RHR), whenever
the Transmit Ready (TXRDY) bit in the Status Register (SR) is set. Successive values
written to THR should correspond to the samples from the left and right audio channels for the
successive frames.
The Receive Ready and Transmit Ready bits can be polled by reading the Status Register.
The IISC processor load can be reduced by enabling interrupt-driven operation. The RXRDY
and/or TXRDY interrupt requests can be enabled by writing a one to the corresponding bit in the
Interrupt Enable Register (IER). The interrupt service routine associated to the IISC interrupt
request will then be executed whenever the Receive Ready or the Transmit Ready status bit is
set.
24.6.3 Master, Controller, and Slave Modes
In Master and Controller modes, the IISC provides the Master Clock, the Serial Clock and the
Word Select. IMCK, ISCK, and IWS pins are outputs.
In Controller mode, the IISC Receiver and Transmitter are disabled. Only the clocks are enabled
and used by an external receiver and/or transmitter.
In Slave mode, the IISC receives the Serial Clock and the Word Select from an external master.
ISCK and IWS pins are inputs.
The mode is selected by writing the MODE field of the Mode Register (MR). Since the MODE
field changes the direction of the IWS and ISCK pins, the Mode Register should only be written
when the IISC is stopped, in order to avoid unwanted glitches on the IWS and ISCK pins.
24.6.4 I2
S Reception and Transmission Sequence
As specified in the I2
S protocol, data bits are left-adjusted in the Word Select time slot, with the
MSB transmitted first, starting one clock period after the transition on the Word Select line.
Figure 24-2. I
2
S Reception and Transmission Sequence
Data bits are sent on the falling edge of the Serial Clock and sampled on the rising edge of the
Serial Clock. The Word Select line indicates the channel in transmission, a low level for the left
channel and a high level for the right channel.
The length of transmitted words can be chosen among 8, 16, 18, 20, 24, and 32 bits by writing
the MR.DATALENGTH field.
If the time slot allows for more data bits than written in the MR.DATALENGTH field, zeroes are
appended to the transmitted data word or extra received bits are discarded. If the time slot
allows for less data bits than written, the extra bits to be transmitted are not sent or the missing
bits are set to zero in the received data word.
Serial Clock ISCK
Word Select IWS
Data ISDI/ISDO MSB
Left Channel
LSB MSB
Right Channel
595
32142D–06/2013
ATUC64/128/256L3/4U
24.6.5 Serial Clock and Word Select Generation
The generation of clocks in the IISC is described in Figure 24-3 on page 596.
In Slave mode, the Serial Clock and Word Select Clock are driven by an external master. ISCK
and IWS pins are inputs and no generic clock is required by the IISC.
In Master mode, the user can configure the Master Clock, Serial Clock, and Word Select Clock
through the Mode Register (MR). IMCK, ISCK, and IWS pins are outputs and a generic clock is
used to derive the IISC clocks.
Audio codecs connected to the IISC pins may require a Master Clock signal with a frequency
multiple of the audio sample frequency (fs), such as 256fs. When the IISC is in Master mode,
writing a one to MR.IMCKMODE will output GCLK_IISC as Master Clock to the IMCK pin, and
will divide GCLK_IISC to create the internal bit clock, output on the ISCK pin. The clock division
factor is defined by writing to MR.IMCKFS and MR.DATALENGTH, as described ”IMCKFS:
Master Clock to fs Ratio” on page 602.
The Master Clock (IMCK) frequency is 16*(IMCKFS+1) times the sample frequency (fs), i.e. IWS
frequency. The Serial Clock (ISCK) frequency is 2*Slot Length times the sample frequency (fs),
where Slot Length is defined in Table 24-2 on page 595.
Warning: MR.IMCKMODE should only be written as one if the Master Clock frequency is strictly
higher than the Serial Clock.
If a Master Clock output is not required, the GCLK_IISC generic clock is used as ISCK, by writing
a zero to MR.IMCKMODE. Alternatively, if the frequency of the generic clock used is a
multiple of the required ISCK frequency, the IMCK to ISCK divider can be used with the ratio
defined by writing the MR.IMCKFS field.
The IWS pin is used as Word Select as described in Section 24.6.4.
Table 24-2. Slot Length
MR.DATALENGTH Word Length Slot Length
0 32 bits 32
1 24 bits
32 if MR.IWS24 is zero
24 if MR.IWS24 is one 2 20 bits
3 18 bits
4 16 bits
16
5 16 bits compact stereo
6 8 bits
8
7 8 bits compact stereo
596
32142D–06/2013
ATUC64/128/256L3/4U
Figure 24-3. IISC Clocks Generation
24.6.6 Mono
When the Transmit Mono (TXMONO) in the Mode Register is set, data written to the left channel
is duplicated to the right output channel.
When the Receive Mono (RXMONO) in the Mode Register is set, data received from the left
channel is duplicated to the right channel.
24.6.7 Holding Registers
The IISC user interface includes a Receive Holding Register (RHR) and a Transmit Holding
Register (THR). RHR and THR are used to access audio samples for both audio channels.
When a new data word is available in the RHR register, the Receive Ready bit (RXRDY) in the
Status Register (SR) is set. Reading the RHR register will clear this bit.
A receive overrun condition occurs if a new data word becomes available before the previous
data word has been read from the RHR register. Then, the Receive Overrun bit in the Status
Register will be set and bit i of the RXORCH field in the Status Register is set, where i is the current
receive channel number.
When the THR register is empty, the Transmit Ready bit (TXRDY) in the Status Register (SR) is
set. Writing into the THR register will clear this bit.
A transmit underrun condition occurs if a new data word needs to be transmitted before it has
been written to the THR register. Then, the Transmit Underrun bit in the Status Register will be
set and bit i of the TXORCH field in the Status Register is set, where i is the current transmit
channel number. If the TXSAME bit in the Mode Register is zero, then a zero data word is transmitted
in case of underrun. If MR.TXSAME is one, then the previous data word for the current
transmit channel number is transmitted.
MR.MODE = SLAVE Clock
divider MR.DATALENGTH
GCLK_IISC Clock
enable
Clock
divider
CR.CKEN/CKDIS MR.IMCKMODE
MR.DATALENGTH
MR.IMCKFS
MR.IMCKMODE 0 1
IMCK pin output
Clock
enable
CR.CKEN/CKDIS
Internal
bit clock ISCK pin input 1
0
ISCK pin output
Internal
word clock IWS pin input 1
0
IWS pin output
597
32142D–06/2013
ATUC64/128/256L3/4U
Data words are right-justified in the RHR and THR registers. For 16-bit compact stereo, the left
sample uses bits 15 through 0 and the right sample uses bits 31 through 16 of the same data
word. For 8-bit compact stereo, the left sample uses bits 7 through 0 and the right sample uses
bits 15 through 8 of the same data word.
24.6.8 DMA Operation
The Receiver and the Transmitter can each be connected either to one single Peripheral DMA
channel or to one Peripheral DMA channel per data channel. This is selected by writing to the
MR.RXDMA and MR.TXDMA bits. If a single Peripheral DMA channel is selected, all data samples
use IISC Receiver or Transmitter DMA channel 0.
The Peripheral DMA reads from the RHR register and writes to the RHR register for both audio
channels, successively.
The Peripheral DMA transfers may use 32-bit word, 16-bit halfword, or 8-bit byte according to
the value of the MR.DATALENGTH field.
24.6.9 Loop-back Mode
For debugging purposes, the IISC can be configured to loop back the Transmitter to the
Receiver. Writing a one to the MR.LOOP bit will internally connect ISDO to ISDI, so that the
transmitted data is also received. Writing a zero to MR.LOOP will restore the normal behavior
with independent Receiver and Transmitter. As for other changes to the Receiver or Transmitter
configuration, the IISC Receiver and Transmitter must be disabled before writing to the MR register
to update MR.LOOP.
24.6.10 Interrupts
An IISC interrupt request can be triggered whenever one or several of the following bits are set
in the Status Register (SR): Receive Ready (RXRDY), Receive Overrun (RXOR), Transmit
Ready (TXRDY), or Transmit Underrun (TXOR).
The interrupt request will be generated if the corresponding bit in the Interrupt Mask Register
(IMR) is set. Bits in IMR are set by writing a one to the corresponding bit in the Interrupt Enable
Register (IER), and cleared by writing a one to the corresponding bit in the Interrupt Disable
Register (IDR). The interrupt request remains active until the corresponding bit in SR is cleared
by writing a one the corresponding bit in the Status Clear Register (SCR).
For debugging purposes, interrupt requests can be simulated by writing a one to the corresponding
bit in the Status Set Register (SSR).
598
32142D–06/2013
ATUC64/128/256L3/4U
Figure 24-4. Interrupt Block Diagram
24.7 IISC Application Examples
The IISC can support several serial communication modes used in audio or high-speed serial
links. Some standard applications are shown in the following figures. All serial link applications
supported by the IISC are not listed here.
Figure 24-5. Audio Application Block Diagram
IER IDR IMR
Set Clear
Interrupt
Control
IISC Interrupt
Request
TXRDY
TXUR
Transmitter
Receiver
RXRDY
RXOR
Serial Clock
Word Select
Serial Data Out MSB LSB MSB
Serial Data Out
Word Select
Serial Clock
IISC
ISCK
IWS
ISDO
ISDI
EXTERNAL
I
2
S
RECEIVER
599
32142D–06/2013
ATUC64/128/256L3/4U
Figure 24-6. Codec Application Block Diagram
Figure 24-7. Time Slot Application Block Diagram
IISC Word Select
Serial Data Out
Serial Data In
EXTERNAL
AUDIO
CODEC
IMCK
IWS
ISDO
ISDI
Serial Clock
Master Clock
ISCK
Right Time Slot
Serial Clock
Word Select
Serial Data Out
Serial Data In
Dstart Dend
Left Time Slot
EXTERNAL
AUDIO
CODEC
for Left
Time Slot
EXTERNAL
AUDIO
CODEC
for Right
Time Slot
Serial Data In
Serial Data Out
Word Select
Serial Clock
Serial Clock
Word Select
Serial Data Out
Serial Data In
Dstart
Left Time Slot Right Time Slot
Dend
IISC
ISCK
IWS
ISDO
ISDI
Master Clock IMCK
600
32142D–06/2013
ATUC64/128/256L3/4U
24.8 User Interface
Note: 1. The reset values for these registers are device specific. Please refer to the Module Configuration section at the end of this
chapter.
Table 24-3. IISC Register Memory Map
Offset Register Register Name Access Reset
0x00 Control Register CR Write-only 0x00000000
0x04 Mode Register MR Read/Write 0x00000000
0x08 Status Register SR Read-only 0x00000000
0x0C Status Clear Register SCR Write-only 0x00000000
0x10 Status Set Register SSR Write-only 0x00000000
0x14 Interrupt Enable Register IER Write-only 0x00000000
0x18 Interrupt Disable Register IDR Write-only 0x00000000
0x1C Interrupt Mask Register IMR Read-only 0x00000000
0x20 Receiver Holding Register RHR Read-only 0x00000000
0x24 Transmitter Holding Register THR Write-only 0x00000000
0x28 Version Register VERSION Read-only -
(1)
0x2C Parameter Register PARAMETER Read-only -
(1)
601
32142D–06/2013
ATUC64/128/256L3/4U
24.8.1 Control Register
Name: CR
Access Type: Write-only
Offset: 0x00
Reset Value: 0x00000000
The Control Register should only be written to enable the IISC after the chosen configuration has been written to the Mode
Register, in order to avoid unwanted glitches on the IWS, ISCK, and ISDO outputs. The proper sequence is to write the MR
register, then write the CR register to enable the IISC, or to disable the IISC before writing a new value into MR.
• SWRST: Software Reset
Writing a zero to this bit has no effect.
Writing a one to this bit resets all the registers in the module. The module will be disabled after the reset.
This bit always reads as zero.
• TXDIS: Transmitter Disable
Writing a zero to this bit has no effect.
Writing a one to this bit disables the IISC Transmitter. SR.TXEN will be cleared when the Transmitter is effectively stopped.
• TXEN: Transmitter Enable
Writing a zero to this bit has no effect.
Writing a one to this bit enables the IISC Transmitter, if TXDIS is not one. SR.TXEN will be set when the Transmitter is effectively
started.
• CKDIS: Clocks Disable
Writing a zero to this bit has no effect.
Writing a one to this bit disables the IISC clocks generation.
• CKEN: Clocks Enable
Writing a zero to this bit has no effect.
Writing a one to this bit enables the IISC clocks generation, if CKDIS is not one.
• RXDIS: Receiver Disable
Writing a zero to this bit has no effect.
Writing a one to this bit disables the IISC Receiver. SR.TXEN will be cleared when the Transmitter is effectively stopped.
• RXEN: Receiver Enable
Writing a zero to this bit has no effect.
Writing a one to this bit enables the IISC Receiver, if RXDIS is not one. SR.RXEN will be set when the Receiver is effectively
started.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
--------
76543210
SWRST - TXDIS TXEN CKDIS CKEN RXDIS RXEN
602
32142D–06/2013
ATUC64/128/256L3/4U
24.8.2 Mode Register
Name: MR
Access Type: Read/Write
Offset: 0x04
Reset Value: 0x00000000
The Mode Register should only be written when the IISC is stopped, in order to avoid unwanted glitches on the IWS, ISCK,
and ISDO outputs. The proper sequence is to write the MR register, then write the CR register to enable the IISC, or to disable
the IISC before writing a new value into MR.
• IWS24: IWS TDM Slot Width
0: IWS slot is 32-bit wide for DATALENGTH=18/20/24-bit
1: IWS slot is 24-bit wide for DATALENGTH=18/20/24-bit
Refer to Table 24-2, “Slot Length,” on page 595.
• IMCKMODE: Master Clock Mode
0: No Master Clock generated (generic clock is used as ISCK output)
1: Master Clock generated (generic clock is used as IMCK output)
Warning: if IMCK frequency is the same as ISCK, IMCKMODE should not be written as one. Refer to Section 24.6.5 ”Serial
Clock and Word Select Generation” on page 595 and Table 24-2, “Slot Length,” on page 595.
• IMCKFS: Master Clock to fs Ratio
Master Clock frequency is 16*(IMCKFS+1) times the sample rate, i.e. IWS frequency:
31 30 29 28 27 26 25 24
IWS24 IMCKMODE IMCKFS
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
- TXSAME TXDMA TXMONO RXLOOP RXDMA RXMONO
76543210
- - - DATALENGTH - MODE
Table 24-4. Master Clock to Sample Frequency (fs) Ratio
fs Ratio IMCKFS
16 fs 0
32 fs 1
48fs 2
64 fs 3
96fs 5
128 fs 7
192fs 11
256 fs 15
603
32142D–06/2013
ATUC64/128/256L3/4U
• TXSAME: Transmit Data when Underrun
0: Zero sample transmitted when underrun
1: Previous sample transmitted when underrun
• TXDMA: Single or multiple DMA Channels for Transmitter
0: Transmitter uses a single DMA channel for both audio channels
1: Transmitter uses one DMA channel per audio channel
• TXMONO: Transmit Mono
0: Stereo
1: Mono, with left audio samples duplicated to right audio channel by the IISC
• RXLOOP: Loop-back Test Mode
0: Normal mode
1: ISDO output of IISC is internally connected to ISDI input
• RXMONO: Receive Mono
0: Stereo
1: Mono, with left audio samples duplicated to right audio channel by the IISC
• RXDMA: Single or multiple DMA Channels for Receiver
0: Receiver uses a single DMA channel for both audio channels
1: Receiver uses one DMA channel per audio channel-
• DATALENGTH: Data Word Length
• MODE: Mode
384 fs 23
512 fs 31
768 fs 47
1024 fs 63
Table 24-5. Data Word Length
DATALENGTH Word Length Comments
0 32 bits
1 24 bits
2 20 bits
3 18 bits
4 16 bits
5 16 bits compact stereo Left sample in bits 15 through 0 and right sample in bits 31 through 16 of the same word
6 8 bits
7 8 bits compact stereo Left sample in bits 7 through 0 and right sample in bits 15 through 8 of the same word
Table 24-6. Mode
MODE Comments
0 SLAVE ISCK and IWS pin inputs used as Bit Clock and Word Select/Frame Sync.
1 MASTER Bit Clock and Word Select/Frame Sync generated by IISC from GCLK_IISC and output to ISCK and IWS pins.
GCLK_IISC is output as Master Clock on IMCK if MR.IMCKMODE is one.
Table 24-4. Master Clock to Sample Frequency (fs) Ratio
fs Ratio IMCKFS
604
32142D–06/2013
ATUC64/128/256L3/4U
24.8.3 Status Register
Name: SR
Access Type: Read-only
Offset: 0x08
Reset Value: 0x00000000
• TXURCH: Transmit Underrun Channel
This field is cleared when SCR.TXUR is written to one
Bit i of this field is set when a transmit underrun error occurred in channel i (i=0 for first channel of the frame)
• RXORCH: Receive Overrun Channel
This field is cleared when SCR.RXOR is written to one
Bit i of this field is set when a receive overrun error occurred in channel i (i=0 for first channel of the frame)
• TXUR: Transmit Underrun
This bit is cleared when the corresponding bit in SCR is written to one
This bit is set when an underrun error occurs on the THR register or when the corresponding bit in SSR is written to one
• TXRDY: Transmit Ready
This bit is cleared when data is written to THR
This bit is set when the THR register is empty and can be written with new data to be transmitted
• TXEN: Transmitter Enabled
This bit is cleared when the Transmitter is effectively disabled, following a CR.TXDIS or CR.SWRST request
This bit is set when the Transmitter is effectively enabled, following a CR.TXEN request
• RXOR: Receive Overrun
This bit is cleared when the corresponding bit in SCR is written to one
This bit is set when an overrun error occurs on the RHR register or when the corresponding bit in SSR is written to one
• RXRDY: Receive Ready
This bit is cleared when the RHR register is read
This bit is set when received data is present in the RHR register
• RXEN: Receiver Enabled
This bit is cleared when the Receiver is effectively disabled, following a CR.RXDIS or CR.SWRST request
This bit is set when the Receiver is effectively enabled, following a CR.RXEN request
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
- - TXURCH - - - -
15 14 13 12 11 10 9 8
- - - - - - RXORCH
76543210
- TXUR TXRDY TXEN - RXOR RXRDY RXEN
605
32142D–06/2013
ATUC64/128/256L3/4U
24.8.4 Status Clear Register
Name: SCR
Access Type: Write-only
Offset: 0x0C
Reset Value: 0x00000000
Writing a zero to a bit in this register has no effect.
Writing a one to a bit in this register will clear the corresponding bit in SR and the corresponding interrupt request.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
- - TXURCH - - - -
15 14 13 12 11 10 9 8
- - - - - - RXORCH
76543210
- TXUR - - - RXOR - -
606
32142D–06/2013
ATUC64/128/256L3/4U
24.8.5 Status Set Register
Name: SSR
Access Type: Write-only
Offset: 0x10
Reset Value: 0x00000000
Writing a zero to a bit in this register has no effect.
Writing a one to a bit in this register will set the corresponding bit in SR.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
- - TXURCH - - - -
15 14 13 12 11 10 9 8
- - - - - - RXORCH
76543210
- TXUR - - - RXOR - -
607
32142D–06/2013
ATUC64/128/256L3/4U
24.8.6 Interrupt Enable Register
Name: IER
Access Type: Write-only
Offset: 0x14
Reset Value: 0x00000000
Writing a zero to a bit in this register has no effect.
Writing a one to a bit in this register will set the corresponding bit in IMR.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
--------
76543210
- TXUR TXRDY - - RXOR RXRDY -
608
32142D–06/2013
ATUC64/128/256L3/4U
24.8.7 Interrupt Disable Register
Name: IDR
Access Type: Write-only
Offset: 0x18
Reset Value: 0x00000000
Writing a zero to a bit in this register has no effect.
Writing a one to a bit in this register will clear the corresponding bit in IMR.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
--------
76543210
- TXUR TXRDY - - RXOR RXRDY -
609
32142D–06/2013
ATUC64/128/256L3/4U
24.8.8 Interrupt Mask Register
Name: IMR
Access Type: Read-only
Offset: 0x1C
Reset Value: 0x00000000
0: The corresponding interrupt is disabled.
1: The corresponding interrupt is enabled.
A bit in this register is cleared when the corresponding bit in IDR is written to one.
A bit in this register is set when the corresponding bit in IER is written to one.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
--------
76543210
- TXUR TXRDY - - RXOR RXRDY -
610
32142D–06/2013
ATUC64/128/256L3/4U
24.8.9 Receive Holding Register
Name: RHR
Access Type: Read-only
Offset: 0x20
Reset Value: 0x00000000
• RHR: Received Word
This field is set by hardware to the last received data word. If MR.DATALENGTH specifies less than 32 bits, data shall be rightjustified
into the RHR field.
31 30 29 28 27 26 25 24
RHR[31:24]
23 22 21 20 19 18 17 16
RHR[23:16]
15 14 13 12 11 10 9 8
RHR[15:8]
76543210
RHR[7:0]
611
32142D–06/2013
ATUC64/128/256L3/4U
24.8.10 Transmit Holding Register
Name: THR
Access Type: Write-only
Offset: 0x24
Reset Value: 0x00000000
• THR: Data Word to Be Transmitted
Next data word to be transmitted after the current word if TXRDY is not set. If MR.DATALENGTH specifies less than 32 bits, data
shall be right-justified into the THR field.
31 30 29 28 27 26 25 24
THR[31:24]
23 22 21 20 19 18 17 16
THR[23:16]
15 14 13 12 11 10 9 8
THR[15:8]
76543210
THR[7:0]
612
32142D–06/2013
ATUC64/128/256L3/4U
24.8.11 Module Version
Name: VERSION
Access Type: Read-only
Offset: 0x28
Reset Value: -
• VARIANT: Variant Number
Reserved. No functionality associated.
• VERSION: Version Number
Version number of the module. No functionality associated.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
- - - - VARIANT
15 14 13 12 11 10 9 8
- - - - VERSION[11:8]
76543210
VERSION[7:0]
613
32142D–06/2013
ATUC64/128/256L3/4U
24.8.12 Module Parameters
Name: PARAMETER
Access Type: Read-only
Offset: 0x2C
Reset Value: -
Reserved. No functionality associated.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
--------
76543210
--------
614
32142D–06/2013
ATUC64/128/256L3/4U
24.9 Module configuration
The specific configuration for each IISC instance is listed in the following tables. The module bus
clocks listed here are connected to the system bus clocks. Please refer to the Power Manager
chapter for details.
Table 24-7. IISC Clocks
Clock Name Description
CLK_IISC Clock for the IISC bus interface
GCLK The generic clock used for the IISC is GCLK6
Table 24-8. Register Reset Values
Register Reset Value
VERSION 0x00000100
615
32142D–06/2013
ATUC64/128/256L3/4U
25. Pulse Width Modulation Controller (PWMA)
Rev: 2.0.1.0
25.1 Features
• Left-aligned non-inverted 12-bit PWM
• Common 12-bit timebase counter
– Asynchronous clock source supported
– Spread-spectrum counter to allow a constantly varying duty cycle
• Separate 12-bit duty cycle register per channel
• Synchronized channel updates
– No glitches when changing the duty cycles
• Interlinked operation supported
– Up to 32 channels can be updated with the same duty cycle value at a time
– Up to 4 channels can be updated with different duty cycle values at a time
• Interrupt on PWM timebase overflow
• Incoming peripheral events supported
– Pre-defined channels support incoming (increase/decrease) peripheral events from the
Peripheral Event System
– Incoming increase/decrease event can either increase or decrease the duty cycle by one
• One output peripheral event supported
– Connected to channel 0 and asserted when the common timebase counter is equal to the
programmed duty cycle for channel 0
• Output PWM waveforms
– Support normal waveform output for each channel
– Support composite waveform generation (XOR’ed) for each pair channels
• Open drain driving on selected pins for 5V PWM operation
25.2 Overview
The Pulse Width Modulation Controller (PWMA) controls several pulse width modulation (PWM)
channels. The number of channels is specific to the device. Each channel controls one square
output PWM waveform. Characteristics of the output PWM waveforms such as period and duty
cycle are configured through the user interface. All user interface registers are mapped on the
peripheral bus.
The duty cycle value for each channel can be set independently, while the period is determined
by a common timebase counter (TC). The timebase for the counter is selected by using the allocated
asynchronous Generic Clock (GCLK). The user interface for the PWMA contains
handshake and synchronizing logic to ensure that no glitches occur on the output PWM waveforms
while changing the duty cycle values.
PWMA duty cycle values can be changed using two approaches, either an interlinked singlevalue
mode or an interlinked multi-value mode. In the interlinked single-value mode, any set of
channels, up to 32 channels, can be updated simultaneously with the same value while the other
channels remain unchanged. There is also an interlinked multi-value mode, where the 8 least
significant bits of up to 4 channels can be updated with 4 different values while the other channels
remain unchanged.
Some pins can be driven in open drain mode, allowing the PWMA to generate a 5V waveform
using an external pullup resistor.
616
32142D–06/2013
ATUC64/128/256L3/4U
25.3 Block Diagram
Figure 25-1. PWMA Block Diagram
25.4 I/O Lines Description
Each channel outputs one PWM waveform on one external I/O line.
25.5 Product Dependencies
In order to use this module, other parts of the system must be configured correctly, as described
below.
PWM Blocks
Channel m
Channel 1
Channel 0
Duty Cycle
Register
COMP
PWMA[m:0]
Interrupt
Handling
IRQ
PB
TOP
Timebase
Counter
SPREAD
Adjust
TOFL
READY
Channel_0
CLK_PWMA
GCLK Domain
PB Clock Domain
Spread
Spectrum
Counter
Sync
GCLK ETV
Control
Duty Cycle Channel
Select WAVEXOR
CWG
TCLR CHERR
Table 25-1. I/O Line Description
Pin Name Pin Description Type
PWMA[n] Output PWM waveform for one channel n Output
PWMMOD[n] Output PWM waveform for one channel n, open drain mode Output
617
32142D–06/2013
ATUC64/128/256L3/4U
25.5.1 I/O Lines
The pins used for interfacing the PWMA may be multiplexed with I/O Controller lines. The programmer
must first program the I/O Controller to assign the desired PWMA pins to their
peripheral function.
It is only required to enable the PWMA outputs actually in use.
25.5.2 Power Management
If the CPU enters a sleep mode that disables clocks used by the PWMA, the PWMA will stop
functioning and resume operation after the system wakes up from sleep mode.
25.5.3 Clocks
The clock for the PWMA bus interface (CLK_PWMA) is controlled by the Power Manager. This
clock is enabled at reset, and can be disabled in the Power Manager. It is recommended to disable
the PWMA before disabling the clock, to avoid freezing the PWMA in an undefined state.
Additionally, the PWMA depends on a dedicated Generic Clock (GCLK). The GCLK can be set
to a wide range of frequencies and clock sources and must be enabled in the System Control
Interface (SCIF) before the PWMA can be used.
25.5.4 Interrupts
The PWMA interrupt request lines are connected to the interrupt controller. Using the PWMA
interrupts requires the interrupt controller to be programmed first.
25.5.5 Peripheral Events
The PWMA peripheral events are connected via the Peripheral Event System. Refer to the
Peripheral Event System chapter for details.
25.5.6 Debug Operation
When an external debugger forces the CPU into debug mode, the PWMA continues normal
operation. If the PWMA is configured in a way that requires it to be periodically serviced by the
CPU through interrupts, improper operation or data loss may result during debugging.
25.6 Functional Description
The PWMA embeds a number of PWM channel submodules, each providing an output PWM
waveform. Each PWM channel contains a duty cycle register and a comparator. A common
timebase counter for all channels determines the frequency and the period for all the PWM
waveforms.
25.6.1 Enabling the PWMA
Once the GCLK has been enabled, the PWMA is enabled by writing a one to the EN bit in the
Control Register (CR).
25.6.2 Timebase Counter
The top value of the timebase counter defines the period of the PWMA output waveform. The
timebase counter starts at zero when the PWMA is enabled and counts upwards until it reaches
its effective top value (ETV). The effective top value is defined by specifying the desired number
of GCLK clock cycles in the TOP field of Top Value Register (TVR.TOP) in normal operation (the
618
32142D–06/2013
ATUC64/128/256L3/4U
SPREAD field of CR (CR.SPREAD) is zero). When the timebase counter reaches its effective
top value, it restarts counting from zero. The period of the PWMA output waveform is then:
The timebase counter can be reset by writing a one to the Timebase Clear bit in CR (CR.TCLR).
Note that this can cause a glitch to the output PWM waveforms in use.
25.6.3 Spread Spectrum Counter
The spread spectrum counter allows the generation of constantly varying duty cycles on the output
PWM waveforms. This is achieved by varying the effective top value of the timebase counter
in a range defined by the spread spectrum counter value.
When CR.SPREAD is not zero, the spread spectrum counter is enabled. Its range is defined by
CR.SPREAD. It starts to count from -CR.SPREAD when the PWMA is enabled or after reset
and counts upwards. When it reaches CR.SPREAD, it restarts to count from -CR.SPREAD
again. The spread spectrum counter will cause the effective top value to vary from TOPSPREAD
to TOP+SPREAD. Figure 25-2 on page 618 illustrates this. This leads to a constantly
varying duty cycle on the PWM output waveforms though the duty cycle values stored are
unchanged.
Figure 25-2. PWMA Adjusting Top Value for Timebase Counter
25.6.3.1 Special considerations
The maximum value of the timebase counter is 0x0FFF. If SPREAD is written to a value that will
cause the ETV to exceed this value, the spread spectrum counter’s range will be limited to prevent
the timebase counter to exceed its maximum value.
If SPREAD is written to a value causing (TOP-SPREAD) to be below zero, the spread spectrum
counter’s range will be limited to prevent the timebase counter to count below zero.
In both cases, the SPREAD value read from the Control Register will be the same value as written
to the SPREAD field.
TPWMA ETV + 1 TGCLK =
0x0
0x0FFF
Duty Cycle
-SPREAD
SPREAD
TOP Adjusting top value range
for the timerbase counter
619
32142D–06/2013
ATUC64/128/256L3/4U
When writing a one to CR.TCLR, the timebase counter and the spread spectrum counter are
reset at their lower limit values and the effective top value of the timebase counter will also be
reset.
25.6.4 Duty Cycle and Waveform Properties
Each PWM channel has its own duty cycle value (DCV) which is write-only and cannot be read
out. The duty cycle value can be changed in two approaches as described in Section25.6.6.
When the duty cycle value is zero, the PWM output is zero. Otherwise, the PWM output is set
when the timebase counter is zero, and cleared when the timebase counter reaches the duty
cycle value. This is summarized as:
Note that when increasing the duty cycle value for one channel from 0 to 1, the number of GCLK
cycles when the PWM waveform is high will jump from 0 to 2. When incrementing the duty cycle
value by one for any other values, the number of GCLK cycle when the waveform is high will
increase by one. This is summarized in Table 25-2.
25.6.5 Waveform Output
PWMA waveforms are output to I/O lines. The output waveform properties are controlled by
Composite Waveform Generation (CWG) register(s). If this register is cleared (by default), the
channel waveforms are out directly to the I/O lines. To avoid too many I/O toggling simultaneously
on the output I/O lines, every other output PWM waveform toggles on the negative edge of
the GCLK instead of the positive edge.
In CWG mode, all channels are paired and their outputs are XOR’ed together if the corresponding
bit of CWG register is set. The even number of output is the XOR’ed output and the odd
number of output is the inverse of its. Each bit of CWG register controls one pair channels and
the least significant bit refers to the lowest number of pair channels.
25.6.6 Updating Duty Cycle Values
25.6.6.1 Interlinked Single Value PWM Operation
The PWM channels can be interlinked to allow multiple channels to be updated simultaneously
with the same duty cycle value. This value must be written to the Interlinked Single Value Duty
Table 25-2. PMW Waveform Duty Cycles
Duty Cycle Value
#Clock Cycles
When Waveform is High
#Clock Cycles
When Waveform is Low
0 0 ETV+1
1 2 ETV-1
2 3 ETV-2
... ... ...
ETV-1 ETV 1
ETV ETV+1 0
PWM Waveform = low when DCV = 0 or TC DCV
high when TC DCV and DCV 0
620
32142D–06/2013
ATUC64/128/256L3/4U
(ISDUTY) register. Each channel has a corresponding enabling bit in the Interlinked Single
Value Channel Set (ISCHSET) register(s). When a bit is written to one in the ISCHSET register,
the duty cycle register for the corresponding channel will be updated with the value stored in the
ISDUTY register. It can only be updated when the READY bit in the Status Register
(SR.READY) is one, indicating that the PWMA is ready for writing. Figure 25-3 on page 620
shows the writing procedure. It is thus possible to update the duty cycle values for up to 32 PWM
channels within one ISCHSET register at a time.
Figure 25-3. Interlinked Single Value PWM Operation Flow
25.6.6.2 Interlinked Multiple Value PWM Operation
The interlinked multiple value PWM operation allows up to four channels to be updated simultaneously
with different duty cycle values. The four duty cycle values are required to be written to
the four registers, DUTY3, DUTY2, DUTY1 and DUTY0 , respectively. The index number of the
four channels to be updated is written to the four SEL fields in the Interlinked Multiple Value
Channel Select (IMCHSEL) register (IMCHSEL.SEL). When the IMCHSEL register is written,
the values stored in the DUTY0/1/2/3 registers are synchronized to the duty cycle registers for
the channels selected by the SEL fields. Figure 25-4 on page 620 shows the writing procedure.
Note that only writes to the implemented channels will be effective. If one of the IMCHSEL.SEL
fields points to a non-existing channel, the corresponding value in the DUTYx register will not be
written. If the same channel is specified multiple times in the IMCHSEL.SEL fields, the channel
will be updated with the value referred by the upper IMCHSEL.SEL field.
When only the least significant 8-bits duty cycle value are considered for updating, the four duty
cycle values can be written to the IMDUTY register once. This is equivalent to writing the four
duty cycle values to the four DUTY registers one by one.
Figure 25-4. Interlinked Multiple Value PWM Operation Flow
ISCHSETm
...
Write
Enable
Channeln
DUTY
Channel1
DUTY
Channel0
DUTY
ISDUTY
Channel2
DUTY
DUTY3/2/1/0
IMDUTY IMCHSEL
Channeln
DUTY
...
MUX
Channel1
DUTY
Channel0
DUTY
621
32142D–06/2013
ATUC64/128/256L3/4U
25.6.7 Open Drain Mode
Some pins can be used in open drain mode, allowing the PWMA waveform to toggle between
0V and up to 5V on these pins. In this mode the PWMA will drive the pin to zero or leave the output
open. An external pullup can be used to pull the pin up to the desired voltage.
To enable open drain mode on a pin the PWMAOD function must be selected instead of the
PWMA function in the I/O Controller. Please refer to the Module Configuration chapter for information
about which pins are available in open drain mode.
25.6.8 Synchronization
Both the timebase counter and the spread spectrum counter can be reset and the duty cycle
registers can be written through the user interface of the module. This requires a synchronization
between the PB and GCLK clock domains, which takes a few clock cycles of each clock
domain. The BUSY bit in SR indicates when the synchronization is ongoing. Writing to the module
while the BUSY bit is set will result in discarding the new value.
Note that the duty cycle registers will not be updated with the new values until the timebase
counter reaches its top value, in order to avoid glitches. The BUSY bit in SR will always be set
during this updating and synchronization period.
25.6.9 Interrupts
When the timebase counter overflows, the Timebase Overflow bit in the Status Register
(SR.TOFL) is set. If the corresponding bit in the Interrupt Mask Register (IMR) is set, an interrupt
request will be generated.
Since the user needs to wait until the user interface is available between each write due to synchronization,
a READY bit is provided in SR, which can be used to generate an interrupt
request.
The interrupt request will be generated if the corresponding bit in IMR is set. Bits in IMR are set
by writing a one to the corresponding bit in the Interrupt Enable Register (IER), and cleared by
writing a one to the corresponding bit in the Interrupt Disable Register (IDR). The interrupt
request remains active until the corresponding bit in SR is cleared by writing a one to the corresponding
bit in the Status Clear Register (SCR).
25.6.10 Peripheral Events
25.6.10.1 Input Peripheral Events
The pre-defined channels support input peripheral events from the Peripheral Event System.
Input peripheral events must be enabled by writing a one to the corresponding bit in the Channel
Event Enable Registers (CHEERs) before peripheral events can be used to control the duty
cycle value. Each bit in the register corresponds to one channel, where bit 0 corresponds to
channel 0 and so on. Both the increase and decrease events are enabled for the corresponding
channel when a bit in the CHEER register is set.
An increase or decrease event (event_incr/event_decr) can either increase or decrease the duty
cycle value by one in a PWM period. The events are taken into account when the common timebase
counter reaches its top. The behavior is defined by the Channel Event Response Register
(CHERR). Each bit in the register corresponds to one channel, where bit 0 corresponds to channel
0 and so on. If the bit in CHERR is set to 0 (default) for a channel, the increase event will
increase the duty cycle value and the decrease event will decrease the duty cycle value for that
channel. If the bit is set to 1, the increase and decrease event will have reverse function so that
622
32142D–06/2013
ATUC64/128/256L3/4U
the increase event will decrease the duty cycle value and decrease event will increase the duty
cycle value. If both the increase event and the decrease event occur at the same time for a
channel, the duty cycle value will not be changed.
The number of channels supporting input peripheral events is device specific. Please refer to the
Module Configuration section at the end of this chapter for details.
25.6.10.2 Output Peripheral Event
The PWMA also supports one output peripheral event (event_ch0) to the Peripheral Event System.
This output peripheral event is connected to channel 0 and will be asserted when the
timebase counter reaches the duty cycle value for channel 0. This output event is always
enabled.
623
32142D–06/2013
ATUC64/128/256L3/4U
25.7 User Interface
Note: 1. The reset values are device specific. Please refer to the Module Configuration section at the end of this chapter.
Table 25-3. PWMA Register Memory Map
Offset Register Register Name Access Reset
0x00 Control Register CR Read/Write 0x00000000
0x04 Interlinked Single Value Duty Register ISDUTY Write-only 0x00000000
0x08 Interlinked Multiple Value Duty Register IMDUTY Write-only 0x00000000
0x0C Interlinked Multiple Value Channel Select IMCHSEL Write-only 0x00000000
0x10 Interrupt Enable Register IER Write-only 0x00000000
0x14 Interrupt Disable Register IDR Write-only 0x00000000
0x18 Interrupt Mask Register IMR Read-only 0x00000000
0x1C Status Register SR Read-only 0x00000000
0x20 Status Clear Register SCR Write-only 0x00000000
0x24 Parameter Register PARAMETER Read-only - (1)
0x28 Version Register VERSION Read-only - (1)
0x2C Top Value Register TVR Read/Write 0x00000000
0x30+m*0x10 Interlinked Single Value Channel Set m ISCHSETm Write-only 0x00000000
0x34+m*0x10 Channel Event Response Register m CHERRm Read/Write 0x00000000
0x38+m*0x10 Channel Event Enable Register m CHEERm Read/Write 0x00000000
0x3C+k*0x10 CWG Register CWGk Read/Write 0x00000000
0x80 Interlinked Multiple Value Duty0 Register DUTY0 Write-only 0x00000000
0x84 Interlinked Multiple Value Duty1 Register DUTY1 Write-only 0x00000000
0x88 Interlinked Multiple Value Duty2 Register DUTY2 Write-only 0x00000000
0x8C Interlinked Multiple Value Duty3 Register DUTY3 Write-only 0x00000000
624
32142D–06/2013
ATUC64/128/256L3/4U
25.7.1 Control Register
Name: CR
Access Type: Read/Write
Offset: 0x00
Reset Value: 0x00000000
• SPREAD: Spread Spectrum Limit Value
The spread spectrum limit value, together with the TOP field, defines the range for the spread spectrum counter. It is introduced
in order to achieve constant varying duty cycles on the output PWM waveforms. Refer to Section25.6.3 for more information.
• TOP: Timebase Counter Top Value
The top value for the timebase counter. The value written to this field will update the least significant 8 bits of the TVR.TOP field
in case only 8-bits resolution is required. The 4 most significant bits of TVR.TOP will be written to 0. When the TVR.TOP field is
written, this CR.TOP field will also be updated with only the least significant 8 bits of TVR.TOP field.
• TCLR: Timebase Clear
Writing a zero to this bit has no effect.
Writing a one to this bit will clear the timebase counter.
This bit is always read as zero.
• EN: Module Enable
0: The PWMA is disabled
1: The PWMA is enabled
31 30 29 28 27 26 25 24
- - - - - - - SPREAD[8]
23 22 21 20 19 18 17 16
SPREAD[7:0]
15 14 13 12 11 10 9 8
TOP
76543210
- - - - - - TCLR EN
625
32142D–06/2013
ATUC64/128/256L3/4U
25.7.2 Interlinked Single Value Duty Register
Name: ISDUTY
Access Type: Write-only
Offset: 0x04
Reset Value: 0x00000000
• DUTY: Duty Cycle Value
The duty cycle value written to this field is written simultaneously to all channels selected in the ISCHSETm register.
If the value zero is written to DUTY all affected channels will be disabled. In this state the output waveform will be zero all the
time.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
- - - - DUTY[11:8]
76543210
DUTY[7:0]
626
32142D–06/2013
ATUC64/128/256L3/4U
25.7.3 Interlinked Multiple Value Duty Register
Name: IMDUTY
Access Type: Write-only
Offset: 0x08
Reset Value: 0x00000000
• DUTYn: Duty Cycle
The value written to DUTY field n will be automatically written to the least significant 8 bits of the DUTYn register for a PWMA
channel while the most significant 4bits of the DUTYn register are unchanged. Which channel is selected for updating is defined
by the corresponding SEL field in the IMCHSEL register.
To write mulitple channels at a time with more than 8 bits of the duty cycle value, refer to DUTY3/2/1/0 registers.
If the value zero is written to DUTY all affected channels will be disabled. In this state the output waveform will be zero all the
time.
31 30 29 28 27 26 25 24
DUTY3
23 22 21 20 19 18 17 16
DUTY2
15 14 13 12 11 10 9 8
DUTY1
76543210
DUTY0
627
32142D–06/2013
ATUC64/128/256L3/4U
25.7.4 Interlinked Multiple Value Channel Select
Name: IMCHSEL
Access Type: Write-only
Offset: 0x0C
Reset Value: 0x00000000
• SELn: Channel Select
The duty cycle of the PWMA channel SELn will be updated with the value stored in the DUTYn register when IMCHSEL is
written. If SELn points to a non-implemented channel, the write will be discarded.
Note: The duty registers will be updated with the value stored in the DUTY3, DUTY2, DUTY1 and DUTY0 registers when the IMCHSEL
register is written. Synchronization takes place immediately when an IMCHSEL register is written. The duty cycle registers
will, however, not be updated until the synchronization is completed and the timebase counter reaches its top value in order to
avoid glitches. When only 8 bits duty cycle value are considered for updating, the four duty cycle values can be written to the
IMDUTY register once. This is equivalent to writing the 8 bits four duty cycle values to the four DUTY registers one by one while
the upper 4 bits remain unchanged.
31 30 29 28 27 26 25 24
SEL3
23 22 21 20 19 18 17 16
SEL2
15 14 13 12 11 10 9 8
SEL1
76543210
SEL0
628
32142D–06/2013
ATUC64/128/256L3/4U
25.7.5 Interrupt Enable Register
Name: IER
Access Type: Write-only
Offset: 0x10
Reset Value: 0x00000000
Writing a zero to a bit in this register has no effect
Writing a one to a bit in this register will set the corresponding bit in IMR.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
--------
76543210
- - - - - READY - TOFL
629
32142D–06/2013
ATUC64/128/256L3/4U
25.7.6 Interrupt Disable Register
Name: IDR
Access Type: Write-only
Offset: 0x14
Reset Value: 0x00000000
Writing a zero to a bit in this register has no effect
Writing a one to a bit in this register will clear the corresponding bit in IMR.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
--------
76543210
- - - - - READY - TOFL
630
32142D–06/2013
ATUC64/128/256L3/4U
25.7.7 Interrupt Mask Register
Name: IMR
Access Type: Read-only
Offset: 0x18
Reset Value: 0x00000000
0: The corresponding interrupt is disabled.
1: The corresponding interrupt is enabled.
A bit in this register is cleared when the corresponding bit in IDR is written to one.
A bit in this register is set when the corresponding bit in IER is written to one.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
--------
76543210
- - - - - READY - TOFL
631
32142D–06/2013
ATUC64/128/256L3/4U
25.7.8 Status Register
Name: SR
Access Type: Read-only
Offset: 0x1C
Reset Value: 0x00000000
• BUSY: Interface Busy
This bit is automatically cleared when the interface is no longer busy.
This bit is set when the user interface is busy and will not respond to new write operations.
• READY: Interface Ready
This bit is cleared by writing a one to the corresponding bit in the SCR register.
This bit is set when the BUSY bit has a 1-to-0 transition.
• TOFL: Timebase Overflow
This bit is cleared by writing a one to corresponding bit in the SCR register.
This bit is set when the timebase counter has wrapped at its top value.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
--------
76543210
- - - - BUSY READY - TOFL
632
32142D–06/2013
ATUC64/128/256L3/4U
25.7.9 Status Clear Register
Name: SCR
Access Type: Write-only
Offset: 0x20
Reset Value: 0x00000000
Writing a zero to a bit in this register has no effect.
Writing a one to a bit in this register will clear the corresponding bit in SR and the corresponding interrupt request.
This register always reads as zero.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 1 10 9 8
--------
76543210
- - - - - READY - TOFL
633
32142D–06/2013
ATUC64/128/256L3/4U
25.7.10 Parameter Register
Name: PARAMETER
Access Type: Read-only
Offset: 0x24
Reset Value: -
• CHANNELS: Channels Implemented
This field contains the number of channels implemented on the device.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
--------
76543210
CHANNELS
634
32142D–06/2013
ATUC64/128/256L3/4U
25.7.11 Version Register
Name: VERSION
Access Type: Read-only
Offset: 0x28
Reset Value: -
• VARIANT: Variant Number
Reserved. No functionality associated.
• VERSION: Version Number
Version number of the module. No functionality associated.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
- - - - VARIANT
15 14 13 12 11 10 9 8
- - - - VERSION[11:8]
76543210
VERSION[7:0]
635
32142D–06/2013
ATUC64/128/256L3/4U
25.7.12 Top Value Register
Name: TVR
Access Type: Read/Write
Offset: 0x2C
Reset Value: 0x00000000
• TOP: Timebase Counter Top Value
The top value for the timebase counter. The value written to the CR.TOP field will automatically be written to the 8 least
significant bits of this field while the 4 most significant bits will be 0. When this register is written, it will also automatically update
the CR.TOP field with the 8 least significant bits.
The effective top value of the timebase counter is defined by both TVR.TOP and the CR.SPREAD. Refer to Section25.6.2 for
more information.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
- - - - TOP[11:8]
76543210
TOP[7:0]
636
32142D–06/2013
ATUC64/128/256L3/4U
25.7.13 Interlinked Single Value Channel Set
Name: ISCHSETm
Access Type: Write-only
Offset: 0x30+m*0x10
Reset Value: 0x00000000
• SET: Single Value Channel Set
If the bit n in SET is one, the duty cycle of PWMA channel n will be updated with the value written to ISDUTY.
If more than one ISCHSET register is present, ISCHSET0 controls channels 31 to 0 and ISCHSET1 controls channels 63 to 32.
Note: The duty registers will be updated with the value stored in the ISDUTY register when any ISCHSETm register is written. Synchronization
takes place immediately when an ISCHSET register is written. The duty cycle registers will, however, not be
updated until the synchronization is completed and the timebase counter reaches its top value in order to avoid glitches.
31 30 29 28 27 26 25 24
SET
23 22 21 20 19 18 17 16
SET
15 14 13 12 11 10 9 8
SET
76543210
SET
637
32142D–06/2013
ATUC64/128/256L3/4U
25.7.14 Channel Event Response Register
Name: CHERRm
Access Type: Read/Write
Offset: 0x34+m*0x10
Reset Value: 0x00000000
• CHER: Channel Event Response
0: The increase event will increase the duty cycle value by one in a PWM period for the corresponding channel and the
decrease event will decrease the duty cycle value by one.
1: The increase event will decrease the duty cycle value by one in a PWM period for the corresponding channel and the
decrease event will increase the duty cycle value by one.
The events are taken into account when the common timebase counter reaches its top.
If more than one CHERR register is present, CHERR0 controls channels 31-0 and CHERR1 controls channels 64-32 and so on.
31 30 29 28 27 26 25 24
CHER
23 22 21 20 19 18 17 16
CHER
15 14 13 12 11 10 9 8
CHER
76543210
CHER
638
32142D–06/2013
ATUC64/128/256L3/4U
25.7.15 Channel Event Enable Register
Name: CHEERm
Access Type: Read/Write
Offset: 0x38+m*0x10
Reset Value: 0x00000000
• CHEE: Channel Event Enable
0: The input peripheral event for the corresponding channel is disabled.
1: The input peripheral event for the corresponding channel is enabled.
Both increase and decrease events for channel n are enabled if bit n is one.
If more than one CHEER register is present, CHEER0 controls channels 31-0 and CHEER1 controls channels 64-32 and so on.
31 30 29 28 27 26 25 24
CHEE
23 22 21 20 19 18 17 16
CHEE
15 14 13 12 11 10 9 8
CHEE
76543210
CHEE
639
32142D–06/2013
ATUC64/128/256L3/4U
25.7.16 Composite Waveform Generation
Name: CWG
Access Type: Read/Write
Offset: 0x3C+k*0x10
Reset Value: 0x00000000
• XOR: Pair Waveform XOR’ed
If the bit n in XOR field is one, the pair of PWMA output waveforms will be XORed before output. The even number output will be
the XOR’ed output and the odd number output will be reverse of it. For example, if bit 0 in XOR is one, the pair of PWMA output
waveforms for channel 0 and 1 will be XORed together.
If bit n in XOR is zero, normal waveforms are output for that pair. Note that
If more than one CWG register is present, CWG0 controls the first 32 pairs, corresponding to channels 63 downto 0, and CWG1
controls the second 32 pairs, corresponding to channels 127 downto 64.
31 30 29 28 27 26 25 24
XOR
23 22 21 20 19 18 17 16
XOR
15 14 13 12 11 10 9 8
XOR
76543210
XOR
640
32142D–06/2013
ATUC64/128/256L3/4U
25.7.17 Interlinked Multiple Value Duty0/1/2/3 Register
Name: DUTY0/1/2/3
Access Type: Write-only
Offset: 0x80-0x8C
Reset Value: 0x00000000
These registers allows up to 4 channels to be updated with a common 12-bits duty cycle value at a time. They are the
extension of the IMDUTY register which only supports updating the least significant 8 bits of the duty registers for up to 4
channels.
• DUTY: Duty Cycle Value
The duty cycle value written to this field will be updated to the channel specified by IMCHSEL.
DUTY0 is specified by IMCHSEL.SEL0, DUTY1 is specified by IMCHSEL.SEL1, and so on.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
- - - - DUTY[11:8]
76543210
DUTY[7:0]
641
32142D–06/2013
ATUC64/128/256L3/4U
25.8 Module Configuration
The specific configuration for each PWMA instance is listed in the following tables. The module
bus clocks listed here are connected to the system bus clocks. Please refer to the Power Manager
chapter for details.
Table 25-4. PWMA Configuration
Feature PWMA
Number of PWM channels 36
Channels supporting incoming peripheral events 0, 6, 8, 9, 11, 14, 19, and 20
PWMA channels with Open Drain mode 21, 27, and 28
Table 25-5. PWMA Clocks
Clock Name Descripton
CLK_PWMA Clock for the PWMA bus interface
GCLK The generic clock used for the PWMA is GCLK3
Table 25-6. Register Reset Values
Register Reset Value
VERSION 0x00000201
PARAMETER 0x00000024
642
32142D–06/2013
ATUC64/128/256L3/4U
26. Timer/Counter (TC)
Rev: 2.2.3.1.3
26.1 Features
• Three 16-bit Timer Counter channels
• A wide range of functions including:
– Frequency measurement
– Event counting
– Interval measurement
– Pulse generation
– Delay timing
– Pulse width modulation
– Up/down capabilities
• Each channel is user-configurable and contains:
– Three external clock inputs
– Five internal clock inputs
– Two multi-purpose input/output signals
• Internal interrupt signal
• Two global registers that act on all three TC channels
• Peripheral event input on all A lines in capture mode
26.2 Overview
The Timer Counter (TC) includes three identical 16-bit Timer Counter channels.
Each channel can be independently programmed to perform a wide range of functions including
frequency measurement, event counting, interval measurement, pulse generation, delay timing,
and pulse width modulation.
Each channel has three external clock inputs, five internal clock inputs, and two multi-purpose
input/output signals which can be configured by the user. Each channel drives an internal interrupt
signal which can be programmed to generate processor interrupts.
The TC block has two global registers which act upon all three TC channels.
The Block Control Register (BCR) allows the three channels to be started simultaneously with
the same instruction.
The Block Mode Register (BMR) defines the external clock inputs for each channel, allowing
them to be chained.
643
32142D–06/2013
ATUC64/128/256L3/4U
26.3 Block Diagram
Figure 26-1. TC Block Diagram
26.4 I/O Lines Description
26.5 Product Dependencies
In order to use this module, other parts of the system must be configured correctly, as described
below.
26.5.1 I/O Lines
The pins used for interfacing the compliant external devices may be multiplexed with I/O lines.
The user must first program the I/O Controller to assign the TC pins to their peripheral functions.
I/O
Controller
TC2XC2S
INT0
INT1
INT2
TIOA0
TIOA1
TIOA2
TIOB0
TIOB1
TIOB2
XC2
TCLK0
TCLK1
TCLK2
TCLK0
TCLK1
TCLK2
TCLK0
TCLK1
TCLK2
TIOA1
TIOA2
TIOA0
TIOA2
TIOA1
Interrupt
Controller
CLK0
CLK1
CLK2
A0
B0
A1
B1
A2
B2
Timer Count er
TIOB
TIOA
TIOB
SYNC
TIMER_CLOCK1
TIOA
SYNC
SYNC
TIOA
TIOB
TIMER_CLOCK2
TIMER_CLOCK3
TIMER_CLOCK4
TIMER_CLOCK5
XC1
XC0
XC0
XC2
XC1
XC0
XC1
XC2
Timer/Counter
Channel 2
Timer/Counter
Channel 1
Timer/Counter
Channel 0
TC1XC1S
TC0XC0S
TIOA0
Table 26-1. I/O Lines Description
Pin Name Description Type
CLK0-CLK2 External Clock Input Input
A0-A2 I/O Line A Input/Output
B0-B2 I/O Line B Input/Output
644
32142D–06/2013
ATUC64/128/256L3/4U
When using the TIOA lines as inputs the user must make sure that no peripheral events are generated
on the line. Refer to the Peripheral Event System chapter for details.
26.5.2 Power Management
If the CPU enters a sleep mode that disables clocks used by the TC, the TC will stop functioning
and resume operation after the system wakes up from sleep mode.
26.5.3 Clocks
The clock for the TC bus interface (CLK_TC) is generated by the Power Manager. This clock is
enabled at reset, and can be disabled in the Power Manager. It is recommended to disable the
TC before disabling the clock, to avoid freezing the TC in an undefined state.
26.5.4 Interrupts
The TC interrupt request line is connected to the interrupt controller. Using the TC interrupt
requires the interrupt controller to be programmed first.
26.5.5 Peripheral Events
The TC peripheral events are connected via the Peripheral Event System. Refer to the Peripheral
Event System chapter for details.
26.5.6 Debug Operation
The Timer Counter clocks are frozen during debug operation, unless the OCD system keeps
peripherals running in debug operation.
26.6 Functional Description
26.6.1 TC Description
The three channels of the Timer Counter are independent and identical in operation. The registers
for channel programming are listed in Figure 26-3 on page 659.
26.6.1.1 Channel I/O Signals
As described in Figure 26-1 on page 643, each Channel has the following I/O signals.
26.6.1.2 16-bit counter
Each channel is organized around a 16-bit counter. The value of the counter is incremented at
each positive edge of the selected clock. When the counter has reached the value 0xFFFF and
passes to 0x0000, an overflow occurs and the Counter Overflow Status bit in the Channel n Status
Register (SRn.COVFS) is set.
Table 26-2. Channel I/O Signals Description
Block/Channel Signal Name Description
Channel Signal
XC0, XC1, XC2 External Clock Inputs
TIOA Capture mode: Timer Counter Input
Waveform mode: Timer Counter Output
TIOB Capture mode: Timer Counter Input
Waveform mode: Timer Counter Input/Output
INT Interrupt Signal Output
SYNC Synchronization Input Signal
645
32142D–06/2013
ATUC64/128/256L3/4U
The current value of the counter is accessible in real time by reading the Channel n Counter
Value Register (CVn). The counter can be reset by a trigger. In this case, the counter value
passes to 0x0000 on the next valid edge of the selected clock.
26.6.1.3 Clock selection
At block level, input clock signals of each channel can either be connected to the external inputs
TCLK0, TCLK1 or TCLK2, or be connected to the configurable I/O signals A0, A1 or A2 for
chaining by writing to the BMR register. See Figure 26-2 on page 645.
Each channel can independently select an internal or external clock source for its counter:
• Internal clock signals: TIMER_CLOCK1, TIMER_CLOCK2, TIMER_CLOCK3,
TIMER_CLOCK4, TIMER_CLOCK5. See the Module Configuration Chapter for details about
the connection of these clock sources.
• External clock signals: XC0, XC1 or XC2. See the Module Configuration Chapter for details
about the connection of these clock sources.
This selection is made by the Clock Selection field in the Channel n Mode Register
(CMRn.TCCLKS).
The selected clock can be inverted with the Clock Invert bit in CMRn (CMRn.CLKI). This allows
counting on the opposite edges of the clock.
The burst function allows the clock to be validated when an external signal is high. The Burst
Signal Selection field in the CMRn register (CMRn.BURST) defines this signal.
Note: In all cases, if an external clock is used, the duration of each of its levels must be longer than the
CLK_TC period. The external clock frequency must be at least 2.5 times lower than the CLK_TC.
Figure 26-2. Clock Selection
TIMER_CLOCK5
XC2
TCCLKS
CLKI
BURST
1
Selected
Clock
XC1
XC0
TIMER_CLOCK4
TIMER_CLOCK3
TIMER_CLOCK2
TIMER_CLOCK1
646
32142D–06/2013
ATUC64/128/256L3/4U
26.6.1.4 Clock control
The clock of each counter can be controlled in two different ways: it can be enabled/disabled
and started/stopped. See Figure 26-3 on page 646.
• The clock can be enabled or disabled by the user by writing to the Counter Clock
Enable/Disable Command bits in the Channel n Clock Control Register (CCRn.CLKEN and
CCRn.CLKDIS). In Capture mode it can be disabled by an RB load event if the Counter Clock
Disable with RB Loading bit in CMRn is written to one (CMRn.LDBDIS). In Waveform mode,
it can be disabled by an RC Compare event if the Counter Clock Disable with RC Compare
bit in CMRn is written to one (CMRn.CPCDIS). When disabled, the start or the stop actions
have no effect: only a CLKEN command in CCRn can re-enable the clock. When the clock is
enabled, the Clock Enabling Status bit is set in SRn (SRn.CLKSTA).
• The clock can also be started or stopped: a trigger (software, synchro, external or compare)
always starts the clock. In Capture mode the clock can be stopped by an RB load event if the
Counter Clock Stopped with RB Loading bit in CMRn is written to one (CMRn.LDBSTOP). In
Waveform mode it can be stopped by an RC compare event if the Counter Clock Stopped
with RC Compare bit in CMRn is written to one (CMRn.CPCSTOP). The start and the stop
commands have effect only if the clock is enabled.
Figure 26-3. Clock Control
26.6.1.5 TC operating modes
Each channel can independently operate in two different modes:
• Capture mode provides measurement on signals.
• Waveform mode provides wave generation.
The TC operating mode selection is done by writing to the Wave bit in the CCRn register
(CCRn.WAVE).
In Capture mode, TIOA and TIOB are configured as inputs.
Q S
R
S
R
Q
CLKSTA CLKEN CLKDIS
Stop
Event
Disable
Counter
Clock
Selected
Clock Trigger
Event
647
32142D–06/2013
ATUC64/128/256L3/4U
In Waveform mode, TIOA is always configured to be an output and TIOB is an output if it is not
selected to be the external trigger.
26.6.1.6 Trigger
A trigger resets the counter and starts the counter clock. Three types of triggers are common to
both modes, and a fourth external trigger is available to each mode.
The following triggers are common to both modes:
• Software Trigger: each channel has a software trigger, available by writing a one to the
Software Trigger Command bit in CCRn (CCRn.SWTRG).
• SYNC: each channel has a synchronization signal SYNC. When asserted, this signal has the
same effect as a software trigger. The SYNC signals of all channels are asserted
simultaneously by writing a one to the Synchro Command bit in the BCR register
(BCR.SYNC).
• Compare RC Trigger: RC is implemented in each channel and can provide a trigger when the
counter value matches the RC value if the RC Compare Trigger Enable bit in CMRn
(CMRn.CPCTRG) is written to one.
The channel can also be configured to have an external trigger. In Capture mode, the external
trigger signal can be selected between TIOA and TIOB. In Waveform mode, an external event
can be programmed to be one of the following signals: TIOB, XC0, XC1, or XC2. This external
event can then be programmed to perform a trigger by writing a one to the External Event Trigger
Enable bit in CMRn (CMRn.ENETRG).
If an external trigger is used, the duration of the pulses must be longer than the CLK_TC period
in order to be detected.
Regardless of the trigger used, it will be taken into account at the following active edge of the
selected clock. This means that the counter value can be read differently from zero just after a
trigger, especially when a low frequency signal is selected as the clock.
26.6.1.7 Peripheral events on TIOA inputs
The TIOA input lines are ored internally with peripheral events from the Peripheral Event System.
To capture using events the user must ensure that the corresponding pin functions for the
TIOA line are disabled. When capturing on the external TIOA pin the user must ensure that no
peripheral events are generated on this pin.
26.6.2 Capture Operating Mode
This mode is entered by writing a zero to the CMRn.WAVE bit.
Capture mode allows the TC channel to perform measurements such as pulse timing, frequency,
period, duty cycle and phase on TIOA and TIOB signals which are considered as
inputs.
Figure 26-4 on page 649 shows the configuration of the TC channel when programmed in Capture
mode.
26.6.2.1 Capture registers A and B
Registers A and B (RA and RB) are used as capture registers. This means that they can be
loaded with the counter value when a programmable event occurs on the signal TIOA.
648
32142D–06/2013
ATUC64/128/256L3/4U
The RA Loading Selection field in CMRn (CMRn.LDRA) defines the TIOA edge for the loading of
the RA register, and the RB Loading Selection field in CMRn (CMRn.LDRB) defines the TIOA
edge for the loading of the RB register.
RA is loaded only if it has not been loaded since the last trigger or if RB has been loaded since
the last loading of RA.
RB is loaded only if RA has been loaded since the last trigger or the last loading of RB.
Loading RA or RB before the read of the last value loaded sets the Load Overrun Status bit in
SRn (SRn.LOVRS). In this case, the old value is overwritten.
26.6.2.2 Trigger conditions
In addition to the SYNC signal, the software trigger and the RC compare trigger, an external trigger
can be defined.
The TIOA or TIOB External Trigger Selection bit in CMRn (CMRn.ABETRG) selects TIOA or
TIOB input signal as an external trigger. The External Trigger Edge Selection bit in CMRn
(CMRn.ETREDG) defines the edge (rising, falling or both) detected to generate an external trigger.
If CMRn.ETRGEDG is zero (none), the external trigger is disabled.
649
32142D–06/2013
ATUC64/128/256L3/4U
Figure 26-4. Capture Mode TIMER_CLOCK1 XC0
XC1
XC2
TCCLKS
CLKI
Q S
R
S
R
Q
CLKSTA CLKEN CLKDIS
BURST
TIOB
Capture
Register A Compare RC =
16-bit
Counter
ABETRG
SWTRG
ETRGEDG CPCTRG
IMR
Trig
LDRBS
LDRAS
ETRGS
SR
LOVRS
COVFS
SYNC
1
MTIOB
TIOA
MTIOA
LDRA
LDBSTOP
If RA is not Loaded
or RB is Loaded If RA is Loaded
LDBDIS
CPCS
INT
Edge
Detector
LDRB
CLK OVF
RESET
Timer/Counter Channel
Edge
Detector
Edge
Detector
Capture
Register B
Register C
TIMER_CLOCK2
TIMER_CLOCK3
TIMER_CLOCK4
TIMER_CLOCK5
650
32142D–06/2013
ATUC64/128/256L3/4U
26.6.3 Waveform Operating Mode
Waveform operating mode is entered by writing a one to the CMRn.WAVE bit.
In Waveform operating mode the TC channel generates one or two PWM signals with the same
frequency and independently programmable duty cycles, or generates different types of oneshot
or repetitive pulses.
In this mode, TIOA is configured as an output and TIOB is defined as an output if it is not used
as an external event.
Figure 26-5 on page 651 shows the configuration of the TC channel when programmed in
Waveform operating mode.
26.6.3.1 Waveform selection
Depending on the Waveform Selection field in CMRn (CMRn.WAVSEL), the behavior of CVn
varies.
With any selection, RA, RB and RC can all be used as compare registers.
RA Compare is used to control the TIOA output, RB Compare is used to control the TIOB output
(if correctly configured) and RC Compare is used to control TIOA and/or TIOB outputs.
651
32142D–06/2013
ATUC64/128/256L3/4U
Figure 26-5. Waveform Mode TCCLKS CLKI Q S
R
S
R
Q
CLKSTA CLKEN CLKDIS
CPCDIS
BURST
TIOB
Register A
Compare RC =
CPCSTOP
16-bit
Counter
EEVT
EEVTEDG
SYNC
SWTRG
ENETRG
WAVSEL
IMR
Trig
ACPC
ACPA
AEEVT
ASWTRG
BCPC
BCPB
BEEVT
BSWTRG
TIOA
MTIOA
TIOB
MTIOB
CPAS
COVFS
ETRGS
SR
CPCS
CPBS
CLK
OVF
RESET
Output Contr oller O utput Cont r oller
INT
1
Edge
Detector
Timer/Counter Channel
TIMER_CLOCK1
XC0
XC1
XC2
WAVSEL
Register B Register C
Compare RB = Compare RA =
TIMER_CLOCK2
TIMER_CLOCK3
TIMER_CLOCK4
TIMER_CLOCK5
652
32142D–06/2013
ATUC64/128/256L3/4U
26.6.3.2 WAVSEL = 0
When CMRn.WAVSEL is zero, the value of CVn is incremented from 0 to 0xFFFF. Once
0xFFFF has been reached, the value of CVn is reset. Incrementation of CVn starts again and
the cycle continues. See Figure 26-6 on page 652.
An external event trigger or a software trigger can reset the value of CVn. It is important to note
that the trigger may occur at any time. See Figure 26-7 on page 653.
RC Compare cannot be programmed to generate a trigger in this configuration. At the same
time, RC Compare can stop the counter clock (CMRn.CPCSTOP = 1) and/or disable the counter
clock (CMRn.CPCDIS = 1).
Figure 26-6. WAVSEL= 0 Without Trigger
Time
Counter Value
RC
RB
RA
TIOB
TIOA
Counter cleared by compare match with
0xFFFF
0xFFFF
Waveform Examples
653
32142D–06/2013
ATUC64/128/256L3/4U
Figure 26-7. WAVSEL= 0 With Trigger
26.6.3.3 WAVSEL = 2
When CMRn.WAVSEL is two, the value of CVn is incremented from zero to the value of RC,
then automatically reset on a RC Compare. Once the value of CVn has been reset, it is then
incremented and so on. See Figure 26-8 on page 654.
It is important to note that CVn can be reset at any time by an external event or a software trigger
if both are programmed correctly. See Figure 26-9 on page 654.
In addition, RC Compare can stop the counter clock (CMRn.CPCSTOP) and/or disable the
counter clock (CMRn.CPCDIS = 1).
Time
Counter Value
RC
RB
RA
TIOB
TIOA
Counter cleared by compare match with 0xFFFF
0xFFFF
Waveform Examples
Counter cleared by trigger
654
32142D–06/2013
ATUC64/128/256L3/4U
Figure 26-8. WAVSEL = 2 Without Trigger
Figure 26-9. WAVSEL = 2 With Trigger
26.6.3.4 WAVSEL = 1
When CMRn.WAVSEL is one, the value of CVn is incremented from 0 to 0xFFFF. Once 0xFFFF
is reached, the value of CVn is decremented to 0, then re-incremented to 0xFFFF and so on.
See Figure 26-10 on page 655.
Time
Counter Value
RC
RB
RA
TIOB
TIOA
Counter cleared by compare match
with RC
0xFFFF
Waveform Examples
Time
Counter Value
RC
RB
RA
TIOB
TIOA
Counter cleared by compare match with RC
0xFFFF
Waveform Examples
Counter cleared by trigger
655
32142D–06/2013
ATUC64/128/256L3/4U
A trigger such as an external event or a software trigger can modify CVn at any time. If a trigger
occurs while CVn is incrementing, CVn then decrements. If a trigger is received while CVn is
decrementing, CVn then increments. See Figure 26-11 on page 655.
RC Compare cannot be programmed to generate a trigger in this configuration.
At the same time, RC Compare can stop the counter clock (CMRn.CPCSTOP = 1) and/or disable
the counter clock (CMRn.CPCDIS = 1).
Figure 26-10. WAVSEL = 1 Without Trigger
Figure 26-11. WAVSEL = 1 With Trigger
Time
Counter Value
RC
RB
RA
TIOB
TIOA
Counter decremented by compare match
with 0xFFFF
0xFFFF
Waveform Examples
Time
Counter Value
TIOB
TIOA
Counter decremented by compare match with 0xFFFF
0xFFFF
Waveform Examples
Counter decremented by trigger
RC
RB
RA
Counter incremented by trigger
656
32142D–06/2013
ATUC64/128/256L3/4U
26.6.3.5 WAVSEL = 3
When CMRn.WAVSEL is three, the value of CVn is incremented from zero to RC. Once RC is
reached, the value of CVn is decremented to zero, then re-incremented to RC and so on. See
Figure 26-12 on page 656.
A trigger such as an external event or a software trigger can modify CVn at any time. If a trigger
occurs while CVn is incrementing, CVn then decrements. If a trigger is received while CVn is
decrementing, CVn then increments. See Figure 26-13 on page 657.
RC Compare can stop the counter clock (CMRn.CPCSTOP = 1) and/or disable the counter clock
(CMRn.CPCDIS = 1).
Figure 26-12. WAVSEL = 3 Without Trigger
Time
Counter Value
RC
RB
RA
TIOB
TIOA
Counter cleared by compare match with RC
0xFFFF
Waveform Examples
657
32142D–06/2013
ATUC64/128/256L3/4U
Figure 26-13. WAVSEL = 3 With Trigger
26.6.3.6 External event/trigger conditions
An external event can be programmed to be detected on one of the clock sources (XC0, XC1,
XC2) or TIOB. The external event selected can then be used as a trigger.
The External Event Selection field in CMRn (CMRn.EEVT) selects the external trigger. The
External Event Edge Selection field in CMRn (CMRn.EEVTEDG) defines the trigger edge for
each of the possible external triggers (rising, falling or both). If CMRn.EEVTEDG is written to
zero, no external event is defined.
If TIOB is defined as an external event signal (CMRn.EEVT = 0), TIOB is no longer used as an
output and the compare register B is not used to generate waveforms and subsequently no
IRQs. In this case the TC channel can only generate a waveform on TIOA.
When an external event is defined, it can be used as a trigger by writing a one to the
CMRn.ENETRG bit.
As in Capture mode, the SYNC signal and the software trigger are also available as triggers. RC
Compare can also be used as a trigger depending on the CMRn.WAVSEL field.
26.6.3.7 Output controller
The output controller defines the output level changes on TIOA and TIOB following an event.
TIOB control is used only if TIOB is defined as output (not as an external event).
The following events control TIOA and TIOB:
• software trigger
• external event
• RC compare
RA compare controls TIOA and RB compare controls TIOB. Each of these events can be programmed
to set, clear or toggle the output as defined in the following fields in CMRn:
• RC Compare Effect on TIOB (CMRn.BCPC)
Time
Counter Value
TIOB
TIOA
Counter decremented by compare match
with RC
0xFFFF
Waveform Examples
RC
RB
RA
Counter decremented by trigger
Counter incremented by trigger
658
32142D–06/2013
ATUC64/128/256L3/4U
• RB Compare Effect on TIOB (CMRn.BCPB)
• RC Compare Effect on TIOA (CMRn.ACPC)
• RA Compare Effect on TIOA (CMRn.ACPA)
659
32142D–06/2013
ATUC64/128/256L3/4U
26.7 User Interface
Table 26-3. TC Register Memory Map
Offset Register Register Name Access Reset
0x00 Channel 0 Control Register CCR0 Write-only 0x00000000
0x04 Channel 0 Mode Register CMR0 Read/Write 0x00000000
0x10 Channel 0 Counter Value CV0 Read-only 0x00000000
0x14 Channel 0 Register A RA0 Read/Write(1) 0x00000000
0x18 Channel 0 Register B RB0 Read/Write(1) 0x00000000
0x1C Channel 0 Register C RC0 Read/Write 0x00000000
0x20 Channel 0 Status Register SR0 Read-only 0x00000000
0x24 Interrupt Enable Register IER0 Write-only 0x00000000
0x28 Channel 0 Interrupt Disable Register IDR0 Write-only 0x00000000
0x2C Channel 0 Interrupt Mask Register IMR0 Read-only 0x00000000
0x40 Channel 1 Control Register CCR1 Write-only 0x00000000
0x44 Channel 1 Mode Register CMR1 Read/Write 0x00000000
0x50 Channel 1 Counter Value CV1 Read-only 0x00000000
0x54 Channel 1 Register A RA1 Read/Write(1) 0x00000000
0x58 Channel 1 Register B RB1 Read/Write(1) 0x00000000
0x5C Channel 1 Register C RC1 Read/Write 0x00000000
0x60 Channel 1 Status Register SR1 Read-only 0x00000000
0x64 Channel 1 Interrupt Enable Register IER1 Write-only 0x00000000
0x68 Channel 1 Interrupt Disable Register IDR1 Write-only 0x00000000
0x6C Channel 1 Interrupt Mask Register IMR1 Read-only 0x00000000
0x80 Channel 2 Control Register CCR2 Write-only 0x00000000
0x84 Channel 2 Mode Register CMR2 Read/Write 0x00000000
0x90 Channel 2 Counter Value CV2 Read-only 0x00000000
0x94 Channel 2 Register A RA2 Read/Write(1) 0x00000000
0x98 Channel 2 Register B RB2 Read/Write(1) 0x00000000
0x9C Channel 2 Register C RC2 Read/Write 0x00000000
0xA0 Channel 2 Status Register SR2 Read-only 0x00000000
0xA4 Channel 2 Interrupt Enable Register IER2 Write-only 0x00000000
0xA8 Channel 2 Interrupt Disable Register IDR2 Write-only 0x00000000
0xAC Channel 2 Interrupt Mask Register IMR2 Read-only 0x00000000
0xC0 Block Control Register BCR Write-only 0x00000000
0xC4 Block Mode Register BMR Read/Write 0x00000000
0xF8 Features Register FEATURES Read-only -(2)
0xFC Version Register VERSION Read-only -(2)
660
32142D–06/2013
ATUC64/128/256L3/4U
Notes: 1. Read-only if CMRn.WAVE is zero.
2. The reset values are device specific. Please refer to the Module Configuration section at the
end of this chapter.
661
32142D–06/2013
ATUC64/128/256L3/4U
26.7.1 Channel Control Register
Name: CCR
Access Type: Write-only
Offset: 0x00 + n * 0x40
Reset Value: 0x00000000
• SWTRG: Software Trigger Command
1: Writing a one to this bit will perform a software trigger: the counter is reset and the clock is started.
0: Writing a zero to this bit has no effect.
• CLKDIS: Counter Clock Disable Command
1: Writing a one to this bit will disable the clock.
0: Writing a zero to this bit has no effect.
• CLKEN: Counter Clock Enable Command
1: Writing a one to this bit will enable the clock if CLKDIS is not one.
0: Writing a zero to this bit has no effect.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
--------
76543210
- - - - - SWTRG CLKDIS CLKEN
662
32142D–06/2013
ATUC64/128/256L3/4U
26.7.2 Channel Mode Register: Capture Mode
Name: CMR
Access Type: Read/Write
Offset: 0x04 + n * 0x40
Reset Value: 0x00000000
• LDRB: RB Loading Selection
• LDRA: RA Loading Selection
• WAVE
1: Capture mode is disabled (Waveform mode is enabled).
0: Capture mode is enabled.
• CPCTRG: RC Compare Trigger Enable
1: RC Compare resets the counter and starts the counter clock.
0: RC Compare has no effect on the counter and its clock.
• ABETRG: TIOA or TIOB External Trigger Selection
1: TIOA is used as an external trigger.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
- - - - LDRB LDRA
15 14 13 12 11 10 9 8
WAVE CPCTRG - - - ABETRG ETRGEDG
76543210
LDBDIS LDBSTOP BURST CLKI TCCLKS
LDRB Edge
0 none
1 rising edge of TIOA
2 falling edge of TIOA
3 each edge of TIOA
LDRA Edge
0 none
1 rising edge of TIOA
2 falling edge of TIOA
3 each edge of TIOA
663
32142D–06/2013
ATUC64/128/256L3/4U
0: TIOB is used as an external trigger.
• ETRGEDG: External Trigger Edge Selection
• LDBDIS: Counter Clock Disable with RB Loading
1: Counter clock is disabled when RB loading occurs.
0: Counter clock is not disabled when RB loading occurs.
• LDBSTOP: Counter Clock Stopped with RB Loading
1: Counter clock is stopped when RB loading occurs.
0: Counter clock is not stopped when RB loading occurs.
• BURST: Burst Signal Selection
• CLKI: Clock Invert
1: The counter is incremented on falling edge of the clock.
0: The counter is incremented on rising edge of the clock.
• TCCLKS: Clock Selection
ETRGEDG Edge
0 none
1 rising edge
2 falling edge
3 each edge
BURST Burst Signal Selection
0 The clock is not gated by an external signal
1 XC0 is ANDed with the selected clock
2 XC1 is ANDed with the selected clock
3 XC2 is ANDed with the selected clock
TCCLKS Clock Selected
0 TIMER_CLOCK1
1 TIMER_CLOCK2
2 TIMER_CLOCK3
3 TIMER_CLOCK4
4 TIMER_CLOCK5
5 XC0
6 XC1
7 XC2
664
32142D–06/2013
ATUC64/128/256L3/4U
26.7.3 Channel Mode Register: Waveform Mode
Name: CMR
Access Type: Read/Write
Offset: 0x04 + n * 0x40
Reset Value: 0x00000000
• BSWTRG: Software Trigger Effect on TIOB
• BEEVT: External Event Effect on TIOB
31 30 29 28 27 26 25 24
BSWTRG BEEVT BCPC BCPB
23 22 21 20 19 18 17 16
ASWTRG AEEVT ACPC ACPA
15 14 13 12 11 10 9 8
WAVE WAVSEL ENETRG EEVT EEVTEDG
76543210
CPCDIS CPCSTOP BURST CLKI TCCLKS
BSWTRG Effect
0 none
1 set
2 clear
3 toggle
BEEVT Effect
0 none
1 set
2 clear
3 toggle
665
32142D–06/2013
ATUC64/128/256L3/4U
• BCPC: RC Compare Effect on TIOB
• BCPB: RB Compare Effect on TIOB
• ASWTRG: Software Trigger Effect on TIOA
• AEEVT: External Event Effect on TIOA
• ACPC: RC Compare Effect on TIOA
BCPC Effect
0 none
1 set
2 clear
3 toggle
BCPB Effect
0 none
1 set
2 clear
3 toggle
ASWTRG Effect
0 none
1 set
2 clear
3 toggle
AEEVT Effect
0 none
1 set
2 clear
3 toggle
ACPC Effect
0 none
1 set
2 clear
3 toggle
666
32142D–06/2013
ATUC64/128/256L3/4U
• ACPA: RA Compare Effect on TIOA
• WAVE
1: Waveform mode is enabled.
0: Waveform mode is disabled (Capture mode is enabled).
• WAVSEL: Waveform Selection
• ENETRG: External Event Trigger Enable
1: The external event resets the counter and starts the counter clock.
0: The external event has no effect on the counter and its clock. In this case, the selected external event only controls the TIOA
output.
• EEVT: External Event Selection
Note: 1. If TIOB is chosen as the external event signal, it is configured as an input and no longer generates waveforms and subsequently
no IRQs.
• EEVTEDG: External Event Edge Selection
• CPCDIS: Counter Clock Disable with RC Compare
1: Counter clock is disabled when counter reaches RC.
0: Counter clock is not disabled when counter reaches RC.
ACPA Effect
0 none
1 set
2 clear
3 toggle
WAVSEL Effect
0 UP mode without automatic trigger on RC Compare
1 UPDOWN mode without automatic trigger on RC Compare
2 UP mode with automatic trigger on RC Compare
3 UPDOWN mode with automatic trigger on RC Compare
EEVT Signal selected as external event TIOB Direction
0 TIOB input(1)
1 XC0 output
2 XC1 output
3 XC2 output
EEVTEDG Edge
0 none
1 rising edge
2 falling edge
3 each edge
667
32142D–06/2013
ATUC64/128/256L3/4U
• CPCSTOP: Counter Clock Stopped with RC Compare
1: Counter clock is stopped when counter reaches RC.
0: Counter clock is not stopped when counter reaches RC.
• BURST: Burst Signal Selection
• CLKI: Clock Invert
1: Counter is incremented on falling edge of the clock.
0: Counter is incremented on rising edge of the clock.
• TCCLKS: Clock Selection
BURST Burst Signal Selection
0 The clock is not gated by an external signal.
1 XC0 is ANDed with the selected clock.
2 XC1 is ANDed with the selected clock.
3 XC2 is ANDed with the selected clock.
TCCLKS Clock Selected
0 TIMER_CLOCK1
1 TIMER_CLOCK2
2 TIMER_CLOCK3
3 TIMER_CLOCK4
4 TIMER_CLOCK5
5 XC0
6 XC1
7 XC2
668
32142D–06/2013
ATUC64/128/256L3/4U
26.7.4 Channel Counter Value Register
Name: CV
Access Type: Read-only
Offset: 0x10 + n * 0x40
Reset Value: 0x00000000
• CV: Counter Value
CV contains the counter value in real time.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
CV[15:8]
76543210
CV[7:0]
669
32142D–06/2013
ATUC64/128/256L3/4U
26.7.5 Channel Register A
Name: RA
Access Type: Read-only if CMRn.WAVE = 0, Read/Write if CMRn.WAVE = 1
Offset: 0x14 + n * 0X40
Reset Value: 0x00000000
• RA: Register A
RA contains the Register A value in real time.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
RA[15:8]
76543210
RA[7:0]
670
32142D–06/2013
ATUC64/128/256L3/4U
26.7.6 Channel Register B
Name: RB
Access Type: Read-only if CMRn.WAVE = 0, Read/Write if CMRn.WAVE = 1
Offset: 0x18 + n * 0x40
Reset Value: 0x00000000
• RB: Register B
RB contains the Register B value in real time.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
RB[15:8]
76543210
RB[7:0]
671
32142D–06/2013
ATUC64/128/256L3/4U
26.7.7 Channel Register C
Name: RC
Access Type: Read/Write
Offset: 0x1C + n * 0x40
Reset Value: 0x00000000
• RC: Register C
RC contains the Register C value in real time.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
RC[15:8]
76543210
RC[7:0]
672
32142D–06/2013
ATUC64/128/256L3/4U
26.7.8 Channel Status Register
Name: SR
Access Type: Read-only
Offset: 0x20 + n * 0x40
Reset Value: 0x00000000
Note: Reading the Status Register will also clear the interrupt bit for the corresponding interrupts.
• MTIOB: TIOB Mirror
1: TIOB is high. If CMRn.WAVE is zero, this means that TIOB pin is high. If CMRn.WAVE is one, this means that TIOB is driven
high.
0: TIOB is low. If CMRn.WAVE is zero, this means that TIOB pin is low. If CMRn.WAVE is one, this means that TIOB is driven
low.
• MTIOA: TIOA Mirror
1: TIOA is high. If CMRn.WAVE is zero, this means that TIOA pin is high. If CMRn.WAVE is one, this means that TIOA is driven
high.
0: TIOA is low. If CMRn.WAVE is zero, this means that TIOA pin is low. If CMRn.WAVE is one, this means that TIOA is driven
low.
• CLKSTA: Clock Enabling Status
1: This bit is set when the clock is enabled.
0: This bit is cleared when the clock is disabled.
• ETRGS: External Trigger Status
1: This bit is set when an external trigger has occurred.
0: This bit is cleared when the SR register is read.
• LDRBS: RB Loading Status
1: This bit is set when an RB Load has occurred and CMRn.WAVE is zero.
0: This bit is cleared when the SR register is read.
• LDRAS: RA Loading Status
1: This bit is set when an RA Load has occurred and CMRn.WAVE is zero.
0: This bit is cleared when the SR register is read.
• CPCS: RC Compare Status
1: This bit is set when an RC Compare has occurred.
0: This bit is cleared when the SR register is read.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
- - - - - MTIOB MTIOA CLKSTA
15 14 13 12 11 10 9 8
--------
76543210
ETRGS LDRBS LDRAS CPCS CPBS CPAS LOVRS COVFS
673
32142D–06/2013
ATUC64/128/256L3/4U
• CPBS: RB Compare Status
1: This bit is set when an RB Compare has occurred and CMRn.WAVE is one.
0: This bit is cleared when the SR register is read.
• CPAS: RA Compare Status
1: This bit is set when an RA Compare has occurred and CMRn.WAVE is one.
0: This bit is cleared when the SR register is read.
• LOVRS: Load Overrun Status
1: This bit is set when RA or RB have been loaded at least twice without any read of the corresponding register and
CMRn.WAVE is zero.
0: This bit is cleared when the SR register is read.
• COVFS: Counter Overflow Status
1: This bit is set when a counter overflow has occurred.
0: This bit is cleared when the SR register is read.
674
32142D–06/2013
ATUC64/128/256L3/4U
26.7.9 Channel Interrupt Enable Register
Name: IER
Access Type: Write-only
Offset: 0x24 + n * 0x40
Reset Value: 0x00000000
Writing a zero to a bit in this register has no effect.
Writing a one to a bit in this register will set the corresponding bit in IMR.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
--------
76543210
ETRGS LDRBS LDRAS CPCS CPBS CPAS LOVRS COVFS
675
32142D–06/2013
ATUC64/128/256L3/4U
26.7.10 Channel Interrupt Disable Register
Name: IDR
Access Type: Write-only
Offset: 0x28 + n * 0x40
Reset Value: 0x00000000
Writing a zero to a bit in this register has no effect.
Writing a one to a bit in this register will clear the corresponding bit in IMR.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
--------
76543210
ETRGS LDRBS LDRAS CPCS CPBS CPAS LOVRS COVFS
676
32142D–06/2013
ATUC64/128/256L3/4U
26.7.11 Channel Interrupt Mask Register
Name: IMR
Access Type: Read-only
Offset: 0x2C + n * 0x40
Reset Value: 0x00000000
0: The corresponding interrupt is disabled.
1: The corresponding interrupt is enabled.
A bit in this register is cleared when the corresponding bit in IDR is written to one.
A bit in this register is set when the corresponding bit in IER is written to one.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
--------
76543210
ETRGS LDRBS LDRAS CPCS CPBS CPAS LOVRS COVFS
677
32142D–06/2013
ATUC64/128/256L3/4U
26.7.12 Block Control Register
Name: BCR
Access Type: Write-only
Offset: 0xC0
Reset Value: 0x00000000
• SYNC: Synchro Command
1: Writing a one to this bit asserts the SYNC signal which generates a software trigger simultaneously for each of the channels.
0: Writing a zero to this bit has no effect.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
--------
76543210
- - - - - - - SYNC
678
32142D–06/2013
ATUC64/128/256L3/4U
26.7.13 Block Mode Register
Name: BMR
Access Type: Read/Write
Offset: 0xC4
Reset Value: 0x00000000
• TC2XC2S: External Clock Signal 2 Selection
• TC1XC1S: External Clock Signal 1 Selection
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
--------
76543210
- - TC2XC2S TC1XC1S TC0XC0S
TC2XC2S Signal Connected to XC2
0 TCLK2
1 none
2 TIOA0
3 TIOA1
TC1XC1S Signal Connected to XC1
0 TCLK1
1 none
2 TIOA0
3 TIOA2
679
32142D–06/2013
ATUC64/128/256L3/4U
• TC0XC0S: External Clock Signal 0 Selection
TC0XC0S Signal Connected to XC0
0 TCLK0
1 none
2 TIOA1
3 TIOA2
680
32142D–06/2013
ATUC64/128/256L3/4U
26.7.14 Features Register
Name: FEATURES
Access Type: Read-only
Offset: 0xF8
Reset Value: -
• BRPBHSB: Bridge type is PB to HSB
1: Bridge type is PB to HSB.
0: Bridge type is not PB to HSB.
• UPDNIMPL: Up/down is implemented
1: Up/down counter capability is implemented.
0: Up/down counter capability is not implemented.
• CTRSIZE: Counter size
This field indicates the size of the counter in bits.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
-------
15 14 13 12 11 10 9 8
- - - - - - BRPBHSB UPDNIMPL
76543210
CTRSIZE
681
32142D–06/2013
ATUC64/128/256L3/4U
26.7.15 Version Register
Name: VERSION
Access Type: Read-only
Offset: 0xFC
Reset Value: -
• VARIANT: Variant number
Reserved. No functionality associated.
• VERSION: Version number
Version number of the module. No functionality associated.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
- - - - VARIANT
15 14 13 12 11 10 9 8
- - - - VERSION[11:8]
76543210
VERSION[7:0]
682
32142D–06/2013
ATUC64/128/256L3/4U
26.8 Module Configuration
The specific configuration for each Timer/Counter instance is listed in the following tables.The
module bus clocks listed here are connected to the system bus clocks. Please refer to the Power
Manager chapter for details.
26.8.1 Clock Connections
There are two Timer/Counter modules, TC0 and TC1, with three channels each, giving a total of
six Timer/Counter channels. Each Timer/Counter channel can independently select an internal
or external clock source for its counter:
Table 26-4. TC Bus Interface Clocks
Module name Clock Name Description
TC0 CLK_TC0 Clock for the TC0 bus interface
TC1 CLK_TC1 Clock for the TC1 bus interface
Table 26-5. Timer/Counter Clock Connections
Module Source Name Connection
TC0 Internal TIMER_CLOCK1 32 KHz oscillator clock (CLK_32K)
TIMER_CLOCK2 PBA Clock / 2
TIMER_CLOCK3 PBA Clock / 8
TIMER_CLOCK4 PBA Clock / 32
TIMER_CLOCK5 PBA Clock / 128
External XC0 See Section on page 10
XC1
XC2
TC1 Internal TIMER_CLOCK1 32 KHz oscillator clock (CLK_32K)
TIMER_CLOCK2 PBA Clock / 2
TIMER_CLOCK3 PBA Clock / 8
TIMER_CLOCK4 PBA Clock / 32
TIMER_CLOCK5 PBA Clock / 128
External XC0 See Section on page 10
XC1
XC2
683
32142D–06/2013
ATUC64/128/256L3/4U
27. Peripheral Event System
Rev: 1.0.0.1
27.1 Features
• Direct peripheral to peripheral communication system
• Allows peripherals to receive, react to, and send peripheral events without CPU intervention
• Cycle deterministic event communication
• Asynchronous interrupts allow advanced peripheral operation in low power sleep modes
27.2 Overview
Several peripheral modules can be configured to emit or respond to signals known as peripheral
events. The exact condition to trigger a peripheral event, or the action taken upon receiving a
peripheral event, is specific to each module. Peripherals that respond to peripheral events are
called peripheral event users and peripherals that emit peripheral events are called peripheral
event generators. A single module can be both a peripheral event generator and user.
The peripheral event generators and users are interconnected by a network known as the
Peripheral Event System. This allows low latency peripheral-to-peripheral signaling without CPU
intervention, and without consuming system resources such as bus or RAM bandwidth. This
offloads the CPU and system resources compared to a traditional interrupt-based software
driven system.
27.3 Peripheral Event System Block Diagram
Figure 27-1. Peripheral Event System Block Diagram
27.4 Functional Description
27.4.1 Configuration
The Peripheral Event System in the ATUC64/128/256L3/4U has a fixed mapping of peripheral
events between generators and users, as described in Table 27-1 to Table 27-4. Thus, the user
does not need to configure the interconnection between the modules, although each peripheral
event can be enabled or disabled at the generator or user side as described in the peripheral
chapter for each module.
Peripheral
Event
System
Generator
Generator
User
Generator/
User
684
32142D–06/2013
ATUC64/128/256L3/4U
Table 27-1. Peripheral Event Mapping from ACIFB to PWMA
Generator Generated Event User Effect Asynchronous
ACIFB channel 0
AC0 VINP > AC0 VINN PWMA channel 0
PWMA duty cycle value increased by one
No
AC0 VINN > AC0 VINP PWMA duty cycle value decreased by one
ACIFB channel 1
AC1 VINP > AC1 VINN PWMA channel 6
PWMA duty cycle value increased by one
AC1 VINN > AC1 VINP PWMA duty cycle value decreased by one
ACIFB channel 2
AC2 VINP > AC2 VINN PWMA channel 8
PWMA duty cycle value increased by one
AC2 VINN > AC2 VINP PWMA duty cycle value decreased by one
ACIFB channel 3
AC3 VINP > AC3 VINN PWMA channel 9
PWMA duty cycle value increased by one
AC3 VINN > AC3 VINP PWMA duty cycle value decreased by one
ACIFB channel 4
AC4 VINP > AC4 VINN PWMA channel 11
PWMA duty cycle value increased by one
AC4 VINN > AC4 VINP PWMA duty cycle value decreased by one
ACIFB channel 5
AC5 VINP > AC5 VINN PWMA channel 14
PWMA duty cycle value increased by one
AC5 VINN > AC5 VINP PWMA duty cycle value decreased by one
ACIFB channel 6
AC6 VINP > AC6 VINN PWMA channel 19
PWMA duty cycle value increased by one
AC6 VINN > AC6 VINP PWMA duty cycle value decreased by one
ACIFB channel 7
AC7 VINP > AC7 VINN PWMA channel 20
PWMA duty cycle value increased by one
AC7 VINN > AC7 VINP PWMA duty cycle value decreased by one
ACIFB channel n ACn VINN > ACn VINP CAT Automatically used by the CAT when
performing QMatrix acquisition. No
Table 27-2. Peripheral Event Mapping from GPIO to TC
Generator Generated Event User Effect Asynchronous
GPIO
Pin change on PA00-PA07
TC0
A0 capture
No
Pin change on PA08-PA15 A1 capture
Pin change on PA16-PA23 A2 capture
Pin change on PB00-PB07 TC1
A1 capture
Pin change on PB08-PB15 A2 capture
685
32142D–06/2013
ATUC64/128/256L3/4U
27.4.2 Peripheral Event Connections
Each generated peripheral event is connected to one or more users. If a peripheral event is connected
to multiple users, the peripheral event can trigger actions in multiple modules.
A peripheral event user can likewise be connected to one or more peripheral event generators. If
a peripheral event user is connected to multiple generators, the peripheral events are OR’ed
together to a single peripheral event. This means that peripheral events from either one of the
generators will result in a peripheral event to the user.
To configure a peripheral event, the peripheral event must be enabled at both the generator and
user side. Even if a generator is connected to multiple users, only the users with the peripheral
event enabled will trigger on the peripheral event.
27.4.3 Low Power Operation
As the peripheral events do not require CPU intervention, they are available in Idle mode. They
are also available in deeper sleep modes if both the generator and user remain clocked in that
mode.
Certain events are known as asynchronous peripheral events, as identified in Table 27-1 to
Table 27-4. These can be issued even when the system clock is stopped, and revive unclocked
user peripherals. The clock will be restarted for this module only, without waking the system from
sleep mode. The clock remains active only as long as required by the triggered function, before
being switched off again, and the system remains in the original sleep mode. The CPU and sysTable
27-3. Peripheral Event Mapping from AST
Generator Generated Event User Effect Asynchronous
AST
Overflow event
ACIFB
Comparison is triggered if the ACIFB.CONFn
register is written to 11 (Event Triggered Single
Measurement Mode) and the EVENTEN bit in
the ACIFB.CTRL register is written to 1.
Yes
Periodic event
Alarm event
Overflow event
ADCIFB
Conversion is triggered if the TRGMOD bit in
the ADCIFB.TRGR register is written to 111
(Peripheral Event Trigger).
Periodic event
Alarm event
Overflow event
CAT Trigger one iteration of autonomous touch
detection. Periodic event
Alarm event
Table 27-4. Peripheral Event Mapping from PWMA
Generator Generated Event User Effect Asynchronous
PWMA channel 0
Timebase counter
reaches the duty cycle
value.
ACIFB
Comparison is triggered if the ACIFB.CONFn
register is written to 11 (Event Triggered Single
Measurement Mode) and the EVENTEN bit in
the ACIFB.CTRL register is written to 1. No
ADCIFB
Conversion is triggered if the TRGMOD bit in
the ADCIFB.TRGR register is written to 111
(Peripheral Event Trigger).
686
32142D–06/2013
ATUC64/128/256L3/4U
tem will only be woken up if the user peripheral generates an interrupt as a result of the
operation. This concept is known as SleepWalking and is described in further detail in the Power
Manager chapter. Note that asynchronous peripheral events may be associated with a delay
due to the need to restart the system clock source if this has been stopped in the sleep mode.
27.5 Application Example
This application example shows how the Peripheral Event System can be used to program the
ADC Interface to perform ADC conversions at selected intervals.
Conversions of the active analog channels are started with a software or a hardware trigger.
One of the possible hardware triggers is a peripheral event trigger, allowing the Peripheral Event
System to synchronize conversion with some configured peripheral event source. From Table
27-3 and Table 27-4, it can be read that this peripheral event source can be either an AST
peripheral event, or an event from the PWM Controller. The AST can generate periodic peripheral
events at selected intervals, among other types of peripheral events. The Peripheral Event
System can then be used to set up the ADC Interface to sample an analog signal at regular
intervals.
The user must enable peripheral events in the AST and in the ADC Interface to accomplish this.
The periodic peripheral event in the AST is enabled by writing a one to the corresponding bit in
the AST Event Enable Register (EVE). To select the peripheral event trigger for the ADC Interface,
the user must write the value 0x7 to the Trigger Mode (TRGMOD) field in the ADC
Interface Trigger Register (TRGR). When the peripheral events are enabled, the AST will generate
peripheral events at the selected intervals, and the Peripheral Event System will route the
peripheral events to the ADC Interface, which will perform ADC conversions at the selected
intervals.
Figure 27-2. Application Example
Since the AST peripheral event is asynchronous, the description above will also work in sleep
modes where the ADC clock is stopped. In this case, the ADC clock (and clock source, if
needed) will be restarted during the ADC conversion. After the conversion, the ADC clock and
clock source will return to the sleep state, unless the ADC generates an interrupt, which in turn
will wake up the system. Using asynchronous interrupts thus allows ADC operation in much
lower power states than would otherwise be possible.
Peripheral
Event
System
AST ADC
Interface
Trigger
conversion
Periodic peripheral
event
687
32142D–06/2013
ATUC64/128/256L3/4U
28. Audio Bit Stream DAC (ABDACB)
Rev.: 1.0.0.0
28.1 Features
• 16 bit digital stereo DAC
• Oversampling D/A conversion architecture
– Adjustable oversampling ratio
– 3rd order Sigma-Delta D/A converters
• Digital bitstream output
• Parallel interface
• Connects to DMA for background transfer without CPU intervention
• Supported sampling frequencies
– 8000Hz, 11025Hz, 12000Hz, 16000Hz, 22050Hz, 24000Hz, 32000Hz, 44100Hz, and 48000Hz
• Supported data formats
– 32-, 24-, 20-, 18-, 16-, and 8-bit stereo format
– 16- and 8-bit compact stereo format, with left and right sample packed in the same word to
reduce data transfers
• Common mode offset control
• Volume control
28.2 Overview
The Audio Bitstream DAC (ABDACB) converts a 16-bit sample value to a digital bitstream with
an average value proportional to the sample value. Two channels are supported making the
Audio Bitstream DAC particularly suitable for stereo audio. Each channel has a pair of complementary
digital outputs, DAC and DACN, which can be connected to an external high input
impedance amplifier.
The Audio Bitstream DAC is made up of several signal processing blocks and a 3rd order Sigma
Delta D/A converter for each channel. The Sigma Delta modulator converts the parallel data to a
bitstream, while the signal processing blocks perform volume control, offset control, upsampling,
and filtering to compensate for the upsampling process. The upsampling is performed by a Cascaded
Integrator-Comb (CIC) filter, and the compensation filter is a Finite Impulse Response
(FIR) CIC compensation filter.
28.3 Block Diagram
Figure 28-1. ABDACB Block Diagram
User Inter af ce
Synchronizer
Volume control
Offset control
CIC Compensation
filter (FIR)
CIC
Comb
Section
CIC Integrator
section
Clock
divider
Sigma Delta
Modulator
Sigma Delta
Modulator
clk_abdacb gclk
Signal processing
(before up-sampling)
CLK
DAC[0]
DACN[0]
DAC[1]
DACN[1]
PB
688
32142D–06/2013
ATUC64/128/256L3/4U
28.4 I/O Lines Description
28.5 Product Dependencies
In order to use this module, other parts of the system must be configured correctly, as described
below.
28.5.1 I/O lines
The output pins used for the output bitstream from the Audio Bitstream DAC may be multiplexed
with I/O Controller lines.
Before using the Audio Bitstream DAC, the I/O Controller must be configured in order for the
Audio Bitstream DAC I/O lines to be in Audio Bitstream DAC peripheral mode.
28.5.2 Clocks
The clock for the ABDACB bus interface (CLK_ABDACB) is generated by the Power Manager.
This clock is turned on by default, and can be enabled and disabled in the Power Manager. It is
recommended to disable the ABDACB before disabling the clock, to avoid freezing the ABDACB
in an undefined state. Before using the Audio Bitstream DAC, the user must ensure that the
Audio Bitstream DAC clock is enabled in the Power Manager.
The Audio Bitstream DAC requires a separate clock for the D/A conversion. This clock is provided
by a generic clock which has to be set up in the System Control Interface (SCIF). The
frequency for this clock has to be set as described in Table 28-3 on page 697. It is important that
this clock is accurate and has low jitter. Incorrect frequency will result in too fast or too slow playback
(frequency shift), and too high jitter will add noise to the D/A conversion. For best
performance one should trade frequency accuracy (within some limits) for low jitter to obtain the
best performance as jitter will have large impact on the quality of the converted signal.
28.5.3 DMA
The ABDACB is connected to the Peripheral DMA controller. Using DMA to transfer data samples
requires the Peripheral DMA controller to be programmed before enabling the ABDACB.
28.5.4 Interrupts
The ABDACB interrupt request line is connected to the interrupt controller. Using the ABDACB
interrupt requires the interrupt controller to be programmed first.
Table 28-1. I/O Lines Description
Pin Name Pin Description Type
DAC[0] Output for channel 0 Output
DACN[0] Inverted output for channel 0 Output
DAC[1] Output for channel 1 Output
DACN[1] Inverted output for channel 1 Output
CLK Clock output for DAC Output
689
32142D–06/2013
ATUC64/128/256L3/4U
28.6 Functional Description
28.6.1 Construction
The Audio Bitstream DAC is divided into several parts, the user interface, the signal processing
blocks, and the Sigma Delta modulator blocks. See Figure 28-1 on page 687. The user interface
is used to configure the signal processing blocks and to input new data samples to the converter.The
signal processing blocks manages volume control, offset control, and upsampling.
The Sigma Delta blocks converts the parallel data to1-bit bitstreams.
28.6.1.1 CIC Interpolation Filter
The interpolation filter in the system is a Cascaded Integrator-Comb (CIC) interpolation filter
which interpolates from Fs to {125, 128, 136}xFs depending on the control settings. This filter is a
4th order CIC filter, and the basic building blocks of the filter is a comb part and an integrator
part. Since the CIC interpolator has a sinc-function frequency response it is compensated by a
linear phase CIC compensation filter to make the passband response more flat in the range 0-
20kHz, see figure Figure 28-4 on page 693. The frequency response of this type of interpolator
has the first zero at the input sampling frequency. This means that the first repeated specters
created by the upsampling process will not be fully rejected and the output signal will contain signals
from these repeated specters. See Figure 28-6 on page 694.
Since the human ear can not hear frequencies above 20kHz, we should not be affected by this
when the sample rate is above 40kHz, but digital measurement equipment will be affected. This
need to be accounted for when doing measurements on the system to prevent aliasing and
incorrect measurement results.
28.6.1.2 Sigma Delta Modulator
The Sigma Delta modulator is a 3rd order modulator consisting of three differentiators (delta
blocks), three integrators (sigma blocks), and a one bit quantizer. The purpose of the integrators
is to shape the noise, so that the noise is reduced in the audio passband and increased at the
higher frequencies, where it can be filtered out by an analog low-pass filter. To be able to filter
out all the noise at high frequencies the analog low-pass filter must be one order larger than the
Sigma Delta modulator.
28.6.1.3 Recreating the Analog Signal
Since the DAC and DACN outputs from the ABDAC are digital square wave signals, they have
to be passed through a low pass filter to recreate the analog signal. This also means that noise
on the IO voltage will couple through to the analog signal. To remove some of the IO noise the
ABDAC can output a clock signal, CLK, which can be used to resample the DAC and DACN signals
on external Flip-Flops powered by a clean supply.
28.6.2 Initialization
Before enabling the ABDACB the correct configuration must be applied to the Control Register
(CR). Configuring the Alternative Upsampling Ratio bit (CR.ALTUPR), Common Mode Offset
Control bit (CR.CMOC), and the Sampling Frequency field (CR.FS) according to the sampling
rate of the data that is converted and the type of amplifier the outputs are connected to is
required to get the correct behavior of the system. When the correct configuration is applied the
ABDACB can be enabled by writing a one to the Enable bit in the Control Register (CR.EN). The
module is disabled by writing a zero to the Enable bit. The module should be disabled before
entering sleep modes to ensure that the outputs are not left in an undesired state.
690
32142D–06/2013
ATUC64/128/256L3/4U
28.6.3 Basic operation
To convert audio data to a digital bitstream the user must first initialize the ABDACB as
described in Section 28.6.2. When the ABDACB is initialized and enabled it will indicate that it is
ready to receive new data by setting the Transmit Ready bit in the Status Register (SR.TXRDY).
When the TXRDY bit is set in the Status Register the user has to write new samples to Sample
Data Register 0 (SDR0) and Sample Data Register 1 (SDR1). If the Mono Mode (MONO) bit in
the Control Register (CR) is set, or one of the compact stereo formats are used by configuring
the Data Word Format (DATAFORMAT) in the Control Register, only SDR0 has to be written.
Failing to write to the sample data registers will result in an underrun indicated by the Transmit
Underrun (TXUR) bit in the Status Register (SR.TXUR). When new samples are written to the
sample data registers the TXRDY bit will be cleared.
To increase performance of the system an interrupt handler or DMA transfer can be used to
write new samples to the sample data registers. See Section 28.6.10 for details on DMA, and
Section 28.6.11 for details on interrupt.
28.6.4 Data Format
The input data type is two’s complement. The Audio Bitstream DAC can be configured to accept
different audio formats. The format must be configured in the Data Word Format field in the Control
Register. In regular operation data for the two channels are written to the sample data
registers SDR0 and SDR1. If the data format field specifies a format using less than 32 bits, data
must be written right-justified in SDR0 and SDR1. Sign extension into the unused bits is not necessary.
Only the 16 most significant bits in the data will be used by the ABDACB. For data
formats larger than 16 bits the least significant bits are ignored. For 8-bit data formats the 8 bits
will be used as the most significant bits in the 16-bit samples, the additional bits will be zeros.
The ABDACB also supports compact data formats for 16- and 8-bit samples. For 16-bit samples
the sample for channel 0 must be written to bits 15 through 0 and the sample for channel 1 must
be written to bits 31 through 16 in SDR0. For 8-bit samples the sample for channel 0 must be
written to bits 7 through 0 and the sample for channel 1 must be written to bits 15 through 8 in
SDR0. SDR1 is not used in this mode. See Table 28-5 on page 699.
28.6.5 Data Swapping
When the Swap Channels (SWAP) bit in the Control Register (CR.SWAP) is one, writing to the
Sample Data Register 0 (SDR0) will put the data in Sample Data Register 1 (SDR1). Writing
SDR1 will put the data in SDR0. If one of the two compact stereo formats is used the lower and
upper halfword of SDR0 will be swapped when writing to SDR0.
28.6.6 Common Mode Offset Control
When the Common Mode Offset Control (CMOC) bit in the Control Register is one the input data
will get a DC value applied to it and the amplitude will be scaled. This will make the common
mode offset of the two corresponding outputs, DAC and DACN, to move away from each other
so that the output signals are not overlapping. The result is that the two signals can be applied to
a differential analog filter, and the difference will always be a positive value, removing the need
for a negative voltage supply for the filter. The cost of doing this a 3dB loss in dynamic range. On
the left side of Figure 28-2 one can see the filtered output from the DAC and DACN pins when a
sine wave is played when CR.CMOC is zero. The waveform on the right side shows the output
of the differential filter when the two outputs on the left side are used as inputs to the differential
filter. Figure 28-3 show the corresponding outputs when CR.CMOC is one.
691
32142D–06/2013
ATUC64/128/256L3/4U
Figure 28-2. Output signals with CMOC=0
Figure 28-3. Output signals with CMOC=1
28.6.7 Volume Control
The Audio Bitstream DAC have two volume control registers, Volume Control Register 0 (VCR0)
and Volume Control Register 1 (VCR1), that can be used to adjust the volume for the corresponding
channel. The volume control is linear and will only scale each sample according to the
value in the Volume Control (VOLUME) field in the volume control registers. The register also
has a Mute bit (MUTE) which can be used to mute the corresponding channel. The filtered out-
692
32142D–06/2013
ATUC64/128/256L3/4U
put of the DAC pins will have a voltage given by the following equation, given that it is configured
to run at the default upsampling ratio of 128:
If one want to get coherence between the sign of the input data and the output voltage one can
use the DATAN outputs or invert the sign of the input data by software.
28.6.8 Mono
When the Mono bit (MONO) in the Control Register is set, data written to SDR0 will be used for
both output channels. If one of the compact stereo formats are used only the data written to the
part of SDR0 that corresponds with channel 0 is used.
28.6.9 Alternative Upsampling Ratio
The digital filters and Sigma Delta modulators requires its own clock to perform the conversion at
the correct speed, and this clock is provided by a generic clock in the SCIF. The frequency of
this clock depends on the input sample rate and the upsampling ratio which is controlled by the
Alternative Upsampling Ratio bit (ALTUPR) in the Control Register.
The ABDACB supports three upsampling ratios, 125, 128, and 136. The default setting is a ratio
of 128, and is used when CR.ALTUPR is zero. Using this ratio gives a clock frequency requirement
that is common for audio products. In some cases one may want to use other clock
frequencies that already are available in the system. By writing a one to CR.ALTUPR a upsampling
ratio of 125 or 136 is used depending on the configuration of the Sampling Frequency field
in the Control Register. Refer to Table 28-3 for required clock frequency and settings.
The required clock frequency of the generic clock can be calculated from the following equation:
R is the upsampling ratio of the converter. If CR.ALTUPR is zero the upsampling ratio is 128. If
CR.ALTUPR is one, R will change to 125 when CR.FS is configured for 8kHz, 12kHz, 16kHz,
24kHz, 32kHz, and 48kHz. For the other configurations of CR.FS, 11.025kHz, 22.050kHz, and
44.100kHz, it will change to 136.
28.6.10 DMA operation
The Audio Bitstream DAC is connected to the Peripheral DMA Controller. The Peripheral DMA
Controller can be programmed to automatically transfer samples to the Sample Data Registers
(SDR0 and SDR1) when the Audio Bitstream DAC is ready for new samples. Two DMA channels
are used, one for each sample data register. If the Mono Mode bit in the Control Register
(CR.MONO) is one, or one of the compact stereo formats is used, only the DMA channel connected
to SDR0 will be used. When using DMA only the Control Register needs to be written in
the Audio Bitstream DAC. This enables the Audio Bitstream DAC to operate without any CPU
intervention such as polling the Status Register (SR) or using interrupts. See the Peripheral
DMA Controller documentation for details on how to setup Peripheral DMA transfers.
28.6.11 Interrupts
The ABDACB requires new data samples at a rate of FS. The interrupt status bits are used to
indicate when the system is ready to receive new samples. The Transmit Ready Interrupt Status
bit in the Status Register (SR.TXRDY) will be set whenever the ABDACB is ready to receive a
new sample. A new sample value must be written to the sample data registers (SDR0 and
VOUT
1
2
-- 33
128 – --------- SDR
215 ------------ VOLUME
215 – 1
------------------------ VVDDIO =
GCLK[Hz] F = S R 8
693
32142D–06/2013
ATUC64/128/256L3/4U
SDR1) before 1/FS second, or an underrun will occur, as indicated by the Underrun Interrupt bit
in SR (SR.TXUR). The interrupt bits in SR are cleared by writing a one to the corresponding bit
in the Status Clear Register (SCR).
28.6.12 Frequency Response
Figure Figure 28-4 to Figure 28-7 show the frequency response for the system. The sampling
frequency used is 48kHz, but the response will be the same for other sampling frequencies,
always having the first zero at FS.
Figure 28-4. Passband Frequency Response
694
32142D–06/2013
ATUC64/128/256L3/4U
Figure 28-5. Frequency Response up to Sampling Frequency
Figure 28-6. Frequency Response up to 3x Sampling Frequency
695
32142D–06/2013
ATUC64/128/256L3/4U
Figure 28-7. Frequency Response up to 128x Sampling Frequency
696
32142D–06/2013
ATUC64/128/256L3/4U
28.7 User Interface
Note: 1. The reset values are device specific. Please refer to the Module Configuration section at the end of this chapter.
Table 28-2. ABDACB Register Memory Map
Offset Register Register Name Access Reset
0x00 Control Register CR Read/Write 0x00000000
0x04 Sample Data Register 0 SDR0 Read/Write 0x00000000
0x08 Sample Data Register 1 SDR1 Read/Write 0x00000000
0x0C Volume Control Register 0 VCR0 Read/Write 0x00000000
0x10 Volume Control Register 1 VCR1 Read/Write 0x00000000
0x14 Interrupt Enable Register IER Write-only 0x00000000
0x18 Interrupt Disable Register IDR Write-only 0x00000000
0x1C Interrupt Mask Register IMR Read-only 0x00000000
0x20 Status Register SR Read-only 0x00000000
0x24 Status Clear Register SCR Write-only 0x00000000
0x28 Parameter Register PARAMETER Read-only -
(1)
0x2C Version Register VERSION Read-only -
(1)
697
32142D–06/2013
ATUC64/128/256L3/4U
28.7.1 Control Register
Name: CR
Access Type: Read/Write
Offset: 0x00
Reset Value: 0x00000000
• FS: Sampling Frequency
Must be set to the matching data sampling frequency, see Table 28-3.
Note: 1. The actual clock requirement are 11.9952MHz, 23.9904MHz, and 47.9808MHz, but this is
very close to the suggested clock frequencies, and will only result in a very small frequency
shift. This need to be accounted for during testing if comparing to a reference signal.
Notes: 1.
31 30 29 28 27 26 25 24
- - - - FS
23 22 21 20 19 18 17 16
- - - - - DATAFORMAT
15 14 13 12 11 10 9 8
--------
76543210
SWRST - MONO CMOC ALTUPR - SWAP EN
Table 28-3. Generic Clock Requirements
CR.FS Description GCLK (CR.ALTUPR=1) GCLK (CR.ALTUPR=0)
0 8000Hz sampling frequency 8.0MHz 8.1920MHz
1 11025Hz sampling frequency 12.0MHz(1) 11.2896MHz
2 12000Hz sampling frequency 12.0MHz 12.2880MHz
3 16000Hz sampling frequency 16.0MHz 16.3840MHz
4 22050Hz sampling frequency 24.0MHz(1) 22.5792MHz
5 24000Hz sampling frequency 24.0MHz 24.5760MHz
6 32000Hz sampling frequency 32.0MHz 32.7680MHz
7 44100Hz sampling frequency 48.0MHz(1) 45.1584MHz
8 48000Hz sampling frequency 48.0MHz 49.1520MHz
Other Reserved - -
698
32142D–06/2013
ATUC64/128/256L3/4U
• DATAFORMAT: Data Word Format
• SWRST: Software Reset
Writing a zero to this bit does not have any effect.
Writing a one to this bit will reset the ABDACB as if a hardware reset was done.
• MONO: Mono Mode
0: Mono mode is disabled.
1: Mono mode is enabled.
• CMOC: Common Mode Offset Control
0: Common mode adjustment is disabled.
1: Common mode adjustment is enabled.
• ALTUPR: Alternative Upsampling Ratio
0: Alternative upsampling is disabled.
1: Alternative upsampling is enabled.
• SWAP: Swap Channels
0: Channel swap is disabled.
1: Channel swap is enabled.
• EN: Enable
0: The ABDACB is disabled.
1: The ABDACB is enabled.
Table 28-4. Data Word Format
DATAFORMAT Word length Comment
0 32 bits
1 24 bits
2 20 bits
3 18 bits
4 16 bits
5 16 bits compact stereo Channel 1 sample in bits 31 through 16, channel 0 sample in bits 15 through 0 in SDR0
6 8 bits
7 8 bits compact stereo Channel 1 sample in bits 15 through 8, channel 0 sample in bits 7through 0 in SDR0
699
32142D–06/2013
ATUC64/128/256L3/4U
28.7.2 Sample Data Register 0
Name: SDR0
Access Type: Read/Write
Offset: 0x04
Reset Value: 0x00000000
• DATA: Sample Data
Sample Data for channel 0 in two’s complement format. Data must be right-justified, see Table 28-5.
31 30 29 28 27 26 25 24
DATA[31:24]
23 22 21 20 19 18 17 16
DATA[23:16]
15 14 13 12 11 10 9 8
DATA[15:8]
76543210
DATA[7:0]
Table 28-5. Sample Data Register Formats
Data Format SDR0 SDR1 Comment
32 bits CH0 sample in DATA[31:0] CH1 sample in DATA[31:0]
24 bits CH0 sample in DATA[23:0] CH1 sample in DATA[23:0] Remaining bits are ignored.
20 bits CH0 sample in DATA[19:0] CH1 sample in DATA[19:0] Remaining bits are ignored.
18 bits CH0 sample in DATA[17:0] CH1 sample in DATA[17:0] Remaining bits are ignored.
16 bits CH0 sample in DATA[15:0] CH1 sample in DATA[15:0] Remaining bits are ignored.
16 bits compact stereo CH0 sample in DATA[15:0]
CH1 sample in DATA[31:16] Not used
8 bits CH0 sample in DATA[7:0] CH1 sample in DATA[7:0] Remaining bits are ignored.
8 bits compact stereo CH0 sample in DATA[7:0]
CH1 sample in DATA[15:8] Not used Remaining bits are ignored.
700
32142D–06/2013
ATUC64/128/256L3/4U
28.7.3 Sample Data Register 1
Name: SDR1
Access Type: Read/Write
Offset: 0x08
Reset Value: 0x00000000
• DATA: Sample Data
Sample Data for channel 1 in two’s complement format. Data must be right-justified, see Table 28-5 on page 699.
31 30 29 28 27 26 25 24
DATA[31:24]
23 22 21 20 19 18 17 16
DATA[23:16]
15 14 13 12 11 10 9 8
DATA[15:8]
76543210
DATA[7:0]
701
32142D–06/2013
ATUC64/128/256L3/4U
28.7.4 Volume Control Register 0
Name: VCR0
Access Type: Read/Write
Offset: 0x0C
Reset Value: 0x00000000
• MUTE: Mute
0: Channel 0 is not muted.
1: Channel 0 is muted.
• VOLUME: Volume Control
15-bit value adjusting the volume for channel 0.
31 30 29 28 27 26 25 24
MUTE - - - - - - -
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
- VOLUME[14:8]
76543210
VOLUME[7:0]
702
32142D–06/2013
ATUC64/128/256L3/4U
28.7.5 Volume Control Register 1
Name: VCR1
Access Type: Read/Write
Offset: 0x10
Reset Value: 0x00000000
• MUTE: Mute
0: Channel 1 is not muted.
1: Channel 1 is muted.
• VOLUME: Volume Control
15-bit value adjusting the volume for channel 1.
31 30 29 28 27 26 25 24
MUTE - - - - - - -
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
- VOLUME[14:8]
76543210
VOLUME[7:0]
703
32142D–06/2013
ATUC64/128/256L3/4U
28.7.6 Interrupt Enable Register
Name: IER
Access Type: Write-only
Offset: 0x14
Reset Value: 0x00000000
Writing a zero to a bit in this register has no effect.
Writing a one to a bit in this register will set the corresponding bit in IMR.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
--------
76543210
- - - - - TXUR TXRDY -
704
32142D–06/2013
ATUC64/128/256L3/4U
28.7.7 Interrupt Disable Register
Name: IDR
Access Type: Write-only
Offset: 0x18
Reset Value: 0x00000000
Writing a zero to a bit in this register has no effect.
Writing a one to a bit in this register will clear the corresponding bit in IMR.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
--------
76543210
- - - - - TXUR TXRDY -
705
32142D–06/2013
ATUC64/128/256L3/4U
28.7.8 Interrupt Mask Register
Name: IMR
Access Type: Read-only
Offset: 0x1C
Reset Value: 0x00000000
0: The corresponding interrupt is disabled.
1: The corresponding interrupt is enabled.
A bit in this register is cleared when the corresponding bit in IDR is written to one.
A bit in this register is set when the corresponding bit in IER is written to one.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
--------
76543210
- - - - - TXUR TXRDY -
706
32142D–06/2013
ATUC64/128/256L3/4U
28.7.9 Status Register
Name: SR
Access Type: Read-only
Offset: 0x20
Reset Value: 0x00000000
• TXUR: Transmit Underrun
This bit is cleared when no underrun has occurred since the last time this bit was cleared (by reset or by writing to SCR).
This bit is set when at least one underrun has occurred since the last time this bit was cleared (by reset or by writing to SCR).
• TXRDY: Transmit Ready
This bit is cleared when the ABDACB is not ready to receive a new data in SDR.
This bit is set when the ABDACB is ready to receive a new data in SDR.
• BUSY: ABDACB Busy
This bit is set when the ABDACB is busy doing a data transfer between clock domains. CR, SDR0, and SDR1 can not be written
during this time.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
--------
76543210
- - - - - TXUR TXRDY BUSY
707
32142D–06/2013
ATUC64/128/256L3/4U
28.7.10 Status Clear Register
Name: SCR
Access Type: Write-only
Offset: 0x24
Reset Value: 0x00000000
Writing a zero to a bit in this register has no effect.
Writing a one to a bit in this register will clear the corresponding bit in SR and the corresponding interrupt request.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
--------
76543210
- - - - - TXUR TXRDY -
708
32142D–06/2013
ATUC64/128/256L3/4U
28.7.11 Parameter Register
Name: PARAMETER
Access Type: Read-only
Offset: 0x28
Reset Value: 0x00000000
Reserved. No functionality associated.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
--------
76543210
--------
709
32142D–06/2013
ATUC64/128/256L3/4U
28.7.12 Version Register
Name: VERSION
Access Type: Read-only
Offset: 0x2C
Reset Value: 0x00000000
• VARIANT: Variant Number
Reserved. No functionality associated.
• VERSION: Version Number
Version number of the module. No functionality associated.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
- - - - VARIANT
15 14 13 12 11 10 9 8
- - - - VERSION[11:8]
76543210
VERSION[7:0]
710
32142D–06/2013
ATUC64/128/256L3/4U
28.8 Module Configuration
The specific configuration for each ABDACB instance is listed in the following tables.The module
bus clocks listed here are connected to the system bus clocks. Please refer to the Power Manager
chapter for details.
Table 28-6. ABDACB Clocks
Clock Name Description
CLK_ABDACB Clock for the ABDACB bus interface
GCLK The generic clock used for the ABDACB is GCLK6
Table 28-7. Register Reset Values
Register Reset Value
VERSION 0x00000100
PARAMETER 0x00000000
711
32142D–06/2013
ATUC64/128/256L3/4U
29. ADC Interface (ADCIFB)
Rev:1.0.1.1
29.1 Features
• Multi-channel Analog-to-Digital Converter with up to 12-bit resolution
• Enhanced Resolution Mode
– 11-bit resolution obtained by interpolating 4 samples
– 12-bit resolution obtained by interpolating 16 samples
• Glueless interface with resistive touch screen panel, allowing
– Resistive Touch Screen position measurement
– Pen detection and pen loss detection
• Integrated enhanced sequencer
– ADC Mode
– Resistive Touch Screen Mode
• Numerous trigger sources
– Software
– Embedded 16-bit timer for periodic trigger
– Pen detect trigger
– Continuous trigger
– External trigger, rising, falling, or any-edge trigger
– Peripheral event trigger
• ADC Sleep Mode for low power ADC applications
• Programmable ADC timings
– Programmable ADC clock
– Programmable startup time
29.2 Overview
The ADC Interface (ADCIFB) converts analog input voltages to digital values. The ADCIFB is
based on a Successive Approximation Register (SAR) 10-bit Analog-to-Digital Converter (ADC).
The conversions extend from 0V to ADVREFP.
The ADCIFB supports 8-bit and 10-bit resolution mode, in addition to enhanced resolution mode
with 11-bit and 12-bit resolution. Conversion results are reported in a common register for all
channels.
The 11-bit and 12-bit resolution modes are obtained by interpolating multiple samples to acquire
better accuracy. For 11-bit mode 4 samples are used, which gives an effective sample rate of
1/4 of the actual sample frequency. For 12-bit mode 16 samples are used, giving a effective
sample rate of 1/16 of actual. This arrangement allows conversion speed to be traded for better
accuracy.
Conversions can be started for all enabled channels, either by a software trigger, by detection of
a level change on the external trigger pin (TRIGGER), or by an integrated programmable timer.
When the Resistive Touch Screen Mode is enabled, an integrated sequencer automatically configures
the pad control signals and performs resistive touch screen conversions.
The ADCIFB also integrates an ADC Sleep Mode, a Pen-Detect Mode, and an Analog Compare
Mode, and connects with one Peripheral DMA Controller channel. These features reduce both
power consumption and processor intervention.
712
32142D–06/2013
ATUC64/128/256L3/4U
29.3 Block Diagram
Figure 29-1. ADCIFB Block Diagram
ADVREFP
Analog Multiplexer
Successive
Approximation
Register
Analog-to-Digital
Converter
Trigger
ADC Control
Logic
Timer
User
Interface
AD0
AD1
AD3
ADn
AD2
Resisitve Touch
Screen
Sequencer
CLK_ADCIFB
....
ADCIFB
ADP0
ADP1
I/O Controller
TRIGGER
Peripheral
Bus
DMA
Request
Interrupt
Request
CLK_ADC
713
32142D–06/2013
ATUC64/128/256L3/4U
29.4 I/O Lines Description
29.5 Product Dependencies
In order to use this module, other parts of the system must be configured correctly, as described
below.
29.5.1 I/O Lines
The analog input pins can be multiplexed with I/O Controller lines. The user must make sure the
I/O Controller is configured correctly to allow the ADCIFB access to the AD pins before the
ADCIFB is instructed to start converting data. If the user fails to do this the converted data may
be wrong.
The number of analog inputs is device dependent, please refer to the ADCIFB Module Configuration
chapter for the number of available AD inputs on the current device.
The ADVREFP pin must be connected correctly prior to using the ADCIFB. Failing to do so will
result in invalid ADC operation. See the Electrical Characteristics chapter for details.
If the TRIGGER, ADP0, and ADP1 pins are to be used in the application, the user must configure
the I/O Controller to assign the needed pins to the ADCIFB function.
29.5.2 Power Management
If the CPU enters a sleep mode that disables clocks used by the ADCIFB, the ADCIFB will stop
functioning and resume operation after the system wakes up from sleep mode.
If the Peripheral Event System is configured to send asynchronous peripheral events to the
ADCIFB and the clock used by the ADCIFB is stopped, a local and temporary clock will automatically
be requested so the event can be processed. Refer to Section 29.6.13, Section 29.6.12,
and the Peripheral Event System chapter for details.
Before entering a sleep mode where the clock to the ADCIFB is stopped, make sure the Analogto-Digital
Converter cell is put in an inactive state. Refer to Section 29.6.13 for more information.
29.5.3 Clocks
The clock for the ADCIFB bus interface (CLK_ADCIFB) is generated by the Power Manager.
This clock is enabled at reset, and can be disabled in the Power Manager. It is recommended to
disable the ADCIFB before disabling the clock, to avoid freezing the ADCIFB in an undefined
state.
Table 29-1. I/O Lines Description
Pin Name Description Type
ADVREFP Reference voltage Analog
TRIGGER External trigger Digital
ADP0 Drive Pin 0 for Resistive Touch Screen top channel (Xp) Digital
ADP1 Drive Pin 1 for Resistive Touch Screen right channel (Yp) Digital
AD0-ADn Analog input channels 0 to n Analog
714
32142D–06/2013
ATUC64/128/256L3/4U
29.5.4 DMA
The ADCIFB DMA handshake interface is connected to the Peripheral DMA Controller. Using
the ADCIFB DMA functionality requires the Peripheral DMA Controller to be programmed first.
29.5.5 Interrupts
The ADCIFB interrupt request line is connected to the interrupt controller. Using the ADCIFB
interrupt request functionality requires the interrupt controller to be programmed first.
29.5.6 Peripheral Events
The ADCIFB peripheral events are connected via the Peripheral Event System. Refer to the
Peripheral Event System chapter for details
29.5.7 Debug Operation
When an external debugger forces the CPU into debug mode, this module continues normal
operation. If this module is configured in a way that requires it to be periodically serviced by the
CPU through interrupt requests or similar, improper operation or data loss may result during
debugging.
29.6 Functional Description
The ADCIFB embeds a Successive Approximation Register (SAR) Analog-to-Digital Converter
(ADC). The ADC supports 8-bit or 10-bit resolution, which can be extended to 11 or 12 bits by
the Enhanced Resolution Mode.
The conversion is performed on a full range between 0V and the reference voltage pin
ADVREFP. Analog inputs between these voltages converts to digital values (codes) based on a
linear conversion. This linear conversion is described in the expression below where M is the
number of bits used to represent the analog value, Vin is the voltage of the analog value to convert,
Vref is the maximum voltage, and Code is the converted digital value.
29.6.1 Initializing the ADCIFB
The ADC Interface is enabled by writing a one to the Enable bit in the Control Register (CR.EN).
After the ADC Interface is enabled, the ADC timings needs to be configured by writing the correct
values to the RES, PRESCAL, and STARTUP fields in the ADC Configuration Register
(ACR). See Section 29.6.5, and Section 29.6.7 for details. Before the ADCIFB can be used, the
I/O Controller must be configured correctly and the Reference Voltage (ADVREFP) signal must
be connected. Refer to Section 29.5.1 for details.
29.6.2 Basic Operation
To convert analog values to digital values the user must first initialize the ADCIFB as described
in Section 29.6.1. When the ADCIFB is initialized the channels to convert must be enabled by
writing a one the corresponding bits in the Channel Enable Register (CHER). Enabling channel
N instructs the ADCIFB to convert the analog voltage applied to AD pin N at each conversion
sequence. Multiple channels can be enabled resulting in multiple AD pins being converted at
each conversion sequence.
Code
2M Vin
Vref
= -------------------
715
32142D–06/2013
ATUC64/128/256L3/4U
To start converting data the user can either manually start a conversion sequence by writing a
one to the START bit in the Control Register (CR.START) or configure an automatic trigger to
initiate the conversions. The automatic trigger can be configured to trig on many different conditions.
Refer to Section 29.8.1 for details.
The result of the conversion is stored in the Last Converted Data Register (LCDR) as they
become available, overwriting the result from the previous conversion. To avoid data loss if more
than one channel is enabled, the user must read the conversion results as they become available
either by using an interrupt handler or by using a Peripheral DMA channel to copy the
results to memory. Failing to do so will result in an Overrun Error condition, indicated by the
OVRE bit in the Status Register (SR).
To use an interrupt handler the user must enable the Data Ready (DRDY) interrupt request by
writing a one to the corresponding bit in the Interrupt Enable Register (IER). To clear the interrupt
after the conversion result is read, the user must write a one to the corresponding bit in the
Interrupt Clear Register (ICR). See Section 29.6.11 for details.
To use a Peripheral DMA Controller channel the user must configure the Peripheral DMA Controller
appropriately. The Peripheral DMA Controller will, when configured, automatically read
converted data as they become available. There is no need to manually clear any bits in the
Interrupt Status Register as this is performed by the hardware. If an Overrun Error condition happens
during DMA operation, the OVRE bit in the SR will be set.
29.6.3 ADC Resolution
The Analog-to-Digital Converter cell supports 8-bit or 10-bit resolution, which can be extended to
11-bit and 12-bit with the Enhanced Resolution Mode. The resolution is selected by writing the
selected resolution value to the RES field in the ADC Configuration Register (ACR). See Section
29.9.3.
By writing a zero to the RES field, the ADC switches to the lowest resolution and the conversion
results can be read in the eight lowest significant bits of the Last Converted Data Register
(LCDR). The four highest bits of the Last Converted Data (LDATA) field in the LCDR register
reads as zero. Writing a one to the RES field enables 10-bit resolution, the optimal resolution for
both sampling speed and accuracy. Writing two or three automatically enables Enhanced Resolution
Mode with 11-bit or 12-bit resolution, see Section 29.6.4 for details.
When a Peripheral DMA Controller channel is connected to the ADCIFB in 10-bit, 11-bit, or 12-
bit resolution mode, a transfer size of 16 bits must be used. By writing a zero to the RES field,
the destination buffers can be optimized for 8-bit transfers.
29.6.4 Enhanced Resolution Mode
The Enhanced Resolution Mode is automatically enabled when 11-bit or 12-bit mode is selected
in the ADC Configuration Register (ACR). In this mode the ADCIFB will trade conversion performance
for accuracy by averaging multiple samples.
To be able to increase the accuracy by averaging multiple samples it is important that some
noise is present in the input signal. The noise level should be between one and two LSB peakto-peak
to get good averaging performance.
The performance cost of enabling 11-bit mode is 4 ADC samples, which reduces the effective
ADC performance by a factor 4. For 12-bit mode this factor is 16. For 12-bit mode the effective
sample rate is maximum ADC sample rate divided by 16.
716
32142D–06/2013
ATUC64/128/256L3/4U
29.6.5 ADC Clock
The ADCIFB generates an internal clock named CLK_ADC that is used by the Analog-to-Digital
Converter cell to perform conversions. The CLK_ADC frequency is selected by writing to the
PRESCAL field in the ADC Configuration Register (ACR). The CLK_ADC range is between
CLK_ADCIFB/2, if PRESCAL is 0, and CLK_ADCIFB/128, if PRESCAL is 63 (0x3F).
A sensible PRESCAL value must be used in order to provide an ADC clock frequency according
to the maximum sampling rate parameter given in the Electrical Characteristics section. Failing
to do so may result in incorrect Analog-to-Digital Converter operation.
29.6.6 ADC Sleep Mode
The ADC Sleep Mode maximizes power saving by automatically deactivating the Analog-to-Digital
Converter cell when it is not being used for conversions. The ADC Sleep Mode is enabled by
writing a one to the SLEEP bit in the ADC Configuration Register (ACR).
When a trigger occurs while the ADC Sleep Mode is enabled, the Analog-to-Digital Converter
cell is automatically activated. As the analog cell requires a startup time, the logic waits during
this time and then starts the conversion of the enabled channels. When conversions of all
enabled channels are complete, the ADC is deactivated until the next trigger.
29.6.7 Startup Time
The Analog-to-Digital Converter cell has a minimal startup time when the cell is activated. This
startup time is given in the Electrical Characteristics chapter and must be written to the
STARTUP field in the ADC Configuration Register (ACR) to get correct conversion results.
The STARTUP field expects the startup time to be represented as the number of CLK_ADC
cycles between 8 and 1024 and in steps of 8 that is needed to cover the ADC startup time as
specified in the Electrical Characteristics chapter.
The Analog-to-Digital Converter cell is activated at the first conversion after reset and remains
active if ACR.SLEEP is zero. If ACR.SLEEP is one, the Analog-to-Digital Converter cell is automatically
deactivated when idle and thus each conversion sequence will have a initial startup
time delay.
29.6.8 Sample and Hold Time
A minimal Sample and Hold Time is necessary for the ADCIFB to guarantee the best converted
final value when switching between ADC channels. This time depends on the input impedance
of the analog input, but also on the output impedance of the driver providing the signal to the
analog input, as there is no input buffer amplifier.
The Sample and Hold time has to be programmed through the SHTIM field in the ADC Configuration
Register (ACR). This field can define a Sample and Hold time between 1 and 16
CLK_ADC cycles.
29.6.9 ADC Conversion
ADC conversions are performed on all enabled channels when a trigger condition is detected.
For details regarding trigger conditions see Section 29.8.1. The term channel is used to identify
a specific analog input pin so it can be included or excluded in an Analog-to-Digital conversion
sequence and to identify which AD pin was used to convert the current value in the Last Converted
Data Register (LCDR). Channel number N corresponding to AD pin number N.
717
32142D–06/2013
ATUC64/128/256L3/4U
Channels are enabled by writing a one to the corresponding bit in the Channel Enable Register
(CHER), and disabled by writing a one to the corresponding bit in the Channel Disable Register
(CHDR). Active channels are listed in the Channel Status Register (CHSR).
When a conversion sequence is started, all enabled channels will be converted in one sequence
and the result will be placed in the Last Converted Data Register (LCDR) with the channel number
used to produce the result. It is important to read out the results while the conversion
sequence is ongoing, as new values will automatically overwrite any old value and the old value
will be lost if not previously read by the user.
If the Analog-to-Digital Converter cell is inactive when starting a conversion sequence, the conversion
logic will wait a configurable number of CLK_ADC cycles as defined in the startup time
field in the ADC Configuration Register (ACR). After the cell is activated all enabled channels is
converted one by one until no more enabled channels exist. The conversion sequence converts
each enabled channel in order starting with the channel with the lowest channel number. If the
ACR.SLEEP bit is one, the Analog-to-Digital Converter cell is deactivated after the conversion
sequence has finished.
For each channel converted, the ADCIFB waits a Sample and Hold number of CLK_ADC cycles
as defined in the SHTIM field in ACR, and then instructs the Analog-to-Digital Converter cell to
start converting the analog voltage. The ADC cell requires 10 CLK_ADC cycles to actually convert
the value, so the total time to convert a channel is Sample and Hold + 10 CLK_ADC cycles.
29.6.10 Analog Compare Mode
The ADCIFB can test if the converted values, as they become available, are below, above, or
inside a specified range and generate interrupt requests based on this information. This is useful
for applications where the user wants to monitor some external analog signal and only initiate
actions if the value is above, below, or inside some specified range.
The Analog Compare mode is enabled by writing a one to the Analog Compare Enable (ACE) bit
in the Mode Register (MR). The values to compare must be written to the Low Value (LV) field
and the High Value (HV) field in the Compare Value Register (CVR). The Analog Compare
mode will, when enabled, check all enabled channels against the pre-programmed high and low
values and set status bits.
To generate an interrupt request if a converted value is below a limit, write the limit to the
CVR.LV field and enable interrupt request on the Compare Lesser Than (CLT) bit by writing a
one to the corresponding bit in the Interrupt Enable Register (IER). To generate an interrupt
request if a converted value is above a limit, write the limit to the CVR.HV field and enable interrupt
for Compare Greater Than (CGT) bit. To generate an interrupt request if a converted value
is inside a range, write the low and high limit to the LV and HV fields and enable the Compare
Else (CELSE) interrupt. To generate an interrupt request if a value is outside a range, write the
LV and HV fields to the low and high limits of the range and enable CGT and CLT interrupts.
Note that the values written to LV and HV must match the resolution selected in the ADC Configuration
Register (ACR).
29.6.11 Interrupt Operation
Interrupt requests are enabled by writing a one to the corresponding bit in the Interrupt Enable
Register (IER) and disabled by writing a one to the corresponding bit in the Interrupt Disable
Register (IDR). Enabled interrupts can be read from the Interrupt Mask Register (IMR). Active
interrupt requests, but potentially masked, are visible in the Interrupt Status Register (ISR). To
718
32142D–06/2013
ATUC64/128/256L3/4U
clear an active interrupt request, write a one to the corresponding bit in the Interrupt Clear Register
(ICR).
The source for the interrupt requests are the status bits in the Status Register (SR). The SR
shows the ADCIFB status at the time the register is read. The Interrupt Status Register (ISR)
shows the status since the last write to the Interrupt Clear Register. The combination of ISR and
SR allows the user to react to status change conditions but also allows the user to read the current
status at any time.
29.6.12 Peripheral Events
The Peripheral Event System can be used together with the ADCIFB to allow any peripheral
event generator to be used as a trigger source. To enable peripheral events to trigger a conversion
sequence the user must write the Peripheral Event Trigger value (0x7) to the Trigger Mode
(TRGMOD) field in the Trigger Register (TRGR). Refer to Table 29-4 on page 730. The user
must also configure a peripheral event generator to emit peripheral events for the ADCIFB to
trigger on. Refer to the Peripheral Event System chapter for details.
29.6.13 Sleep Mode
Before entering sleep modes the user must make sure the ADCIFB is idle and that the Analogto-Digital
Converter cell is inactive. To deactivate the Analog-to-Digital Converter cell the SLEEP
bit in the ADC Configuration Register (ACR) must be written to one and the ADCIFB must be
idle. To make sure the ADCIFB is idle, write a zero the Trigger Mode (TRGMOD) field in the
Trigger Register (TRGR) and wait for the READY bit in the Status Register (SR) to be set.
Note that by deactivating the Analog-to-Digital Converter cell, a startup time penalty as defined
in the STARTUP field in the ADC Configuration Register (ACR) will apply on the next
conversion.
29.6.14 Conversion Performances
For performance and electrical characteristics of the ADCIFB, refer to the Electrical Characteristics
chapter.
29.7 Resistive Touch Screen
The ADCIFB embeds an integrated Resistive Touch Screen Sequencer that can be used to calculate
contact coordinates on a resistive touch screen film. When instructed to start, the
integrated Resistive Touch Screen Sequencer automatically applies a sequence of voltage patterns
to the resistive touch screen films and the Analog-to-Digital Conversion cell is used to
measure the effects. The resulting measurements can be used to calculate the horizontal and
vertical contact coordinates. It is recommended to use a high resistance touch screen for optimal
resolution.
The resistive touch screen film is connected to the ADCIFB using the AD and ADP pins. See
Section 29.7.3 for details.
Resistive Touch Screen Mode is enabled by writing a one to the Touch Screen ADC Mode field
in the Mode Register (MR.TSAMOD). In this mode, channels TSPO+0 though TSPO+3 are
automatically enabled where TSPO refers to the Touch Screen Pin Offset field in the Mode Register
(MR.TSPO). For each conversion sequence, all enabled channels before TSPO+0 and
after TSPO+3 are converted as ordinary ADC channels, producing 1 conversion result each.
When the sequencer enters the TSPO+0 channel the Resistive Touch Screen Sequencer will
take over control and convert the next 4 channels as described in Section 29.7.4.
719
32142D–06/2013
ATUC64/128/256L3/4U
29.7.1 Resistive Touch Screen Principles
A resistive touch screen is based on two resistive films, each one fitted with a pair of electrodes,
placed at the top and bottom on one film, and on the right and left on the other. Between the two,
there is a layer that acts as an insulator, but makes a connection when pressure is applied to the
screen. This is illustrated in Figure 29-2 on page 719.
Figure 29-2. Resistive Touch Screen Position Measurement
29.7.2 Position Measurement Method
As shown in Figure 29-2 on page 719, to detect the position of a contact, voltage is first applied
to XP (top) and Xm (bottom) leaving Yp and Ym tristated. Due to the linear resistance of the film,
there is a voltage gradient from top to bottom on the first film. When a contact is performed on
the screen, the voltage at the contact point propagates to the second film. If the input impedance
on the YP (right) and Ym (left) electrodes are high enough, no current will flow, allowing the voltage
at the contact point to be measured at Yp. The value measured represents the vertical
position component of the contact point.
For the horizontal direction, the same method is used, but by applying voltage from YP (right) to
Ym (left) and measuring at XP.
In an ideal world (linear, with no loss), the vertical position is equal to:
VYP / VDD
To compensate for some of the real world imperfections, VXP and VXm can be measured and
used to improve accuracy at the cost of two more conversions per axes. The new expression for
the vertical position then becomes:
(VYP - VXM) / (VXP - VXM)
XM
XP
YM YP
XP
XM
YP
VDD
GND
Volt
Horizontal Position Detection
YP
YM
XP
VDD
GND
Volt
Vertical Position Detection
Pen
Contact
720
32142D–06/2013
ATUC64/128/256L3/4U
29.7.3 Resistive Touch Screen Pin Connections
The resistive touch screen film signals connects to the ADCIFB using the AD and ADP pins. The
XP (top) and XM (bottom) film signals are connected to ADtspo+0 and ADtspo+1 pins, and the YP
(right) and YM (left) signals are connected to ADtspo+2 and ADtspo+3 pins. The tspo index is
configurable through the Touch Screen Pin Offset (TSPO) field in the Mode Register (MR) and
allows the user to configure which AD pins to use for resistive touch screen applications. Writing
a zero to the TSPO field instructs the ADCIFB to use AD0 through AD3, where AD0 is connected
to XP, AD1 is connected to XM and so on. Writing a one to the TSPO field instructs the
ADCIFB to use AD1 through AD4 for resistive touch screen sequencing, where AD1 is connected
to XP and AD0 is free to be used as an ordinary ADC channel.
When the Analog Pin Output Enable (APOE) bit in the Mode Register (MR) is zero, the AD pins
are used to measure input voltage and drive the GND sequences, while the ADP pins are used
to drive the VDD sequences. This arrangement allows the user to reduce the voltage seen at the
AD input pins by inserting external resistors between ADP0 and XP and ADP1 and YP signals
which are again directly connected to the AD pins. It is important that the voltages observed at
the AD pins are not higher than the maximum allowed ADC input voltage. See Figure 29-3 on
page 721 for details regarding how to connect the resistive touch screen films to the AD and
ADP pins.
By adding a resistor between ADP0 and XP, and ADP1 and YP, the maximum voltage observed
at the AD pins can be controlled by the following voltage divider expressions:
The Rfilmx parameter is the film resistance observed when measuring between XP and XM. The
Rresistorx parameter is the resistor size inserted between ADP0 and XP. The definition of Rfilmy
and Rresistory is the same but for ADP1, YP, and YM instead.
Table 29-2. Resistive Touch Screen Pin Connections
ADCIFB Pin TS Signal, APOE == 0 TS Signal, APOE == 1
ADP0 Xp through a resistor No Connect
ADP1 Yp through a resistor No Connect
ADtspo+0 Xp Xp
ADtspo+1 Xm Xm
ADtspo+2 Yp Yp
ADtspo+3 Ym Ym
V ADtspo + 0
Rfilmx
Rfilmx Rresistorx + -------------------------------------------- V DP0 =
721
32142D–06/2013
ATUC64/128/256L3/4U
The ADP pins are used by default, as the APOE bit is zero after reset. Writing a one to the
APOE bit instructs the ADCIFB Resistive Touch Screen Sequencer to use the already connected
ADtspo+0 and ADtspo+2 pins to drive VDD to XP and YP signals directly. In this mode the
ADP pins can be used as general purpose I/O pins.
Before writing a one to the APOE bit the user must make sure that the I/O voltage is compatible
with the ADC input voltage. If the I/O voltage is higher than the maximum input voltage of the
ADC, permanent damage may occur. Refer to the Electrical Characteristics chapter for details.
Figure 29-3. Resistive Touch Screen Pin Connections
V ADtspo + 2
Rfilmy
Rfilmy Rresistory + -------------------------------------------- V DP1 =
ADtspo+1
XM
XP
YM YP
ADtspo+0
DP1
DP0
ADtspo+3
ADtspo+2
Analog Pin Output Enable (MR.APOE) == 0
ADtspo+1
XM
XP
YM YP
ADtspo+0
DP1
DP0
ADtspo+3
ADtspo+2
Analog Pin Output Enable (MR.APOE) == 1
NC
NC
722
32142D–06/2013
ATUC64/128/256L3/4U
29.7.4 Resistive Touch Screen Sequencer
The Resistive Touch Screen Sequencer is responsible for applying voltage to the resistive touch
screen films as described in Section 29.7.2. This is done by controlling the output enable and the
output value of the ADP and AD pins. This allows the Resistive Touch Screen Sequencer to add
a voltage gradient on one film while keeping the other film floating so a touch can be measured.
The Resistive Touch Screen Sequencer will when measuring the vertical position, apply VDD
and GND to the pins connected to XP and XM. The YP and YM pins are put in tristate mode so the
measurement of YP can proceed without interference. To compensate for ADC offset errors and
non ideal pad drivers, the actual voltage of XP and XM is measured as well, so the real values for
VDD and GND can be used in the contact point calculation to increase accuracy. See second
formula in Section 29.7.2.
When the vertical values are converted the same setup is applies for the second axes, by setting
XP and XM in tristate mode and applying VDD and GND to YP and YM. Refer to Section 29.8.3 for
details.
29.7.5 Pen Detect
If no contact is applied to the resistive touch screen films, any resistive touch screen conversion
result will be undefined as the film being measured is floating. This can be avoided by enabling
Pen Detect and only trigger resistive touch screen conversions when the Pen Contact
(PENCNT) status bit in the Status Register (SR) is one. Pen Detect is enabled by writing a one
to the Pen Detect (PENDET) bit in the Mode Register (MR).
When Pen Detect is enabled, the ADCIFB grounds the vertical panel by applying GND to XP and
XM and polarizes the horizontal panel by enabling pull-up on the pin connected to YP. The YM pin
will in this mode be tristated. Since there is no contact, no current is flowing and there is no
related power consumption. As soon as a contact occurs, GND will propagate to YM by pulling
down YP, allowing the contact to be registered by the ADCIFB.
A programmable debouncing filter can be used to filter out false pen detects because of noise.
The debouncing filter is programmable from one CLK_ADC period and up to 215 CLK_ADC periods.
The debouncer length is set by writing to the PENDBC field in MR.
723
32142D–06/2013
ATUC64/128/256L3/4U
Figure 29-4. Resistive Touch Screen Pen Detect
The Resistive Touch Screen Pen Detect can be used to generate an ADCIFB interrupt request
or it can be used to trig a conversion, so that a position can be measured as soon as a contact is
detected.
The Pen Detect Mode generates two types of status signals, reported in the Status Register
(SR):
• The bit PENCNT is set when current flows and remains set until current stops.
• The bit NOCNT is set when no current flows and remains set until current flows.
Before a current change is reflected in the SR, the new status must be stable for the duration of
the debouncing time.
Both status conditions can generate an interrupt request if the corresponding bit in the Interrupt
Mask Register (IMR) is one. Refer to Section 29.6.11 on page 717.
XP
XM
YM
YP
Tristate
GND
Pullup T o the ADC
Debouncer Pen Interrupt
PENDBC
GND
Resistive
Touch Screen
Sequencer
724
32142D–06/2013
ATUC64/128/256L3/4U
29.8 Operating Modes
The ADCIFB features two operating modes, each defining a separate conversion sequence:
• ADC Mode: At each trigger, all the enabled channels are converted.
• Resistive Touch Screen Mode: At each trigger, all enabled channels plus the resistive touch
screen channels are converted as described in Section 29.8.3. If channels except the
dedicated resistive touch screen channels are enabled, they are converted normally before
and after the resistive touch screen channels are converted.
The operating mode is selected by the TSAMOD field in the Mode Register (MR).
29.8.1 Conversion Triggers
A conversion sequence is started either by a software or by a hardware trigger. When a conversion
sequence is started, all enabled channels will be converted and made available in the
shared Last Converted Register (LCDR).
The software trigger is asserted by writing a one to the START field in the Control Register (CR).
The hardware trigger can be selected by the TRGMOD field in the Trigger Register (TRGR). Different
hardware triggers exist:
• External trigger, either rising or falling or any, detected on the external trigger pin TRIGGER
• Pen detect trigger, depending the PENDET bit in the Mode Register (MR)
• Continuous trigger, meaning the ADCIFB restarts the next sequence as soon as it finishes
the current one
• Periodic trigger, which is defined by the TRGR.TRGPER field
• Peripheral event trigger, allowing the Peripheral Event System to synchronize conversion with
some configured peripheral event source.
Enabling a hardware trigger does not disable the software trigger functionality. Thus, if a hardware
trigger is selected, the start of a conversion can still be initiated by the software trigger.
29.8.2 ADC Mode
In the ADC Mode, the active channels are defined by the Channel Status Register (CHSR). A
channel is enabled by writing a one to the corresponding bit in the Channel Enable Register
(CHER), and disabled by writing a one to the corresponding bit in the Channel Disable Register
(CHDR). The conversion results are stored in the Last Converted Data Register (LCDR) as they
become available, overwriting old conversions.
At each trigger, the following sequence is performed:
1. If ACR.SLEEP is one, wake up the ADC and wait for the startup time.
2. If Channel 0 is enabled, convert Channel 0 and store result in LCDR.
3. If Channel 1 is enabled, convert Channel 1 and store result in LCDR.
4. If Channel N is enabled, convert Channel N and store result in LCDR.
5. If ACR.SLEEP is one, place the ADC cell in a low-power state.
If the Peripheral DMA Controller is enabled, all converted values are transferred continuously
into the memory buffer.
29.8.3 Resistive Touch Screen Mode
Writing a one to the TSAMOD field in the Mode Register (MR) enables Resistive Touch Screen
Mode. In this mode the channels TSPO+0 to TSPO+3, corresponding to the resistive touch
725
32142D–06/2013
ATUC64/128/256L3/4U
screen inputs, are automatically activated. In addition, if any other channels are enabled, they
will be converted before and after the resistive touch screen conversion.
At each trigger, the following sequence is performed:
1. If ACR.SLEEP is one, wake up the ADC cell and wait for the startup time.
2. Convert all enabled channels before TSPO and store the results in the LCDR.
3. Apply supply on the inputs XP and XM during the Sample and Hold Time.
4. Convert Channel XM and store the result in TMP.
5. Apply supply on the inputs XP and XM during the Sample and Hold Time.
6. Convert Channel XP, subtract TMP from the result and store the subtracted result in
LCDR.
7. Apply supply on the inputs XP and XM during the Sample and Hold Time.
8. Convert Channel YP, subtract TMP from the result and store the subtracted result in
LCDR.
9. Apply supply on the inputs YP and YM during the Sample and Hold Time.
10. Convert Channel YM and store the result in TMP.
11. Apply supply on the inputs YP and YM during the Sample and Hold Time.
12. Convert Channel YP, subtract TMP from the result and store the subtracted result in
LCDR.
13. Apply supply on the inputs YP and YM during the Sample and Hold Time.
14. Convert Channel XP, subtract TMP from the result and store the subtracted result in
LCDR.
15. Convert all enabled channels after TSPO + 3 and store results in the LCDR.
16. If ACR.SLEEP is one, place the ADC cell in a low-power state.
The resulting buffer structure stored in memory is:
1. XP - XM
2. YP - XM
3. YP - YM
4. XP - YM.
The vertical position can be easily calculated by dividing the data at offset 1(XP - XM) by the data
at offset 2(YP - XM).
The horizontal position can be easily calculated by dividing the data at offset 3(YP - YM) by the
data at offset 4(XP - YM).
726
32142D–06/2013
ATUC64/128/256L3/4U
29.9 User Interface
Note: 1. The reset values for these registers are device specific. Please refer to the Module Configuration section at the end of this
chapter.
Table 29-3. ADCIFB Register Memory Map
Offset Register Name Access Reset
0x00 Control Register CR Write-only -
0x04 Mode Register MR Read/Write 0x00000000
0x08 ADC Configuration Register ACR Read/Write 0x00000000
0x0C Trigger Register TRGR Read/Write 0x00000000
0x10 Compare Value Register CVR Read/Write 0x00000000
0x14 Status Register SR Read-only 0x00000000
0x18 Interrupt Status Register ISR Read-only 0x00000000
0x1C Interrupt Clear Register ICR Write-only -
0x20 Interrupt Enable Register IER Write-only -
0x24 Interrupt Disable Register IDR Write-only -
0x28 Interrupt Mask Register IMR Read-only 0x00000000
0x2C Last Converted Data Register LCDR Read-only 0x00000000
0x30 Parameter Register PARAMETER Read-only -(1)
0x34 Version Register VERSION Read-only -(1)
0x40 Channel Enable Register CHER Write-only -
0x44 Channel Disable Register CHDR Write-only -
0x48 Channel Status Register CHSR Read-only 0x00000000
727
32142D–06/2013
ATUC64/128/256L3/4U
29.9.1 Control Register
Register Name: CR
Access Type: Write-only
Offset: 0x00
Reset Value: 0x00000000
• DIS: ADCDIFB Disable
Writing a zero to this bit has no effect.
Writing a one to this bit disables the ADCIFB.
Note: Disabling the ADCIFB effectively stops all clocks in the module so the user must make sure the ADCIFB is idle before
disabling the ADCIFB.
• EN: ADCIFB Enable
Writing a zero to this bit has no effect.
Writing a one to this bit enables the ADCIFB.
Note: The ADCIFB must be enabled before use.
• START: Start Conversion
Writing a zero to this bit has no effect.
Writing a one to this bit starts an Analog-to-Digital conversion.
• SWRST: Software Reset
Writing a zero to this bit has no effect.
Writing a one to this bit resets the ADCIFB, simulating a hardware reset.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
- - - - - - DIS EN
76543210
- - - - - - START SWRST
728
32142D–06/2013
ATUC64/128/256L3/4U
29.9.2 Mode Register
Name: MR
Access Type: Read/Write
Offset: 0x04
Reset Value: 0x00000000
• PENDBC: Pen Detect Debouncing Period
Period = 2PENDBC*TCLK_ADC
• TSPO: Touch Screen Pin Offset
The Touch Screen Pin Offset field is used to indicate which AD pins are connected to the resistive touch screen film edges. Only
an offset is specified and it is assumed that the resistive touch screen films are connected sequentially from the specified offset
pin and up to and including offset + 3 (4 pins).
• APOE: Analog Pin Output Enable
0: AD pins are not used to drive VDD in resistive touch screen sequence.
1: AD pins are used to drive VDD in resistive touch screen sequence.
Note: If the selected I/O voltage configuration is incompatible with the Analog-to-Digital converter cell voltage specification, this
bit must stay cleared to avoid damaging the ADC. In this case the ADP pins must be used to drive VDD instead, as described in
Section 29.7.3. If the I/O and ADC voltages are compatible, the AD pins can be used directly by writing a one to this bit. In this
case the ADP pins can be ignored.
• ACE: Analog Compare Enable
0: The analog compare functionality is disabled.
1: The analog compare functionality is enabled.
• PENDET: Pen Detect
0: The pen detect functionality is disabled.
1: The pen detect functionality is enabled.
Note: Touch detection logic can only be enabled when the ADC sequencer is idle. For successful pen detection the user must
make sure there is enough idle time between consecutive scans for the touch detection logic to settle.
• TSAMOD: Touch Screen ADC Mode
0: Touch Screen Mode is disabled.
1: Touch Screen Mode is enabled.
31 30 29 28 27 26 25 24
PENDBC - - - -
23 22 21 20 19 18 17 16
TSPO
15 14 13 12 11 10 9 8
--------
76543210
- APOE ACE PENDET - - - TSAMOD
729
32142D–06/2013
ATUC64/128/256L3/4U
29.9.3 ADC Configuration Register
Name: ACR
Access Type: Read/Write
Offset: 0x08
Reset Value: 0x00000000
• SHTIM: Sample & Hold Time for ADC Channels
• STARTUP: Startup Time
• PRESCAL: Prescaler Rate Selection
• RES: Resolution Selection
0: 8-bit resolution.
1: 10-bit resolution.
2: 11-bit resolution, interpolated.
3: 12-bit resolution, interpolated.
• SLEEP: ADC Sleep Mode
0: ADC Sleep Mode is disabled.
1: ADC Sleep Mode is enabled.
31 30 29 28 27 26 25 24
- - - - SHTIM
23 22 21 20 19 18 17 16
- STARTUP
15 14 13 12 11 10 9 8
- - PRESCAL
76543210
- - RES - - - SLEEP
TSAMPLE&HOLD SHTIM + 2 TCLK_ADC =
TARTUP STARTUP + 1 8 TCLK_AD =
TCLK_ADC = PRESCAL + 1 2 TCLK_ADCIFB
730
32142D–06/2013
ATUC64/128/256L3/4U
29.9.4 Trigger Register
Name: TRGR
Access Type: Read/Write
Offset: 0x0C
Reset Value: 0x00000000
• TRGPER: Trigger Period
Effective only if TRGMOD defines a Periodic Trigger.
Defines the periodic trigger period, with the following equations:
Trigger Period = TRGPER *TCLK_ADC
• TRGMOD: Trigger Mode
31 30 29 28 27 26 25 24
TRGPER[15:8]
23 22 21 20 19 18 17 16
TRGPER[7:0]
15 14 13 12 11 10 9 8
--------
76543210
- - - - - TRGMOD
Table 29-4. Trigger Modes
TRGMOD Selected Trigger Mode
0 0 0 No trigger, only software trigger can start conversions
0 0 1 External Trigger Rising Edge
0 1 0 External Trigger Falling Edge
0 1 1 External Trigger Any Edge
100 Pen Detect Trigger (shall be selected only if PENDET is set and TSAMOD = Touch
Screen mode)
1 0 1 Periodic Trigger (TRGPER shall be initiated appropriately)
1 1 0 Continuous Mode
1 1 1 Peripheral Event Trigger
731
32142D–06/2013
ATUC64/128/256L3/4U
29.9.5 Compare Value Register
Name: CVR
Access Type: Read/Write
Offset: 0x10
Reset Value: 0x00000000
• HV: High Value
Defines the high value used when comparing analog input.
• LV: Low Value
Defines the low value used when comparing analog input.
31 30 29 28 27 26 25 24
- - - - HV[11:8]
23 22 21 20 19 18 17 16
HV[7:0]
15 14 13 12 11 10 9 8
- - - - LV[11:8]
76543210
LV[7:0]
732
32142D–06/2013
ATUC64/128/256L3/4U
29.9.6 Status Register
Name: SR
Access Type: Read-only
Offset: 0x14
Reset Value: 0x00000000
• EN: Enable Status
0: The ADCIFB is disabled.
1: The ADCIFB is enabled.
This bit is cleared when CR.DIS is written to one.
This bit is set when CR.EN is written to one.
• CELSE: Compare Else Status
This bit is cleared when either CLT or CGT are detected or when analog compare is disabled.
This bit is set when no CLT or CGT are detected on the last converted data and analog compare is enabled.
• CGT: Compare Greater Than Status
This bit is cleared when no compare greater than CVR.HV is detected on the last converted data or when analog compare is
disabled.
This bit is set when compare greater than CVR.HV is detected on the last converted data and analog compare is enabled.
• CLT: Compare Lesser Than Status
This bit is cleared when no compare lesser than CVR.LV is detected on the last converted data or when analog compare is
disabled.
This bit is set when compare lesser than CVR.LV is detected on the last converted data and analog compare is enabled.
• BUSY: Busy Status
This bit is cleared when the ADCIFB is ready to perform a conversion sequence.
This bit is set when the ADCIFB is busy performing a convention sequence.
• READY: Ready Status
This bit is cleared when the ADCIFB is busy performing a conversion sequence
This bit is set when the ADCIFB is ready to perform a conversion sequence.
• NOCNT: No Contact Status
This bit is cleared when no contact loss is detected or pen detect is disabled
This bit is set when contact loss is detected and pen detect is enabled.
• PENCNT: Pen Contact Status
This bit is cleared when no contact is detected or pen detect is disabled.
31 30 29 28 27 26 25 24
- - - - - - - EN
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
- CELSE CGT CLT - - BUSY READY
76543210
- - NOCNT PENCNT - - OVRE DRDY
733
32142D–06/2013
ATUC64/128/256L3/4U
This bit is set when pen contact is detected and pen detect is enabled.
• OVRE: Overrun Error Status
This bit is cleared when no Overrun Error has occurred since the start of a conversion sequence.
This bit is set when one or more Overrun Error has occurred since the start of a conversion sequence.
• DRDY: Data Ready Status
0: No data has been converted since the last reset.
1: One or more conversions have completed since the last reset and data is available in LCDR.
This bit is cleared when CR.SWRST is written to one.
This bit is set when one or more conversions have completed and data is available in LCDR.
734
32142D–06/2013
ATUC64/128/256L3/4U
29.9.7 Interrupt Status Register
Name: ISR
Access Type: Read-only
Offset: 0x18
Reset Value: 0x00000000
• CELSE: Compare Else Status
This bit is cleared when the corresponding bit in ICR is written to one.
This bit is set when the corresponding bit in SR has a zero-to-one transition.
• CGT: Compare Greater Than Status
This bit is cleared when the corresponding bit in ICR is written to one.
This bit is set when the corresponding bit in SR has a zero-to-one transition.
• CLT: Compare Lesser Than Status
This bit is cleared when the corresponding bit in ICR is written to one.
This bit is set when the corresponding bit in SR has a zero-to-one transition.
• BUSY: Busy Status
This bit is cleared when the corresponding bit in ICR is written to one.
This bit is set when the corresponding bit in SR has a zero-to-one transition.
• READY: Ready Status
This bit is cleared when the corresponding bit in ICR is written to one.
This bit is set when the corresponding bit in SR has a zero-to-one transition.
• NOCNT: No Contact Status
This bit is cleared when the corresponding bit in ICR is written to one.
This bit is set when the corresponding bit in SR has a zero-to-one transition.
• PENCNT: Pen Contact Status
This bit is cleared when the corresponding bit in ICR is written to one.
This bit is set when the corresponding bit in SR has a zero-to-one transition.
• OVRE: Overrun Error Status
This bit is cleared when the corresponding bit in ICR is written to one.
This bit is set when the corresponding bit in SR has a zero-to-one transition.
• DRDY: Data Ready Status
This bit is cleared when the corresponding bit in ICR is written to one.
This bit is set when a conversion has completed and new data is available in LCDR.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
- CELSE CGT CLT - - BUSY READY
76543210
- - NOCNT PENCNT - - OVRE DRDY
735
32142D–06/2013
ATUC64/128/256L3/4U
29.9.8 Interrupt Clear Register
Name: ICR
Access Type: Write-only
Offset: 0x1C
Reset Value: 0x00000000
Writing a zero to a bit in this register has no effect.
Writing a one to a bit in this register will clear the corresponding bit in ISR and the corresponding interrupt request.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
- CELSE CGT CLT - - BUSY READY
76543210
- - NOCNT PENCNT - - OVRE DRDY
736
32142D–06/2013
ATUC64/128/256L3/4U
29.9.9 Interrupt Enable Register
Name: IER
Access Type: Write-only
Offset: 0x20
Reset Value: 0x00000000
Writing a zero to a bit in this register has no effect.
Writing a one to a bit in this register will set the corresponding bit in IMR.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
- CELSE CGT CLT - - BUSY READY
76543210
- - NOCNT PENCNT - - OVRE DRDY
737
32142D–06/2013
ATUC64/128/256L3/4U
29.9.10 Interrupt Disable Register
Name: IDR
Access Type: Write-only
Offset: 0x24
Reset Value: 0x00000000
Writing a zero to a bit in this register has no effect.
Writing a one to a bit in this register will clear the corresponding bit in IMR.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
- CELSE CGT CLT - - BUSY READY
76543210
- - NOCNT PENCNT - - OVRE DRDY
738
32142D–06/2013
ATUC64/128/256L3/4U
29.9.11 Interrupt Mask Register
Name: IMR
Access Type: Read-only
Offset: 0x28
Reset Value: 0x00000000
0: The corresponding interrupt is disabled.
1: The corresponding interrupt is enabled.
A bit in this register is cleared by writing a one to the corresponding bit in Interrupt Disable Register (IDR).
A bit in this register is set by writing a one to the corresponding bit in Interrupt Enable Register (IER).
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
- CELSE CGT CLT - - BUSY READY
76543210
- - NOCNT PENCNT - - OVRE DRDY
739
32142D–06/2013
ATUC64/128/256L3/4U
29.9.12 Last Converted Data Register
Name: LCDR
Access Type: Read-only
Offset: 0x2C
Reset Value: 0x00000000
• LCCH: Last Converted Channel
This field indicates what channel was last converted, i.e. what channel the LDATA represents.
• LDATA: Last Data Converted
The analog-to-digital conversion data is placed in this register at the end of a conversion on any analog channel and remains
until a new conversion on any analog channel is completed.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
LCCH
15 14 13 12 11 10 9 8
- - - - LDATA[11:8]
76543210
LDATA[7:0]
740
32142D–06/2013
ATUC64/128/256L3/4U
29.9.13 Parameter Register
Name: PARAMETER
Access Type: Read-only
Offset: 0x30
Reset Value: 0x00000000
• CHn: Channel n Implemented
0: The corresponding channel is not implemented.
1: The corresponding channel is implemented.
31 30 29 28 27 26 25 24
CH31 CH30 CH29 CH28 CH27 CH26 CH25 CH24
23 22 21 20 19 18 17 16
CH23 CH22 CH21 CH20 CH19 CH18 CH17 CH16
15 14 13 12 11 10 9 8
CH15 CH14 CH13 CH12 CH11 CH10 CH9 CH8
76543210
CH7 CH6 CH5 CH4 CH3 CH2 CH1 CH0
741
32142D–06/2013
ATUC64/128/256L3/4U
29.9.14 Version Register
Name: VERSION
Access Type: Read-only
Offset: 0x34
Reset Value: 0x00000000
• VARIANT: Variant Number
Reserved. No functionality associated.
• VERSION: Version Number
Version number of the Module. No functionality associated.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
- - - - VARIANT
15 14 13 12 11 10 9 8
- - - - VERSION[11:8]
76543210
VERSION[7:0]
742
32142D–06/2013
ATUC64/128/256L3/4U
29.9.15 Channel Enable Register
Name: CHER
Access Type: Write-only
Offset: 0x40
Reset Value: 0x00000000
• CHn: Channel n Enable
Writing a zero to a bit in this register has no effect
Writing a one to a bit in this register enables the corresponding channel
The number of available channels is device dependent. Please refer to the Module Configuration section at the end of this
chapter for information regarding which channels are implemented.
31 30 29 28 27 26 25 24
CH31 CH30 CH29 CH28 CH27 CH26 CH25 CH24
23 22 21 20 19 18 17 16
CH23 CH22 CH21 CH20 CH19 CH18 CH17 CH16
15 14 13 12 11 10 9 8
CH15 CH14 CH13 CH12 CH11 CH10 CH9 CH8
76543210
CH7 CH6 CH5 CH4 CH3 CH2 CH1 CH0
743
32142D–06/2013
ATUC64/128/256L3/4U
29.9.16 Channel Disable Register
Name: CHDR
Access Type: Write-only
Offset: 0x44
Reset Value: 0x00000000
• CHn: Channel N Disable
Writing a zero to a bit in this register has no effect.
Writing a one to a bit in this register disables the corresponding channel.
Warning: If the corresponding channel is disabled during a conversion, or if it is disabled and then re-enabled during a
conversion, its associated data and its corresponding DRDY and OVRE bits in SR are unpredictable.
The number of available channels is device dependent. Please refer to the Module Configuration section at the end of this
chapter for information regarding how many channels are implemented.
31 30 29 28 27 26 25 24
CH31 CH30 CH29 CH28 CH27 CH26 CH25 CH24
23 22 21 20 19 18 17 16
CH23 CH22 CH21 CH20 CH19 CH18 CH17 CH16
15 14 13 12 11 10 9 8
CH15 CH14 CH13 CH12 CH11 CH10 CH9 CH8
76543210
CH7 CH6 CH5 CH4 CH3 CH2 CH1 CH0
744
32142D–06/2013
ATUC64/128/256L3/4U
29.9.17 Channel Status Register
Name: CHSR
Access Type: Read-only
Offset: 0x48
Reset Value: 0x00000000
• CHn: Channel N Status
0: The corresponding channel is disabled.
1: The corresponding channel is enabled.
A bit in this register is cleared by writing a one to the corresponding bit in Channel Disable Register (CHDR).
A bit in this register is set by writing a one to the corresponding bit in Channel Enable Register (CHER).
The number of available channels is device dependent. Please refer to the Module Configuration section at the end of this
chapter for information regarding how many channels are implemented.
31 30 29 28 27 26 25 24
CH31 CH30 CH29 CH28 CH27 CH26 CH25 CH24
23 22 21 20 19 18 17 16
CH23 CH22 CH21 CH20 CH19 CH18 CH17 CH16
15 14 13 12 11 10 9 8
CH15 CH14 CH13 CH12 CH11 CH10 CH9 CH8
76543210
CH7 CH6 CH5 CH4 CH3 CH2 CH1 CH0
745
32142D–06/2013
ATUC64/128/256L3/4U
29.10 Module Configuration
The specific configuration for each ADCIFB instance is listed in the following tables.The module
bus clocks listed here are connected to the system bus clocks. Please refer to the Power Manager
chapter for details.
Note: 1. AD3 does not exist
Table 29-5. Module Configuration
Feature ADCIFB
Number of ADC channels 9 (8 + 1 internal temperature sensor channel)
Table 29-6. ADCIFB Clocks
Clock Name Description
CLK_ADCIFB Clock for the ADCIFB bus interface
Table 29-7. Register Reset Values
Register Reset Value
VERSION 0x00000110
PARAMETER 0x000003FF
Table 29-8. ADC Input Channels(1)
Channel Input
CH0 AD0
CH1 AD1
CH2 AD2
CH4 AD4
CH5 AD5
CH6 AD6
CH7 AD7
CH8 AD8
CH9 Temperature sensor
746
32142D–06/2013
ATUC64/128/256L3/4U
30. Analog Comparator Interface (ACIFB)
Rev: 2.0.2.2
30.1 Features
• Controls an array of Analog Comparators
• Low power option
– Single shot mode support
• Selectable settings for filter option
– Filter length and hysteresis
• Window Mode
– Detect inside/outside window
– Detect above/below window
• Interrupt
– On comparator result rising edge, falling edge, toggle
– Inside window, outside window, toggle
– When startup time has passed
• Can generate events to the peripheral event system
30.2 Overview
The Analog Comparator Interface (ACIFB) is able to control a number of Analog Comparators
(AC) with identical behavior. An Analog Comparator compares two voltages and gives a compare
output depending on this comparison.
The ACIFB can be configured in normal mode using each comparator independently or in window
mode using defined comparator pairs to observe a window.
The number of channels implemented is device specific. Refer to the Module Configuration section
at the end of this chapter for details.
747
32142D–06/2013
ATUC64/128/256L3/4U
30.3 Block Diagram
Figure 30-1. ACIFB Block Diagram
30.4 I/O Lines Description
There are two groups of analog comparators, A and B, as shown in Table 30-1. In normal mode,
this grouping does not have any meaning. In window mode, two analog comparators, one from
group A and the corresponding comparator from group B, are paired.
……………...
TRIGGER
EVENTS
IRQ
GCLK
Peripheral Bus ACIFB
Analog
Comparators
PERIPHERAL
EVENT
GENERATION
-
+
AC
INN
INP
CONF0.INSELN
-
+
AC
INN
INP
CONFn.INSELN
FILTER
FILTER
INTERRUPT
GENERATION
CLK_ACIFB
CTRL.ACTEST
TR.ACTESTn
TR.ACTEST0
ACOUT0
ACOUTn
ACP0
ACN0
ACREFN
ACPn
ACNn
Table 30-1. Analog Comparator Groups for Window Mode
Group A Group B Pair Number
AC0 AC1 0
AC2 AC3 1
AC4 AC5 2
AC6 AC7 3
Table 30-2. I/O Line Description
Pin Name Pin Description Type
ACAPn Positive reference pin for Analog Comparator A n Analog
ACANn Negative reference pin for Analog Comparator A n Analog
748
32142D–06/2013
ATUC64/128/256L3/4U
The signal names corresponds to the groups A and B of analog comparators. For normal mode,
the mapping from input signal names in the block diagram to the signal names is given in Table
30-3.
30.5 Product Dependencies
In order to use this module, other parts of the system must be configured correctly, as described
below.
30.5.1 I/O Lines
The ACIFB pins are multiplexed with other peripherals. The user must first program the I/O Controller
to give control of the pins to the ACIFB.
30.5.2 Power Management
If the CPU enters a sleep mode that disables clocks used by the ACIFB, the ACIFB will stop
functioning and resume operation after the system wakes up from sleep mode.
30.5.3 Clocks
The clock for the ACIFB bus interface (CLK_ACIFB) is generated by the Power Manager. This
clock is enabled at reset, and can be disabled in the Power Manager. It is recommended to disable
the ACIFB before disabling the clock, to avoid freezing the ACIFB in an undefined state.
The ACIFB uses a GCLK as clock source for the Analog Comparators. The user must set up this
GCLK at the right frequency. The CLK_ACIFB clock of the interface must be at least 4x the
GCLK frequency used in the comparators. The GCLK is used both for measuring the startup
time of a comparator, and to give a frequency for the comparisons done in Continuous Measurement
Mode, see Section 30.6.
Refer to the Electrical Characteristics chapter for GCLK frequency limitations.
ACBPn Positive reference pin for Analog Comparator B n Analog
ACBNn Negative reference pin for Analog Comparator B n Analog
ACREFN Reference Voltage for all comparators selectable for INN Analog
Table 30-3. Signal Name Mapping
Pin Name Channel Number Normal Mode
ACAP0/ACAN0 0 ACP0/ACN0
ACBP0/ACBN0 1 ACP1/ACN1
ACAP1/ACAN1 2 ACP2/ACN2
ACBP1/ACBN1 3 ACP3/ACN3
ACAP2/ACAN2 4 ACP4/ACN4
ACBP2/ACBN2 5 ACP5/ACN5
ACAP3/ACAN3 6 ACP6/ACN6
ACBP3/ACBN3 7 ACP7/ACN7
Table 30-2. I/O Line Description
Pin Name Pin Description Type
749
32142D–06/2013
ATUC64/128/256L3/4U
30.5.4 Interrupts
The ACIFB interrupt request line is connected to the interrupt controller. Using the ACIFB interrupt
requires the interrupt controller to be programmed first.
30.5.5 Peripheral Events
The ACIFB peripheral events are connected via the Peripheral Event System. Refer to the
Peripheral Event System chapter for details.
30.5.6 Debug Operation
When an external debugger forces the CPU into debug mode, the ACIFB continues normal
operation. If the ACIFB is configured in a way that requires it to be periodically serviced by the
CPU through interrupts or similar, improper operation or data loss may result during debugging.
30.6 Functional Description
The ACIFB is enabled by writing a one to the Control Register Enable bit (CTRL.EN). Additionally,
the comparators must be individually enabled by programming the MODE field in the AC
Configuration Register (CONFn.MODE).
The results from the individual comparators can either be used directly (normal mode), or the
results from two comparators can be grouped to generate a comparison window (window mode).
All comparators need not be in the same mode, some comparators may be in normal mode,
while others are in window mode. There are restrictions on which AC channels that can be
grouped together in a window pair, see Section 30.6.5.
30.6.1 Analog Comparator Operation
Each AC channel can be in one of four different modes, determined by CONFn.MODE:
• Off
• Continuous Measurement Mode (CM)
• User Triggered Single Measurement Mode (UT)
• Event Triggered Single Measurement Mode (ET)
After being enabled, a startup time defined in CTRL.SUT is required before the result of the
comparison is ready. The GCLK is used for measuring the startup time of a comparator,
During the startup time the AC output is not available. When the ACn Ready bit in the Status
Register (SR.ACRDYn) is one, the output of ACn is ready. In window mode the result is available
when both the comparator outputs are ready (SR.ACRDYn=1 and SR.ACRDYn+1=1).
30.6.1.1 Continuous Measurement Mode
In CM, the Analog Comparator is continuously enabled and performing comparisons. This
ensures that the result of the latest comparison is always available in the ACn Current Comparison
Status bit in the Status Register (SR.ACCSn). Comparisons are done on every positive
edge of GCLK.
CM is enabled by writing CONFn.MODE to 1. After the startup time has passed, a comparison is
done and SR is updated. Appropriate peripheral events and interrupts are also generated. New
comparisons are performed continuously until the CONFn.MODE field is written to 0.
750
32142D–06/2013
ATUC64/128/256L3/4U
30.6.1.2 User Triggered Single Measurement Mode
In the UT mode, the user starts a single comparison by writing a one to the User Start Single
Comparison bit (CTRL.USTART). This mode is enabled by writing CONFn.MODE to 2. After the
startup time has passed, a single comparison is done and SR is updated. Appropriate peripheral
events and interrupts are also generated. No new comparisons will be performed.
CTRL.USTART is cleared automatically by hardware when the single comparison has been
done.
30.6.1.3 Event Triggered Single Measurement Mode
This mode is enabled by writing CONFn.MODE to 3 and Peripheral Event Trigger Enable
(CTRL.EVENTEN) to one. The ET mode is similar to the UT mode, the difference is that a
peripheral event from another hardware module causes the hardware to automatically set the
Peripheral Event Start Single Comparison bit (CTRL.ESTART). After the startup time has
passed, a single comparison is done and SR is updated. Appropriate peripheral events and
interrupts are also generated. No new comparisons will be performed. CTRL.ESTART is cleared
automatically by hardware when the single comparison has been done.
30.6.1.4 Selecting Comparator Inputs
Each Analog Comparator has one positive (INP) and one negative (INN) input. The positive
input is fed from an external input pin (ACPn). The negative input can either be fed from an
external input pin (ACNn) or from a reference voltage common to all ACs (ACREFN).
The user selects the input source as follows:
• In normal mode with the Negative Input Select and Positive Input Select fields
(CONFn.INSELN and CONFn.INSELP).
• In window mode with CONFn.INSELN, CONFn.INSELP and CONFn+1.INSELN,
CONFn+1,INSELP. The user must configure CONFn.INSELN and CONFn+1.INSELP to the
same source.
30.6.2 Interrupt Generation
The interrupt request will be generated if the corresponding bit in the Interrupt Mask Register
(IMR) is set. Bits in IMR are set by writing a one to the corresponding bit in the Interrupt Enable
Register (IER), and cleared by writing a one to the corresponding bit in the Interrupt Disable
Register (IDR). The interrupt request remains active until the corresponding bit in ISR is cleared
by writing a one to the corresponding bit in the Interrupt Status Clear Register (ICR).
30.6.3 Peripheral Event Generation
The ACIFB can be set up so that certain comparison results notify other parts of the device via
the Peripheral Event system. Refer to Section 30.6.4.3 and Section 30.6.5.3 for information on
which comparison results can generate events, and how to configure the ACIFB to achieve this.
Zero or one event will be generated per comparison.
30.6.4 Normal Mode
In normal mode all Analog Comparators are operating independently.
30.6.4.1 Normal Mode Output
Each Analog Comparator generates one output ACOUT according to the input voltages on INP
(AC positive input) and INN (AC negative input):
751
32142D–06/2013
ATUC64/128/256L3/4U
• ACOUT = 1 if VINP > VINN
• ACOUT = 0 if VINP < VINN
• ACOUT = 0 if the AC output is not available (SR.ACRDY = 0)
The output can optionally be filtered, as described in Section 30.6.6.
30.6.4.2 Normal Mode Interrupt
The AC channels can generate interrupts. The Interrupt Settings field in the Configuration Register
(CONFn.IS) can be configured to select when the AC will generate an interrupt:
• When VINP > VINN
• When VINP < VINN
• On toggle of the AC output (ACOUT)
• When comparison has been done
30.6.4.3 Normal Mode Peripheral Events
The ACIFB can generate peripheral events according to the configuration of CONFn.EVENN
and CONFn.EVENP.
• When VINP > VINN or
• When VINP < VINN or
• On toggle of the AC output (ACOUT)
30.6.5 Window Mode
In window mode, two ACs (an even and the following odd build up a pair) are grouped.
The negative input of ACn (even) and the positive input of ACn+1 (odd) has to be connected
together externally to the device and are controlled by the Input Select fields in the AC Configuration
Registers (CONFn.INSELN and CONFn+1.INSELP). The positive input of ACn (even) and
the negative input of ACn+1 (odd) can still be configured independently by CONFn.INSELP and
CONFn+1.INSELN, respectively.
752
32142D–06/2013
ATUC64/128/256L3/4U
Figure 30-2. Analog Comparator Interface in Window Mode
30.6.5.1 Window Mode Output
When operating in window mode, each channel generates the same ACOUT outputs as in normal
mode, see Section 30.6.4.1.
Additionally, the ACIFB generates a window mode signal (acwout) according to the common
input voltage to be compared:
• ACWOUT = 1 if the common input voltage is inside the window, VACN(N+1) < Vcommon < VACP(N)
• ACWOUT = 0 if the common input voltage is outside the window, Vcommon < VACN(N+1) or
Vcommon > VACP(N)
• ACWOUT = 0 if the window mode output is not available (SR.ACRDYn=0 or
SR.ACRDYn+1=0)
30.6.5.2 Window Mode Interrupts
When operating in window mode, each channel can generate the same interrupts as in normal
mode, see Section 30.6.4.2.
Additionally, when channels operate in window mode, programming Window Mode Interrupt Settings
in the Window Mode Configuration Register (CONFWn.WIS) can cause interrupts to be
generated when:
• As soon as the common input voltage is inside the window.
• As soon as the common input voltage is outside the window.
• On toggle of the window compare output (ACWOUT).
• When the comparison in both channels in the window pair is ready.
Comparator pair 0
-
+
AC0
Interrupt
Generator
Window
Module
ACOUT0
Peripheral Event
Generator
Window
window event
-
+
AC1
Filter
Filter
SR.ACCS0
SR.WFCS0
ACAP0
ACAN0
ACBP0
COMMON ACWOUT
ACBN0
IRQ
ACOUT1
753
32142D–06/2013
ATUC64/128/256L3/4U
30.6.5.3 Window Mode Peripheral Events
When operating in window mode, each channel can generate the same peripheral events as in
normal mode, see Section 30.6.4.3.
Additionally, when channels operate in window mode, programming Window Mode Event Selection
Source (CONFWn.WEVSRC) can cause peripheral events to be generated when:
• As soon as the common input voltage is inside the window.
• As soon as the common input voltage is outside the window.
• On toggle of the window compare output (ACWOUT)
• Whenever a comparison is ready and the common input voltage is inside the window.
• Whenever a comparison is ready and the common input voltage is outside the window.
• When the comparison in both channels in the window pair is ready.
30.6.6 Filtering
The output of the comparator can be filtered to reduce noise. The filter length is determined by
the Filter Length field in the CONFn register (CONFn.FLEN). The filter samples the Analog
Comparator output at the GCLK frequency for 2CONFn.FLEN samples. A separate counter (CNT)
counts the number of cycles the AC output was one. This filter is deactivated if CONFn.FLEN
equals 0.
If the filter is enabled, the Hysteresis Value field HYS in the CONFn register (CONFn.HYS) can
be used to define a hysteresis value. The hysteresis value should be chosen so that:
The filter function is defined by:
The filtering algorithm is explained in Figure 30-3. 2FLEN measurements are sampled. If the number
of measurements that are zero is less than (2FLEN/2 - HYS), the filtered result is zero. If the
number of measurements that are one is more than (2FLEN/2 + HYS), the filtered result is one.
Otherwise, the result is unchanged.
2FLEN
2 ---------------- HYS
CNT 2FLEN
2 ---------------- + HYS comp = 1
2FLEN
2 ---------------- + HYS CNT 2FLEN
2 ----------------–HYS comp unchanged
CNT 2FLEN
2 ----------------–HYS comp = 0
754
32142D–06/2013
ATUC64/128/256L3/4U
Figure 30-3. The Filtering Algorithm
30.7 Peripheral Event Triggers
Peripheral events from other modules can trigger comparisons in the ACIFB. All channels that
are set up in Event Triggered Single Measurement Mode will be started simultaneously when a
peripheral event is received. Channels that are operating in Continuous Measurement Mode or
User Triggered Single Measurement Mode will be unaffected by the received event. The software
can still operate these channels independently of channels in Event Triggered Single
Measurement Mode.
A peripheral event will trigger one or more comparisons, in normal or window mode.
30.8 AC Test mode
By writing the Analog Comparator Test Mode (CR.ACTEST) bit to one, the outputs from the ACs
are overridden by the value in the Test Register (TR), see Figure 30-1. This is useful for software
development.
2
FLEN
2
FLEN
2
HYS HYS
”Result=0" ”Result=1"
Result =
UNCHANGED
0
755
32142D–06/2013
ATUC64/128/256L3/4U
30.9 User Interface
Note: 1. The reset values for these registers are device specific. Please refer to the Module Configuration section at the end of this
chapter.
Table 30-4. ACIFB Register Memory Map
Offset Register Register Name Access Reset
0x00 Control Register CTRL Read/Write 0x00000000
0x04 Status Register SR Read-only 0x00000000
0x10 Interrupt Enable Register IER Write-only 0x00000000
0x14 Interrupt Disable Register IDR Write-only 0x00000000
0x18 Interrupt Mask Register IMR Read-only 0x00000000
0x1C Interrupt Status Register ISR Read-only 0x00000000
0x20 Interrupt Status Clear Register ICR Write-only 0x00000000
0x24 Test Register TR Read/Write 0x00000000
0x30 Parameter Register PARAMETER Read-only -(1)
0x34 Version Register VERSION Read-only -(1)
0x80 Window0 Configuration Register CONFW0 Read/Write 0x00000000
0x84 Window1 Configuration Register CONFW1 Read/Write 0x00000000
0x88 Window2 Configuration Register CONFW2 Read/Write 0x00000000
0x8C Window3 Configuration Register CONFW3 Read/Write 0x00000000
0xD0 AC0 Configuration Register CONF0 Read/Write 0x00000000
0xD4 AC1 Configuration Register CONF1 Read/Write 0x00000000
0xD8 AC2 Configuration Register CONF2 Read/Write 0x00000000
0xDC AC3 Configuration Register CONF3 Read/Write 0x00000000
0xE0 AC4 Configuration Register CONF4 Read/Write 0x00000000
0xE4 AC5 Configuration Register CONF5 Read/Write 0x00000000
0xE8 AC6 Configuration Register CONF6 Read/Write 0x00000000
0xEC AC7 Configuration Register CONF7 Read/Write 0x00000000
756
32142D–06/2013
ATUC64/128/256L3/4U
30.9.1 Control Register
Name: CTRL
Access Type: Read/Write
Offset: 0x00
Reset Value: 0x00000000
• SUT: Startup Time
Analog Comparator startup time = .
Each time an AC is enabled, the AC comparison will be enabled after the startup time of the AC.
• ACTEST: Analog Comparator Test Mode
0: The Analog Comparator outputs feeds the channel logic in ACIFB.
1: The Analog Comparator outputs are bypassed with the AC Test Register.
• ESTART: Peripheral Event Start Single Comparison
Writing a zero to this bit has no effect.
Writing a one to this bit starts a comparison and can be used for test purposes.
This bit is cleared when comparison is done.
This bit is set when an enabled peripheral event is received.
• USTART: User Start Single Comparison
Writing a zero to this bit has no effect.
Writing a one to this bit starts a Single Measurement Mode comparison.
This bit is cleared when comparison is done.
• EVENTEN: Peripheral Event Trigger Enable
0: A peripheral event will not trigger a comparison.
1: Enable comparison triggered by a peripheral event.
• EN: ACIFB Enable
0: The ACIFB is disabled.
1: The ACIFB is enabled.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
- - - - - - SUT[9:8]
15 14 13 12 11 10 9 8
SUT[7:0]
76543210
ACTEST - ESTART USTART - - -EVENTEN EN
SUT
FGCLK
----------------
757
32142D–06/2013
ATUC64/128/256L3/4U
30.9.2 Status Register
Name: SR
Access Type: Read-only
Offset: 0x04
Reset Value: 0x00000000
• WFCSn: Window Mode Current Status
This bit is cleared when the common input voltage is outside the window.
This bit is set when the common input voltage is inside the window.
• ACRDYn: ACn Ready
This bit is cleared when the AC output (ACOUT) is not ready.
This bit is set when the AC output (ACOUT) is ready, AC is enabled and its startup time is over.
• ACCSn: ACn Current Comparison Status
This bit is cleared when VINP is currently lower than VINN
This bit is set when VINP is currently greater than VINN.
31 30 29 28 27 26 25 24
- - - - WFCS3 WFCS2 WFCS1 WFCS0
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
ACRDY7 ACCS7 ACRDY6 ACCS6 ACRDY5 ACCS5 ACRDY4 ACCS4
76543210
ACRDY3 ACCS3 ACRDY2 ACCS2 ACRDY1 ACCS1 ACRDY0 ACCS0
758
32142D–06/2013
ATUC64/128/256L3/4U
30.9.3 Interrupt Enable Register
Name: IER
Access Type: Write-only
Offset: 0x10
Reset Value: 0x00000000
Writing a zero to a bit in this register has no effect.
Writing a one to a bit in this register will set the corresponding bit in IMR.
31 30 29 28 27 26 25 24
- - - - WFINT3 WFINT2 WFINT1 WFINT0
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
SUTINT7 ACINT7 SUTINT6 ACINT6 SUTINT5 ACINT5 SUTINT4 ACINT4
76543210
SUTINT3 ACINT3 SUTINT2 ACINT2 SUTINT1 ACINT1 SUTINT0 ACINT0
759
32142D–06/2013
ATUC64/128/256L3/4U
30.9.4 Interrupt Disable Register
Name: IDR
Access Type: Write-only
Offset: 0x14
Reset Value: 0x00000000
Writing a zero to a bit in this register has no effect.
Writing a one to a bit in this register will clear the corresponding bit in IMR.
31 30 29 28 27 26 25 24
- - - - WFINT3 WFINT2 WFINT1 WFINT0
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
SUTINT7 ACINT7 SUTINT6 ACINT6 SUTINT5 ACINT5 SUTINT4 ACINT4
76543210
SUTINT3 ACINT3 SUTINT2 ACINT2 SUTINT1 ACINT1 SUTINT0 ACINT0
760
32142D–06/2013
ATUC64/128/256L3/4U
30.9.5 Interrupt Mask Register
Name: IMR
Access Type: Read-only
Offset: 0x18
Reset Value: 0x00000000
• WFINTn: Window Mode Interrupt Mask
0: The corresponding interrupt is disabled.
1: The corresponding interrupt is enabled.
This bit is cleared when the corresponding bit in IDR is written to one.
This bit is set when the corresponding bit in IER is written to one.
• SUTINTn: ACn Startup Time Interrupt Mask
0: The corresponding interrupt is disabled.
1: The corresponding interrupt is enabled.
This bit is cleared when the corresponding bit in IDR is written to one.
This bit is set when the corresponding bit in IER is written to one.
• ACINTn: ACn Interrupt Mask
0: The corresponding interrupt is disabled.
1: The corresponding interrupt is enabled.
This bit is cleared when the corresponding bit in IDR is written to one.
This bit is set when the corresponding bit in IER is written to one.
31 30 29 28 27 26 25 24
- - - - WFINT3 WFINT2 WFINT1 WFINT0
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
SUTINT7 ACINT7 SUTINT6 ACINT6 SUTINT5 ACINT5 SUTINT4 ACINT4
76543210
SUTINT3 ACINT3 SUTINT2 ACINT2 SUTINT1 ACINT1 SUTINT0 ACINT0
761
32142D–06/2013
ATUC64/128/256L3/4U
30.9.6 Interrupt Status Register
Name: ISR
Access Type: Read-only
Offset: 0x1C
Reset Value: 0x00000000
• WFINTn: Window Mode Interrupt Status
0: No Window Mode Interrupt is pending.
1: Window Mode Interrupt is pending.
This bit is cleared when the corresponding bit in ICR is written to one.
This bit is set when the corresponding channel pair operating in window mode generated an interrupt.
• SUTINTn: ACn Startup Time Interrupt Status
0: No Startup Time Interrupt is pending.
1: Startup Time Interrupt is pending.
This bit is cleared when the corresponding bit in ICR is written to one.
This bit is set when the startup time of the corresponding AC has passed.
• ACINTn: ACn Interrupt Status
0: No Normal Mode Interrupt is pending.
1: Normal Mode Interrupt is pending.
This bit is cleared when the corresponding bit in ICR is written to one.
This bit is set when the corresponding channel generated an interrupt.
31 30 29 28 27 26 25 24
- - - - WFINT3 WFINT2 WFINT1 WFINT0
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
SUTINT7 ACINT7 SUTINT6 ACINT6 SUTINT5 ACINT5 SUTINT4 ACINT4
76543210
SUTINT3 ACINT3 SUTINT2 ACINT2 SUTINT1 ACINT1 SUTINT0 ACINT0
762
32142D–06/2013
ATUC64/128/256L3/4U
30.9.7 Interrupt Status Clear Register
Name: ICR
Access Type: Write-only
Offset: 0x20
Reset Value: 0x00000000
Writing a zero to a bit in this register has no effect.
Writing a one to a bit in this register will clear the corresponding bit in ISR and the corresponding interrupt request.
31 30 29 28 27 26 25 24
- - - - WFINT3 WFINT2 WFINT1 WFINT0
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
SUTINT7 ACINT7 SUTINT6 ACINT6 SUTINT5 ACINT5 SUTINT4 ACINT4
76543210
SUTINT3 ACINT3 SUTINT2 ACINT2 SUTINT1 ACINT1 SUTINT0 ACINT0
763
32142D–06/2013
ATUC64/128/256L3/4U
30.9.8 Test Register
Name: TR
Access Type: Read/Write
Offset: 0x24
Reset Value: 0x00000000
• ACTESTn: AC Output Override Value
If CTRL.ACTEST is set, the ACn output is overridden with the value of ACTESTn.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
--------
76543210
ACTEST7 ACTEST6 ACTEST5 ACTEST4 ACTEST3 ACTEST2 ACTEST1 ACTEST0
764
32142D–06/2013
ATUC64/128/256L3/4U
30.9.9 Parameter Register
Name: PARAMETER
Access Type: Read-only
Offset: 0x30
Reset Value: -
• WIMPLn: Window Pair n Implemented
0: Window Pair not implemented.
1: Window Pair implemented.
• ACIMPLn: Analog Comparator n Implemented
0: Analog Comparator not implemented.
1: Analog Comparator implemented.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
- - - - WIMPL3 WIMPL2 WIMPL1 WIMPL0
15 14 13 12 11 10 9 8
--------
76543210
ACIMPL7 ACIMPL6 ACIMPL5 ACIMPL4 ACIMPL3 ACIMPL2 ACIMPL1 ACIMPL0
765
32142D–06/2013
ATUC64/128/256L3/4U
30.9.10 Version Register
Name: VERSION
Access Type: Read-only
Offset: 0x34
Reset Value: -
• VARIANT: Variant Number
Reserved. No functionality associated.
• VERSION: Version Number
Version number of the module. No functionality associated.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
- - - - VARIANT
15 14 13 12 11 10 9 8
- - - - VERSION[11:8]
76543210
VERSION[7:0]
766
32142D–06/2013
ATUC64/128/256L3/4U
30.9.11 Window Configuration Register
Name: CONFWn
Access Type: Read/Write
Offset: 0x80,0x84,0x88,0x8C
Reset Value: 0x00000000
• WFEN: Window Mode Enable
0: The window mode is disabled.
1: The window mode is enabled.
• WEVEN: Window Event Enable
0: Event from awout is disabled.
1: Event from awout is enabled.
• WEVSRC: Event Source Selection for Window Mode
000: Event on acwout rising edge.
001: Event on acwout falling edge.
010: Event on awout rising or falling edge.
011: Inside window.
100: Outside window.
101: Measure done.
110-111: Reserved.
• WIS: Window Mode Interrupt Settings
00: Window interrupt as soon as the input voltage is inside the window.
01: Window interrupt as soon as the input voltage is outside the window.
10: Window interrupt on toggle of window compare output.
11: Window interrupt when evaluation of input voltage is done.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
- - - - - - - WFEN
15 14 13 12 11 10 9 8
- - - - WEVEN WEVSRC
7654321 0
- - - - - - WIS
767
32142D–06/2013
ATUC64/128/256L3/4U
30.9.12 AC Configuration Register
Name: CONFn
Access Type: Read/Write
Offset: 0xD0,0xD4,0xD8,0xDC,0xE0,0xE4,0xE8,0xEC
Reset Value: 0x00000000
• FLEN: Filter Length
000: Filter off.
n: Number of samples to be averaged =2n
.
• HYS: Hysteresis Value
0000: No hysteresis.
1111: Max hysteresis.
• EVENN: Event Enable Negative
0: Do not output event when ACOUT is zero.
1: Output event when ACOUT is zero.
• EVENP: Event Enable Positive
0: Do not output event when ACOUT is one.
1: Output event when ACOUT is one.
• INSELP: Positive Input Select
00: ACPn pin selected.
01: Reserved.
10: Reserved.
11: Reserved.
• INSELN: Negative Input Select
00: ACNn pin selected.
01: ACREFN pin selected.
10: Reserved.
11: Reserved.
• MODE: Mode
00: Off.
01: Continuous Measurement Mode.
10: User Triggered Single Measurement Mode.
11: Event Triggered Single Measurement Mode.
31 30 29 28 27 26 25 24
- FLEN HYS
23 22 21 20 19 18 17 16
- - - - - - EVENP EVENN
15 14 13 12 11 10 9 8
- - - - INSELP INSELN
7654321 0
- - MODE - - IS
768
32142D–06/2013
ATUC64/128/256L3/4U
• IS: Interrupt Settings
00: Comparator interrupt when as VINP > VINN.
01: Comparator interrupt when as VINP < VINN.
10: Comparator interrupt on toggle of Analog Comparator output.
11: Comparator interrupt when comparison of VINP and VINN is done.
769
32142D–06/2013
ATUC64/128/256L3/4U
30.10 Module Configuration
The specific configuration for each ACIFB instance is listed in the following tables.The module
bus clocks listed here are connected to the system bus clocks. Refer to the Power Manager
chapter for details.
Table 30-5. ACIFB Configuration
Feature ACIFB
Number of channels 8
Table 30-6. ACIFB Clocks
Clock Name Description
CLK_ACIFB Clock for the ACIFB bus interface
GCLK The generic clock used for the ACIFB is GCLK4
Table 30-7. Register Reset Values
Register Reset Value
VERSION 0x00000202
PARAMETER 0x000F00FF
770
32142D–06/2013
ATUC64/128/256L3/4U
31. Capacitive Touch Module (CAT)
Rev: 4.0.0.0
31.1 Features
• QTouch® method allows N touch sensors to be implemented using 2N physical pins
• QMatrix method allows X by Y matrix of sensors to be implemented using (X+2Y) physical pins
• One autonomous QTouch sensor operates without DMA or CPU intervention
• All QTouch sensors can operate in DMA-driven mode without CPU intervention
• External synchronization to reduce 50 or 60 Hz mains interference
• Spread spectrum sensor drive capability
31.2 Overview
The Capacitive Touch Module (CAT) senses touch on external capacitive touch sensors. Capacitive
touch sensors use no external mechanical components, and therefore demand less
maintenance in the user application.
The module implements the QTouch method of capturing signals from capacitive touch sensors.
The QTouch method is generally suitable for small numbers of sensors since it requires 2 physical
pins per sensor. The module also implements the QMatrix method, which is more
appropriate for large numbers of sensors since it allows an X by Y matrix of sensors to be implemented
using only (X+2Y) physical pins. The module allows methods to function together, so N
touch sensors and an X by Y matrix of sensors can be implemented using (2N+X+2Y) physical
pins.
In addition, the module allows sensors using the QTouch method to be divided into two groups.
Each QTouch group can be configured with different properties. This eases the implementation
of multiple kinds of controls such as push buttons, wheels, and sliders.
All of the QTouch sensors can operate in a DMA-driven mode, known as DMATouch, that allows
detection of touch without CPU intervention. The module also implements one autonomous
QTouch sensor that is capable of detecting touch without DMA or CPU intervention. This allows
proximity or activation detection in low-power sleep modes.
771
32142D–06/2013
ATUC64/128/256L3/4U
31.3 Block Diagram
Figure 31-1. CAT Block Diagram
31.4 I/O Lines Description
Interface
Registers Peripheral Bus
Finite State
Machine Capacitor
Charge and
Discharge
Sequence
Generator
Counters
CSAn
SMP
I/O
Controller Pins
Discharge
Current
Sources
DIS
Yn
Analog
Comparators
Peripheral
Event System
CLK_CAT
Analog
Comparator
Interface
SYNC
Capacitive Touch Module (CAT)
CSBn
GCLK_CAT VDIVEN
NOTE:
Italicized
signals and
blocks are
used only for
QMatrix
operation
Table 31-1. I/O Lines Description
Name Description Type
CSAn Capacitive sense A line n I/O
CSBn Capacitive sense B line n I/O
DIS Discharge current control (only used for QMatrix) Analog
772
32142D–06/2013
ATUC64/128/256L3/4U
31.5 Product Dependencies
In order to use the CAT module, other parts of the system must be configured correctly, as
described below.
31.5.1 I/O Lines
The CAT pins may be multiplexed with other peripherals. The user must first program the I/O
Controller to give control of the pins to the CAT module. In QMatrix mode, the Y lines must be
driven by the CAT and analog comparators sense the voltage on the Y lines. Thus, the CAT (not
the Analog Comparator Interface) must be the selected function for the Y lines in the I/O
Controller.
By writing ones and zeros to bits in the Pin Mode Registers (PINMODEx), most of the CAT pins
can be individually selected to implement the QTouch method or the QMatrix method. Each pin
has a different name and function depending on whether it is implementing the QTouch method
or the QMatrix method. The following table shows the pin names for each method and the bits in
the PINMODEx registers which control the selection of the QTouch or QMatrix method.
SMP SMP line (only used for QMatrix) Output
SYNC Synchronize signal Input
VDIVEN Voltage divider enable (only used for QMatrix) Output
Table 31-1. I/O Lines Description
Name Description Type
Table 31-2. Pin Selection Guide
CAT Module Pin
Name
QTouch Method
Pin Name
QMatrix Method Pin
Name
Selection Bit in
PINMODEx Register
CSA0 SNS0 X0 SP0
CSB0 SNSK0 X1 SP0
CSA1 SNS1 Y0 SP1
CSB1 SNSK1 YK0 SP1
CSA2 SNS2 X2 SP2
CSB2 SNSK2 X3 SP2
CSA3 SNS3 Y1 SP3
CSB3 SNSK3 YK1 SP3
CSA4 SNS4 X4 SP4
CSB4 SNSK4 X5 SP4
CSA5 SNS5 Y2 SP5
CSB5 SNSK5 YK2 SP5
CSA6 SNS6 X6 SP6
CSB6 SNSK6 X7 SP6
CSA7 SNS7 Y3 SP7
CSB7 SNSK7 YK3 SP7
CSA8 SNS8 X8 SP8
773
32142D–06/2013
ATUC64/128/256L3/4U
31.5.2 Clocks
The clock for the CAT module, CLK_CAT, is generated by the Power Manager (PM). This clock
is turned on by default, and can be enabled and disabled in the PM. The user must ensure that
CLK_CAT is enabled before using the CAT module.
QMatrix operations also require the CAT generic clock, GCLK_CAT. This generic clock is generated
by the System Control Interface (SCIF), and is shared between the CAT and the Analog
Comparator Interface. The user must ensure that the GCLK_CAT is enabled in the SCIF before
using QMatrix functionality in the CAT module. For proper QMatrix operation, the frequency of
GCLK_CAT must be less than half the frequency of CLK_CAT. If only QTouch functionality is
used, then GCLK_CAT is unnecessary.
31.5.3 Interrupts
The CAT interrupt request line is connected to the interrupt controller. Using CAT interrupts
requires the interrupt controller to be programmed first.
31.5.4 Peripheral Events
The CAT peripheral events are connected via the Peripheral Event System. Refer to the Peripheral
Event System chapter for details.
31.5.5 Peripheral Direct Memory Access
The CAT module provides handshake capability for a Peripheral DMA Controller. One handshake
controls transfers from the Acquired Count Register (ACOUNT) to memory. A second
handshake requests burst lengths for each (X,Y) pair to the Matrix Burst Length Register
CSB8 SNSK8 X9 SP8
CSA9 SNS9 Y4 SP9
CSB9 SNSK9 YK4 SP9
CSA10 SNS10 X10 SP10
CSB10 SNSK10 X11 SP10
CSA11 SNS11 Y5 SP11
CSB11 SNSK11 YK5 SP11
CSA12 SNS12 X12 SP12
CSB12 SNSK12 X13 SP12
CSA13 SNS13 Y6 SP13
CSB13 SNSK13 YK6 SP13
CSA14 SNS14 X14 SP14
CSB14 SNSK14 X15 SP14
CSA15 SNS15 Y7 SP15
CSB15 SNSK15 YK7 SP15
CSA16 SNS16 X16 SP16
CSB16 SNSK16 X17 SP16
Table 31-2. Pin Selection Guide
CAT Module Pin
Name
QTouch Method
Pin Name
QMatrix Method Pin
Name
Selection Bit in
PINMODEx Register
774
32142D–06/2013
ATUC64/128/256L3/4U
(MBLEN) when using the QMatrix acquisition method. Two additional handshakes support DMATouch
by regulating transfers from memory to the DMATouch State Write Register (DMATSW)
and from the DMATouch State Read Register (DMATSR) to memory. The Peripheral DMA Controller
must be configured properly and enabled in order to perform direct memory access
transfers to/from the CAT module.
31.5.6 Analog Comparators
When the CAT module is performing QMatrix acquisition, it requires that on-chip analog comparators
be used as part of the process. These analog comparators are not controlled directly by
the CAT module, but by a separate Analog Comparator (AC) Interface. This interface must be
configured properly and enabled before the CAT module is used. This includes configuring the
generic clock input for the analog comparators to the proper sampling frequency.
The CAT will automatically use the negative peripheral events from the AC Interface on every Y
pin in QMatrix mode. When QMatrix acquisition is used the analog comparator corresponding to
the selected Y pins must be enabled and converting continuously, using the Y pin as the positive
reference and the ACREFN as negative reference.
31.5.7 Debug Operation
When an external debugger forces the CPU into debug mode, the CAT continues normal operation.
If the CAT is configured in a way that requires it to be periodically serviced by the CPU
through interrupts or similar, improper operation or data loss may result during debugging.
31.6 Functional Description
31.6.1 Acquisition Types
The CAT module can perform several types of QTouch acquisition from capacitive touch sensors:
autonomous QTouch (one sensor only), DMATouch, QTouch group A, and QTouch group
B. The CAT module can also perform QMatrix acquisition. Each type of acquisition has an associated
set of pin selection and configuration registers that allow a large degree of flexibility.
The following schematic diagrams show typical hardware connections for QTouch and QMatrix
sensors, respectively:
Figure 31-2. CAT Touch Connections
AVR32 Chip
QTouch
Sensor
Cs (Sense Capacitor)
SNSKn
SNSn
775
32142D–06/2013
ATUC64/128/256L3/4U
Figure 31-3. CAT Matrix Connections
In order to use the autonomous QTouch detection capability, the user must first set up the
Autonomous Touch Pin Select Register (ATPINS) and Autonomous/DMA Touch Configuration
Registers (ATCFG0 through 3) with appropriate values. The module can then be enabled using
the Control Register (CTRL). After the module is enabled, the module will acquire data from the
autonomous QTouch sensor and use it to determine whether the sensor is activated. The
active/inactive status of the autonomous QTouch sensor is reported in the Status Register (SR),
and it is also possible to configure the CAT to generate an interrupt whenever the status
changes. The module will continue acquiring autonomous QTouch sensor data and updating
autonomous QTouch status until the module is disabled or reset.
In order to use the DMATouch capability, it is first necessary to set up the pin mode registers
(PINMODE0, PINMODE1, and PINMODE2) so that the desired pins are specified as DMATouch.
The Autonomous/DMA Touch Configuration Registers (ATCFG0 through 3) must also be
configured with appropriate values. One channel of the Peripheral DMA Controller must be set
up to transfer state words from a block of memory to the DMATSW register, and another channel
must be set up to transfer state words from the DMATSR register back to the same block of
memory. The module can then be enabled using the CTRL register. After the module is enabled,
the module will acquire count values from each DMATouch sensor. Once the module has
acquired a count value for a sensor, it will use a handshake interface to signal the Peripheral
DMA controller to transfer a state word to the DMATSW register. The module will use the count
value to update the state word, and then the updated state word will be transferred to the
DMATSR register. Another handshake interface will signal the Peripheral DMA controller to
transfer the contents of the DMATSR register back to memory. The status of the DMATouch
sensors can be determined at any time by reading the DMATouch Sensor Status Register
(DMATSS).
AVR32 Chip
Cs0 (Sense Capacitor)
X3
YK0
X6 QMatrix Sensor Array
X7
X2
Y0
YK1
Y1 Cs1 (Sense Capacitor)
SMP
Rsmp1 Rsmp0
VDIVEN
DIS
Rdis
ACREFN
Ra
Rb
NOTE: If the CAT internal
current sources will be enabled,
the SMP signal and Rsmp
resistors should NOT be included
in the design. If the CAT internal
current sources will NOT be
enabled, the DIS signal and Rdis
resistor should NOT be included
in the design.
776
32142D–06/2013
ATUC64/128/256L3/4U
In order to use the QMatrix, QTouch group A, or QTouch group B acquisition capabilities, it is
first necessary to set up the pin mode registers (PINMODE0, PINMODE1, and PINMODE2) and
configuration registers (MGCFG0, MGCFG1, TGACFG0, TGACFG1, TGBCFG0, and
TGBCFG1). The module must then be enabled using the CTRL register. In order to initiate
acquisition, it is necessary to perform a write to the Acquisition Initiation and Selection Register
(AISR). The specific value written to AISR determines which type of acquisition will be performed:
QMatrix, QTouch group A, or QTouch group B. The CPU can initiate acquisition by
writing to the AISR.
While QMatrix, QTouch group A, or QTouch group B acquisition is in progress, the module collects
count values from the sensors and buffers them. Availability of acquired count data is
indicated by the Acquisition Ready (ACREADY) bit in the Status Register (SR). The CPU or the
Peripheral DMA Controller can then read the acquired counts from the ACOUNT register.
Because the CAT module is configured with Peripheral DMA Controller capability that can transfer
data from memory to MBLEN and from ACOUNT to memory, the Peripheral DMA Controller
can perform long acquisition sequences and store results in memory without CPU intervention.
31.6.2 Prescaler and Charge Length
Each QTouch acquisition type (autonomous QTouch, QTouch group A, and QTouch group B)
has its own prescaler. Each QTouch prescaler divides down the CLK_CAT clock to an appropriate
sampling frequency for its particular acquisition type. Typical frequencies are 1MHz for
QTouch acquisition and 4MHz for QMatrix burst timing control.
Each QTouch prescaler is controlled by the DIV field in the appropriate Configuration Register 0
(ATCFG0, TGACFG0, or TGBCFG0). The QMatrix burst timing prescaler is controlled by the
DIV field in MGCFG0. Each prescaler uses the following formula to generate the sampling clock:
Sampling clock = CLK_CAT / (2(DIV+1))
The capacitive sensor charge length, discharge length, and settle length can be determined for
each acquisition type using the CHLEN, DILEN, and SELEN fields in Configuration Registers 0
and 1. The lengths are specified in terms of prescaler clocks. In addition, the QMatrix Cx discharge
length can be determined using the CXDILEN field in MGCFG2.
For QMatrix acquisition, the duration of CHLEN should not be set to the same value as the
period of any periodic signal on any other pin. If the duration of CHLEN is the same as the
period of a signal on another pin, it is likely that the other signal will significantly affect measurements
due to stray capacitive coupling. For example, if a 1 MHz signal is generated on another
pin of the chip, then CHLEN should not be 1 microsecond.
For the QMatrix method, burst and capture lengths are set for each (X,Y) pair by writing the
desired length values to the MBLEN register. The write must be done before each X line can
start its acquisition and is indicated by the status bit MBLREQ in the Status Register (SR). A
DMA handshake interface is also connected to this status bit to reduce CPU overhead during
QMatrix acquisitions.
Four burst lengths (BURST0..3) can be written at one time into the MBLEN register. If the current
configuration uses Y lines larger than Y3 the register has to be written a second time. The
first write to MBLEN specifies the burst length for Y lines 0 to 3 in the BURST0 to BURST3 fields,
respectively. The second write specifies the burst length for Y lines 4 to 7 in fields BURST0 to
BURST3, respectively, and so on.
777
32142D–06/2013
ATUC64/128/256L3/4U
The Y and YK pins remain clamped to ground apart from the specified number of burst pulses,
when charge is transferred and captured into the sampling capacitor.
31.6.3 Capacitive Count Acquisition
For the QMatrix, QTouch group A, and QTouch group B types of acquisition, the module
acquires count values from the sensors, buffers them, and makes them available for reading in
the ACOUNT register. Further processing of the count values must be performed by the CPU.
When the module performs QMatrix acquisition using multiple Y lines, it starts the capture for
each Y line at the appropriate time in the burst sequence so that all captures finish simultaneously.
For example, suppose that an acquisition is performed on Y0 and Y1 with BURST0=53
and BURST1=60. The module will first toggle the X line 7 times while capturing on Y1 while Y0
and YK0 are clamped to ground. The module will then toggle the X line 53 times while capturing
on both Y1 and Y0.
31.6.4 Autonomous QTouch and DMATouch
For autonomous QTouch and DMATouch, a complete detection algorithm is implemented within
the CAT module. The additional parameters needed to control the detection algorithm must be
specified by the user in the ATCFG2 and ATCFG3 registers.
Autonomous QTouch and DMATouch sensitivity and out-of-touch sensitivity can be adjusted
with the SENSE and OUTSENS fields, respectively, in ATCFG2. Each field accepts values from
one to 255 where 255 is the least sensitive setting. The value in the OUTSENS field should be
smaller than the value in the SENSE field.
To avoid false positives a detect integration filtering technique can be used. The number of successive
detects required is specified in the FILTER field of the ATCFG2 register.
To compensate for changes in capacitance the CAT can recalibrate the autonomous QTouch
sensor periodically. The timing of this calibration is done with the NDRIFT and PDRIFT fields in
the Configuration register, ATCFG3. It is recommended that the PDRIFT value is smaller than
the NDRIFT value.
The autonomous QTouch sensor and DMATouch sensors will also recalibrate if the count value
goes too far positive beyond a threshold. This positive recalibration threshold is specified by the
PTHR field in the ATCFG3 register.
The following block diagram shows the sequence of acquisition and processing operations used
by the CAT module. The AISR written bit is internal and not visible in the user interface.
778
32142D–06/2013
ATUC64/128/256L3/4U
Figure 31-4. CAT Acquisition and Processing Sequence
31.6.5 Spread Spectrum Sensor Drive
To reduce electromagnetic compatibility issues, the capacitive sensors can be driven with a
spread spectrum signal. To enable spread spectrum drive for a specific acquisition type, the
user must write a one to the SPREAD bit in the appropriate Configuration Register 1 (MGCFG1,
ATCFG1, TGACFG1, or TGBCFG1).
During spread spectrum operation, the length of each pulse within a burst is varied in a deterministic
pattern, so that the exact same burst pattern is used for a specific burst length. The
maximum spread is determined by the MAXDEV field in the Spread Spectrum Configuration
Register (SSCFG) register. The prescaler divisor is varied in a sawtooth pattern from
(2(DIV+1))-MAXDEV to (2(DIV+1))+MAXDEV and then back to (2(DIV+1))-MAXDEV. For example,
if DIV is 2 and MAXDEV is 3, the prescaler divisor will have the following sequence: 6, 7, 8,
Idle
Acquire
autonomous
touch count
Acquire counts
Update
autonomous
touch detection
algorithm
Wait for all
acquired counts
to be transferred
AISR written flag set?
No Yes
Clear AISR
written flag
No Yes
Autonomous touch
enabled (ATEN)?
779
32142D–06/2013
ATUC64/128/256L3/4U
9, 3, 4, 5, 6, 7, 8, 9, 3, 4, etc. MAXDEV must not exceed the value of (2(DIV+1)), or undefined
behavior will occur.
31.6.6 Synchronization
To prevent interference from the 50 or 60 Hz mains line the CAT can trigger acquisition on the
SYNC signal. The SYNC signal should be derived from the mains line. The acquisition will trigger
on a falling edge of this signal. To enable synchronization for a specific acquisition type, the
user must write a one to the SYNC bit in the appropriate Configuration Register 1 (MGCFG1,
ATCFG1, TGACFG1, or TGBCFG1).
For QMatrix acquisition, all X lines must be sampled at a specific phase of the noise signal for
the synchronization to be effective. This can be accomplished by the synchronization timer,
which is enabled by writing a non-zero value to the SYNCTIM field in the MGCFG2 register. This
ensures that the start of the acquisition of each X line is spaced at regular intervals, defined by
the SYNCTIM field.
31.6.7 Resistive Drive
By default, the CAT pins are driven with normal I/O drive properties. Some of the CSA and CSB
pins can optionally drive with a 1k output resistance for improved EMC. The pins that have this
capability are listed in the Module Configuration section.
31.6.8 Discharge Current Sources
The device integrates discharge current sources, which can be used to discharge the sampling
capacitors during the QMatrix measurement phase. The discharge current sources are enabled
by writing the GLEN bit in the Discharge Current Source (DICS) register to one. This enables an
internal reference voltage, which can be either the internal 1.1V band gap voltage or VDDIO/3,
as selected by the INTVREFSEL bit in the DICS register. If the DICS.INTREFSEL bit is one, the
reference voltage is applied across an internal resistor, Rint. Otherwise, the voltage is applied to
the DIS pin, and an external reference resistor must be connected between DIS and ground.
The nominal discharge current is given by the following formula, where Vref is the reference voltage,
Rref is the value of the reference resistor, trim is the value written to the DICS.TRIM field,
and k is a constant of proportionality:
I = (Vref/Rref)*(1+(k*trim))
The values for the internal reference resistor, Rint, and the constant, k, may be found in the Electrical
Characteristics section. The nominal discharge current may be programmed between 2
and 20 µA. The reference current can be fine-tuned by adjusting the trim value in the DICS.TRIM
field.
The reference current is mirrored to each Y-pin if the corresponding bit is written to one in the
DICS.SOURCES field.
31.6.9 Voltage Divider Enable (VDIVEN) Capability
In many QMatrix applications, the sense capacitors will be charged to 50 mV or more and the
negative reference pin (ACREFN) of the analog comparators can be tied directly to ground. In
that case, the relatively small input offset voltage of the comparators will not cause acquisition
problems. However, in certain specialized QMatrix applications such as interpolated touch
screens, it may be desirable for the sense capacitors to be charged to less than 25 mV. When
such small voltages are used on the sense capacitors, the input offset voltage of the comparators
becomes an issue and can cause QMatrix acquisition problems.
780
32142D–06/2013
ATUC64/128/256L3/4U
Problems with QMatrix acquisition of small sense capacitor voltages can be solved by connecting
the negative reference pin (ACREFN) to a voltage divider that produces a small positive
voltage (20 mV, typically) to cancel any negative input offset voltage. With a 3.3V supply, recommended
values for the voltage divider are Ra (resistor from positive supply to ACREFN) of 8200
ohm and Rb (resistor from ACREFN to ground) of 50 ohm. These recommended values will produce
20 mV on the ACREFN pin, which should generally be enough to compensate for the
worst-case negative input offset of the analog comparators.
Unfortunately, such a voltage divider constantly draws a small current from the power supply,
reducing battery life in portable applications. In order to prevent this constant power drain, the
CAT module provides a voltage divider enable pin (VDIVEN) that can be used for driving the
voltage divider. The VDIVEN pin provides power to the voltage divider only when the comparators
are actually performing QMatrix comparisons. When the comparators are inactive, the
VDIVEN output is zero. This minimizes the power consumed by the voltage divider.
781
32142D–06/2013
ATUC64/128/256L3/4U
31.7 User Interface
Table 31-3. CAT Register Memory Map
Offset Register Register Name Access Reset
0x00 Control Register CTRL Read/Write 0x00000000
0x04 Autonomous Touch Pin Selection Register ATPINS Read/Write 0x00000000
0x08 Pin Mode Register 0 PINMODE0 Read/Write 0x00000000
0x0C Pin Mode Register 1 PINMODE1 Read/Write 0x00000000
0x10 Autonomous/DMA Touch Configuration Register 0 ATCFG0 Read/Write 0x00000000
0x14 Autonomous/DMA Touch Configuration Register 1 ATCFG1 Read/Write 0x00000000
0x18 Autonomous/DMA Touch Configuration Register 2 ATCFG2 Read/Write 0x00000000
0x1C Autonomous/DMA Touch Configuration Register 3 ATCFG3 Read/Write 0x00000000
0x20 Touch Group A Configuration Register 0 TGACFG0 Read/Write 0x00000000
0x24 Touch Group A Configuration Register 1 TGACFG1 Read/Write 0x00000000
0x28 Touch Group B Configuration Register 0 TGBCFG0 Read/Write 0x00000000
0x2C Touch Group B Configuration Register 1 TGBCFG1 Read/Write 0x00000000
0x30 Matrix Group Configuration Register 0 MGCFG0 Read/Write 0x00000000
0x34 Matrix Group Configuration Register 1 MGCFG1 Read/Write 0x00000000
0x38 Matrix Group Configuration Register 2 MGCFG2 Read/Write 0x00000000
0x3C Status Register SR Read-only 0x00000000
0x40 Status Clear Register SCR Write-only -
0x44 Interrupt Enable Register IER Write-only -
0x48 Interrupt Disable Register IDR Write-only -
0x4C Interrupt Mask Register IMR Read-only 0x00000000
0x50 Acquisition Initiation and Selection Register AISR Read/Write 0x00000000
0x54 Acquired Count Register ACOUNT Read-only 0x00000000
0x58 Matrix Burst Length Register MBLEN Write-only -
0x5C Discharge Current Source Register DICS Read/Write 0x00000000
0x60 Spread Spectrum Configuration Register SSCFG Read/Write 0x00000000
0x64 CSA Resistor Control Register CSARES Read/Write 0x00000000
0x68 CSB Resistor Control Register CSBRES Read/Write 0x00000000
0x6C Autonomous Touch Base Count Register ATBASE Read-only 0x00000000
0x70 Autonomous Touch Current Count Register ATCURR Read-only 0x00000000
0x74 Pin Mode Register 2 PINMODE2 Read/Write 0x00000000
0x78 DMATouch State Write Register DMATSW Write-only 0x00000000
0x7C DMATouch State Read Register DMATSR Read-only 0x00000000
0x80 Analog Comparator Shift Offset Register 0 ACSHI0 Read/Write 0x00000000
0x84 Analog Comparator Shift Offset Register 1 ACSHI1 Read/Write 0x00000000
0x88 Analog Comparator Shift Offset Register 2 ACSHI2 Read/Write 0x00000000
782
32142D–06/2013
ATUC64/128/256L3/4U
Note: 1. The reset value for this register is device specific. Please refer to the Module Configuration section at the end of this chapter.
0x8C Analog Comparator Shift Offset Register 3 ACSHI3 Read/Write 0x00000000
0x90 Analog Comparator Shift Offset Register 4 ACSHI4 Read/Write 0x00000000
0x94 Analog Comparator Shift Offset Register 5 ACSHI5 Read/Write 0x00000000
0x98 Analog Comparator Shift Offset Register 6 ACSHI6 Read/Write 0x00000000
0x9C Analog Comparator Shift Offset Register 7 ACSHI7 Read/Write 0x00000000
0xA0 DMATouch Sensor Status Register DMATSS Read-only 0x00000000
0xF8 Parameter Register PARAMETER Read-only -(1)
0xFC Version Register VERSION Read-only -(1)
Table 31-3. CAT Register Memory Map
Offset Register Register Name Access Reset
783
32142D–06/2013
ATUC64/128/256L3/4U
31.7.1 Control Register
Name: CTRL
Access Type: Read/Write
Offset: 0x00
Reset Value: 0x00000000
• SWRST: Software reset
Writing a zero to this bit has no effect.
Writing a one to this bit resets the module. The module will be disabled after the reset.
This bit always reads as zero.
• EN: Module enable
0: Module is disabled.
1: Module is enabled.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
--------
76543210
SWRST - - - - - - EN
784
32142D–06/2013
ATUC64/128/256L3/4U
31.7.2 Autonomous Touch Pin Selection Register
Name: ATPINS
Access Type: Read/Write
Offset: 0x04
Reset Value: 0x00000000
• ATEN: Autonomous Touch Enable
0: Autonomous QTouch acquisition and detection is disabled.
1: Autonomous QTouch acquisition and detection is enabled using the sense pair specified in ATSP.
• ATSP: Autonomous Touch Sense Pair
Selects the sense pair that will be used by the autonomous QTouch sensor. A value of n will select sense pair n (CSAn and
CSBn pins).
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
- - - - - - - ATEN
76543210
- - - ATSP
785
32142D–06/2013
ATUC64/128/256L3/4U
31.7.3 Pin Mode Registers 0, 1, and 2
Name: PINMODE0, PINMODE1, and PINMODE2
Access Type: Read/Write
Offset: 0x08, 0x0C, 0x74
Reset Value: 0x00000000
• SP: Sense Pair Mode Selection
Each SP[n] bit determines the operation mode of sense pair n (CSAn and CSBn pins). The (PINMODE2.SP[n]
PINMODE1.SP[n] PINMODE0.SP[n]) bits have the following definitions:
000: Sense pair n disabled.
001: Sense pair n is assigned to QTouch Group A.
010: Sense pair n is assigned to QTouch Group B.
011: Sense pair n is assigned to the QMatrix Group.
100: Sense pair n is assigned to the DMATouch Group.
101: Reserved.
110: Reserved.
111: Reserved.
31 30 29 28 27 26 25 24
-
23 22 21 20 19 18 17 16
- SP[16]
15 14 13 12 11 10 9 8
SP[15:8]
76543210
SP[7:0]
786
32142D–06/2013
ATUC64/128/256L3/4U
31.7.4 Autonomous/DMA Touch Configuration Register 0
Name: ATCFG0
Access Type: Read/Write
Offset: 0x10
Reset Value: 0x00000000
• DIV: Clock Divider
The prescaler is used to ensure that the CLK_CAT clock is divided to around 1 MHz to produce the sampling clock.The
prescaler uses the following formula to generate the sampling clock:
Sampling clock = CLK_CAT / (2(DIV+1))
• CHLEN: Charge Length
For the autonomous QTouch sensor and DMATouch sensors, specifies how many sample clock cycles should be used for
transferring charge to the sense capacitor.
• SELEN: Settle Length
For the autonomous QTouch sensor and DMATouch sensors, specifies how many sample clock cycles should be used for
settling after charge transfer.
31 30 29 28 27 26 25 24
DIV[15:8]
23 22 21 20 19 18 17 16
DIV[7:0]
15 14 13 12 11 10 9 8
CHLEN
76543210
SELEN
787
32142D–06/2013
ATUC64/128/256L3/4U
31.7.5 Autonomous/DMA Touch Configuration Register 1
Name: ATCFG1
Access Type: Read/Write
Offset: 0x14
Reset Value: 0x00000000
• DISHIFT: Discharge Shift
For the autonomous QTouch sensor and DMATouch sensors, specifies how many bits the DILEN field should be shifted before
using it to determine the discharge time.
• SYNC: Sync Pin
For the autonomous QTouch sensor and DMATouch sensors, specifies that acquisition shall begin when a falling edge is
received on the SYNC line.
• SPREAD: Spread Spectrum Sensor Drive
For the autonomous QTouch sensor and DMATouch sensors, specifies that spread spectrum sensor drive shall be used.
• DILEN: Discharge Length
For the autonomous QTouch sensor and DMATouch sensors, specifies how many sample clock cycles the CAT should use to
discharge the capacitors before charging them.
• MAX: Maximum Count
For the autonomous QTouch sensor and DMATouch sensors, specifies how many counts the maximum acquisition should be.
31 30 29 28 27 26 25 24
- DISHIFT - SYNC SPREAD
23 22 21 20 19 18 17 16
DILEN
15 14 13 12 11 10 9 8
MAX[15:8]
76543210
MAX[7:0]
788
32142D–06/2013
ATUC64/128/256L3/4U
31.7.6 Autonomous/DMA Touch Configuration Register 2
Name: ATCFG2
Access Type: Read/Write
Offset: 0x18
Reset Value: 0x00000000
• FILTER: Autonomous Touch Filter Setting
For the autonomous QTouch sensor and DMATouch sensors, specifies how many positive detects in a row the CAT needs to
have on the sensor before reporting it as a touch. A FILTER value of 0 is not allowed and will result in undefined behavior.
• OUTSENS: Out-of-Touch Sensitivity
For the autonomous QTouch sensor and DMATouch sensors, specifies how sensitive the out-of-touch detector should be.
• SENSE: Sensitivity
For the autonomous QTouch sensor and DMATouch sensors, specifies how sensitive the touch detector should be.
31 30 29 28 27 26 25 24
-
23 22 21 20 19 18 17 16
- FILTER
15 14 13 12 11 10 9 8
OUTSENS
76543210
SENSE
789
32142D–06/2013
ATUC64/128/256L3/4U
31.7.7 Autonomous/DMA Touch Configuration Register 3
Name: ATCFG3
Access Type: Read/Write
Offset: 0x1C
Reset Value: 0x00000000
• PTHR: Positive Recalibration Threshold
For the autonomous QTouch sensor and DMATouch sensors, specifies how far a sensor’s signal must move in a positive
direction from the reference in order to cause a recalibration.
• PDRIFT: Positive Drift Compensation
For the autonomous QTouch sensor and DMATouch sensors, specifies how often a positive drift compensation should be
performed. When this field is zero, positive drift compensation will never be performed. When this field is non-zero, the positive
drift compensation time interval is given by the following formula:
Tpdrift = PDRIFT * 65536 * (sample clock period)
• NDRIFT: Negative Drift Compensation
For the autonomous QTouch sensor and DMATouch sensors, specifies how often a negative drift compensation should be
performed. When this field is zero, negative drift compensation will never be performed. When this field is non-zero, the negative
drift compensation time interval is given by the following formula:
Tndrift = NDRIFT * 65536 * (sample clock period)
With the typical sample clock frequency of 1 MHz, PDRIFT and NDRIFT can be set from 0.066 seconds to 16.7 seconds
with 0.066 second resolution.
31 30 29 28 27 26 25 24
-
23 22 21 20 19 18 17 16
PTHR
15 14 13 12 11 10 9 8
PDRIFT
76543210
NDRIFT
790
32142D–06/2013
ATUC64/128/256L3/4U
31.7.8 Touch Group x Configuration Register 0
Name: TGxCFG0
Access Type: Read/Write
Offset: 0x20, 0x28
Reset Value: 0x00000000
• DIV: Clock Divider
The prescaler is used to ensure that the CLK_CAT clock is divided to around 1 MHz to produce the sampling clock.The
prescaler uses the following formula to generate the sampling clock:
Sampling clock = CLK_CAT / (2(DIV+1))
• CHLEN: Charge Length
For the QTouch method, specifies how many sample clock cycles should be used for transferring charge to the sense capacitor.
• SELEN: Settle Length
For the QTouch method, specifies how many sample clock cycles should be used for settling after charge transfer.
31 30 29 28 27 26 25 24
DIV[15:8]
23 22 21 20 19 18 17 16
DIV[7:0]
15 14 13 12 11 10 9 8
CHLEN
76543210
SELEN
791
32142D–06/2013
ATUC64/128/256L3/4U
31.7.9 Touch Group x Configuration Register 1
Name: TGxCFG1
Access Type: Read/Write
Offset: 0x24, 0x2C
Reset Value: 0x00000000
• DISHIFT: Discharge Shift
For the sensors in QTouch group x, specifies how many bits the DILEN field should be shifted before using it to determine the
discharge time.
• SYNC: Sync Pin
For sensors in QTouch group x, specifies that acquisition shall begin when a falling edge is received on the SYNC line.
• SPREAD: Spread Spectrum Sensor Drive
For sensors in QTouch group x, specifies that spread spectrum sensor drive shall be used.
• DILEN: Discharge Length
For sensors in QTouch group x, specifies how many clock cycles the CAT should use to discharge the capacitors before
charging them.
• MAX: Touch Maximum Count
For sensors in QTouch group x, specifies how many counts the maximum acquisition should be.
31 30 29 28 27 26 25 24
- - DISHIFT - - SYNC SPREAD
23 22 21 20 19 18 17 16
DILEN
15 14 13 12 11 10 9 8
MAX[15:8]
76543210
MAX[7:0]
792
32142D–06/2013
ATUC64/128/256L3/4U
31.7.10 Matrix Group Configuration Register 0
Name: MGCFG0
Access Type: Read/Write
Offset: 0x30
Reset Value: 0x00000000
• DIV: Clock Divider
The prescaler is used to ensure that the CLK_CAT clock is divided to around 4 MHz to produce the burst timing clock.The
prescaler uses the following formula to generate the burst timing clock:
Burst timing clock = CLK_CAT / (2(DIV+1))
• CHLEN: Charge Length
For QMatrix sensors, specifies how many burst prescaler clock cycles should be used for transferring charge to the sense
capacitor.
• SELEN: Settle Length
For QMatrix sensors, specifies how many burst prescaler clock cycles should be used for settling after charge transfer.
31 30 29 28 27 26 25 24
DIV[15:8]
23 22 21 20 19 18 17 16
DIV[7:0]
15 14 13 12 11 10 9 8
CHLEN
76543210
SELEN
793
32142D–06/2013
ATUC64/128/256L3/4U
31.7.11 Matrix Group Configuration Register 1
Name: MGCFG1
Access Type: Read/Write
Offset: 0x34
Reset Value: 0x00000000
• DISHIFT: Discharge Shift
For QMatrix sensors, specifies how many bits the DILEN field should be shifted before using it to determine the discharge time.
• SYNC: Sync Pin
For QMatrix sensors, specifies that acquisition shall begin when a falling edge is received on the SYNC line.
• SPREAD: Spread Spectrum Sensor Drive
For QMatrix sensors, specifies that spread spectrum sensor drive shall be used.
• DILEN: Discharge Length
For QMatrix sensors, specifies how many burst prescaler clock cycles the CAT should use to discharge the capacitors at the
beginning of a burst sequence.
• MAX: Maximum Count
For QMatrix sensors, specifies how many counts the maximum acquisition should be.
31 30 29 28 27 26 25 24
- DISHIFT - SYNC SPREAD
23 22 21 20 19 18 17 16
DILEN
15 14 13 12 11 10 9 8
MAX[15:8]
76543210
MAX[7:0]
794
32142D–06/2013
ATUC64/128/256L3/4U
31.7.12 Matrix Group Configuration Register 2
Name: MGCFG2
Access Type: Read/Write
Offset: 0x38
Reset Value: 0x00000000
• ACCTRL: Analog Comparator Control
When written to one, allows the CAT to disable the analog comparators when they are not needed. When written to zero, the
analog comparators are always enabled.
• CONSEN: Consensus Filter Length
For QMatrix sensors, specifies that discharge will be terminated when CONSEN out of the most recent 5 comparator samples
are positive. For example, a value of 3 in the CONSEN field will terminate discharge when 3 out of the most recent 5 comparator
samples are positive. When CONSEN has the default value of 0, discharge will be terminated immediately when the comparator
output goes positive.
• CXDILEN: Cx Capacitor Discharge Length
For QMatrix sensors, specifies how many burst prescaler clock cycles the CAT should use to discharge the Cx capacitor at the
end of each burst cycle.
• SYNCTIM: Sync Time Interval
When non-zero, determines the number of prescaled clock cycles between the start of the acquisition on each X line for QMatrix
acquisition.
31 30 29 28 27 26 25 24
ACCTRL CONSEN -
23 22 21 20 19 18 17 16
CXDILEN
15 14 13 12 11 10 9 8
- SYNCTIM[11:8]
76543210
SYNCTIM[7:0]
795
32142D–06/2013
ATUC64/128/256L3/4U
31.7.13 Status Register
Name: SR
Access Type: Read-only
Offset: 0x3C
Reset Value: 0x00000000
• DMATSC: DMATouch Sensor State Change
0: No change in the DMATSS register.
1: One or more bits have changed in the DMATSS register.
• DMATSR: DMATouch State Read Register Ready
0: A new state word is not available in the DMATSR register.
1: A new state word is available in the DMATSR register.
• DMATSW: DMATouch State Write Register Request
0: The DMATouch algorithm is not requesting that a state word be written to the DMATSW register.
1: The DMATouch algorithm is requesting that a state word be written to the DMATSW register.
• ACQDONE: Acquisition Done
0: Acquisition is not done (still in progress).
1: Acquisition is complete.
• ACREADY: Acquired Count Data is Ready
0: Acquired count data is not available in the ACOUNT register.
1: Acquired count data is available in the ACOUNT register.
• MBLREQ: Matrix Burst Length Required
0: The QMatrix acquisition does not require any burst lengths.
1: The QMatrix acquisition requires burst lengths for the current X line.
• ATSTATE: Autonomous Touch Sensor State
0: The autonomous QTouch sensor is not active.
1: The autonomous QTouch sensor is active.
• ATSC: Autonomous Touch Sensor Status Interrupt
0: No status change in the autonomous QTouch sensor.
1: Status change in the autonomous QTouch sensor.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
DMATSC - - - - - DMATSR DMATSW
15 14 13 12 11 10 9 8
- - - - - - ACQDONE ACREADY
76543210
- - - MBLREQ ATSTATE ATSC ATCAL ENABLED
796
32142D–06/2013
ATUC64/128/256L3/4U
• ATCAL: Autonomous Touch Calibration Ongoing
0: The autonomous QTouch sensor is not calibrating.
1: The autonomous QTouch sensor is calibrating.
• ENABLED: Module Enabled
0: The module is disabled.
1: The module is enabled.
797
32142D–06/2013
ATUC64/128/256L3/4U
31.7.14 Status Clear Register
Name: SCR
Access Type: Write-only
Offset: 0x40
Reset Value: -
Writing a zero to a bit in this register has no effect.
Writing a one to a bit in this register will clear the corresponding bit in SR and the corresponding interrupt request.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
DMATSC - - - - - - -
15 14 13 12 11 10 9 8
- - - - - - ACQDONE ACREADY
76543210
- - - - - ATSC ATCAL -
798
32142D–06/2013
ATUC64/128/256L3/4U
31.7.15 Interrupt Enable Register
Name: IER
Access Type: Write-only
Offset: 0x44
Reset Value: -
Writing a zero to a bit in this register has no effect.
Writing a one to a bit in this register will set the corresponding bit in IMR.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
DMATSC - - - - - - -
15 14 13 12 11 10 9 8
- - - - - - ACQDONE ACREADY
76543210
- - - - - ATSC ATCAL -
799
32142D–06/2013
ATUC64/128/256L3/4U
31.7.16 Interrupt Disable Register
Name: IDR
Access Type: Write-only
Offset: 0x48
Reset Value: -
Writing a zero to a bit in this register has no effect.
Writing a one to a bit in this register will clear the corresponding bit in IMR.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
DMATSC - - - - - - -
15 14 13 12 11 10 9 8
- - - - - - ACQDONE ACREADY
76543210
- - - - - ATSC ATCAL -
800
32142D–06/2013
ATUC64/128/256L3/4U
31.7.17 Interrupt Mask Register
Name: IMR
Access Type: Read-only
Offset: 0x4C
Reset Value: 0x00000000
0: The corresponding interrupt is disabled.
1: The corresponding interrupt is enabled.
A bit in this register is cleared when the corresponding bit in IDR is written to one.
A bit in this register is set when the corresponding bit in IER is written to one.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
DMATSC - - - - - - -
15 14 13 12 11 10 9 8
- - - - - - ACQDONE ACREADY
76543210
- - - - - ATSC ATCAL -
801
32142D–06/2013
ATUC64/128/256L3/4U
31.7.18 Acquisition Initiation and Selection Register
Name: AISR
Access Type: Read/Write
Offset: 0x50
Reset Value: 0x00000000
• ACQSEL: Acquisition Type Selection
A write to this register initiates an acquisition of the following type:
00: QTouch Group A.
01: QTouch Group B.
10: QMatrix Group.
11: Undefined behavior.
A read of this register will return the value that was previously written.
31 30 29 28 27 26 25 24
-
23 22 21 20 19 18 17 16
-
15 14 13 12 11 10 9 8
-
76543210
- ACQSEL
802
32142D–06/2013
ATUC64/128/256L3/4U
31.7.19 Acquired Count Register
Name: ACOUNT
Access Type: Read-only
Offset: 0x54
Reset Value: 0x00000000
• Y: Y index
The Y index (for QMatrix method) associated with this count value.
• SPORX: Sensor pair or X index
The sensor pair index (for QTouch method) or X index (for QMatrix method) associated with this count value.
• COUNT: Count value
The signal (number of counts) acquired on the channel specified in the SPORX and Y fields.
When multiple acquired count values are read from a QTouch acquisition, the Y field will always be 0 and the SPORX value will
increase monotonically. For example, suppose a QTouch acquisition is performed using sensor pairs SP1, SP4, and SP9. The
first count read will have SPORX=1, the second read will have SPORX=4, and the third read will have SPORX=9.
When multiple acquired count values are read from a QMatrix acquisition, the SPORX value will stay the same while Y
increases monotonically through all Y values in the group. Then SPORX will increase to the next X value in the group. For
example, a QMatrix acquisition with X=2,3 and Y=4,7 would provide count values in the following order: X=2 and Y=4, then X=2
and Y=7, then X=3 and Y=4, and finally X=3 and Y=7.
31 30 29 28 27 26 25 24
Y
23 22 21 20 19 18 17 16
SPORX
15 14 13 12 11 10 9 8
COUNT[15:8]
76543210
COUNT[7:0]
803
32142D–06/2013
ATUC64/128/256L3/4U
31.7.20 Matrix Burst Length Register
Name: MBLEN
Access Type: Write-only
Offset: 0x58
Reset Value: -
• BURSTx: Burst Length x
For QMatrix sensors, specifies how many times the switching sequence should be repeated before acquisition begins for each
channel. Each count in the BURSTx field specifies 1 repeat of the switching sequence, so the actual burst length will be BURST.
Before doing a QMatrix acquisition on one X line this register has to be written with the burst values for the current XY pairs. For
each X line this register needs to be programmed with all the Y values. If Y values larger than 3 are used the register has to be
written several times in order to specify all burst lengths.
The Status Register bit MBLREQ is set to 1 when the CAT is waiting for values to be written into this register.
31 30 29 28 27 26 25 24
BURST0
23 22 21 20 19 18 17 16
BURST1
15 14 13 12 11 10 9 8
BURST2
76543210
BURST3
804
32142D–06/2013
ATUC64/128/256L3/4U
31.7.21 Discharge Current Source Register
Name: DICS
Access Type: Read/Write
Offset: 0x5C
Reset Value: 0x00000000
• FSOURCES: Force Discharge Current Sources
When FSOURCES[n] is 0, the corresponding discharge current source behavior depends on SOURCES[n].
When FSOURCES[n] is 1, the corresponding discharge current source is forced to be enabled continuously. This is useful for
testing or debugging but should not be done during normal acquisition.
• GLEN: Global Enable
0: The current source module is globally disabled.
1: The current source module is globally enabled.
• INTVREFSEL: Internal Voltage Reference Select
0: The voltage for the reference resistor is generated from the internal band gap circuit.
1: The voltage for the reference resistor is VDDIO/3.
• INTREFSEL: Internal Reference Select
0: The reference current flows through an external resistor on the DIS pin.
1: The reference current flows through the internal reference resistor.
• TRIM: Reference Current Trimming
This field is used to trim the discharge current. 0x00 corresponds to the minimum current value, and 0x1F corresponds to the
maximum current value.
• SOURCES: Enable Discharge Current Sources
When SOURCES[n] is 0, the corresponding discharge current source is disabled.
When SOURCES[n] is 1, the corresponding discharge current source is enabled at appropriate times during acquisition.
31 30 29 28 27 26 25 24
FSOURCES[7:0]
23 22 21 20 19 18 17 16
GLEN - - - - - INTVREFSEL INTREFSEL
15 14 13 12 11 10 9 8
- - - TRIM
76543210
SOURCES[7:0]
805
32142D–06/2013
ATUC64/128/256L3/4U
31.7.22 Spread Spectrum Configuration Register
Name: SSCFG
Access Type: Read/Write
Offset: 0x60
Reset Value: 0x00000000
• MAXDEV: Maximum Deviation
When spread spectrum burst is enabled, MAXDEV indicates the maximum number of prescaled clock cycles the burst pulse will
be extended or shortened.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
--------
76543210
MAXDEV
806
32142D–06/2013
ATUC64/128/256L3/4U
31.7.23 CSA Resistor Control Register
Name: CSARES
Access Type: Read/Write
Offset: 0x64
Reset Value: 0x00000000
• RES: Resistive Drive Enable
When RES[n] is 0, CSA[n] has the same drive properties as normal I/O pads.
When RES[n] is 1, CSA[n] has a nominal output resistance of 1kOhm during the burst phase.
31 30 29 28 27 26 25 24
-
23 22 21 20 19 18 17 16
- RES[16]
15 14 13 12 11 10 9 8
RES[15:8]
76543210
RES[7:0]
807
32142D–06/2013
ATUC64/128/256L3/4U
31.7.24 CSB Resistor Control Register
Name: CSBRES
Access Type: Read/Write
Offset: 0x68
Reset Value: 0x00000000
• RES: Resistive Drive Enable
When RES[n] is 0, CSB[n] has the same drive properties as normal I/O pads.
When RES[n] is 1, CSB[n] has a nominal output resistance of 1kOhm during the burst phase.
31 30 29 28 27 26 25 24
-
23 22 21 20 19 18 17 16
- RES[16]
15 14 13 12 11 10 9 8
RES[15:8]
76543210
RES[7:0]
808
32142D–06/2013
ATUC64/128/256L3/4U
31.7.25 Autonomous Touch Base Count Register
Name: ATBASE
Access Type: Read-only
Offset: 0x6C
Reset Value: 0x00000000
• COUNT: Count value
The base count currently stored by the autonomous touch sensor. This is useful for autonomous touch debugging purposes.
31 30 29 28 27 26 25 24
-
23 22 21 20 19 18 17 16
-
15 14 13 12 11 10 9 8
COUNT[15:8]
76543210
COUNT[7:0]
809
32142D–06/2013
ATUC64/128/256L3/4U
31.7.26 Autonomous Touch Current Count Register
Name: ATCURR
Access Type: Read-only
Offset: 0x70
Reset Value: 0x00000000
• COUNT: Count value
The current count acquired by the autonomous touch sensor. This is useful for autonomous touch debugging purposes.
31 30 29 28 27 26 25 24
-
23 22 21 20 19 18 17 16
-
15 14 13 12 11 10 9 8
COUNT[15:8]
76543210
COUNT[7:0]
810
32142D–06/2013
ATUC64/128/256L3/4U
31.7.27 DMATouch State Write Register
Name: DMATSW
Access Type: Write-only
Offset: 0x78
Reset Value: 0x00000000
• NOTINCAL: Not in Calibration Mode
0: Calibration should be performed on the next iteration of the DMATouch algorithm.
1: Calibration should not be performed on the next iteration of the DMATouch algorithm.
• DETCNT: Detection Count
This count value is updated and used by the DMATouch algorithm in order to detect when a button has been pushed.
• BASECNT: Base Count
This count value represents the average expected acquired count when the sensor/button is not pushed.
31 30 29 28 27 26 25 24
- - - - - - - NOTINCAL
23 22 21 20 19 18 17 16
DETCNT[23:16]
15 14 13 12 11 10 9 8
BASECNT[15:8]
76543210
BASECNT[7:0]
811
32142D–06/2013
ATUC64/128/256L3/4U
31.7.28 DMA Touch State Read Register
Name: DMATSR
Access Type: Read/Write
Offset: 0x7C
Reset Value: 0x00000000
• NOTINCAL: Not in Calibration Mode
0: Calibration should be performed on the next iteration of the DMATouch algorithm.
1: Calibration should not be performed on the next iteration of the DMATouch algorithm.
• DETCNT: Detection Count
This count value is updated and used by the DMATouch algorithm in order to detect when a button has been pushed.
• BASECNT: Base Count
This count value represents the average expected acquired count when the sensor/button is not pushed.
31 30 29 28 27 26 25 24
- - - - - - - NOTINCAL
23 22 21 20 19 18 17 16
DETCNT[23:16]
15 14 13 12 11 10 9 8
BASECNT[15:8]
76543210
BASECNT[7:0]
812
32142D–06/2013
ATUC64/128/256L3/4U
31.7.29 Analog Comparator Shift Offset Register x
Name: ACSHIx
Access Type: Read/Write
Offset: 0x80, 0x84, 0x88, 0x8C, 0x90, 0x94, 0x98, and 0x9C
Reset Value: 0x00000000
• SHIVAL: Shift Offset Value
Specifies the amount to shift the count value from each comparator. This allows the offset of each comparator to be
compensated.
31 30 29 28 27 26 25 24
-
23 22 21 20 19 18 17 16
-
15 14 13 12 11 10 9 8
- SHIVAL[11:8]
76543210
SHIVAL[7:0]
813
32142D–06/2013
ATUC64/128/256L3/4U
31.7.30 DMATouch Sensor Status Register
Name: DMATSS
Access Type: Read-only
Offset: 0xA0
Reset Value: 0x00000000
• SS: Sensor Status
0: The DMATouch sensor is not active, i.e. the button is currently not pushed.
1: The DMATouch sensor is active, i.e. the button is currently pushed.
31 30 29 28 27 26 25 24
SS[31:24]
23 22 21 20 19 18 17 16
SS[23:16]
15 14 13 12 11 10 9 8
SS[15:8]
76543210
SS[7:0]
814
32142D–06/2013
ATUC64/128/256L3/4U
31.7.31 Parameter Register
Name: PARAMETER
Access Type: Read-only
Offset: 0xF8
Reset Value: -
• SP[n]: Sensor pair implemented
0: The corresponding sensor pair is not implemented
1: The corresponding sensor pair is implemented.
31 30 29 28 27 26 25 24
SP[31:24]
23 22 21 20 19 18 17 16
SP[23:16]
15 14 13 12 11 10 9 8
SP[15:8]
76543210
SP[7:0]
815
32142D–06/2013
ATUC64/128/256L3/4U
31.7.32 Version Register
Name: VERSION
Access Type: Read-only
Offset: 0xFC
Reset Value: -
• VARIANT: Variant number
Reserved. No functionality associated.
• VERSION: Version number
Version number of the module. No functionality associated.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
- - - - VARIANT
15 14 13 12 11 10 9 8
- - - - VERSION[11:8]
76543210
VERSION[7:0]
816
32142D–06/2013
ATUC64/128/256L3/4U
31.8 Module Configuration
The specific configuration the CAT module is listed in the following tables.The module bus
clocks listed here are connected to the system bus clocks. Please refer to the Power Manager
chapter for details.
31.8.1 Resistive Drive
By default, the CAT pins are driven with normal I/O drive properties. Some of the CSA and CSB
pins can optionally drive with a 1k output resistance for improved EMC.
To enable resistive drive on a pin, the user must write a one to the corresponding bit in the CSA
Resistor Control Register (CSARES) or CSB Resistor Control Register (CSBRES) register.
Table 31-4. CAT Configuration
Feature CAT
Number of touch sensors/Size of matrix Allows up to 17 touch sensors, or up to 16 by 8
matrix sensors to be interfaced.
Table 31-5. CAT Clocks
Clock Name Description
CLK_CAT Clock for the CAT bus interface
GCLK The generic clock used for the CAT is GCLK4
Table 31-6. Register Reset Values
Register Reset Value
VERSION 0x00000400
PARAMETER 0x0001FFFF
817
32142D–06/2013
ATUC64/128/256L3/4U
32. Glue Logic Controller (GLOC)
Rev: 1.0.0.0
32.1 Features
• Glue logic for general purpose PCB design
• Programmable lookup table
• Up to four inputs supported per lookup table
• Optional filtering of output
32.2 Overview
The Glue Logic Controller (GLOC) contains programmable logic which can be connected to the
device pins. This allows the user to eliminate logic gates for simple glue logic functions on the
PCB.
The GLOC consists of a number of lookup table (LUT) units. Each LUT can generate an output
as a user programmable logic expression with four inputs. Inputs can be individually masked.
The output can be combinatorially generated from the inputs, or filtered to remove spikes.
32.3 Block Diagram
Figure 32-1. GLOC Block Diagram PERIPHERAL BUS TRUTH
FILTER
OUT[0]
...
OUT[n]
FILTEN
IN[3:0]
…
IN[(4n+3):4n]
AEN
CLK_GLOC
GCLK
818
32142D–06/2013
ATUC64/128/256L3/4U
32.4 I/O Lines Description
Each LUT have 4 inputs and one output. The inputs and outputs for the LUTs are mapped
sequentially to the inputs and outputs. This means that LUT0 is connected to IN0 to IN3 and
OUT0. LUT1 is connected to IN4 to IN7 and OUT1. In general, LUTn is connected to IN[4n] to
IN[4n+3] and OUTn.
32.5 Product Dependencies
In order to use this module, other parts of the system must be configured correctly, as described
below.
32.5.1 I/O Lines
The pins used for interfacing the GLOC may be multiplexed with I/O Controller lines. The programmer
must first program the I/O Controller to assign the desired GLOC pins to their
peripheral function. If I/O lines of the GLOC are not used by the application, they can be used for
other purposes by the I/O Controller.
It is only required to enable the GLOC inputs and outputs actually in use. Pullups for pins configured
to be used by the GLOC will be disabled.
32.5.2 Clocks
The clock for the GLOC bus interface (CLK_GLOC) is generated by the Power Manager. This
clock is enabled at reset, and can be disabled in the Power Manager. It is recommended to disable
the GLOC before disabling the clock, to avoid freezing the module in an undefined state.
Additionally, the GLOC depends on a dedicated Generic Clock (GCLK). The GCLK can be set to
a wide range of frequencies and clock sources, and must be enabled by the System Control
Interface (SCIF) before the GLOC filter can be used.
32.5.3 Debug Operation
When an external debugger forces the CPU into debug mode, the GLOC continues normal
operation.
32.6 Functional Description
32.6.1 Enabling the Lookup Table Inputs
Since the inputs to each lookup table (LUT) unit can be multiplexed with other peripherals, each
input must be explicitly enabled by writing a one to the corresponding enable bit (AEN) in the
corresponding Control Register (CR).
If no inputs are enabled, the output OUTn will be the least significant bit in the TRUTHn register.
Table 32-1. I/O Lines Description
Pin Name Pin Description Type
IN0-INm Inputs to lookup tables Input
OUT0-OUTn Output from lookup tables Output
819
32142D–06/2013
ATUC64/128/256L3/4U
32.6.2 Configuring the Lookup Table
The lookup table in each LUT unit can generate any logic expression OUT as a function of up to
four inputs, IN[3:0]. The truth table for the expression is written to the TRUTH register for the
LUT. Table 32-2 shows the truth table for LUT0. The truth table for LUTn is written to TRUTHn,
and the corresponding input and outputs will be IN[4n] to IN[4n+3] and OUTn.
32.6.3 Output Filter
By default, the output OUTn is a combinatorial function of the inputs IN[4n] to IN[4n+3]. This may
cause some short glitches to occur when the inputs change value.
It is also possible to clock the output through a filter to remove glitches. This requires that the
corresponding generic clock (GCLK) has been enabled before use. The filter can then be
enabled by writing a one to the Filter Enable (FILTEN) bit in CRn. The OUTn output will be
delayed by three to four GCLK cycles when the filter is enabled.
Table 32-2. Truth Table for the Lookup Table in LUT0
IN[3] IN[2] IN[1] IN[0] OUT[0]
0 0 0 0 TRUTH0[0]
0 0 0 1 TRUTH0[1]
0 0 1 0 TRUTH0[2]
0 0 1 1 TRUTH0[3]
0 1 0 0 TRUTH0[4]
0 1 0 1 TRUTH0[5]
0 1 1 0 TRUTH0[6]
0 1 1 1 TRUTH0[7]
1 0 0 0 TRUTH0[8]
1 0 0 1 TRUTH0[9]
1 0 1 0 TRUTH0[10]
1 0 1 1 TRUTH0[11]
1 1 0 0 TRUTH0[12]
1 1 0 1 TRUTH0[13]
1 1 1 0 TRUTH0[14]
1 1 1 1 TRUTH0[15]
820
32142D–06/2013
ATUC64/128/256L3/4U
32.7 User Interface
Note: 1. The reset values are device specific. Please refer to the Module Configuration section at the end of this chapter.
Table 32-3. GLOC Register Memory Map
Offset Register Register Name Access Reset
0x00+n*0x08 Control Register n CRn Read/Write 0x00000000
0x04+n*0x08 Truth Table Register n TRUTHn Read/Write 0x00000000
0x38 Parameter Register PARAMETER Read-only - (1)
0x3C Version Register VERSION Read-only - (1)
821
32142D–06/2013
ATUC64/128/256L3/4U
32.7.1 Control Register n
Name: CRn
Access Type: Read/Write
Offset: 0x00+n*0x08
Reset Value: 0x00000000
• FILTEN: Filter Enable
1: The output is glitch filtered
0: The output is not glitch filtered
• AEN: Enable IN Inputs
Input IN[n] is enabled when AEN[n] is one.
Input IN[n] is disabled when AEN[n] is zero, and will not affect the OUT value.
31 30 29 28 27 26 25 24
FILTEN - - - - - - -
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
--------
76543210
- - - - AEN
822
32142D–06/2013
ATUC64/128/256L3/4U
32.7.2 Truth Table Register n
Name: TRUTHn
Access Type: Read/Write
Offset: 0x04+n*0x08
Reset Value: 0x00000000
• TRUTH: Truth Table Value
This value defines the output OUT as a function of inputs IN:
OUT = TRUTH[IN]
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
TRUTH[15:8]
76543210
TRUTH[7:0]
823
32142D–06/2013
ATUC64/128/256L3/4U
32.7.3 Parameter Register
Name: PARAMETER
Access Type: Read-only
Offset: 0x38
Reset Value: -
• LUTS: Lookup Table Units Implemented
This field contains the number of lookup table units implemented in this device.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
--------
76543210
LUTS
824
32142D–06/2013
ATUC64/128/256L3/4U
32.7.4 VERSION Register
Name: VERSION
Access Type: Read-only
Offset: 0x3C
Reset Value: -
• VARIANT: Variant Number
Reserved. No functionality associated.
• VERSION: Version Number
Version number of the module. No functionality associated.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
- - - - VARIANT
15 14 13 12 11 10 9 8
- - - - VERSION[11:8]
76543210
VERSION[7:0]
825
32142D–06/2013
ATUC64/128/256L3/4U
32.8 Module Configuration
The specific configuration for each GLOC instance is listed in the following tables.The GLOC
bus clocks listed here are connected to the system bus clocks. Please refer to the Power Manager
chapter for details.
Table 32-4. GLOC Configuration
Feature GLOC
Number of LUT units 2
Table 32-5. GLOC Clocks
Clock Name Description
CLK_GLOC Clock for the GLOC bus interface
GCLK The generic clock used for the GLOC is GCLK5
Table 32-6. Register Reset Values
Register Reset Value
VERSION 0x00000100
PARAMETER 0x00000002
826
32142D–06/2013
ATUC64/128/256L3/4U
33. aWire UART (AW)
Rev: 2.3.0.0
33.1 Features
• Asynchronous receiver or transmitter when the aWire system is not used for debugging.
• One- or two-pin operation supported.
33.2 Overview
If the AW is not used for debugging, the aWire UART can be used by the user to send or receive
data with one start bit, eight data bits, no parity bits, and one stop bit. This can be controlled
through the aWire UART user interface.
This chapter only describes the aWire UART user interface. For a description of the aWire
Debug Interface, please see the Programming and Debugging chapter.
33.3 Block Diagram
Figure 33-1. aWire Debug Interface Block Diagram
UART
Reset
filter
External reset
AW_ENABLE
RESET_N
Baudrate Detector
RW SZ ADDR DATA
CRC
AW CONTROL
AW User Interface
SAB interface
RESET command
Power
Manager
HALT command CPU
Flash
Controller CHIP_ERASE command
aWire Debug Interface
PB
SAB
827
32142D–06/2013
ATUC64/128/256L3/4U
33.4 I/O Lines Description
33.5 Product Dependencies
In order to use this module, other parts of the system must be configured correctly, as described
below.
33.5.1 I/O Lines
The pin used by AW is multiplexed with the RESET_N pin. The reset functionality is the default
function of this pin. To enable the aWire functionality on the RESET_N pin the user must enable
the aWire UART user interface.
33.5.2 Power Management
If the CPU enters a sleep mode that disables clocks used by the aWire UART user interface, the
aWire UART user interface will stop functioning and resume operation after the system wakes
up from sleep mode.
33.5.3 Clocks
The aWire UART uses the internal 120 MHz RC oscillator (RC120M) as clock source for its
operation. When using the aWire UART user interface RC120M must enabled using the Clock
Request Register (see Section 33.6.1).
The clock for the aWire UART user interface (CLK_AW) is generated by the Power Manager.
This clock is enabled at reset, and can be disabled in the Power Manager. It is recommended to
disable the aWire UART user interface before disabling the clock, to avoid freezing the aWire
UART user interface in an undefined state.
33.5.4 Interrupts
The aWire UART user interface interrupt request line is connected to the interrupt controller.
Using the aWire UART user interface interrupt requires the interrupt controller to be programmed
first.
33.5.5 Debug Operation
If the AW is used for debugging the aWire UART user interface will not be usable.
When an external debugger forces the CPU into debug mode, the aWire UART user interface
continues normal operation. If the aWire UART user interface is configured in a way that
requires it to be periodically serviced by the CPU through interrupts or similar, improper operation
or data loss may result during debugging.
33.5.6 External Components
The AW needs an external pullup on the RESET_N pin to ensure that the pin is pulled up when
the bus is not driven.
33.6 Functional Description
The aWire UART user interface can be used as a spare Asynchronous Receiver or Transmitter
when AW is not used for debugging.
Table 33-1. I/O Lines Description
Name Description Type
DATA aWire data multiplexed with the RESET_N pin. Input/Output
828
32142D–06/2013
ATUC64/128/256L3/4U
33.6.1 How to Initialize The Module
To initialize the aWire UART user interface the user must first enable the clock by writing a one
to the Clock Enable bit in the Clock Request Register (CLKR.CLKEN) and wait for the Clock
Enable bit in the Status Register (SR.CENABLED) to be set. After doing this either receive,
transmit or receive with resync must be selected by writing the corresponding value into the
Mode field of the Control (CTRL.MODE) Register. Due to the RC120M being asynchronous with
the system clock values must be allowed to propagate in the system. During this time the aWire
master will set the Busy bit in the Status Register (SR.BUSY).
After the SR.BUSY bit is cleared the Baud Rate field in the Baud Rate Register (BRR.BR) can
be written with the wanted baudrate ( ) according to the following formula ( is the RC120M
clock frequency):
After this operation the user must wait until the SR.BUSY is cleared. The interface is now ready
to be used.
33.6.2 Basic Asynchronous Receiver Operation
The aWire UART user interface must be initialized according to the sequence above, but the
CTRL.MODE field must be written to one (Receive mode).
When a data byte arrives the aWire UART user interface will indicate this by setting the Data
Ready Interrupt bit in the Status Register (SR.DREADYINT). The user must read the Data in the
Receive Holding Register (RHR.RXDATA) and clear the Interrupt bit by writing a one to the Data
Ready Interrupt Clear bit in the Status Clear Register (SCR.DREADYINT). The interface is now
ready to receive another byte.
33.6.3 Basic Asynchronous Transmitter Operation
The aWire UART user interface must be initialized according to the sequence above, but the
CTRL.MODE field must be written to two (Transmit mode).
To transmit a data byte the user must write the data to the Transmit Holding Register
(THE.TXDATA). Before the next byte can be written the SR.BUSY must be cleared.
33.6.4 Basic Asynchronous Receiver with Resynchronization
By writing three into CTRL.MODE the aWire UART user interface will assume that the first byte
it receives is a sync byte (0x55) and set BRR.BR according to this. All subsequent transfers will
assume this baudrate, unless BRR.BR is rewritten by the user.
To make the aWire UART user interface accept a new sync resynchronization the aWire UART
user interface must be disabled by writing zero to CTRL.MODE and then reenable the interface.
33.6.5 Overrun
In Receive mode an overrun can occur if the user has not read the previous received data from
the RHR.RXDATA when the newest data should be placed there. Such a condition is flagged by
setting the Overrun bit in the Status Register (SR.OVERRUN). If SR.OVERRUN is set the newest
data received is placed in RHR.RXDATA and the data that was there before is overwritten.
f
br f
aw
f
br
8f
aw
BR = -----------
829
32142D–06/2013
ATUC64/128/256L3/4U
33.6.6 Interrupts
To make the CPU able to do other things while waiting for the aWire UART user interface to finish
its operations the aWire UART user interface supports generating interrupts. All status bits in
the Status Register can be used as interrupt sources, except the SR.BUSY and SR.CENABLED
bits.
To enable an interrupt the user must write a one to the corresponding bit in the Interrupt Enable
Register (IER). Upon the next zero to one transition of this SR bit the aWire UART user interface
will flag this interrupt to the CPU. To clear the interrupt the user must write a one to the corresponding
bit in the Status Clear Register (SCR).
Interrupts can be disabled by writing a one to the corresponding bit in the Interrupt Disable Register
(IDR). The interrupt Mask Register (IMR) can be read to check if an interrupt is enabled or
disabled.
33.6.7 Using the Peripheral DMA Controller
To relieve the CPU of data transfers the aWire UART user interface support using the Peripheral
DMA controller.
To transmit using the Peripheral DMA Controller do the following:
1. Setup the aWire UART user interface in transmit mode.
2. Setup the Peripheral DMA Controller with buffer address and length, use byte as transfer
size.
3. Enable the Peripheral DMA Controller.
4. Wait until the Peripheral DMA Controller is done.
To receive using the Peripheral DMA Controller do the following:
1. Setup the aWire UART user interface in receive mode
2. Setup the Peripheral DMA Controller with buffer address and length, use byte as transfer
size.
3. Enable the Peripheral DMA Controller.
4. Wait until the Peripheral DMA Controller is ready.
830
32142D–06/2013
ATUC64/128/256L3/4U
33.7 User Interface
Note: 1. The reset values are device specific. Please refer to the Module Configuration section at the end of this chapter.
Table 33-2. aWire UART user interface Register Memory Map
Offset Register Register Name Access Reset
0x00 Control Register CTRL Read/Write 0x00000000
0x04 Status Register SR Read-only 0x00000000
0x08 Status Clear Register SCR Write-only -
0x0C Interrupt Enable Register IER Write-only -
0x10 Interrupt Disable Register IDR Write-only -
0x14 Interrupt Mask Register IMR Read-only 0x00000000
0x18 Receive Holding Register RHR Read-only 0x00000000
0x1C Transmit Holding Register THR Read/Write 0x00000000
0x20 Baud Rate Register BRR Read/Write 0x00000000
0x24 Version Register VERSION Read-only -(1)
0x28 Clock Request Register CLKR Read/Write 0x00000000
831
32142D–06/2013
ATUC64/128/256L3/4U
33.7.1 Control Register
Name: CTRL
Access Type: Read/Write
Offset: 0x00
Reset Value: 0x00000000
• MODE: aWire UART user interface mode
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
--------
76543210
- - - - - - MODE
Table 33-3. aWire UART user interface Modes
MODE Mode Description
0 Disabled
1 Receive
2 Transmit
3 Receive with resync.
832
32142D–06/2013
ATUC64/128/256L3/4U
33.7.2 Status Register
Name: SR
Access Type: Read-only
Offset: 0x04
Reset Value: 0x00000000
• TRMIS: Transmit Mismatch
0: No transfers mismatches.
1: The transceiver was active when receiving.
This bit is set when the transceiver is active when receiving.
This bit is cleared when corresponding bit in SCR is written to one.
• OVERRUN: Data Overrun
0: No data overwritten in RHR.
1: Data in RHR has been overwritten before it has been read.
This bit is set when data in RHR is overwritten before it has been read.
This bit is cleared when corresponding bit in SCR is written to one.
• DREADYINT: Data Ready Interrupt
0: No new data in the RHR.
1: New data received and placed in the RHR.
This bit is set when new data is received and placed in the RHR.
This bit is cleared when corresponding bit in SCR is written to one.
• READYINT: Ready Interrupt
0: The interface has not generated an ready interrupt.
1: The interface has had a transition from busy to not busy.
This bit is set when the interface has transition from busy to not busy.
This bit is cleared when corresponding bit in SCR is written to one.
• CENABLED: Clock Enabled
0: The aWire clock is not enabled.
1: The aWire clock is enabled.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
- - TRMIS - - OVERRUN DREADYINT READYINT
76543210
- - - - - CENABLED - BUSY
833
32142D–06/2013
ATUC64/128/256L3/4U
This bit is set when the clock is disabled.
This bit is cleared when the clock is enabled.
• BUSY: Synchronizer Busy
0: The asynchronous interface is ready to accept more data.
1: The asynchronous interface is busy and will block writes to CTRL, BRR, and THR.
This bit is set when the asynchronous interface becomes busy.
This bit is cleared when the asynchronous interface becomes ready.
834
32142D–06/2013
ATUC64/128/256L3/4U
33.7.3 Status Clear Register
Name: SCR
Access Type: Write-only
Offset: 0x08
Reset Value: 0x00000000
Writing a zero to a bit in this register has no effect.
Writing a one to a bit in this register will clear the corresponding bit in SR and the corresponding interrupt request.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
- - TRMIS - - OVERRUN DREADYINT READYINT
76543210
--------
835
32142D–06/2013
ATUC64/128/256L3/4U
33.7.4 Interrupt Enable Register
Name: IER
Access Type: Write-only
Offset: 0x0C
Reset Value: 0x00000000
Writing a zero to a bit in this register has no effect.
Writing a one to a bit in this register will set the corresponding bit in IMR.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
- - TRMIS - - OVERRUN DREADYINT READYINT
76543210
--------
836
32142D–06/2013
ATUC64/128/256L3/4U
33.7.5 Interrupt Disable Register
Name: IDR
Access Type: Write-only
Offset: 0x10
Reset Value: 0x00000000
Writing a zero to a bit in this register has no effect.
Writing a one to a bit in this register will clear the corresponding bit in IMR.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
- - TRMIS - - OVERRUN DREADYINT READYINT
76543210
--------
837
32142D–06/2013
ATUC64/128/256L3/4U
33.7.6 Interrupt Mask Register
Name: IMR
Access Type: Read-only
Offset: 0x14
Reset Value: 0x00000000
0: The corresponding interrupt is disabled.
1: The corresponding interrupt is enabled.
A bit in this register is cleared when the corresponding bit in IDR is written to one.
A bit in this register is set when the corresponding bit in IER is written to one.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
- - TRMIS - - OVERRUN DREADYINT READYINT
76543210
--------
838
32142D–06/2013
ATUC64/128/256L3/4U
33.7.7 Receive Holding Register
Name: RHR
Access Type: Read-only
Offset: 0x18
Reset Value: 0x00000000
• RXDATA: Received Data
The last byte received.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
--------
76543210
RXDATA
839
32142D–06/2013
ATUC64/128/256L3/4U
33.7.8 Transmit Holding Register
Name: THR
Access Type: Read/Write
Offset: 0x1C
Reset Value: 0x00000000
• TXDATA: Transmit Data
The data to send.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
--------
76543210
TXDATA
840
32142D–06/2013
ATUC64/128/256L3/4U
33.7.9 Baud Rate Register
Name: BRR
Access Type: Read/Write
Offset: 0x20
Reset Value: 0x00000000
• BR: Baud Rate
The baud rate ( ) of the transmission, calculated using the following formula ( is the RC120M frequency):
BR should not be set to a value smaller than 32.
Writing a value to this field will update the baud rate of the transmission.
Reading this field will give the current baud rate of the transmission.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
BR[15:8]
76543210
BR[7:0]
f
br f
aw
f
br
8f
aw
BR = -----------
841
32142D–06/2013
ATUC64/128/256L3/4U
33.7.10 Version Register
Name: VERSION
Access Type: Read-only
Offset: 0x24
Reset Value: 0x00000200
• VERSION: Version Number
Version number of the module. No functionality associated.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
- - - - VERSION[11:8]
76543210
VERSION[7:0]
842
32142D–06/2013
ATUC64/128/256L3/4U
33.7.11 Clock Request Register
Name: CLKR
Access Type: Read/Write
Offset: 0x28
Reset Value: 0x00000000
• CLKEN: Clock Enable
0: The aWire clock is disabled.
1: The aWire clock is enabled.
Writing a zero to this bit will disable the aWire clock.
Writing a one to this bit will enable the aWire clock.
31 30 29 28 27 26 25 24
--------
23 22 21 20 19 18 17 16
--------
15 14 13 12 11 10 9 8
--------
76543210
- - - - - - - CLKEN
843
32142D–06/2013
ATUC64/128/256L3/4U
33.8 Module Configuration
The specific configuration for each aWire instance is listed in the following tables.The module
bus clocks listed here are connected to the system bus clocks. Please refer to the Power Manager
chapter for details.
Table 33-4. AW Clocks
Clock Name Description
CLK_AW Clock for the AW bus interface
Table 33-5. Register Reset Values
Register Reset Value
VERSION 0x00000230
844
32142D–06/2013
ATUC64/128/256L3/4U
34. Programming and Debugging
34.1 Overview
The ATUC64/128/256L3/4U supports programming and debugging through two interfaces,
JTAG or aWire. JTAG is an industry standard interface and allows boundary scan for PCB testing,
as well as daisy-chaining of multiple devices on the PCB. aWire is an Atmel proprietary
protocol which offers higher throughput and robust communication, and does not require application
pins to be reserved. Either interface provides access to the internal Service Access Bus
(SAB), which offers a bridge to the High Speed Bus, giving access to memories and peripherals
in the device. By using this bridge to the bus system, the flash and fuses can thus be programmed
by accessing the Flash Controller in the same manner as the CPU.
The SAB also provides access to the Nexus-compliant On-chip Debug (OCD) system in the
device, which gives the user non-intrusive run-time control of the program execution. Additionally,
trace information can be output on the Auxiliary (AUX) debug port or buffered in internal
RAM for later retrieval by JTAG or aWire.
34.2 Service Access Bus
The AVR32 architecture offers a common interface for access to On-chip Debug, programming,
and test functions. These are mapped on a common bus called the Service Access Bus (SAB),
which is linked to the JTAG and aWire port through a bus master module, which also handles
synchronization between the debugger and SAB clocks.
When accessing the SAB through the debugger there are no limitations on debugger frequency
compared to chip frequency, although there must be an active system clock in order for the SAB
accesses to complete. If the system clock is switched off in sleep mode, activity on the debugger
will restart the system clock automatically, without waking the device from sleep. Debuggers
may optimize the transfer rate by adjusting the frequency in relation to the system clock. This
ratio can be measured with debug protocol specific instructions.
The Service Access Bus uses 36 address bits to address memory or registers in any of the
slaves on the bus. The bus supports sized accesses of bytes (8 bits), halfwords (16 bits), or
words (32 bits). All accesses must be aligned to the size of the access, i.e. halfword accesses
must have the lowest address bit cleared, and word accesses must have the two lowest address
bits cleared.
34.2.1 SAB Address Map
The SAB gives the user access to the internal address space and other features through a 36
bits address space. The 4 MSBs identify the slave number, while the 32 LSBs are decoded
within the slave’s address space. The SAB slaves are shown in Table 34-1.
Table 34-1. SAB Slaves, Addresses and Descriptions
Slave Address [35:32] Description
Unallocated 0x0 Intentionally unallocated
OCD 0x1 OCD registers
HSB 0x4 HSB memory space, as seen by the CPU
845
32142D–06/2013
ATUC64/128/256L3/4U
34.2.2 SAB Security Restrictions
The Service Access bus can be restricted by internal security measures. A short description of
the security measures are found in the table below.
34.2.2.1 Security measure and control location
A security measure is a mechanism to either block or allow SAB access to a certain address or
address range. A security measure is enabled or disabled by one or several control signals. This
is called the control location for the security measure.
These security measures can be used to prevent an end user from reading out the code programmed
in the flash, for instance.
Below follows a more in depth description of what locations are accessible when the security
measures are active.
Note: 1. Second Word of the User Page, refer to the Fuses Settings section for details.
HSB 0x5 Alternative mapping for HSB space, for compatibility with
other 32-bit AVR devices.
Memory Service
Unit 0x6 Memory Service Unit registers
Reserved Other Unused
Table 34-1. SAB Slaves, Addresses and Descriptions
Slave Address [35:32] Description
Table 34-2. SAB Security Measures
Security Measure Control Location Description
Secure mode FLASHCDW
SECURE bits set
Allocates a portion of the flash for secure code. This code
cannot be read or debugged. The User page is also locked.
Security bit FLASHCDW
security bit set
Programming and debugging not possible, very restricted
access.
User code
programming
FLASHCDW
UPROT + security
bit set
Restricts all access except parts of the flash and the flash
controller for programming user code. Debugging is not
possible unless an OS running from the secure part of the
flash supports it.
Table 34-3. Secure Mode SAB Restrictions
Name Address Start Address End Access
Secure flash area 0x580000000 0x580000000 +
(USERPAGE[15:0] << 10) Blocked
Secure RAM area 0x500000000 0x500000000 +
(USERPAGE[31:16] << 10) Blocked
User page 0x580800000 0x581000000 Read
Other accesses - - As normal
846
32142D–06/2013
ATUC64/128/256L3/4U
Table 34-4. Security Bit SAB Restrictions
Name Address start Address end Access
OCD DCCPU,
OCD DCEMU,
OCD DCSR
0x100000110 0x100000118 Read/Write
User page 0x580800000 0x581000000 Read
Other accesses - - Blocked
Table 34-5. User Code Programming SAB Restrictions
Name Address start Address end Access
OCD DCCPU,
OCD DCEMU,
OCD DCSR
0x100000110 0x100000118 Read/Write
User page 0x580800000 0x581000000 Read
FLASHCDW PB
interface 0x5FFFE0000 0x5FFFE0400 Read/Write
FLASH pages
outside
BOOTPROT
0x580000000 +
BOOTPROT size 0x580000000 + Flash size Read/Write
Other accesses - - Blocked
847
32142D–06/2013
ATUC64/128/256L3/4U
34.3 On-Chip Debug
Rev: 2.1.2.0
34.3.1 Features
• Debug interface in compliance with IEEE-ISTO 5001-2003 (Nexus 2.0) Class 2+
• JTAG or aWire access to all on-chip debug functions
• Advanced Program, Data, Ownership, and Watchpoint trace supported
• NanoTrace aWire- or JTAG-based trace access
• Auxiliary port for high-speed trace information
• Hardware support for 6 Program and 2 Data breakpoints
• Unlimited number of software breakpoints supported
• Automatic CRC check of memory regions
34.3.2 Overview
Debugging on the ATUC64/128/256L3/4U is facilitated by a powerful On-Chip Debug (OCD)
system. The user accesses this through an external debug tool which connects to the JTAG or
aWire port and the Auxiliary (AUX) port if implemented. The AUX port is primarily used for trace
functions, and an aWire- or JTAG-based debugger is sufficient for basic debugging.
The debug system is based on the Nexus 2.0 standard, class 2+, which includes:
• Basic run-time control
• Program breakpoints
• Data breakpoints
• Program trace
• Ownership trace
• Data trace
In addition to the mandatory Nexus debug features, the ATUC64/128/256L3/4U implements
several useful OCD features, such as:
• Debug Communication Channel between CPU and debugger
• Run-time PC monitoring
• CRC checking
• NanoTrace
• Software Quality Assurance (SQA) support
The OCD features are controlled by OCD registers, which can be accessed by the debugger, for
instance when the NEXUS_ACCESS JTAG instruction is loaded. The CPU can also access
OCD registers directly using mtdr/mfdr instructions in any privileged mode. The OCD registers
are implemented based on the recommendations in the Nexus 2.0 standard, and are detailed in
the AVR32UC Technical Reference Manual.
34.3.3 I/O Lines Description
The OCD AUX trace port contains a number of pins, as shown in Table 34-6 on page 848.
These are multiplexed with I/O Controller lines, and must explicitly be enabled by writing OCD
registers before the debug session starts. The AUX port is mapped to two different locations,
848
32142D–06/2013
ATUC64/128/256L3/4U
selectable by OCD Registers, minimizing the chance that the AUX port will need to be shared
with an application.
34.3.4 Product Dependencies
In order to use this module, other parts of the system must be configured correctly, as described
below.
34.3.4.1 Power Management
The OCD clock operates independently of the CPU clock. If enabled in the Power Manager, the
OCD clock (CLK_OCD) will continue running even if the CPU enters a sleep mode that disables
the CPU clock.
34.3.4.2 Clocks
The OCD has a clock (CLK_OCD) running synchronously with the CPU clock. This clock is generated
by the Power Manager. The clock is enabled at reset, and can be disabled by writing to
the Power Manager.
34.3.4.3 Interrupt
The OCD system interrupt request lines are connected to the interrupt controller. Using the OCD
interrupts requires the interrupt controller to be programmed first.
Table 34-6. Auxiliary Port Signals
Pin Name Pin Description Direction Active Level Type
MCKO Trace data output clock Output Digital
MDO[5:0] Trace data output Output Digital
MSEO[1:0] Trace frame control Output Digital
EVTI_N Event In Input Low Digital
EVTO_N Event Out Output Low Digital
849
32142D–06/2013
ATUC64/128/256L3/4U
34.3.5 Block Diagram
Figure 34-1. On-Chip Debug Block Diagram
34.3.6 SAB-based Debug Features
A debugger can control all OCD features by writing OCD registers over the SAB interface. Many
of these do not depend on output on the AUX port, allowing an aWire- or JTAG-based debugger
to be used.
A JTAG-based debugger should connect to the device through a standard 10-pin IDC connector
as described in the AVR32UC Technical Reference Manual.
An aWire-based debugger should connect to the device through the RESET_N pin.
On-Chip Debug
JTAG
Debug PC
Debug
Instruction
CPU
Breakpoints
Program
Trace Data Trace Ownership
Trace
Transmit Queue Watchpoints
AUX
JTAG
Internal
SRAM
Service Access Bus
Memory
Service
Unit
HSB Bus Matrix Memories and
peripherals
aWire
aWire
850
32142D–06/2013
ATUC64/128/256L3/4U
Figure 34-2. JTAG-based Debugger
Figure 34-3. aWire-based Debugger
34.3.6.1 Debug Communication Channel
The Debug Communication Channel (DCC) consists of a pair OCD registers with associated
handshake logic, accessible to both CPU and debugger. The registers can be used to exchange
data between the CPU and the debugmaster, both runtime as well as in debug mode.
32-bit AVR
JTAG-based
debug tool
PC
JTAG
10-pin IDC
32-bit AVR
aWire-based
debug tool
PC
aWire
851
32142D–06/2013
ATUC64/128/256L3/4U
The OCD system can generate an interrupt to the CPU when DCCPU is read and when DCEMU
is written. This enables the user to build a custum debug protocol using only these registers. The
DCCPU and DCEMU registers are available even when the security bit in the flash is active.
For more information refer to the AVR32UC Technical Reference Manual.
34.3.6.2 Breakpoints
One of the most fundamental debug features is the ability to halt the CPU, to examine registers
and the state of the system. This is accomplished by breakpoints, of which many types are
available:
• Unconditional breakpoints are set by writing OCD registers by the debugger, halting the CPU
immediately.
• Program breakpoints halt the CPU when a specific address in the program is executed.
• Data breakpoints halt the CPU when a specific memory address is read or written, allowing
variables to be watched.
• Software breakpoints halt the CPU when the breakpoint instruction is executed.
When a breakpoint triggers, the CPU enters debug mode, and the D bit in the status register is
set. This is a privileged mode with dedicated return address and return status registers. All privileged
instructions are permitted. Debug mode can be entered as either OCD Mode, running
instructions from the debugger, or Monitor Mode, running instructions from program memory.
34.3.6.3 OCD Mode
When a breakpoint triggers, the CPU enters OCD mode, and instructions are fetched from the
Debug Instruction OCD register. Each time this register is written by the debugger, the instruction
is executed, allowing the debugger to execute CPU instructions directly. The debug master
can e.g. read out the register file by issuing mtdr instructions to the CPU, writing each register to
the Debug Communication Channel OCD registers.
34.3.6.4 Monitor Mode
Since the OCD registers are directly accessible by the CPU, it is possible to build a softwarebased
debugger that runs on the CPU itself. Setting the Monitor Mode bit in the Development
Control register causes the CPU to enter Monitor Mode instead of OCD mode when a breakpoint
triggers. Monitor Mode is similar to OCD mode, except that instructions are fetched from the
debug exception vector in regular program memory, instead of issued by the debug master.
34.3.6.5 Program Counter Monitoring
Normally, the CPU would need to be halted for a debugger to examine the current PC value.
However, the ATUC64/128/256L3/4U also proves a Debug Program Counter OCD register,
where the debugger can continuously read the current PC without affecting the CPU. This allows
the debugger to generate a simple statistic of the time spent in various areas of the code, easing
code optimization.
34.3.7 Memory Service Unit
The Memory Service Unit (MSU) is a block dedicated to test and debug functionality. It is controlled
through a dedicated set of registers addressed through the Service Access Bus.
852
32142D–06/2013
ATUC64/128/256L3/4U
34.3.7.1 Cyclic Redundancy Check (CRC)
The MSU can be used to automatically calculate the CRC of a block of data in memory. The
MSU will then read out each word in the specified memory block and report the CRC32-value in
an MSU register.
34.3.7.2 NanoTrace
The MSU additionally supports NanoTrace. This is a 32-bit AVR-specific feature, in which trace
data is output to memory instead of the AUX port. This allows the trace data to be extracted by
the debugger through the SAB, enabling trace features for aWire- or JTAG-based debuggers.
The user must write MSU registers to configure the address and size of the memory block to be
used for NanoTrace. The NanoTrace buffer can be anywhere in the physical address range,
including internal and external RAM, through an EBI, if present. This area may not be used by
the application running on the CPU.
34.3.8 AUX-based Debug Features
Utilizing the Auxiliary (AUX) port gives access to a wide range of advanced debug features. Of
prime importance are the trace features, which allow an external debugger to receive continuous
information on the program execution in the CPU. Additionally, Event In and Event Out pins
allow external events to be correlated with the program flow.
Debug tools utilizing the AUX port should connect to the device through a Nexus-compliant Mictor-38
connector, as described in the AVR32UC Technical Reference manual. This connector
includes the JTAG signals and the RESET_N pin, giving full access to the programming and
debug features in the device.
853
32142D–06/2013
ATUC64/128/256L3/4U
Figure 34-4. AUX+JTAG Based Debugger
34.3.8.1 Trace Operation
Trace features are enabled by writing OCD registers by the debugger. The OCD extracts the
trace information from the CPU, compresses this information and formats it into variable-length
messages according to the Nexus standard. The messages are buffered in a 16-frame transmit
queue, and are output on the AUX port one frame at a time.
The trace features can be configured to be very selective, to reduce the bandwidth on the AUX
port. In case the transmit queue overflows, error messages are produced to indicate loss of
data. The transmit queue module can optionally be configured to halt the CPU when an overflow
occurs, to prevent the loss of messages, at the expense of longer run-time for the program.
34.3.8.2 Program Trace
Program trace allows the debugger to continuously monitor the program execution in the CPU.
Program trace messages are generated for every branch in the program, and contains compressed
information, which allows the debugger to correlate the message with the source code
to identify the branch instruction and target address.
34.3.8.3 Data Trace
Data trace outputs a message every time a specific location is read or written. The message
contains information about the type (read/write) and size of the access, as well as the address
and data of the accessed location. The ATUC64/128/256L3/4U contains two data trace chanAVR32
AUX+JTAG
debu g tool
JTAG AUX
h ig h s p e e d
M ic to r3 8
T ra ce b u ffe r
P C
854
32142D–06/2013
ATUC64/128/256L3/4U
nels, each of which are controlled by a pair of OCD registers which determine the range of
addresses (or single address) which should produce data trace messages.
34.3.8.4 Ownership Trace
Program and data trace operate on virtual addresses. In cases where an operating system runs
several processes in overlapping virtual memory segments, the Ownership Trace feature can be
used to identify the process switch. When the O/S activates a process, it will write the process ID
number to an OCD register, which produces an Ownership Trace Message, allowing the debugger
to switch context for the subsequent program and data trace messages. As the use of this
feature depends on the software running on the CPU, it can also be used to extract other types
of information from the system.
34.3.8.5 Watchpoint Messages
The breakpoint modules normally used to generate program and data breakpoints can also be
used to generate Watchpoint messages, allowing a debugger to monitor program and data
events without halting the CPU. Watchpoints can be enabled independently of breakpoints, so a
breakpoint module can optionally halt the CPU when the trigger condition occurs. Data trace
modules can also be configured to produce watchpoint messages instead of regular data trace
messages.
34.3.8.6 Event In and Event Out Pins
The AUX port also contains an Event In pin (EVTI_N) and an Event Out pin (EVTO_N). EVTI_N
can be used to trigger a breakpoint when an external event occurs. It can also be used to trigger
specific program and data trace synchronization messages, allowing an external event to be
correlated to the program flow.
When the CPU enters debug mode, a Debug Status message is transmitted on the trace port.
All trace messages can be timestamped when they are received by the debug tool. However,
due to the latency of the transmit queue buffering, the timestamp will not be 100% accurate. To
improve this, EVTO_N can toggle every time a message is inserted into the transmit queue,
allowing trace messages to be timestamped precisely. EVTO_N can also toggle when a breakpoint
module triggers, or when the CPU enters debug mode, for any reason. This can be used to
measure precisely when the respective internal event occurs.
34.3.8.7 Software Quality Analysis (SQA)
Software Quality Analysis (SQA) deals with two important issues regarding embedded software
development. Code coverage involves identifying untested parts of the embedded code, to
improve test procedures and thus the quality of the released software. Performance analysis
allows the developer to precisely quantify the time spent in various parts of the code, allowing
bottlenecks to be identified and optimized.
Program trace must be used to accomplish these tasks without instrumenting (altering) the code
to be examined. However, traditional program trace cannot reconstruct the current PC value
without correlating the trace information with the source code, which cannot be done on-the-fly.
This limits program trace to a relatively short time segment, determined by the size of the trace
buffer in the debug tool.
The OCD system in ATUC64/128/256L3/4U extends program trace with SQA capabilities, allowing
the debug tool to reconstruct the PC value on-the-fly. Code coverage and performance
analysis can thus be reported for an unlimited execution sequence.
855
32142D–06/2013
ATUC64/128/256L3/4U
34.4 JTAG and Boundary-scan (JTAG)
Rev: 2.2.2.4
34.4.1 Features
• IEEE1149.1 compliant JTAG Interface
• Boundary-scan Chain for board-level testing
• Direct memory access and programming capabilities through JTAG Interface
34.4.2 Overview
The JTAG Interface offers a four pin programming and debug solution, including boundary-scan
support for board-level testing.
Figure 34-5 on page 856 shows how the JTAG is connected in an 32-bit AVR device. The TAP
Controller is a state machine controlled by the TCK and TMS signals. The TAP Controller
selects either the JTAG Instruction Register or one of several Data Registers as the scan chain
(shift register) between the TDI-input and TDO-output.
The Instruction Register holds JTAG instructions controlling the behavior of a Data Register. The
Device Identification Register, Bypass Register, and the boundary-scan chain are the Data Registers
used for board-level testing. The Reset Register can be used to keep the device reset
during test or programming.
The Service Access Bus (SAB) interface contains address and data registers for the Service
Access Bus, which gives access to On-Chip Debug, programming, and other functions in the
device. The SAB offers several modes of access to the address and data registers, as described
in Section 34.4.11.
Section 34.5 lists the supported JTAG instructions, with references to the description in this
document.
856
32142D–06/2013
ATUC64/128/256L3/4U
34.4.3 Block Diagram
Figure 34-5. JTAG and Boundary-scan Access
34.4.4 I/O Lines Description
34.4.5 Product Dependencies
In order to use this module, other parts of the system must be configured correctly, as described
below.
Table 34-7. I/O Line Description
Pin Name Pin Description Type Active Level
RESET_N External reset pin. Used when enabling and disabling the JTAG. Input Low
TCK Test Clock Input. Fully asynchronous to system clock frequency. Input
TMS Test Mode Select, sampled on rising TCK. Input
TDI Test Data In, sampled on rising TCK. Input
TDO Test Data Out, driven on falling TCK. Output
32-bit AVR device
JTAG data registers
TAP
Controller
Instruction Register
Device Identification
Register
By-pass Register
Reset Register
Service Access Bus
interface
Boundary Scan Chain
Pins and analog blocks
Data register
scan enable
JTAG Pins
Boundary scan enable
2nd JTAG
device
JTAG master
TDO TDI
Part specific registers
...
TMS TDO TDI
TMS
TCK
TCK
Instruction register
scan enable
SAB Internal I/O
lines
JTAG
TMS
TDI
TDO
TCK
857
32142D–06/2013
ATUC64/128/256L3/4U
34.4.5.1 I/O Lines
The TMS, TDI, TDO, and TCK pins are multiplexed with I/O lines. When the JTAG is used the
associated pins must be enabled. To enable the JTAG pins, refer to Section 34.4.7.
While using the multiplexed JTAG lines all normal peripheral activity on these lines is disabled.
The user must make sure that no external peripheral is blocking the JTAG lines while
debugging.
34.4.5.2 Power Management
When an instruction that accesses the SAB is loaded in the instruction register, before entering
a sleep mode, the system clocks are not switched off to allow debugging in sleep modes. This
can lead to a program behaving differently when debugging.
34.4.5.3 Clocks
The JTAG Interface uses the external TCK pin as clock source. This clock must be provided by
the JTAG master.
Instructions that use the SAB bus requires the internal main clock to be running.
34.4.6 JTAG Interface
The JTAG Interface is accessed through the dedicated JTAG pins shown in Table 34-7 on page
856. The TMS control line navigates the TAP controller, as shown in Figure 34-6 on page 858.
The TAP controller manages the serial access to the JTAG Instruction and Data registers. Data
is scanned into the selected instruction or data register on TDI, and out of the register on TDO,
in the Shift-IR and Shift-DR states, respectively. The LSB is shifted in and out first. TDO is highZ
in other states than Shift-IR and Shift-DR.
The device implements a 5-bit Instruction Register (IR). A number of public JTAG instructions
defined by the JTAG standard are supported, as described in Section 34.5.2, as well as a number
of 32-bit AVR-specific private JTAG instructions described in Section 34.5.3. Each
instruction selects a specific data register for the Shift-DR path, as described for each
instruction.
858
32142D–06/2013
ATUC64/128/256L3/4U
Figure 34-6. TAP Controller State Diagram
Test-LogicReset
Run-Test/
Idle
Select-DR
Scan
Select-IR
Scan
Capture-DR Capture-IR
Shift-DR Shift-IR
Exit1-DR Exit1-IR
Pause-DR Pause-IR
Exit2-DR Exit2-IR
Update-DR Update-IR
0
1 1
1
0
0
1
0
1
1
0
0
1
0
1
1
1
0
1 1
0 0
1 1
0
1
0
0 0
0
0
1
859
32142D–06/2013
ATUC64/128/256L3/4U
34.4.7 How to Initialize the Module
To enable the JTAG pins the TCK pin must be held low while the RESET_N pin is released.
After enabling the JTAG interface the halt bit is set automatically to prevent the system from running
code after the interface is enabled. To make the CPU run again set halt to zero using the
HALT command..
JTAG operation when RESET_N is pulled low is not possible.
Independent of the initial state of the TAP Controller, the Test-Logic-Reset state can always be
entered by holding TMS high for 5 TCK clock periods. This sequence should always be applied
at the start of a JTAG session and after enabling the JTAG pins to bring the TAP Controller into
a defined state before applying JTAG commands. Applying a 0 on TMS for 1 TCK period brings
the TAP Controller to the Run-Test/Idle state, which is the starting point for JTAG operations.
34.4.8 How to disable the module
To disable the JTAG pins the TCK pin must be held high while RESET_N pin is released.
34.4.9 Typical Sequence
Assuming Run-Test/Idle is the present state, a typical scenario for using the JTAG Interface
follows.
34.4.9.1 Scanning in JTAG Instruction
At the TMS input, apply the sequence 1, 1, 0, 0 at the rising edges of TCK to enter the Shift
Instruction Register (Shift-IR) state. While in this state, shift the 5 bits of the JTAG instructions
into the JTAG instruction register from the TDI input at the rising edge of TCK. During shifting,
the JTAG outputs status bits on TDO, refer to Section 34.5 for a description of these. The TMS
input must be held low during input of the 4 LSBs in order to remain in the Shift-IR state. The
JTAG Instruction selects a particular Data Register as path between TDI and TDO and controls
the circuitry surrounding the selected Data Register.
Apply the TMS sequence 1, 1, 0 to re-enter the Run-Test/Idle state. The instruction is latched
onto the parallel output from the shift register path in the Update-IR state. The Exit-IR, Pause-IR,
and Exit2-IR states are only used for navigating the state machine.
Figure 34-7. Scanning in JTAG Instruction
34.4.9.2 Scanning in/out Data
At the TMS input, apply the sequence 1, 0, 0 at the rising edges of TCK to enter the Shift Data
Register (Shift-DR) state. While in this state, upload the selected Data Register (selected by the
present JTAG instruction in the JTAG Instruction Register) from the TDI input at the rising edge
TCK
TAP State TLR RTI SelDR SelIR CapIR ShIR Ex1IR UpdIR RTI
TMS
TDI Instruction
TDO ImplDefined
860
32142D–06/2013
ATUC64/128/256L3/4U
of TCK. In order to remain in the Shift-DR state, the TMS input must be held low. While the Data
Register is shifted in from the TDI pin, the parallel inputs to the Data Register captured in the
Capture-DR state is shifted out on the TDO pin.
Apply the TMS sequence 1, 1, 0 to re-enter the Run-Test/Idle state. If the selected Data Register
has a latched parallel-output, the latching takes place in the Update-DR state. The Exit-DR,
Pause-DR, and Exit2-DR states are only used for navigating the state machine.
As shown in the state diagram, the Run-Test/Idle state need not be entered between selecting
JTAG instruction and using Data Registers.
34.4.10 Boundary-scan
The boundary-scan chain has the capability of driving and observing the logic levels on the digital
I/O pins, as well as the boundary between digital and analog logic for analog circuitry having
off-chip connections. At system level, all ICs having JTAG capabilities are connected serially by
the TDI/TDO signals to form a long shift register. An external controller sets up the devices to
drive values at their output pins, and observe the input values received from other devices. The
controller compares the received data with the expected result. In this way, boundary-scan provides
a mechanism for testing interconnections and integrity of components on Printed Circuits
Boards by using the 4 TAP signals only.
The four IEEE 1149.1 defined mandatory JTAG instructions IDCODE, BYPASS, SAMPLE/PRELOAD,
and EXTEST can be used for testing the Printed Circuit Board. Initial scanning of the
data register path will show the ID-code of the device, since IDCODE is the default JTAG
instruction. It may be desirable to have the 32-bit AVR device in reset during test mode. If not
reset, inputs to the device may be determined by the scan operations, and the internal software
may be in an undetermined state when exiting the test mode. If needed, the BYPASS instruction
can be issued to make the shortest possible scan chain through the device. The device can be
set in the reset state either by pulling the external RESETn pin low, or issuing the AVR_RESET
instruction with appropriate setting of the Reset Data Register.
The EXTEST instruction is used for sampling external pins and loading output pins with data.
The data from the output latch will be driven out on the pins as soon as the EXTEST instruction
is loaded into the JTAG IR-register. Therefore, the SAMPLE/PRELOAD should also be used for
setting initial values to the scan ring, to avoid damaging the board when issuing the EXTEST
instruction for the first time. SAMPLE/PRELOAD can also be used for taking a snapshot of the
external pins during normal operation of the part.
When using the JTAG Interface for boundary-scan, the JTAG TCK clock is independent of the
internal chip clock. The internal chip clock is not required to run during boundary-scan
operations.
NOTE: For pins connected to 5V lines care should be taken to not drive the pins to a logic one
using boundary-scan, as this will create a current flowing from the 3,3V driver to the 5V pull-up
on the line. Optionally a series resistor can be added between the line and the pin to reduce the
current.
Details about the boundary-scan chain can be found in the BSDL file for the device. This can be
found on the Atmel website.
34.4.11 Service Access Bus
The AVR32 architecture offers a common interface for access to On-Chip Debug, programming,
and test functions. These are mapped on a common bus called the Service Access Bus (SAB),
861
32142D–06/2013
ATUC64/128/256L3/4U
which is linked to the JTAG through a bus master module, which also handles synchronization
between the TCK and SAB clocks.
For more information about the SAB and a list of SAB slaves see the Service Access Bus
chapter.
34.4.11.1 SAB Address Mode
The MEMORY_SIZED_ACCESS instruction allows a sized read or write to any 36-bit address
on the bus. MEMORY_WORD_ACCESS is a shorthand instruction for 32-bit accesses to any
36-bit address, while the NEXUS_ACCESS instruction is a Nexus-compliant shorthand instruction
for accessing the 32-bit OCD registers in the 7-bit address space reserved for these. These
instructions require two passes through the Shift-DR TAP state: one for the address and control
information, and one for data.
34.4.11.2 Block Transfer
To increase the transfer rate, consecutive memory accesses can be accomplished by the
MEMORY_BLOCK_ACCESS instruction, which only requires a single pass through Shift-DR for
data transfer only. The address is automatically incremented according to the size of the last
SAB transfer.
34.4.11.3 Canceling a SAB Access
It is possible to abort an ongoing SAB access by the CANCEL_ACCESS instruction, to avoid
hanging the bus due to an extremely slow slave.
34.4.11.4 Busy Reporting
As the time taken to perform an access may vary depending on system activity and current chip
frequency, all the SAB access JTAG instructions can return a busy indicator. This indicates
whether a delay needs to be inserted, or an operation needs to be repeated in order to be successful.
If a new access is requested while the SAB is busy, the request is ignored.
The SAB becomes busy when:
• Entering Update-DR in the address phase of any read operation, e.g., after scanning in a
NEXUS_ACCESS address with the read bit set.
• Entering Update-DR in the data phase of any write operation, e.g., after scanning in data for
a NEXUS_ACCESS write.
• Entering Update-DR during a MEMORY_BLOCK_ACCESS.
• Entering Update-DR after scanning in a counter value for SYNC.
• Entering Update-IR after scanning in a MEMORY_BLOCK_ACCESS if the previous access
was a read and data was scanned after scanning the address.
The SAB becomes ready again when:
• A read or write operation completes.
• A SYNC countdown completed.
• A operation is cancelled by the CANCEL_ACCESS instruction.
What to do if the busy bit is set:
• During Shift-IR: The new instruction is selected, but the previous operation has not yet
completed and will continue (unless the new instruction is CANCEL_ACCESS). You may
862
32142D–06/2013
ATUC64/128/256L3/4U
continue shifting the same instruction until the busy bit clears, or start shifting data. If shifting
data, you must be prepared that the data shift may also report busy.
• During Shift-DR of an address: The new address is ignored. The SAB stays in address mode,
so no data must be shifted. Repeat the address until the busy bit clears.
• During Shift-DR of read data: The read data is invalid. The SAB stays in data mode. Repeat
scanning until the busy bit clears.
• During Shift-DR of write data: The write data is ignored. The SAB stays in data mode. Repeat
scanning until the busy bit clears.
34.4.11.5 Error Reporting
The Service Access Bus may not be able to complete all accesses as requested. This may be
because the address is invalid, the addressed area is read-only or cannot handle byte/halfword
accesses, or because the chip is set in a protected mode where only limited accesses are
allowed.
The error bit is updated when an access completes, and is cleared when a new access starts.
What to do if the error bit is set:
• During Shift-IR: The new instruction is selected. The last operation performed using the old
instruction did not complete successfully.
• During Shift-DR of an address: The previous operation failed. The new address is accepted.
If the read bit is set, a read operation is started.
• During Shift-DR of read data: The read operation failed, and the read data is invalid.
• During Shift-DR of write data: The previous write operation failed. The new data is accepted
and a write operation started. This should only occur during block writes or stream writes. No
error can occur between scanning a write address and the following write data.
• While polling with CANCEL_ACCESS: The previous access was cancelled. It may or may not
have actually completed.
• After power-up: The error bit is set after power up, but there has been no previous SAB
instruction so this error can be discarded.
34.4.11.6 Protected Reporting
A protected status may be reported during Shift-IR or Shift-DR. This indicates that the security
bit in the Flash Controller is set and that the chip is locked for access, according to Section
34.5.1.
The protected state is reported when:
• The Flash Controller is under reset. This can be due to the AVR_RESET command or the
RESET_N line.
• The Flash Controller has not read the security bit from the flash yet (This will take a a few
ms). Happens after the Flash Controller reset has been released.
• The security bit in the Flash Controller is set.
What to do if the protected bit is set:
• Release all active AVR_RESET domains, if any.
• Release the RESET_N line.
• Wait a few ms for the security bit to clear. It can be set temporarily due to a reset.
863
32142D–06/2013
ATUC64/128/256L3/4U
• Perform a CHIP_ERASE to clear the security bit. NOTE: This will erase all the contents of the
non-volatile memory.
34.5 JTAG Instruction Summary
The implemented JTAG instructions in the 32-bit AVR are shown in the table below.
34.5.1 Security Restrictions
When the security fuse in the Flash is programmed, the following JTAG instructions are
restricted:
• NEXUS_ACCESS
• MEMORY_WORD_ACCESS
• MEMORY_BLOCK_ACCESS
• MEMORY_SIZED_ACCESS
For description of what memory locations remain accessible, please refer to the SAB address
map.
Full access to these instructions is re-enabled when the security fuse is erased by the
CHIP_ERASE JTAG instruction.
Table 34-8. JTAG Instruction Summary
Instruction
OPCODE Instruction Description
0x01 IDCODE Select the 32-bit Device Identification register as data register.
0x02 SAMPLE_PRELOAD Take a snapshot of external pin values without affecting system operation.
0x03 EXTEST Select boundary-scan chain as data register for testing circuitry external to
the device.
0x04 INTEST Select boundary-scan chain for internal testing of the device.
0x06 CLAMP Bypass device through Bypass register, while driving outputs from boundaryscan
register.
0x0C AVR_RESET Apply or remove a static reset to the device
0x0F CHIP_ERASE Erase the device
0x10 NEXUS_ACCESS Select the SAB Address and Data registers as data register for the TAP. The
registers are accessed in Nexus mode.
0x11 MEMORY_WORD_ACCESS Select the SAB Address and Data registers as data register for the TAP.
0x12 MEMORY_BLOCK_ACCESS Select the SAB Data register as data register for the TAP. The address is
auto-incremented.
0x13 CANCEL_ACCESS Cancel an ongoing Nexus or Memory access.
0x14 MEMORY_SERVICE Select the SAB Address and Data registers as data register for the TAP. The
registers are accessed in Memory Service mode.
0x15 MEMORY_SIZED_ACCESS Select the SAB Address and Data registers as data register for the TAP.
0x17 SYNC Synchronization counter
0x1C HALT Halt the CPU for safe programming.
0x1F BYPASS Bypass this device through the bypass register.
Others N/A Acts as BYPASS
864
32142D–06/2013
ATUC64/128/256L3/4U
Note that the security bit will read as programmed and block these instructions also if the Flash
Controller is statically reset.
Other security mechanisms can also restrict these functions. If such mechanisms are present
they are listed in the SAB address map section.
34.5.1.1 Notation
Table 34-10 on page 864 shows bit patterns to be shifted in a format like "peb01". Each character
corresponds to one bit, and eight bits are grouped together for readability. The least
significantbit is always shifted first, and the most significant bit shifted last. The symbols used
are shown in Table 34-9.
In many cases, it is not required to shift all bits through the data register. Bit patterns are shown
using the full width of the shift register, but the suggested or required bits are emphasized using
bold text. I.e. given the pattern "aaaaaaar xxxxxxxx xxxxxxxx xxxxxxxx xx", the shift register is
34 bits, but the test or debug unit may choose to shift only 8 bits "aaaaaaar".
The following describes how to interpret the fields in the instruction description tables:
Table 34-9. Symbol Description
Symbol Description
0 Constant low value - always reads as zero.
1 Constant high value - always reads as one.
a An address bit - always scanned with the least significant bit first
b A busy bit. Reads as one if the SAB was busy, or zero if it was not. See Section 34.4.11.4 for
details on how the busy reporting works.
d A data bit - always scanned with the least significant bit first.
e An error bit. Reads as one if an error occurred, or zero if not. See Section 34.4.11.5 for
details on how the error reporting works.
p
The chip protected bit. Some devices may be set in a protected state where access to chip
internals are severely restricted. See the documentation for the specific device for details.
On devices without this possibility, this bit always reads as zero.
r A direction bit. Set to one to request a read, set to zero to request a write.
s A size bit. The size encoding is described where used.
x A don’t care bit. Any value can be shifted in, and output data should be ignored.
Table 34-10. Instruction Description
Instruction Description
IR input value
Shows the bit pattern to shift into IR in the Shift-IR state in order to select this
instruction. The pattern is show both in binary and in hexadecimal form for
convenience.
Example: 10000 (0x10)
IR output value
Shows the bit pattern shifted out of IR in the Shift-IR state when this instruction is
active.
Example: peb01
865
32142D–06/2013
ATUC64/128/256L3/4U
34.5.2 Public JTAG Instructions
The JTAG standard defines a number of public JTAG instructions. These instructions are
described in the sections below.
34.5.2.1 IDCODE
This instruction selects the 32 bit Device Identification register (DID) as Data Register. The DID
register consists of a version number, a device number, and the manufacturer code chosen by
JEDEC. This is the default instruction after a JTAG reset. Details about the DID register can be
found in the module configuration section at the end of this chapter.
Starting in Run-Test/Idle, the Device Identification register is accessed in the following way:
1. Select the IR Scan path.
2. In Capture-IR: The IR output value is latched into the shift register.
3. In Shift-IR: The instruction register is shifted by the TCK input.
4. Return to Run-Test/Idle.
5. Select the DR Scan path.
6. In Capture-DR: The IDCODE value is latched into the shift register.
7. In Shift-DR: The IDCODE scan chain is shifted by the TCK input.
8. Return to Run-Test/Idle.
34.5.2.2 SAMPLE_PRELOAD
This instruction takes a snap-shot of the input/output pins without affecting the system operation,
and pre-loading the scan chain without updating the DR-latch. The boundary-scan chain is
selected as Data Register.
Starting in Run-Test/Idle, the Device Identification register is accessed in the following way:
DR Size Shows the number of bits in the data register chain when this instruction is active.
Example: 34 bits
DR input value
Shows which bit pattern to shift into the data register in the Shift-DR state when this
instruction is active. Multiple such lines may exist, e.g., to distinguish between
reads and writes.
Example: aaaaaaar xxxxxxxx xxxxxxxx xxxxxxxx xx
DR output value
Shows the bit pattern shifted out of the data register in the Shift-DR state when this
instruction is active. Multiple such lines may exist, e.g., to distinguish between
reads and writes.
Example: xx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxeb
Table 34-10. Instruction Description (Continued)
Instruction Description
Table 34-11. IDCODE Details
Instructions Details
IR input value 00001 (0x01)
IR output value p0001
DR Size 32
DR input value xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx
DR output value Device Identification Register
866
32142D–06/2013
ATUC64/128/256L3/4U
1. Select the IR Scan path.
2. In Capture-IR: The IR output value is latched into the shift register.
3. In Shift-IR: The instruction register is shifted by the TCK input.
4. Return to Run-Test/Idle.
5. Select the DR Scan path.
6. In Capture-DR: The Data on the external pins are sampled into the boundary-scan
chain.
7. In Shift-DR: The boundary-scan chain is shifted by the TCK input.
8. Return to Run-Test/Idle.
34.5.2.3 EXTEST
This instruction selects the boundary-scan chain as Data Register for testing circuitry external to
the 32-bit AVR package. The contents of the latched outputs of the boundary-scan chain is
driven out as soon as the JTAG IR-register is loaded with the EXTEST instruction.
Starting in Run-Test/Idle, the EXTEST instruction is accessed the following way:
1. Select the IR Scan path.
2. In Capture-IR: The IR output value is latched into the shift register.
3. In Shift-IR: The instruction register is shifted by the TCK input.
4. In Update-IR: The data from the boundary-scan chain is applied to the output pins.
5. Return to Run-Test/Idle.
6. Select the DR Scan path.
7. In Capture-DR: The data on the external pins is sampled into the boundary-scan chain.
8. In Shift-DR: The boundary-scan chain is shifted by the TCK input.
9. In Update-DR: The data from the scan chain is applied to the output pins.
10. Return to Run-Test/Idle.
Table 34-12. SAMPLE_PRELOAD Details
Instructions Details
IR input value 00010 (0x02)
IR output value p0001
DR Size Depending on boundary-scan chain, see BSDL-file.
DR input value Depending on boundary-scan chain, see BSDL-file.
DR output value Depending on boundary-scan chain, see BSDL-file.
Table 34-13. EXTEST Details
Instructions Details
IR input value 00011 (0x03)
IR output value p0001
DR Size Depending on boundary-scan chain, see BSDL-file.
DR input value Depending on boundary-scan chain, see BSDL-file.
DR output value Depending on boundary-scan chain, see BSDL-file.
867
32142D–06/2013
ATUC64/128/256L3/4U
34.5.2.4 INTEST
This instruction selects the boundary-scan chain as Data Register for testing internal logic in the
device. The logic inputs are determined by the boundary-scan chain, and the logic outputs are
captured by the boundary-scan chain. The device output pins are driven from the boundary-scan
chain.
Starting in Run-Test/Idle, the INTEST instruction is accessed the following way:
1. Select the IR Scan path.
2. In Capture-IR: The IR output value is latched into the shift register.
3. In Shift-IR: The instruction register is shifted by the TCK input.
4. In Update-IR: The data from the boundary-scan chain is applied to the internal logic
inputs.
5. Return to Run-Test/Idle.
6. Select the DR Scan path.
7. In Capture-DR: The data on the internal logic is sampled into the boundary-scan chain.
8. In Shift-DR: The boundary-scan chain is shifted by the TCK input.
9. In Update-DR: The data from the boundary-scan chain is applied to internal logic
inputs.
10. Return to Run-Test/Idle.
34.5.2.5 CLAMP
This instruction selects the Bypass register as Data Register. The device output pins are driven
from the boundary-scan chain.
Starting in Run-Test/Idle, the CLAMP instruction is accessed the following way:
1. Select the IR Scan path.
2. In Capture-IR: The IR output value is latched into the shift register.
3. In Shift-IR: The instruction register is shifted by the TCK input.
4. In Update-IR: The data from the boundary-scan chain is applied to the output pins.
5. Return to Run-Test/Idle.
6. Select the DR Scan path.
7. In Capture-DR: A logic ‘0’ is loaded into the Bypass Register.
8. In Shift-DR: Data is scanned from TDI to TDO through the Bypass register.
Table 34-14. INTEST Details
Instructions Details
IR input value 00100 (0x04)
IR output value p0001
DR Size Depending on boundary-scan chain, see BSDL-file.
DR input value Depending on boundary-scan chain, see BSDL-file.
DR output value Depending on boundary-scan chain, see BSDL-file.
868
32142D–06/2013
ATUC64/128/256L3/4U
9. Return to Run-Test/Idle.
34.5.2.6 BYPASS
This instruction selects the 1-bit Bypass Register as Data Register.
Starting in Run-Test/Idle, the CLAMP instruction is accessed the following way:
1. Select the IR Scan path.
2. In Capture-IR: The IR output value is latched into the shift register.
3. In Shift-IR: The instruction register is shifted by the TCK input.
4. Return to Run-Test/Idle.
5. Select the DR Scan path.
6. In Capture-DR: A logic ‘0’ is loaded into the Bypass Register.
7. In Shift-DR: Data is scanned from TDI to TDO through the Bypass register.
8. Return to Run-Test/Idle.
34.5.3 Private JTAG Instructions
The 32-bit AVR defines a number of private JTAG instructions, not defined by the JTAG standard.
Each instruction is briefly described in text, with details following in table form.
34.5.3.1 NEXUS_ACCESS
This instruction allows Nexus-compliant access to the On-Chip Debug registers through the
SAB. The 7-bit register index, a read/write control bit, and the 32-bit data is accessed through
the JTAG port.
The data register is alternately interpreted by the SAB as an address register and a data register.
The SAB starts in address mode after the NEXUS_ACCESS instruction is selected, and
toggles between address and data mode each time a data scan completes with the busy bit
cleared.
NOTE: The polarity of the direction bit is inverse of the Nexus standard.
Table 34-15. CLAMP Details
Instructions Details
IR input value 00110 (0x06)
IR output value p0001
DR Size 1
DR input value x
DR output value x
Table 34-16. BYPASS Details
Instructions Details
IR input value 11111 (0x1F)
IR output value p0001
DR Size 1
DR input value x
DR output value x
869
32142D–06/2013
ATUC64/128/256L3/4U
Starting in Run-Test/Idle, OCD registers are accessed in the following way:
1. Select the IR Scan path.
2. In Capture-IR: The IR output value is latched into the shift register.
3. In Shift-IR: The instruction register is shifted by the TCK input.
4. Return to Run-Test/Idle.
5. Select the DR Scan path.
6. In Shift-DR: Scan in the direction bit (1=read, 0=write) and the 7-bit address for the
OCD register.
7. Go to Update-DR and re-enter Select-DR Scan.
8. In Shift-DR: For a read operation, scan out the contents of the addressed register. For a
write operation, scan in the new contents of the register.
9. Return to Run-Test/Idle.
For any operation, the full 7 bits of the address must be provided. For write operations, 32 data
bits must be provided, or the result will be undefined. For read operations, shifting may be terminated
once the required number of bits have been acquired.
34.5.3.2 MEMORY_SERVICE
This instruction allows access to registers in an optional Memory Service Unit. The 7-bit register
index, a read/write control bit, and the 32-bit data is accessed through the JTAG port.
The data register is alternately interpreted by the SAB as an address register and a data register.
The SAB starts in address mode after the MEMORY_SERVICE instruction is selected, and
toggles between address and data mode each time a data scan completes with the busy bit
cleared.
Starting in Run-Test/Idle, Memory Service registers are accessed in the following way:
1. Select the IR Scan path.
2. In Capture-IR: The IR output value is latched into the shift register.
3. In Shift-IR: The instruction register is shifted by the TCK input.
4. Return to Run-Test/Idle.
5. Select the DR Scan path.
6. In Shift-DR: Scan in the direction bit (1=read, 0=write) and the 7-bit address for the
Memory Service register.
Table 34-17. NEXUS_ACCESS Details
Instructions Details
IR input value 10000 (0x10)
IR output value peb01
DR Size 34 bits
DR input value (Address phase) aaaaaaar xxxxxxxx xxxxxxxx xxxxxxxx xx
DR input value (Data read phase) xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xx
DR input value (Data write phase) dddddddd dddddddd dddddddd dddddddd xx
DR output value (Address phase) xx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxeb
DR output value (Data read phase) eb dddddddd dddddddd dddddddd dddddddd
DR output value (Data write phase) xx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxeb
870
32142D–06/2013
ATUC64/128/256L3/4U
7. Go to Update-DR and re-enter Select-DR Scan.
8. In Shift-DR: For a read operation, scan out the contents of the addressed register. For a
write operation, scan in the new contents of the register.
9. Return to Run-Test/Idle.
For any operation, the full 7 bits of the address must be provided. For write operations, 32 data
bits must be provided, or the result will be undefined. For read operations, shifting may be terminated
once the required number of bits have been acquired.
34.5.3.3 MEMORY_SIZED_ACCESS
This instruction allows access to the entire Service Access Bus data area. Data is accessed
through a 36-bit byte index, a 2-bit size, a direction bit, and 8, 16, or 32 bits of data. Not all units
mapped on the SAB bus may support all sizes of accesses, e.g., some may only support word
accesses.
The data register is alternately interpreted by the SAB as an address register and a data register.
The SAB starts in address mode after the MEMORY_SIZED_ACCESS instruction is
selected, and toggles between address and data mode each time a data scan completes with
the busy bit cleared.
Table 34-18. MEMORY_SERVICE Details
Instructions Details
IR input value 10100 (0x14)
IR output value peb01
DR Size 34 bits
DR input value (Address phase) aaaaaaar xxxxxxxx xxxxxxxx xxxxxxxx xx
DR input value (Data read phase) xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xx
DR input value (Data write phase) dddddddd dddddddd dddddddd dddddddd xx
DR output value (Address phase) xx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxeb
DR output value (Data read phase) eb dddddddd dddddddd dddddddd dddddddd
DR output value (Data write phase) xx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxeb
871
32142D–06/2013
ATUC64/128/256L3/4U
The size field is encoded as i Table 34-19.
Starting in Run-Test/Idle, SAB data is accessed in the following way:
1. Select the IR Scan path.
2. In Capture-IR: The IR output value is latched into the shift register.
3. In Shift-IR: The instruction register is shifted by the TCK input.
4. Return to Run-Test/Idle.
5. Select the DR Scan path.
6. In Shift-DR: Scan in the direction bit (1=read, 0=write), 2-bit access size, and the 36-bit
address of the data to access.
7. Go to Update-DR and re-enter Select-DR Scan.
8. In Shift-DR: For a read operation, scan out the contents of the addressed area. For a
write operation, scan in the new contents of the area.
9. Return to Run-Test/Idle.
For any operation, the full 36 bits of the address must be provided. For write operations, 32 data
bits must be provided, or the result will be undefined. For read operations, shifting may be terminated
once the required number of bits have been acquired.
Table 34-19. Size Field Semantics
Size field value Access size Data alignment
00 Byte (8 bits)
Address modulo 4 : data alignment
0: dddddddd xxxxxxxx xxxxxxxx xxxxxxxx
1: xxxxxxxx dddddddd xxxxxxxx xxxxxxxx
2: xxxxxxxx xxxxxxxx dddddddd xxxxxxxx
3: xxxxxxxx xxxxxxxx xxxxxxxx dddddddd
01 Halfword (16 bits)
Address modulo 4 : data alignment
0: dddddddd dddddddd xxxxxxxx xxxxxxxx
1: Not allowed
2: xxxxxxxx xxxxxxxx dddddddd dddddddd
3: Not allowed
10 Word (32 bits)
Address modulo 4 : data alignment
0: dddddddd dddddddd dddddddd dddddddd
1: Not allowed
2: Not allowed
3: Not allowed
11 Reserved N/A
Table 34-20. MEMORY_SIZED_ACCESS Details
Instructions Details
IR input value 10101 (0x15)
IR output value peb01
DR Size 39 bits
DR input value (Address phase) aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaassr
DR input value (Data read phase) xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxx
DR input value (Data write phase) dddddddd dddddddd dddddddd dddddddd xxxxxxx
872
32142D–06/2013
ATUC64/128/256L3/4U
34.5.3.4 MEMORY_WORD_ACCESS
This instruction allows access to the entire Service Access Bus data area. Data is accessed
through the 34 MSB of the SAB address, a direction bit, and 32 bits of data. This instruction is
identical to MEMORY_SIZED_ACCESS except that it always does word sized accesses. The
size field is implied, and the two lowest address bits are removed and not scanned in.
Note: This instruction was previously known as MEMORY_ACCESS, and is provided for backwards
compatibility.
The data register is alternately interpreted by the SAB as an address register and a data register.
The SAB starts in address mode after the MEMORY_WORD_ACCESS instruction is
selected, and toggles between address and data mode each time a data scan completes with
the busy bit cleared.
Starting in Run-Test/Idle, SAB data is accessed in the following way:
1. Select the IR Scan path.
2. In Capture-IR: The IR output value is latched into the shift register.
3. In Shift-IR: The instruction register is shifted by the TCK input.
4. Return to Run-Test/Idle.
5. Select the DR Scan path.
6. In Shift-DR: Scan in the direction bit (1=read, 0=write) and the 34-bit address of the
data to access.
7. Go to Update-DR and re-enter Select-DR Scan.
8. In Shift-DR: For a read operation, scan out the contents of the addressed area. For a
write operation, scan in the new contents of the area.
9. Return to Run-Test/Idle.
For any operation, the full 34 bits of the address must be provided. For write operations, 32 data
bits must be provided, or the result will be undefined. For read operations, shifting may be terminated
once the required number of bits have been acquired.
DR output value (Address phase) xxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxeb
DR output value (Data read phase) xxxxxeb dddddddd dddddddd dddddddd dddddddd
DR output value (Data write phase) xxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxeb
Table 34-20. MEMORY_SIZED_ACCESS Details (Continued)
Instructions Details
Table 34-21. MEMORY_WORD_ACCESS Details
Instructions Details
IR input value 10001 (0x11)
IR output value peb01
DR Size 35 bits
DR input value (Address phase) aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aar
DR input value (Data read phase) xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxx
DR input value (Data write phase) dddddddd dddddddd dddddddd dddddddd xxx
873
32142D–06/2013
ATUC64/128/256L3/4U
34.5.3.5 MEMORY_BLOCK_ACCESS
This instruction allows access to the entire SAB data area. Up to 32 bits of data is accessed at a
time, while the address is sequentially incremented from the previously used address.
In this mode, the SAB address, size, and access direction is not provided with each access.
Instead, the previous address is auto-incremented depending on the specified size and the previous
operation repeated. The address must be set up in advance with
MEMORY_SIZE_ACCESS or MEMORY_WORD_ACCESS. It is allowed, but not required, to
shift data after shifting the address.
This instruction is primarily intended to speed up large quantities of sequential word accesses. It
is possible to use it also for byte and halfword accesses, but the overhead in this is case much
larger as 32 bits must still be shifted for each access.
The following sequence should be used:
1. Use the MEMORY_SIZE_ACCESS or MEMORY_WORD_ACCESS to read or write the
first location.
2. Return to Run-Test/Idle.
3. Select the IR Scan path.
4. In Capture-IR: The IR output value is latched into the shift register.
5. In Shift-IR: The instruction register is shifted by the TCK input.
6. Return to Run-Test/Idle.
7. Select the DR Scan path. The address will now have incremented by 1, 2, or 4 (corresponding
to the next byte, halfword, or word location).
8. In Shift-DR: For a read operation, scan out the contents of the next addressed location.
For a write operation, scan in the new contents of the next addressed location.
9. Go to Update-DR.
10. If the block access is not complete, return to Select-DR Scan and repeat the access.
11. If the block access is complete, return to Run-Test/Idle.
For write operations, 32 data bits must be provided, or the result will be undefined. For read
operations, shifting may be terminated once the required number of bits have been acquired.
DR output value (Address phase) xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xeb
DR output value (Data read phase) xeb dddddddd dddddddd dddddddd dddddddd
DR output value (Data write phase) xxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxeb
Table 34-21. MEMORY_WORD_ACCESS Details (Continued)
Instructions Details
Table 34-22. MEMORY_BLOCK_ACCESS Details
Instructions Details
IR input value 10010 (0x12)
IR output value peb01
DR Size 34 bits
DR input value (Data read phase) xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xx
874
32142D–06/2013
ATUC64/128/256L3/4U
The overhead using block word access is 4 cycles per 32 bits of data, resulting in an 88% transfer
efficiency, or 2.1 MBytes per second with a 20 MHz TCK frequency.
34.5.3.6 CANCEL_ACCESS
If a very slow memory location is accessed during a SAB memory access, it could take a very
long time until the busy bit is cleared, and the SAB becomes ready for the next operation. The
CANCEL_ACCESS instruction provides a possibility to abort an ongoing transfer and report a
timeout to the JTAG master.
When the CANCEL_ACCESS instruction is selected, the current access will be terminated as
soon as possible. There are no guarantees about how long this will take, as the hardware may
not always be able to cancel the access immediately. The SAB is ready to respond to a new
command when the busy bit clears.
Starting in Run-Test/Idle, CANCEL_ACCESS is accessed in the following way:
1. Select the IR Scan path.
2. In Capture-IR: The IR output value is latched into the shift register.
3. In Shift-IR: The instruction register is shifted by the TCK input.
4. Return to Run-Test/Idle.
34.5.3.7 SYNC
This instruction allows external debuggers and testers to measure the ratio between the external
JTAG clock and the internal system clock. The SYNC data register is a 16-bit counter that
counts down to zero using the internal system clock. The busy bit stays high until the counter
reaches zero.
Starting in Run-Test/Idle, SYNC instruction is used in the following way:
1. Select the IR Scan path.
2. In Capture-IR: The IR output value is latched into the shift register.
3. In Shift-IR: The instruction register is shifted by the TCK input.
4. Return to Run-Test/Idle.
5. Select the DR Scan path.
DR input value (Data write phase) dddddddd dddddddd dddddddd dddddddd xx
DR output value (Data read phase) eb dddddddd dddddddd dddddddd dddddddd
DR output value (Data write phase) xx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxeb
Table 34-22. MEMORY_BLOCK_ACCESS Details (Continued)
Instructions Details
Table 34-23. CANCEL_ACCESS Details
Instructions Details
IR input value 10011 (0x13)
IR output value peb01
DR Size 1
DR input value x
DR output value 0
875
32142D–06/2013
ATUC64/128/256L3/4U
6. Scan in an 16-bit counter value.
7. Go to Update-DR and re-enter Select-DR Scan.
8. In Shift-DR: Scan out the busy bit, and until the busy bit clears goto 7.
9. Calculate an approximation to the internal clock speed using the elapsed time and the
counter value.
10. Return to Run-Test/Idle.
The full 16-bit counter value must be provided when starting the synch operation, or the result
will be undefined. When reading status, shifting may be terminated once the required number of
bits have been acquired.
34.5.3.8 AVR_RESET
This instruction allows a debugger or tester to directly control separate reset domains inside the
chip. The shift register contains one bit for each controllable reset domain. Setting a bit to one
resets that domain and holds it in reset. Setting a bit to zero releases the reset for that domain.
The AVR_RESET instruction can be used in the following way:
1. Select the IR Scan path.
2. In Capture-IR: The IR output value is latched into the shift register.
3. In Shift-IR: The instruction register is shifted by the TCK input.
4. Return to Run-Test/Idle.
5. Select the DR Scan path.
6. In Shift-DR: Scan in the value corresponding to the reset domains the JTAG master
wants to reset into the data register.
7. Return to Run-Test/Idle.
8. Stay in run test idle for at least 10 TCK clock cycles to let the reset propagate to the
system.
See the device specific documentation for the number of reset domains, and what these
domains are.
For any operation, all bits must be provided or the result will be undefined.
Table 34-24. SYNC_ACCESS Details
Instructions Details
IR input value 10111 (0x17)
IR output value peb01
DR Size 16 bits
DR input value dddddddd dddddddd
DR output value xxxxxxxx xxxxxxeb
Table 34-25. AVR_RESET Details
Instructions Details
IR input value 01100 (0x0C)
IR output value p0001
876
32142D–06/2013
ATUC64/128/256L3/4U
34.5.3.9 CHIP_ERASE
This instruction allows a programmer to completely erase all nonvolatile memories in a chip.
This will also clear any security bits that are set, so the device can be accessed normally. In
devices without non-volatile memories this instruction does nothing, and appears to complete
immediately.
The erasing of non-volatile memories starts as soon as the CHIP_ERASE instruction is selected.
The CHIP_ERASE instruction selects a 1 bit bypass data register.
A chip erase operation should be performed as:
1. Reset the system and stop the CPU from executing.
2. Select the IR Scan path.
3. In Capture-IR: The IR output value is latched into the shift register.
4. In Shift-IR: The instruction register is shifted by the TCK input.
5. Check the busy bit that was scanned out during Shift-IR. If the busy bit was set goto 2.
6. Return to Run-Test/Idle.
34.5.3.10 HALT
This instruction allows a programmer to easily stop the CPU to ensure that it does not execute
invalid code during programming.
This instruction selects a 1-bit halt register. Setting this bit to one halts the CPU. Setting this bit
to zero releases the CPU to run normally. The value shifted out from the data register is one if
the CPU is halted. Before releasing the halt command the CPU needs to be reset to ensure that
it will start at the reset startup address.
The HALT instruction can be used in the following way:
1. Select the IR Scan path.
2. In Capture-IR: The IR output value is latched into the shift register.
3. In Shift-IR: The instruction register is shifted by the TCK input.
4. Return to Run-Test/Idle.
5. Select the DR Scan path.
DR Size Device specific.
DR input value Device specific.
DR output value Device specific.
Table 34-25. AVR_RESET Details (Continued)
Instructions Details
Table 34-26. CHIP_ERASE Details
Instructions Details
IR input value 01111 (0x0F)
IR output value p0b01
Where b is the busy bit.
DR Size 1 bit
DR input value x
DR output value 0
877
32142D–06/2013
ATUC64/128/256L3/4U
6. In Shift-DR: Scan in the value 1 to halt the CPU, 0 to start CPU execution.
7. Return to Run-Test/Idle.
Table 34-27. HALT Details
Instructions Details
IR input value 11100 (0x1C)
IR output value p0001
DR Size 1 bit
DR input value d
DR output value d
878
32142D–06/2013
ATUC64/128/256L3/4U
34.5.4 JTAG Data Registers
The following device specific registers can be selected as JTAG scan chain depending on the
instruction loaded in the JTAG Instruction Register. Additional registers exist, but are implicitly
described in the functional description of the relevant instructions.
34.5.4.1 Device Identification Register
The Device Identification Register contains a unique identifier for each product. The register is
selected by the IDCODE instruction, which is the default instruction after a JTAG reset.
Device specific ID codes
The different device configurations have different JTAG ID codes, as shown in Table 34-28.
Note that if the flash controller is statically reset, the ID code will be undefined.
34.5.4.2 Reset Register
The reset register is selected by the AVR_RESET instruction and contains one bit for each reset
domain in the device. Setting each bit to one will keep that domain reset until the bit is cleared.
MSB LSB
Bit 31 28 27 12 11 1 0
Device ID Revision Part Number Manufacturer ID 1
4 bits 16 bits 11 bits 1 bit
Revision This is a 4 bit number identifying the revision of the component.
Rev A = 0x0, B = 0x1, etc.
Part Number The part number is a 16 bit code identifying the component.
Manufacturer ID The Manufacturer ID is a 11 bit code identifying the manufacturer.
The JTAG manufacturer ID for ATMEL is 0x01F.
Table 34-28. Device and JTAG ID
Device Name JTAG ID Code (R is the revision number)
ATUC256L3U 0xr21C303F
ATUC128L3U 0xr21C403F
ATUC64L3U 0xr21C503F
ATUC256L4U 0xr21C603F
ATUC128L4U 0xr21C703F
ATUC64L4U 0xr21C803F
Bit 0
Reset
domain System
879
32142D–06/2013
ATUC64/128/256L3/4U
34.5.4.3 Boundary--scan Chain
The boundary-scan chain has the capability of driving and observing the logic levels on the digital
I/O pins, as well as driving and observing the logic levels between the digital I/O pins and the
internal logic. Typically, output value, output enable, and input data are all available in the
boundary-scan chain.
The boundary-scan chain is described in the BSDL (Boundary Scan Description Language) file
available at the Atmel web site.
System Resets the whole chip, except the JTAG itself.
880
32142D–06/2013
ATUC64/128/256L3/4U
34.6 aWire Debug Interface (AW)
Rev.: 2.3.0.1
34.6.1 Features
• Single pin debug system.
• Half Duplex asynchronous communication (UART compatible).
• Full duplex mode for direct UART connection.
• Compatible with JTAG functionality, except boundary scan.
• Failsafe packet-oriented protocol.
• Read and write on-chip memory and program on-chip flash and fuses through SAB interface.
• On-Chip Debug access through SAB interface.
• Asynchronous receiver or transmitter when the aWire system is not used for debugging.
34.6.2 Overview
The aWire Debug Interface (AW) offers a single pin debug solution that is fully compatible with
the functionality offered by the JTAG interface, except boundary scan. This functionality includes
memory access, programming capabilities, and On-Chip Debug access.
Figure 34-8 on page 881 shows how the AW is connected in a 32-bit AVR device. The
RESET_N pin is used both as reset and debug pin. A special sequence on RESET_N is needed
to block the normal reset functionality and enable the AW.
The Service Access Bus (SAB) interface contains address and data registers for the Service
Access Bus, which gives access to On-Chip Debug, programming, and other functions in the
device. The SAB offers several modes of access to the address and data registers, as discussed
in Section 34.6.6.8.
Section 34.6.7 lists the supported aWire commands and responses, with references to the
description in this document.
If the AW is not used for debugging, the aWire UART can be used by the user to send or receive
data with one stop bit, eight data bits, no parity bits, and one stop bit. This can be controlled
through the aWire user interface.
881
32142D–06/2013
ATUC64/128/256L3/4U
34.6.3 Block Diagram
Figure 34-8. aWire Debug Interface Block Diagram
34.6.4 I/O Lines Description
34.6.5 Product Dependencies
In order to use this module, other parts of the system must be configured correctly, as described
below.
Table 34-29. I/O Lines Description
Name Description Type
DATA aWire data multiplexed with the RESET_N pin. Input/Output
DATAOUT aWire data output in 2-pin mode. Output
UART
Reset
filter
External reset
AW_ENABLE
RESET_N
Baudrate Detector
RW SZ ADDR DATA
CRC
AW CONTROL
AW User Interface
SAB interface
RESET command
Power
Manager
HALT command CPU
Flash
Controller CHIP_ERASE command
aWire Debug Interface
PB
SAB
882
32142D–06/2013
ATUC64/128/256L3/4U
34.6.5.1 I/O Lines
The pin used by AW is multiplexed with the RESET_N pin. The reset functionality is the default
function of this pin. To enable the aWire functionality on the RESET_N pin the user must enable
the AW either by sending the enable sequence over the RESET_N pin from an external aWire
master or by enabling the aWire user interface.
In 2-pin mode data is received on the RESET_N line, but transmitted on the DATAOUT line.
After sending the 2_PIN_MODE command the DATAOUT line is automatically enabled. All other
peripheral functions on this pin is disabled.
34.6.5.2 Power Management
When debugging through AW the system clocks are automatically turned on to allow debugging
in sleep modes.
34.6.5.3 Clocks
The aWire UART uses the internal 120 MHz RC oscillator (RC120M) as clock source for its
operation. When enabling the AW the RC120M is automatically started.
34.6.5.4 External Components
The AW needs an external pullup on the RESET_N pin to ensure that the pin is pulled up when
the bus is not driven.
34.6.6 Functional Description
34.6.6.1 aWire Communication Protocol
The AW is accessed through the RESET_N pin shown in Table 34-29 on page 881. The AW
communicates through a UART operating at variable baud rate (depending on a sync pattern)
with one start bit, 8 data bits (LSB first), one stop bit, and no parity bits. The aWire protocol is
based upon command packets from an externalmaster and response packets from the slave
(AW). The master always initiates communication and decides the baud rate.
The packet contains a sync byte (0x55), a command/response byte, two length bytes (optional),
a number of data bytes as defined in the length field (optional), and two CRC bytes. If the command/response
has the most significant bit set, the command/response also carries the optional
length and data fields. The CRC field is not checked if the CRC value transmitted is 0x0000.
Table 34-30. aWire Packet Format
Field Number of bytes Description Comment Optional
SYNC 1 Sync pattern (0x55). Used by the receiver to set the baud rate
clock. No
COMMAND/
RESPONSE 1 Command from the master or
response from the slave.
When the most significant bit is set the
command/response has a length field. A
response has the next most significant bit
set. A command does not have this bit set.
No
883
32142D–06/2013
ATUC64/128/256L3/4U
CRC calculation
The CRC is calculated from the command/response, length, and data fields. The polynomial
used is the FCS16 (or CRC-16-CCIT) in reverse mode (0x8408) and the starting value is
0x0000.
Example command
Below is an example command from the master with additional data.
Figure 34-9. Example Command
Example response
Below is an example response from the slave with additional data.
Figure 34-10. Example Response
LENGTH 2 The number of bytes in the DATA
field. Yes
DATA LENGTH Data according to command/
response.
Yes
CRC 2 CRC calculated with the FCS16
polynomial.
CRC value of 0x0000 makes the aWire
disregard the CRC if the master does not
support it.
No
Table 34-30. aWire Packet Format
Field Number of bytes Description Comment Optional
baud_rate_clk
data_pin ...
field sync(0x55) command(0x81) length(MSB) length(lsb)
...
data(MSB) data(LSB) CRC(MSB) CRC(lsb)
baud_rate_clk
data_pin ...
field sync(0x55) response(0xC1) length(MSB) length(lsb)
...
data(MSB) data(LSB) CRC(MSB) CRC(lsb)
884
32142D–06/2013
ATUC64/128/256L3/4U
Avoiding drive contention when changing direction
The aWire debug protocol uses one dataline in both directions. To avoid both the master and the
slave to drive this line when changing direction the AW has a built in guard time before it starts to
drive the line. At reset this guard time is set to maximum (128 bit cycles), but can be lowered by
the master upon command.
The AW will release the line immediately after the stop character has been transmitted.
During the direction change there can be a period when the line is not driven. An external pullup
has to be added to RESET_N to keep the signal stable when neither master or slave is actively
driving the line.
34.6.6.2 The RESET_N pin
Normal reset functionality on the RESET_N pin is disabled when using aWire. However, the
user can reset the system through the RESET aWire command. During aWire operation the
RESET_N pin should not be connected to an external reset circuitry, but disconnected via a
switch or a jumper to avoid drive contention and speed problems.
Figure 34-11. Reset Circuitry and aWire.
34.6.6.3 Initializing the AW
To enable AW, the user has to send a 0x55 pattern with a baudrate of 1 kHz on the RESET_N
pin. The AW is enabled after transmitting this pattern and the user can start transmitting commands.
This pattern is not the sync pattern for the first command.
After enabling the aWire debug interface the halt bit is set automatically to prevent the system
from running code after the interface is enabled. To make the CPU run again set halt to zero
using the HALT command.
34.6.6.4 Disabling the AW
To disable AW, the user can keep the RESET_N pin low for 100 ms. This will disable the AW,
return RESET_N to its normal function, and reset the device.
An aWire master can also disable aWire by sending the DISABLE command. After acking the
command the AW will be disabled and RESET_N returns to its normal function.
RESET_N
AW Debug
Interface
Jumper
MCU
Power Manager
aWire master connector
Board Reset
Circuitry
885
32142D–06/2013
ATUC64/128/256L3/4U
34.6.6.5 Resetting the AW
The aWire master can reset the AW slave by pulling the RESET_N pin low for 20 ms. This is
equivalent to disabling and then enabling AW.
34.6.6.6 2-pin Mode
To avoid using special hardware when using a normal UART device as aWire master, the aWire
slave has a 2-pin mode where one pin is used as input and on pin is used as output. To enable
this mode the 2_PIN_MODE command must be sent. After sending the command, all responses
will be sent on the DATAOUT pin instead of the RESET_N pin. Commands are still received on
the RESET_N pin.
34.6.6.7 Baud Rate Clock
The communication speed is set by the master in the sync field of the command. The AW will
use this to resynchronize its baud rate clock and reply on this frequency. The minimum frequency
of the communication is 1 kHz. The maximum frequency depends on the internal clock
source for the AW (RC120M). The baud rate clock is generated by AW with the following
formula:
Where is the baud rate frequency and is the frequency of the internal RC120M. TUNE is
the value returned by the BAUD_RATE response.
To find the max frequency the user can issue the TUNE command to the AW to make it return
the TUNE value. This value can be used to compute the . The maximum operational frequency
( ) is then:
34.6.6.8 Service Access Bus
The AVR32 architecture offers a common interface for access to On-Chip Debug, programming,
and test functions. These are mapped on a common bus called the Service Access Bus (SAB),
which is linked to the aWire through a bus master module, which also handles synchronization
between the aWire and SAB clocks.
For more information about the SAB and a list of SAB slaves see the Service Access Bus
chapter.
SAB Clock
When accessing the SAB through the aWire there are no limitations on baud rate frequency
compared to chip frequency, although there must be an active system clock in order for the SAB
accesses to complete. If the system clock (CLK_SYS) is switched off in sleep mode, activity on
the aWire pin will restart the CLK_SYS automatically, without waking the device from sleep.
aWire masters may optimize the transfer rate by adjusting the baud rate frequency in relation to
the CLK_SYS. This ratio can be measured with the MEMORY_SPEED_REQUEST command.
When issuing the MEMORY_SPEED_REQUEST command a counter value CV is returned. CV
can be used to calculate the SAB speed ( ) using this formula:
f
aw
TUNE f br
8 = ----------------------------
f
br f
aw
f
aw
f
brmax
f
brmax
f
aw
4 = -------
f
sab
886
32142D–06/2013
ATUC64/128/256L3/4U
SAB Address Mode
The Service Access Bus uses 36 address bits to address memory or registers in any of the
slaves on the bus. The bus supports sized accesses of bytes (8 bits), halfwords (16 bits), or
words (32 bits). All accesses must be aligned to the size of the access, i.e. halfword accesses
must have the lowest address bit cleared, and word accesses must have the two lowest address
bits cleared.
Two instructions exist to access the SAB: MEMORY_WRITE and MEMORY_READ. These two
instructions write and read words, halfwords, and bytes from the SAB.
Busy Reporting
If the aWire master, during a MEMORY_WRITE or a MEMORY_READ command, transmit
another byte when the aWire is still busy sending the previous byte to the SAB, the AW will
respond with a MEMORY_READ_WRITE_STATUS error. See chapter Section 34.6.8.5 for
more details.
The aWire master should adjust its baudrate or delay between bytes when doing SAB accesses
to ensure that the SAB is not overwhelmed with data.
Error Reporting
If a write is performed on a non-existing memory location the SAB interface will respond with an
error. If this happens, all further writes in this command will not be performed and the error and
number of bytes written is reported in the MEMORY_READWRITE_STATUS message from the
AW after the write.
If a read is performed on a non-existing memory location, the SAB interface will respond with an
error. If this happens, the data bytes read after this event are not valid. The AW will include three
extra bytes at the end of the transfer to indicate if the transfer was successful, or in the case of
an error, how many valid bytes were received.
34.6.6.9 CRC Errors/NACK Response
The AW will calculate a CRC value when receiving the command, length, and data fields of the
command packets. If this value differs from the value from the CRC field of the packet, the AW
will reply with a NACK response. Otherwise the command is carried out normally.
An unknown command will be replied with a NACK response.
In worst case a transmission error can happen in the length or command field of the packet. This
can lead to the aWire slave trying to receive a command with or without length (opposite of what
the master intended) or receive an incorrect number of bytes. The aWire slave will then either
wait for more data when the master has finished or already have transmitted the NACK
response in congestion with the master. The master can implement a timeout on every command
and reset the slave if no response is returned after the timeout period has ended.
f
sab
3f
aw
CV – 3 = ----------------
887
32142D–06/2013
ATUC64/128/256L3/4U
34.6.7 aWire Command Summary
The implemented aWire commands are shown in the table below. The responses from the AW
are listed in Section 34.6.8.
All aWire commands are described below, with a summary in table form.
34.6.7.1 AYA
This command asks the AW: “Are you alive”, where the AW should respond with an
acknowledge.
Table 34-31. aWire Command Summary
COMMAND Instruction Description
0x01 AYA “Are you alive”.
0x02 JTAG_ID Asks AW to return the JTAG IDCODE.
0x03 STATUS_REQUEST Request a status message from the AW.
0x04 TUNE Tell the AW to report the current baud rate.
0x05 MEMORY_SPEED_REQUEST Reports the speed difference between the aWire control and the SAB clock
domains.
0x06 CHIP_ERASE Erases the flash and all volatile memories.
0x07 DISABLE Disables the AW.
0x08 2_PIN_MODE Enables the DATAOUT pin and puts the aWire in 2-pin mode, where all
responses are sent on the DATAOUT pin.
0x80 MEMORY_WRITE Writes words, halfwords, or bytes to the SAB.
0x81 MEMORY_READ Reads words, halfwords, or bytes from the SAB.
0x82 HALT Issues a halt command to the device.
0x83 RESET Issues a reset to the Reset Controller.
0x84 SET_GUARD_TIME Sets the guard time for the AW.
Table 34-32. Command/Response Description Notation
Command/Response Description
Command/Response value Shows the command/response value to put into the command/response field of the packet.
Additional data Shows the format of the optional data field if applicable.
Possible responses Shows the possible responses for this command.
Table 34-33. AYA Details
Command Details
Command value 0x01
Additional data N/A
Possible responses 0x40: ACK (Section 34.6.8.1)
0x41: NACK (Section 34.6.8.2)
888
32142D–06/2013
ATUC64/128/256L3/4U
34.6.7.2 JTAG_ID
This command instructs the AW to output the JTAG idcode in the following response.
34.6.7.3 STATUS_REQUEST
Asks the AW for a status message.
34.6.7.4 TUNE
Asks the AW for the current baud rate counter value.
34.6.7.5 MEMORY_SPEED_REQUEST
Asks the AW for the relative speed between the aWire clock (RC120M) and the SAB interface.
34.6.7.6 CHIP_ERASE
This instruction allows a programmer to completely erase all nonvolatile memories in the chip.
This will also clear any security bits that are set, so the device can be accessed normally. The
command is acked immediately, but the status of the command can be monitored by checking
Table 34-34. JTAG_ID Details
Command Details
Command value 0x02
Additional data N/A
Possible responses 0xC0: IDCODE (Section 34.6.8.3)
0x41: NACK (Section 34.6.8.2)
Table 34-35. STATUS_REQUEST Details
Command Details
Command value 0x03
Additional data N/A
Possible responses 0xC4: STATUS_INFO (Section 34.6.8.7)
0x41: NACK (Section 34.6.8.2)
Table 34-36. TUNE Details
Command Details
Command value 0x04
Additional data N/A
Possible responses 0xC3: BAUD_RATE (Section 34.6.8.6)
0x41: NACK (Section 34.6.8.2)
Table 34-37. MEMORY_SPEED_REQUEST Details
Command Details
Command value 0x05
Additional data N/A
Possible responses 0xC5: MEMORY_SPEED (Section 34.6.8.8)
0x41: NACK (Section 34.6.8.2)
889
32142D–06/2013
ATUC64/128/256L3/4U
the Chip Erase ongoing bit in the status bytes received after the STATUS_REQUEST
command.
34.6.7.7 DISABLE
Disables the AW. The AW will respond with an ACK response and then disable itself.
34.6.7.8 2_PIN_MODE
Enables the DATAOUT pin as an output pin. All responses sent from the aWire slave will be sent
on this pin, instead of the RESET_N pin, starting with the ACK for the 2_PIN_MODE command.
34.6.7.9 MEMORY_WRITE
This command enables programming of memory/writing to registers on the SAB. The
MEMORY_WRITE command allows words, halfwords, and bytes to be programmed to a continuous
sequence of addresses in one operation. Before transferring the data, the user must
supply:
1. The number of data bytes to write + 5 (size and starting address) in the length field.
2. The size of the transfer: words, halfwords, or bytes.
3. The starting address of the transfer.
Table 34-38. CHIP_ERASE Details
Command Details
Command value 0x06
Additional data N/A
Possible responses 0x40: ACK (Section 34.6.8.1)
0x41: NACK (Section 34.6.8.2)
Table 34-39. DISABLE Details
Command Details
Command value 0x07
Additional data N/A
Possible responses 0x40: ACK (Section 34.6.8.1)
0x41: NACK (Section 34.6.8.2)
Table 34-40. DISABLE Details
Command Details
Command value 0x07
Additional data N/A
Possible responses 0x40: ACK (Section 34.6.8.1)
0x41: NACK (Section 34.6.8.2)
890
32142D–06/2013
ATUC64/128/256L3/4U
The 4 MSB of the 36 bit SAB address are submitted together with the size field (2 bits). Then follows
the 4 remaining address bytes and finally the data bytes. The size of the transfer is
specified using the values from the following table:
Below is an example write command:
1. 0x55 (sync)
2. 0x80 (command)
3. 0x00 (length MSB)
4. 0x09 (length LSB)
5. 0x25 (size and address MSB, the two MSB of this byte are unused and set to zero)
6. 0x00
7. 0x00
8. 0x00
9. 0x04 (address LSB)
10. 0xCA
11. 0xFE
12. 0xBA
13. 0xBE
14. 0xXX (CRC MSB)
15. 0xXX (CRC LSB)
The length field is set to 0x0009 because there are 9 bytes of additional data: 5 address and size
bytes and 4 bytes of data. The address and size field indicates that words should be written to
address 0x500000004. The data written to 0x500000004 is 0xCAFEBABE.
34.6.7.10 MEMORY_READ
This command enables reading of memory/registers on the Service Access Bus (SAB). The
MEMORY_READ command allows words, halfwords, and bytes to be read from a continuous
sequence of addresses in one operation. The user must supply:
Table 34-41. Size Field Decoding
Size field Description
00 Byte transfer
01 Halfword transfer
10 Word transfer
11 Reserved
Table 34-42. MEMORY_WRITE Details
Command Details
Command value 0x80
Additional data Size, Address and Data
Possible responses 0xC2: MEMORY_READWRITE_STATUS (Section 34.6.8.5)
0x41: NACK (Section 34.6.8.2)
891
32142D–06/2013
ATUC64/128/256L3/4U
1. The size of the data field: 7 (size and starting address + read length indicator) in the
length field.
2. The size of the transfer: Words, halfwords, or bytes.
3. The starting address of the transfer.
4. The number of bytes to read (max 65532).
The 4 MSB of the 36 bit SAB address are submitted together with the size field (2 bits). The 4
remaining address bytes are submitted before the number of bytes to read. The size of the
transfer is specified using the values from the following table:
Below is an example read command:
1. 0x55 (sync)
2. 0x81 (command)
3. 0x00 (length MSB)
4. 0x07 (length LSB)
5. 0x25 (size and address MSB, the two MSB of this byte are unused and set to zero)
6. 0x00
7. 0x00
8. 0x00
9. 0x04 (address LSB)
10. 0x00
11. 0x04
12. 0xXX (CRC MSB)
13. 0xXX (CRC LSB)
The length field is set to 0x0007 because there are 7 bytes of additional data: 5 bytes of address
and size and 2 bytes with the number of bytes to read. The address and size field indicates one
word (four bytes) should be read from address 0x500000004.
Table 34-43. Size Field Decoding
Size field Description
00 Byte transfer
01 Halfword transfer
10 Word transfer
11 Reserved
Table 34-44. MEMORY_READ Details
Command Details
Command value 0x81
Additional data Size, Address and Length
Possible responses
0xC1: MEMDATA (Section 34.6.8.4)
0xC2: MEMORY_READWRITE_STATUS (Section 34.6.8.5)
0x41: NACK (Section 34.6.8.2)
892
32142D–06/2013
ATUC64/128/256L3/4U
34.6.7.11 HALT
This command tells the CPU to halt code execution for safe programming. If the CPU is not
halted during programming it can start executing partially loaded programs. To halt the processor,
the aWire master should send 0x01 in the data field of the command. After programming the
halting can be released by sending 0x00 in the data field of the command.
34.6.7.12 RESET
This command resets different domains in the part. The aWire master sends a byte with the
reset value. Each bit in the reset value byte corresponds to a reset domain in the chip. If a bit is
set the reset is activated and if a bit is not set the reset is released. The number of reset domains
and their destinations are identical to the resets described in the JTAG data registers chapter
under reset register.
34.6.7.13 SET_GUARD_TIME
Sets the guard time value in the AW, i.e. how long the AW will wait before starting its transfer
after the master has finished.
The guard time can be either 0x00 (128 bit lengths), 0x01 (16 bit lengths), 0x2 (4 bit lengths) or
0x3 (1 bit length).
Table 34-45. HALT Details
Command Details
Command value 0x82
Additional data 0x01 to halt the CPU 0x00 to release the halt and reset the
device.
Possible responses 0x40: ACK (Section 34.6.8.1)
0x41: NACK (Section 34.6.8.2)
Table 34-46. RESET Details
Command Details
Command value 0x83
Additional data Reset value for each reset domain. The number of reset
domains is part specific.
Possible responses 0x40: ACK (Section 34.6.8.1)
0x41: NACK (Section 34.6.8.2)
Table 34-47. SET_GUARD_TIME Details
Command Details
Command value 0x84
Additional data Guard time
Possible responses 0x40: ACK (Section 34.6.8.1)
0x41: NACK (Section 34.6.8.2)
893
32142D–06/2013
ATUC64/128/256L3/4U
34.6.8 aWire Response Summary
The implemented aWire responses are shown in the table below.
34.6.8.1 ACK
The AW has received the command successfully and performed the operation.
34.6.8.2 NACK
The AW has received the command, but got a CRC mismatch.
34.6.8.3 IDCODE
The JTAG idcode for this device.
34.6.8.4 MEMDATA
The data read from the address specified by the MEMORY_READ command. The last 3 bytes
are status bytes from the read. The first status byte is the status of the command described in
the table below. The last 2 bytes are the number of remaining data bytes to be sent in the data
field of the packet when the error occurred. If the read was not successful all data bytes after the
failure are undefined. A successful word read (4 bytes) will look like this:
Table 34-48. aWire Response Summary
RESPONSE Instruction Description
0x40 ACK Acknowledge.
0x41 NACK Not acknowledge. Sent after CRC errors and after unknown commands.
0xC0 IDCODE The JTAG idcode.
0xC1 MEMDATA Values read from memory.
0xC2 MEMORY_READWRITE_STATUS Status after a MEMORY_WRITE or a MEMORY_READ command. OK, busy,
error.
0xC3 BAUD_RATE The current baudrate.
0xC4 STATUS_INFO Status information.
0xC5 MEMORY_SPEED SAB to aWire speed information.
Table 34-49. ACK Details
Response Details
Response value 0x40
Additional data N/A
Table 34-50. NACK Details
Response Details
Response value 0x41
Additional data N/A
Table 34-51. IDCODE Details
Response Details
Response value 0xC0
Additional data JTAG idcode
894
32142D–06/2013
ATUC64/128/256L3/4U
1. 0x55 (sync)
2. 0xC1 (command)
3. 0x00 (length MSB)
4. 0x07 (length LSB)
5. 0xCA (Data MSB)
6. 0xFE
7. 0xBA
8. 0xBE (Data LSB)
9. 0x00 (Status byte)
10. 0x00 (Bytes remaining MSB)
11. 0x00 (Bytes remaining LSB)
12. 0xXX (CRC MSB)
13. 0xXX (CRC LSB)
The status is 0x00 and all data read are valid. An unsuccessful four byte read can look like this:
1. 0x55 (sync)
2. 0xC1 (command)
3. 0x00 (length MSB)
4. 0x07 (length LSB)
5. 0xCA (Data MSB)
6. 0xFE
7. 0xXX (An error has occurred. Data read is undefined. 5 bytes remaining of the Data
field)
8. 0xXX (More undefined data)
9. 0x02 (Status byte)
10. 0x00 (Bytes remaining MSB)
11. 0x05 (Bytes remaining LSB)
12. 0xXX (CRC MSB)
13. 0xXX (CRC LSB)
The error occurred after reading 2 bytes on the SAB. The rest of the bytes read are undefined.
The status byte indicates the error and the bytes remaining indicates how many bytes were
remaining to be sent of the data field of the packet when the error occurred.
Table 34-52. MEMDATA Status Byte
status byte Description
0x00 Read successful
0x01 SAB busy
0x02 Bus error (wrong address)
Other Reserved
Table 34-53. MEMDATA Details
Response Details
Response value 0xC1
Additional data Data read, status byte, and byte count (2 bytes)
895
32142D–06/2013
ATUC64/128/256L3/4U
34.6.8.5 MEMORY_READWRITE_STATUS
After a MEMORY_WRITE command this response is sent by AW. The response can also be
sent after a MEMORY_READ command if AW encountered an error when receiving the
address. The response contains 3 bytes, where the first is the status of the command and the 2
next contains the byte count when the first error occurred. The first byte is encoded this way:
34.6.8.6 BAUD_RATE
The current baud rate in the AW. See Section 34.6.6.7 for more details.
34.6.8.7 STATUS_INFO
A status message from AW.
Table 34-54. MEMORY_READWRITE_STATUS Status Byte
status byte Description
0x00 Write successful
0x01 SAB busy
0x02 Bus error (wrong address)
Other Reserved
Table 34-55. MEMORY_READWRITE_STATUS Details
Response Details
Response value 0xC2
Additional data Status byte and byte count (2 bytes)
Table 34-56. BAUD_RATE Details
Response Details
Response value 0xC3
Additional data Baud rate
Table 34-57. STATUS_INFO Contents
Bit number Name Description
15-9 Reserved
8 Protected The protection bit in the internal flash is set. SAB access is restricted. This bit
will read as one during reset.
7 SAB busy
The SAB bus is busy with a previous transfer. This could indicate that the CPU
is running on a very slow clock, the CPU clock has stopped for some reason
or that the part is in constant reset.
6 Chip erase ongoing The Chip erase operation has not finished.
5 CPU halted This bit will be set if the CPU is halted. This bit will read as zero during reset.
4-1 Reserved
0 Reset status This bit will be set if AW has reset the CPU using the RESET command.
896
32142D–06/2013
ATUC64/128/256L3/4U
34.6.8.8 MEMORY_SPEED
Counts the number of RC120M clock cycles it takes to sync one message to the SAB interface
and back again. The SAB clock speed ( ) can be calculated using the following formula:
34.6.9 Security Restrictions
When the security fuse in the Flash is programmed, the following aWire commands are limited:
• MEMORY_WRITE
• MEMORY_READ
Unlimited access to these instructions is restored when the security fuse is erased by the
CHIP_ERASE aWire command.
Note that the security bit will read as programmed and block these instructions also if the Flash
Controller is statically reset.
Table 34-58. STATUS_INFO Details
Response Details
Response value 0xC4
Additional data 2 status bytes
Table 34-59. MEMORY_SPEED Details
Response Details
Response value 0xC5
Additional data Clock cycle count (MS)
f
sab
f
sab
3f
aw
CV – 3 = ----------------
897
32142D–06/2013
ATUC64/128/256L3/4U
35. Electrical Characteristics
35.1 Absolute Maximum Ratings*
Notes: 1. 5V tolerant pins, see Section ”Peripheral Multiplexing on I/O lines” on page 10
2. VVDD corresponds to either VVDDIN or VVDDIO, depending on the supply for the pin. Refer to Section on page 10 for details.
35.2 Supply Characteristics
The following characteristics are applicable to the operating temperature range: TA = -40°C to
85°C, unless otherwise specified and are valid for a junction temperature up to TJ = 100°C.
Please refer to Section 6. ”Supply and Startup Considerations” on page 39.
Table 35-1. Absolute Maximum Ratings
Operating temperature..................................... -40C to +85C *NOTICE: Stresses beyond those listed under
“Absolute Maximum Ratings” may cause
permanent damage to the device. This is
a stress rating only and functional operation
of the device at these or other conditions
beyond those indicated in the
operational sections of this specification is
not implied. Exposure to absolute maximum
rating conditions for extended periods
may affect device reliability.
Storage temperature...................................... -60°C to +150°C
Voltage on input pins (except for 5V pins) with respect to ground
.................................................................-0.3V to VVDD(2)+0.3V
Voltage on 5V tolerant(1) pins with respect to ground ...............
.............................................................................-0.3V to 5.5V
Total DC output current on all I/O pins - VDDIO, 64-pin package
............... ......................................................................141 mA
Total DC output current on all I/O pins - VDDIN, 64-pin package
....................................................................................... 42 mA
Total DC output current on all I/O pins - VDDIO, 48-pin package
........... ...........................................................................120mA
Total DC output current on all I/O pins - VDDIN, 48-pin package
....................................................................................... 39 mA
Maximum operating voltage VDDCORE......................... 1.98V
Maximum operating voltage VDDIO, VDDIN .................... 3.6V
Table 35-2. Supply Characteristics
Symbol Parameter
Voltage
Min Max Unit
VVDDIO DC supply peripheral I/Os 1.62 3.6 V
VVDDIN
DC supply peripheral I/Os, 1.8V
single supply mode 1.62 1.98 V
DC supply peripheral I/Os and
internal regulator, 3.3V supply
mode
1.98 3.6 V
VVDDCORE DC supply core 1.62 1.98 V
VVDDANA Analog supply voltage 1.62 1.98 V
898
32142D–06/2013
ATUC64/128/256L3/4U
Note: 1. These values are based on simulation and characterization of other AVR microcontrollers
manufactured in the same process technology. These values are not covered by test limits in
production.
35.3 Maximum Clock Frequencies
These parameters are given in the following conditions:
• VVDDCORE = 1.62V to 1.98V
• Temperature = -40°C to 85°C
35.4 Power Consumption
The values in Table 35-5 are measured values of power consumption under the following conditions,
except where noted:
• Operating conditions, internal core supply (Figure 35-1) - this is the default configuration
– VVDDIN = 3.0V
Table 35-3. Supply Rise Rates and Order(1)
Symbol Parameter
Rise Rate
Min Max Unit Comment
VVDDIO DC supply peripheral I/Os 0 2.5 V/µs
VVDDIN
DC supply peripheral I/Os
and internal regulator 0.002 2.5 V/µs
Slower rise time requires
external power-on reset
circuit.
VVDDCORE DC supply core 0 2.5 V/µs Rise before or at the same
time as VDDIO
VVDDANA Analog supply voltage 0 2.5 V/µs Rise together with
VDDCORE
Table 35-4. Clock Frequencies
Symbol Parameter Description Min Max Units
fCPU CPU clock frequency 50
MHz
fPBA PBA clock frequency 50
fPBB PBB clock frequency 50
fGCLK0 GCLK0 clock frequency DFLLIF main reference, GCLK0 pin 50
fGCLK1 GCLK1 clock frequency DFLLIF dithering and SSG reference, GCLK1 pin 50
fGCLK2 GCLK2 clock frequency AST, GCLK2 pin 20
fGCLK3 GCLK3 clock frequency PWMA, GCLK3 pin 140
fGCLK4 GCLK4 clock frequency CAT, ACIFB, GCLK4 pin 50
fGCLK5 GCLK5 clock frequency GLOC and GCLK5 pin 80
fGCLK6 GCLK6 clock frequency ABDACB, IISC, and GCLK6 pin 50
fGCLK7 GCLK7 clock frequency USBC and GCLK7 pin 50
fGCLK8 GCLK8 clock frequency PLL0 source clock and GCLK8 pin 50
fGCLK9 GCLK9 clock frequency FREQM, GCLK0-8, GCLK9 pin 150
899
32142D–06/2013
ATUC64/128/256L3/4U
– VVDDCORE = 1.62V, supplied by the internal regulator
– Corresponds to the 3.3V supply mode with 1.8V regulated I/O lines, please refer to
the Supply and Startup Considerations section for more details
• Equivalent to the 3.3V single supply mode
• Consumption in 1.8V single supply mode can be estimated by subtracting the regulator
static current
• Operating conditions, external core supply (Figure 35-2) - used only when noted
– VVDDIN = VVDDCORE = 1.8V
– Corresponds to the 1.8V single supply mode, please refer to the Supply and Startup
Considerations section for more details
• TA = 25C
• Oscillators
– OSC0 (crystal oscillator) stopped
– OSC32K (32KHz crystal oscillator) running with external 32KHz crystal
– DFLL running at 50MHz with OSC32K as reference
• Clocks
– DFLL used as main clock source
– CPU, HSB, and PBB clocks undivided
– PBA clock divided by 4
– The following peripheral clocks running
• PM, SCIF, AST, FLASHCDW, PBA bridge
– All other peripheral clocks stopped
• I/Os are inactive with internal pull-up
• Flash enabled in high speed mode
• POR18 enabled
• POR33 disabled
900
32142D–06/2013
ATUC64/128/256L3/4U
Note: 1. These numbers are valid for the measured condition only and must not be extrapolated to other frequencies.
Figure 35-1. Measurement Schematic, Internal Core Supply
Table 35-5. Power Consumption for Different Operating Modes
Mode Conditions Measured on Consumption Typ Unit
Active(1) CPU running a recursive Fibonacci algorithm
Amp0
300
µA/MHz
CPU running a division algorithm 174
Idle(1) 96
Frozen(1) 57
Standby(1) 46
Stop 38
µA
DeepStop 25
Static
-OSC32K and AST stopped
-Internal core supply
14
-OSC32K running
-AST running at 1KHz
-External core supply (Figure 35-2)
7.3
-OSC32K and AST stopped
-External core supply (Figure 35-2) 6.7
Shutdown
-OSC32K running
-AST running at 1KHz 800
nA
AST and OSC32K stopped 220
Amp0 VDDIN
VDDCORE
VDDANA
VDDIO
901
32142D–06/2013
ATUC64/128/256L3/4U
Figure 35-2. Measurement Schematic, External Core Supply
Amp0 VDDIN
VDDCORE
VDDANA
VDDIO
902
32142D–06/2013
ATUC64/128/256L3/4U
35.5 I/O Pin Characteristics
Notes: 1. VVDD corresponds to either VVDDIN or VVDDIO, depending on the supply for the pin. Refer to Section on page 10 for details.
2. These values are based on simulation and characterization of other AVR microcontrollers manufactured in the same process
technology. These values are not covered by test limits in production.
Table 35-6. Normal I/O Pin Characteristics(1)
Symbol Parameter Condition Min Typ Max Units
RPULLUP Pull-up resistance 75 100 145 kOhm
VIL Input low-level voltage
VVDD = 3.0V -0.3 0.3 * VVDD V
VVDD = 1.62V -0.3 0.3 * VVDD
VIH Input high-level voltage
VVDD = 3.6V 0.7 * VVDD VVDD + 0.3
V
VVDD = 1.98V 0.7 * VVDD VVDD + 0.3
VOL Output low-level voltage
VVDD = 3.0V, IOL = 3mA 0.4
V
VVDD = 1.62V, IOL = 2mA 0.4
VOH Output high-level voltage
VVDD = 3.0V, IOH = 3mA VVDD - 0.4
V
VVDD = 1.62V, IOH = 2mA VVDD - 0.4
fMAX Output frequency(2)
VVDD = 3.0V, load = 10pF 45
MHz
VVDD = 3.0V, load = 30pF 23
tRISE Rise time(2)
VVDD = 3.0V, load = 10pF 4.7
ns
VVDD = 3.0V, load = 30pF 11.5
tFALL Fall time(2)
VVDD = 3.0V, load = 10pF 4.8
VVDD = 3.0V, load = 30pF 12
ILEAK Input leakage current Pull-up resistors disabled 1 µA
CIN
Input capacitance, all
normal I/O pins except
PA05, PA07, PA17, PA20,
PA21, PB04, PB05
TQFP48 package 1.4
pF
QFN48 package 1.1
TLLGA48 package 1.1
TQFP64 package 1.5
QFN64 package 1.1
CIN Input capacitance, PA20
TQFP48 package 2.7
QFN48 package 2.4
TLLGA48 package 2.4
TQFP64 package 2.8
QFN64 package 2.4
CIN
Input capacitance, PA05,
PA07, PA17, PA21, PB04,
PB05
TQFP48 package 3.8
QFN48 package 3.5
TLLGA48 package 3.5
TQFP64 package 3.9
QFN64 package 3.5
903
32142D–06/2013
ATUC64/128/256L3/4U
Notes: 1. VVDD corresponds to either VVDDIN or VVDDIO, depending on the supply for the pin. Refer to Section on page 10 for details.
Table 35-7. High-drive I/O Pin Characteristics(1)
Symbol Parameter Condition Min Typ Max Units
RPULLUP Pull-up resistance
PA06 30 50 110
PA02, PB01, RESET 75 100 145 kOhm
PA08, PA09 10 20 45
VIL Input low-level voltage
VVDD = 3.0V -0.3 0.3 * VVDD V
VVDD = 1.62V -0.3 0.3 * VVDD
VIH Input high-level voltage
VVDD = 3.6V 0.7 * VVDD VVDD + 0.3
V
VVDD = 1.98V 0.7 * VVDD VVDD + 0.3
VOL Output low-level voltage
VVDD = 3.0V, IOL = 6mA 0.4
V
VVDD = 1.62V, IOL = 4mA 0.4
VOH Output high-level voltage
VVDD = 3.0V, IOH = 6mA VVDD - 0.4
V
VVDD = 1.62V, IOH = 4mA VVDD - 0.4
fMAX
Output frequency, all High-drive I/O
pins, except PA08 and PA09(2)
VVDD = 3.0V, load = 10pF 45
MHz
VVDD = 3.0V, load = 30pF 23
tRISE
Rise time, all High-drive I/O pins, except
PA08 and PA09(2)
VVDD = 3.0V, load = 10pF 4.7
ns
VVDD = 3.0V, load = 30pF 11.5
tFALL
Fall time, all High-drive I/O pins, except
PA08 and PA09(2)
VVDD = 3.0V, load = 10pF 4.8
VVDD = 3.0V, load = 30pF 12
fMAX Output frequency, PA08 and PA09(2)
VVDD = 3.0V, load = 10pF 54
MHz
VVDD = 3.0V, load = 30pF 40
tRISE Rise time, PA08 and PA09(2)
VVDD = 3.0V, load = 10pF 2.8
ns
VVDD = 3.0V, load = 30pF 4.9
tFALL Fall time, PA08 and PA09(2)
VVDD = 3.0V, load = 10pF 2.4
VVDD = 3.0V, load = 30pF 4.6
ILEAK Input leakage current Pull-up resistors disabled 1 µA
CIN
Input capacitance, all High-drive I/O
pins, except PA08 and PA09
TQFP48 package 2.2
pF
QFN48 package 2.0
TLLGA48 package 2.0
TQFP64 package 2.3
QFN64 package 2.0
CIN Input capacitance, PA08 and PA09
TQFP48 package 7.0
QFN48 package 6.7
TLLGA48 package 6.7
TQFP64 package 7.1
QFN64 package 6.7
904
32142D–06/2013
ATUC64/128/256L3/4U
2. These values are based on simulation and characterization of other AVR microcontrollers manufactured in the same process
technology. These values are not covered by test limits in production.
Notes: 1. VVDD corresponds to either VVDDIN or VVDDIO, depending on the supply for the pin. Refer to Section on page 10 for details.
2. These values are based on simulation and characterization of other AVR microcontrollers manufactured in the same process
technology. These values are not covered by test limits in production.
Table 35-8. High-drive I/O, 5V Tolerant, Pin Characteristics(1)
Symbol Parameter Condition Min Typ Max Units
RPULLUP Pull-up resistance 30 50 110 kOhm
VIL Input low-level voltage
VVDD = 3.0V -0.3 0.3 * VVDD V
VVDD = 1.62V -0.3 0.3 * VVDD
VIH Input high-level voltage
VVDD = 3.6V 0.7 * VVDD 5.5
V
VVDD = 1.98V 0.7 * VVDD 5.5
VOL Output low-level voltage
VVDD = 3.0V, IOL = 6mA 0.4
V
VVDD = 1.62V, IOL = 4mA 0.4
VOH Output high-level voltage
VVDD = 3.0V, IOH = 6mA VVDD - 0.4
V
VVDD = 1.62V, IOH = 4mA VVDD - 0.4
fMAX Output frequency(2)
VVDD = 3.0V, load = 10pF 87
MHz
VVDD = 3.0V, load = 30pF 58
tRISE Rise time(2)
VVDD = 3.0V, load = 10pF 2.3
ns
VVDD = 3.0V, load = 30pF 4.3
tFALL Fall time(2)
VVDD = 3.0V, load = 10pF 1.9
VVDD = 3.0V, load = 30pF 3.7
ILEAK Input leakage current 5.5V, pull-up resistors disabled 10 µA
CIN Input capacitance
TQFP48 package 4.5
pF
QFN48 package 4.2
TLLGA48 package 4.2
TQFP64 package 4.6
QFN64 package 4.2
Table 35-9. TWI Pin Characteristics(1)
Symbol Parameter Condition Min Typ Max Units
RPULLUP Pull-up resistance 25 35 60 kOhm
VIL Input low-level voltage
VVDD = 3.0V -0.3 0.3 * VVDD V
VVDD = 1.62V -0.3 0.3 * VVDD
VIH
Input high-level voltage
VVDD = 3.6V 0.7 * VVDD VVDD + 0.3
V
VVDD = 1.98V 0.7 * VVDD VVDD + 0.3
Input high-level voltage, 5V tolerant
SMBUS compliant pins
VVDD = 3.6V 0.7 * VVDD 5.5
V
VVDD = 1.98V 0.7 * VVDD 5.5
905
32142D–06/2013
ATUC64/128/256L3/4U
Note: 1. VVDD corresponds to either VVDDIN or VVDDIO, depending on the supply for the pin. Refer to Section on page 10 for details.
35.6 Oscillator Characteristics
35.6.1 Oscillator 0 (OSC0) Characteristics
35.6.1.1 Digital Clock Characteristics
The following table describes the characteristics for the oscillator when a digital clock is applied
on XIN.
Note: 1. These values are based on simulation and characterization of other AVR microcontrollers manufactured in the same process
technology. These values are not covered by test limits in production.
35.6.1.2 Crystal Oscillator Characteristics
The following table describes the characteristics for the oscillator when a crystal is connected
between XIN and XOUT as shown in Figure 35-3. The user must choose a crystal oscillator
where the crystal load capacitance CL is within the range given in the table. The exact value of CL
VOL Output low-level voltage IOL = 3mA 0.4 V
ILEAK Input leakage current Pull-up resistors disabled 1
IIL Input low leakage 1 µA
IIH Input high leakage 1
CIN Input capacitance
TQFP48 package 3.8
pF
QFN48 package 3.5
TLLGA48 package 3.5
TQFP64 package 3.9
QFN64 package 3.5
tFALL Fall time
Cbus = 400pF, VVDD > 2.0V 250
ns
Cbus = 400pF, VVDD > 1.62V 470
fMAX Max frequency Cbus = 400pF, VVDD > 2.0V 400 kHz
Table 35-9. TWI Pin Characteristics(1)
Symbol Parameter Condition Min Typ Max Units
Table 35-10. Digital Clock Characteristics
Symbol Parameter Conditions Min Typ Max Units
fCPXIN XIN clock frequency 50 MHz
tCPXIN XIN clock duty cycle(1) 40 60 %
tSTARTUP Startup time 0 cycles
CIN XIN input capacitance
TQFP48 package 7.0
pF
QFN48 package 6.7
TLLGA48 package 6.7
TQFP64 package 7.1
QFN64 package 6.7
906
32142D–06/2013
ATUC64/128/256L3/4U
can be found in the crystal datasheet. The capacitance of the external capacitors (CLEXT) can
then be computed as follows:
where CPCB is the capacitance of the PCB and Ci
is the internal equivalent load capacitance.
Notes: 1. Please refer to the SCIF chapter for details.
2. Nominal crystal cycles.
3. These values are based on simulation and characterization of other AVR microcontrollers manufactured in the same process
technology. These values are not covered by test limits in production.
Figure 35-3. Oscillator Connection
CLEXT 2 CL Ci – CPCB = –
Table 35-11. Crystal Oscillator Characteristics
Symbol Parameter Conditions Min Typ Max Unit
fOUT Crystal oscillator frequency(3) 0.45 10 16 MHz
CL Crystal load capacitance(3) 6 18
pF
Ci Internal equivalent load capacitance 2
tSTARTUP Startup time SCIF.OSCCTRL.GAIN = 2(1) 30 000(2) cycles
IOSC Current consumption
Active mode, f = 0.45MHz,
SCIF.OSCCTRL.GAIN = 0 30
µA Active mode, f = 10MHz,
SCIF.OSCCTRL.GAIN = 2 220
XIN
XOUT
CLEXT
CLEXT
CL
Ci
UC3L
907
32142D–06/2013
ATUC64/128/256L3/4U
35.6.2 32KHz Crystal Oscillator (OSC32K) Characteristics
Figure 35-3 and the equation above also applies to the 32KHz oscillator connection. The user
must choose a crystal oscillator where the crystal load capacitance CL is within the range given
in the table. The exact value of CL can then be found in the crystal datasheet.
Notes: 1. Nominal crystal cycles.
2. These values are based on simulation and characterization of other AVR microcontrollers manufactured in the same process
technology. These values are not covered by test limits in production.
35.6.3 Phase Locked Loop (PLL) Characteristics
Note: 1. These values are based on simulation and characterization of other AVR microcontrollers manufactured in the same process
technology. These values are not covered by test limits in production.
Table 35-12. 32 KHz Crystal Oscillator Characteristics
Symbol Parameter Conditions Min Typ Max Unit
fOUT Crystal oscillator frequency 32 768 Hz
tSTARTUP Startup time RS = 60kOhm, CL = 9pF 30 000(1) cycles
CL Crystal load capacitance(2) 6 12.5
pF Ci
Internal equivalent load
capacitance 2
IOSC32 Current consumption 0.6 µA
RS Equivalent series resistance(2) 32 768Hz 35 85 kOhm
Table 35-13. Phase Locked Loop Characteristics
Symbol Parameter Conditions Min Typ Max Unit
fOUT Output frequency(1) 40 240
MHz
fIN Input frequency(1) 4 16
IPLL Current consumption 8 µA/MHz
tSTARTUP
Startup time, from enabling
the PLL until the PLL is
locked
fIN= 4MHz 200
µs
fIN= 16MHz 155
908
32142D–06/2013
ATUC64/128/256L3/4U
35.6.4 Digital Frequency Locked Loop (DFLL) Characteristics
Notes: 1. Spread Spectrum Generator (SSG) is disabled by writing a zero to the EN bit in the DFLL0SSG register.
2. These values are based on simulation and characterization of other AVR microcontrollers manufactured in the same process
technology. These values are not covered by test limits in production.
3. The FINE and COARSE values are selected by wrirting to the DFLL0VAL.FINE and DFLL0VAL.COARSE field respectively.
Table 35-14. Digital Frequency Locked Loop Characteristics
Symbol Parameter Conditions Min Typ Max Unit
fOUT Output frequency(2) 20 150 MHz
fREF Reference frequency(2) 8 150 kHz
FINE resolution step FINE > 100, all COARSE values (3) 0.38 %
Frequency drift over voltage
and temperature Open loop mode See Figure
35-4
Accuracy(2)
FINE lock, fREF = 32kHz, SSG disabled 0.1 0.5
%
ACCURATE lock, fREF = 32kHz, dither clk
RCSYS/2, SSG disabled 0.06 0.5
FINE lock, fREF = 8-150kHz, SSG
disabled 0.2 1
ACCURATE lock, fREF = 8-150kHz,
dither clk RCSYS/2, SSG disabled 0.1 1
IDFLL Power consumption 25 µA/MHz
tSTARTUP Startup time(2) Within 90% of final values 100 µs
tLOCK Lock time
fREF = 32kHz, FINE lock, SSG disabled 8
ms fREF = 32kHz, ACCURATE lock, dithering
clock = RCSYS/2, SSG disabled 28
909
32142D–06/2013
ATUC64/128/256L3/4U
Figure 35-4. DFLL Open Loop Frequency Variation(1)(2)
Notes: 1. The plot shows a typical open loop mode behavior with COARSE= 99 and FINE= 255.
2. These values are based on simulation and characterization of other AVR microcontrollers manufactured in the same process
technology. These values are not covered by test limits in production.
35.6.5 120MHz RC Oscillator (RC120M) Characteristics
Note: 1. These values are based on simulation and characterization of other AVR microcontrollers manufactured in the same process
technology. These values are not covered by test limits in production.
DFLL Open Loop Frequency variation
80
90
100
110
120
130
140
150
160
-40 -20 0 20 40 60 80
Temperature
Frequencies (MHz)
1,98V
1,8V
1.62V
Table 35-15. Internal 120MHz RC Oscillator Characteristics
Symbol Parameter Conditions Min Typ Max Unit
fOUT Output frequency(1) 88 120 152 MHz
IRC120M Current consumption 1.2 mA
tSTARTUP Startup time(1) VVDDCORE = 1.8V 3 µs
910
32142D–06/2013
ATUC64/128/256L3/4U
35.6.6 32kHz RC Oscillator (RC32K) Characteristics
Note: 1. These values are based on simulation and characterization of other AVR microcontrollers manufactured in the same process
technology. These values are not covered by test limits in production.
35.6.7 System RC Oscillator (RCSYS) Characteristics
35.7 Flash Characteristics
Table 35-18 gives the device maximum operating frequency depending on the number of flash
wait states and the flash read mode. The FSW bit in the FLASHCDW FSR register controls the
number of wait states used when accessing the flash memory.
Table 35-16. 32kHz RC Oscillator Characteristics
Symbol Parameter Conditions Min Typ Max Unit
fOUT Output frequency(1) 20 32 44 kHz
IRC32K Current consumption 0.7 µA
tSTARTUP Startup time(1) 100 µs
Table 35-17. System RC Oscillator Characteristics
Symbol Parameter Conditions Min Typ Max Unit
fOUT Output frequency Calibrated at 85C 111.6 115 118.4 kHz
Table 35-18. Maximum Operating Frequency
Flash Wait States Read Mode Maximum Operating Frequency
1
High speed read mode
50MHz
0 25MHz
1
Normal read mode
30MHz
0 15MHz
Table 35-19. Flash Characteristics
Symbol Parameter Conditions Min Typ Max Unit
tFPP Page programming time
fCLK_HSB = 50MHz
5
ms
tFPE Page erase time 5
tFFP Fuse programming time 1
tFEA Full chip erase time (EA) 6
tFCE JTAG chip erase time (CHIP_ERASE) fCLK_HSB = 115kHz 310
911
32142D–06/2013
ATUC64/128/256L3/4U
35.8 ABDACB Electrical Characteristics.
Notes: 1. Test Condition: Common Mode Offset Control disabled (CR.CMOC = 0). Alternative Upsampling Ratio disabled
(CR.ALTUPR = 0). Volume at maximum level (VCR0.VOLUME = 0x7FFF and VCR1.VOLUME = 0x7FFF). Device is battery
powered (9V) through an LDO, VDDIO at 3.3V. Analog low pass filter as shown in Figure 35-5(1. order differential low pass
filter followed by a 4. order low-pass), +VCC at +9V and -VCC at -9V. Test signal stored on a SD card and read by the SPI
Interface.
2. Performance numbers for dynamic range, SNR, and THD performance are very dependent on the application and circuit
board design. Since the design has 0dB Power Supply Rejection Ratio (PSRR), noise on the IO power supply will couple
directly through to the output and be present in the audio signal. To get the best performance one should reduce toggling of
other IO pins as much as possible and make sure the device has sufficient decoupling on the IO supply pins.
3. These values are based on simulation and characterization of other AVR microcontrollers manufactured in the same process
technology. These values are not covered by test limits in production.
Figure 35-5. Differential Analog Low-pass Filter
Table 35-20. Flash Endurance and Data Retention
Symbol Parameter Conditions Min Typ Max Unit
NFARRAY Array endurance (write/page) 100k
cycles
NFFUSE General Purpose fuses endurance (write/bit) 10k
tRET Data retention 15 years
Table 35-21. ABDACB Electrical Characteristics
Symbol Parameter Conditions MIN TYP MAX Unit
Resolution 16 Bits
Dynamic range(1)(2)(3) FS = 48.000kHz > 76 dB
SNR(1)(2)(3) FS = 48.000kHz > 46 dB
THD(1)(2)(3) FS = 48.000kHz < 0.02 %
PSRR 0 dB
VOut maximum CR.CMOC = 0 97/128 * VDDIO V
VOut minimum CR.CMOC = 0 31/128 * VDDIO V
Common mode
CR.CMOC = 0
CR.CMOC = 1, DAC_0 and DAC_1 pins
CR.CMOC = 1, DACN_0 and DACN_1 pins
64/128 * VDDIO
80/128 * VDDIO
48/128 * VDDIO
V
R1, 22K
C2
140p
R2, 22K
R4, 22K
C1, 140p
R3, 22K
R6, 22K
R5, 22K
R7, 22K
C4
270p
C3
310p
-Vcc
+Vcc
-Vcc
+Vcc
DAC
DACN
R8, 22K R9, 22K
C6
110p
C5
750p
-Vcc
+Vcc
GND GND GND GND GND
Out
912
32142D–06/2013
ATUC64/128/256L3/4U
35.9 Analog Characteristics
35.9.1 Voltage Regulator Characteristics
Note: 1. These values are based on simulation and characterization of other AVR microcontrollers manufactured in the same process
technology. These values are not covered by test limits in production.
Note: 1. Refer to Section 6.1.2 on page 39.
Table 35-22. VREG Electrical Characteristics
Symbol Parameter Condition Min Typ Max Units
VVDDIN Input voltage range 1.98 3.3 3.6
V
VVDDCORE Output voltage, calibrated value VVDDIN >= 1.98V 1.8
Output voltage accuracy(1)
IOUT = 0.1mA to 60mA,
VVDDIN > 1.98V
2
%
IOUT = 0.1mA to 60mA,
VVDDIN <1.98V
4
IOUT DC output current(1)
Normal mode 60
mA
Low power mode 1
IVREG Static current of internal regulator
Normal mode 13
µA
Low power mode 4
Table 35-23. Decoupling Requirements
Symbol Parameter Condition Typ Techno. Units
CIN1 Input regulator capacitor 1 33
nF
CIN2 Input regulator capacitor 2 100
CIN3 Input regulator capacitor 3 10 µF
COUT1 Output regulator capacitor 1 100 nF
COUT2 Output regulator capacitor 2 2.2 Tantalum
0.5 3.0V, fADC = 6MHz,
12-bit resolution mode,
low impedance source
28
kSPS
VVDD > 3.0V, fADC = 6MHz,
10-bit resolution mode,
low impedance source
460
VVDD > 3.0V, fADC = 6MHz,
8-bit resolution mode,
low impedance source
460
VADVREFP Reference voltage range VADVREFP = VVDDANA 1.62 1.98 V
IADC Current consumption on VVDDANA ADC Clock = 6MHz 350
µA
IADVREFP
Current consumption on ADVREFP
pin fADC = 6MHz 150
Table 35-30. Analog Inputs
Symbol Parameter Conditions Min Typ Max Units
VADn Input Voltage Range
12-bit mode
10-bit mode 0 VADVREFP V
8-bit mode
CONCHIP Internal Capacitance(1) 22.5 pF
RONCHIP Internal Resistance(1)
VVDDIO = 3.0V to 3.6V,
VVDDCORE = 1.8V 3.15
kOhm
VVDDIO = VVDDCORE = 1.62V to 1.98V 55.9
RONCHIP CONCHIP RSOURCE
917
32142D–06/2013
ATUC64/128/256L3/4U
( ) of the PCB and source must be taken into account when calculating the required
sample and hold time. Figure 35-8 shows the ADC input channel equivalent circuit.
Figure 35-8. ADC Input
The minimum sample and hold time (in ns) can be found using this formula:
Where n is the number of bits in the conversion. is defined by the SHTIM field in the
ADCIFB ACR register. Please refer to the ADCIFB chapter for more information.
35.9.6.2 Applicable Conditions and Derating Data
Note: 1. These values are based on simulation and characterization of other AVR microcontrollers manufactured in the same process
technology. These values are not covered by test limits in production.
CSOURCE
ADCVREFP/2
CONCHIP
RONCHIP R Positive Input SOURCE
CSOURCE VIN
t
SAMPLEHOLD RONCHIP + RSOURCE CONCHIP CSOURCE + 2n + 1 ln
t
SAMPLEHOLD
Table 35-31. Transfer Characteristics 12-bit Resolution Mode(1)
Parameter Conditions Min Typ Max Units
Resolution 12 Bit
Integral non-linearity
ADC clock frequency = 6MHz,
Input Voltage Range = 0 - VADVREFP
+/-4
LSB
ADC clock frequency = 6MHz,
Input Voltage Range = (10% VADVREFP) -
(90% VADVREFP)
+/-2
Differential non-linearity
ADC clock frequency = 6MHz
-1.5 1.5
Offset error +/-3
Gain error +/-5
Table 35-32. Transfer Characteristics, 10-bit Resolution Mode(1)
Parameter Conditions Min Typ Max Units
Resolution 10 Bit
Integral non-linearity
ADC clock frequency = 6MHz
+/-1
LSB Differential non-linearity -1.0 1.0
Offset error +/-1
Gain error +/-2
918
32142D–06/2013
ATUC64/128/256L3/4U
Note: 1. These values are based on simulation and characterization of other AVR microcontrollers manufactured in the same process
technology. These values are not covered by test limits in production.
Note: 1. These values are based on simulation and characterization of other AVR microcontrollers manufactured in the same process
technology. These values are not covered by test limits in production.
35.9.7 Temperature Sensor Characteristics
Note: 1. The Temperature Sensor is not calibrated. The accuracy of the Temperature Sensor is governed by the ADC accuracy.
Table 35-33. Transfer Characteristics, 8-bit Resolution Mode(1)
Parameter Conditions Min Typ Max Units
Resolution 8 Bit
Integral non-linearity
ADC clock frequency = 6MHz
+/-0.5
LSB Differential non-linearity -0.3 0.3
Offset error +/-1
Gain error +/-1
Table 35-34. Temperature Sensor Characteristics(1)
Symbol Parameter Condition Min Typ Max Units
Gradient 1 mV/°C
ITS Current consumption 1 µA
tSTARTUP Startup time 0 µs
919
32142D–06/2013
ATUC64/128/256L3/4U
35.9.8 Analog Comparator Characteristics
Notes: 1. AC.CONFn.FLEN and AC.CONFn.HYS fields, refer to the Analog Comparator Interface chapter.
2. Referring to fAC.
3. These values are based on simulation and characterization of other AVR microcontrollers manufactured in the same process
technology. These values are not covered by test limits in production.
35.9.9 Capacitive Touch Characteristics
35.9.9.1 Discharge Current Source
Note: 1. These values are based on simulation and characterization of other AVR microcontrollers manufactured in the same process
technology. These values are not covered by test limits in production.
Table 35-35. Analog Comparator Characteristics
Symbol Parameter Condition Min Typ Max Units
Positive input
voltage range(3) -0.2 VVDDIO + 0.3
V
Negative input
voltage range(3) -0.2 VVDDIO - 0.6
Statistical offset(3)
VACREFN = 1.0V,
fAC = 12MHz,
filter length = 2,
hysteresis = 0(1)
20 mV
fAC
Clock frequency for
GCLK4(3) 12 MHz
Throughput rate(3) fAC = 12MHz 12 000 000 Comparisons
per second
Propagation delay
Delay from input
change to
Interrupt Status
Register Changes
ns
IAC
Current
consumption(3)
All channels,
VDDIO = 3.3V,
fA = 3MHz
420 µA
tSTARTUP Startup time 3 cycles
Input current per
pin(3) 0.2 µA/MHz(2)
Table 35-36. DICS Characteristics
Symbol Parameter Min Typ Max Unit
RREF Internal resistor 170 kOhm
k Trim step size(1) 0.7 %
1
t
CLKACIFB f
AC ---------------------------------------- + 3 t
CLKACIFB
920
32142D–06/2013
ATUC64/128/256L3/4U
35.9.9.2 Strong Pull-up Pull-down
35.9.10 USB Transceiver Characteristics
The USB on-chip buffers comply with the Universal Serial Bus (USB) v2.0 standard. All AC
parameters related to these buffers can be found within the USB 2.0 electrical specifications.
35.9.10.1 Electrical Characteristics
Table 35-37. Strong Pull-up Pull-down
Parameter Min Typ Max Unit
Pull-down resistor 1
kOhm
Pull-up resistor 1
Table 35-38. Electrical Parameters
Symbol Parameter Conditions Min Typ Max Unit
REXT
Recommended external USB
series resistor
In series with each USB pin with
±5% 39 Ohm
921
32142D–06/2013
ATUC64/128/256L3/4U
35.10 Timing Characteristics
35.10.1 Startup, Reset, and Wake-up Timing
The startup, reset, and wake-up timings are calculated using the following formula:
Where and are found in Table 35-39. is the period of the CPU clock. If a
clock source other than RCSYS is selected as the CPU clock, the oscillator startup time,
, must be added to the wake-up time from the stop, deepstop, and static sleep
modes. Please refer to the source for the CPU clock in the ”Oscillator Characteristics” on page
905 for more details about oscillator startup times.
Note: 1. These values are based on simulation and characterization of other AVR microcontrollers manufactured in the same process
technology. These values are not covered by test limits in production.
35.10.2 RESET_N Timing
Note: 1. These values are based on simulation and characterization of other AVR microcontrollers manufactured in the same process
technology. These values are not covered by test limits in production.
t tCONST NCPU t
CPU = +
t
CONST NCPU t
CPU
t
OSCSTART
Table 35-39. Maximum Reset and Wake-up Timing(1)
Parameter Measuring Max (in µs) Max
Startup time from power-up, using
regulator
Time from VDDIN crossing the VPOT+ threshold of
POR33 to the first instruction entering the decode
stage of CPU. VDDCORE is supplied by the internal
regulator.
2210 0
Startup time from power-up, no
regulator
Time from VDDIN crossing the VPOT+ threshold of
POR33 to the first instruction entering the decode
stage of CPU. VDDCORE is connected to VDDIN.
1810 0
Startup time from reset release
Time from releasing a reset source (except POR18,
POR33, and SM33) to the first instruction entering
the decode stage of CPU.
170 0
Wake-up
Idle
From wake-up event to the first instruction of an
interrupt routine entering the decode stage of the
CPU.
0 19
Frozen 0 110
Standby 0 110
Stop 27 + 116
Deepstop 27 + 116
Static 97 + 116
Wake-up from shutdown From wake-up event to the first instruction entering
the decode stage of the CPU. 1180 0
t
CONST NCPU
t
OSCSTART
t
OSCSTART
t
OSCSTART
Table 35-40. RESET_N Waveform Parameters(1)
Symbol Parameter Conditions Min Max Units
tRESET RESET_N minimum pulse length 10 ns
922
32142D–06/2013
ATUC64/128/256L3/4U
35.10.3 USART in SPI Mode Timing
35.10.3.1 Master mode
Figure 35-9. USART in SPI Master Mode with (CPOL= CPHA= 0) or (CPOL= CPHA= 1)
Figure 35-10. USART in SPI Master Mode with (CPOL= 0 and CPHA= 1) or (CPOL= 1 and
CPHA= 0)
Notes: 1. These values are based on simulation and characterization of other AVR microcontrollers manufactured in the same process
technology. These values are not covered by test limits in production.
2. Where:
USPI0 USPI1
MISO
SPCK
MOSI
USPI2
USPI3 USPI4
MISO
SPCK
MOSI
USPI5
Table 35-41. USART in SPI Mode Timing, Master Mode(1)
Symbol Parameter Conditions Min Max Units
USPI0 MISO setup time before SPCK rises
VVDDIO from
3.0V to 3.6V,
maximum
external
capacitor =
40pF
28.7 + tSAMPLE(2)
ns
USPI1 MISO hold time after SPCK rises 0
USPI2 SPCK rising to MOSI delay 16.5
USPI3 MISO setup time before SPCK falls 25.8 + tSAMPLE(2)
USPI4 MISO hold time after SPCK falls 0
USPI5 SPCK falling to MOSI delay 21.19
t
SAMPLE t
SPCK
t
SPCK
2 t
CLKUSART ------------------------------------ 1
2
-- t
CLKUSART = –
923
32142D–06/2013
ATUC64/128/256L3/4U
Maximum SPI Frequency, Master Output
The maximum SPI master output frequency is given by the following formula:
Where is the MOSI delay, USPI2 or USPI5 depending on CPOL and NCPHA. is
the maximum frequency of the SPI pins. Please refer to the I/O Pin Characteristics section for
the maximum frequency of the pins. is the maximum frequency of the CLK_SPI. Refer
to the SPI chapter for a description of this clock.
Maximum SPI Frequency, Master Input
The maximum SPI master input frequency is given by the following formula:
Where is the MISO setup and hold time, USPI0 + USPI1 or USPI3 + USPI4 depending on
CPOL and NCPHA. is the SPI slave response time. Please refer to the SPI slave
datasheet for . is the maximum frequency of the CLK_SPI. Refer to the SPI chapter
for a description of this clock.
35.10.3.2 Slave mode
Figure 35-11. USART in SPI Slave Mode with (CPOL= 0 and CPHA= 1) or (CPOL= 1 and
CPHA= 0)
f
SPCKMAX MIN fPINMAX
1
SPIn
------------ f
CLKSPI 2
9 = (, ) ----------------------------
SPIn fPINMAX
f
CLKSPI
f
SPCKMAX MIN 1
SPIn tVALID + ----------------------------------- f
CLKSPI 2
9 = ( ,) -----------------------------
SPIn
TVALID
TVALID f
CLKSPI
USPI7 USPI8
MISO
SPCK
MOSI
USPI6
924
32142D–06/2013
ATUC64/128/256L3/4U
Figure 35-12. USART in SPI Slave Mode with (CPOL= CPHA= 0) or (CPOL= CPHA= 1)
Figure 35-13. USART in SPI Slave Mode, NPCS Timing
Notes: 1. These values are based on simulation and characterization of other AVR microcontrollers manufactured in the same process
technology. These values are not covered by test limits in production.
2. Where:
USPI10 USPI11
MISO
SPCK
MOSI
USPI9
USPI14
USPI12
USPI15
USPI13
NSS
SPCK, CPOL=0
SPCK, CPOL=1
Table 35-42. USART in SPI mode Timing, Slave Mode(1)
Symbol Parameter Conditions Min Max Units
USPI6 SPCK falling to MISO delay
VVDDIO from
3.0V to 3.6V,
maximum
external
capacitor =
40pF
37.3
ns
USPI7 MOSI setup time before SPCK rises 2.6 + tSAMPLE(2) +
tCLK_USART
USPI8 MOSI hold time after SPCK rises 0
USPI9 SPCK rising to MISO delay 37.0
USPI10 MOSI setup time before SPCK falls 2.6 + tSAMPLE(2) +
tCLK_USART
USPI11 MOSI hold time after SPCK falls 0
USPI12 NSS setup time before SPCK rises 27.2
USPI13 NSS hold time after SPCK falls 0
USPI14 NSS setup time before SPCK falls 27.2
USPI15 NSS hold time after SPCK rises 0
t
SAMPLE t
SPCK
t
SPCK
2 tCLKUSART ------------------------------------ 1
2
+ -- t
CLKUSART = –
925
32142D–06/2013
ATUC64/128/256L3/4U
Maximum SPI Frequency, Slave Input Mode
The maximum SPI slave input frequency is given by the following formula:
Where is the MOSI setup and hold time, USPI7 + USPI8 or USPI10 + USPI11 depending
on CPOL and NCPHA. is the maximum frequency of the CLK_SPI. Refer to the SPI
chapter for a description of this clock.
Maximum SPI Frequency, Slave Output Mode
The maximum SPI slave output frequency is given by the following formula:
Where is the MISO delay, USPI6 or USPI9 depending on CPOL and NCPHA. is
the SPI master setup time. Please refer to the SPI master datasheet for . is the
maximum frequency of the CLK_SPI. Refer to the SPI chapter for a description of this
clock. is the maximum frequency of the SPI pins. Please refer to the I/O Pin Characteristics
section for the maximum frequency of the pins.
35.10.4 SPI Timing
35.10.4.1 Master mode
Figure 35-14. SPI Master Mode with (CPOL= NCPHA= 0) or (CPOL= NCPHA= 1)
f
SPCKMAX MIN f
CLKSPI 2
9 ----------------------------- 1
SPIn = ( ,) ------------
SPIn
f
CLKSPI
f
SPCKMAX MIN f
CLKSPI 2
9 ---------------------------- f
PINMAX 1
SPIn tSETUP + = ( ,) ------------------------------------
SPIn TSETUP
TSETUP f
CLKSPI
f
PINMAX
SPI0 SPI1
MISO
SPCK
MOSI
SPI2
926
32142D–06/2013
ATUC64/128/256L3/4U
Figure 35-15. SPI Master Mode with (CPOL= 0 and NCPHA= 1) or (CPOL= 1 and NCPHA= 0)
Note: 1. These values are based on simulation and characterization of other AVR microcontrollers manufactured in the same process
technology. These values are not covered by test limits in production.
Maximum SPI Frequency, Master Output
The maximum SPI master output frequency is given by the following formula:
Where is the MOSI delay, SPI2 or SPI5 depending on CPOL and NCPHA. is the
maximum frequency of the SPI pins. Please refer to the I/O Pin Characteristics section for the
maximum frequency of the pins.
Maximum SPI Frequency, Master Input
The maximum SPI master input frequency is given by the following formula:
Where is the MISO setup and hold time, SPI0 + SPI1 or SPI3 + SPI4 depending on
CPOL and NCPHA. is the SPI slave response time. Please refer to the SPI slave
datasheet for .
SPI3 SPI4
MISO
SPCK
MOSI
SPI5
Table 35-43. SPI Timing, Master Mode(1)
Symbol Parameter Conditions Min Max Units
SPI0 MISO setup time before SPCK rises
VVDDIO from
3.0V to 3.6V,
maximum
external
capacitor =
40pF
33.4 + (tCLK_SPI)/2
ns
SPI1 MISO hold time after SPCK rises 0
SPI2 SPCK rising to MOSI delay 7.1
SPI3 MISO setup time before SPCK falls 29.2 + (tCLK_SPI)/2
SPI4 MISO hold time after SPCK falls 0
SPI5 SPCK falling to MOSI delay 8.63
f
SPCKMAX MIN fPINMAX
1
SPIn = ( ,) ------------
SPIn f
PINMAX
f
SPCKMAX
1
SPIn tVALID + = -----------------------------------
SPIn
t
VALID
tVALID
927
32142D–06/2013
ATUC64/128/256L3/4U
35.10.4.2 Slave mode
Figure 35-16. SPI Slave Mode with (CPOL= 0 and NCPHA= 1) or (CPOL= 1 and NCPHA= 0)
Figure 35-17. SPI Slave Mode with (CPOL= NCPHA= 0) or (CPOL= NCPHA= 1)
Figure 35-18. SPI Slave Mode, NPCS Timing
SPI7 SPI8
MISO
SPCK
MOSI
SPI6
SPI10 SPI11
MISO
SPCK
MOSI
SPI9
SPI14
SPI12
SPI15
SPI13
NPCS
SPCK, CPOL=0
SPCK, CPOL=1
928
32142D–06/2013
ATUC64/128/256L3/4U
Note: 1. These values are based on simulation and characterization of other AVR microcontrollers manufactured in the same process
technology. These values are not covered by test limits in production.
Maximum SPI Frequency, Slave Input Mode
The maximum SPI slave input frequency is given by the following formula:
Where is the MOSI setup and hold time, SPI7 + SPI8 or SPI10 + SPI11 depending on
CPOL and NCPHA. is the maximum frequency of the CLK_SPI. Refer to the SPI chapter
for a description of this clock.
Maximum SPI Frequency, Slave Output Mode
The maximum SPI slave output frequency is given by the following formula:
Where is the MISO delay, SPI6 or SPI9 depending on CPOL and NCPHA. is the
SPI master setup time. Please refer to the SPI master datasheet for . is the maximum
frequency of the SPI pins. Please refer to the I/O Pin Characteristics section for the
maximum frequency of the pins.
35.10.5 TWIM/TWIS Timing
Figure 35-45 shows the TWI-bus timing requirements and the compliance of the device with
them. Some of these requirements (tr
and tf
) are met by the device without requiring user intervention.
Compliance with the other requirements (tHD-STA, tSU-STA, tSU-STO, tHD-DAT, tSU-DAT-TWI, tLOWTWI,
tHIGH, and fTWCK) requires user intervention through appropriate programming of the relevant
Table 35-44. SPI Timing, Slave Mode(1)
Symbol Parameter Conditions Min Max Units
SPI6 SPCK falling to MISO delay
VVDDIO from
3.0V to 3.6V,
maximum
external
capacitor =
40pF
29.4
ns
SPI7 MOSI setup time before SPCK rises 0
SPI8 MOSI hold time after SPCK rises 6.0
SPI9 SPCK rising to MISO delay 29.0
SPI10 MOSI setup time before SPCK falls 0
SPI11 MOSI hold time after SPCK falls 5.5
SPI12 NPCS setup time before SPCK rises 3.4
SPI13 NPCS hold time after SPCK falls 1.1
SPI14 NPCS setup time before SPCK falls 3.3
SPI15 NPCS hold time after SPCK rises 0.7
f
SPCKMAX MIN fCLKSPI
1
SPIn = ( ,) ------------
SPIn
f
CLKSPI
f
SPCKMAX MIN fPINMAX
1
SPIn tSETUP + = (, ) ------------------------------------
SPIn t
SETUP
t
SETUP fPINMAX
929
32142D–06/2013
ATUC64/128/256L3/4U
TWIM and TWIS user interface registers. Please refer to the TWIM and TWIS sections for more
information.
Notes: 1. Standard mode: ; fast mode: .
2. A device must internally provide a hold time of at least 300 ns for TWD with reference to the falling edge of TWCK.
Notations:
Cb = total capacitance of one bus line in pF
tclkpb = period of TWI peripheral bus clock
tprescaled = period of TWI internal prescaled clock (see chapters on TWIM and TWIS)
The maximum tHD;DAT has only to be met if the device does not stretch the LOW period (tLOW-TWI)
of TWCK.
Table 35-45. TWI-Bus Timing Requirements
Symbol Parameter Mode
Minimum Maximum Uni
Requirement Device Requirement Device t
tr TWCK and TWD rise time
Standard(
1) - 1000
ns
Fast(1) 20 + 0.1Cb 300
tf TWCK and TWD fall time
Standard - 300
ns
Fast 20 + 0.1Cb 300
tHD-STA (Repeated) START hold time
Standard 4
tclkpb - s
Fast 0.6
tSU-STA
(Repeated) START set-up
time
Standard 4.7
tclkpb - s
Fast 0.6
tSU-STO STOP set-up time
Standard 4.0
4tclkpb - s
Fast 0.6
tHD-DAT Data hold time
Standard
0.3(2) 2tclkpb
3.45()
15tprescaled +
tclkpb
s
Fast 0.9()
tSU-DATTWI
Data set-up time
Standard 250
2tclkpb - ns
Fast 100
tSU-DAT - -tclkpb - -
tLOW-TWI TWCK LOW period
Standard 4.7
4tclkpb - s
Fast 1.3
tLOW - -tclkpb - -
tHIGH TWCK HIGH period
Standard 4.0
8tclkpb - s
Fast 0.6
fTWCK TWCK frequency
Standard - 100
kHz
Fast 400
1
12tclkpb
-----------------------
fTWCK 100 kHz f
TWCK 100 kHz
930
32142D–06/2013
ATUC64/128/256L3/4U
35.10.6 JTAG Timing
Figure 35-19. JTAG Interface Signals
Note: 1. These values are based on simulation and characterization of other AVR microcontrollers manufactured in the same process
technology. These values are not covered by test limits in production.
JTAG2
JTAG3
JTAG1
JTAG4
JTAG0
TMS/TDI
TCK
TDO
JTAG5
JTAG6
JTAG7 JTAG8
JTAG9
JTAG10
Boundary
Scan Inputs
Boundary
Scan Outputs
Table 35-46. JTAG Timings(1)
Symbol Parameter Conditions Min Max Units
JTAG0 TCK Low Half-period
VVDDIO from
3.0V to 3.6V,
maximum
external
capacitor =
40pF
21.8
ns
JTAG1 TCK High Half-period 8.6
JTAG2 TCK Period 30.3
JTAG3 TDI, TMS Setup before TCK High 2.0
JTAG4 TDI, TMS Hold after TCK High 2.3
JTAG5 TDO Hold Time 9.5
JTAG6 TCK Low to TDO Valid 21.8
JTAG7 Boundary Scan Inputs Setup Time 0.6
JTAG8 Boundary Scan Inputs Hold Time 6.9
JTAG9 Boundary Scan Outputs Hold Time 9.3
JTAG10 TCK to Boundary Scan Outputs Valid 32.2
931
32142D–06/2013
ATUC64/128/256L3/4U
36. Mechanical Characteristics
36.1 Thermal Considerations
36.1.1 Thermal Data
Table 36-1 summarizes the thermal resistance data depending on the package.
36.1.2 Junction Temperature
The average chip-junction temperature, TJ, in °C can be obtained from the following:
1.
2.
where:
• JA = package thermal resistance, Junction-to-ambient (°C/W), provided in Table 36-1.
• JC = package thermal resistance, Junction-to-case thermal resistance (°C/W), provided in
Table 36-1.
• HEAT SINK = cooling device thermal resistance (°C/W), provided in the device datasheet.
• PD = device power consumption (W) estimated from data provided in Section 35.4 on page
898.
• TA = ambient temperature (°C).
From the first equation, the user can derive the estimated lifetime of the chip and decide if a
cooling device is necessary or not. If a cooling device is to be fitted on the chip, the second
equation should be used to compute the resulting average chip-junction temperature TJ in °C.
Table 36-1. Thermal Resistance Data
Symbol Parameter Condition Package Typ Unit
JA Junction-to-ambient thermal resistance Still Air TQFP48 54.4 C/W
JC Junction-to-case thermal resistance TQFP48 15.7
JA Junction-to-ambient thermal resistance Still Air QFN48 26.0 C/W
JC Junction-to-case thermal resistance QFN48 1.6
JA Junction-to-ambient thermal resistance Still Air TLLGA48 25.4 C/W
JC Junction-to-case thermal resistance TLLGA48 12.7
JA Junction-to-ambient thermal resistance Still Air TQFP64 52.9 C/W
JC Junction-to-case thermal resistance TQFP64 15.5
JA Junction-to-ambient thermal resistance Still Air QFN64 22.9 C/W
JC Junction-to-case thermal resistance QFN64 1.6
TJ TA PD JA = +
TJ TA PD HEATSINK JC = + +
932
32142D–06/2013
ATUC64/128/256L3/4U
36.2 Package Drawings
Figure 36-1. TQFP-48 Package Drawing
Table 36-2. Device and Package Maximum Weight
140 mg
Table 36-3. Package Characteristics
Moisture Sensitivity Level MSL3
Table 36-4. Package Reference
JEDEC Drawing Reference MS-026
JESD97 Classification E3
933
32142D–06/2013
ATUC64/128/256L3/4U
Figure 36-2. QFN-48 Package Drawing
Note: The exposed pad is not connected to anything internally, but should be soldered to ground to increase board level reliability.
Table 36-5. Device and Package Maximum Weight
140 mg
Table 36-6. Package Characteristics
Moisture Sensitivity Level MSL3
Table 36-7. Package Reference
JEDEC Drawing Reference M0-220
JESD97 Classification E3
934
32142D–06/2013
ATUC64/128/256L3/4U
Figure 36-3. TLLGA-48 Package Drawing
Table 36-8. Device and Package Maximum Weight
39.3 mg
Table 36-9. Package Characteristics
Moisture Sensitivity Level MSL3
Table 36-10. Package Reference
JEDEC Drawing Reference N/A
JESD97 Classification E4
935
32142D–06/2013
ATUC64/128/256L3/4U
Figure 36-4. TQFP-64 Package Drawing
Table 36-11. Device and Package Maximum Weight
300 mg
Table 36-12. Package Characteristics
Moisture Sensitivity Level MSL3
Table 36-13. Package Reference
JEDEC Drawing Reference MS-026
JESD97 Classification E3
936
32142D–06/2013
ATUC64/128/256L3/4U
Figure 36-5. QFN-64 Package Drawing
Note: The exposed pad is not connected to anything internally, but should be soldered to ground to increase board level reliability.
Table 36-14. Device and Package Maximum Weight
200 mg
Table 36-15. Package Characteristics
Moisture Sensitivity Level MSL3
Table 36-16. Package Reference
JEDEC Drawing Reference M0-220
JESD97 Classification E3
937
32142D–06/2013
ATUC64/128/256L3/4U
36.3 Soldering Profile
Table 36-17 gives the recommended soldering profile from J-STD-20.
A maximum of three reflow passes is allowed per component.
Table 36-17. Soldering Profile
Profile Feature Green Package
Average Ramp-up Rate (217°C to Peak) 3°C/s max
Preheat Temperature 175°C ±25°C 150-200°C
Time Maintained Above 217°C 60-150 s
Time within 5C of Actual Peak Temperature 30 s
Peak Temperature Range 260°C
Ramp-down Rate 6°C/s max
Time 25C to Peak Temperature 8 minutes max
938
32142D–06/2013
ATUC64/128/256L3/4U
37. Ordering Information
Table 37-1. Ordering Information
Device Ordering Code Carrier Type Package Package Type
Temperature Operating
Range
ATUC256L3U
ATUC256L3U-AUTES ES
TQFP 64
JESD97 Classification E3
N/A
ATUC256L3U-AUT Tray
Industrial (-40C to 85C)
ATUC256L3U-AUR Tape & Reel
ATUC256L3U-Z3UTES ES
QFN 64
N/A
ATUC256L3U-Z3UT Tray
Industrial (-40C to 85C)
ATUC256L3U-Z3UR Tape & Reel
ATUC128L3U
ATUC128L3U-AUT Tray TQFP 64
JESD97 Classification E3 Industrial (-40C to 85C)
ATUC128L3U-AUR Tape & Reel
ATUC128L3U-Z3UT Tray QFN 64
ATUC128L3U-Z3UR Tape & Reel
ATUC64L3U
ATUC64L3U-AUT Tray TQFP 64
JESD97 Classification E3 Industrial (-40C to 85C) ATUC64L3U-AUR Tape & Reel
ATUC64L3U-Z3UT Tray QFN 64
ATUC64L3U-Z3UR Tape & Reel
939
32142D–06/2013
ATUC64/128/256L3/4U
ATUC256L4U
ATUC256L4U-AUTES ES
TQFP 48
JESD97 Classification E3
N/A
ATUC256L4U-AUT Tray Industrial (-40C to 85C)
ATUC256L4U-AUR Tape & Reel
ATUC256L4U-ZAUTES ES
QFN 48
N/A
ATUC256L4U-ZAUT Tray
Industrial (-40C to 85C) ATUC256L4U-ZAUR Tape & Reel
ATUC256L4U-D3HES ES
TLLGA 48 JESD97 Classification E4
N/A
ATUC256L4U-D3HT Tray
Industrial (-40C to 85C)
ATUC256L4U-D3HR Tape & Reel
ATUC128L4U
ATUC128L4U-AUT Tray TQFP 48
JESD97 Classification E3
ATUC128L4U-AUR Tape & Reel
ATUC128L4U-ZAUT Tray QFN 48
ATUC128L4U-ZAUR Tape & Reel
ATUC128L4U-D3HT Tray TLLGA 48 JESD97 Classification E4
ATUC128L4U-D3HR Tape & Reel
ATUC64L4U
ATUC64L4U-AUT Tray TQFP 48
JESD97 Classification E3
ATUC64L4U-AUR Tape & Reel
ATUC64L4U-ZAUT Tray QFN 48
ATUC64L4U-ZAUR Tape & Reel
ATUC64L4U-D3HT Tray TLLGA 48 JESD97 Classification E4
ATUC64L4U-D3HR Tape & Reel
Table 37-1. Ordering Information
Device Ordering Code Carrier Type Package Package Type
Temperature Operating
Range
940
32142D–06/2013
ATUC64/128/256L3/4U
38. Errata
38.1 Rev. C
38.1.1 SCIF
1. The RC32K output on PA20 is not always permanently disabled
The RC32K output on PA20 may sometimes re-appear.
Fix/Workaround
Before using RC32K for other purposes, the following procedure has to be followed in order
to properly disable it:
- Run the CPU on RCSYS
- Disable the output to PA20 by writing a zero to PM.PPCR.RC32OUT
- Enable RC32K by writing a one to SCIF.RC32KCR.EN, and wait for this bit to be read as
one
- Disable RC32K by writing a zero to SCIF.RC32KCR.EN, and wait for this bit to be read as
zero.
2. PLLCOUNT value larger than zero can cause PLLEN glitch
Initializing the PLLCOUNT with a value greater than zero creates a glitch on the PLLEN signal
during asynchronous wake up.
Fix/Workaround
The lock-masking mechanism for the PLL should not be used.
The PLLCOUNT field of the PLL Control Register should always be written to zero.
3. Writing 0x5A5A5A5A to the SCIF memory range will enable the SCIF UNLOCK feature
The SCIF UNLOCK feature will be enabled if the value 0x5A5A5A5A is written to any location
in the SCIF memory range.
Fix/Workaround
None.
38.1.2 SPI
1. SPI data transfer hangs with CSR0.CSAAT==1 and MR.MODFDIS==0
When CSR0.CSAAT==1 and mode fault detection is enabled (MR.MODFDIS==0), the SPI
module will not start a data transfer.
Fix/Workaround
Disable mode fault detection by writing a one to MR.MODFDIS.
2. Disabling SPI has no effect on the SR.TDRE bit
Disabling SPI has no effect on the SR.TDRE bit whereas the write data command is filtered
when SPI is disabled. Writing to TDR when SPI is disabled will not clear SR.TDRE. If SPI is
disabled during a PDCA transfer, the PDCA will continue to write data to TDR until its buffer
is empty, and this data will be lost.
Fix/Workaround
Disable the PDCA, add two NOPs, and disable the SPI. To continue the transfer, enable the
SPI and PDCA.
3. SPI disable does not work in SLAVE mode
SPI disable does not work in SLAVE mode.
Fix/Workaround
Read the last received data, then perform a software reset by writing a one to the Software
Reset bit in the Control Register (CR.SWRST).
941
32142D–06/2013
ATUC64/128/256L3/4U
4. SPI bad serial clock generation on 2nd chip_select when SCBR=1, CPOL=1, and
NCPHA=0
When multiple chip selects (CS) are in use, if one of the baudrates equal 1 while one
(CSRn.SCBR=1) of the others do not equal 1, and CSRn.CPOL=1 and CSRn.NCPHA=0,
then an additional pulse will be generated on SCK.
Fix/Workaround
When multiple CS are in use, if one of the baudrates equals 1, the others must also equal 1
if CSRn.CPOL=1 and CSRn.NCPHA=0.
5. SPI mode fault detection enable causes incorrect behavior
When mode fault detection is enabled (MR.MODFDIS==0), the SPI module may not operate
properly.
Fix/Workaround
Always disable mode fault detection before using the SPI by writing a one to MR.MODFDIS.
6. SPI RDR.PCS is not correct
The PCS (Peripheral Chip Select) field in the SPI RDR (Receive Data Register) does not
correctly indicate the value on the NPCS pins at the end of a transfer.
Fix/Workaround
Do not use the PCS field of the SPI RDR.
38.1.3 TWI
1. SMBALERT bit may be set after reset
The SMBus Alert (SMBALERT) bit in the Status Register (SR) might be erroneously set after
system reset.
Fix/Workaround
After system reset, clear the SR.SMBALERT bit before commencing any TWI transfer.
2. Clearing the NAK bit before the BTF bit is set locks up the TWI bus
When the TWIS is in transmit mode, clearing the NAK Received (NAK) bit of the Status Register
(SR) before the end of the Acknowledge/Not Acknowledge cycle will cause the TWIS to
attempt to continue transmitting data, thus locking up the bus.
Fix/Workaround
Clear SR.NAK only after the Byte Transfer Finished (BTF) bit of the same register has been
set.
38.1.4 TC
1. Channel chaining skips first pulse for upper channel
When chaining two channels using the Block Mode Register, the first pulse of the clock
between the channels is skipped.
Fix/Workaround
Configure the lower channel with RA = 0x1 and RC = 0x2 to produce a dummy clock cycle
for the upper channel. After the dummy cycle has been generated, indicated by the
SR.CPCS bit, reconfigure the RA and RC registers for the lower channel with the real
values.
38.1.5 CAT
1. CAT QMatrix sense capacitors discharged prematurely
At the end of a QMatrix burst charging sequence that uses different burst count values for
different Y lines, the Y lines may be incorrectly grounded for up to n-1 periods of the periph-
942
32142D–06/2013
ATUC64/128/256L3/4U
eral bus clock, where n is the ratio of the PB clock frequency to the GCLK_CAT frequency.
This results in premature loss of charge from the sense capacitors and thus increased variability
of the acquired count values.
Fix/Workaround
Enable the 1kOhm drive resistors on all implemented QMatrix Y lines (CSA 1, 3, 5, 7, 9, 11,
13, and/or 15) by writing ones to the corresponding odd bits of the CSARES register.
2. Autonomous CAT acquisition must be longer than AST source clock period
When using the AST to trigger CAT autonomous touch acquisition in sleep modes where the
CAT bus clock is turned off, the CAT will start several acquisitions if the period of the AST
source clock is larger than one CAT acquisition. One AST clock period after the AST trigger,
the CAT clock will automatically stop and the CAT acquisition can be stopped prematurely,
ruining the result.
Fix/Workaround
Always ensure that the ATCFG1.max field is set so that the duration of the autonomous
touch acquisition is greater than one clock period of the AST source clock.
38.1.6 aWire
1. aWire MEMORY_SPEED_REQUEST command does not return correct CV
The aWire MEMORY_SPEED_REQUEST command does not return a CV corresponding to
the formula in the aWire Debug Interface chapter.
Fix/Workaround
Issue a dummy read to address 0x100000000 before issuing the
MEMORY_SPEED_REQUEST command and use this formula instead:
38.2 Flash
1. Corrupted data in flash may happen after flash page write operations
After a flash page write operation from an external programmer, reading (data read or code
fetch) in flash may fail. This may lead to an exception or to others errors derived from this
corrupted read access.
Fix/Workaround
Before any flash page write operation, each write in the page buffer must preceded by a
write in the page buffer with 0xFFFF_FFFF content at any address in the page.
38.3 Rev. B
38.3.1 SCIF
1. The RC32K output on PA20 is not always permanently disabled
The RC32K output on PA20 may sometimes re-appear.
Fix/Workaround
Before using RC32K for other purposes, the following procedure has to be followed in order
to properly disable it:
- Run the CPU on RCSYS
- Disable the output to PA20 by writing a zero to PM.PPCR.RC32OUT
- Enable RC32K by writing a one to SCIF.RC32KCR.EN, and wait for this bit to be read as
one
f
sab
7f
aw
CV – 3 = ----------------
943
32142D–06/2013
ATUC64/128/256L3/4U
- Disable RC32K by writing a zero to SCIF.RC32KCR.EN, and wait for this bit to be read as
zero.
2. PLLCOUNT value larger than zero can cause PLLEN glitch
Initializing the PLLCOUNT with a value greater than zero creates a glitch on the PLLEN signal
during asynchronous wake up.
Fix/Workaround
The lock-masking mechanism for the PLL should not be used.
The PLLCOUNT field of the PLL Control Register should always be written to zero.
3. Writing 0x5A5A5A5A to the SCIF memory range will enable the SCIF UNLOCK feature
The SCIF UNLOCK feature will be enabled if the value 0x5A5A5A5A is written to any location
in the SCIF memory range.
Fix/Workaround
None.
38.3.2 WDT
1. WDT Control Register does not have synchronization feedback
When writing to the Timeout Prescale Select (PSEL), Time Ban Prescale Select (TBAN),
Enable (EN), or WDT Mode (MODE) fieldss of the WDT Control Register (CTRL), a synchronizer
is started to propagate the values to the WDT clcok domain. This synchronization
takes a finite amount of time, but only the status of the synchronization of the EN bit is
reflected back to the user. Writing to the synchronized fields during synchronization can lead
to undefined behavior.
Fix/Workaround
-When writing to the affected fields, the user must ensure a wait corresponding to 2 clock
cycles of both the WDT peripheral bus clock and the selected WDT clock source.
-When doing writes that changes the EN bit, the EN bit can be read back until it reflects the
written value.
38.3.3 SPI
1. SPI data transfer hangs with CSR0.CSAAT==1 and MR.MODFDIS==0
When CSR0.CSAAT==1 and mode fault detection is enabled (MR.MODFDIS==0), the SPI
module will not start a data transfer.
Fix/Workaround
Disable mode fault detection by writing a one to MR.MODFDIS.
2. Disabling SPI has no effect on the SR.TDRE bit
Disabling SPI has no effect on the SR.TDRE bit whereas the write data command is filtered
when SPI is disabled. Writing to TDR when SPI is disabled will not clear SR.TDRE. If SPI is
disabled during a PDCA transfer, the PDCA will continue to write data to TDR until its buffer
is empty, and this data will be lost.
Fix/Workaround
Disable the PDCA, add two NOPs, and disable the SPI. To continue the transfer, enable the
SPI and PDCA.
3. SPI disable does not work in SLAVE mode
SPI disable does not work in SLAVE mode.
Fix/Workaround
Read the last received data, then perform a software reset by writing a one to the Software
Reset bit in the Control Register (CR.SWRST).
944
32142D–06/2013
ATUC64/128/256L3/4U
4. SPI bad serial clock generation on 2nd chip_select when SCBR=1, CPOL=1, and
NCPHA=0
When multiple chip selects (CS) are in use, if one of the baudrates equal 1 while one
(CSRn.SCBR=1) of the others do not equal 1, and CSRn.CPOL=1 and CSRn.NCPHA=0,
then an additional pulse will be generated on SCK.
Fix/Workaround
When multiple CS are in use, if one of the baudrates equals 1, the others must also equal 1
if CSRn.CPOL=1 and CSRn.NCPHA=0.
5. SPI mode fault detection enable causes incorrect behavior
When mode fault detection is enabled (MR.MODFDIS==0), the SPI module may not operate
properly.
Fix/Workaround
Always disable mode fault detection before using the SPI by writing a one to MR.MODFDIS.
6. SPI RDR.PCS is not correct
The PCS (Peripheral Chip Select) field in the SPI RDR (Receive Data Register) does not
correctly indicate the value on the NPCS pins at the end of a transfer.
Fix/Workaround
Do not use the PCS field of the SPI RDR.
38.3.4 TWI
1. TWIS may not wake the device from sleep mode
If the CPU is put to a sleep mode (except Idle and Frozen) directly after a TWI Start condition,
the CPU may not wake upon a TWIS address match. The request is NACKed.
Fix/Workaround
When using the TWI address match to wake the device from sleep, do not switch to sleep
modes deeper than Frozen. Another solution is to enable asynchronous EIC wake on the
TWIS clock (TWCK) or TWIS data (TWD) pins, in order to wake the system up on bus
events.
2. SMBALERT bit may be set after reset
The SMBus Alert (SMBALERT) bit in the Status Register (SR) might be erroneously set after
system reset.
Fix/Workaround
After system reset, clear the SR.SMBALERT bit before commencing any TWI transfer.
3. Clearing the NAK bit before the BTF bit is set locks up the TWI bus
When the TWIS is in transmit mode, clearing the NAK Received (NAK) bit of the Status Register
(SR) before the end of the Acknowledge/Not Acknowledge cycle will cause the TWIS to
attempt to continue transmitting data, thus locking up the bus.
Fix/Workaround
Clear SR.NAK only after the Byte Transfer Finished (BTF) bit of the same register has been
set.
38.3.5 PWMA
1. The SR.READY bit cannot be cleared by writing to SCR.READY
The Ready bit in the Status Register will not be cleared when writing a one to the corresponding
bit in the Status Clear register. The Ready bit will be cleared when the Busy bit is
set.
Fix/Workaround
945
32142D–06/2013
ATUC64/128/256L3/4U
Disable the Ready interrupt in the interrupt handler when receiving the interrupt. When an
operation that triggers the Busy/Ready bit is started, wait until the ready bit is low in the Status
Register before enabling the interrupt.
38.3.6 TC
1. Channel chaining skips first pulse for upper channel
When chaining two channels using the Block Mode Register, the first pulse of the clock
between the channels is skipped.
Fix/Workaround
Configure the lower channel with RA = 0x1 and RC = 0x2 to produce a dummy clock cycle
for the upper channel. After the dummy cycle has been generated, indicated by the
SR.CPCS bit, reconfigure the RA and RC registers for the lower channel with the real
values.
38.3.7 CAT
1. CAT QMatrix sense capacitors discharged prematurely
At the end of a QMatrix burst charging sequence that uses different burst count values for
different Y lines, the Y lines may be incorrectly grounded for up to n-1 periods of the peripheral
bus clock, where n is the ratio of the PB clock frequency to the GCLK_CAT frequency.
This results in premature loss of charge from the sense capacitors and thus increased variability
of the acquired count values.
Fix/Workaround
Enable the 1kOhm drive resistors on all implemented QMatrix Y lines (CSA 1, 3, 5, 7, 9, 11,
13, and/or 15) by writing ones to the corresponding odd bits of the CSARES register.
2. Autonomous CAT acquisition must be longer than AST source clock period
When using the AST to trigger CAT autonomous touch acquisition in sleep modes where the
CAT bus clock is turned off, the CAT will start several acquisitions if the period of the AST
source clock is larger than one CAT acquisition. One AST clock period after the AST trigger,
the CAT clock will automatically stop and the CAT acquisition can be stopped prematurely,
ruining the result.
Fix/Workaround
Always ensure that the ATCFG1.max field is set so that the duration of the autonomous
touch acquisition is greater than one clock period of the AST source clock.
3. CAT consumes unnecessary power when disabled or when autonomous touch not
used
A CAT prescaler controlled by the ATCFG0.DIV field will be active even when the CAT module
is disabled or when the autonomous touch feature is not used, thereby causing
unnecessary power consumption.
Fix/Workaround
If the CAT module is not used, disable the CLK_CAT clock in the PM module. If the CAT
module is used but the autonomous touch feature is not used, the power consumption of the
CAT module may be reduced by writing 0xFFFF to the ATCFG0.DIV field.
38.3.8 aWire
1. aWire MEMORY_SPEED_REQUEST command does not return correct CV
The aWire MEMORY_SPEED_REQUEST command does not return a CV corresponding to
the formula in the aWire Debug Interface chapter.
Fix/Workaround
946
32142D–06/2013
ATUC64/128/256L3/4U
Issue a dummy read to address 0x100000000 before issuing the
MEMORY_SPEED_REQUEST command and use this formula instead:
38.4 Flash
2. Corrupted data in flash may happen after flash page write operations
After a flash page write operation from an external programmer, reading (data read or code
fetch) in flash may fail. This may lead to an exception or to others errors derived from this
corrupted read access.
Fix/Workaround
Before any flash page write operation, each write in the page buffer must preceded by a
write in the page buffer with 0xFFFF_FFFF content at any address in the page.
38.5 Rev. A
38.5.1 Device
3. JTAGID is wrong
The JTAGID reads 0x021DF03F for all devices.
Fix/Workaround
None.
38.5.2 FLASHCDW
1. General-purpose fuse programming does not work
The general-purpose fuses cannot be programmed and are stuck at 1. Please refer to the
Fuse Settings chapter in the FLASHCDW for more information about what functions are
affected.
Fix/Workaround
None.
2. Set Security Bit command does not work
The Set Security Bit (SSB) command of the FLASHCDW does not work. The device cannot
be locked from external JTAG, aWire, or other debug accesses.
Fix/Workaround
None.
3. Flash programming time is longer than specified
f
sab
7f
aw
CV – 3 = ----------------
947
32142D–06/2013
ATUC64/128/256L3/4U
The flash programming time is now:
Fix/Workaround
None.
4. Power Manager
5. Clock Failure Detector (CFD) can be issued while turning off the CFD
While turning off the CFD, the CFD bit in the Status Register (SR) can be set. This will
change the main clock source to RCSYS.
Fix/Workaround
Solution 1: Enable CFD interrupt. If CFD interrupt is issues after turning off the CFD, switch
back to original main clock source.
Solution 2: Only turn off the CFD while running the main clock on RCSYS.
6. Sleepwalking in idle and frozen sleep mode will mask all other PB clocks
If the CPU is in idle or frozen sleep mode and a module is in a state that triggers sleep walking,
all PB clocks will be masked except the PB clock to the sleepwalking module.
Fix/Workaround
Mask all clock requests in the PM.PPCR register before going into idle or frozen mode.
4. Unused PB clocks are running
Three unused PBA clocks are enabled by default and will cause increased active power
consumption.
Fix/Workaround
Disable the clocks by writing zeroes to bits [27:25] in the PBA clock mask register.
38.5.3 SCIF
1. The RC32K output on PA20 is not always permanently disabled
The RC32K output on PA20 may sometimes re-appear.
Fix/Workaround
Before using RC32K for other purposes, the following procedure has to be followed in order
to properly disable it:
- Run the CPU on RCSYS
- Disable the output to PA20 by writing a zero to PM.PPCR.RC32OUT
- Enable RC32K by writing a one to SCIF.RC32KCR.EN, and wait for this bit to be read as
one
- Disable RC32K by writing a zero to SCIF.RC32KCR.EN, and wait for this bit to be read as
zero.
2. PLL lock might not clear after disable
Table 38-1. Flash Characteristics
Symbol Parameter Conditions Min Typ Max Unit
TFPP Page programming time
fCLK_HSB= 50MHz
7.5
ms
TFPE Page erase time 7.5
TFFP Fuse programming time 1
TFEA Full chip erase time (EA) 9
TFCE
JTAG chip erase time
(CHIP_ERASE) fCLK_HSB= 115kHz 250
948
32142D–06/2013
ATUC64/128/256L3/4U
Under certain circumstances, the lock signal from the Phase Locked Loop (PLL) oscillator
may not go back to zero after the PLL oscillator has been disabled. This can cause the propagation
of clock signals with the wrong frequency to parts of the system that use the PLL
clock.
Fix/Workaround
PLL must be turned off before entering STOP, DEEPSTOP or STATIC sleep modes. If PLL
has been turned off, a delay of 30us must be observed after the PLL has been enabled
again before the SCIF.PLL0LOCK bit can be used as a valid indication that the PLL is
locked.
3. PLLCOUNT value larger than zero can cause PLLEN glitch
Initializing the PLLCOUNT with a value greater than zero creates a glitch on the PLLEN signal
during asynchronous wake up.
Fix/Workaround
The lock-masking mechanism for the PLL should not be used.
The PLLCOUNT field of the PLL Control Register should always be written to zero.
4. RCSYS is not calibrated
The RCSYS is not calibrated and will run faster than 115.2kHz. Frequencies around 150kHz
can be expected.
Fix/Workaround
If a known clock source is available the RCSYS can be runtime calibrated by using the frequency
meter (FREQM) and tuning the RCSYS by writing to the RCCR register in SCIF.
5. Writing 0x5A5A5A5A to the SCIF memory range will enable the SCIF UNLOCK feature
The SCIF UNLOCK feature will be enabled if the value 0x5A5A5A5A is written to any location
in the SCIF memory range.
Fix/Workaround
None.
38.5.4 WDT
1. Clearing the Watchdog Timer (WDT) counter in second half of timeout period will
issue a Watchdog reset
If the WDT counter is cleared in the second half of the timeout period, the WDT will immediately
issue a Watchdog reset.
Fix/Workaround
Use twice as long timeout period as needed and clear the WDT counter within the first half
of the timeout period. If the WDT counter is cleared after the first half of the timeout period,
you will get a Watchdog reset immediately. If the WDT counter is not cleared at all, the time
before the reset will be twice as long as needed.
2. WDT Control Register does not have synchronization feedback
When writing to the Timeout Prescale Select (PSEL), Time Ban Prescale Select (TBAN),
Enable (EN), or WDT Mode (MODE) fieldss of the WDT Control Register (CTRL), a synchronizer
is started to propagate the values to the WDT clcok domain. This synchronization
takes a finite amount of time, but only the status of the synchronization of the EN bit is
reflected back to the user. Writing to the synchronized fields during synchronization can lead
to undefined behavior.
Fix/Workaround
-When writing to the affected fields, the user must ensure a wait corresponding to 2 clock
cycles of both the WDT peripheral bus clock and the selected WDT clock source.
-When doing writes that changes the EN bit, the EN bit can be read back until it reflects the
written value.
949
32142D–06/2013
ATUC64/128/256L3/4U
38.5.5 GPIO
1. Clearing Interrupt flags can mask other interrupts
When clearing interrupt flags in a GPIO port, interrupts on other pins of that port, happening
in the same clock cycle will not be registered.
Fix/Workaround
Read the PVR register of the port before and after clearing the interrupt to see if any pin
change has happened while clearing the interrupt. If any change occurred in the PVR
between the reads, they must be treated as an interrupt.
38.5.6 SPI
1. SPI data transfer hangs with CSR0.CSAAT==1 and MR.MODFDIS==0
When CSR0.CSAAT==1 and mode fault detection is enabled (MR.MODFDIS==0), the SPI
module will not start a data transfer.
Fix/Workaround
Disable mode fault detection by writing a one to MR.MODFDIS.
2. Disabling SPI has no effect on the SR.TDRE bit
Disabling SPI has no effect on the SR.TDRE bit whereas the write data command is filtered
when SPI is disabled. Writing to TDR when SPI is disabled will not clear SR.TDRE. If SPI is
disabled during a PDCA transfer, the PDCA will continue to write data to TDR until its buffer
is empty, and this data will be lost.
Fix/Workaround
Disable the PDCA, add two NOPs, and disable the SPI. To continue the transfer, enable the
SPI and PDCA.
3. SPI disable does not work in SLAVE mode
SPI disable does not work in SLAVE mode.
Fix/Workaround
Read the last received data, then perform a software reset by writing a one to the Software
Reset bit in the Control Register (CR.SWRST).
4. SPI bad serial clock generation on 2nd chip_select when SCBR=1, CPOL=1, and
NCPHA=0
When multiple chip selects (CS) are in use, if one of the baudrates equal 1 while one
(CSRn.SCBR=1) of the others do not equal 1, and CSRn.CPOL=1 and CSRn.NCPHA=0,
then an additional pulse will be generated on SCK.
Fix/Workaround
When multiple CS are in use, if one of the baudrates equals 1, the others must also equal 1
if CSRn.CPOL=1 and CSRn.NCPHA=0.
5. SPI mode fault detection enable causes incorrect behavior
When mode fault detection is enabled (MR.MODFDIS==0), the SPI module may not operate
properly.
Fix/Workaround
Always disable mode fault detection before using the SPI by writing a one to MR.MODFDIS.
6. SPI RDR.PCS is not correct
The PCS (Peripheral Chip Select) field in the SPI RDR (Receive Data Register) does not
correctly indicate the value on the NPCS pins at the end of a transfer.
Fix/Workaround
Do not use the PCS field of the SPI RDR.
950
32142D–06/2013
ATUC64/128/256L3/4U
38.5.7 TWI
1. TWIS may not wake the device from sleep mode
If the CPU is put to a sleep mode (except Idle and Frozen) directly after a TWI Start condition,
the CPU may not wake upon a TWIS address match. The request is NACKed.
Fix/Workaround
When using the TWI address match to wake the device from sleep, do not switch to sleep
modes deeper than Frozen. Another solution is to enable asynchronous EIC wake on the
TWIS clock (TWCK) or TWIS data (TWD) pins, in order to wake the system up on bus
events.
2. SMBALERT bit may be set after reset
The SMBus Alert (SMBALERT) bit in the Status Register (SR) might be erroneously set after
system reset.
Fix/Workaround
After system reset, clear the SR.SMBALERT bit before commencing any TWI transfer.
3. Clearing the NAK bit before the BTF bit is set locks up the TWI bus
When the TWIS is in transmit mode, clearing the NAK Received (NAK) bit of the Status Register
(SR) before the end of the Acknowledge/Not Acknowledge cycle will cause the TWIS to
attempt to continue transmitting data, thus locking up the bus.
Fix/Workaround
Clear SR.NAK only after the Byte Transfer Finished (BTF) bit of the same register has been
set.
4. TWIS stretch on Address match error
When the TWIS stretches TWCK due to a slave address match, it also holds TWD low for
the same duration if it is to be receiving data. When TWIS releases TWCK, it releases TWD
at the same time. This can cause a TWI timing violation.
Fix/Workaround
None.
5. TWIM TWALM polarity is wrong
The TWALM signal in the TWIM is active high instead of active low.
Fix/Workaround
Use an external inverter to invert the signal going into the TWIM. When using both TWIM
and TWIS on the same pins, the TWALM cannot be used.
38.5.8 PWMA
1. The SR.READY bit cannot be cleared by writing to SCR.READY
The Ready bit in the Status Register will not be cleared when writing a one to the corresponding
bit in the Status Clear register. The Ready bit will be cleared when the Busy bit is
set.
Fix/Workaround
Disable the Ready interrupt in the interrupt handler when receiving the interrupt. When an
operation that triggers the Busy/Ready bit is started, wait until the ready bit is low in the Status
Register before enabling the interrupt.
38.5.9 TC
1. Channel chaining skips first pulse for upper channel
When chaining two channels using the Block Mode Register, the first pulse of the clock
between the channels is skipped.
951
32142D–06/2013
ATUC64/128/256L3/4U
Fix/Workaround
Configure the lower channel with RA = 0x1 and RC = 0x2 to produce a dummy clock cycle
for the upper channel. After the dummy cycle has been generated, indicated by the
SR.CPCS bit, reconfigure the RA and RC registers for the lower channel with the real
values.
38.5.10 ADCIFB
1. ADCIFB DMA transfer does not work with divided PBA clock
DMA requests from the ADCIFB will not be performed when the PBA clock is slower than
the HSB clock.
Fix/Workaround
Do not use divided PBA clock when the PDCA transfers from the ADCIFB.
38.5.11 CAT
1. CAT QMatrix sense capacitors discharged prematurely
At the end of a QMatrix burst charging sequence that uses different burst count values for
different Y lines, the Y lines may be incorrectly grounded for up to n-1 periods of the peripheral
bus clock, where n is the ratio of the PB clock frequency to the GCLK_CAT frequency.
This results in premature loss of charge from the sense capacitors and thus increased variability
of the acquired count values.
Fix/Workaround
Enable the 1kOhm drive resistors on all implemented QMatrix Y lines (CSA 1, 3, 5, 7, 9, 11,
13, and/or 15) by writing ones to the corresponding odd bits of the CSARES register.
2. Autonomous CAT acquisition must be longer than AST source clock period
When using the AST to trigger CAT autonomous touch acquisition in sleep modes where the
CAT bus clock is turned off, the CAT will start several acquisitions if the period of the AST
source clock is larger than one CAT acquisition. One AST clock period after the AST trigger,
the CAT clock will automatically stop and the CAT acquisition can be stopped prematurely,
ruining the result.
Fix/Workaround
Always ensure that the ATCFG1.max field is set so that the duration of the autonomous
touch acquisition is greater than one clock period of the AST source clock.
3. CAT consumes unnecessary power when disabled or when autonomous touch not
used
A CAT prescaler controlled by the ATCFG0.DIV field will be active even when the CAT module
is disabled or when the autonomous touch feature is not used, thereby causing
unnecessary power consumption.
Fix/Workaround
If the CAT module is not used, disable the CLK_CAT clock in the PM module. If the CAT
module is used but the autonomous touch feature is not used, the power consumption of the
CAT module may be reduced by writing 0xFFFF to the ATCFG0.DIV field.
4. CAT module does not terminate QTouch burst on detect
The CAT module does not terminate a QTouch burst when the detection voltage is
reached on the sense capacitor. This can cause the sense capacitor to be charged more
than necessary. Depending on the dielectric absorption characteristics of the capacitor, this
can lead to unstable measurements.
Fix/Workaround
Use the minimum possible value for the MAX field in the ATCFG1, TG0CFG1, and
TG1CFG1 registers.
952
32142D–06/2013
ATUC64/128/256L3/4U
38.5.12 aWire
1. aWire MEMORY_SPEED_REQUEST command does not return correct CV
The aWire MEMORY_SPEED_REQUEST command does not return a CV corresponding to
the formula in the aWire Debug Interface chapter.
Fix/Workaround
Issue a dummy read to address 0x100000000 before issuing the
MEMORY_SPEED_REQUEST command and use this formula instead:
38.5.13 Flash
5. Corrupted data in flash may happen after flash page write operations
After a flash page write operation from an external programmer, reading (data read or code
fetch) in flash may fail. This may lead to an exception or to others errors derived from this
corrupted read access.
Fix/Workaround
Before any flash page write operation, each write in the page buffer must preceded by a
write in the page buffer with 0xFFFF_FFFF content at any address in the page.
38.5.14 I/O Pins
1. PA05 is not 3.3V tolerant.
PA05 should be grounded on the PCB and left unused if VDDIO is above 1.8V.
Fix/Workaround
None.
2. No pull-up on pins that are not bonded
PB13 to PB27 are not bonded on UC3L0256/128, but has no pull-up and can cause current
consumption on VDDIO/VDDIN if left undriven.
Fix/Workaround
Enable pull-ups on PB13 to PB27 by writing 0x0FFFE000 to the PUERS1 register in the
GPIO.
3. PA17 has low ESD tolerance
PA17 only tolerates 500V ESD pulses (Human Body Model).
Fix/Workaround
Care must be taken during manufacturing and PCB design.
f
sab
7f
aw
CV – 3 = ----------------
953
32142D–06/2013
ATUC64/128/256L3/4U
39. Datasheet Revision History
Please note that the referring page numbers in this section are referred to this document. The
referring revision in this section are referring to the document revision.
39.1 Rev. D – 06/2013
39.2 Rev. C – 01/2012
39.3 Rev. B – 12/2011
39.4 Rev. A – 12/2011
1. Updated the datasheet with a new ATmel blue logo and the last page.
2. Added Flash errata.
1. Description: DFLL frequency is 20 to 150MHz, not 40 to 150MHz.
2. Block Diagram: GCLK_IN is input, not output. CAT SMP corrected from I/O to output. SPI
NPCS corrected from output to I/O.
3, Package and Pinout: EXTINT0 in Signal Descriptions table is NMI.
4, Supply and Startup Considerations: In 1.8V single supply mode figure, the input voltage is
1.62-1.98V, not 1.98-3.6V. “On system start-up, the DFLL is disabled” is replaced by “On
system start-up, all high-speed clocks are disabled”.
5, ADCIFB: PRND signal removed from block diagram.
6, Electrical Charateristics: Added 64-pin package information to I/O Pin Characteristics tables
and Digital Clock Characteristics table.
7, Mechanical Characteristics: QFN48 Package Drawing updated. Note that the package drawing
for QFN48 is correct in datasheet rev A, but wrong in rev B. Added notes to package drawings.
8. Summary: Removed Programming and Debugging chapter, added Processor and Architecture
chapter.
1. JTAG Data Registers subchapter added in the Programming and Debugging chapter,
containing JTAG IDs.
1. Initial revision.
i
32142D–06/2013
ATUC64/128/256L3/4U
Table of Contents
Features ..................................................................................................... 1
1 Description ............................................................................................... 3
2 Overview ................................................................................................... 5
2.1 Block Diagram ...................................................................................................5
2.2 Configuration Summary .....................................................................................6
3 Package and Pinout ................................................................................. 7
3.1 Package .............................................................................................................7
3.2 See Section 3.3 for a description of the various peripheral signals. ................12
3.3 Signal Descriptions ..........................................................................................15
3.4 I/O Line Considerations ...................................................................................18
4 Processor and Architecture .................................................................. 21
4.1 Features ..........................................................................................................21
4.2 AVR32 Architecture .........................................................................................21
4.3 The AVR32UC CPU ........................................................................................22
4.4 Programming Model ........................................................................................26
4.5 Exceptions and Interrupts ................................................................................30
5 Memories ................................................................................................ 35
5.1 Embedded Memories ......................................................................................35
5.2 Physical Memory Map .....................................................................................35
5.3 Peripheral Address Map ..................................................................................36
5.4 CPU Local Bus Mapping .................................................................................37
6 Supply and Startup Considerations ..................................................... 39
6.1 Supply Considerations .....................................................................................39
6.2 Startup Considerations ....................................................................................44
7 Peripheral DMA Controller (PDCA) ...................................................... 45
7.1 Features ..........................................................................................................45
7.2 Overview ..........................................................................................................45
7.3 Block Diagram .................................................................................................46
7.4 Product Dependencies ....................................................................................46
7.5 Functional Description .....................................................................................47
7.6 Performance Monitors .....................................................................................49
7.7 User Interface ..................................................................................................51
ii
32142D–06/2013
ATUC64/128/256L3/4U
7.8 Module Configuration ......................................................................................79
8 USB Interface (USBC) ............................................................................ 81
8.1 Features ..........................................................................................................81
8.2 Overview ..........................................................................................................81
8.3 Block Diagram .................................................................................................81
8.4 I/O Lines Description .......................................................................................83
8.5 Product Dependencies ....................................................................................84
8.6 Functional Description .....................................................................................85
8.7 User Interface ...............................................................................................101
8.8 Module Configuration ....................................................................................134
9 Flash Controller (FLASHCDW) ........................................................... 135
9.1 Features ........................................................................................................135
9.2 Overview ........................................................................................................135
9.3 Product Dependencies ..................................................................................135
9.4 Functional Description ...................................................................................136
9.5 Flash Commands ..........................................................................................141
9.6 General-purpose Fuse Bits ............................................................................143
9.7 Security Bit ....................................................................................................146
9.8 User Interface ................................................................................................147
9.9 Fuse Settings .................................................................................................157
9.10 Serial Number ................................................................................................160
9.11 Module Configuration ....................................................................................160
10 Secure Access Unit (SAU) .................................................................. 162
10.1 Features ........................................................................................................162
10.2 Overview ........................................................................................................162
10.3 Block Diagram ...............................................................................................163
10.4 Product Dependencies ..................................................................................164
10.5 Functional Description ...................................................................................164
10.6 User Interface ................................................................................................168
10.7 Module Configuration ....................................................................................183
11 HSB Bus Matrix (HMATRIXB) .............................................................. 184
11.1 Features ........................................................................................................184
11.2 Overview ........................................................................................................184
11.3 Product Dependencies ..................................................................................184
11.4 Functional Description ...................................................................................184
iii
32142D–06/2013
ATUC64/128/256L3/4U
11.5 User Interface ................................................................................................188
11.6 Module Configuration ....................................................................................196
12 Interrupt Controller (INTC) .................................................................. 198
12.1 Features ........................................................................................................198
12.2 Overview ........................................................................................................198
12.3 Block Diagram ...............................................................................................198
12.4 Product Dependencies ..................................................................................199
12.5 Functional Description ...................................................................................199
12.6 User Interface ................................................................................................202
12.7 Module Configuration ....................................................................................206
12.8 Interrupt Request Signal Map ........................................................................206
13 Power Manager (PM) ............................................................................ 209
13.1 Features ........................................................................................................209
13.2 Overview ........................................................................................................209
13.3 Block Diagram ...............................................................................................210
13.4 I/O Lines Description .....................................................................................210
13.5 Product Dependencies ..................................................................................210
13.6 Functional Description ...................................................................................211
13.7 User Interface ................................................................................................220
13.8 Module Configuration ....................................................................................243
14 System Control Interface (SCIF) ......................................................... 244
14.1 Features ........................................................................................................244
14.2 Overview ........................................................................................................244
14.3 I/O Lines Description .....................................................................................244
14.4 Product Dependencies ..................................................................................244
14.5 Functional Description ...................................................................................245
14.6 User Interface ................................................................................................265
14.7 Module Configuration ....................................................................................318
15 Asynchronous Timer (AST) ................................................................ 322
15.1 Features ........................................................................................................322
15.2 Overview ........................................................................................................322
15.3 Block Diagram ...............................................................................................323
15.4 Product Dependencies ..................................................................................323
15.5 Functional Description ...................................................................................324
15.6 User Interface ................................................................................................330
iv
32142D–06/2013
ATUC64/128/256L3/4U
15.7 Module Configuration ....................................................................................351
16 Watchdog Timer (WDT) ....................................................................... 352
16.1 Features ........................................................................................................352
16.2 Overview ........................................................................................................352
16.3 Block Diagram ...............................................................................................352
16.4 Product Dependencies ..................................................................................352
16.5 Functional Description ...................................................................................353
16.6 User Interface ................................................................................................358
16.7 Module Configuration ....................................................................................364
17 External Interrupt Controller (EIC) ..................................................... 365
17.1 Features ........................................................................................................365
17.2 Overview ........................................................................................................365
17.3 Block Diagram ...............................................................................................365
17.4 I/O Lines Description .....................................................................................366
17.5 Product Dependencies ..................................................................................366
17.6 Functional Description ...................................................................................366
17.7 User Interface ................................................................................................370
17.8 Module Configuration ....................................................................................386
18 Frequency Meter (FREQM) .................................................................. 387
18.1 Features ........................................................................................................387
18.2 Overview ........................................................................................................387
18.3 Block Diagram ...............................................................................................387
18.4 Product Dependencies ..................................................................................387
18.5 Functional Description ...................................................................................388
18.6 User Interface ................................................................................................390
18.7 Module Configuration ....................................................................................401
19 General-Purpose Input/Output Controller (GPIO) ............................. 403
19.1 Features ........................................................................................................403
19.2 Overview ........................................................................................................403
19.3 Block Diagram ...............................................................................................403
19.4 I/O Lines Description .....................................................................................404
19.5 Product Dependencies ..................................................................................404
19.6 Functional Description ...................................................................................405
19.7 User Interface ................................................................................................410
19.8 Module Configuration ....................................................................................433
v
32142D–06/2013
ATUC64/128/256L3/4U
20 Universal Synchronous Asynchronous Receiver Transmitter (USART)
434
20.1 Features ........................................................................................................434
20.2 Overview ........................................................................................................434
20.3 Block Diagram ...............................................................................................435
20.4 I/O Lines Description ....................................................................................436
20.5 Product Dependencies ..................................................................................436
20.6 Functional Description ...................................................................................437
20.7 User Interface ................................................................................................463
20.8 Module Configuration ....................................................................................485
21 Serial Peripheral Interface (SPI) ......................................................... 486
21.1 Features ........................................................................................................486
21.2 Overview ........................................................................................................486
21.3 Block Diagram ...............................................................................................487
21.4 Application Block Diagram .............................................................................487
21.5 I/O Lines Description .....................................................................................488
21.6 Product Dependencies ..................................................................................488
21.7 Functional Description ...................................................................................488
21.8 User Interface ................................................................................................499
21.9 Module Configuration ....................................................................................526
22 Two-wire Master Interface (TWIM) ...................................................... 527
22.1 Features ........................................................................................................527
22.2 Overview ........................................................................................................527
22.3 List of Abbreviations ......................................................................................528
22.4 Block Diagram ...............................................................................................528
22.5 Application Block Diagram .............................................................................529
22.6 I/O Lines Description .....................................................................................529
22.7 Product Dependencies ..................................................................................529
22.8 Functional Description ...................................................................................531
22.9 User Interface ................................................................................................543
22.10 Module Configuration ....................................................................................560
23 Two-wire Slave Interface (TWIS) ......................................................... 561
23.1 Features ........................................................................................................561
23.2 Overview ........................................................................................................561
23.3 List of Abbreviations ......................................................................................562
vi
32142D–06/2013
ATUC64/128/256L3/4U
23.4 Block Diagram ...............................................................................................562
23.5 Application Block Diagram .............................................................................563
23.6 I/O Lines Description .....................................................................................563
23.7 Product Dependencies ..................................................................................563
23.8 Functional Description ...................................................................................564
23.9 User Interface ................................................................................................574
23.10 Module Configuration ....................................................................................590
24 Inter-IC Sound Controller (IISC) .......................................................... 591
24.1 Features ........................................................................................................591
24.2 Overview ........................................................................................................591
24.3 Block Diagram ...............................................................................................592
24.4 I/O Lines Description .....................................................................................592
24.5 Product Dependencies ..................................................................................592
24.6 Functional Description ...................................................................................593
24.7 IISC Application Examples ............................................................................598
24.8 User Interface ................................................................................................600
24.9 Module configuration .....................................................................................614
25 Pulse Width Modulation Controller (PWMA) ..................................... 615
25.1 Features ........................................................................................................615
25.2 Overview ........................................................................................................615
25.3 Block Diagram ...............................................................................................616
25.4 I/O Lines Description .....................................................................................616
25.5 Product Dependencies ..................................................................................616
25.6 Functional Description ...................................................................................617
25.7 User Interface ................................................................................................623
25.8 Module Configuration ....................................................................................641
26 Timer/Counter (TC) .............................................................................. 642
26.1 Features ........................................................................................................642
26.2 Overview ........................................................................................................642
26.3 Block Diagram ...............................................................................................643
26.4 I/O Lines Description .....................................................................................643
26.5 Product Dependencies ..................................................................................643
26.6 Functional Description ...................................................................................644
26.7 User Interface ................................................................................................659
26.8 Module Configuration ....................................................................................682
vii
32142D–06/2013
ATUC64/128/256L3/4U
27 Peripheral Event System ..................................................................... 683
27.1 Features ........................................................................................................683
27.2 Overview ........................................................................................................683
27.3 Peripheral Event System Block Diagram .......................................................683
27.4 Functional Description ...................................................................................683
27.5 Application Example ......................................................................................686
28 Audio Bit Stream DAC (ABDACB) ...................................................... 687
28.1 Features ........................................................................................................687
28.2 Overview ........................................................................................................687
28.3 Block Diagram ...............................................................................................687
28.4 I/O Lines Description .....................................................................................688
28.5 Product Dependencies ..................................................................................688
28.6 Functional Description ...................................................................................689
28.7 User Interface ................................................................................................696
28.8 Module Configuration ....................................................................................710
29 ADC Interface (ADCIFB) ...................................................................... 711
29.1 Features ........................................................................................................711
29.2 Overview ........................................................................................................711
29.3 Block Diagram ...............................................................................................712
29.4 I/O Lines Description .....................................................................................713
29.5 Product Dependencies ..................................................................................713
29.6 Functional Description ...................................................................................714
29.7 Resistive Touch Screen .................................................................................718
29.8 Operating Modes ...........................................................................................724
29.9 User Interface ................................................................................................726
29.10 Module Configuration ....................................................................................745
30 Analog Comparator Interface (ACIFB) ............................................... 746
30.1 Features ........................................................................................................746
30.2 Overview ........................................................................................................746
30.3 Block Diagram ...............................................................................................747
30.4 I/O Lines Description .....................................................................................747
30.5 Product Dependencies ..................................................................................748
30.6 Functional Description ...................................................................................749
30.7 Peripheral Event Triggers ..............................................................................754
30.8 AC Test mode ................................................................................................754
viii
32142D–06/2013
ATUC64/128/256L3/4U
30.9 User Interface ................................................................................................755
30.10 Module Configuration ....................................................................................769
31 Capacitive Touch Module (CAT) ......................................................... 770
31.1 Features ........................................................................................................770
31.2 Overview ........................................................................................................770
31.3 Block Diagram ...............................................................................................771
31.4 I/O Lines Description .....................................................................................771
31.5 Product Dependencies ..................................................................................772
31.6 Functional Description ...................................................................................774
31.7 User Interface ................................................................................................781
31.8 Module Configuration ....................................................................................816
32 Glue Logic Controller (GLOC) ............................................................ 817
32.1 Features ........................................................................................................817
32.2 Overview ........................................................................................................817
32.3 Block Diagram ...............................................................................................817
32.4 I/O Lines Description .....................................................................................818
32.5 Product Dependencies ..................................................................................818
32.6 Functional Description ...................................................................................818
32.7 User Interface ................................................................................................820
32.8 Module Configuration ....................................................................................825
33 aWire UART (AW) ................................................................................. 826
33.1 Features ........................................................................................................826
33.2 Overview ........................................................................................................826
33.3 Block Diagram ...............................................................................................826
33.4 I/O Lines Description .....................................................................................827
33.5 Product Dependencies ..................................................................................827
33.6 Functional Description ...................................................................................827
33.7 User Interface ................................................................................................830
33.8 Module Configuration ....................................................................................843
34 Programming and Debugging ............................................................ 844
34.1 Overview ........................................................................................................844
34.2 Service Access Bus .......................................................................................844
34.3 On-Chip Debug ..............................................................................................847
34.4 JTAG and Boundary-scan (JTAG) .................................................................855
34.5 JTAG Instruction Summary ...........................................................................863
ix
32142D–06/2013
ATUC64/128/256L3/4U
34.6 aWire Debug Interface (AW) .........................................................................880
35 Electrical Characteristics .................................................................... 897
35.1 Absolute Maximum Ratings* .........................................................................897
35.2 Supply Characteristics ...................................................................................897
35.3 Maximum Clock Frequencies ........................................................................898
35.4 Power Consumption ......................................................................................898
35.5 I/O Pin Characteristics ...................................................................................902
35.6 Oscillator Characteristics ...............................................................................905
35.7 Flash Characteristics .....................................................................................910
35.8 ABDACB Electrical Characteristics. .............................................................911
35.9 Analog Characteristics ...................................................................................912
35.10 Timing Characteristics ...................................................................................921
36 Mechanical Characteristics ................................................................. 931
36.1 Thermal Considerations ................................................................................931
36.2 Package Drawings .........................................................................................932
36.3 Soldering Profile ............................................................................................937
37 Ordering Information ........................................................................... 938
38 Errata ..................................................................................................... 940
38.1 Rev. C ............................................................................................................940
38.2 Flash ..............................................................................................................942
38.3 Rev. B ............................................................................................................942
38.4 Flash .............................................................................................................946
38.5 Rev. A ............................................................................................................946
39 Datasheet Revision History ................................................................ 953
39.1 Rev. D – 06/2013 ...........................................................................................953
39.2 Rev. C – 01/2012 ...........................................................................................953
39.3 Rev. B – 12/2011 ...........................................................................................953
39.4 Rev. A – 12/2011 ...........................................................................................953
Table of Contents....................................................................................... i
Atmel Corporation
1600 Technology Drive
San Jose, CA 95110
USA
Tel: (+1) (408) 441-0311
Fax: (+1) (408) 487-2600
www.atmel.com
Atmel Asia Limited
Unit 01-5 & 16, 19F
BEA Tower, Millennium City 5
418 Kwun Tong Roa
Kwun Tong, Kowloon
HONG KONG
Tel: (+852) 2245-6100
Fax: (+852) 2722-1369
Atmel Munich GmbH
Business Campus
Parkring 4
D-85748 Garching b. Munich
GERMANY
Tel: (+49) 89-31970-0
Fax: (+49) 89-3194621
Atmel Japan G.K.
16F Shin-Osaki Kangyo Bldg
1-6-4 Osaki, Shinagawa-ku
Tokyo 141-0032
JAPAN
Tel: (+81) (3) 6417-0300
Fax: (+81) (3) 6417-0370
© 2013 Atmel Corporation. All rights reserved. / Rev.: 32142D–AVR32–06/2013
Atmel®, logo and combinations thereof, AVR®, picoPower®, QTouch®, AKS® and others are registered trademarks or trademarks of Atmel Corporation
or its subsidiaries. Other terms and product names may be trademarks of others.
Disclaimer: The information in this document is provided in connection with Atmel products. No license, express or implied, by estoppel or otherwise, to any intellectual property right is granted by this
document or in connection with the sale of Atmel products. EXCEPT AS SET FORTH IN THE ATMEL TERMS AND CONDITIONS OF SALES LOCATED ON THE ATMEL WEBSITE, ATMEL ASSUMES
NO LIABILITY WHATSOEVER AND DISCLAIMS ANY EXPRESS, IMPLIED OR STATUTORY WARRANTY RELATING TO ITS PRODUCTS INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
CONSEQUENTIAL, PUNITIVE, SPECIAL OR INCIDENTAL DAMAGES (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS AND PROFITS, BUSINESS INTERRUPTION, OR LOSS OF
INFORMATION) ARISING OUT OF THE USE OR INABILITY TO USE THIS DOCUMENT, EVEN IF ATMEL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. Atmel makes no
representations or warranties with respect to the accuracy or completeness of the contents of this document and reserves the right to make changes to specifications and products descriptions at any time
without notice. Atmel does not make any commitment to update the information contained herein. Unless specifically provided otherwise, Atmel products are not suitable for, and shall not be used in,
automotive applications. Atmel products are not intended, authorized, or warranted for use as components in applications intended to support or sustain life.
2015 Microchip Technology Inc. DS00001625B-page 1
General Description
The CAP1133, which incorporates RightTouch® technology,
is a multiple channel Capacitive Touch sensor
with multiple power LED drivers. It contains three (3)
individual capacitive touch sensor inputs with programmable
sensitivity for use in touch sensor applications.
Each sensor input automatically recalibrates to compensate
for gradual environmental changes.
The CAP1133 also contains three (3) LED drivers that
offer full-on / off, variable rate blinking, dimness controls,
and breathing. Each of the LED drivers may be
linked to one of the sensor inputs to be actuated when
a touch is detected. As well, each LED driver may be
individually controlled via a host controller.
The CAP1133 includes Multiple Pattern Touch recognition
that allows the user to select a specific set of buttons
to be touched simultaneously. If this pattern is
detected, then a status bit is set and an interrupt generated.
Additionally, the CAP1133 includes circuitry and support
for enhanced sensor proximity detection.
The CAP1133 offers multiple power states operating at
low quiescent currents. In the Standby state of operation,
one or more capacitive touch sensor inputs are
active and all LEDs may be used.
Deep Sleep is the lowest power state available, drawing
5uA (typical) of current. In this state, no sensor
inputs are active. Communications will wake the
device.
Applications
• Desktop and Notebook PCs
• LCD Monitors
• Consumer Electronics
• Appliances
Features
• Three (3) Capacitive Touch Sensor Inputs
- Programmable sensitivity
- Automatic recalibration
- Individual thresholds for each button
• Proximity Detection
• Multiple Button Pattern Detection
• Calibrates for Parasitic Capacitance
• Analog Filtering for System Noise Sources
• Press and Hold feature for Volume-like Applications
• SMBus / I2C Compliant Communication Interface
• Low Power Operation
- 5uA quiescent current in Deep Sleep
- 50uA quiescent current in Standby (1 sensor
input monitored)
- Samples one or more channels in Standby
• Three (3) LED Driver Outputs
- Open Drain or Push-Pull
- Programmable blink, breathe, and dimness
controls
- Can be linked to Capacitive Touch Sensor
inputs
• Available in 10-pin 3mm x 3mm RoHS compliant
DFN package
CAP1133
3 Channel Capacitive Touch Sensor with 3 LED Drivers
CAP1133
DS00001625B-page 2 2015 Microchip Technology Inc.
TO OUR VALUED CUSTOMERS
It is our intention to provide our valued customers with the best documentation possible to ensure successful use of your Microchip
products. To this end, we will continue to improve our publications to better suit your needs. Our publications will be refined and
enhanced as new volumes and updates are introduced.
If you have any questions or comments regarding this publication, please contact the Marketing Communications Department via
E-mail at docerrors@microchip.com. We welcome your feedback.
Most Current Data Sheet
To obtain the most up-to-date version of this data sheet, please register at our Worldwide Web site at:
http://www.microchip.com
You can determine the version of a data sheet by examining its literature number found on the bottom outside corner of any page.
The last character of the literature number is the version number, (e.g., DS30000000A is version A of document DS30000000).
Errata
An errata sheet, describing minor operational differences from the data sheet and recommended workarounds, may exist for current
devices. As device/documentation issues become known to us, we will publish an errata sheet. The errata will specify the
revision of silicon and revision of document to which it applies.
To determine if an errata sheet exists for a particular device, please check with one of the following:
• Microchip’s Worldwide Web site; http://www.microchip.com
• Your local Microchip sales office (see last page)
When contacting a sales office, please specify which device, revision of silicon and data sheet (include -literature number) you are
using.
Customer Notification System
Register on our web site at www.microchip.com to receive the most current information on all of our products.
2015 Microchip Technology Inc. DS00001625B-page 3
CAP1133
Table of Contents
1.0 Block Diagram ................................................................................................................................................................................. 4
2.0 Pin Description ................................................................................................................................................................................ 5
3.0 Electrical Specifications .................................................................................................................................................................. 9
4.0 Communications ........................................................................................................................................................................... 12
5.0 General Description ...................................................................................................................................................................... 23
6.0 Register Description ...................................................................................................................................................................... 29
7.0 Package Information ..................................................................................................................................................................... 67
Appendix A: Device Delta ................................................................................................................................................................... 72
Appendix B: Data Sheet Revision History ........................................................................................................................................... 74
The Microchip Web Site ...................................................................................................................................................................... 76
Customer Change Notification Service ............................................................................................................................................... 76
Customer Support ............................................................................................................................................................................... 76
Product Identification System ............................................................................................................................................................. 77
CAP1133
DS00001625B-page 4 2015 Microchip Technology Inc.
1.0 BLOCK DIAGRAM
SMBus
Slave
Protocol
SMCLK
SMDATA
VDD GND
ALERT#
Capacitive Touch Sensing
Algorithm
CS1 CS2 CS3
LED1
LED Driver, Breathe, and
Dimness control
LED2 LED3
2015 Microchip Technology Inc. DS00001625B-page 5
CAP1133
2.0 PIN DESCRIPTION
FIGURE 2-1: CAP1133 Pin Diagram (10-Pin DFN)
TABLE 2-1: PIN DESCRIPTION FOR CAP1133
Pin
Number Pin Name Pin Function Pin Type Unused
Connection
1 ALERT#
Active low alert / interrupt output usable for SMBus alert OD (5V) Connect to
Ground
Active high alert / interrupt output usable for SMBus alert DO leave open
2 SMDATA Bi-directional, open-drain SMBus data - requires pull-up DIOD (5V)
n/a
3 SMCLK SMBus clock input - requires pull-up resistor DI (5V)
4 VDD Positive Power supply Power n/a
5 LED1
Open drain LED 1 driver (default) OD (5V) Connect to
Ground
Push-pull LED 1 driver DO leave open or
connect to Ground
6 LED2
Open drain LED 2 driver (default) OD (5V) Connect to
Ground
Push-pull LED 2 driver DO leave open or
connect to Ground
7 LED3
Open drain LED 3 driver (default) OD (5V) Connect to
Ground
Push-pull LED 3 driver DO leave open or
connect to Ground
GND
CS2
1 CS1
2
3
4
5
CS3
LED1
ALERT#
SMDATA
VDD
SMCLK
LED3
LED2
CAP1133
3mm x 3mm DFN
10
9
8
7
6
CAP1133
DS00001625B-page 6 2015 Microchip Technology Inc.
APPLICATION NOTE: When the ALERT# pinis configured as an active low output, it will be open drain. When it is
configured as an active high output, it will be push-pull.
APPLICATION NOTE: For the 5V tolerant pins that have a pull-up resistor, the pull-up voltage must not exceed 3.6V
when the CAP1133 is unpowered.
The pin types are described in Table 2-2. All pins labeled with (5V) are 5V tolerant.
8 CS3 Capacitive Touch Sensor Input 3 AIO Connect to
Ground
9 CS2 Capacitive Touch Sensor Input 2 AIO Connect to
Ground
10 CS1 Capacitive Touch Sensor Input 1 AIO Connect to
Ground
Bottom
Pad GND Ground Power n/a
TABLE 2-2: PIN TYPES
Pin Type Description
Power This pin is used to supply power or ground to the device.
DI Digital Input - This pin is used as a digital input. This pin is 5V tolerant.
AIO Analog Input / Output -This pin is used as an I/O for analog signals.
DIOD Digital Input / Open Drain Output - This pin is used as a digital I/O. When it is used as an output,
it is open drain and requires a pull-up resistor. This pin is 5V tolerant.
OD Open Drain Digital Output - This pin is used as a digital output. It is open drain and requires a
pull-up resistor. This pin is 5V tolerant.
DO Push-pull Digital Output - This pin is used as a digital output and can sink and source current.
DIO Push-pull Digital Input / Output - This pin is used as an I/O for digital signals.
TABLE 2-1: PIN DESCRIPTION FOR CAP1133 (CONTINUED)
Pin
Number Pin Name Pin Function Pin Type Unused
Connection
2015 Microchip Technology Inc. DS00001625B-page 7
CAP1133
3.0 ELECTRICAL SPECIFICATIONS
Note 3-1 Stresses above those listed could cause permanent damage to the device. This is a stress rating
only and functional operation of the device at any other condition above those indicated in the
operation sections of this specification is not implied.
Note 3-2 For the 5V tolerant pins that have a pull-up resistor, the voltage difference between V5VT_PIN and VDD
must never exceed 3.6V.
Note 3-3 The Package Power Dissipation specification assumes a recommended thermal via design consisting
of a 2x2 matrix of 0.3mm (12mil) vias at 1.0mm pitch connected to the ground plane with a 1.6 x
2.3mm thermal landing.
TABLE 3-1: ABSOLUTE MAXIMUM RATINGS
Voltage on 5V tolerant pins (V5VT_PIN) -0.3 to 5.5 V
Voltage on 5V tolerant pins (|V5VT_PIN - VDD|) Note 3-2 0 to 3.6 V
Voltage on VDD pin -0.3 to 4 V
Voltage on any other pin to GND -0.3 to VDD + 0.3 V
Package Power Dissipation up to TA = 85°C for 10 pin DFN
(see Note 3-3)
0.7 W
Junction to Ambient (θJA) 77.7 °C/W
Operating Ambient Temperature Range -40 to 125 °C
Storage Temperature Range -55 to 150 °C
ESD Rating, All Pins, HBM 8000 V
CAP1133
DS00001625B-page 8 2015 Microchip Technology Inc.
TABLE 3-2: ELECTRICAL SPECIFICATIONS
VDD = 3V to 3.6V, TA = 0°C to 85°C, all typical values at TA = 27°C unless otherwise noted.
Characteristic Symbol Min Typ Max Unit Conditions
DC Power
Supply Voltage VDD 3.0 3.3 3.6 V
Supply Current
ISTBY 120 170 uA
Standby state active
1 sensor input monitored
No LEDs active
Default conditions (8 avg, 70ms
cycle time)
ISTBY 50 uA
Standby state active
1 sensor input monitored
No LEDs active
1 avg, 140ms cycle time,
IDSLEEP 5 15 uA
Deep Sleep state active
LEDs at 100% or 0% Duty Cycle
No communications
TA < 40°C
3.135 < VDD < 3.465V
IDD 500 600 uA Capacitive Sensing Active
No LEDs active
Capacitive Touch Sensor Inputs
Maximum Base
Capacitance CBASE 50 pF Pad untouched
Minimum Detectable
Capacitive Shift ΔCTOUCH 20 fF
Pad touched - default conditions (1
avg, 35ms cycle time, 1x sensitivity)
Recommended Cap
Shift ΔCTOUCH 0.1 2 pF Pad touched - Not tested
Power Supply Rejection
PSR ±3 ±10 counts /
V
Untouched Current Counts
Base Capacitance 5pF - 50pF
Maximum sensitivity
Negative Delta Counts disabled
All other parameters default
Timing
Time to communications
ready tCOMM_DLY 15 ms
Time to first conversion
ready tCONV_DLY 170 200 ms
LED Drivers
Duty Cycle DUTYLED 0 100 % Programmable
Drive Frequency fLED 2 kHz
Sinking Current ISINK 24 mA VOL = 0.4
Sourcing Current ISOURCE 24 mA VOH = VDD - 0.4
Leakage Current ILEAK ±5 uA
powered or unpowered
TA < 85°C
pull-up voltage < 3.6V if unpowered
I/O Pins
Output Low Voltage VOL 0.4 V ISINK_IO = 8mA
Output High Voltage VOH VDD - 0.4 V ISOURCE_IO = 8mA
Input High Voltage VIH 2.0 V
2015 Microchip Technology Inc. DS00001625B-page 9
CAP1133
Note 3-4 The ALERT pin will not glitch high or low at power up if connected to VDD or another voltage.
Note 3-5 The SMCLK and SMDATA pins will not glitch low at power up if connected to VDD or another voltage.
Input Low Voltage VIL 0.8 V
Leakage Current ILEAK ±5 uA
powered or unpowered
TA < 85°C
pull-up voltage < 3.6V if unpowered
SMBus Timing
Input Capacitance CIN 5 pF
Clock Frequency fSMB 10 400 kHz
Spike Suppression tSP 50 ns
Bus Free Time Stop to
Start tBUF 1.3 us
Start Setup Time tSU:STA 0.6 us
Start Hold Time tHD:STA 0.6 us
Stop Setup Time tSU:STO 0.6 us
Data Hold Time tHD:DAT 0 us When transmitting to the master
Data Hold Time tHD:DAT 0.3 us When receiving from the master
Data Setup Time tSU:DAT 0.6 us
Clock Low Period tLOW 1.3 us
Clock High Period tHIGH 0.6 us
Clock / Data Fall Time tFALL 300 ns Min = 20+0.1CLOAD ns
Clock / Data Rise
Time tRISE 300 ns Min = 20+0.1CLOAD ns
Capacitive Load CLOAD 400 pF per bus line
TABLE 3-2: ELECTRICAL SPECIFICATIONS (CONTINUED)
VDD = 3V to 3.6V, TA = 0°C to 85°C, all typical values at TA = 27°C unless otherwise noted.
Characteristic Symbol Min Typ Max Unit Conditions
CAP1133
DS00001625B-page 10 2015 Microchip Technology Inc.
4.0 COMMUNICATIONS
4.1 Communications
The CAP1133 communicates using the SMBus or I2C protocol.
The supports the following protocols: Send Byte, Receive Byte, Read Byte, Write Byte, Read Block, and Write Block.
In addition, the device supports I2C formatting for block read and block write protocols.
4.2 System Management Bus
The CAP1133 communicates with a host controller, such as an SIO, through the SMBus. The SMBus is a two-wire serial
communication protocol between a computer host and its peripheral devices. A detailed timing diagram is shown in
Figure 4-1. Stretching of the SMCLK signal is supported; however, the CAP1133 will not stretch the clock signal.
4.2.1 SMBUS START BIT
The SMBus Start bit is defined as a transition of the SMBus Data line from a logic ‘1’ state to a logic ‘0’ state while the
SMBus Clock line is in a logic ‘1’ state.
4.2.2 SMBUS ADDRESS AND RD / WR BIT
The SMBus Address Byte consists of the 7-bit slave address followed by the RD / WR indicator bit. If this RD / WR bit
is a logic ‘0’, then the SMBus Host is writing data to the slave device. If this RD / WR bit is a logic ‘1’, then the SMBus
Host is reading data from the slave device.
The CAP1133 responds to SMBus address 0101_000(r/w).
4.2.3 SMBUS DATA BYTES
All SMBus Data bytes are sent most significant bit first and composed of 8-bits of information.
4.2.4 SMBUS ACK AND NACK BITS
The SMBus slave will acknowledge all data bytes that it receives. This is done by the slave device pulling the SMBus
Data line low after the 8th bit of each byte that is transmitted. This applies to both the Write Byte and Block Write protocols.
The Host will NACK (not acknowledge) the last data byte to be received from the slave by holding the SMBus data line
high after the 8th data bit has been sent. For the Block Read protocol, the Host will ACK each data byte that it receives
except the last data byte.
FIGURE 4-1: SMBus Timing Diagram
SMDATA
SMCLK
TLOW
TRISE
THIGH
TFALL
TBUF
THD:STA
P S S - Start Condition P - Stop Condition
THD:DAT TSU:DAT TSU:STA
THD:STA
P
TSU:STO
S
2015 Microchip Technology Inc. DS00001625B-page 11
CAP1133
4.2.5 SMBUS STOP BIT
The SMBus Stop bit is defined as a transition of the SMBus Data line from a logic ‘0’ state to a logic ‘1’ state while the
SMBus clock line is in a logic ‘1’ state. When the CAP1133 detects an SMBus Stop bit and it has been communicating
with the SMBus protocol, it will reset its slave interface and prepare to receive further communications.
4.2.6 SMBUS TIMEOUT
The CAP1133 includes an SMBus timeout feature. Following a 30ms period of inactivity on the SMBus where the
SMCLK pin is held low, the device will timeout and reset the SMBus interface.
The timeout function defaults to disabled. It can be enabled by setting the TIMEOUT bit in the Configuration register
(see Section 6.6, "Configuration Registers").
4.2.7 SMBUS AND I2C COMPATIBILITY
The major differences between SMBus and I2C devices are highlighted here. For more information, refer to the SMBus
2.0 and I2C specifications. For information on using the CAP1133 in an I2C system, refer to AN 14.0 Dedicated Slave
Devices in I2C Systems.
1. CAP1133 supports I2C fast mode at 400kHz. This covers the SMBus max time of 100kHz.
2. Minimum frequency for SMBus communications is 10kHz.
3. The SMBus slave protocol will reset if the clock is held at a logic ‘0’ for longer than 30ms. This timeout functionality
is disabled by default in the CAP1133 and can be enabled by writing to the TIMEOUT bit. I2C does not have
a timeout.
4. The SMBus slave protocol will reset if both the clock and data lines are held at a logic ‘1’ for longer than 200µs
(idle condition). This function is disabled by default in the CAP1133 and can be enabled by writing to the TIMEOUT
bit. I2C does not have an idle condition.
5. I2C devices do not support the Alert Response Address functionality (which is optional for SMBus).
6. I2C devices support block read and write differently. I2C protocol allows for unlimited number of bytes to be sent
in either direction. The SMBus protocol requires that an additional data byte indicating number of bytes to read /
write is transmitted. The CAP1133 supports I2C formatting only.
4.3 SMBus Protocols
The CAP1133 is SMBus 2.0 compatible and supports Write Byte, Read Byte, Send Byte, and Receive Byte as valid
protocols as shown below.
All of the below protocols use the convention in Table 4-1.
4.3.1 SMBUS WRITE BYTE
The Write Byte is used to write one byte of data to a specific register as shown in Table 4-2.
4.3.2 SMBUS READ BYTE
The Read Byte protocol is used to read one byte of data from the registers as shown in Table 4-3.
TABLE 4-1: PROTOCOL FORMAT
Data Sent to
Device
Data Sent to the
HOst
Data sent Data sent
TABLE 4-2: WRITE BYTE PROTOCOL
Start Slave
Address WR ACK Register
Address ACK Register Data ACK Stop
1 ->0 0101_000 0 0 XXh 0 XXh 0 0 -> 1
CAP1133
DS00001625B-page 12 2015 Microchip Technology Inc.
4.3.3 SMBUS SEND BYTE
The Send Byte protocol is used to set the internal address register pointer to the correct address location. No data is
transferred during the Send Byte protocol as shown in Table 4-4.
APPLICATION NOTE: The Send Byte protocol is not functional in Deep Sleep (i.e., DSLEEP bit is set).
4.3.4 SMBUS RECEIVE BYTE
The Receive Byte protocol is used to read data from a register when the internal register address pointer is known to
be at the right location (e.g., set via Send Byte). This is used for consecutive reads of the same register as shown in
Table 4-5.
APPLICATION NOTE: The Receive Byte protocol is not functional in Deep Sleep (i.e., DSLEEP bit is set).
4.4 I2C Protocols
The CAP1133 supports I2C Block Write and Block Read.
The protocols listed below use the convention in Table 4-1.
4.4.1 BLOCK WRITE
The Block Write is used to write multiple data bytes to a group of contiguous registers as shown in Table 4-6.
APPLICATION NOTE: When using the Block Write protocol, the internal address pointer will be automatically
incremented after every data byte is received. It will wrap from FFh to 00h.
4.4.2 BLOCK READ
The Block Read is used to read multiple data bytes from a group of contiguous registers as shown in Table 4-7.
APPLICATION NOTE: When using the Block Read protocol, the internal address pointer will be automatically
incremented after every data byte is received. It will wrap from FFh to 00h.
TABLE 4-3: READ BYTE PROTOCOL
Start Slave
Address WR ACK Register
Address ACK Start Slave
Address RD ACK Register
Data NACK Stop
1->0 0101_000 0 0 XXh 0 1 ->0 0101_000 1 0 XXh 1 0 -> 1
TABLE 4-4: SEND BYTE PROTOCOL
Start Slave Address WR ACK Register Address ACK Stop
1 -> 0 0101_000 0 0 XXh 0 0 -> 1
TABLE 4-5: RECEIVE BYTE PROTOCOL
Start Slave Address RD ACK Register Data NACK Stop
1 -> 0 0101_000 1 0 XXh 1 0 -> 1
TABLE 4-6: BLOCK WRITE PROTOCOL
Start Slave
Address WR ACK Register
Address ACK Register Data ACK
1 ->0 0101_000 0 0 XXh 0 XXh 0
Register Data ACK Register
Data
ACK . . . Register
Data
ACK Stop
XXh 0 XXh 0 . . . XXh 0 0 -> 1
2015 Microchip Technology Inc. DS00001625B-page 13
CAP1133
TABLE 4-7: BLOCK READ PROTOCOL
Start Slave
Address WR ACK Register
Address ACK Start Slave
Address RD ACK Register
Data
1->0 0101_000 0 0 XXh 0 1 ->0 0101_000 1 0 XXh
ACK Register
Data
ACK Register
Data
ACK Register
Data
ACK . . . Register
Data
NACK Stop
0 XXh 0 XXh 0 XXh 0 . . . XXh 1 0 -> 1
CAP1133
DS00001625B-page 14 2015 Microchip Technology Inc.
5.0 GENERAL DESCRIPTION
The CAP1133 is a multiple channel Capacitive Touch sensor with multiple power LED drivers. It contains three (3) individual
capacitive touch sensor inputs with programmable sensitivity for use in touch sensor applications. Each sensor
input automatically recalibrates to compensate for gradual environmental changes.
The CAP1133 also contains three (3) low side (or push-pull) LED drivers that offer full-on / off, variable rate blinking,
dimness controls, and breathing. Each of the LED drivers may be linked to one of the sensor inputs to be actuated when
a touch is detected. As well, each LED driver may be individually controlled via a host controller.
The CAP1133 offers multiple power states. It operates at the lowest quiescent current during its Deep Sleep state. In
the low power Standby state, it can monitor one or more channels and respond to communications normally.
The device communicates with a host controller using SMBus / I2C. The host controller may poll the device for updated
information at any time or it may configure the device to flag an interrupt whenever a touch is detected on any sensor
pad.
A typical system diagram is shown in Figure 5-1.
5.1 Power States
The CAP1133 has three operating states depending on the status of the STBY and DSLEEP bits. When the device transitions
between power states, previously detected touches (for inactive channels) are cleared and the status bits reset.
1. Fully Active - The device is fully active. It is monitoring all active capacitive sensor inputs and driving all LED channels
as defined.
2. Standby - The device is in a lower power state. It will measure a programmable number of channels using the
Standby Configuration controls (see Section 6.20 through Section 6.22). Interrupts will still be generated based
on the active channels. The device will still respond to communications normally and can be returned to the Fully
Active state of operation by clearing the STBY bit.
FIGURE 5-1: System Diagram for CAP1133
CAP1133
LED3
SMDATA
SMCLK
Embedded Controller
VDD
ALERT#
LED2
LED1
CS3
CS2
CS1
Touch
Button
Touch
Button
Touch
Button
3.3V – 5V
2015 Microchip Technology Inc. DS00001625B-page 15
CAP1133
3. Deep Sleep - The device is in its lowest power state. It is not monitoring any capacitive sensor inputs and not
driving any LEDs. All LEDs will be driven to their programmed non-actuated state and no PWM operations will
be done. While in Deep Sleep, the device can be awakened by SMBus communications targeting the device.
This will not cause the DSLEEP to be cleared so the device will return to Deep Sleep once all communications
have stopped.
APPLICATION NOTE: In the Deep Sleep state, the LED output will be either high or low and will not be PWM’d at
the min or max duty cycle.
5.2 LED Drivers
The CAP1133 contains three (3) LED drivers. Each LED driver can be linked to its respective capacitive touch sensor
input or it can be controlled by the host. Each LED driver can be configured to operate in one of the following modes
with either push-pull or open drain drive.
1. Direct - The LED is configured to be on or off when the corresponding input stimulus is on or off (or inverted). The
brightness of the LED can be programmed from full off to full on (default). Additionally, the LED contains controls
to individually configure ramping on, off, and turn-off delay.
2. Pulse 1 - The LED is configured to “Pulse” (transition ON-OFF-ON) a programmable number of times with programmable
rate and min / max brightness. This behavior may be actuated when a press is detected or when a
release is detected.
3. Pulse 2 - The LED is configured to “Pulse” while actuated and then “Pulse” a programmable number of times with
programmable rate and min / max brightness when the sensor pad is released.
4. Breathe - The LED is configured to transition continuously ON-OFF-ON (i.e. to “Breathe”) with a programmable
rate and min / max brightness.
When an LED is not linked to a sensor and is actuated by the host, there’s an option to assert the ALERT# pin when
the initiated LED behavior has completed.
5.2.1 LINKING LEDS TO CAPACITIVE TOUCH SENSOR INPUTS
All LEDs can be linked to the corresponding capacitive touch sensor input so that when the sensor input detects a touch,
the corresponding LED will be actuated at one of the programmed responses.
5.3 Capacitive Touch Sensing
The CAP1133 contains three (3) independent capacitive touch sensor inputs. Each sensor input has dynamic range to
detect a change of capacitance due to a touch. Additionally, each sensor input can be configured to be automatically
and routinely re-calibrated.
5.3.1 SENSING CYCLE
Each capacitive touch sensor input has controls to be activated and included in the sensing cycle. When the device is
active, it automatically initiates a sensing cycle and repeats the cycle every time it finishes. The cycle polls through each
active sensor input starting with CS1 and extending through CS3. As each capacitive touch sensor input is polled, its
measurement is compared against a baseline “Not Touched” measurement. If the delta measurement is large enough,
a touch is detected and an interrupt is generated.
The sensing cycle time is programmable (see Section 6.10, "Averaging and Sampling Configuration Register").
5.3.2 RECALIBRATING SENSOR INPUTS
There are various options for recalibrating the capacitive touch sensor inputs. Recalibration re-sets the Base Count Registers
(Section 6.24, "Sensor Input Base Count Registers") which contain the “not touched” values used for touch detection
comparisons.
APPLICATION NOTE: The device will recalibrate all sensor inputs that were disabled when it transitions from
Standby. Likewise, the device will recalibrate all sensor inputs when waking out of Deep
Sleep.
CAP1133
DS00001625B-page 16 2015 Microchip Technology Inc.
5.3.2.1 Manual Recalibration
The Calibration Activate Registers (Section 6.11, "Calibration Activate Register") force recalibration of selected sensor
inputs. When a bit is set, the corresponding capacitive touch sensor input will be recalibrated (both analog and digital).
The bit is automatically cleared once the recalibration routine has finished.
5.3.2.2 Automatic Recalibration
Each sensor input is regularly recalibrated at a programmable rate (see Section 6.17, "Recalibration Configuration Register").
By default, the recalibration routine stores the average 64 previous measurements and periodically updates the
base “not touched” setting for the capacitive touch sensor input.
5.3.2.3 Negative Delta Count Recalibration
It is possible that the device loses sensitivity to a touch. This may happen as a result of a noisy environment, an accidental
recalibration during a touch, or other environmental changes. When this occurs, the base untouched sensor input
may generate negative delta count values. The NEG_DELTA_CNT bits (see Section 6.17, "Recalibration Configuration
Register") can be set to force a recalibration after a specified number of consecutive negative delta readings.
5.3.2.4 Delayed Recalibration
It is possible that a “stuck button” occurs when something is placed on a button which causes a touch to be detected
for a long period. By setting the MAX_DUR_EN bit (see Section 6.6, "Configuration Registers"), a recalibration can be
forced when a touch is held on a button for longer than the duration specified in the MAX_DUR bits (see Section 6.8,
"Sensor Input Configuration Register").
5.3.3 PROXIMITY DETECTION
Each sensor input can be configured to detect changes in capacitance due to proximity of a touch. This circuitry detects
the change of capacitance that is generated as an object approaches, but does not physically touch, the enabled sensor
pad(s). When a sensor input is selected to perform proximity detection, it will be sampled from 1x to 128x per sampling
cycle. The larger the number of samples that are taken, the greater the range of proximity detection is available at the
cost of an increased overall sampling time.
5.3.4 MULTIPLE TOUCH PATTERN DETECTION
The multiple touch pattern (MTP) detection circuitry can be used to detect lid closure or other similar events. An event
can be flagged based on either a minimum number of sensor inputs or on specific sensor inputs simultaneously exceeding
an MTP threshold or having their Noise Flag Status Register bits set. An interrupt can also be generated. During an
MTP event, all touches are blocked (see Section 6.15, "Multiple Touch Pattern Configuration Register").
5.3.5 LOW FREQUENCY NOISE DETECTION
Each sensor input has an EMI noise detector that will sense if low frequency noise is injected onto the input with sufficient
power to corrupt the readings. If this occurs, the device will reject the corrupted sample and set the corresponding
bit in the Noise Status register to a logic ‘1’.
Note: During this recalibration routine, the sensor inputs will not detect a press for up to 200ms and the Sensor
Base Count Register values will be invalid. In addition, any press on the corresponding sensor pads will
invalidate the recalibration.
Note: Automatic recalibration only works when the delta count is below the active sensor input threshold. It is disabled
when a touch is detected.
Note: During this recalibration, the device will not respond to touches.
Note: Delayed recalibration only works when the delta count is above the active sensor input threshold. If
enabled, it is invoked when a sensor pad touch is held longer than the MAX_DUR bit setting.
2015 Microchip Technology Inc. DS00001625B-page 17
CAP1133
5.3.6 RF NOISE DETECTION
Each sensor input contains an integrated RF noise detector. This block will detect injected RF noise on the CS pin. The
detector threshold is dependent upon the noise frequency. If RF noise is detected on a CS line, that sample is removed
and not compared against the threshold.
5.4 ALERT# Pin
The ALERT# pin is an active low (or active high when configured) output that is driven when an interrupt event is
detected.
Whenever an interrupt is generated, the INT bit (see Section 6.1, "Main Control Register") is set. The ALERT# pin is
cleared when the INT bit is cleared by the user. Additionally, when the INT bit is cleared by the user, status bits are only
cleared if no touch is detected.
5.4.1 SENSOR INTERRUPT BEHAVIOR
The sensor interrupts are generated in one of two ways:
1. An interrupt is generated when a touch is detected and, as a user selectable option, when a release is detected
(by default - see Section 6.6). See Figure 5-3.
2. If the repeat rate is enabled then, so long as the touch is held, another interrupt will be generated based on the
programmed repeat rate (see Figure 5-2).
When the repeat rate is enabled, the device uses an additional control called MPRESS that determines whether a touch
is flagged as a simple “touch” or a “press and hold”. The MPRESS[3:0] bits set a minimum press timer. When the button
is touched, the timer begins. If the sensor pad is released before the minimum press timer expires, it is flagged as a
touch and an interrupt is generated upon release. If the sensor input detects a touch for longer than this timer value, it
is flagged as a “press and hold” event. So long as the touch is held, interrupts will be generated at the programmed
repeat rate and upon release (if enabled).
APPLICATION NOTE: Figure 5-2 and Figure 5-3 show default operation which is to generate an interrupt upon
sensor pad release and an active-low ALERT# pin.
APPLICATION NOTE: The host may need to poll the device twice to determine that a release has been detected.
FIGURE 5-2: Sensor Interrupt Behavior - Repeat Rate Enabled
Touch Detected
INT bit
Button Status
Write to INT bit
Polling Cycle
(35ms)
Min Press Setting
(280ms)
Interrupt on
Touch
Button Repeat Rate
(175ms)
Button Repeat Rate
(175ms)
Interrupt on
Release
(optional)
ALERT# pin
(active low)
CAP1133
DS00001625B-page 18 2015 Microchip Technology Inc.
FIGURE 5-3: Sensor Interrupt Behavior - No Repeat Rate Enabled
Touch Detected
INT bit
Button Status
Write to INT bit
Polling Cycle
(35ms) Interrupt on
Touch Interrupt on
Release
(optional)
ALERT# pin
(active low)
2015 Microchip Technology Inc. DS00001625B-page 19
CAP1133
6.0 REGISTER DESCRIPTION
The registers shown in Table 6-1 are accessible through the communications protocol. An entry of ‘-’ indicates that the
bit is not used and will always read ‘0’.
TABLE 6-1: REGISTER SET IN HEXADECIMAL ORDER
Register
Address R/W Register Name Function Default Value Page
00h R/W Main Control Controls general power states and
power dissipation 00h Page 21
02h R General Status Stores general status bits 00h Page 22
03h R Sensor Input Status Returns the state of the sampled
capacitive touch sensor inputs 00h Page 22
04h R LED Status Stores status bits for LEDs 00h Page 22
0Ah R Noise Flag Status Stores the noise flags for sensor inputs 00h Page 23
10h R Sensor Input 1 Delta
Count Stores the delta count for CS1 00h Page 23
11h R Sensor Input 2 Delta
Count Stores the delta count for CS2 00h Page 23
12h R Sensor Input 3 Delta
Count Stores the delta count for CS3 00h Page 23
1Fh R/W Sensitivity Control
Controls the sensitivity of the threshold
and delta counts and data scaling of
the base counts
2Fh Page 24
20h R/W Configuration Controls general functionality 20h Page 25
21h R/W Sensor Input Enable Controls whether the capacitive touch
sensor inputs are sampled 07h Page 26
22h R/W Sensor Input Configuration
Controls max duration and auto-repeat
delay for sensor inputs operating in the
full power state
A4h Page 27
23h R/W Sensor Input Configuration
2
Controls the MPRESS controls for all
sensor inputs 07h Page 28
24h R/W Averaging and Sampling
Config
Controls averaging and sampling window
39h Page 28
26h R/W Calibration Activate Forces re-calibration for capacitive
touch sensor inputs 00h Page 30
27h R/W Interrupt Enable Enables Interrupts associated with
capacitive touch sensor inputs 07h Page 30
28h R/W Repeat Rate Enable Enables repeat rate for all sensor
inputs 07h Page 30
2Ah R/W Multiple Touch Configuration
Determines the number of simultaneous
touches to flag a multiple touch
condition
80h Page 31
2Bh R/W Multiple Touch Pattern
Configuration
Determines the multiple touch pattern
(MTP) configuration 00h Page 31
2Dh R/W Multiple Touch Pattern
Determines the pattern or number of
sensor inputs used by the MTP circuitry
07h Page 32
2Fh R/W Recalibration Configuration
Determines re-calibration timing and
sampling window 8Ah Page 33
30h R/W Sensor Input 1 Threshold
Stores the delta count threshold to
determine a touch for Capacitive
Touch Sensor Input 1
40h Page 34
CAP1133
DS00001625B-page 20 2015 Microchip Technology Inc.
31h R/W Sensor Input 2 Threshold
Stores the delta count threshold to
determine a touch for Capacitive
Touch Sensor Input 2
40h Page 34
32h R/W Sensor Input 3 Threshold
Stores the delta count threshold to
determine a touch for Capacitive
Touch Sensor Input 3
40h Page 34
38h R/W Sensor Input Noise
Threshold
Stores controls for selecting the noise
threshold for all sensor inputs 01h Page 34
Standby Configuration Registers
40h R/W Standby Channel Controls which sensor inputs are
enabled while in standby 00h Page 35
41h R/W Standby Configuration Controls averaging and cycle time
while in standby 39h Page 35
42h R/W Standby Sensitivity Controls sensitivity settings used while
in standby 02h Page 36
43h R/W Standby Threshold Stores the touch detection threshold
for active sensor inputs in standby 40h Page 37
44h R/W Configuration 2 Stores additional configuration controls
for the device 40h Page 25
Base Count Registers
50h R Sensor Input 1 Base
Count
Stores the reference count value for
sensor input 1 C8h Page 37
51h R Sensor Input 2 Base
Count
Stores the reference count value for
sensor input 2 C8h Page 37
52h R Sensor Input 3 Base
Count
Stores the reference count value for
sensor input 3 C8h Page 37
LED Controls
71h R/W LED Output Type Controls the output type for the LED
outputs 00h Page 38
72h R/W Sensor Input LED Linking
Controls linking of sensor inputs to
LED channels 00h Page 38
73h R/W LED Polarity Controls the output polarity of LEDs 00h Page 38
74h R/W LED Output Control Controls the output state of the LEDs 00h Page 39
77h R/W Linked LED
Transition Control
Controls the transition when LEDs are
linked to CS channels 00h Page 40
79h R/W LED Mirror Control Controls the mirroring of duty cycles
for the LEDs 00h Page 41
81h R/W LED Behavior 1 Controls the behavior and response of
LEDs 1 - 3 00h Page 41
84h R/W LED Pulse 1 Period Controls the period of each breathe
during a pulse 20h Page 43
85h R/W LED Pulse 2 Period Controls the period of the breathing
during breathe and pulse operation 14h Page 45
86h R/W LED Breathe Period Controls the period of an LED breathe
operation 5Dh Page 46
88h R/W LED Config Controls LED configuration 04h Page 46
90h R/W LED Pulse 1 Duty Cycle Determines the min and max duty
cycle for the pulse operation F0h Page 47
TABLE 6-1: REGISTER SET IN HEXADECIMAL ORDER (CONTINUED)
Register
Address R/W Register Name Function Default Value Page
2015 Microchip Technology Inc. DS00001625B-page 21
CAP1133
During Power-On-Reset (POR), the default values are stored in the registers. A POR is initiated when power is first
applied to the part and the voltage on the VDD supply surpasses the POR level as specified in the electrical characteristics.
Any reads to undefined registers will return 00h. Writes to undefined registers will not have an effect.
When a bit is “set”, this means that the user writes a logic ‘1’ to it. When a bit is “cleared”, this means that the user writes
a logic ‘0’ to it.
6.1 Main Control Register
The Main Control register controls the primary power state of the device.
Bits 7 - 6 - GAIN[1:0] - Controls the gain used by the capacitive touch sensing circuitry. As the gain is increased, the
effective sensitivity is likewise increased as a smaller delta capacitance is required to generate the same delta count
values. The sensitivity settings may need to be adjusted along with the gain settings such that data overflow does not
occur.
APPLICATION NOTE: The gain settings apply to both Standby and Active states.
91h R/W LED Pulse 2 Duty Cycle Determines the min and max duty
cycle for breathe and pulse operation F0h Page 47
92h R/W LED Breathe Duty Cycle Determines the min and max duty
cycle for the breathe operation F0h Page 47
93h R/W LED Direct Duty Cycle Determines the min and max duty
cycle for Direct mode LED operation F0h Page 47
94h R/W LED Direct Ramp Rates Determines the rising and falling edge
ramp rates of the LEDs 00h Page 47
95h R/W LED Off Delay Determines the off delay for all LED
behaviors 00h Page 48
B1h R Sensor Input 1 Calibration
Stores the upper 8-bit calibration value
for sensor input 1 00h Page 51
B2h R Sensor Input 2 Calibration
Stores the upper 8-bit calibration value
for sensor input 2 00h Page 51
B3h R Sensor Input 3 Calibration
Stores the upper 8-bit calibration value
for sensor input 3 00h Page 51
B9h R Sensor Input Calibration
LSB 1
Stores the 2 LSBs of the calibration
value for sensor inputs 1 - 3 00h Page 51
FDh R Product ID Stores a fixed value that identifies
each product 54h Page 51
FEh R Manufacturer ID Stores a fixed value that identifies
Microchip 5Dh Page 52
FFh R Revision Stores a fixed value that represents
the revision number 83h Page 52
TABLE 6-2: MAIN CONTROL REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
00h R/W Main Control GAIN[1:0] STBY DSLEEP - - - INT 00h
TABLE 6-3: GAIN BIT DECODE
GAIN[1:0]
Capacitive Touch Sensor Gain
1 0
0 0 1
TABLE 6-1: REGISTER SET IN HEXADECIMAL ORDER (CONTINUED)
Register
Address R/W Register Name Function Default Value Page
CAP1133
DS00001625B-page 22 2015 Microchip Technology Inc.
Bit 5 - STBY - Enables Standby.
• ‘0’ (default) - Sensor input scanning is active and LEDs are functional.
• ‘1’ - Capacitive touch sensor input scanning is limited to the sensor inputs set in the Standby Channel register (see
Section 6.20). The status registers will not be cleared until read. LEDs that are linked to capacitive touch sensor
inputs will remain linked and active. Sensor inputs that are no longer sampled will flag a release and then remain
in a non-touched state. LEDs that are manually controlled will be unaffected.
• Bit 4 - DSLEEP - Enables Deep Sleep by deactivating all functions. ‘0’ (default) - Sensor input scanning is active
and LEDs are functional.
• ‘1’ - All sensor input scanning is disabled. All LEDs are driven to their programmed non-actuated state and no
PWM operations will be done. The status registers are automatically cleared and the INT bit is cleared.
Bit 0 - INT - Indicates that there is an interrupt. When this bit is set, it asserts the ALERT# pin. If a channel detects a
touch and its associated interrupt enable bit is not set to a logic ‘1’, no action is taken.
This bit is cleared by writing a logic ‘0’ to it. When this bit is cleared, the ALERT# pin will be deasserted and all status
registers will be cleared if the condition has been removed.
• ‘0’ - No interrupt pending.
• ‘1’ - A touch has been detected on one or more channels and the interrupt has been asserted.
6.2 Status Registers
All status bits are cleared when the device enters the Deep Sleep (DSLEEP = ‘1’ - see Section 6.1).
6.2.1 GENERAL STATUS - 02H
Bit 4 - LED - Indicates that one or more LEDs have finished their programmed activity. This bit is set if any bit in the LED
Status register is set.
Bit 2 - MULT - Indicates that the device is blocking detected touches due to the Multiple Touch detection circuitry (see
Section 6.14). This bit will not cause the INT bit to be set and hence will not cause an interrupt.
Bit 1 - MTP - Indicates that the device has detected a number of sensor inputs that exceed the MTP threshold either via
the pattern recognition or via the number of sensor inputs (see Section 6.15). This bit will cause the INT bit to be set if
the MTP_ALERT bit is also set. This bit will not be cleared until the condition that caused it to be set has been removed.
Bit 0 - TOUCH - Indicates that a touch was detected. This bit is set if any bit in the Sensor Input Status register is set.
6.2.2 SENSOR INPUT STATUS - 03H
The Sensor Input Status Register stores status bits that indicate a touch has been detected. A value of ‘0’ in any bit
indicates that no touch has been detected. A value of ‘1’ in any bit indicates that a touch has been detected.
01 2
10 4
11 8
TABLE 6-4: STATUS REGISTERS
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
02h R General Status - - - LED - MULT MTP TOUCH 00h
03h R Sensor Input Status
- - - - - CS3 CS2 CS1 00h
04h R LED Status - - - - - LED3_
DN
LED2_
DN
LED1_
DN 00h
TABLE 6-3: GAIN BIT DECODE (CONTINUED)
GAIN[1:0]
Capacitive Touch Sensor Gain
1 0
2015 Microchip Technology Inc. DS00001625B-page 23
CAP1133
All bits are cleared when the INT bit is cleared and if a touch on the respective capacitive touch sensor input is no longer
present. If a touch is still detected, the bits will not be cleared (but this will not cause the interrupt to be asserted - see
Section 6.6).
Bit 2 - CS3 - Indicates that a touch was detected on Sensor Input 3. This sensor input can be linked to LED3.
Bit 1 - CS2 - Indicates that a touch was detected on Sensor Input 2. This sensor input can be linked to LED2.
Bit 0 - CS1 - Indicates that a touch was detected on Sensor Input 1. This sensor input can be linked to LED1.
6.2.3 LED STATUS - 04H
The LED Status Registers indicate when an LED has completed its configured behavior (see Section 6.31, "LED Behavior
Register") after being actuated by the host (see Section 6.28, "LED Output Control Register"). These bits are ignored
when the LED is linked to a capacitive sensor input. All LED Status bits are cleared when the INT bit is cleared.
Bit 2 - LED3_DN - Indicates that LED3 has finished its behavior after being actuated by the host.
Bit 1 - LED2_DN - Indicates that LED2 has finished its behavior after being actuated by the host.
Bit 0 - LED1_DN - Indicates that LED1 has finished its behavior after being actuated by the host.
6.3 Noise Flag Status Registers
The Noise Flag Status registers store status bits that are generated from the analog block if the detected noise is above
the operating region of the analog detector or the RF noise detector. These bits indicate that the most recently received
data from the sensor input is invalid and should not be used for touch detection. So long as the bit is set for a particular
channel, the delta count value is reset to 00h and thus no touch is detected.
These bits are not sticky and will be cleared automatically if the analog block does not report a noise error.
APPLICATION NOTE: If the MTP detection circuitry is enabled, these bits count as sensor inputs above the MTP
threshold (see Section 5.3.4, "Multiple Touch Pattern Detection") even if the corresponding
delta count is not. If the corresponding delta count also exceeds the MTP threshold, it is not
counted twice.
APPLICATION NOTE: Regardless of the state of the Noise Status bits, if low frequency noise is detected on a
sensor input, that sample will be discarded unless the DIS_ANA_NOISE bit is set. As well,
if RF noise is detected on a sensor input, that sample will be discarded unless the
DIS_RF_NOISE bit is set.
6.4 Sensor Input Delta Count Registers
The Sensor Input Delta Count registers store the delta count that is compared against the threshold used to determine
if a touch has been detected. The count value represents a change in input due to the capacitance associated with a
touch on one of the sensor inputs and is referenced to a calibrated base “Not Touched” count value. The delta is an
instantaneous change and is updated once per sensor input per sensing cycle (see Section 5.3.1, "Sensing Cycle").
TABLE 6-5: NOISE FLAG STATUS REGISTERS
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
0Ah R Noise Flag Status - - - CS3_
NOISE
CS2_
NOISE
CS1_
NOISE 00h
TABLE 6-6: SENSOR INPUT DELTA COUNT REGISTERS
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
10h R Sensor Input 1
Delta Count Sign 64 32 16 8 4 2 1 00h
11h R Sensor Input 2
Delta Count Sign 64 32 16 8 4 2 1 00h
12h R Sensor Input 3
Delta Count Sign 64 32 16 8 4 2 1 00h
CAP1133
DS00001625B-page 24 2015 Microchip Technology Inc.
The value presented is a standard 2’s complement number. In addition, the value is capped at a value of 7Fh. A reading
of 7Fh indicates that the sensitivity settings are too high and should be adjusted accordingly (see Section 6.5).
The value is also capped at a negative value of 80h for negative delta counts which may result upon a release.
6.5 Sensitivity Control Register
The Sensitivity Control register controls the sensitivity of a touch detection.
Bits 6-4 DELTA_SENSE[2:0] - Controls the sensitivity of a touch detection. The sensitivity settings act to scale the relative
delta count value higher or lower based on the system parameters. A setting of 000b is the most sensitive while a
setting of 111b is the least sensitive. At the more sensitive settings, touches are detected for a smaller delta capacitance
corresponding to a “lighter” touch. These settings are more sensitive to noise, however, and a noisy environment may
flag more false touches with higher sensitivity levels.
APPLICATION NOTE: A value of 128x is the most sensitive setting available. At the most sensitivity settings, the
MSB of the Delta Count register represents 64 out of ~25,000 which corresponds to a touch
of approximately 0.25% of the base capacitance (or a ΔC of 25fF from a 10pF base
capacitance). Conversely, a value of 1x is the least sensitive setting available. At these
settings, the MSB of the Delta Count register corresponds to a delta count of 8192 counts
out of ~25,000 which corresponds to a touch of approximately 33% of the base capacitance
(or a ΔC of 3.33pF from a 10pF base capacitance).
Bits 3 - 0 - BASE_SHIFT[3:0] - Controls the scaling and data presentation of the Base Count registers. The higher the
value of these bits, the larger the range and the lower the resolution of the data presented. The scale factor represents
the multiplier to the bit-weighting presented in these register descriptions.
APPLICATION NOTE: The BASE_SHIFT[3:0] bits normally do not need to be updated. These settings will not affect
touch detection or sensitivity. These bits are sometimes helpful in analyzing the Cap Sensing
board performance and stability.
TABLE 6-7: SENSITIVITY CONTROL REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
1Fh R/W Sensitivity Control - DELTA_SENSE[2:0] BASE_SHIFT[3:0] 2Fh
TABLE 6-8: DELTA_SENSE BIT DECODE
DELTA_SENSE[2:0]
Sensitivity Multiplier
210
0 0 0 128x (most sensitive)
0 0 1 64x
0 1 0 32x (default)
0 1 1 16x
1 0 0 8x
1 0 1 4x
1 1 0 2x
1 1 1 1x - (least sensitive)
TABLE 6-9: BASE_SHIFT BIT DECODE
BASE_SHIFT[3:0]
Data Scaling Factor
32 1 0
0 0 0 0 1x
0 0 0 1 2x
0 0 1 0 4x
0 0 1 1 8x
2015 Microchip Technology Inc. DS00001625B-page 25
CAP1133
6.6 Configuration Registers
The Configuration registers control general global functionality that affects the entire device.
6.6.1 CONFIGURATION - 20H
Bit 7 - TIMEOUT - Enables the timeout and idle functionality of the SMBus protocol.
• ‘0’ (default for Functional Revision C) - The SMBus timeout and idle functionality are disabled. The SMBus interface
will not time out if the clock line is held low. Likewise, it will not reset if both the data and clock lines are held
high for longer than 200us. This is used for I2C compliance.
• ‘1’ (default for Functional Revision B) - The SMBus timeout and idle functionality are enabled. The SMBus interface
will time out if the clock line is held low for longer than 30ms. Likewise, it will reset if both the data and clock
lines are held high for longer than 200us.
Bit 5 - DIS_DIG_NOISE - Determines whether the digital noise threshold (see Section 6.19, "Sensor Input Noise Threshold
Register") is used by the device. Setting this bit disables the feature.
• ‘0’ - The digital noise threshold is used. If a delta count value exceeds the noise threshold but does not exceed the
touch threshold, the sample is discarded and not used for the automatic re-calibration routine.
• ‘1’ (default) - The noise threshold is disabled. Any delta count that is less than the touch threshold is used for the
automatic re-calibration routine.
Bit 4 - DIS_ANA_NOISE - Determines whether the analog noise filter is enabled. Setting this bit disables the feature.
• ‘0’ (default) - If low frequency noise is detected by the analog block, the delta count on the corresponding channel
is set to 0. Note that this does not require that Noise Status bits be set.
• ‘1’ - A touch is not blocked even if low frequency noise is detected.
Bit 3 - MAX_DUR_EN - Determines whether the maximum duration recalibration is enabled.
• ‘0’ (default) - The maximum duration recalibration functionality is disabled. A touch may be held indefinitely and no
re-calibration will be performed on any sensor input.
• ‘1’ - The maximum duration recalibration functionality is enabled. If a touch is held for longer than the MAX_DUR
bit settings, then the re-calibration routine will be restarted (see Section 6.8).
0 1 0 0 16x
0 1 0 1 32x
0 1 1 0 64x
0 1 1 1 128x
1 0 0 0 256x
All others 256x
(default = 1111b)
TABLE 6-10: CONFIGURATION REGISTERS
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
20h R/W Configuration TIMEOUT - DIS_ DIG_
NOISE
DIS_ ANA_
NOISE
MAX_
DUR_EN - --
A0h
(Rev B)
20h
(rev C)
44h R/W Configuration 2 INV_LINK_
TRAN
ALT_
POL
BLK_PWR_
CTRL
BLK_POL_
MIR
SHOW_
RF_
NOISE
DIS_
RF_
NOISE
- INT_
REL_n 40h
TABLE 6-9: BASE_SHIFT BIT DECODE (CONTINUED)
BASE_SHIFT[3:0]
Data Scaling Factor
32 1 0
CAP1133
DS00001625B-page 26 2015 Microchip Technology Inc.
6.6.2 CONFIGURATION 2 - 44H
Bit 7 - INV_LINK_TRAN - Determines the behavior of the Linked LED Transition controls (see Section 6.29).
• ‘0’ (default) - The Linked LED Transition controls set the min duty cycle equal to the max duty cycle.
• ‘1’ - The Linked LED Transition controls will invert the touch signal. For example, a touch signal will be inverted to
a non-touched signal.
Bit 6 - ALT_POL - Determines the ALERT# pin polarity and behavior.
• ‘0’ - The ALERT# pin is active high and push-pull.
• ‘1’ (default) - The ALERT# pin is active low and open drain.
Bit 5 - BLK_PWR_CTRL - Determines whether the device will reduce power consumption while waiting between conversion
time completion and the end of the polling cycle.
• ‘0’ (default) - The device will always power down as much as possible during the time between the end of the last
conversion and the end of the polling cycle.
• ‘1’ - The device will not power down the Cap Sensor during the time between the end of the last conversion and
the end of the polling cycle.
Bit 4 - BLK_POL_MIR - Determines whether the LED Mirror Control register bits are linked to the LED Polarity bits. Setting
this bit blocks the normal behavior which is to automatically set and clear the LED Mirror Control bits when the LED
Polarity bits are set or cleared.
• ‘0’ (default) - When the LED Polarity controls are set, the corresponding LED Mirror control is automatically set.
Likewise, when the LED Polarity controls are cleared, the corresponding LED Mirror control is also cleared.
• ‘1’ - When the LED Polarity controls are set, the corresponding LED Mirror control is not automatically set.
Bit 3 - SHOW_RF_NOISE - Determines whether the Noise Status bits will show RF Noise as the only input source.
• ‘0’ (default) - The Noise Status registers will show both RF noise and low frequency EMI noise if either is detected
on a capacitive touch sensor input.
• ‘1’ - The Noise Status registers will only show RF noise if it is detected on a capacitive touch sensor input. EMI
noise will still be detected and touches will be blocked normally; however, the status bits will not be updated.
Bit 2 - DIS_RF_NOISE - Determines whether the RF noise filter is enabled. Setting this bit disables the feature.
• ‘0’ (default) - If RF noise is detected by the analog block, the delta count on the corresponding channel is set to 0.
Note that this does not require that Noise Status bits be set.
• ‘1’ - A touch is not blocked even if RF noise is detected.
Bit 0 - INT_REL_n - Controls the interrupt behavior when a release is detected on a button.
• ‘0’ (default) - An interrupt is generated when a press is detected and again when a release is detected and at the
repeat rate (if enabled - see Section 6.13).
• ‘1’ - An interrupt is generated when a press is detected and at the repeat rate but not when a release is detected.
6.7 Sensor Input Enable Registers
The Sensor Input Enable registers determine whether a capacitive touch sensor input is included in the sampling cycle.
The length of the sampling cycle is not affected by the number of sensor inputs measured.
Bit 2 - CS3_EN - Enables the CS3 input to be included during the sampling cycle.
• ‘0’ - The CS3 input is not included in the sampling cycle.
• ‘1’ (default) - The CS3 input is included in the sampling cycle.
Bit 1 - CS2_EN - Enables the CS2 input to be included during the sampling cycle.
Bit 0 - CS1_EN - Enables the CS1 input to be included during the sampling cycle.
TABLE 6-11: SENSOR INPUT ENABLE REGISTERS
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
21h R/W Sensor Input
Enable - - - - - CS3_EN CS2_EN CS1_EN 07h
2015 Microchip Technology Inc. DS00001625B-page 27
CAP1133
6.8 Sensor Input Configuration Register
The Sensor Input Configuration Register controls timings associated with the Capacitive sensor inputs 1 - 3.
Bits 7 - 4 - MAX_DUR[3:0] - (default 1010b) - Determines the maximum time that a sensor pad is allowed to be touched
until the capacitive touch sensor input is recalibrated, as shown in Table 6-13.
Bits 3 - 0 - RPT_RATE[3:0] - (default 0100b) Determines the time duration between interrupt assertions when auto
repeat is enabled. The resolution is 35ms the range is from 35ms to 560ms as shown in Table 6-14.
TABLE 6-12: SENSOR INPUT CONFIGURATION REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
22h R/W Sensor Input
Configuration MAX_DUR[3:0] RPT_RATE[3:0] A4h
TABLE 6-13: MAX_DUR BIT DECODE
MAX_DUR[3:0]
Time Before Recalibration
32 1 0
0 0 0 0 560ms
0 0 0 1 840ms
0 0 1 0 1120ms
0 0 1 1 1400ms
0 1 0 0 1680ms
0 1 0 1 2240ms
0 1 1 0 2800ms
1 1 1 3360ms
1 0 0 0 3920ms
1 0 0 1 4480ms
1 0 1 0 5600ms (default)
1 0 1 1 6720ms
1 1 0 0 7840ms
1 1 0 1 8906ms
1 1 1 0 10080ms
1 1 1 1 11200ms
TABLE 6-14: RPT_RATE BIT DECODE
RPT_RATE[3:0]
Interrupt Repeat RATE
3 21 0
0 0 0 0 35ms
0 0 0 1 70ms
0 0 1 0 105ms
0 0 1 1 140ms
0 1 0 0 175ms (default)
0 1 0 1 210ms
0 1 1 0 245ms
0 1 1 1 280ms
1 0 0 0 315ms
1 0 0 1 350ms
1 0 1 0 385ms
CAP1133
DS00001625B-page 28 2015 Microchip Technology Inc.
6.9 Sensor Input Configuration 2 Register
Bits 3 - 0 - M_PRESS[3:0] - (default 0111b) - Determines the minimum amount of time that sensor inputs configured to
use auto repeat must detect a sensor pad touch to detect a “press and hold” event. If the sensor input detects a touch
for longer than the M_PRESS[3:0] settings, a “press and hold” event is detected. If a sensor input detects a touch for
less than or equal to the M_PRESS[3:0] settings, a touch event is detected.
The resolution is 35ms the range is from 35ms to 560ms as shown in Table 6-16.
6.10 Averaging and Sampling Configuration Register
1 0 1 1 420ms
1 1 0 0 455ms
1 1 0 1 490ms
1 1 1 0 525ms
1 1 1 1 560ms
TABLE 6-15: SENSOR INPUT CONFIGURATION 2 REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
23h R/W Sensor Input
Configuration 2 - - - - M_PRESS[3:0] 07h
TABLE 6-16: M_PRESS BIT DECODE
M_PRESS[3:0]
M_PRESS SETTINGS
3 21 0
0 0 0 0 35ms
0 0 0 1 70ms
0 0 1 0 105ms
0 0 1 1 140ms
0 1 0 0 175ms
0 1 0 1 210ms
0 1 1 0 245ms
0 1 1 1 280ms (default)
1 0 0 0 315ms
1 0 0 1 350ms
1 0 1 0 385ms
1 0 1 1 420ms
1 1 0 0 455ms
1 1 0 1 490ms
1 1 1 0 525ms
1 1 1 1 560ms
TABLE 6-17: AVERAGING AND SAMPLING CONFIGURATION REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
24h R/W Averaging and
Sampling Config AVG[2:0] SAMP_TIME[1:0] CYCLE_TIME
[1:0] 39h
TABLE 6-14: RPT_RATE BIT DECODE (CONTINUED)
RPT_RATE[3:0]
Interrupt Repeat RATE
3 21 0
2015 Microchip Technology Inc. DS00001625B-page 29
CAP1133
The Averaging and Sampling Configuration register controls the number of samples taken and the total sensor input
cycle time for all active sensor inputs while the device is functioning in Active state.
Bits 6 - 4 - AVG[2:0] - Determines the number of samples that are taken for all active channels during the sensor cycle
as shown in Table 6-18. All samples are taken consecutively on the same channel before the next channel is sampled
and the result is averaged over the number of samples measured before updating the measured results.
For example, if CS1, CS2, and CS3 are sampled during the sensor cycle, and the AVG[2:0] bits are set to take 4 samples
per channel, then the full sensor cycle will be: CS1, CS1, CS1, CS1, CS2, CS2, CS2, CS2, CS3, CS3, CS3, CS3.
Bits 3 - 2 - SAMP_TIME[1:0] - Determines the time to take a single sample as shown in Table 6-19.
Bits 1 - 0 - CYCLE_TIME[1:0] - Determines the overall cycle time for all measured channels during normal operation as
shown in Table 6-20. All measured channels are sampled at the beginning of the cycle time. If additional time is remaining,
then the device is placed into a lower power state for the remaining duration of the cycle.
APPLICATION NOTE: The programmed cycle time is only maintained if the total averaging time for all samples is
less than the programmed cycle. The AVG[2:0] bits will take priority so that if more samples
are required than would normally be allowed during the cycle time, the cycle time will be
extended as necessary to accommodate the number of samples to be measured.
TABLE 6-18: AVG BIT DECODE
AVG[2:0] Number of Samples Taken per
Measurement 2 10
0 0 0 1
0 01 2
0 10 4
0 1 1 8 (default)
1 0 0 16
1 0 1 32
1 1 0 64
1 1 1 128
TABLE 6-19: SAMP_TIME BIT DECODE
SAMP_TIME[1:0]
Sample Time
1 0
0 0 320us
0 1 640us
1 0 1.28ms (default)
1 1 2.56ms
TABLE 6-20: CYCLE_TIME BIT DECODE
CYCLE_TIME[1:0]
Overall Cycle Time
1 0
0 0 35ms
0 1 70ms (default)
1 0 105ms
1 1 140ms
CAP1133
DS00001625B-page 30 2015 Microchip Technology Inc.
6.11 Calibration Activate Register
The Calibration Activate register forces the respective sensor inputs to be re-calibrated affecting both the analog and
digital blocks. During the re-calibration routine, the sensor inputs will not detect a press for up to 600ms and the Sensor
Input Base Count register values will be invalid. During this time, any press on the corresponding sensor pads will invalidate
the re-calibration. When finished, the CALX[9:0] bits will be updated (see Section 6.39).
When the corresponding bit is set, the device will perform the calibration and the bit will be automatically cleared once
the re-calibration routine has finished.
Bit 2 - CS3_CAL - When set, the CS3 input is re-calibrated. This bit is automatically cleared once the sensor input has
been re-calibrated successfully.
Bit 1 - CS2_CAL - When set, the CS2 input is re-calibrated. This bit is automatically cleared once the sensor input has
been re-calibrated successfully.
Bit 0 - CS1_CAL - When set, the CS1 input is re-calibrated. This bit is automatically cleared once the sensor input has
been re-calibrated successfully.
6.12 Interrupt Enable Register
The Interrupt Enable register determines whether a sensor pad touch or release (if enabled) causes the interrupt pin to
be asserted.
Bit 2 - CS3_INT_EN - Enables the interrupt pin to be asserted if a touch is detected on CS3 (associated with the CS3
status bit).
• ‘0’ - The interrupt pin will not be asserted if a touch is detected on CS3 (associated with the CS6 status bit).
• ‘1’ (default) - The interrupt pin will be asserted if a touch is detected on CS3 (associated with the CS6 status bit).
Bit 1 - CS2_INT_EN - Enables the interrupt pin to be asserted if a touch is detected on CS2 (associated with the CS2
status bit).
Bit 0 - CS1_INT_EN - Enables the interrupt pin to be asserted if a touch is detected on CS1 (associated with the CS1
status bit).
6.13 Repeat Rate Enable Register
The Repeat Rate Enable register enables the repeat rate of the sensor inputs as described in Section 5.4.1.
Bit 2 - CS3_RPT_EN - Enables the repeat rate for capacitive touch sensor input 3.
• ‘0’ - The repeat rate for CS3 is disabled. It will only generate an interrupt when a touch is detected and when a
release is detected no matter how long the touch is held for.
• ‘1’ (default) - The repeat rate for CS3 is enabled. In the case of a “touch” event, it will generate an interrupt when a
touch is detected and a release is detected (as determined by the INT_REL_n bit - see Section 6.6). In the case of
a “press and hold” event, it will generate an interrupt when a touch is detected and at the repeat rate so long as
TABLE 6-21: CALIBRATION ACTIVATE REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
26h R/W Calibration
Activate --- CS3_
CAL
CS2_
CAL
CS1_
CAL 00h
TABLE 6-22: INTERRUPT ENABLE REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
27h R/W Interrupt
Enable --- CS3_
INT_EN
CS2_
INT_EN
CS1_
INT_EN 07h
TABLE 6-23: REPEAT RATE ENABLE REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
28h R/W Repeat Rate
Enable ---- - CS3_
RPT_EN
CS2_
RPT_EN
CS1_
RPT_EN 07h
2015 Microchip Technology Inc. DS00001625B-page 31
CAP1133
the touch is held d.
Bit 1 - CS2_RPT_EN - Enables the repeat rate for capacitive touch sensor input 2.
Bit 0 - CS1_RPT_EN - Enables the repeat rate for capacitive touch sensor input 1.
6.14 Multiple Touch Configuration Register
The Multiple Touch Configuration register controls the settings for the multiple touch detection circuitry. These settings
determine the number of simultaneous buttons that may be pressed before additional buttons are blocked and the MULT
status bit is set.
Bit 7 - MULT_BLK_EN - Enables the multiple button blocking circuitry.
• ‘0’ - The multiple touch circuitry is disabled. The device will not block multiple touches.
• ‘1’ (default) - The multiple touch circuitry is enabled. The device will flag the number of touches equal to programmed
multiple touch threshold and block all others. It will remember which sensor inputs are valid and block all
others until that sensor pad has been released. Once a sensor pad has been released, the N detected touches
(determined via the cycle order of CS1 - CS3) will be flagged and all others blocked.
Bits 3 - 2 - B_MULT_T[1:0] - Determines the number of simultaneous touches on all sensor pads before a Multiple Touch
Event is detected and sensor inputs are blocked. The bit decode is given by Table 6-25.
6.15 Multiple Touch Pattern Configuration Register
The Multiple Touch Pattern Configuration register controls the settings for the multiple touch pattern detection circuitry.
This circuitry works like the multiple touch detection circuitry with the following differences:
1. The detection threshold is a percentage of the touch detection threshold as defined by the MTP_TH[1:0] bits
whereas the multiple touch circuitry uses the touch detection threshold.
2. The MTP detection circuitry either will detect a specific pattern of sensor inputs as determined by the Multiple
Touch Pattern register settings or it will use the Multiple Touch Pattern register settings to determine a minimum
number of sensor inputs that will cause the MTP circuitry to flag an event. When using pattern recognition mode,
if all of the sensor inputs set by the Multiple Touch Pattern register have a delta count greater than the MTP
threshold or have their corresponding Noise Flag Status bits set, the MTP bit will be set. When using the absolute
number mode, if the number of sensor inputs with thresholds above the MTP threshold or with Noise Flag Status
bits set is equal to or greater than this number, the MTP bit will be set.
3. When an MTP event occurs, all touches are blocked and an interrupt is generated.
TABLE 6-24: MULTIPLE TOUCH CONFIGURATION
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
2Ah R/W Multiple Touch
Config
MULT_
BLK_
EN
- - - B_MULT_T[1:0] - - 80h
TABLE 6-25: B_MULT_T BIT DECODE
B_MULT_T[1:0]
Number of Simultaneous Touches
1 0
0 0 1 (default)
01 2
10 3
11 3
TABLE 6-26: MULTIPLE TOUCH PATTERN CONFIGURATION
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
2Bh R/W Multiple Touch
Pattern Config MTP_ EN - - MTP_TH[1:0] COMP_
PTRN
MTP_
ALERT 00h
CAP1133
DS00001625B-page 32 2015 Microchip Technology Inc.
4. All sensor inputs will remain blocked so long as the requisite number of sensor inputs are above the MTP threshold
or have Noise Flag Status bits set. Once this condition is removed, touch detection will be restored. Note that
the MTP status bit is only cleared by writing a ‘0’ to the INT bit once the condition has been removed.
Bit 7 - MTP_EN - Enables the multiple touch pattern detection circuitry.
• ‘0’ (default) - The MTP detection circuitry is disabled.
• ‘1’ - The MTP detection circuitry is enabled.
Bits 3-2 - MTP_TH[1:0] - Determine the MTP threshold, as shown in Table 6-27. This threshold is a percentage of sensor
input threshold (see Section 6.18, "Sensor Input Threshold Registers") when the device is in the Fully Active state or of
the standby threshold (see Section 6.23, "Standby Threshold Register") when the device is in the Standby state.
Bit 1 - COMP_PTRN - Determines whether the MTP detection circuitry will use the Multiple Touch Pattern register as a
specific pattern of sensor inputs or as an absolute number of sensor inputs.
• ‘0’ (default) - The MTP detection circuitry will use the Multiple Touch Pattern register bit settings as an absolute
minimum number of sensor inputs that must be above the threshold or have Noise Flag Status bits set. The number
will be equal to the number of bits set in the register.
• ‘1’ - The MTP detection circuitry will use pattern recognition. Each bit set in the Multiple Touch Pattern register
indicates a specific sensor input that must have a delta count greater than the MTP threshold or have a Noise Flag
Status bit set. If the criteria are met, the MTP status bit will be set.
Bit 0 - MTP_ALERT - Enables an interrupt if an MTP event occurs. In either condition, the MTP status bit will be set.
• ‘0’ (default) - If an MTP event occurs, the ALERT# pin is not asserted.
• ‘1’ - If an MTP event occurs, the ALERT# pin will be asserted.
6.16 Multiple Touch Pattern Register
The Multiple Touch Pattern register acts as a pattern to identify an expected sensor input profile for diagnostics or other
significant events. There are two methods for how the Multiple Touch Pattern register is used: as specific sensor inputs
or number of sensor input that must exceed the MTP threshold or have Noise Flag Status bits set. Which method is used
is based on the COMP_PTRN bit (see Section 6.15). The methods are described below.
1. Specific Sensor Inputs: If, during a single polling cycle, the specific sensor inputs above the MTP threshold or
with Noise Flag Status bits set match those bits set in the Multiple Touch Pattern register, an MTP event is
flagged.
2. Number of Sensor Inputs: If, during a single polling cycle, the number of sensor inputs with a delta count above
the MTP threshold or with Noise Flag Status bits set is equal to or greater than the number of pattern bits set, an
MTP event is flagged.
Bit 2 - CS3_PTRN - Determines whether CS3 is considered as part of the Multiple Touch Pattern.
• ‘0’ - CS3 is not considered a part of the pattern.
• ‘1’ - CS3 is considered a part of the pattern or the absolute number of sensor inputs that must have a delta count
greater than the MTP threshold or have the Noise Flag Status bit set is increased by 1.
TABLE 6-27: MTP_TH BIT DECODE
MTP_TH[1:0]
Threshold Divide Setting
1 0
0 0 12.5% (default)
0 1 25%
1 0 37.5%
1 1 100%
TABLE 6-28: MULTIPLE TOUCH PATTERN REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
2Dh R/W Multiple
Touch Pattern --- CS3_
PTRN
CS2_
PTRN
CS1_
PTRN 07h
2015 Microchip Technology Inc. DS00001625B-page 33
CAP1133
Bit 1 - CS2_PTRN - Determines whether CS2 is considered as part of the Multiple Touch Pattern.
Bit 0 - CS1_PTRN - Determines whether CS1 is considered as part of the Multiple Touch Pattern.
6.17 Recalibration Configuration Register
The Recalibration Configuration register controls the automatic re-calibration routine settings as well as advanced controls
to program the Sensor Input Threshold register settings.
Bit 7 - BUT_LD_TH - Enables setting all Sensor Input Threshold registers by writing to the Sensor Input 1 Threshold
register.
• ‘0’ - Each Sensor Input X Threshold register is updated individually.
• ‘1’ (default) - Writing the Sensor Input 1 Threshold register will automatically overwrite the Sensor Input Threshold
registers for all sensor inputs (Sensor Input Threshold 1 through Sensor Input Threshold 3). The individual Sensor
Input X Threshold registers (Sensor Input 2 Threshold and Sensor Input 3 Threshold) can be individually updated
at any time.
Bit 6 - NO_CLR_INTD - Controls whether the accumulation of intermediate data is cleared if the noise status bit is set.
• ‘0’ (default) - The accumulation of intermediate data is cleared if the noise status bit is set.
• ‘1’ - The accumulation of intermediate data is not cleared if the noise status bit is set.
APPLICATION NOTE: Bits 5 and 6 should both be set to the same value. Either both should be set to ‘0’ or both
should be set to ‘1’.
Bit 5 - NO_CLR_NEG - Controls whether the consecutive negative delta counts counter is cleared if the noise status bit
is set.
• ‘0’ (default) - The consecutive negative delta counts counter is cleared if the noise status bit is set.
• ‘1’ - The consecutive negative delta counts counter is not cleared if the noise status bit is set.
Bits 4 - 3 - NEG_DELTA_CNT[1:0] - Determines the number of negative delta counts necessary to trigger a digital recalibration
as shown in Table 6-30.
Bits 2 - 0 - CAL_CFG[2:0] - Determines the update time and number of samples of the automatic re-calibration routine.
The settings apply to all sensor inputs universally (though individual sensor inputs can be configured to support re-calibration
- see Section 6.11).
TABLE 6-29: RECALIBRATION CONFIGURATION REGISTERS
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
2Fh R/W Recalibration
Configuration
BUT_
LD_TH
NO_
CLR_
INTD
NO_
CLR_
NEG
NEG_DELTA_
CNT[1:0] CAL_CFG[2:0] 8Ah
TABLE 6-30: NEG_DELTA_CNT BIT DECODE
NEG_DELTA_CNT[1:0]
Number of Consecutive Negative Delta Count Values
1 0
00 8
0 1 16 (default)
1 0 32
1 1 None (disabled)
TABLE 6-31: CAL_CFG BIT DECODE
CAL_CFG[2:0] Recalibration Samples
(see Note 6-1)
Update Time (see
Note 6-2) 210
0 0 0 16 16
0 0 1 32 32
CAP1133
DS00001625B-page 34 2015 Microchip Technology Inc.
Note 6-1 Recalibration Samples refers to the number of samples that are measured and averaged before the
Base Count is updated however does not control the base count update period.
Note 6-2 Update Time refers to the amount of time (in polling cycle periods) that elapses before the Base
Count is updated. The time will depend upon the number of channels active, the averaging setting,
and the programmed cycle time.
6.18 Sensor Input Threshold Registers
The Sensor Input Threshold registers store the delta threshold that is used to determine if a touch has been detected.
When a touch occurs, the input signal of the corresponding sensor pad changes due to the capacitance associated with
a touch. If the sensor input change exceeds the threshold settings, a touch is detected.
When the BUT_LD_TH bit is set (see Section 6.17 - bit 7), writing data to the Sensor Input 1 Threshold register will
update all of the sensor input threshold registers (31h - 32h inclusive).
6.19 Sensor Input Noise Threshold Register
The Sensor Input Noise Threshold register controls the value of a secondary internal threshold to detect noise and
improve the automatic recalibration routine. If a capacitive touch sensor input exceeds the Sensor Input Noise Threshold
but does not exceed the sensor input threshold, it is determined to be caused by a noise spike. That sample is not used
by the automatic re-calibration routine. This feature can be disabled by setting the DIS_DIG_NOISE bit.
Bits 1-0 - CS1_BN_TH[1:0] - Controls the noise threshold for all capacitive touch sensor inputs, as shown in Table 6-34.
The threshold is proportional to the threshold setting.
0 1 0 64 64 (default)
0 1 1 128 128
1 0 0 256 256
1 0 1 256 1024
1 1 0 256 2048
1 1 1 256 4096
TABLE 6-32: SENSOR INPUT THRESHOLD REGISTERS
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
30h R/W Sensor Input 1
Threshold - 64 32 16 8 4 2 1 40h
31h R/W Sensor Input 2
Threshold - 64 32 16 8 4 2 1 40h
32h R/W Sensor Input 3
Threshold - 64 32 16 8 4 2 1 40h
TABLE 6-33: SENSOR INPUT NOISE THRESHOLD REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
38h R/W Sensor Input
Noise Threshold CS_BN_TH [1:0] 01h
TABLE 6-31: CAL_CFG BIT DECODE (CONTINUED)
CAL_CFG[2:0] Recalibration Samples
(see Note 6-1)
Update Time (see
Note 6-2) 210
2015 Microchip Technology Inc. DS00001625B-page 35
CAP1133
6.20 Standby Channel Register
The Standby Channel register controls which (if any) capacitive touch sensor inputs are active during Standby.
Bit 2 - CS3_STBY - Controls whether the CS3 channel is active in Standby.
• ‘0’ (default) - The CS3 channel not be sampled during Standby mode.
• ‘1’ - The CS3 channel will be sampled during Standby Mode. It will use the Standby threshold setting, and the
standby averaging and sensitivity settings.
Bit 1 - CS2_STBY - Controls whether the CS2 channel is active in Standby.
Bit 0 - CS1_STBY - Controls whether the CS1 channel is active in Standby.
6.21 Standby Configuration Register
The Standby Configuration register controls averaging and cycle time for those sensor inputs that are active in Standby.
This register is useful for detecting proximity on a small number of sensor inputs as it allows the user to change averaging
and sample times on a limited number of sensor inputs and still maintain normal functionality in the fully active
state.
Bit 7 - AVG_SUM - Determines whether the active sensor inputs will average the programmed number of samples or
whether they will accumulate for the programmed number of samples.
• ‘0’ - (default) - The active sensor input delta count values will be based on the average of the programmed number
of samples when compared against the threshold.
• ‘1’ - The active sensor input delta count values will be based on the summation of the programmed number of
samples when compared against the threshold. This bit should only be set when performing proximity detection as
a physical touch will overflow the delta count registers and may result in false readings.
Bits 6 - 4 - STBY_AVG[2:0] - Determines the number of samples that are taken for all active channels during the sensor
cycle as shown in Table 6-37. All samples are taken consecutively on the same channel before the next channel is sampled
and the result is averaged over the number of samples measured before updating the measured results.
TABLE 6-34: CSX_BN_TH BIT DECODE
CS_BN_TH[1:0]
Percent Threshold Setting
1 0
0 0 25%
0 1 37.5% (default)
1 0 50%
1 1 62.5%
TABLE 6-35: STANDBY CHANNEL REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
40h R/W Standby Channel - - - - - CS3_
STBY
CS2_
STBY
CS1_
STBY 00h
TABLE 6-36: STANDBY CONFIGURATION REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
41h R/W Standby Configuration
AVG_
SUM STBY_AVG[2:0] STBY_SAMP_
TIME[1:0]
STBY_CY_TIME
[1:0] 39h
TABLE 6-37: STBY_AVG BIT DECODE
STBY_AVG[2:0] Number of Samples Taken per
Measurement 2 10
0 0 0 1
0 01 2
CAP1133
DS00001625B-page 36 2015 Microchip Technology Inc.
Bit 3-2 - STBY SAMP_TIME[1:0] - Determines the time to take a single sample when the device is in Standby as shown
in Table 6-38.
Bits 1 - 0 - STBY_CY_TIME[2:0] - Determines the overall cycle time for all measured channels during standby operation
as shown in Table 6-39. All measured channels are sampled at the beginning of the cycle time. If additional time is
remaining, the device is placed into a lower power state for the remaining duration of the cycle.
APPLICATION NOTE: The programmed cycle time is only maintained if the total averaging time for all samples is
less than the programmed cycle. The STBY_AVG[2:0] bits will take priority so that if more
samples are required than would normally be allowed during the cycle time, the cycle time
will be extended as necessary to accommodate the number of samples to be measured.
6.22 Standby Sensitivity Register
The Standby Sensitivity register controls the sensitivity for sensor inputs that are active in Standby.
0 10 4
0 1 1 8 (default)
1 0 0 16
1 0 1 32
1 1 0 64
1 1 1 128
TABLE 6-38: STBY_SAMP_TIME BIT DECODE
STBY_SAMP_TIME[1:0]
Sampling Time
1 0
0 0 320us
0 1 640us
1 0 1.28ms (default)
1 1 2.56ms
TABLE 6-39: STBY_CY_TIME BIT DECODE
STBY_CY_TIME[1:0]
Overall Cycle Time
1 0
0 0 35ms
0 1 70ms (default)
1 0 105ms
1 1 140ms
TABLE 6-40: STANDBY SENSITIVITY REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
42h R/W Standby Sensitivity
- - - - - STBY_SENSE[2:0] 02h
TABLE 6-37: STBY_AVG BIT DECODE (CONTINUED)
STBY_AVG[2:0] Number of Samples Taken per
Measurement 2 10
2015 Microchip Technology Inc. DS00001625B-page 37
CAP1133
Bits 2 - 0 - STBY_SENSE[2:0] - Controls the sensitivity for sensor inputs that are active in Standby. The sensitivity settings
act to scale the relative delta count value higher or lower based on the system parameters. A setting of 000b is the
most sensitive while a setting of 111b is the least sensitive. At the more sensitive settings, touches are detected for a
smaller delta C corresponding to a “lighter” touch. These settings are more sensitive to noise however and a noisy environment
may flag more false touches than higher sensitivity levels.
APPLICATION NOTE: A value of 128x is the most sensitive setting available. At the most sensitivity settings, the
MSB of the Delta Count register represents 64 out of ~25,000 which corresponds to a touch
of approximately 0.25% of the base capacitance (or a ΔC of 25fF from a 10pF base
capacitance). Conversely a value of 1x is the least sensitive setting available. At these
settings, the MSB of the Delta Count register corresponds to a delta count of 8192 counts
out of ~25,000 which corresponds to a touch of approximately 33% of the base capacitance
(or a ΔC of 3.33pF from a 10pF base capacitance).
6.23 Standby Threshold Register
The Standby Threshold register stores the delta threshold that is used to determine if a touch has been detected. When
a touch occurs, the input signal of the corresponding sensor pad changes due to the capacitance associated with a
touch. If the sensor input change exceeds the threshold settings, a touch is detected.
6.24 Sensor Input Base Count Registers
The Sensor Input Base Count registers store the calibrated “Not Touched” input value from the capacitive touch sensor
inputs. These registers are periodically updated by the re-calibration routine.
The routine uses an internal adder to add the current count value for each reading to the sum of the previous readings
until sample size has been reached. At this point, the upper 16 bits are taken and used as the Sensor Input Base Count.
The internal adder is then reset and the re-calibration routine continues.
TABLE 6-41: STBY_SENSE BIT DECODE
STBY_SENSE[2:0]
Sensitivity Multiplier
210
0 0 0 128x (most sensitive)
0 0 1 64x
0 1 0 32x (default)
0 1 1 16x
1 0 0 8x
1 0 1 4x
1 1 0 2x
1 1 1 1x - (least sensitive)
TABLE 6-42: STANDBY THRESHOLD REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
43h R/W Standby Threshold
- 64 32 16 8 4 2 1 40h
TABLE 6-43: SENSOR INPUT BASE COUNT REGISTERS
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
50h R Sensor Input 1
Base Count 128 64 32 16 8 4 2 1 C8h
51h R Sensor Input 2
Base Count 128 64 32 16 8 4 2 1 C8h
52h R Sensor Input 3
Base Count 128 64 32 16 8 4 2 1 C8h
CAP1133
DS00001625B-page 38 2015 Microchip Technology Inc.
The data presented is determined by the BASE_SHIFT[3:0] bits (see Section 6.5).
6.25 LED Output Type Register
The LED Output Type register controls the type of output for the LED pins. Each pin is controlled by a single bit. Refer
to application note 21.4 CAP1133Family LED Configuration Options for more information about implementing LEDs.
Bit 2 - LED3_OT - Determines the output type of the LED3 pin.
• ‘0’ (default) - The LED3 pin is an open-drain output with an external pull-up resistor. When the appropriate pin is
set to the “active” state (logic ‘1’), the pin will be driven low. Conversely, when the pin is set to the “inactive” state
(logic ‘0’), the pin will be left in a High Z state and pulled high via an external pull-up resistor.
• ‘1’ - The LED3 pin is a push-pull output. When driving a logic ‘1’, the pin is driven high. When driving a logic ‘0’, the
pin is driven low.
Bit 1 - LED2_OT - Determines the output type of the LED2 pin.
Bit 0 - LED1_OT - Determines the output type of the LED1 pin.
6.26 Sensor Input LED Linking Register
The Sensor Input LED Linking register controls whether a capacitive touch sensor input is linked to an LED output. If
the corresponding bit is set, then the appropriate LED output will change states defined by the LED Behavior controls
(see Section 6.31) in response to the capacitive touch sensor input.
Bit 2 - CS3_LED3 - Links the LED3 output to a detected touch on the CS3 sensor input. When a touch is detected, the
LED is actuated and will behave as determined by the LED Behavior controls.
• ‘0’ (default) - The LED 3 output is not associated with the CS3 input. If a touch is detected on the CS3 input, the
LED will not automatically be actuated. The LED is enabled and controlled via the LED Output Control register
(see Section 6.28) and the LED Behavior registers (see Section 6.31).
• ‘1’ - The LED 3 output is associated with the CS3 input. If a touch is detected on the CS3 input, the LED will be
actuated and behave as defined in Table 6-52.
Bit 1 - CS2_LED2 - Links the LED2 output to a detected touch on the CS2 sensor input. When a touch is detected, the
LED is actuated and will behave as determined by the LED Behavior controls.
Bit 0 - CS1_LED1 - Links the LED1 output to a detected touch on the CS1 sensor input. When a touch is detected, the
LED is actuated and will behave as determined by the LED Behavior controls.
6.27 LED Polarity Register
TABLE 6-44: LED OUTPUT TYPE REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
71h R/W LED Output
Type ----- LED3_
OT
LED2_
OT
LED1_
OT 00h
TABLE 6-45: SENSOR INPUT LED LINKING REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
72h R/W Sensor Input
LED Linking
- - - - - CS3_
LED3
CS2_
LED2
CS1_
LED1
00h
TABLE 6-46: LED POLARITY REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
73h R/W LED Polarity - - - - - LED3_
POL
LED2_
POL
LED1_
POL 00h
2015 Microchip Technology Inc. DS00001625B-page 39
CAP1133
The LED Polarity register controls the logical polarity of the LED outputs. When these bits are set or cleared, the corresponding
LED Mirror controls are also set or cleared (unless the BLK_POL_MIR bit is set - see Section 6.6, "Configuration
Registers"). Table 6-48, "LED Polarity Behavior" shows the interaction between the polarity controls, output
controls, and relative brightness.
APPLICATION NOTE: The polarity controls determine the final LED pin drive. A touch on a linked capacitive touch
sensor input is treated in the same way as the LED Output Control bit being set to a logic ‘1’.
APPLICATION NOTE: The LED drive assumes that the LEDs are configured such that if the LED pin is driven to
a logic ‘0’ then the LED will be on and that the CAP1133 LED pin is sinking the LED current.
Conversely, if the LED pin is driven to a logic ‘1’, the LED will be off and there is no current
flow. See Figure 5-1, "System Diagram for CAP1133".
APPLICATION NOTE: This application note applies when the LED polarity is inverted (LEDx_POL = ‘0’). For LED
operation, the duty cycle settings determine the % of time that the LED pin will be driven to
a logic ‘0’ state in. The Max Duty Cycle settings define the maximum % of time that the LED
pin will be driven low (i.e. maximum % of time that the LED is on) while the Min Duty Cycle
settings determine the minimum % of time that the LED pin will be driven low (i.e. minimum
% of time that the LED is on). When there is no touch detected or the LED Output Control
register bit is at a logic ‘0’, the LED output will be driven at the minimum duty cycle setting.
Breathe operations will ramp the duty cycle from the minimum duty cycle to the maximum
duty cycle.
APPLICATION NOTE: This application note applies when the LED polarity is non-inverted (LEDx_POL = ‘1’). For
LED operation, the duty cycle settings determine the % of time that the LED pin will be driven
to a logic ‘1’ state. The Max Duty Cycle settings define the maximum % of time that the LED
pin will be driven high (i.e. maximum % of time that the LED is off) while the Min Duty Cycle
settings determine the minimum % of time that the LED pin will be driven high (i.e. minimum
% of time that the LED is off). When there is no touch detected or the LED Output Control
register bit is at a logic ‘0’, the LED output will be driven at 100 minus the minimum duty
cycle setting. Breathe operations will ramp the duty cycle from 100 minus the minimum duty
cycle to 100 minus the maximum duty cycle.
APPLICATION NOTE: The LED Mirror controls (see Section 6.30, "LED Mirror Control Register") work with the
polarity controls with respect to LED brightness but will not have a direct effect on the output
pin drive.
Bit 2 - LED3_POL - Determines the polarity of the LED3 output.
• ‘0’ (default) - The LED3 output is inverted. For example, a setting of ‘1’ in the LED Output Control register will
cause the LED pin output to be driven to a logic ‘0’.
• ‘1’ - The LED3 output is non-inverted. For example, a setting of ‘1’ in the LED Output Control register will cause
the LED pin output to be driven to a logic ‘1’ or left in the high-z state as determined by its output type
Bit 1 - LED2_POL - Determines the polarity of the LED2 output.
Bit 0 - LED1_POL - Determines the polarity of the LED1 output.
6.28 LED Output Control Register
The LED Output Control Register controls the output state of the LED pins that are not linked to sensor inputs.
TABLE 6-47: LED OUTPUT CONTROL REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
74h R/W LED Output
Control ----- LED3_
DR
LED2_
DR
LED1_
DR 00h
Note: If an LED is linked to a sensor input in the Sensor Input LED Linking Register (Section 6.26, "Sensor Input
LED Linking Register"), the corresponding bit in the LED Output Control Register is ignored (i.e. a linked
LED cannot be host controlled).
CAP1133
DS00001625B-page 40 2015 Microchip Technology Inc.
The LED Polarity Control Register will determine the non actuated state of the LED pins. The actuated LED behavior is
determined by the LED behavior controls (see Section 6.31, "LED Behavior Register").
Table 6-48 shows the interaction between the polarity controls, output controls, and relative brightness.
Bit 2 - LED3_DR - Determines whether LED3 output is driven high or low.
• ‘0’ (default) - The LED3 output is driven at the minimum duty cycle or not actuated.
• ‘1’ - The LED3 output is driven at the maximum duty cycle or is actuated.
Bit 1 - LED2_DR - Determines whether LED2 output is driven high or low.
Bit 0 - LED1_DR - Determines whether LED1 output is driven high or low.
6.29 Linked LED Transition Control Register
The Linked LED Transition Control register controls the LED drive when the LED is linked to a capacitive touch sensor
input. These controls work in conjunction with the INV_LINK_TRAN bit (see Section 6.6.2, "Configuration 2 - 44h") to
create smooth transitions from host control to linked LEDs.
Bit 2 - LED3_LTRAN - Determines the transition effect when LED3 is linked to CS3.
• ‘0’ (default) - When the LED output control bit for LED3 is ‘1’, and then LED3 is linked to CS3 and no touch is
detected, the LED will change states.
• ‘1’ - If the INV_LINK_TRAN bit is ‘1’, when the LED output control bit for CS3 is ‘1’, and then CS3 is linked to LED3
and no touch is detected, the LED will not change states. In addition, the LED state will change when the sensor
pad is touched. If the INV_LINK_TRAN bit is ‘0’, when the LED output control bit for CS3 is ‘1’, and then CS3 is
linked to LED3 and no touch is detected, the LED will not change states. However, the LED state will not change
TABLE 6-48: LED POLARITY BEHAVIOR
LED Output
Control
Register or
Touch
Polarity Max Duty Min Duty Brightness LED Appearance
0 inverted (‘0’) not used
minimum % of time
that the LED is on
(logic 0)
maximum brightness at
min duty cycle
on at min duty
cycle
1 inverted (‘0’)
maximum % of time
that the LED is on
(logic 0)
minimum % of time
that the LED is on
(logic 0)
maximum brightness at
max duty cycle. Brightness
ramps from min
duty cycle to max duty
cycle
according to LED
behavior
0 non-inverted
(‘1’) not used
minimum % of time
that the LED is off
(logic 1)
maximum brightness at
100 minus min duty
cycle.
on at 100 - min
duty cycle
1 non-inverted
(‘1’)
maximum % of time
that the LED is off
(logic 1)
minimum % of time
that the LED is off
(logic 1)
For Direct behavior,
maximum brightness is
100 minus max duty
cycle. When breathing,
max brightness is
100 minus min duty
cycle. Brightness
ramps from 100 - min
duty cycle to 100 - max
duty cycle.
according to LED
behavior
TABLE 6-49: LINKED LED TRANSITION CONTROL REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
77h R/W Linked LED Transition
Control - ---- LED3_
LTRAN
LED2_
LTRAN
LED1_
LTRAN 00h
2015 Microchip Technology Inc. DS00001625B-page 41
CAP1133
when the sensor pad is touched.
APPLICATION NOTE: If the LED behavior is not “Direct” and the INV_LINK_TRAN bit it ‘0’, the LED will not perform
as expected when the LED3_LTRAN bit is set to ‘1’. Therefore, if breathe and pulse
behaviors are used, set the INV_LINK_TRAN bit to ‘1’.
Bit 1 - LED2_LTRAN - Determines the transition effect when LED2 is linked to CS2.
Bit 0 - LED1_LTRAN - Determines the transition effect when LED1 is linked to CS1.
6.30 LED Mirror Control Register
The LED Mirror Control Registers determine the meaning of duty cycle settings when polarity is non-inverted for each
LED channel. When the polarity bit is set to ‘1’ (non-inverted), to obtain correct steps for LED ramping, pulse, and
breathe behaviors, the min and max duty cycles need to be relative to 100%, rather than the default, which is relative
to 0%.
APPLICATION NOTE: The LED drive assumes that the LEDs are configured such that if the LED pin is driven to
a logic ‘0’, the LED will be on and the CAP1133 LED pin is sinking the LED current. When
the polarity bit is set to ‘1’, it is considered non-inverted. For systems using the opposite LED
configuration, mirror controls would apply when the polarity bit is ‘0’.
These bits are changed automatically if the corresponding LED Polarity bit is changed (unless the BLK_POL_MIR bit is
set - see Section 6.6).
Bit 2 - LED3_MIR_EN - Determines whether the duty cycle settings are “biased” relative to 0% or 100% duty cycle.
• ‘0’ (default) - The duty cycle settings are determined relative to 0% and are determined directly with the settings.
• ‘1’ - The duty cycle settings are determined relative to 100%.
Bit 1 - LED2_MIR_EN - Determines whether the duty cycle settings are “biased” relative to 0% or 100% duty cycle.
Bit 0 - LED1_MIR_EN - Determines whether the duty cycle settings are “biased” relative to 0% or 100% duty cycle.
6.31 LED Behavior Register
The LED Behavior register controls the operation of LEDs. Each LED pin is controlled by a 2-bit field and the behavior
is determined by whether the LED is linked to a capacitive touch sensor input or not.
If the corresponding LED output is linked to a capacitive touch sensor input, the appropriate behavior will be enabled /
disabled based on touches and releases.
If the LED output is not associated with a capacitive touch sensor input, the appropriate behavior will be enabled / disabled
by the LED Output Control register. If the respective LEDx_DR bit is set to a logic ‘1’, this will be associated as a
“touch”, and if the LEDx_DR bit is set to a logic ‘0’, this will be associated as a “release”.
Table 6-52, "LEDx_CTL Bit Decode" shows the behavior triggers. The defined behavior will activate when the Start Trigger
is met and will stop when the Stop Trigger is met. Note the behavior of the Breathe Hold and Pulse Release option.
The LED Polarity Control register will determine the non actuated state of the LED outputs (see Section 6.27, "LED
Polarity Register").
APPLICATION NOTE: If an LED is not linked to a capacitive touch sensor input and is breathing (via the Breathe
or Pulse behaviors), it must be unactuated and then re-actuated before changes to behavior
TABLE 6-50: LED MIRROR CONTROL REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
79h R/W LED Mirror Control
-----
LED3_
MIR_
EN
LED2_
MIR _
EN
LED1_
MIR _
EN
00h
TABLE 6-51: LED BEHAVIOR REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
81h R/W LED Behavior 1 - - LED3_CTL[1:0] LED2_CTL[1:0] LED1_CTL[1:0] 00h
CAP1133
DS00001625B-page 42 2015 Microchip Technology Inc.
are processed. For example, if the LED output is breathing and the Maximum duty cycle is
changed, this change will not take effect until the LED output control register is set to ‘0’ and
then re-set to ‘1’.
APPLICATION NOTE: If an LED is not linked to the capacitive touch sensor input and configured to operate using
Pulse 1 Behavior, then the circuitry will only be actuated when the corresponding output
control bit is set. It will not check the bit condition until the Pulse 1 behavior is finished. The
device will not remember if the bit was cleared and reset while it was actuated.
APPLICATION NOTE: If an LED is actuated and not linked and the desired LED behavior is changed, this new
behavior will take effect immediately; however, the first instance of the changed behavior
may act incorrectly (e.g. if changed from Direct to Pulse 1, the LED output may ‘breathe’ 4
times and then end at minimum duty cycle). LED Behaviors will operate normally once the
LED has been un-actuated and then re-actuated.
APPLICATION NOTE: If an LED is actuated and it is switched from linked to a capacitive touch sensor input to
unlinked (or vice versa), the LED will respond to the new command source immediately if
the behavior was Direct or Breathe. For Pulse behaviors, it will complete the behavior
already in progress. For example, if a linked LED was actuated by a touch and the control
is changed so that it is unlinked, it will check the status of the corresponding LED Output
Control bit. If that bit is ‘0’, then the LED will behave as if a release was detected. Likewise,
if an unlinked LED was actuated by the LED Output Control register and the control is
changed so that it is linked and no touch is detected, then the LED will behave as if a release
was detected.
Bits 5 - 4 - LED3_CTL[1:0] - Determines the behavior of LED3 as shown in Table 6-52.
Bits 3 - 2 - LED2_CTL[1:0] - Determines the behavior of LED2 as shown in Table 6-52.
Bits 1 - 0 - LED1_CTL[1:0] - Determines the behavior of LED1 as shown in Table 6-52.
TABLE 6-52: LEDX_CTL BIT DECODE
LEDx_CTL
[1:0] Operation Description Start TRigger Stop Trigger
1 0
0 0 Direct The LED is driven to the programmed state
(active or inactive). See Figure 6-7
Touch Detected or
LED Output Control
bit set
Release
Detected or
LED Output
Control bit
cleared
0 1 Pulse 1
The LED will “Pulse” a programmed number
of times. During each “Pulse” the LED will
breathe up to the maximum brightness and
back down to the minimum brightness so that
the total “Pulse” period matches the programmed
value.
Touch or Release
Detected or LED
Output Control bit
set or cleared
(see Section 6.32)
n/a
1 0 Pulse 2
The LED will “Pulse” when the start trigger is
detected. When the stop trigger is detected, it
will “Pulse” a programmable number of times
then return to its minimum brightness.
Touch Detected or
LED Output Control
bit set
Release
Detected or
LED Output
Control bit
cleared
2015 Microchip Technology Inc. DS00001625B-page 43
CAP1133
APPLICATION NOTE: The PWM frequency is determined based on the selected LED behavior, the programmed
breathe period, and the programmed min and max duty cycles. For the Direct behavior
mode, the PWM frequency is calculated based on the programmed Rise and Fall times. If
these are set at 0, then the maximum PWM frequency will be used based on the
programmed duty cycle settings.
6.32 LED Pulse 1 Period Register
The LED Pulse Period 1 register determines the overall period of a pulse operation as determined by the LED_CTL
registers (see Table 6-52 - setting 01b). The LSB represents 32ms so that a setting of 18h (24d) would represent a
period of 768ms (24 x 32ms = 768ms). The total range is from 32ms to 4.064 seconds as shown in Table 6-54 with the
default being 1024ms.
APPLICATION NOTE: Due to constraints on the LED Drive PWM operation, any Breathe Period less than 160ms
(05h) may not be achievable. The device will breathe at the minimum period possible as
determined by the period and min / max duty cycle settings.
Bit 7 - ST_TRIG - Determines the start trigger for the LED Pulse behavior.
• ‘0’ (default) - The LED will Pulse when a touch is detected or the drive bit is set.
• ‘1’ - The LED will Pulse when a release is detected or the drive bit is cleared.
The Pulse 1 operation is shown in Figure 6-1 when the LED output is configured for non-inverted polarity (LEDx_POL
= 1) and in Figure 6-2 for inverted polarity (LEDx_POL = 0).
1 1 Breathe
The LED will breathe. It will be driven with a
duty cycle that ramps up from the programmed
minimum duty cycle (default 0%) to
the programmed maximum duty cycle duty
cycle (default 100%) and then back down.
Each ramp takes up 50% of the programmed
period. The total period of each “breath” is
determined by the LED Breathe Period controls
- see Section 6.34.
Touch Detected or
LED Output Control
bit set
Release
Detected or
LED Output
Control bit
cleared
TABLE 6-53: LED PULSE 1 PERIOD REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
84h R/W LED Pulse 1
Period
ST_
TRIG
P1_
PER6
P1_
PER5
P1_
PER4
P1_
PER3
P1_
PER2
P1_
PER1
P1_
PER0 20h
TABLE 6-52: LEDX_CTL BIT DECODE (CONTINUED)
LEDx_CTL
[1:0] Operation Description Start TRigger Stop Trigger
1 0
CAP1133
DS00001625B-page 44 2015 Microchip Technology Inc.
.
FIGURE 6-1: Pulse 1 Behavior with Non-Inverted Polarity
FIGURE 6-2: Pulse 1 Behavior with Inverted Polarity
TABLE 6-54: LED PULSE / BREATHE PERIOD EXAMPLE
Setting (HEX) Setting (Decimal) Total Breathe / Pulse Period (MS)
00h 0 32
01h 1 32
02h 2 64
03h 3 96
. . . . . . . . .
7Dh 125 4000
7Eh 126 4032
7Fh 127 4064
Normal – untouched
operation Normal – untouched
operation
Touch Detected or
Release Detected
(100% - Pulse 1 Max Duty Cycle) * Brightness
X pulses after touch or after release
Pulse 1 Period
(P1_PER)
(100% - Pulse 1 Min Duty Cycle) * Brightness
LED
Brightness
Normal – untouched
operation
Normal – untouched
operation
Touch Detected or
Release Detected
Pulse 1 Min Duty Cycle * Brightness
X pulses after touch or after release
Pulse Period
(P1_PER)
Pulse 1 Max Duty Cycle * Brightness
LED
Brightness
2015 Microchip Technology Inc. DS00001625B-page 45
CAP1133
6.33 LED Pulse 2 Period Register
The LED Pulse 2 Period register determines the overall period of a pulse operation as determined by the LED_CTL
registers (see Table 6-52 - setting 10b). The LSB represents 32ms so that a setting of 18h (24d) would represent a
period of 768ms. The total range is from 32ms to 4.064 seconds (see Table 6-54) with a default of 640ms.
APPLICATION NOTE: Due to constraints on the LED Drive PWM operation, any Breathe Period less than 160ms
(05h) may not be achievable. The device will breathe at the minimum period possible as
determined by the period and min / max duty cycle settings.
The Pulse 2 Behavior is shown in Figure 6-3 for non-inverted polarity (LEDx_POL = 1) and in Figure 6-4 for inverted
polarity (LEDx_POL = 0).
TABLE 6-55: LED PULSE 2 PERIOD REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
85h R/W LED Pulse 2
Period - P2_
PER6
P2_
PER5
P2_
PER4
P2_
PER3
P2_
PER2
P2_
PER1
P2_
PER0 14h
FIGURE 6-3: Pulse 2 Behavior with Non-Inverted Polarity
FIGURE 6-4: Pulse 2 Behavior with Inverted Polarity
. . .
Normal – untouched
operation
Normal – untouched
operation
Touch Detected
(100% - Pulse 2 Min Duty Cycle) *
Brightness
(100% - Pulse 2 Max Duty Cycle) * Brightness
X additional pulses after release
Release Detected
Pulse
Period
(P2_PER)
LED
Brightness
Normal – untouched
operation
Normal – untouched
operation
Touch Detected
Pulse 2 Max Duty Cycle * Brightness
Pulse 2 Min Duty Cycle * Brightness
X additional pulses after release
Release Detected
Pulse
Period
(P2_PER)
LED
Brightness . . .
CAP1133
DS00001625B-page 46 2015 Microchip Technology Inc.
6.34 LED Breathe Period Register
The LED Breathe Period register determines the overall period of a breathe operation as determined by the LED_CTL
registers (see Table 6-52 - setting 11b). The LSB represents 32ms so that a setting of 18h (24d) would represent a
period of 768ms. The total range is from 32ms to 4.064 seconds (see Table 6-54) with a default of 2976ms.
APPLICATION NOTE: Due to constraints on the LED Drive PWM operation, any Breathe Period less than 160ms
(05h) may not be achievable. The device will breathe at the minimum period possible as
determined by the period and min / max duty cycle settings.
6.35 LED Configuration Register
The LED Configuration register controls general LED behavior as well as the number of pulses that are sent for the
PULSE LED output behavior.
Bit 6 - RAMP_ALERT - Determines whether the device will assert the ALERT# pin when LEDs actuated by the LED
Output Control register bits have finished their respective behaviors. Interrupts will only be generated if the LED activity
is generated by writing the LED Output Control registers. Any LED activity associated with touch detection will not cause
an interrupt to be generated when the LED behavior has been finished.
• ‘0’ (default) - The ALERT# pin will not be asserted when LEDs actuated by the LED Output Control register have
finished their programmed behaviors.
• ‘1’ - The ALERT# pin will be asserted whenever any LED that is actuated by the LED Output Control register has
finished its programmed behavior.
Bits 5 - 3 - PULSE2_CNT[2:0] - Determines the number of pulses used for the Pulse 2 behavior as shown in Table 6-58.
Bits 2 - 0 - PULSE1_CNT[2:0] - Determines the number of pulses used for the Pulse 1 behavior as shown in Table 6-58.
TABLE 6-56: LED BREATHE PERIOD REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
86h R/W LED Breathe
Period - BR_
PER6
BR_
PER5
BR_
PER4
BR_
PER3
BR_
PER2
BR_
PER1
BR_
PER0 5Dh
TABLE 6-57: LED CONFIGURATION REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
88h R/W LED Config - RAMP_
ALERT PULSE2_CNT[2:0] PULSE1_CNT[2:0] 04h
TABLE 6-58: PULSEX_CNT DECODE
PULSEX_CNT[2:0]
Number of Breaths
21 0
0 0 0 1 (default - Pulse 2)
00 1 2
01 0 3
01 1 4
1 0 0 5 (default - Pulse 1)
10 1 6
11 0 7
11 1 8
2015 Microchip Technology Inc. DS00001625B-page 47
CAP1133
6.36 LED Duty Cycle Registers
The LED Duty Cycle registers determine the minimum and maximum duty cycle settings used for the LED for each LED
behavior. These settings affect the brightness of the LED when it is fully off and fully on.
The LED driver duty cycle will ramp up from the minimum duty cycle to the maximum duty cycle and back down again.
APPLICATION NOTE: When operating in Direct behavior mode, changes to the Duty Cycle settings will be applied
immediately. When operating in Breathe, Pulse 1, or Pulse 2 modes, the LED must be
unactuated and then re-actuated before changes to behavior are processed.
Bits 7 - 4 - X_MAX_DUTY[3:0] - Determines the maximum PWM duty cycle for the LED drivers as shown in Table 6-60.
Bits 3 - 0 - X_MIN_DUTY[3:0] - Determines the minimum PWM duty cycle for the LED drivers as shown in Table 6-60.
6.37 LED Direct Ramp Rates Register
TABLE 6-59: LED DUTY CYCLE REGISTERS
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
90h R/W LED Pulse 1 Duty
Cycle P1_MAX_DUTY[3:0] P1_MIN_DUTY[3:0] F0h
91h R/W LED Pulse 2 Duty
Cycle P2_MAX_DUTY[3:0] P2_MIN_DUTY[3:0] F0h
92h R/W LED Breathe
Duty Cycle BR_MAX_DUTY[3:0] BR_MIN_DUTY[3:0] F0h
93h R/W Direct Duty Cycle DR_MAX_DUTY[3:0] DR_MIN_DUTY[3:0] F0h
TABLE 6-60: LED DUTY CYCLE DECODE
x_MAX/MIN_Duty [3:0]
Maximum Duty Cycle Minimum Duty Cycle
3 21 0
0 0 0 0 7% 0%
0 0 0 1 9% 7%
0 0 1 0 11% 9%
0 0 1 1 14% 11%
0 1 0 0 17% 14%
0 1 0 1 20% 17%
0 1 1 0 23% 20%
0 1 1 1 26% 23%
1 0 0 0 30% 26%
1 0 0 1 35% 30%
1 0 1 0 40% 35%
1 0 1 1 46% 40%
1 1 0 0 53% 46%
1 1 0 1 63% 53%
1 1 1 0 77% 63%
1 1 1 1 100% 77%
TABLE 6-61: LED DIRECT RAMP RATES REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
94h R/W LED Direct Ramp
Rates - - RISE_RATE[2:0] FALL_RATE[2:0] 00h
CAP1133
DS00001625B-page 48 2015 Microchip Technology Inc.
The LED Direct Ramp Rates register control the rising and falling edge time of an LED that is configured to operate in
Direct behavior mode. The rising edge time corresponds to the amount of time the LED takes to transition from its minimum
duty cycle to its maximum duty cycle. Conversely, the falling edge time corresponds to the amount of time that
the LED takes to transition from its maximum duty cycle to its minimum duty cycle.
Bits 5 - 3 - RISE_RATE[2:0] - Determines the rising edge time of an LED when it transitions from its minimum drive state
to its maximum drive state as shown in Table 6-62.
Bits 2 - 0 - FALL_RATE[2:0] - Determines the falling edge time of an LED when it transitions from its maximum drive
state to its minimum drive state as shown in Table 6-62.
6.38 LED Off Delay Register
The LED Off Delay register determines the amount of time that an LED remains at its maximum duty cycle (or minimum
as determined by the polarity controls) before it starts to ramp down. If the LED is operating in Breathe mode, this delay
is applied at the top of each “breath”. If the LED is operating in the Direct mode, this delay is applied when the LED is
unactuated.
Bits 6 - 4 - BR_OFF_DLY[2:0] - Determines the Breathe behavior mode off delay, which is the amount of time an LED
in Breathe behavior mode remains inactive after it finishes a breathe pulse (ramp on and ramp off), as shown in Figure 6-
5 (non-inverted polarity LEDx_POL = 1) and Figure 6-6 (inverted polarity LEDx_POL = 0). Available settings are shown
in Table 6-64.
TABLE 6-62: RISE / FALL RATE DECODE
RISE_RATE/ FALL_RATE/ Bit Decode
Rise / Fall Time (TRISE / TFALL)
21 0
00 0 0
0 0 1 250ms
0 1 0 500ms
0 1 1 750ms
1 0 0 1s
1 0 1 1.25s
1 1 0 1.5s
1 1 1 2s
TABLE 6-63: LED OFF DELAY REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
95h R/W LED Off Delay
Register - BR_OFF_DLY[2:0] DIR_OFF_DLY[3:0] 00h
2015 Microchip Technology Inc. DS00001625B-page 49
CAP1133
FIGURE 6-5: Breathe Behavior with Non-Inverted Polarity
FIGURE 6-6: Breathe Behavior with Inverted Polarity
TABLE 6-64: BREATHE OFF DELAY SETTINGS
BR_OFF_DLY [2:0]
OFF Delay
2 10
0 0 0 0 (default)
0 0 1 0.25s
0 1 0 0.5s
0 1 1 0.75s
LED Actuated
100% - Breathe Max Min Cycle * Brightness
100% - Breathe Min Duty Cycle *
Brightness
LED Unactuated
Breathe Off
Delay
(BR_OFF_DLY)
LED
Brightness
Breathe
Period
(BR_PER)
LED Actuated
Breathe Max Duty Cycle * Brightness
Breathe Min Duty Cycle * Brightness
LED Unactuated
Breathe Off
Delay
(BR_OFF_DLY)
LED
Brightness
Breathe
Period
(BR_PER)
CAP1133
DS00001625B-page 50 2015 Microchip Technology Inc.
Bits 3 - 0 - DIR_OFF_DLY[3:0] - Determines the turn-off delay, as shown in Table 6-65, for all LEDs that are configured
to operate in Direct behavior mode.
The Direct behavior operation is determined by the combination of programmed Rise Time, Fall Time, Min and Max Duty
cycles, Off Delay, and polarity. Figure 6-7 shows the behavior for non-inverted polarity (LEDx_POL = 1) while Figure 6-
8 shows the behavior for inverted polarity (LEDx_POL = 0).
1 0 0 1.0s
1 0 1 1.25s
1 1 0 1.5s
1 1 1 2.0s
FIGURE 6-7: Direct Behavior for Non-Inverted Polarity
FIGURE 6-8: Direct Behavior for Inverted Polarity
TABLE 6-65: OFF DELAY DECODE
OFF Delay[3:0] Bit Decode
OFF Delay (tOFF_DLY)
32 1 0
00 0 0 0
0 0 0 1 250ms
0 0 1 0 500ms
0 0 1 1 750ms
TABLE 6-64: BREATHE OFF DELAY SETTINGS (CONTINUED)
BR_OFF_DLY [2:0]
OFF Delay
2 10
Normal –
untouched
operation
RISE_RATE
Setting (tRISE)
(100% - Max Duty
Cycle) * Brightness
Touch
Detected
Release
Detected
Off Delay
(tOFF_DLY)
FALL_RATE
Setting (tFALL)
Normal –
untouched
operation
(100% - Min Duty Cycle) *
Brightness LED
Brightness
Normal –
untouched
operation RISE_RATE
Setting (tRISE)
Min Duty Cycle * Brightness
Touch
Detected
Release
Detected
Off Delay
(tOFF_DLY)
FALL_RATE
Setting (tFALL)
Normal –
untouched
operation
Max Duty Cycle * Brightness
LED
Brightness
2015 Microchip Technology Inc. DS00001625B-page 51
CAP1133
6.39 Sensor Input Calibration Registers
The Sensor Input Calibration registers hold the 10-bit value that represents the last calibration value.
6.40 Product ID Register
The Product ID register stores a unique 8-bit value that identifies the device.
6.41 Manufacturer ID Register
The Vendor ID register stores an 8-bit value that represents Microchip.
0 1 0 0 1s
0 1 0 1 1.25s
0 1 1 0 1.5s
0 1 1 1 2s
1 0 0 0 2.5s
1 0 0 1 3.0s
1 0 1 0 3.5s
1 0 1 1 4.0s
1 1 0 0 4.5s
All others 5.0s
TABLE 6-66: SENSOR INPUT CALIBRATION REGISTERS
ADDR Register R/W B7 B6 B5 B4 B3 B2 B1 B0 Default
B1h Sensor Input 1
Calibration R CAL1_9 CAL1_8 CAL1_7 CAL1_6 CAL1_5 CAL1_4 CAL1_3 CAL1_2 00h
B2h Sensor Input 2
Calibration R CAL2_9 CAL2_8 CAL2_7 CAL2_6 CAL2_5 CAL2_4 CAL2_3 CAL2_2 00h
B3h Sensor Input 3
Calibration R CAL3_9 CAL3_8 CAL3_7 CAL3_6 CAL3_5 CAL3_4 CAL3_3 CAL3_2 00h
B9h
Sensor Input
Calibration LSB
1
R - - CAL3_1 CAL3_0 CAL2_1 CAL2_0 CAL1_1 CAL1_0 00h
TABLE 6-67: PRODUCT ID REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
FDh R Product ID 0 1 0 1 0 1 0 0 54h
TABLE 6-68: VENDOR ID REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
FEh R Manufacturer ID 0 1 0 1 1 1 0 1 5Dh
TABLE 6-65: OFF DELAY DECODE (CONTINUED)
OFF Delay[3:0] Bit Decode
OFF Delay (tOFF_DLY)
32 1 0
CAP1133
DS00001625B-page 52 2015 Microchip Technology Inc.
6.42 Revision Register
The Revision register stores an 8-bit value that represents the part revision.
TABLE 6-69: REVISION REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
FFh R Revision 1 0 0 0 0 0 1 1 83h
2015 Microchip Technology Inc. DS00001625B-page 53
CAP1133
7.0 PACKAGE INFORMATION
7.1 CAP1133 Package Drawings
FIGURE 7-1: 10-Pin DFN 3mm x 3mm Package Drawings (1 of 2)
Note: For the most current package drawings,
see the Microchip Packaging Specification at
http://www.microchip.com/packaging
CAP1133
DS00001625B-page 54 2015 Microchip Technology Inc.
FIGURE 7-2: 10-Pin DFN 3mm x 3mm Package Drawings (2 of 2)
Note: For the most current package drawings,
see the Microchip Packaging Specification at
http://www.microchip.com/packaging
2015 Microchip Technology Inc. DS00001625B-page 55
CAP1133
7.2 Package Marking
FIGURE 7-3: CAP1133 Package Marking
1 A W
NNNA
e4
TOP
BOTTOM
Bottom marking not allowed
PB-FREE/GREEN SYMBOL
PIN 1 (Ni/Pd PP-LF)
Line 1 – Device Code, Week 2x 0.6
Line 2 – Alphanumeric Traceability Code
W
Lines 1-2:
Line 3:
Center Horizontal Alignment
As Shown
CAP1133
DS00001625B-page 56 2015 Microchip Technology Inc.
APPENDIX A: DEVICE DELTA
A.1 Delta from CAP1033 to CAP1133
1. Updated circuitry to improve power supply rejection.
2. Updated LED driver duty cycle decode values to have more distribution at lower values - closer to a logarithmic
curve. See Table 6-60, "LED Duty Cycle Decode".
3. Updated bug that breathe periods were not correct above 2.6s. This includes rise / fall time decodes above 1.5s.
4. Added 1 bit to the LED Off Delay register (see Section 6.38, "LED Off Delay Register") to extend times from 2s
to 5s in 0.5s intervals.
5. Breathe behavior modified. A breathe off delay control was added to the LED Off Delay Register (see Section
6.38, "LED Off Delay Register") so the LEDs can be configured to remain inactive between breathes.
6. Added controls for the LED transition effects when linking LEDs to capacitive sensor inputs. See Section 6.29,
"Linked LED Transition Control Register".
7. Added controls to “mirror” the LED duty cycle outputs so that when polarity changes, the LED brightness levels
look right. These bits are automatically set when polarity is set. Added control to break this auto-set behavior.
See Section 6.30, "LED Mirror Control Register".
8. Added Multiple Touch Pattern detection circuitry. See Section 6.15, "Multiple Touch Pattern Configuration Register".
9. Added General Status register to flag Multiple touches, Multiple Touch Pattern issues and general touch detections.
See Section 6.2, "Status Registers".
10. Added bits 6 and 5 to the Recalibration Configuration register (2Fh - see Section 6.17, "Recalibration Configuration
Register"). These bits control whether the accumulation of intermediate data and the consecutive negative
delta counts counter are cleared when the noise status bit is set.
11. Added Configuration 2 register for LED linking controls, noise detection controls, and control to interrupt on press
but not on release. Added control to change alert pin polarity. See Section 6.6, "Configuration Registers".
12. Updated Deep Sleep behavior so that device does not clear DSLEEP bit on received communications but will
wake to communicate.
13. Changed PWM frequency for LED drivers. The PWM frequency was derived from the programmed breathe
period and duty cycle settings and it ranged from ~4Hz to ~8000 Hz. The PWM frequency has been updated to
be a fixed value of ~2000Hz.
14. Register delta:
Table A.1 Register Delta From CAP1033 to CAP1133
Address Register Delta Delta Default
00h
Page 21
Changed - Main Status /
Control
added bits 7-6 to control gain 00h
02h
Page 22
New - General Status new register to store MTP, MULT, LED, and
general TOUCH bits
00h
44h
Page 25
New - Configuration 2 new register to control alert polarity, LED
touch linking behavior, LED output behavior,
and noise detection, and interrupt on
release
40h
24h
Page 28
Changed - Averaging
Control
updated register bits - moved
SAMP_AVG[2:0] bits and added SAMP_-
TIME bit 1. Default changed
39h
2Bh
Page 31
New - Multiple Touch
Pattern Configuration
new register for Multiple Touch Pattern
configuration - enable and threshold settings
80h
2Dh
Page 32
New - Multiple Touch
Pattern Register
new register for Multiple Touch Pattern
detection circuitry - pattern or number of
sensor inputs
07h
2015 Microchip Technology Inc. DS00001625B-page 57
CAP1133
2Fh
Page 33
Changed - Recalibration
Configuration
updated register - updated CAL_CFG bit
decode to add a 128 averages setting and
removed highest time setting. Default
changed. Added bit 6 NO_CLR_INTD and
bit 5 NO_CLR_NEG.
8Ah
38h
Page 34
Changed - Sensor Input
Noise Threshold
updated register bits - removed bits 7 - 3
and consolidated all controls into bits 1 - 0.
These bits will set the noise threshold for
all channels. Default changed
01h
39h Removed - Noise
Threshold Register 2
removed register n/a
41h
Page 35
Changed - Standby Configuration
updated register bits - moved
STBY_AVG[2:0] bits and added STBY_-
TIME bit 1. Default changed
39h
77h
Page 40
New - Linked LED Transition
Control
new register to control transition effect
when LED linked to sensor inputs
00h
79h
Page 41
New - LED Mirror Control new register to control LED output mirroring
for brightness control when polarity
changed
00h
90h
Page 47
Changed - LED Pulse 1
Duty Cycle
changed bit decode to be more logarithmic F0h
91h
Page 47
Changed - LED Pulse 2
Duty Cycle
changed bit decode to be more logarithmic F0h
92h
Page 47
Changed - LED Breathe
Duty Cycle
changed bit decode to be more logarithmic F0h
93h
Page 47
Changed - LED Direct
Duty Cycle
changed bit decode to be more logarithmic F0h
95h Added controls - LED Off
Delay
Added bits 6-4 BR_OFF_DLY[2:0]
Added bit 3 DIR_OFF_DLY[3]
00h
FDh
Page 51
Changed - Product ID Changed bit decode for CAP1133 54h
Table A.1 Register Delta From CAP1033 to CAP1133 (continued)
Address Register Delta Delta Default
CAP1133
DS00001625B-page 58 2015 Microchip Technology Inc.
APPENDIX B: DATA SHEET REVISION HISTORY
Revision Section/Figure/Entry Correction
DS00001625B (02-09-15)
Features, Table 2-2, Table 2-
2, "Pin Types", Section 5.0,
"General Description"
References to BC-Link Interface, BC_DATA, BC_-
CLK, BC-IRQ#, BC-Link bus have been removed
Application Note under Table
2-6
[BC-Link] hidden in data sheet
Table 3-2, "Electrical Specifications"
BC-Link Timing Section hidden in data sheet
Table 4-1 Protocol Used for 68K Pull Down Resistor changed
from “BC-Link Communications” to “Reserved”
Section 4.2.2, "SMBus
Address and RD / WR Bit"
Replaced “client address” with “slave address” in this
section.
Section 4.2.4, SMBus ACK
and NACK Bits, Section 4.2.5,
SMBus Stop Bit,Section 4.2.7,
SMBus and I2C Compatibility
Replaced “client” with “slave” in these sections.
Table 4-3, "Read Byte Protocol"
Heading changed from “Client Address” to “Slave
Address”
Table 6-1 Register Name for Register Address 77h changed
from “LED Linked Transition Control” to “Linked LED
Transition Control”
Section 6.30 changed CS3 to LED3
Section 7.7 Package Marking Updated package drawing
Appendix A: Device Delta changed 2Dh to 2Fh in item #12
Product Identification System Removed BC-Link references
REV A REV A replaces previous SMSC version Rev. 1.32 (01-05-12)
Rev. 1.32 (01-05-12) Table 3-2, "Electrical Specifications"
Added conditions for tHD:DAT.
Section 4.2.7, "SMBus and
I2C Compatibility"
Renamed from “SMBus and I2C Compliance.”
First paragraph, added last sentence: “For information
on using the CAP1188 in an I2C system, refer to
SMSC AN 14.0 SMSC Dedicated Slave Devices in
I
2C Systems.”
Added: CAP1188 supports I2C fast mode at 400kHz.
This covers the SMBus max time of 100kHz.
Section 6.4, "Sensor Input
Delta Count Registers"
Changed negative value cap from FFh to 80h.
Rev. 1.31 (08-18-11) Section 4.3.3, "SMBus Send
Byte"
Added an application note: The Send Byte protocol
is not functional in Deep Sleep (i.e., DSLEEP bit is
set).
Section 4.3.4, "SMBus
Receive Byte"
Added an application note: The Receive Byte protocol
is not functional in Deep Sleep (i.e., DSLEEP bit
is set).
Section 6.2, "Status Registers"
Removed RESET as bit 3 in register 02h.
Rev. 1.3 (05-18-11) Section 6.42, "Revision Register"
Updated revision ID from 82h to 83h.
Section 6.2, "Status Registers"
Added RESET as bit 3 in register 02h.
2015 Microchip Technology Inc. DS00001625B-page 59
CAP1133
Rev. 1.2 (02-10-11) Section A.8, "Delta from Rev
B (Mask B0) to Rev C (Mask
B1)"
Added.
Table 3-2, "Electrical Specifications"
PSR improvements made in functional revision B.
Changed PSR spec from ±100 typ and ±200 max
counts / V to ±3 and ±10 counts / V. Conditions
updated.
Section 5.3.2, "Recalibrating
Sensor Inputs"
Added more detail with subheadings for each type of
recalibration.
Section 6.6, "Configuration
Registers"
Added bit 5 BLK_PWR_CTRL to the Configuration 2
Register 44h.
The TIMEOUT bit is set to ‘1’ by default for functional
revision B and is set to ‘0’ by default for functional
revision C.
Section 6.42, "Revision Register"
Updated revision ID in register FFh from 81h to 82h.
Rev. 1.1 (11-17-10) Document Updated for functional revision B. See Section A.7,
"Delta from Rev A (Mask A0) to Rev B (Mask B0)".
Cover Added to General Description: “includes circuitry and
support for enhanced sensor proximity detection.”
Added the following Features:
Calibrates for Parasitic Capacitance
Analog Filtering for System Noise Sources
Press and Hold feature for Volume-like Applications
Table 3-2, "Electrical Specifications"
Conditions for Power Supply Rejection modified adding
the following:
Sampling time = 2.56ms
Averaging = 1
Negative Delta Counts = Disabled
All other parameters default
Section 6.11, "Calibration Activate
Register"
Updated register description to indicate which re-calibration
routine is used.
Section 6.14, "Multiple Touch
Configuration Register"
Updated register description to indicate what will
happen.
Table 6-34, "CSx_BN_TH Bit
Decode"
Table heading changed from “Threshold Divide Setting”
to “Percent Threshold Setting”.
Rev. 1.0 (06-14-10) Initial release
Revision Section/Figure/Entry Correction
CAP1133
DS00001625B-page 60 2015 Microchip Technology Inc.
THE MICROCHIP WEB SITE
Microchip provides online support via our WWW site at www.microchip.com. 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 (FAQ), 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
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. Under “Support”, click on “Customer Change Notification”
and follow the registration instructions.
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://www.microchip.com/support
2015 Microchip Technology Inc. DS00001625B-page 61
CAP1133
PRODUCT IDENTIFICATION SYSTEM
To order or obtain information, e.g., on pricing or delivery, refer to the factory or the listed sales office.
PART NO. [X] - [X] - XXX - [X](1)
l l l l l
Device Temperature Addressing Package Tape and Reel
Range Option Option
Example:
Note 1: Tape and Reel identifier only appears in the catalog part number description. This identifier is used for ordering
purposes and is not printed on the device package. Check with your Microchip Sales Office for package availability
with the Tape and Reel option.
Device: CAP1133
Temperature
Range:
Blank = 0°C to +85°C (Extended Commercial)
Package: AIA = DFN
Tape and
Reel Option:
TR = Tape and Reel(1)
CAP1133-1-AIA-TR
10-pin DFN 3mm x 3mm (RoHS compliant)
Three capacitive touch sensor inputs, Three
LED drivers, SMBus interface
Reel size is 4,000 pieces
CAP1133
DS00001625B-page 62 2015 Microchip Technology Inc.
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, FlashFlex, flexPWR, JukeBlox, KEELOQ, KEELOQ logo, Kleer, LANCheck,
MediaLB, MOST, MOST logo, MPLAB, OptoLyzer, PIC, PICSTART, PIC32 logo, RightTouch, SpyNIC, SST, SST Logo, SuperFlash and
UNI/O are registered trademarks of Microchip Technology Incorporated in the U.S.A. and other countries.
The Embedded Control Solutions Company and mTouch are registered trademarks of Microchip Technology Incorporated in the U.S.A.
Analog-for-the-Digital Age, BodyCom, chipKIT, chipKIT logo, CodeGuard, dsPICDEM, dsPICDEM.net, ECAN, In-Circuit Serial
Programming, ICSP, Inter-Chip Connectivity, KleerNet, KleerNet logo, MiWi, MPASM, MPF, MPLAB Certified logo, MPLIB, MPLINK,
MultiTRAK, NetDetach, Omniscient Code Generation, PICDEM, PICDEM.net, PICkit, PICtail, RightTouch logo, REAL ICE, SQI, Serial
Quad I/O, Total Endurance, TSHARC, USBCheck, VariSense, ViewSpan, WiperLock, Wireless DNA, 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.
Silicon Storage Technology is a registered trademark of Microchip Technology Inc. in other countries.
GestIC is a registered trademarks of Microchip Technology Germany II GmbH & Co. KG, a subsidiary of Microchip Technology Inc., in
other countries.
All other trademarks mentioned herein are property of their respective companies.
© 2015, Microchip Technology Incorporated, Printed in the U.S.A., All Rights Reserved.
ISBN: 978632770356
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.
QUALITY MANAGEMENT SYSTEM
CERTIFIED BY DNV
== ISO/TS 16949 ==
2015 Microchip Technology Inc. DS00001625B-page 63
AMERICAS
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
Atlanta
Duluth, GA
Tel: 678-957-9614
Fax: 678-957-1455
Austin, TX
Tel: 512-257-3370
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
Novi, MI
Tel: 248-848-4000
Houston, TX
Tel: 281-894-5983
Indianapolis
Noblesville, IN
Tel: 317-773-8323
Fax: 317-773-5453
Los Angeles
Mission Viejo, CA
Tel: 949-462-9523
Fax: 949-462-9608
New York, NY
Tel: 631-435-6000
San Jose, CA
Tel: 408-735-9110
Canada - Toronto
Tel: 905-673-0699
Fax: 905-673-6509
ASIA/PACIFIC
Asia Pacific Office
Suites 3707-14, 37th Floor
Tower 6, The Gateway
Harbour City, Kowloon
Hong Kong
Tel: 852-2943-5100
Fax: 852-2401-3431
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
China - Dongguan
Tel: 86-769-8702-9880
China - Hangzhou
Tel: 86-571-8792-8115
Fax: 86-571-8792-8116
China - Hong Kong SAR
Tel: 852-2943-5100
Fax: 852-2401-3431
China - Nanjing
Tel: 86-25-8473-2460
Fax: 86-25-8473-2470
China - Qingdao
Tel: 86-532-8502-7355
Fax: 86-532-8502-7205
China - Shanghai
Tel: 86-21-5407-5533
Fax: 86-21-5407-5066
China - Shenyang
Tel: 86-24-2334-2829
Fax: 86-24-2334-2393
China - Shenzhen
Tel: 86-755-8864-2200
Fax: 86-755-8203-1760
China - Wuhan
Tel: 86-27-5980-5300
Fax: 86-27-5980-5118
China - Xian
Tel: 86-29-8833-7252
Fax: 86-29-8833-7256
ASIA/PACIFIC
China - Xiamen
Tel: 86-592-2388138
Fax: 86-592-2388130
China - Zhuhai
Tel: 86-756-3210040
Fax: 86-756-3210049
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
India - Pune
Tel: 91-20-3019-1500
Japan - Osaka
Tel: 81-6-6152-7160
Fax: 81-6-6152-9310
Japan - Tokyo
Tel: 81-3-6880- 3770
Fax: 81-3-6880-3771
Korea - Daegu
Tel: 82-53-744-4301
Fax: 82-53-744-4302
Korea - Seoul
Tel: 82-2-554-7200
Fax: 82-2-558-5932 or
82-2-558-5934
Malaysia - Kuala Lumpur
Tel: 60-3-6201-9857
Fax: 60-3-6201-9859
Malaysia - Penang
Tel: 60-4-227-8870
Fax: 60-4-227-4068
Philippines - Manila
Tel: 63-2-634-9065
Fax: 63-2-634-9069
Singapore
Tel: 65-6334-8870
Fax: 65-6334-8850
Taiwan - Hsin Chu
Tel: 886-3-5778-366
Fax: 886-3-5770-955
Taiwan - Kaohsiung
Tel: 886-7-213-7828
Taiwan - Taipei
Tel: 886-2-2508-8600
Fax: 886-2-2508-0102
Thailand - Bangkok
Tel: 66-2-694-1351
Fax: 66-2-694-1350
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
Fax: 33-1-69-30-90-79
Germany - Dusseldorf
Tel: 49-2129-3766400
Germany - Munich
Tel: 49-89-627-144-0
Fax: 49-89-627-144-44
Germany - Pforzheim
Tel: 49-7231-424750
Italy - Milan
Tel: 39-0331-742611
Fax: 39-0331-466781
Italy - Venice
Tel: 39-049-7625286
Netherlands - Drunen
Tel: 31-416-690399
Fax: 31-416-690340
Poland - Warsaw
Tel: 48-22-3325737
Spain - Madrid
Tel: 34-91-708-08-90
Fax: 34-91-708-08-91
Sweden - Stockholm
Tel: 46-8-5090-4654
UK - Wokingham
Tel: 44-118-921-5800
Fax: 44-118-921-5820
Worldwide Sales and Service
01/27/15
2015 Microchip Technology Inc. DS00001624B-page 1
General Description
The CAP1106, which incorporates RightTouch® technology,
is a multiple channel Capacitive Touch sensor.
The CAP1106 contains six (6) individual capacitive
touch sensor inputs. The device offers programmable
sensitivity for use in touch sensor applications. Each
sensor input automatically recalibrates to compensate
for gradual environmental changes.
The CAP1106 includes Multiple Pattern Touch recognition
that allows the user to select a specific set of buttons
to be touched simultaneously. If this pattern is
detected, then a status bit is set and an interrupt generated.
Additionally, the CAP1106 includes circuitry and support
for enhanced sensor proximity detection.
The CAP1106 offers multiple power states operating at
low quiescent currents. In the Standby state of operation,
one or more capacitive touch sensor inputs are
active.
Deep Sleep is the lowest power state available, drawing
5uA (typical) of current. In this state, no sensor
inputs are active. Communications will wake the
device.
Applications
• Desktop and Notebook PCs
• LCD Monitors
• Consumer Electronics
• Appliances
Features
• Six (6) Capacitive Touch Sensor Inputs -
CAP1106
- Programmable sensitivity
- Automatic recalibration
- Individual thresholds for each button
• Proximity Detection
• Multiple Button Pattern Detection
• Calibrates for Parasitic Capacitance
• Analog Filtering for System Noise Sources
• Press and Hold feature for Volume-like Applications
• Multiple Communication Interfaces
- SMBus / I2C compliant interface
• Low Power Operation
- 5uA quiescent current in Deep Sleep
- 50uA quiescent current in Standby (1 sensor
input monitored)
- Samples one or more channels in Standby
• Available in 10-pin 3mm x 3mm RoHS compliant
DFN package
CAP1106
6 Channel Capacitive Touch Sensor
CAP1106
DS00001624B-page 2 2015 Microchip Technology Inc.
TO OUR VALUED CUSTOMERS
It is our intention to provide our valued customers with the best documentation possible to ensure successful use of your Microchip
products. To this end, we will continue to improve our publications to better suit your needs. Our publications will be refined and
enhanced as new volumes and updates are introduced.
If you have any questions or comments regarding this publication, please contact the Marketing Communications Department via
E-mail at docerrors@microchip.com. We welcome your feedback.
Most Current Data Sheet
To obtain the most up-to-date version of this data sheet, please register at our Worldwide Web site at:
http://www.microchip.com
You can determine the version of a data sheet by examining its literature number found on the bottom outside corner of any page.
The last character of the literature number is the version number, (e.g., DS30000000A is version A of document DS30000000).
Errata
An errata sheet, describing minor operational differences from the data sheet and recommended workarounds, may exist for current
devices. As device/documentation issues become known to us, we will publish an errata sheet. The errata will specify the
revision of silicon and revision of document to which it applies.
To determine if an errata sheet exists for a particular device, please check with one of the following:
• Microchip’s Worldwide Web site; http://www.microchip.com
• Your local Microchip sales office (see last page)
When contacting a sales office, please specify which device, revision of silicon and data sheet (include -literature number) you are
using.
Customer Notification System
Register on our web site at www.microchip.com to receive the most current information on all of our products.
2015 Microchip Technology Inc. DS00001624B-page 3
CAP1106
Table of Contents
1.0 Block Diagram ................................................................................................................................................................................. 4
2.0 Pin Description ................................................................................................................................................................................ 5
3.0 Electrical Specifications .................................................................................................................................................................. 9
4.0 Communications ........................................................................................................................................................................... 12
5.0 General Description ...................................................................................................................................................................... 23
6.0 Register Description ...................................................................................................................................................................... 29
7.0 Package Information ..................................................................................................................................................................... 67
Appendix A: Device Delta ................................................................................................................................................................... 72
Appendix B: Data Sheet Revision History ........................................................................................................................................... 74
The Microchip Web Site ...................................................................................................................................................................... 76
Customer Change Notification Service ............................................................................................................................................... 76
Customer Support ............................................................................................................................................................................... 76
Product Identification System ............................................................................................................................................................. 77
CAP1106
DS00001624B-page 4 2015 Microchip Technology Inc.
1.0 BLOCK DIAGRAM
SMBus /
BC-Link
Protocol
VDD GND
Capacitive Touch Sensing Algorithm
CS1 CS2 CS3 CS4 CS5
SMCLK1
/ BC_CLK2
SMDATA1
/ BC_DATA2
ALERT#1
/ BC_IRQ#2
1
= CAP1106-1
2
= CAP1106-2 CS6
2015 Microchip Technology Inc. DS00001624B-page 5
CAP1106
2.0 PIN DESCRIPTION
FIGURE 2-1: CAP1106 Pin Diagram (10-Pin DFN)
TABLE 2-1: PIN DESCRIPTION FOR CAP1106
Pin
Number Pin Name Pin Function Pin Type Unused
Connection
1 CS1 Capacitive Touch Sensor Input 1 AIO Connect to
Ground
2 ALERT#
ALERT# - Active low alert / interrupt output for SMBus
alert OD (5V) Connect to
Ground
ALERT# - Active high alert / interrupt output for SMBus
alert DO leave open
3 SMDATA SMDATA - Bi-directional, open-drain SMBus data -
requires pull-up resistor DIOD (5V) n/a
4 SMCLK SMCLK - SMBus clock input - requires pull-up resistor DI (5V) n/a
5 VDD Positive Power supply Power n/a
6 CS6 Capacitive Touch Sensor Input 6 AIO Connect to
Ground
7 CS5 Capacitive Touch Sensor Input 5 AIO Connect to
Ground
8 CS4 Capacitive Touch Sensor Input 4 AIO Connect to
Ground
9 CS3 Capacitive Touch Sensor Input 3 AIO Connect to
Ground
GND
CS3
1 CS2
2
3
4
5
CS4
CS1
ALERT# / BC_IRQ#
SMDATA / BC_DATA
VDD
SMCLK / BC_CLK CS5
CS6
CAP1106
3mm x 3mm DFN
10
9
8
7
6
CAP1106
DS00001624B-page 6 2015 Microchip Technology Inc.
APPLICATION NOTE: When the ALERT# pin is configured as an active low output, it will be open drain. When it
is configured as an active high output, it will be push-pull.
APPLICATION NOTE: For the 5V tolerant pins that have a pull-up resistor, the pull-up voltage must not exceed 3.6V
when the CAP1106 is unpowered.
The pin types are described in Table 2-2. All pins labeled with (5V) are 5V tolerant.
10 CS2 Capacitive Touch Sensor Input 2 AIO Connect to
Ground
Bottom
Pad GND Ground Power n/a
TABLE 2-2: PIN TYPES
Pin Type Description
Power This pin is used to supply power or ground to the device.
DI Digital Input - This pin is used as a digital input. This pin is 5V tolerant.
AIO Analog Input / Output -This pin is used as an I/O for analog signals.
DIOD Digital Input / Open Drain Output - This pin is used as a digital I/O. When it is used as an output,
it is open drain and requires a pull-up resistor. This pin is 5V tolerant.
OD Open Drain Digital Output - This pin is used as a digital output. It is open drain and requires a
pull-up resistor. This pin is 5V tolerant.
DO Push-pull Digital Output - This pin is used as a digital output and can sink and source current.
DIO Push-pull Digital Input / Output - This pin is used as an I/O for digital signals.
TABLE 2-1: PIN DESCRIPTION FOR CAP1106 (CONTINUED)
Pin
Number Pin Name Pin Function Pin Type Unused
Connection
2015 Microchip Technology Inc. DS00001624B-page 7
CAP1106
3.0 ELECTRICAL SPECIFICATIONS
Note 3-1 Stresses above those listed could cause permanent damage to the device. This is a stress rating
only and functional operation of the device at any other condition above those indicated in the
operation sections of this specification is not implied.
Note 3-2 For the 5V tolerant pins that have a pull-up resistor, the voltage difference between V5VT_PIN and VDD
must never exceed 3.6V.
Note 3-3 The Package Power Dissipation specification assumes a recommended thermal via design consisting
of a 2x2 matrix of 0.3mm (12mil) vias at 1.0mm pitch connected to the ground plane with a 1.6 x
2.3mm thermal landing.
TABLE 3-1: ABSOLUTE MAXIMUM RATINGS
Voltage on 5V tolerant pins (V5VT_PIN) -0.3 to 5.5 V
Voltage on 5V tolerant pins (|V5VT_PIN - VDD|) Note 3-2 0 to 3.6 V
Voltage on VDD pin -0.3 to 4 V
Voltage on any other pin to GND -0.3 to VDD + 0.3 V
Package Power Dissipation up to TA = 85°C for 10 pin DFN
(see Note 3-3)
0.7 W
Junction to Ambient (θJA) 77.7 °C/W
Operating Ambient Temperature Range -40 to 125 °C
Storage Temperature Range -55 to 150 °C
ESD Rating, All Pins, HBM 8000 V
CAP1106
DS00001624B-page 8 2015 Microchip Technology Inc.
TABLE 3-2: ELECTRICAL SPECIFICATIONS
VDD = 3V to 3.6V, TA = 0°C to 85°C, all typical values at TA = 27°C unless otherwise noted.
Characteristic Symbol Min Typ Max Unit Conditions
DC Power
Supply Voltage VDD 3.0 3.3 3.6 V
Supply Current
ISTBY 120 170 uA
Standby state active
1 sensor input monitored
Default conditions (8 avg, 70ms
cycle time)
ISTBY 50 uA
Standby state active
1 sensor input monitored
1 avg, 140ms cycle time,
IDSLEEP 5 15 uA
Deep Sleep state active
No communications
TA < 40°C
3.135 < VDD < 3.465V
IDD 500 600 uA Capacitive Sensing Active
Capacitive Touch Sensor Inputs
Maximum Base
Capacitance CBASE 50 pF Pad untouched
Minimum Detectable
Capacitive Shift ΔCTOUCH 20 fF
Pad touched - default conditions (1
avg, 35ms cycle time, 1x sensitivity)
Recommended Cap
Shift ΔCTOUCH 0.1 2 pF Pad touched - Not tested
Power Supply Rejection
PSR ±3 ±10 counts /
V
Untouched Current Counts
Base Capacitance 5pF - 50pF
Maximum sensitivity
Negative Delta Counts disabled
All other parameters default
Timing
Time to communications
ready tCOMM_DLY 15 ms
Time to first conversion
ready tCONV_DLY 170 200 ms
I/O Pins
Output Low Voltage VOL 0.4 V ISINK_IO = 8mA
Output High Voltage VOH VDD - 0.4 V ISOURCE_IO = 8mA
Input High Voltage VIH 2.0 V
Input Low Voltage VIL 0.8 V
Leakage Current ILEAK ±5 uA
powered or unpowered
TA < 85°C
pull-up voltage < 3.6V if unpowered
SMBus Timing
Input Capacitance CIN 5 pF
Clock Frequency fSMB 10 400 kHz
Spike Suppression tSP 50 ns
Bus Free Time Stop to
Start tBUF 1.3 us
Start Setup Time tSU:STA 0.6 us
2015 Microchip Technology Inc. DS00001624B-page 9
CAP1106
Note 3-4 The ALERT pin will not glitch high or low at power up if connected to VDD or another voltage.
Note 3-5 The SMCLK and SMDATA pins will not glitch low at power up if connected to VDD or another voltage.
Start Hold Time tHD:STA 0.6 us
Stop Setup Time tSU:STO 0.6 us
Data Hold Time tHD:DAT 0 us When transmitting to the master
Data Hold Time tHD:DAT 0.3 us When receiving from the master
Data Setup Time tSU:DAT 0.6 us
Clock Low Period tLOW 1.3 us
Clock High Period tHIGH 0.6 us
Clock / Data Fall Time tFALL 300 ns Min = 20+0.1CLOAD ns
Clock / Data Rise
Time tRISE 300 ns Min = 20+0.1CLOAD ns
Capacitive Load CLOAD 400 pF per bus line
TABLE 3-2: ELECTRICAL SPECIFICATIONS (CONTINUED)
VDD = 3V to 3.6V, TA = 0°C to 85°C, all typical values at TA = 27°C unless otherwise noted.
Characteristic Symbol Min Typ Max Unit Conditions
CAP1106
DS00001624B-page 10 2015 Microchip Technology Inc.
4.0 COMMUNICATIONS
4.1 Communications
The CAP1106 communicates using the SMBus or I2C protocol. If the proprietary BC-Link protocol is required for your
application, please contact your Microchip representative for ordering instructions. Regardless of the communications
mechanism, the device functionality remains unchanged.
4.1.1 SMBUS (I2C) COMMUNICATIONS
The supports the following protocols: Send Byte, Receive Byte, Read Byte, Write Byte, Read Block, and Write Block.
In addition, the device supports I2C formatting for block read and block write protocols.
See Section 4.2 and Section 4.3 for more information on the SMBus bus and protocols respectively.
APPLICATION NOTE: Upon power up, the CAP1106 will not respond to any communications for up to 15ms. After
this time, full functionality is available.
4.2 System Management Bus
The CAP1106 communicates with a host controller, such as an SIO, through the SMBus. The SMBus is a two-wire serial
communication protocol between a computer host and its peripheral devices. A detailed timing diagram is shown in
Figure 4-1. Stretching of the SMCLK signal is supported; however, the CAP1106 will not stretch the clock signal.
4.2.1 SMBUS START BIT
The SMBus Start bit is defined as a transition of the SMBus Data line from a logic ‘1’ state to a logic ‘0’ state while the
SMBus Clock line is in a logic ‘1’ state.
4.2.2 SMBUS ADDRESS AND RD / WR BIT
The SMBus Address Byte consists of the 7-bit slave address followed by the RD / WR indicator bit. If this RD / WR bit
is a logic ‘0’, then the SMBus Host is writing data to the slave device. If this RD / WR bit is a logic ‘1’, then the SMBus
Host is reading data from the slave device.
The CAP1106 responds to SMBus address 0101_000(r/w).
4.2.3 SMBUS DATA BYTES
All SMBus Data bytes are sent most significant bit first and composed of 8-bits of information.
4.2.4 SMBUS ACK AND NACK BITS
The SMBus slave will acknowledge all data bytes that it receives. This is done by the slave device pulling the SMBus
Data line low after the 8th bit of each byte that is transmitted. This applies to both the Write Byte and Block Write protocols.
FIGURE 4-1: SMBus Timing Diagram
SMDATA
SMCLK
TLOW
TRISE
THIGH
TFALL
TBUF
THD:STA
P S S - Start Condition P - Stop Condition
THD:DAT TSU:DAT TSU:STA
THD:STA
P
TSU:STO
S
2015 Microchip Technology Inc. DS00001624B-page 11
CAP1106
The Host will NACK (not acknowledge) the last data byte to be received from the slave by holding the SMBus data line
high after the 8th data bit has been sent. For the Block Read protocol, the Host will ACK each data byte that it receives
except the last data byte.
4.2.5 SMBUS STOP BIT
The SMBus Stop bit is defined as a transition of the SMBus Data line from a logic ‘0’ state to a logic ‘1’ state while the
SMBus clock line is in a logic ‘1’ state. When the CAP1106 detects an SMBus Stop bit and it has been communicating
with the SMBus protocol, it will reset its slave interface and prepare to receive further communications.
4.2.6 SMBUS TIMEOUT
The CAP1106 includes an SMBus timeout feature. Following a 30ms period of inactivity on the SMBus where the
SMCLK pin is held low, the device will timeout and reset the SMBus interface.
The timeout function defaults to disabled. It can be enabled by setting the TIMEOUT bit in the Configuration register
(see Section 6.6, "Configuration Registers").
4.2.7 SMBUS AND I2C COMPATIBILITY
The major differences between SMBus and I2C devices are highlighted here. For more information, refer to the SMBus
2.0 and I2C specifications. For information on using the CAP1106 in an I2C system, refer to AN 14.0 Dedicated Slave
Devices in I2C Systems.
1. CAP1106 supports I2C fast mode at 400kHz. This covers the SMBus max time of 100kHz.
2. Minimum frequency for SMBus communications is 10kHz.
3. The SMBus slave protocol will reset if the clock is held at a logic ‘0’ for longer than 30ms. This timeout functionality
is disabled by default in the CAP1106 and can be enabled by writing to the TIMEOUT bit. I2C does not have
a timeout.
4. The SMBus slave protocol will reset if both the clock and data lines are held at a logic ‘1’ for longer than 200µs
(idle condition). This function is disabled by default in the CAP1106 and can be enabled by writing to the TIMEOUT
bit. I2C does not have an idle condition.
5. I2C devices do not support the Alert Response Address functionality (which is optional for SMBus).
6. I2C devices support block read and write differently. I2C protocol allows for unlimited number of bytes to be sent
in either direction. The SMBus protocol requires that an additional data byte indicating number of bytes to read /
write is transmitted. The CAP1106 supports I2C formatting only.
4.3 SMBus Protocols
The CAP1106 is SMBus 2.0 compatible and supports Write Byte, Read Byte, Send Byte, and Receive Byte as valid
protocols as shown below.
All of the below protocols use the convention in Table 4-1.
4.3.1 SMBUS WRITE BYTE
The Write Byte is used to write one byte of data to a specific register as shown in Table 4-2.
4.3.2 SMBUS READ BYTE
The Read Byte protocol is used to read one byte of data from the registers as shown in Table 4-3.
TABLE 4-1: PROTOCOL FORMAT
Data Sent to
Device
Data Sent to the
HOst
Data sent Data sent
TABLE 4-2: WRITE BYTE PROTOCOL
Start Slave
Address WR ACK Register
Address ACK Register Data ACK Stop
1 ->0 0101_000 0 0 XXh 0 XXh 0 0 -> 1
CAP1106
DS00001624B-page 12 2015 Microchip Technology Inc.
4.3.3 SMBUS SEND BYTE
The Send Byte protocol is used to set the internal address register pointer to the correct address location. No data is
transferred during the Send Byte protocol as shown in Table 4-4.
APPLICATION NOTE: The Send Byte protocol is not functional in Deep Sleep (i.e., DSLEEP bit is set).
4.3.4 SMBUS RECEIVE BYTE
The Receive Byte protocol is used to read data from a register when the internal register address pointer is known to
be at the right location (e.g., set via Send Byte). This is used for consecutive reads of the same register as shown in
Table 4-5.
APPLICATION NOTE: The Receive Byte protocol is not functional in Deep Sleep (i.e., DSLEEP bit is set).
4.4 I2C Protocols
The CAP1106 supports I2C Block Write and Block Read.
The protocols listed below use the convention in Table 4-1.
4.4.1 BLOCK WRITE
The Block Write is used to write multiple data bytes to a group of contiguous registers as shown in Table 4-6.
APPLICATION NOTE: When using the Block Write protocol, the internal address pointer will be automatically
incremented after every data byte is received. It will wrap from FFh to 00h.
4.4.2 BLOCK READ
The Block Read is used to read multiple data bytes from a group of contiguous registers as shown in Table 4-7.
APPLICATION NOTE: When using the Block Read protocol, the internal address pointer will be automatically
incremented after every data byte is received. It will wrap from FFh to 00h.
TABLE 4-3: READ BYTE PROTOCOL
Start Slave
Address WR ACK Register
Address ACK Start Slave
Address RD ACK Register
Data NACK Stop
1->0 0101_000 0 0 XXh 0 1 ->0 0101_000 1 0 XXh 1 0 -> 1
TABLE 4-4: SEND BYTE PROTOCOL
Start Slave Address WR ACK Register Address ACK Stop
1 -> 0 0101_000 0 0 XXh 0 0 -> 1
TABLE 4-5: RECEIVE BYTE PROTOCOL
Start Slave Address RD ACK Register Data NACK Stop
1 -> 0 0101_000 1 0 XXh 1 0 -> 1
TABLE 4-6: BLOCK WRITE PROTOCOL
Start Slave
Address WR ACK Register
Address ACK Register Data ACK
1 ->0 0101_000 0 0 XXh 0 XXh 0
Register Data ACK Register
Data
ACK . . . Register
Data
ACK Stop
XXh 0 XXh 0 . . . XXh 0 0 -> 1
2015 Microchip Technology Inc. DS00001624B-page 13
CAP1106
4.5 BC-Link Interface
The BC-Link is a proprietary bus developed to allow communication between a host controller device to a companion
device. This device uses this serial bus to read and write registers and for interrupt processing. The interface uses a
data port concept, where the base interface has an address register, data register and a control register, defined in the
8051’s SFR space.
Refer to documentation for the BC-Link compatible host controller for details on how to access the CAP1106-2 via the
BC-Link Interface.
TABLE 4-7: BLOCK READ PROTOCOL
Start Slave
Address WR ACK Register
Address ACK Start Slave
Address RD ACK Register
Data
1->0 0101_000 0 0 XXh 0 1 ->0 0101_000 1 0 XXh
ACK Register
Data
ACK Register
Data
ACK Register
Data
ACK . . . Register
Data
NACK Stop
0 XXh 0 XXh 0 XXh 0 . . . XXh 1 0 -> 1
CAP1106
DS00001624B-page 14 2015 Microchip Technology Inc.
5.0 GENERAL DESCRIPTION
The CAP1106 is a multiple channel Capacitive Touch sensor. The CAP1106 contains six (6) individual capacitive touch
sensor inputs. The device offers programmable sensitivity for use in touch sensor applications. Each sensor input automatically
recalibrates to compensate for gradual environmental changes.
The CAP1106 offers multiple power states. It operates at the lowest quiescent current during its Deep Sleep state. In
the low power Standby state, it can monitor one or more channels and respond to communications normally.
The device communicates with a host controller using or via SMBus / I2C. The host controller may poll the device for
updated information at any time or it may configure the device to flag an interrupt whenever a touch is detected on any
sensor pad.
A typical system diagram for the CAP1106 is shown in Figure 5-1.
FIGURE 5-1: System Diagram for CAP1106
CAP1106
CS6
SMDATA1 / BC_DATA2
SMCLK1 / BC_CLK2
VDD Embedded Controller ALERT#1 / BC_IRQ#2
CS4
CS2
CS5
CS3
CS1
Touch
Button
Touch
Button
Touch
Button
Touch
Button
Touch
Button
Touch
Button
1
= CAP1106-1
2
= CAP1106-2
2015 Microchip Technology Inc. DS00001624B-page 15
CAP1106
5.1 Power States
The CAP1106 has three operating states depending on the status of the STBY and DSLEEP bits. When the device transitions
between power states, previously detected touches (for inactive channels) are cleared and the status bits reset.
1. Fully Active - The device is fully active. It is monitoring all active capacitive sensor inputs.
2. Standby - The device is in a lower power state. It will measure a programmable number of channels using the
Standby Configuration controls (see Section 6.20 through Section 6.22). Interrupts will still be generated based
on the active channels. The device will still respond to communications normally and can be returned to the Fully
Active state of operation by clearing the STBY bit.
3. Deep Sleep - The device is in its lowest power state. It is not monitoring any capacitive sensor inputs. While in
Deep Sleep, the device can be awakened by SMBus or SPI communications targeting the device. This will not
cause the DSLEEP to be cleared so the device will return to Deep Sleep once all communications have stopped.
5.2 Capacitive Touch Sensing
The CAP1106 contains six (6) independent capacitive touch sensor inputs. Each sensor input has dynamic range to
detect a change of capacitance due to a touch. Additionally, each sensor input can be configured to be automatically
and routinely re-calibrated.
5.2.1 SENSING CYCLE
Each capacitive touch sensor input has controls to be activated and included in the sensing cycle. When the device is
active, it automatically initiates a sensing cycle and repeats the cycle every time it finishes. The cycle polls through each
active sensor input starting with CS1 and extending through CS6. As each capacitive touch sensor input is polled, its
measurement is compared against a baseline “Not Touched” measurement. If the delta measurement is large enough,
a touch is detected and an interrupt is generated.
The sensing cycle time is programmable (see Section 6.10, "Averaging and Sampling Configuration Register").
5.2.2 RECALIBRATING SENSOR INPUTS
There are various options for recalibrating the capacitive touch sensor inputs. Recalibration re-sets the Base Count Registers
(Section 6.24, "Sensor Input Base Count Registers") which contain the “not touched” values used for touch detection
comparisons.
APPLICATION NOTE: The device will recalibrate all sensor inputs that were disabled when it transitions from
Standby. Likewise, the device will recalibrate all sensor inputs when waking out of Deep
Sleep.
5.2.2.1 Manual Recalibration
The Calibration Activate Registers (Section 6.11, "Calibration Activate Register") force recalibration of selected sensor
inputs. When a bit is set, the corresponding capacitive touch sensor input will be recalibrated (both analog and digital).
The bit is automatically cleared once the recalibration routine has finished.
5.2.2.2 Automatic Recalibration
Each sensor input is regularly recalibrated at a programmable rate (see Section 6.17, "Recalibration Configuration Register").
By default, the recalibration routine stores the average 64 previous measurements and periodically updates the
base “not touched” setting for the capacitive touch sensor input.
Note: During this recalibration routine, the sensor inputs will not detect a press for up to 200ms and the Sensor
Base Count Register values will be invalid. In addition, any press on the corresponding sensor pads will
invalidate the recalibration.
Note: Automatic recalibration only works when the delta count is below the active sensor input threshold. It is disabled
when a touch is detected.
CAP1106
DS00001624B-page 16 2015 Microchip Technology Inc.
5.2.2.3 Negative Delta Count Recalibration
It is possible that the device loses sensitivity to a touch. This may happen as a result of a noisy environment, an accidental
recalibration during a touch, or other environmental changes. When this occurs, the base untouched sensor input
may generate negative delta count values. The NEG_DELTA_CNT bits (see Section 6.17, "Recalibration Configuration
Register") can be set to force a recalibration after a specified number of consecutive negative delta readings.
5.2.2.4 Delayed Recalibration
It is possible that a “stuck button” occurs when something is placed on a button which causes a touch to be detected
for a long period. By setting the MAX_DUR_EN bit (see Section 6.6, "Configuration Registers"), a recalibration can be
forced when a touch is held on a button for longer than the duration specified in the MAX_DUR bits (see Section 6.8,
"Sensor Input Configuration Register").
5.2.3 PROXIMITY DETECTION
Each sensor input can be configured to detect changes in capacitance due to proximity of a touch. This circuitry detects
the change of capacitance that is generated as an object approaches, but does not physically touch, the enabled sensor
pad(s). When a sensor input is selected to perform proximity detection, it will be sampled from 1x to 128x per sampling
cycle. The larger the number of samples that are taken, the greater the range of proximity detection is available at the
cost of an increased overall sampling time.
5.2.4 MULTIPLE TOUCH PATTERN DETECTION
The multiple touch pattern (MTP) detection circuitry can be used to detect lid closure or other similar events. An event
can be flagged based on either a minimum number of sensor inputs or on specific sensor inputs simultaneously exceeding
an MTP threshold or having their Noise Flag Status Register bits set. An interrupt can also be generated. During an
MTP event, all touches are blocked (see Section 6.15, "Multiple Touch Pattern Configuration Register").
5.2.5 LOW FREQUENCY NOISE DETECTION
Each sensor input has an EMI noise detector that will sense if low frequency noise is injected onto the input with sufficient
power to corrupt the readings. If this occurs, the device will reject the corrupted sample and set the corresponding
bit in the Noise Status register to a logic ‘1’.
5.2.6 RF NOISE DETECTION
Each sensor input contains an integrated RF noise detector. This block will detect injected RF noise on the CS pin. The
detector threshold is dependent upon the noise frequency. If RF noise is detected on a CS line, that sample is removed
and not compared against the threshold.
5.3 ALERT# Pin
The ALERT# pin is an active low (or active high when configured) output that is driven when an interrupt event is
detected.
Whenever an interrupt is generated, the INT bit (see Section 6.1, "Main Control Register") is set. The ALERT# pin is
cleared when the INT bit is cleared by the user. Additionally, when the INT bit is cleared by the user, status bits are only
cleared if no touch is detected.
5.3.1 SENSOR INTERRUPT BEHAVIOR
The sensor interrupts are generated in one of two ways:
1. An interrupt is generated when a touch is detected and, as a user selectable option, when a release is detected
(by default - see Section 6.6). See Figure 5-3.
2. If the repeat rate is enabled then, so long as the touch is held, another interrupt will be generated based on the
programmed repeat rate (see Figure 5-2).
Note: During this recalibration, the device will not respond to touches.
Note: Delayed recalibration only works when the delta count is above the active sensor input threshold. If
enabled, it is invoked when a sensor pad touch is held longer than the MAX_DUR bit setting.
2015 Microchip Technology Inc. DS00001624B-page 17
CAP1106
When the repeat rate is enabled, the device uses an additional control called MPRESS that determines whether a touch
is flagged as a simple “touch” or a “press and hold”. The MPRESS[3:0] bits set a minimum press timer. When the button
is touched, the timer begins. If the sensor pad is released before the minimum press timer expires, it is flagged as a
touch and an interrupt is generated upon release. If the sensor input detects a touch for longer than this timer value, it
is flagged as a “press and hold” event. So long as the touch is held, interrupts will be generated at the programmed
repeat rate and upon release (if enabled).
APPLICATION NOTE: Figure 5-2 and Figure 5-3 show default operation which is to generate an interrupt upon
sensor pad release and an active-low ALERT# pin.
APPLICATION NOTE: The host may need to poll the device twice to determine that a release has been detected.
FIGURE 5-2: Sensor Interrupt Behavior - Repeat Rate Enabled
FIGURE 5-3: Sensor Interrupt Behavior - No Repeat Rate Enabled
Touch Detected
INT bit
Button Status
Write to INT bit
Polling Cycle
(35ms)
Min Press Setting
(280ms)
Interrupt on
Touch
Button Repeat Rate
(175ms)
Button Repeat Rate
(175ms)
Interrupt on
Release
(optional)
ALERT# pin
(active low)
Touch Detected
INT bit
Button Status
Write to INT bit
Polling Cycle
(35ms) Interrupt on
Touch Interrupt on
Release
(optional)
ALERT# pin
(active low)
CAP1106
DS00001624B-page 18 2015 Microchip Technology Inc.
6.0 REGISTER DESCRIPTION
The registers shown in Table 6-1 are accessible through the communications protocol. An entry of ‘-’ indicates that the
bit is not used and will always read ‘0’.
TABLE 6-1: REGISTER SET IN HEXADECIMAL ORDER
Register
Address R/W Register Name Function Default Value Page
00h R/W Main Control Controls general power states and
power dissipation 00h Page 20
02h R General Status Stores general status bits 00h Page 21
03h R Sensor Input Status Returns the state of the sampled
capacitive touch sensor inputs 00h Page 21
0Ah R Noise Flag Status Stores the noise flags for sensor inputs 00h Page 22
10h R Sensor Input 1 Delta
Count Stores the delta count for CS1 00h Page 22
11h R Sensor Input 2 Delta
Count Stores the delta count for CS2 00h Page 22
12h R Sensor Input 3 Delta
Count Stores the delta count for CS3 00h Page 22
13h R Sensor Input 4 Delta
Count Stores the delta count for CS4 00h Page 22
14h R Sensor Input 5 Delta
Count Stores the delta count for CS5 00h Page 22
15h R Sensor Input 6 Delta
Count Stores the delta count for CS6 00h Page 22
1Fh R/W Sensitivity Control
Controls the sensitivity of the threshold
and delta counts and data scaling of
the base counts
2Fh Page 22
20h R/W Configuration Controls general functionality 20h Page 24
21h R/W Sensor Input Enable Controls whether the capacitive touch
sensor inputs are sampled 3Fh Page 25
22h R/W Sensor Input Configuration
Controls max duration and auto-repeat
delay for sensor inputs operating in the
full power state
A4h Page 25
23h R/W Sensor Input Configuration
2
Controls the MPRESS controls for all
sensor inputs 07h Page 26
24h R/W Averaging and Sampling
Config
Controls averaging and sampling window
39h Page 27
26h R/W Calibration Activate Forces re-calibration for capacitive
touch sensor inputs 00h Page 28
27h R/W Interrupt Enable Enables Interrupts associated with
capacitive touch sensor inputs 3Fh Page 29
28h R/W Repeat Rate Enable Enables repeat rate for all sensor
inputs 3Fh Page 29
2Ah R/W Multiple Touch Configuration
Determines the number of simultaneous
touches to flag a multiple touch
condition
80h Page 30
2Bh R/W Multiple Touch Pattern
Configuration
Determines the multiple touch pattern
(MTP) configuration 00h Page 30
2Dh R/W Multiple Touch Pattern
Determines the pattern or number of
sensor inputs used by the MTP circuitry
3Fh Page 31
2015 Microchip Technology Inc. DS00001624B-page 19
CAP1106
2Fh R/W Recalibration Configuration
Determines re-calibration timing and
sampling window 8Ah Page 32
30h R/W Sensor Input 1 Threshold
Stores the delta count threshold to
determine a touch for Capacitive
Touch Sensor Input 1
40h Page 33
31h R/W Sensor Input 2 Threshold
Stores the delta count threshold to
determine a touch for Capacitive
Touch Sensor Input 2
40h Page 33
32h R/W Sensor Input 3 Threshold
Stores the delta count threshold to
determine a touch for Capacitive
Touch Sensor Input 3
40h Page 33
33h R/W Sensor Input 4 Threshold
Stores the delta count threshold to
determine a touch for Capacitive
Touch Sensor Input 4
40h Page 33
34h R/W Sensor Input 5 Threshold
Stores the delta count threshold to
determine a touch for Capacitive
Touch Sensor Input 5
40h Page 33
35h R/W Sensor Input 6 Threshold
Stores the delta count threshold to
determine a touch for Capacitive
Touch Sensor Input 6
40h Page 33
38h R/W Sensor Input Noise
Threshold
Stores controls for selecting the noise
threshold for all sensor inputs 01h Page 33
Standby Configuration Registers
40h R/W Standby Channel Controls which sensor inputs are
enabled while in standby 00h Page 34
41h R/W Standby Configuration Controls averaging and cycle time
while in standby 39h Page 34
42h R/W Standby Sensitivity Controls sensitivity settings used while
in standby 02h Page 35
43h R/W Standby Threshold Stores the touch detection threshold
for active sensor inputs in standby 40h Page 36
44h R/W Configuration 2 Stores additional configuration controls
for the device 40h Page 24
Base Count Registers
50h R Sensor Input 1 Base
Count
Stores the reference count value for
sensor input 1 C8h Page 36
51h R Sensor Input 2 Base
Count
Stores the reference count value for
sensor input 2 C8h Page 36
52h R Sensor Input 3 Base
Count
Stores the reference count value for
sensor input 3 C8h Page 36
53h R Sensor Input 4 Base
Count
Stores the reference count value for
sensor input 4 C8h Page 36
54h R Sensor Input 5 Base
Count
Stores the reference count value for
sensor input 5 C8h Page 36
55h R Sensor Input 6 Base
Count
Stores the reference count value for
sensor input 6 C8h Page 36
B1h R Sensor Input 1 Calibration
Stores the upper 8-bit calibration value
for sensor input 1 00h Page 37
TABLE 6-1: REGISTER SET IN HEXADECIMAL ORDER (CONTINUED)
Register
Address R/W Register Name Function Default Value Page
CAP1106
DS00001624B-page 20 2015 Microchip Technology Inc.
During Power-On-Reset (POR), the default values are stored in the registers. A POR is initiated when power is first
applied to the part and the voltage on the VDD supply surpasses the POR level as specified in the electrical characteristics.
Any reads to undefined registers will return 00h. Writes to undefined registers will not have an effect.
When a bit is “set”, this means that the user writes a logic ‘1’ to it. When a bit is “cleared”, this means that the user writes
a logic ‘0’ to it.
6.1 Main Control Register
The Main Control register controls the primary power state of the device.
Bits 7 - 6 - GAIN[1:0] - Controls the gain used by the capacitive touch sensing circuitry. As the gain is increased, the
effective sensitivity is likewise increased as a smaller delta capacitance is required to generate the same delta count
values. The sensitivity settings may need to be adjusted along with the gain settings such that data overflow does not
occur.
APPLICATION NOTE: The gain settings apply to both Standby and Active states.
B2h R Sensor Input 2 Calibration
Stores the upper 8-bit calibration value
for sensor input 2 00h Page 37
B3h R Sensor Input 3 Calibration
Stores the upper 8-bit calibration value
for sensor input 3 00h Page 37
B4h R Sensor Input 4 Calibration
Stores the upper 8-bit calibration value
for sensor input 4 00h Page 37
B5h R Sensor Input 5 Calibration
Stores the upper 8-bit calibration value
for sensor input 5 00h Page 37
B6h R Sensor Input 6 Calibration
Stores the upper 8-bit calibration value
for sensor input 6 00h Page 37
B9h R Sensor Input Calibration
LSB 1
Stores the 2 LSBs of the calibration
value for sensor inputs 1 - 4 00h Page 37
BAh R Sensor Input Calibration
LSB 2
Stores the 2 LSBs of the calibration
value for sensor inputs 5- 6 00h Page 37
FDh R Product ID
CAP1106
Stores a fixed value that identifies
each product 55h Page 37
FEh R Manufacturer ID Stores a fixed value that identifies
Microchip 5Dh Page 38
FFh R Revision Stores a fixed value that represents
the revision number 83h Page 38
TABLE 6-2: MAIN CONTROL REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
00h R/W Main Control GAIN[1:0] STBY DSLEEP - - - INT 00h
TABLE 6-3: GAIN BIT DECODE
GAIN[1:0]
Capacitive Touch Sensor Gain
1 0
0 0 1
01 2
10 4
11 8
TABLE 6-1: REGISTER SET IN HEXADECIMAL ORDER (CONTINUED)
Register
Address R/W Register Name Function Default Value Page
2015 Microchip Technology Inc. DS00001624B-page 21
CAP1106
Bit 5 - STBY - Enables Standby.
• ‘0’ (default) - Sensor input scanning is active.
• ‘1’ - Capacitive touch sensor input scanning is limited to the sensor inputs set in the Standby Channel register (see
Section 6.20). The status registers will not be cleared until read. Sensor inputs that are no longer sampled will flag
a release and then remain in a non-touched state.
• Bit 4 - DSLEEP - Enables Deep Sleep by deactivating all functions. ‘0’ (default) - Sensor input scanning is active.
• ‘1’ - All sensor input scanning is disabled.. The status registers are automatically cleared and the INT bit is
cleared.
Bit 0 - INT - Indicates that there is an interrupt. When this bit is set, it asserts the ALERT# pin. If a channel detects a
touch and its associated interrupt enable bit is not set to a logic ‘1’, no action is taken.
This bit is cleared by writing a logic ‘0’ to it. When this bit is cleared, the ALERT# pin will be deasserted and all status
registers will be cleared if the condition has been removed.
• ‘0’ - No interrupt pending.
• ‘1’ - A touch has been detected on one or more channels and the interrupt has been asserted.
6.2 Status Registers
All status bits are cleared when the device enters the Deep Sleep (DSLEEP = ‘1’ - see Section 6.1).
6.2.1 GENERAL STATUS - 02H
Bit 2 - MULT - Indicates that the device is blocking detected touches due to the Multiple Touch detection circuitry (see
Section 6.14). This bit will not cause the INT bit to be set and hence will not cause an interrupt.
Bit 1 - MTP - Indicates that the device has detected a number of sensor inputs that exceed the MTP threshold either via
the pattern recognition or via the number of sensor inputs (see Section 6.15). This bit will cause the INT bit to be set if
the MTP_ALERT bit is also set. This bit will not be cleared until the condition that caused it to be set has been removed.
Bit 0 - TOUCH - Indicates that a touch was detected. This bit is set if any bit in the Sensor Input Status register is set.
6.2.2 SENSOR INPUT STATUS - 03H
The Sensor Input Status Register stores status bits that indicate a touch has been detected. A value of ‘0’ in any bit
indicates that no touch has been detected. A value of ‘1’ in any bit indicates that a touch has been detected.
All bits are cleared when the INT bit is cleared and if a touch on the respective capacitive touch sensor input is no longer
present. If a touch is still detected, the bits will not be cleared (but this will not cause the interrupt to be asserted - see
Section 6.6).
Bit 5 - CS6 - Indicates that a touch was detected on Sensor Input 6.
Bit 4 - CS5 - Indicates that a touch was detected on Sensor Input 5.
Bit 3 - CS4 - Indicates that a touch was detected on Sensor Input 4.
Bit 2 - CS3 - Indicates that a touch was detected on Sensor Input 3.
Bit 1 - CS2 - Indicates that a touch was detected on Sensor Input 2.
Bit 0 - CS1 - Indicates that a touch was detected on Sensor Input 1.
TABLE 6-4: STATUS REGISTERS
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
02h R General Status - - - - - MULT MTP TOUCH 00h
03h R Sensor Input Status
- - CS6 CS5 CS4 CS3 CS2 CS1 00h
CAP1106
DS00001624B-page 22 2015 Microchip Technology Inc.
6.3 Noise Flag Status Registers
The Noise Flag Status registers store status bits that are generated from the analog block if the detected noise is above
the operating region of the analog detector or the RF noise detector. These bits indicate that the most recently received
data from the sensor input is invalid and should not be used for touch detection. So long as the bit is set for a particular
channel, the delta count value is reset to 00h and thus no touch is detected.
These bits are not sticky and will be cleared automatically if the analog block does not report a noise error.
APPLICATION NOTE: If the MTP detection circuitry is enabled, these bits count as sensor inputs above the MTP
threshold (see Section 5.2.4, "Multiple Touch Pattern Detection") even if the corresponding
delta count is not. If the corresponding delta count also exceeds the MTP threshold, it is not
counted twice.
APPLICATION NOTE: Regardless of the state of the Noise Status bits, if low frequency noise is detected on a
sensor input, that sample will be discarded unless the DIS_ANA_NOISE bit is set. As well,
if RF noise is detected on a sensor input, that sample will be discarded unless the
DIS_RF_NOISE bit is set.
6.4 Sensor Input Delta Count Registers
The Sensor Input Delta Count registers store the delta count that is compared against the threshold used to determine
if a touch has been detected. The count value represents a change in input due to the capacitance associated with a
touch on one of the sensor inputs and is referenced to a calibrated base “Not Touched” count value. The delta is an
instantaneous change and is updated once per sensor input per sensing cycle (see Section 5.2.1, "Sensing Cycle").
The value presented is a standard 2’s complement number. In addition, the value is capped at a value of 7Fh. A reading
of 7Fh indicates that the sensitivity settings are too high and should be adjusted accordingly (see Section 6.5).
The value is also capped at a negative value of 80h for negative delta counts which may result upon a release.
6.5 Sensitivity Control Register
TABLE 6-5: NOISE FLAG STATUS REGISTERS
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
0Ah R Noise Flag Status - - CS6_
NOISE
CS5_
NOISE
CS4_
NOISE
CS3_
NOISE
CS2_
NOISE
CS1_
NOISE 00h
TABLE 6-6: SENSOR INPUT DELTA COUNT REGISTERS
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
10h R Sensor Input 1
Delta Count Sign 64 32 16 8 4 2 1 00h
11h R Sensor Input 2
Delta Count Sign 64 32 16 8 4 2 1 00h
12h R Sensor Input 3
Delta Count Sign 64 32 16 8 4 2 1 00h
13h R Sensor Input 4
Delta Count Sign 64 32 16 8 4 2 1 00h
14h R Sensor Input 5
Delta Count Sign 64 32 16 8 4 2 1 00h
15h R Sensor Input 6
Delta Count Sign 64 32 16 8 4 2 1 00h
TABLE 6-7: SENSITIVITY CONTROL REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
1Fh R/W Sensitivity Control - DELTA_SENSE[2:0] BASE_SHIFT[3:0] 2Fh
2015 Microchip Technology Inc. DS00001624B-page 23
CAP1106
The Sensitivity Control register controls the sensitivity of a touch detection.
Bits 6-4 DELTA_SENSE[2:0] - Controls the sensitivity of a touch detection. The sensitivity settings act to scale the relative
delta count value higher or lower based on the system parameters. A setting of 000b is the most sensitive while a
setting of 111b is the least sensitive. At the more sensitive settings, touches are detected for a smaller delta capacitance
corresponding to a “lighter” touch. These settings are more sensitive to noise, however, and a noisy environment may
flag more false touches with higher sensitivity levels.
APPLICATION NOTE: A value of 128x is the most sensitive setting available. At the most sensitivity settings, the
MSB of the Delta Count register represents 64 out of ~25,000 which corresponds to a touch
of approximately 0.25% of the base capacitance (or a ΔC of 25fF from a 10pF base
capacitance). Conversely, a value of 1x is the least sensitive setting available. At these
settings, the MSB of the Delta Count register corresponds to a delta count of 8192 counts
out of ~25,000 which corresponds to a touch of approximately 33% of the base capacitance
(or a ΔC of 3.33pF from a 10pF base capacitance).
Bits 3 - 0 - BASE_SHIFT[3:0] - Controls the scaling and data presentation of the Base Count registers. The higher the
value of these bits, the larger the range and the lower the resolution of the data presented. The scale factor represents
the multiplier to the bit-weighting presented in these register descriptions.
APPLICATION NOTE: The BASE_SHIFT[3:0] bits normally do not need to be updated. These settings will not affect
touch detection or sensitivity. These bits are sometimes helpful in analyzing the Cap Sensing
board performance and stability.
TABLE 6-8: DELTA_SENSE BIT DECODE
DELTA_SENSE[2:0]
Sensitivity Multiplier
210
0 0 0 128x (most sensitive)
0 0 1 64x
0 1 0 32x (default)
0 1 1 16x
1 0 0 8x
1 0 1 4x
1 1 0 2x
1 1 1 1x - (least sensitive)
TABLE 6-9: BASE_SHIFT BIT DECODE
BASE_SHIFT[3:0]
Data Scaling Factor
32 1 0
0 0 0 0 1x
0 0 0 1 2x
0 0 1 0 4x
0 0 1 1 8x
0 1 0 0 16x
0 1 0 1 32x
0 1 1 0 64x
0 1 1 1 128x
1 0 0 0 256x
All others 256x
(default = 1111b)
CAP1106
DS00001624B-page 24 2015 Microchip Technology Inc.
6.6 Configuration Registers
The Configuration registers control general global functionality that affects the entire device.
6.6.1 CONFIGURATION - 20H
Bit 7 - TIMEOUT - Enables the timeout and idle functionality of the SMBus protocol.
• ‘0’ (default for Functional Revision C) - The SMBus timeout and idle functionality are disabled. The SMBus interface
will not time out if the clock line is held low. Likewise, it will not reset if both the data and clock lines are held
high for longer than 200us. This is used for I2C compliance.
• ‘1’ (default for Functional Revision B) - The SMBus timeout and idle functionality are enabled. The SMBus interface
will time out if the clock line is held low for longer than 30ms. Likewise, it will reset if both the data and clock
lines are held high for longer than 200us.
Bit 5 - DIS_DIG_NOISE - Determines whether the digital noise threshold (see Section 6.19, "Sensor Input Noise Threshold
Register") is used by the device. Setting this bit disables the feature.
• ‘0’ - The digital noise threshold is used. If a delta count value exceeds the noise threshold but does not exceed the
touch threshold, the sample is discarded and not used for the automatic re-calibration routine.
• ‘1’ (default) - The noise threshold is disabled. Any delta count that is less than the touch threshold is used for the
automatic re-calibration routine.
Bit 4 - DIS_ANA_NOISE - Determines whether the analog noise filter is enabled. Setting this bit disables the feature.
• ‘0’ (default) - If low frequency noise is detected by the analog block, the delta count on the corresponding channel
is set to 0. Note that this does not require that Noise Status bits be set.
• ‘1’ - A touch is not blocked even if low frequency noise is detected.
Bit 3 - MAX_DUR_EN - Determines whether the maximum duration recalibration is enabled.
• ‘0’ (default) - The maximum duration recalibration functionality is disabled. A touch may be held indefinitely and no
re-calibration will be performed on any sensor input.
• ‘1’ - The maximum duration recalibration functionality is enabled. If a touch is held for longer than the MAX_DUR
bit settings, then the re-calibration routine will be restarted (see Section 6.8).
6.6.2 CONFIGURATION 2 - 44H
Bit 6 - ALT_POL - Determines the ALERT# pin polarity and behavior.
• ‘0’ - The ALERT# pin is active high and push-pull.
• ‘1’ (default) - The ALERT# pin is active low and open drain.
Bit 5 - BLK_PWR_CTRL - Determines whether the device will reduce power consumption while waiting between conversion
time completion and the end of the polling cycle.
• ‘0’ (default) - The device will always power down as much as possible during the time between the end of the last
conversion and the end of the polling cycle.
• ‘1’ - The device will not power down the Cap Sensor during the time between the end of the last conversion and
the end of the polling cycle.
Bit 3 - SHOW_RF_NOISE - Determines whether the Noise Status bits will show RF Noise as the only input source.
• ‘0’ (default) - The Noise Status registers will show both RF noise and low frequency EMI noise if either is detected
on a capacitive touch sensor input.
• ‘1’ - The Noise Status registers will only show RF noise if it is detected on a capacitive touch sensor input. EMI
TABLE 6-10: CONFIGURATION REGISTERS
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
20h R/W Configuration TIMEOUT - DIS_ DIG_
NOISE
DIS_ ANA_
NOISE
MAX_
DUR_EN - --
A0h
(Rev B)
20h
(rev C)
44h R/W Configuration 2 - ALT_
POL
BLK_PWR_
CTRL
- SHOW_
RF_
NOISE
DIS_
RF_
NOISE
- INT_
REL_n 40h
2015 Microchip Technology Inc. DS00001624B-page 25
CAP1106
noise will still be detected and touches will be blocked normally; however, the status bits will not be updated.
Bit 2 - DIS_RF_NOISE - Determines whether the RF noise filter is enabled. Setting this bit disables the feature.
• ‘0’ (default) - If RF noise is detected by the analog block, the delta count on the corresponding channel is set to 0.
Note that this does not require that Noise Status bits be set.
• ‘1’ - A touch is not blocked even if RF noise is detected.
Bit 0 - INT_REL_n - Controls the interrupt behavior when a release is detected on a button.
• ‘0’ (default) - An interrupt is generated when a press is detected and again when a release is detected and at the
repeat rate (if enabled - see Section 6.13).
• ‘1’ - An interrupt is generated when a press is detected and at the repeat rate but not when a release is detected.
6.7 Sensor Input Enable Registers
The Sensor Input Enable registers determine whether a capacitive touch sensor input is included in the sampling cycle.
The length of the sampling cycle is not affected by the number of sensor inputs measured.
Bit 5 - CS6_EN - Enables the CS6 input to be included during the sampling cycle.
• ‘0’ - The CS6 input is not included in the sampling cycle.
• ‘1’ (default) - The CS6 input is included in the sampling cycle.
Bit 4 - CS5_EN - Enables the CS5 input to be included during the sampling cycle.
Bit 3 - CS4_EN - Enables the CS4 input to be included during the sampling cycle.
Bit 2 - CS3_EN - Enables the CS3 input to be included during the sampling cycle.
Bit 1 - CS2_EN - Enables the CS2 input to be included during the sampling cycle.
Bit 0 - CS1_EN - Enables the CS1 input to be included during the sampling cycle.
6.8 Sensor Input Configuration Register
The Sensor Input Configuration Register controls timings associated with the Capacitive sensor inputs 1 - 6.
Bits 7 - 4 - MAX_DUR[3:0] - (default 1010b) - Determines the maximum time that a sensor pad is allowed to be touched
until the capacitive touch sensor input is recalibrated, as shown in Table 6-13.
TABLE 6-11: SENSOR INPUT ENABLE REGISTERS
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
21h R/W Sensor Input
Enable - - CS6_EN CS5_EN CS4_EN CS3_EN CS2_EN CS1_EN 3Fh
TABLE 6-12: SENSOR INPUT CONFIGURATION REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
22h R/W Sensor Input
Configuration MAX_DUR[3:0] RPT_RATE[3:0] A4h
TABLE 6-13: MAX_DUR BIT DECODE
MAX_DUR[3:0]
Time Before Recalibration
32 1 0
0 0 0 0 560ms
0 0 0 1 840ms
0 0 1 0 1120ms
0 0 1 1 1400ms
0 1 0 0 1680ms
0 1 0 1 2240ms
0 1 1 0 2800ms
CAP1106
DS00001624B-page 26 2015 Microchip Technology Inc.
Bits 3 - 0 - RPT_RATE[3:0] - (default 0100b) Determines the time duration between interrupt assertions when auto
repeat is enabled. The resolution is 35ms the range is from 35ms to 560ms as shown in Table 6-14.
6.9 Sensor Input Configuration 2 Register
Bits 3 - 0 - M_PRESS[3:0] - (default 0111b) - Determines the minimum amount of time that sensor inputs configured to
use auto repeat must detect a sensor pad touch to detect a “press and hold” event. If the sensor input detects a touch
for longer than the M_PRESS[3:0] settings, a “press and hold” event is detected. If a sensor input detects a touch for
less than or equal to the M_PRESS[3:0] settings, a touch event is detected.
The resolution is 35ms the range is from 35ms to 560ms as shown in Table 6-16.
1 1 1 3360ms
1 0 0 0 3920ms
1 0 0 1 4480ms
1 0 1 0 5600ms (default)
1 0 1 1 6720ms
1 1 0 0 7840ms
1 1 0 1 8906ms
1 1 1 0 10080ms
1 1 1 1 11200ms
TABLE 6-14: RPT_RATE BIT DECODE
RPT_RATE[3:0]
Interrupt Repeat RATE
3 21 0
0 0 0 0 35ms
0 0 0 1 70ms
0 0 1 0 105ms
0 0 1 1 140ms
0 1 0 0 175ms (default)
0 1 0 1 210ms
0 1 1 0 245ms
0 1 1 1 280ms
1 0 0 0 315ms
1 0 0 1 350ms
1 0 1 0 385ms
1 0 1 1 420ms
1 1 0 0 455ms
1 1 0 1 490ms
1 1 1 0 525ms
1 1 1 1 560ms
TABLE 6-15: SENSOR INPUT CONFIGURATION 2 REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
23h R/W Sensor Input
Configuration 2 - - - - M_PRESS[3:0] 07h
TABLE 6-13: MAX_DUR BIT DECODE (CONTINUED)
MAX_DUR[3:0]
Time Before Recalibration
32 1 0
2015 Microchip Technology Inc. DS00001624B-page 27
CAP1106
6.10 Averaging and Sampling Configuration Register
The Averaging and Sampling Configuration register controls the number of samples taken and the total sensor input
cycle time for all active sensor inputs while the device is functioning in Active state.
Bits 6 - 4 - AVG[2:0] - Determines the number of samples that are taken for all active channels during the sensor cycle
as shown in Table 6-18. All samples are taken consecutively on the same channel before the next channel is sampled
and the result is averaged over the number of samples measured before updating the measured results.
For example, if CS1, CS2, and CS3 are sampled during the sensor cycle, and the AVG[2:0] bits are set to take 4 samples
per channel, then the full sensor cycle will be: CS1, CS1, CS1, CS1, CS2, CS2, CS2, CS2, CS3, CS3, CS3, CS3.
Bits 3 - 2 - SAMP_TIME[1:0] - Determines the time to take a single sample as shown in Table 6-19.
TABLE 6-16: M_PRESS BIT DECODE
M_PRESS[3:0]
M_PRESS SETTINGS
3 21 0
0 0 0 0 35ms
0 0 0 1 70ms
0 0 1 0 105ms
0 0 1 1 140ms
0 1 0 0 175ms
0 1 0 1 210ms
0 1 1 0 245ms
0 1 1 1 280ms (default)
1 0 0 0 315ms
1 0 0 1 350ms
1 0 1 0 385ms
1 0 1 1 420ms
1 1 0 0 455ms
1 1 0 1 490ms
1 1 1 0 525ms
1 1 1 1 560ms
TABLE 6-17: AVERAGING AND SAMPLING CONFIGURATION REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
24h R/W Averaging and
Sampling Config AVG[2:0] SAMP_TIME[1:0] CYCLE_TIME
[1:0] 39h
TABLE 6-18: AVG BIT DECODE
AVG[2:0] Number of Samples Taken per
Measurement 2 10
0 0 0 1
0 01 2
0 10 4
0 1 1 8 (default)
1 0 0 16
1 0 1 32
1 1 0 64
1 1 1 128
CAP1106
DS00001624B-page 28 2015 Microchip Technology Inc.
Bits 1 - 0 - CYCLE_TIME[1:0] - Determines the overall cycle time for all measured channels during normal operation as
shown in Table 6-20. All measured channels are sampled at the beginning of the cycle time. If additional time is remaining,
then the device is placed into a lower power state for the remaining duration of the cycle.
APPLICATION NOTE: The programmed cycle time is only maintained if the total averaging time for all samples is
less than the programmed cycle. The AVG[2:0] bits will take priority so that if more samples
are required than would normally be allowed during the cycle time, the cycle time will be
extended as necessary to accommodate the number of samples to be measured.
6.11 Calibration Activate Register
The Calibration Activate register forces the respective sensor inputs to be re-calibrated affecting both the analog and
digital blocks. During the re-calibration routine, the sensor inputs will not detect a press for up to 600ms and the Sensor
Input Base Count register values will be invalid. During this time, any press on the corresponding sensor pads will invalidate
the re-calibration. When finished, the CALX[9:0] bits will be updated (see Section 6.25).
When the corresponding bit is set, the device will perform the calibration and the bit will be automatically cleared once
the re-calibration routine has finished.
Bit 5 - CS6_CAL - When set, the CS6 input is re-calibrated. This bit is automatically cleared once the sensor input has
been re-calibrated successfully.
Bit 4 - CS5_CAL - When set, the CS5 input is re-calibrated. This bit is automatically cleared once the sensor input has
been re-calibrated successfully.
Bit 3 - CS4_CAL - When set, the CS4 input is re-calibrated. This bit is automatically cleared once the sensor input has
been re-calibrated successfully.
Bit 2 - CS3_CAL - When set, the CS3 input is re-calibrated. This bit is automatically cleared once the sensor input has
been re-calibrated successfully.
Bit 1 - CS2_CAL - When set, the CS2 input is re-calibrated. This bit is automatically cleared once the sensor input has
been re-calibrated successfully.
Bit 0 - CS1_CAL - When set, the CS1 input is re-calibrated. This bit is automatically cleared once the sensor input has
been re-calibrated successfully.
TABLE 6-19: SAMP_TIME BIT DECODE
SAMP_TIME[1:0]
Sample Time
1 0
0 0 320us
0 1 640us
1 0 1.28ms (default)
1 1 2.56ms
TABLE 6-20: CYCLE_TIME BIT DECODE
CYCLE_TIME[1:0]
Overall Cycle Time
1 0
0 0 35ms
0 1 70ms (default)
1 0 105ms
1 1 140ms
TABLE 6-21: CALIBRATION ACTIVATE REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
26h R/W Calibration
Activate - - CS6_
CAL
CS5_
CAL
CS4_
CAL
CS3_
CAL
CS2_
CAL
CS1_
CAL 00h
2015 Microchip Technology Inc. DS00001624B-page 29
CAP1106
6.12 Interrupt Enable Register
The Interrupt Enable register determines whether a sensor pad touch or release (if enabled) causes the interrupt pin to
be asserted.
Bit 5 - CS6_INT_EN - Enables the interrupt pin to be asserted if a touch is detected on CS6 (associated with the CS6
status bit).
• ‘0’ - The interrupt pin will not be asserted if a touch is detected on CS6 (associated with the CS6 status bit).
• ‘1’ (default) - The interrupt pin will be asserted if a touch is detected on CS6 (associated with the CS6 status bit).
Bit 4 - CS5_INT_EN - Enables the interrupt pin to be asserted if a touch is detected on CS5 (associated with the CS5
status bit).
Bit 3 - CS4_INT_EN - Enables the interrupt pin to be asserted if a touch is detected on CS4 (associated with the CS4
status bit).
Bit 2 - CS3_INT_EN - Enables the interrupt pin to be asserted if a touch is detected on CS3 (associated with the CS3
status bit).
Bit 1 - CS2_INT_EN - Enables the interrupt pin to be asserted if a touch is detected on CS2 (associated with the CS2
status bit).
Bit 0 - CS1_INT_EN - Enables the interrupt pin to be asserted if a touch is detected on CS1 (associated with the CS1
status bit).
6.13 Repeat Rate Enable Register
The Repeat Rate Enable register enables the repeat rate of the sensor inputs as described in Section 5.3.1.
Bit 5 - CS6_RPT_EN - Enables the repeat rate for capacitive touch sensor input 6.
• ‘0’ - The repeat rate for CS6 is disabled. It will only generate an interrupt when a touch is detected and when a
release is detected no matter how long the touch is held for.
• ‘1’ (default) - The repeat rate for CS6 is enabled. In the case of a “touch” event, it will generate an interrupt when a
touch is detected and a release is detected (as determined by the INT_REL_n bit - see Section 6.6). In the case of
a “press and hold” event, it will generate an interrupt when a touch is detected and at the repeat rate so long as
the touch is held.
Bit 4 - CS5_RPT_EN - Enables the repeat rate for capacitive touch sensor input 5.
Bit 3 - CS4_RPT_EN - Enables the repeat rate for capacitive touch sensor input 4.
Bit 2 - CS3_RPT_EN - Enables the repeat rate for capacitive touch sensor input 3.
Bit 1 - CS2_RPT_EN - Enables the repeat rate for capacitive touch sensor input 2.
Bit 0 - CS1_RPT_EN - Enables the repeat rate for capacitive touch sensor input 1.
TABLE 6-22: INTERRUPT ENABLE REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
27h R/W Interrupt
Enable - - CS6_
INT_EN
CS5_
INT_EN
CS4_
INT_EN
CS3_
INT_EN
CS2_
INT_EN
CS1_
INT_EN 3Fh
TABLE 6-23: REPEAT RATE ENABLE REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
28h R/W Repeat Rate
Enable - - CS6_
RPT_EN
CS5_
RPT_EN
CS4_
RPT_EN
CS3_
RPT_EN
CS2_
RPT_EN
CS1_
RPT_EN 3Fh
CAP1106
DS00001624B-page 30 2015 Microchip Technology Inc.
6.14 Multiple Touch Configuration Register
The Multiple Touch Configuration register controls the settings for the multiple touch detection circuitry. These settings
determine the number of simultaneous buttons that may be pressed before additional buttons are blocked and the MULT
status bit is set.
Bit 7 - MULT_BLK_EN - Enables the multiple button blocking circuitry.
• ‘0’ - The multiple touch circuitry is disabled. The device will not block multiple touches.
• ‘1’ (default) - The multiple touch circuitry is enabled. The device will flag the number of touches equal to programmed
multiple touch threshold and block all others. It will remember which sensor inputs are valid and block all
others until that sensor pad has been released. Once a sensor pad has been released, the N detected touches
(determined via the cycle order of CS1 - CS6) will be flagged and all others blocked.
Bits 3 - 2 - B_MULT_T[1:0] - Determines the number of simultaneous touches on all sensor pads before a Multiple Touch
Event is detected and sensor inputs are blocked. The bit decode is given by Table 6-25.
6.15 Multiple Touch Pattern Configuration Register
The Multiple Touch Pattern Configuration register controls the settings for the multiple touch pattern detection circuitry.
This circuitry works like the multiple touch detection circuitry with the following differences:
1. The detection threshold is a percentage of the touch detection threshold as defined by the MTP_TH[1:0] bits
whereas the multiple touch circuitry uses the touch detection threshold.
2. The MTP detection circuitry either will detect a specific pattern of sensor inputs as determined by the Multiple
Touch Pattern register settings or it will use the Multiple Touch Pattern register settings to determine a minimum
number of sensor inputs that will cause the MTP circuitry to flag an event. When using pattern recognition mode,
if all of the sensor inputs set by the Multiple Touch Pattern register have a delta count greater than the MTP
threshold or have their corresponding Noise Flag Status bits set, the MTP bit will be set. When using the absolute
number mode, if the number of sensor inputs with thresholds above the MTP threshold or with Noise Flag Status
bits set is equal to or greater than this number, the MTP bit will be set.
3. When an MTP event occurs, all touches are blocked and an interrupt is generated.
4. All sensor inputs will remain blocked so long as the requisite number of sensor inputs are above the MTP threshold
or have Noise Flag Status bits set. Once this condition is removed, touch detection will be restored. Note that
the MTP status bit is only cleared by writing a ‘0’ to the INT bit once the condition has been removed.
TABLE 6-24: MULTIPLE TOUCH CONFIGURATION
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
2Ah R/W Multiple Touch
Config
MULT_
BLK_
EN
- - - B_MULT_T[1:0] - - 80h
TABLE 6-25: B_MULT_T BIT DECODE
B_MULT_T[1:0]
Number of Simultaneous Touches
1 0
0 0 1 (default)
01 2
10 3
11 4
TABLE 6-26: MULTIPLE TOUCH PATTERN CONFIGURATION
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
2Bh R/W Multiple Touch
Pattern Config MTP_ EN - - MTP_TH[1:0] COMP_
PTRN
MTP_
ALERT 00h
2015 Microchip Technology Inc. DS00001624B-page 31
CAP1106
Bit 7 - MTP_EN - Enables the multiple touch pattern detection circuitry.
• ‘0’ (default) - The MTP detection circuitry is disabled.
• ‘1’ - The MTP detection circuitry is enabled.
Bits 3-2 - MTP_TH[1:0] - Determine the MTP threshold, as shown in Table 6-27. This threshold is a percentage of sensor
input threshold (see Section 6.18, "Sensor Input Threshold Registers") when the device is in the Fully Active state or of
the standby threshold (see Section 6.23, "Standby Threshold Register") when the device is in the Standby state.
Bit 1 - COMP_PTRN - Determines whether the MTP detection circuitry will use the Multiple Touch Pattern register as a
specific pattern of sensor inputs or as an absolute number of sensor inputs.
• ‘0’ (default) - The MTP detection circuitry will use the Multiple Touch Pattern register bit settings as an absolute
minimum number of sensor inputs that must be above the threshold or have Noise Flag Status bits set. The number
will be equal to the number of bits set in the register.
• ‘1’ - The MTP detection circuitry will use pattern recognition. Each bit set in the Multiple Touch Pattern register
indicates a specific sensor input that must have a delta count greater than the MTP threshold or have a Noise Flag
Status bit set. If the criteria are met, the MTP status bit will be set.
Bit 0 - MTP_ALERT - Enables an interrupt if an MTP event occurs. In either condition, the MTP status bit will be set.
• ‘0’ (default) - If an MTP event occurs, the ALERT# pin is not asserted.
• ‘1’ - If an MTP event occurs, the ALERT# pin will be asserted.
6.16 Multiple Touch Pattern Register
The Multiple Touch Pattern register acts as a pattern to identify an expected sensor input profile for diagnostics or other
significant events. There are two methods for how the Multiple Touch Pattern register is used: as specific sensor inputs
or number of sensor input that must exceed the MTP threshold or have Noise Flag Status bits set. Which method is used
is based on the COMP_PTRN bit (see Section 6.15). The methods are described below.
1. Specific Sensor Inputs: If, during a single polling cycle, the specific sensor inputs above the MTP threshold or
with Noise Flag Status bits set match those bits set in the Multiple Touch Pattern register, an MTP event is
flagged.
2. Number of Sensor Inputs: If, during a single polling cycle, the number of sensor inputs with a delta count above
the MTP threshold or with Noise Flag Status bits set is equal to or greater than the number of pattern bits set, an
MTP event is flagged.
Bit 5 - CS6_PTRN - Determines whether CS6 is considered as part of the Multiple Touch Pattern.
• ‘0’ - CS6 is not considered a part of the pattern.
• ‘1’ - CS6 is considered a part of the pattern or the absolute number of sensor inputs that must have a delta count
greater than the MTP threshold or have the Noise Flag Status bit set is increased by 1.
Bit 4 - CS5_PTRN - Determines whether CS5 is considered as part of the Multiple Touch Pattern.
Bit 3 - CS4_PTRN - Determines whether CS4 is considered as part of the Multiple Touch Pattern.
Bit 2 - CS3_PTRN - Determines whether CS3 is considered as part of the Multiple Touch Pattern.
TABLE 6-27: MTP_TH BIT DECODE
MTP_TH[1:0]
Threshold Divide Setting
1 0
0 0 12.5% (default)
0 1 25%
1 0 37.5%
1 1 100%
TABLE 6-28: MULTIPLE TOUCH PATTERN REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
2Dh R/W Multiple
Touch Pattern - - CS6_
PTRN
CS5_
PTRN
CS4_
PTRN
CS3_
PTRN
CS2_
PTRN
CS1_
PTRN 3Fh
CAP1106
DS00001624B-page 32 2015 Microchip Technology Inc.
Bit 1 - CS2_PTRN - Determines whether CS2 is considered as part of the Multiple Touch Pattern.
Bit 0 - CS1_PTRN - Determines whether CS1 is considered as part of the Multiple Touch Pattern.
6.17 Recalibration Configuration Register
The Recalibration Configuration register controls the automatic re-calibration routine settings as well as advanced controls
to program the Sensor Input Threshold register settings.
Bit 7 - BUT_LD_TH - Enables setting all Sensor Input Threshold registers by writing to the Sensor Input 1 Threshold
register.
• ‘0’ - Each Sensor Input X Threshold register is updated individually.
• ‘1’ (default) - Writing the Sensor Input 1 Threshold register will automatically overwrite the Sensor Input Threshold
registers for all sensor inputs (Sensor Input Threshold 1 through Sensor Input Threshold 6). The individual Sensor
Input X Threshold registers (Sensor Input 2 Threshold through Sensor Input 6 Threshold) can be individually
updated at any time.
Bit 6 - NO_CLR_INTD - Controls whether the accumulation of intermediate data is cleared if the noise status bit is set.
• ‘0’ (default) - The accumulation of intermediate data is cleared if the noise status bit is set.
• ‘1’ - The accumulation of intermediate data is not cleared if the noise status bit is set.
APPLICATION NOTE: Bits 5 and 6 should both be set to the same value. Either both should be set to ‘0’ or both
should be set to ‘1’.
Bit 5 - NO_CLR_NEG - Controls whether the consecutive negative delta counts counter is cleared if the noise status bit
is set.
• ‘0’ (default) - The consecutive negative delta counts counter is cleared if the noise status bit is set.
• ‘1’ - The consecutive negative delta counts counter is not cleared if the noise status bit is set.
Bits 4 - 3 - NEG_DELTA_CNT[1:0] - Determines the number of negative delta counts necessary to trigger a digital recalibration
as shown in Table 6-30.
Bits 2 - 0 - CAL_CFG[2:0] - Determines the update time and number of samples of the automatic re-calibration routine.
The settings apply to all sensor inputs universally (though individual sensor inputs can be configured to support re-calibration
- see Section 6.11).
TABLE 6-29: RECALIBRATION CONFIGURATION REGISTERS
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
2Fh R/W Recalibration
Configuration
BUT_
LD_TH
NO_
CLR_
INTD
NO_
CLR_
NEG
NEG_DELTA_
CNT[1:0] CAL_CFG[2:0] 8Ah
TABLE 6-30: NEG_DELTA_CNT BIT DECODE
NEG_DELTA_CNT[1:0]
Number of Consecutive Negative Delta Count Values
1 0
00 8
0 1 16 (default)
1 0 32
1 1 None (disabled)
TABLE 6-31: CAL_CFG BIT DECODE
CAL_CFG[2:0] Recalibration Samples
(see Note 6-1)
Update Time (see
Note 6-2) 210
0 0 0 16 16
0 0 1 32 32
2015 Microchip Technology Inc. DS00001624B-page 33
CAP1106
Note 6-1 Recalibration Samples refers to the number of samples that are measured and averaged before the
Base Count is updated however does not control the base count update period.
Note 6-2 Update Time refers to the amount of time (in polling cycle periods) that elapses before the Base
Count is updated. The time will depend upon the number of channels active, the averaging setting,
and the programmed cycle time.
6.18 Sensor Input Threshold Registers
The Sensor Input Threshold registers store the delta threshold that is used to determine if a touch has been detected.
When a touch occurs, the input signal of the corresponding sensor pad changes due to the capacitance associated with
a touch. If the sensor input change exceeds the threshold settings, a touch is detected.
When the BUT_LD_TH bit is set (see Section 6.17 - bit 7), writing data to the Sensor Input 1 Threshold register will
update all of the sensor input threshold registers (31h - 35h inclusive).
6.19 Sensor Input Noise Threshold Register
The Sensor Input Noise Threshold register controls the value of a secondary internal threshold to detect noise and
improve the automatic recalibration routine. If a capacitive touch sensor input exceeds the Sensor Input Noise Threshold
but does not exceed the sensor input threshold, it is determined to be caused by a noise spike. That sample is not used
by the automatic re-calibration routine. This feature can be disabled by setting the DIS_DIG_NOISE bit.
0 1 0 64 64 (default)
0 1 1 128 128
1 0 0 256 256
1 0 1 256 1024
1 1 0 256 2048
1 1 1 256 4096
TABLE 6-32: SENSOR INPUT THRESHOLD REGISTERS
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
30h R/W Sensor Input 1
Threshold - 64 32 16 8 4 2 1 40h
31h R/W Sensor Input 2
Threshold - 64 32 16 8 4 2 1 40h
32h R/W Sensor Input 3
Threshold - 64 32 16 8 4 2 1 40h
33h R/W Sensor Input 4
Threshold - 64 32 16 8 4 2 1 40h
34h R/W Sensor Input 5
Threshold - 64 32 16 8 4 2 1 40h
35h R/W Sensor Input 6
Threshold - 64 32 16 8 4 2 1 40h
TABLE 6-33: SENSOR INPUT NOISE THRESHOLD REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
38h R/W Sensor Input
Noise Threshold CS_BN_TH [1:0] 01h
TABLE 6-31: CAL_CFG BIT DECODE (CONTINUED)
CAL_CFG[2:0] Recalibration Samples
(see Note 6-1)
Update Time (see
Note 6-2) 210
CAP1106
DS00001624B-page 34 2015 Microchip Technology Inc.
Bits 1-0 - CS1_BN_TH[1:0] - Controls the noise threshold for all capacitive touch sensor inputs, as shown in Table 6-34.
The threshold is proportional to the threshold setting.
6.20 Standby Channel Register
The Standby Channel register controls which (if any) capacitive touch sensor inputs are active during Standby.
Bit 5 - CS6_STBY - Controls whether the CS6 channel is active in Standby.
• ‘0’ (default) - The CS6 channel not be sampled during Standby mode.
• ‘1’ - The CS6 channel will be sampled during Standby Mode. It will use the Standby threshold setting, and the
standby averaging and sensitivity settings.
Bit 4 - CS5_STBY - Controls whether the CS5 channel is active in Standby.
Bit 3 - CS4_STBY - Controls whether the CS4 channel is active in Standby.
Bit 2 - CS3_STBY - Controls whether the CS3 channel is active in Standby.
Bit 1 - CS2_STBY - Controls whether the CS2 channel is active in Standby.
Bit 0 - CS1_STBY - Controls whether the CS1 channel is active in Standby.
6.21 Standby Configuration Register
The Standby Configuration register controls averaging and cycle time for those sensor inputs that are active in Standby.
This register is useful for detecting proximity on a small number of sensor inputs as it allows the user to change averaging
and sample times on a limited number of sensor inputs and still maintain normal functionality in the fully active
state.
Bit 7 - AVG_SUM - Determines whether the active sensor inputs will average the programmed number of samples or
whether they will accumulate for the programmed number of samples.
• ‘0’ - (default) - The active sensor input delta count values will be based on the average of the programmed number
of samples when compared against the threshold.
• ‘1’ - The active sensor input delta count values will be based on the summation of the programmed number of
samples when compared against the threshold. This bit should only be set when performing proximity detection as
a physical touch will overflow the delta count registers and may result in false readings.
Bits 6 - 4 - STBY_AVG[2:0] - Determines the number of samples that are taken for all active channels during the sensor
cycle as shown in Table 6-37. All samples are taken consecutively on the same channel before the next channel is sampled
and the result is averaged over the number of samples measured before updating the measured results.
TABLE 6-34: CSX_BN_TH BIT DECODE
CS_BN_TH[1:0]
Percent Threshold Setting
1 0
0 0 25%
0 1 37.5% (default)
1 0 50%
1 1 62.5%
TABLE 6-35: STANDBY CHANNEL REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
40h R/W Standby Channel - - CS6_
STBY
CS5_
STBY
CS4_
STBY
CS3_
STBY
CS2_
STBY
CS1_
STBY 00h
TABLE 6-36: STANDBY CONFIGURATION REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
41h R/W Standby Configuration
AVG_
SUM STBY_AVG[2:0] STBY_SAMP_
TIME[1:0]
STBY_CY_TIME
[1:0] 39h
2015 Microchip Technology Inc. DS00001624B-page 35
CAP1106
Bit 3-2 - STBY SAMP_TIME[1:0] - Determines the time to take a single sample when the device is in Standby as shown
in Table 6-38.
Bits 1 - 0 - STBY_CY_TIME[2:0] - Determines the overall cycle time for all measured channels during standby operation
as shown in Table 6-39. All measured channels are sampled at the beginning of the cycle time. If additional time is
remaining, the device is placed into a lower power state for the remaining duration of the cycle.
APPLICATION NOTE: The programmed cycle time is only maintained if the total averaging time for all samples is
less than the programmed cycle. The STBY_AVG[2:0] bits will take priority so that if more
samples are required than would normally be allowed during the cycle time, the cycle time
will be extended as necessary to accommodate the number of samples to be measured.
6.22 Standby Sensitivity Register
The Standby Sensitivity register controls the sensitivity for sensor inputs that are active in Standby.
TABLE 6-37: STBY_AVG BIT DECODE
STBY_AVG[2:0] Number of Samples Taken per
Measurement 2 10
0 0 0 1
0 01 2
0 10 4
0 1 1 8 (default)
1 0 0 16
1 0 1 32
1 1 0 64
1 1 1 128
TABLE 6-38: STBY_SAMP_TIME BIT DECODE
STBY_SAMP_TIME[1:0]
Sampling Time
1 0
0 0 320us
0 1 640us
1 0 1.28ms (default)
1 1 2.56ms
TABLE 6-39: STBY_CY_TIME BIT DECODE
STBY_CY_TIME[1:0]
Overall Cycle Time
1 0
0 0 35ms
0 1 70ms (default)
1 0 105ms
1 1 140ms
TABLE 6-40: STANDBY SENSITIVITY REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
42h R/W Standby Sensitivity
- - - - - STBY_SENSE[2:0] 02h
CAP1106
DS00001624B-page 36 2015 Microchip Technology Inc.
Bits 2 - 0 - STBY_SENSE[2:0] - Controls the sensitivity for sensor inputs that are active in Standby. The sensitivity settings
act to scale the relative delta count value higher or lower based on the system parameters. A setting of 000b is the
most sensitive while a setting of 111b is the least sensitive. At the more sensitive settings, touches are detected for a
smaller delta C corresponding to a “lighter” touch. These settings are more sensitive to noise however and a noisy environment
may flag more false touches than higher sensitivity levels.
APPLICATION NOTE: A value of 128x is the most sensitive setting available. At the most sensitivity settings, the
MSB of the Delta Count register represents 64 out of ~25,000 which corresponds to a touch
of approximately 0.25% of the base capacitance (or a ΔC of 25fF from a 10pF base
capacitance). Conversely a value of 1x is the least sensitive setting available. At these
settings, the MSB of the Delta Count register corresponds to a delta count of 8192 counts
out of ~25,000 which corresponds to a touch of approximately 33% of the base capacitance
(or a ΔC of 3.33pF from a 10pF base capacitance).
6.23 Standby Threshold Register
The Standby Threshold register stores the delta threshold that is used to determine if a touch has been detected. When
a touch occurs, the input signal of the corresponding sensor pad changes due to the capacitance associated with a
touch. If the sensor input change exceeds the threshold settings, a touch is detected.
6.24 Sensor Input Base Count Registers
TABLE 6-41: STBY_SENSE BIT DECODE
STBY_SENSE[2:0]
Sensitivity Multiplier
210
0 0 0 128x (most sensitive)
0 0 1 64x
0 1 0 32x (default)
0 1 1 16x
1 0 0 8x
1 0 1 4x
1 1 0 2x
1 1 1 1x - (least sensitive)
TABLE 6-42: STANDBY THRESHOLD REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
43h R/W Standby Threshold
- 64 32 16 8 4 2 1 40h
TABLE 6-43: SENSOR INPUT BASE COUNT REGISTERS
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
50h R Sensor Input 1
Base Count 128 64 32 16 8 4 2 1 C8h
51h R Sensor Input 2
Base Count 128 64 32 16 8 4 2 1 C8h
52h R Sensor Input 3
Base Count 128 64 32 16 8 4 2 1 C8h
53h R Sensor Input 4
Base Count 128 64 32 16 8 4 2 1 C8h
54h R Sensor Input 5
Base Count 128 64 32 16 8 4 2 1 C8h
55h R Sensor Input 6
Base Count 128 64 32 16 8 4 2 1 C8h
2015 Microchip Technology Inc. DS00001624B-page 37
CAP1106
The Sensor Input Base Count registers store the calibrated “Not Touched” input value from the capacitive touch sensor
inputs. These registers are periodically updated by the re-calibration routine.
The routine uses an internal adder to add the current count value for each reading to the sum of the previous readings
until sample size has been reached. At this point, the upper 16 bits are taken and used as the Sensor Input Base Count.
The internal adder is then reset and the re-calibration routine continues.
The data presented is determined by the BASE_SHIFT[3:0] bits (see Section 6.5).
6.25 Sensor Input Calibration Registers
The Sensor Input Calibration registers hold the 10-bit value that represents the last calibration value.
6.26 Product ID Register
The Product ID register stores a unique 8-bit value that identifies the device.
6.27 Manufacturer ID Register
The Vendor ID register stores an 8-bit value that represents Microchip.
TABLE 6-44: SENSOR INPUT CALIBRATION REGISTERS
ADDR Register R/W B7 B6 B5 B4 B3 B2 B1 B0 Default
B1h Sensor Input 1
Calibration R CAL1_9 CAL1_8 CAL1_7 CAL1_6 CAL1_5 CAL1_4 CAL1_3 CAL1_2 00h
B2h Sensor Input 2
Calibration R CAL2_9 CAL2_8 CAL2_7 CAL2_6 CAL2_5 CAL2_4 CAL2_3 CAL2_2 00h
B3h Sensor Input 3
Calibration R CAL3_9 CAL3_8 CAL3_7 CAL3_6 CAL3_5 CAL3_4 CAL3_3 CAL3_2 00h
B4h Sensor Input 4
Calibration R CAL4_9 CAL4_8 CAL4_7 CAL4_6 CAL4_5 CAL4_4 CAL4_3 CAL4_2 00h
B5h Sensor Input 5
Calibration R CAL5_9 CAL5_8 CAL5_7 CAL5_6 CAL5_5 CAL5_4 CAL5_3 CAL5_2 00h
B6h Sensor Input 6
Calibration R CAL6_9 CAL6_8 CAL6_7 CAL6_6 CAL6_5 CAL6_4 CAL6_3 CAL6_2 00h
B9h
Sensor Input
Calibration LSB
1
R CAL4_1 CAL4_0 CAL3_1 CAL3_0 CAL2_1 CAL2_0 CAL1_1 CAL1_0 00h
BAh
Sensor Input
Calibration LSB
2
R - - - - CAL6_1 CAL6_0 CAL5_1 CAL5_0 00h
TABLE 6-45: PRODUCT ID REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
FDh R Product ID
CAP1106
0 1 0 1 0 1 0 1 55h
TABLE 6-46: VENDOR ID REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
FEh R Manufacturer ID 0 1 0 1 1 1 0 1 5Dh
CAP1106
DS00001624B-page 38 2015 Microchip Technology Inc.
6.28 Revision Register
The Revision register stores an 8-bit value that represents the part revision.
TABLE 6-47: REVISION REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
FFh R Revision 1 0 0 0 0 0 1 1 83h
2015 Microchip Technology Inc. DS00001624B-page 39
CAP1106
7.0 PACKAGE INFORMATION
7.1 CAP1106 Package Drawings
FIGURE 7-1: 10-Pin DFN 3mm x 3mm Package Drawings (1 of 2)
Note: For the most current package drawings,
see the Microchip Packaging Specification at
http://www.microchip.com/packaging
CAP1106
DS00001624B-page 40 2015 Microchip Technology Inc.
FIGURE 7-2: 10-Pin DFN 3mm x 3mm Package Drawings (2 of 2)
Note: For the most current package drawings,
see the Microchip Packaging Specification at
http://www.microchip.com/packaging
2015 Microchip Technology Inc. DS00001624B-page 41
CAP1106
7.2 Package Marking
FIGURE 7-3: CAP1106 Package Markings
1 8 W
NNNA
e4
TOP
BOTTOM
Bottom marking not allowed
PB-FREE/GREEN SYMBOL
PIN 1 (Ni/Pd PP-LF)
Line 1 – Device Code, Week 2x 0.6
Line 2 – Alphanumeric Traceability Code
W
Lines 1-2:
Line 3:
Center Horizontal Alignment
As Shown
CAP1106
DS00001624B-page 42 2015 Microchip Technology Inc.
APPENDIX A: DEVICE DELTA
A.1 Delta from CAP1006 to CAP1106
1. Updated circuitry to improve power supply rejection.
2. Added Multiple Touch Pattern detection circuitry. See Section 6.15, "Multiple Touch Pattern Configuration Register".
3. Added General Status register to flag Multiple touches, Multiple Touch Pattern issues and general touch detections.
See Section 6.2, "Status Registers".
4. Added bits 6 and 5 to the Recalibration Configuration register (2Fh - see Section 6.17, "Recalibration Configuration
Register"). These bits control whether the accumulation of intermediate data and the consecutive negative
delta counts counter are cleared when the noise status bit is set.
5. Added Configuration 2 register for noise detection controls and control to interrupt on press but not on release.
Added control to change alert pin polarity. See Section 6.6, "Configuration Registers".
6. Updated Deep Sleep behavior so that device does not clear DSLEEP bit on received communications but will
wake to communicate.
7. Register delta:
Table A.1 Register Delta From CAP1006 to CAP1106
Address Register Delta Delta Default
00h
Page 20
Changed - Main Status /
Control
added bits 7-6 to control gain 00h
02h
Page 21
New - General Status new register to store MTP, MULT, and general
TOUCH bits
00h
44h
Page 24
New - Configuration 2 new register to control alert polarity, and
noise detection, and interrupt on release
00h
24h
Page 27
Changed - Averaging
Control
updated register bits - moved
SAMP_AVG[2:0] bits and added SAMP_-
TIME bit 1. Default changed
39h
2Bh
Page 30
New - Multiple Touch
Pattern Configuration
new register for Multiple Touch Pattern
configuration - enable and threshold settings
80h
2Dh
Page 31
New - Multiple Touch
Pattern Register
new register for Multiple Touch Pattern
detection circuitry - pattern or number of
sensor inputs
3Fh
2Fh
Page 32
Changed - Recalibration
Configuration
updated register - updated CAL_CFG bit
decode to add a 128 averages setting and
removed highest time setting. Default
changed. Added bit 6 NO_CLR_INTD and
bit 5 NO_CLR_NEG.
8Ah
38h
Page 33
Changed - Sensor Input
Noise Threshold
updated register bits - removed bits 7 - 3
and consolidated all controls into bits 1 - 0.
These bits will set the noise threshold for
all channels. Default changed
01h
39h Removed - Noise
Threshold Register 2
removed register n/a
41h
Page 34
Changed - Standby Configuration
updated register bits - moved
STBY_AVG[2:0] bits and added STBY_-
TIME bit 1. Default changed
39h
FDh
Page 37
Changed - Product ID Changed bit decode for CAP1106 55h
2015 Microchip Technology Inc. DS00001624B-page 43
CAP1106
APPENDIX B: DATA SHEET REVISION HISTORY
Revision Section/Figure/Entry Correction
DS00001624B (02-09-15)
Features, Table 2-2, Table 2-
2, "Pin Types", Section 5.0,
"General Description"
References to BC-Link Interface, BC_DATA, BC_-
CLK, BC-IRQ#, BC-Link bus have been removed
Application Note under Table
2-6
[BC-Link] hidden in data sheet
Table 3-2, "Electrical Specifications"
BC-Link Timing Section hidden in data sheet
Table 4-1 Protocol Used for 68K Pull Down Resistor changed
from “BC-Link Communications” to “Reserved”
Section 4.1.3 BC-Link Communications
Removed this section and Application Note
Section 4.2.2, "SMBus
Address and RD / WR Bit"
Replaced “client address” with “slave address” in this
section.
Section 4.2.4, SMBus ACK
and NACK Bits, Section 4.2.5,
SMBus Stop Bit,Section 4.2.7,
SMBus and I2C Compatibility
Replaced “client” with “slave” in these sections.
Table 4-3, "Read Byte Protocol"
Heading changed from “Client Address” to “Slave
Address”
Section 5.1, Power States Removed “BC-Link” Application Notes
Table 6-1 Register Name for Register Address 77h changed
from “LED Linked Transition Control” to “Linked LED
Transition Control”
Section 6.1 Main Control Register
BC-Link paragraph removed from Bit 4 under Table
6-3
Section 7.7 Package Marking Updated package drawing
Figure 7-25 CAP1106 with
BC-Link Support Package
Markings
Removed figure.
Appendix A: Device Delta changed 2Dh to 2Fh in item #12
Product Identification System Removed BC-Link references
REV A REV A replaces previous SMSC version Rev. 1.32 (01-05-12)
Rev. 1.32 (01-05-12) Table 3-2, "Electrical Specifications"
Added conditions for tHD:DAT.
Section 4.2.7, "SMBus and
I2C Compatibility"
Renamed from “SMBus and I2C Compliance.”
First paragraph, added last sentence: “For information
on using the CAP1106 in an I2C system, refer to
SMSC AN 14.0 SMSC Dedicated Slave Devices in
I
2C Systems.”
Added: CAP1106 supports I2C fast mode at 400kHz.
This covers the SMBus max time of 100kHz.
Section 6.4, "Sensor Input
Delta Count Registers"
Changed negative value cap from FFh to 80h.
Rev. 1.31 (08-18-11) Section 4.3.3, "SMBus Send
Byte"
Added an application note: The Send Byte protocol
is not functional in Deep Sleep (i.e., DSLEEP bit is
set).
Section 4.3.4, "SMBus
Receive Byte"
Added an application note: The Receive Byte protocol
is not functional in Deep Sleep (i.e., DSLEEP bit
is set).
CAP1106
DS00001624B-page 44 2015 Microchip Technology Inc.
Section 6.2, "Status Registers"
Removed RESET as bit 3 in register 02h.
Rev. 1.3 (05-18-11) Section 6.28, "Revision Register"
Updated revision ID from 82h to 83h.
Section 6.2, "Status Registers"
Added RESET as bit 3 in register 02h.
Rev. 1.2 (02-10-11) Section A.8, "Delta from Rev
B (Mask B0) to Rev C (Mask
B1)"
Added.
Table 3-2, "Electrical Specifications"
PSR improvements made in functional revision B.
Changed PSR spec from ±100 typ and ±200 max
counts / V to ±3 and ±10 counts / V. Conditions
updated.
Section 5.2.2, "Recalibrating
Sensor Inputs"
Added more detail with subheadings for each type of
recalibration.
Section 6.6, "Configuration
Registers"
Added bit 5 BLK_PWR_CTRL to the Configuration 2
Register 44h.
The TIMEOUT bit is set to ‘1’ by default for functional
revision B and is set to ‘0’ by default for functional
revision C.
Section 6.28, "Revision Register"
Updated revision ID in register FFh from 81h to 82h.
Rev. 1.1 (11-17-10) Document Updated for functional revision B. See Section A.7,
"Delta from Rev A (Mask A0) to Rev B (Mask B0)".
Cover Added to General Description: “includes circuitry and
support for enhanced sensor proximity detection.”
Added the following Features:
Calibrates for Parasitic Capacitance
Analog Filtering for System Noise Sources
Press and Hold feature for Volume-like Applications
Table 3-2, "Electrical Specifications"
Conditions for Power Supply Rejection modified adding
the following:
Sampling time = 2.56ms
Averaging = 1
Negative Delta Counts = Disabled
All other parameters default
Section 6.11, "Calibration Activate
Register"
Updated register description to indicate which re-calibration
routine is used.
Section 6.14, "Multiple Touch
Configuration Register"
Updated register description to indicate what will
happen.
Table 6-34, "CSx_BN_TH Bit
Decode"
Table heading changed from “Threshold Divide Setting”
to “Percent Threshold Setting”.
Rev. 1.0 (06-14-10) Initial release
Revision Section/Figure/Entry Correction
2015 Microchip Technology Inc. DS00001624B-page 45
CAP1106
THE MICROCHIP WEB SITE
Microchip provides online support via our WWW site at www.microchip.com. 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 (FAQ), 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
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. Under “Support”, click on “Customer Change Notification”
and follow the registration instructions.
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://www.microchip.com/support
CAP1106
DS00001624B-page 46 2015 Microchip Technology Inc.
PRODUCT IDENTIFICATION SYSTEM
To order or obtain information, e.g., on pricing or delivery, refer to the factory or the listed sales office.
PART NO. [X] - [X] - XXX - [X](1)
l l l l l
Device Temperature Addressing Package Tape and Reel
Range Option Option
Example:
Note 1: Tape and Reel identifier only appears in the catalog part number description. This identifier is used for ordering
purposes and is not printed on the device package. Check with your Microchip Sales Office for package availability
with the Tape and Reel option.
Device: CAP1106
Temperature
Range:
Blank = 0°C to +85°C (Extended Commercial)
Package: AIA = DFN
Tape and
Reel Option:
TR = Tape and Reel(1)
CAP1106-1-AIA-TR
10-pin DFN 3mm x 3mm (RoHS compliant)
Six capacitive touch sensor inputs, SMBus
interface
Reel size is 4,000 pieces
2015 Microchip Technology Inc. DS00001624B-page 47
CAP1106
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, FlashFlex, flexPWR, JukeBlox, KEELOQ, KEELOQ logo, Kleer, LANCheck,
MediaLB, MOST, MOST logo, MPLAB, OptoLyzer, PIC, PICSTART, PIC32 logo, RightTouch, SpyNIC, SST, SST Logo, SuperFlash and
UNI/O are registered trademarks of Microchip Technology Incorporated in the U.S.A. and other countries.
The Embedded Control Solutions Company and mTouch are registered trademarks of Microchip Technology Incorporated in the U.S.A.
Analog-for-the-Digital Age, BodyCom, chipKIT, chipKIT logo, CodeGuard, dsPICDEM, dsPICDEM.net, ECAN, In-Circuit Serial
Programming, ICSP, Inter-Chip Connectivity, KleerNet, KleerNet logo, MiWi, MPASM, MPF, MPLAB Certified logo, MPLIB, MPLINK,
MultiTRAK, NetDetach, Omniscient Code Generation, PICDEM, PICDEM.net, PICkit, PICtail, RightTouch logo, REAL ICE, SQI, Serial
Quad I/O, Total Endurance, TSHARC, USBCheck, VariSense, ViewSpan, WiperLock, Wireless DNA, 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.
Silicon Storage Technology is a registered trademark of Microchip Technology Inc. in other countries.
GestIC is a registered trademarks of Microchip Technology Germany II GmbH & Co. KG, a subsidiary of Microchip Technology Inc., in
other countries.
All other trademarks mentioned herein are property of their respective companies.
© 2015, Microchip Technology Incorporated, Printed in the U.S.A., All Rights Reserved.
ISBN: 9781632770349
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.
QUALITY MANAGEMENT SYSTEM
CERTIFIED BY DNV
== ISO/TS 16949 ==
2015 Microchip Technology Inc. DS00001624B-page 48
AMERICAS
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
Atlanta
Duluth, GA
Tel: 678-957-9614
Fax: 678-957-1455
Austin, TX
Tel: 512-257-3370
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
Novi, MI
Tel: 248-848-4000
Houston, TX
Tel: 281-894-5983
Indianapolis
Noblesville, IN
Tel: 317-773-8323
Fax: 317-773-5453
Los Angeles
Mission Viejo, CA
Tel: 949-462-9523
Fax: 949-462-9608
New York, NY
Tel: 631-435-6000
San Jose, CA
Tel: 408-735-9110
Canada - Toronto
Tel: 905-673-0699
Fax: 905-673-6509
ASIA/PACIFIC
Asia Pacific Office
Suites 3707-14, 37th Floor
Tower 6, The Gateway
Harbour City, Kowloon
Hong Kong
Tel: 852-2943-5100
Fax: 852-2401-3431
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
China - Dongguan
Tel: 86-769-8702-9880
China - Hangzhou
Tel: 86-571-8792-8115
Fax: 86-571-8792-8116
China - Hong Kong SAR
Tel: 852-2943-5100
Fax: 852-2401-3431
China - Nanjing
Tel: 86-25-8473-2460
Fax: 86-25-8473-2470
China - Qingdao
Tel: 86-532-8502-7355
Fax: 86-532-8502-7205
China - Shanghai
Tel: 86-21-5407-5533
Fax: 86-21-5407-5066
China - Shenyang
Tel: 86-24-2334-2829
Fax: 86-24-2334-2393
China - Shenzhen
Tel: 86-755-8864-2200
Fax: 86-755-8203-1760
China - Wuhan
Tel: 86-27-5980-5300
Fax: 86-27-5980-5118
China - Xian
Tel: 86-29-8833-7252
Fax: 86-29-8833-7256
ASIA/PACIFIC
China - Xiamen
Tel: 86-592-2388138
Fax: 86-592-2388130
China - Zhuhai
Tel: 86-756-3210040
Fax: 86-756-3210049
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
India - Pune
Tel: 91-20-3019-1500
Japan - Osaka
Tel: 81-6-6152-7160
Fax: 81-6-6152-9310
Japan - Tokyo
Tel: 81-3-6880- 3770
Fax: 81-3-6880-3771
Korea - Daegu
Tel: 82-53-744-4301
Fax: 82-53-744-4302
Korea - Seoul
Tel: 82-2-554-7200
Fax: 82-2-558-5932 or
82-2-558-5934
Malaysia - Kuala Lumpur
Tel: 60-3-6201-9857
Fax: 60-3-6201-9859
Malaysia - Penang
Tel: 60-4-227-8870
Fax: 60-4-227-4068
Philippines - Manila
Tel: 63-2-634-9065
Fax: 63-2-634-9069
Singapore
Tel: 65-6334-8870
Fax: 65-6334-8850
Taiwan - Hsin Chu
Tel: 886-3-5778-366
Fax: 886-3-5770-955
Taiwan - Kaohsiung
Tel: 886-7-213-7828
Taiwan - Taipei
Tel: 886-2-2508-8600
Fax: 886-2-2508-0102
Thailand - Bangkok
Tel: 66-2-694-1351
Fax: 66-2-694-1350
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
Fax: 33-1-69-30-90-79
Germany - Dusseldorf
Tel: 49-2129-3766400
Germany - Munich
Tel: 49-89-627-144-0
Fax: 49-89-627-144-44
Germany - Pforzheim
Tel: 49-7231-424750
Italy - Milan
Tel: 39-0331-742611
Fax: 39-0331-466781
Italy - Venice
Tel: 39-049-7625286
Netherlands - Drunen
Tel: 31-416-690399
Fax: 31-416-690340
Poland - Warsaw
Tel: 48-22-3325737
Spain - Madrid
Tel: 34-91-708-08-90
Fax: 34-91-708-08-91
Sweden - Stockholm
Tel: 46-8-5090-4654
UK - Wokingham
Tel: 44-118-921-5800
Fax: 44-118-921-5820
Worldwide Sales and Service
01/27/15
2015 Microchip Technology Inc. DS00001623B-page 1
General Description
The CAP1126, which incorporates RightTouch® technology,
is a multiple channel Capacitive Touch sensor
with multiple power LED drivers. It contains six (6) individual
capacitive touch sensor inputs with programmable
sensitivity for use in touch sensor applications.
Each sensor input automatically recalibrates to compensate
for gradual environmental changes.
The CAP1126 also contains two (2) LED drivers that
offer full-on / off, variable rate blinking, dimness controls,
and breathing. Each of the LED drivers may be
linked to one of the sensor inputs to be actuated when
a touch is detected. As well, each LED driver may be
individually controlled via a host controller.
The CAP1126 includes Multiple Pattern Touch recognition
that allows the user to select a specific set of buttons
to be touched simultaneously. If this pattern is
detected, then a status bit is set and an interrupt generated.
Additionally, the CAP1126 includes circuitry and support
for enhanced sensor proximity detection.
The CAP1126 offers multiple power states operating at
low quiescent currents. In the Standby state of operation,
one or more capacitive touch sensor inputs are
active and all LEDs may be used. If a touch is detected,
it will wake the system using the WAKE/SPI_MOSI pin.
Deep Sleep is the lowest power state available, drawing
5uA (typical) of current. In this state, no sensor
inputs are active. Driving the WAKE/SPI_MOSI pin or
communications will wake the device.
Applications
• Desktop and Notebook PCs
• LCD Monitors
• Consumer Electronics
• Appliances
Features
• Six (6) Capacitive Touch Sensor Inputs
- Programmable sensitivity
- Automatic recalibration
- Individual thresholds for each button
• Proximity Detection
• Multiple Button Pattern Detection
• Calibrates for Parasitic Capacitance
• Analog Filtering for System Noise Sources
• Press and Hold feature for Volume-like Applications
• Multiple Communication Interfaces
- SMBus / I2C compliant interface
- SPI communications
- Pin selectable communications protocol and
multiple slave addresses (SMBus / I2C only)
• Low Power Operation
- 5uA quiescent current in Deep Sleep
- 50uA quiescent current in Standby (1 sensor
input monitored)
- Samples one or more channels in Standby
• Two (2) LED Driver Outputs
- Open Drain or Push-Pull
- Programmable blink, breathe, and dimness
controls
- Can be linked to Capacitive Touch Sensor
inputs
• Dedicated Wake output flags touches in low
power state
• System RESET pin
• Available in 16-pin 4mm x 4mm RoHS compliant
QFN package
CAP1126
6 Channel Capacitive Touch Sensor with 2 LED Drivers
CAP1126
DS00001623B-page 2 2015 Microchip Technology Inc.
TO OUR VALUED CUSTOMERS
It is our intention to provide our valued customers with the best documentation possible to ensure successful use of your Microchip
products. To this end, we will continue to improve our publications to better suit your needs. Our publications will be refined and
enhanced as new volumes and updates are introduced.
If you have any questions or comments regarding this publication, please contact the Marketing Communications Department via
E-mail at docerrors@microchip.com. We welcome your feedback.
Most Current Data Sheet
To obtain the most up-to-date version of this data sheet, please register at our Worldwide Web site at:
http://www.microchip.com
You can determine the version of a data sheet by examining its literature number found on the bottom outside corner of any page.
The last character of the literature number is the version number, (e.g., DS30000000A is version A of document DS30000000).
Errata
An errata sheet, describing minor operational differences from the data sheet and recommended workarounds, may exist for current
devices. As device/documentation issues become known to us, we will publish an errata sheet. The errata will specify the
revision of silicon and revision of document to which it applies.
To determine if an errata sheet exists for a particular device, please check with one of the following:
• Microchip’s Worldwide Web site; http://www.microchip.com
• Your local Microchip sales office (see last page)
When contacting a sales office, please specify which device, revision of silicon and data sheet (include -literature number) you are
using.
Customer Notification System
Register on our web site at www.microchip.com to receive the most current information on all of our products.
2015 Microchip Technology Inc. DS00001623B-page 3
CAP1126
Table of Contents
1.0 Block Diagram ................................................................................................................................................................................. 4
2.0 Pin Description ................................................................................................................................................................................ 5
3.0 Electrical Specifications .................................................................................................................................................................. 9
4.0 Communications ........................................................................................................................................................................... 12
5.0 General Description ...................................................................................................................................................................... 23
6.0 Register Description ...................................................................................................................................................................... 29
7.0 Package Information ..................................................................................................................................................................... 67
Appendix A: Device Delta ................................................................................................................................................................... 72
Appendix B: Data Sheet Revision History ........................................................................................................................................... 74
The Microchip Web Site ...................................................................................................................................................................... 76
Customer Change Notification Service ............................................................................................................................................... 76
Customer Support ............................................................................................................................................................................... 76
Product Identification System ............................................................................................................................................................. 77
CAP1126
DS00001623B-page 4 2015 Microchip Technology Inc.
1.0 BLOCK DIAGRAM
SMBus /
BC-Link /
SPI Slave
Protocol
SMCLK BC_CLK /
SPI_CLK
SMDATA BC_DATA / SPI_MSIO /
SPI_MISO
VDD GND
ALERT# / BC_IRQ#
Capacitive Touch Sensing Algorithm
LED1
CS1 CS2 CS3 CS4 CS5 CS6
LED Driver, Breathe, and
Dimness control
RESET WAKE / SPI_MOSI
ADDR_COMM
SPI_CS#
LED2
2015 Microchip Technology Inc. DS00001623B-page 5
CAP1126
2.0 PIN DESCRIPTION
FIGURE 2-1: CAP1126 Pin Diagram (16-Pin QFN)
TABLE 2-1: PIN DESCRIPTION FOR CAP1126
Pin
Number Pin Name Pin Function Pin Type Unused
Connection
1 SPI_CS# Active low chip-select for SPI bus DI (5V) Connect to
Ground
2 WAKE / SPI_-
MOSI
WAKE - Active high wake / interrupt output
Standby power state - requires pull-down resistor DO
Pull-down
WAKE - Active high wake input - requires pull-down Resistor
resistor
Deep Sleep power state
DI
SPI_MOSI - SPI Master-Out-Slave-In port when used in
normal mode DI (5V) Connect to
Ground
1
2
3
4
12
11
10
9
16
15
14
13
5
6
7
8
SMCLK / BC_CLK /
SPI_CLK
SMDATA / BC_DATA / SPI_MSIO /
SPI_MISO
WAKE / SPI_MOSI
ADDR_COMM
VDD
CS6
SPI_CS#
CS5
CS1
CS2
CS3
RESET
LED1
LED2
CS4
ALERT# / BC_IRQ#
CAP1126
16 pin QFN
GND
CAP1126
DS00001623B-page 6 2015 Microchip Technology Inc.
3
SMDATA /
SPI_MSIO /
SPI_MISO
SMDATA - Bi-directional, open-drain SMBus data -
requires pull-up resistor DIOD (5V)
n/a
SPI_MSIO - SPI Master-Slave-In-Out bidirectional port
when used in bi-directional mode DIO
SPI_MISO - SPI Master-In-Slave-Out port when used in
normal mode DO
4 SMCLK / SPI_-
CLK
SMCLK - SMBus clock input - requires pull-up resistor DI (5V)
SPI_CLK - SPI clock input DI (5V) n/a
5 LED1
Open drain LED 1 driver (default) OD (5V) Connect to
Ground
Push-pull LED 1 driver DO
leave open or
connect to
Ground
6 LED2
Open drain LED 2 driver (default) OD (5V) Connect to
Ground
Push-pull LED 2 driver DO
leave open or
connect to
Ground
7 RESET Active high soft reset for system - resets all registers to
default values. If not used, connect to ground. DI (5V) Connect to
Ground
8 ALERT#
ALERT# - Active low alert / interrupt output for SMBus
alert or SPI interrupt OD (5V) Connect to
Ground
ALERT# - Active high push-pull alert / interrupt output for
SMBus alert or SPI interrupt DO leave open
9 ADDR_COMM Address / communications select pin - pull-down resistor
determines address / communications mechanism AI n/a
10 CS6 Capacitive Touch Sensor Input 6 AIO Connect to
Ground
11 CS5 Capacitive Touch Sensor Input 5 AIO Connect to
Ground
12 CS4 Capacitive Touch Sensor Input 4 AIO Connect to
Ground
13 CS3 Capacitive Touch Sensor Input 3 AIO Connect to
Ground
14 CS2 Capacitive Touch Sensor Input 2 AIO Connect to
Ground
15 CS1 Capacitive Touch Sensor Input 1 AIO Connect to
Ground
16 VDD Positive Power supply Power n/a
TABLE 2-1: PIN DESCRIPTION FOR CAP1126 (CONTINUED)
Pin
Number Pin Name Pin Function Pin Type Unused
Connection
2015 Microchip Technology Inc. DS00001623B-page 7
CAP1126
APPLICATION NOTE: When the ALERT# pinis configured as an active low output, it will be open drain. When it is
configured as an active high output, it will be push-pull.
APPLICATION NOTE: For the 5V tolerant pins that have a pull-up resistor, the pull-up voltage must not exceed 3.6V
when the CAP1126 is unpowered.
APPLICATION NOTE: The SPI_CS# pin should be grounded when SMBus, or I2C,communications are used.
The pin types are described in Table 2-2. All pins labeled with (5V) are 5V tolerant.
Bottom
Pad GND Ground Power n/a
TABLE 2-2: PIN TYPES
Pin Type Description
Power This pin is used to supply power or ground to the device.
DI Digital Input - This pin is used as a digital input. This pin is 5V tolerant.
AIO Analog Input / Output -This pin is used as an I/O for analog signals.
DIOD Digital Input / Open Drain Output - This pin is used as a digital I/O. When it is used as an output,
it is open drain and requires a pull-up resistor. This pin is 5V tolerant.
OD Open Drain Digital Output - This pin is used as a digital output. It is open drain and requires a
pull-up resistor. This pin is 5V tolerant.
DO Push-pull Digital Output - This pin is used as a digital output and can sink and source current.
DIO Push-pull Digital Input / Output - This pin is used as an I/O for digital signals.
TABLE 2-1: PIN DESCRIPTION FOR CAP1126 (CONTINUED)
Pin
Number Pin Name Pin Function Pin Type Unused
Connection
CAP1126
DS00001623B-page 8 2015 Microchip Technology Inc.
3.0 ELECTRICAL SPECIFICATIONS
Note 3-1 Stresses above those listed could cause permanent damage to the device. This is a stress rating
only and functional operation of the device at any other condition above those indicated in the
operation sections of this specification is not implied.
Note 3-2 For the 5V tolerant pins that have a pull-up resistor, the voltage difference between V5VT_PIN and VDD
must never exceed 3.6V.
Note 3-3 The Package Power Dissipation specification assumes a recommended thermal via design consisting
of a 3x3 matrix of 0.3mm (12mil) vias at 1.0mm pitch connected to the ground plane with a 2.1mm
x 2.1mm thermal landing.
Note 3-4 Junction to Ambient (θJA) is dependent on the design of the thermal vias. Without thermal vias and
a thermal landing, the θJA is approximately 60°C/W including localized PCB temperature increase.
TABLE 3-1: ABSOLUTE MAXIMUM RATINGS
Voltage on 5V tolerant pins (V5VT_PIN) -0.3 to 5.5 V
Voltage on 5V tolerant pins (|V5VT_PIN - VDD|) Note 3-2 0 to 3.6 V
Voltage on VDD pin -0.3 to 4 V
Voltage on any other pin to GND -0.3 to VDD + 0.3 V
Package Power Dissipation up to TA = 85°C for 16 pin QFN
(see Note 3-3)
0.9 W
Junction to Ambient (θJA) (see Note 3-4) 58 °C/W
Operating Ambient Temperature Range -40 to 125 °C
Storage Temperature Range -55 to 150 °C
ESD Rating, All Pins, HBM 8000 V
2015 Microchip Technology Inc. DS00001623B-page 9
CAP1126
TABLE 3-2: ELECTRICAL SPECIFICATIONS
VDD = 3V to 3.6V, TA = 0°C to 85°C, all typical values at TA = 27°C unless otherwise noted.
Characteristic Symbol Min Typ Max Unit Conditions
DC Power
Supply Voltage VDD 3.0 3.3 3.6 V
Supply Current
ISTBY 120 170 uA
Standby state active
1 sensor input monitored
No LEDs active
Default conditions (8 avg, 70ms
cycle time)
ISTBY 50 uA
Standby state active
1 sensor input monitored
No LEDs active
1 avg, 140ms cycle time,
IDSLEEP 5 15 uA
Deep Sleep state active
LEDs at 100% or 0% Duty Cycle
No communications
TA < 40°C
3.135 < VDD < 3.465V
IDD 500 600 uA Capacitive Sensing Active
No LEDs active
Capacitive Touch Sensor Inputs
Maximum Base
Capacitance CBASE 50 pF Pad untouched
Minimum Detectable
Capacitive Shift ΔCTOUCH 20 fF
Pad touched - default conditions (1
avg, 35ms cycle time, 1x sensitivity)
Recommended Cap
Shift ΔCTOUCH 0.1 2 pF Pad touched - Not tested
Power Supply Rejection
PSR ±3 ±10 counts /
V
Untouched Current Counts
Base Capacitance 5pF - 50pF
Maximum sensitivity
Negative Delta Counts disabled
All other parameters default
Timing
RESET Pin Delay tRST_DLY 10 ms
Time to communications
ready tCOMM_DLY 15 ms
Time to first conversion
ready tCONV_DLY 170 200 ms
LED Drivers
Duty Cycle DUTYLED 0 100 % Programmable
Drive Frequency fLED 2 kHz
Sinking Current ISINK 24 mA VOL = 0.4
Sourcing Current ISOURCE 24 mA VOH = VDD - 0.4
Leakage Current ILEAK ±5 uA
powered or unpowered
TA < 85°C
pull-up voltage < 3.6V if unpowered
I/O Pins
Output Low Voltage VOL 0.4 V ISINK_IO = 8mA
Output High Voltage VOH VDD - 0.4 V ISOURCE_IO = 8mA
CAP1126
DS00001623B-page 10 2015 Microchip Technology Inc.
Note 3-5 The ALERT pin will not glitch high or low at power up if connected to VDD or another voltage.
Note 3-6 The SMCLK and SMDATA pins will not glitch low at power up if connected to VDD or another voltage.
Input High Voltage VIH 2.0 V
Input Low Voltage VIL 0.8 V
Leakage Current ILEAK ±5 uA
powered or unpowered
TA < 85°C
pull-up voltage < 3.6V if unpowered
RESET Pin Release
to conversion ready tRESET 170 200 ms
SMBus Timing
Input Capacitance CIN 5 pF
Clock Frequency fSMB 10 400 kHz
Spike Suppression tSP 50 ns
Bus Free Time Stop to
Start tBUF 1.3 us
Start Setup Time tSU:STA 0.6 us
Start Hold Time tHD:STA 0.6 us
Stop Setup Time tSU:STO 0.6 us
Data Hold Time tHD:DAT 0 us When transmitting to the master
Data Hold Time tHD:DAT 0.3 us When receiving from the master
Data Setup Time tSU:DAT 0.6 us
Clock Low Period tLOW 1.3 us
Clock High Period tHIGH 0.6 us
Clock / Data Fall Time tFALL 300 ns Min = 20+0.1CLOAD ns
Clock / Data Rise
Time tRISE 300 ns Min = 20+0.1CLOAD ns
Capacitive Load CLOAD 400 pF per bus line
SPI Timing
Clock Period tP 250 ns
Clock Low Period tLOW 0.4 x tP 0.6 x tP ns
Clock High Period tHIGH 0.4 x tP 0.6 x tP ns
Clock Rise / Fall time tRISE / tFALL 0.1 x tP ns
Data Output Delay tD:CLK 10 ns
Data Setup Time tSU:DAT 20 ns
Data Hold Time tHD:DAT 20 ns
SPI_CS# to SPI_CLK
setup time tSU:CS 0 ns
Wake Time tWAKE 10 20 us SPI_CS# asserted to CLK assert
TABLE 3-2: ELECTRICAL SPECIFICATIONS (CONTINUED)
VDD = 3V to 3.6V, TA = 0°C to 85°C, all typical values at TA = 27°C unless otherwise noted.
Characteristic Symbol Min Typ Max Unit Conditions
2015 Microchip Technology Inc. DS00001623B-page 11
CAP1126
4.0 COMMUNICATIONS
4.1 Communications
The CAP1126communicates using the 2-wire SMBus or I2C bus, the 2-wire proprietary BC-Link, or the SPI bus. If the
proprietary BC-Link protocol is required for your application, please contact your Microchip representative for ordering
instructions. Regardless of communication mechanism, the device functionality remains unchanged. The communications
mechanism as well as the SMBus (or I2C) slave address is determined by the resistor connected between the
ADDR_COMM pin and ground as shown in Table 4-1.
4.1.1 SMBUS (I2C) COMMUNICATIONS
When configured to communicate via the SMBus, the CAP1126 supports the following protocols: Send Byte, Receive
Byte, Read Byte, Write Byte, Read Block, and Write Block. In addition, the device supports I2C formatting for block read
and block write protocols.
APPLICATION NOTE: For SMBus/I2C communications, the SPI_CS# pin is not used and should be grounded; any
data presented to this pin will be ignored.
See Section 4.2 and Section 4.3 for more information on the SMBus bus and protocols respectively.
4.1.2 SPI COMMUNICATIONS
When configured to communicate via the SPI bus, the CAP1126supports both bi-directional 3-wire and normal 4-wire
protocols and uses the SPI_CS# pin to enable communications.
APPLICATION NOTE: See Section 4.5 and Section 4.6 for more information on the SPI bus and protocols
respectively.Upon power up, the CAP1126 will not respond to any communications for up to
15ms. After this time, full functionality is available.
4.2 System Management Bus
The CAP1126 communicates with a host controller, such as an SIO, through the SMBus. The SMBus is a two-wire serial
communication protocol between a computer host and its peripheral devices. A detailed timing diagram is shown in
Figure 4-1. Stretching of the SMCLK signal is supported; however, the CAP1126 will not stretch the clock signal.
TABLE 4-1: ADDR_COMM PIN DECODE
Pull-Down Resistor (+/- 5%) Protocol Used SMBus Address
GND SPI Communications using Normal
4-wire Protocol Used
n/a
56k SPI Communications using BiDirectional
3-wire Protocol Used
n/a
68k Reserved n/a
82k SMBus / I2C 0101_100(r/w)
100k SMBus / I2C 0101_011(r/w)
120k SMBus / I2C 0101_010(r/w)
150k SMBus / I2C 0101_001(r/w)
VDD SMBus / I2C 0101_000(r/w)
CAP1126
DS00001623B-page 12 2015 Microchip Technology Inc.
4.2.1 SMBUS START BIT
The SMBus Start bit is defined as a transition of the SMBus Data line from a logic ‘1’ state to a logic ‘0’ state while the
SMBus Clock line is in a logic ‘1’ state.
4.2.2 SMBUS ADDRESS AND RD / WR BIT
The SMBus Address Byte consists of the 7-bit slave address followed by the RD / WR indicator bit. If this RD / WR bit
is a logic ‘0’, then the SMBus Host is writing data to the slave device. If this RD / WR bit is a logic ‘1’, then the SMBus
Host is reading data from the slave device.
See Table 4-1 for available SMBus addresses.
4.2.3 SMBUS DATA BYTES
All SMBus Data bytes are sent most significant bit first and composed of 8-bits of information.
4.2.4 SMBUS ACK AND NACK BITS
The SMBus slave will acknowledge all data bytes that it receives. This is done by the slave device pulling the SMBus
Data line low after the 8th bit of each byte that is transmitted. This applies to both the Write Byte and Block Write protocols.
The Host will NACK (not acknowledge) the last data byte to be received from the slave by holding the SMBus data line
high after the 8th data bit has been sent. For the Block Read protocol, the Host will ACK each data byte that it receives
except the last data byte.
4.2.5 SMBUS STOP BIT
The SMBus Stop bit is defined as a transition of the SMBus Data line from a logic ‘0’ state to a logic ‘1’ state while the
SMBus clock line is in a logic ‘1’ state. When the CAP1126 detects an SMBus Stop bit and it has been communicating
with the SMBus protocol, it will reset its slave interface and prepare to receive further communications.
4.2.6 SMBUS TIMEOUT
The CAP1126 includes an SMBus timeout feature. Following a 30ms period of inactivity on the SMBus where the
SMCLK pin is held low, the device will timeout and reset the SMBus interface.
The timeout function defaults to disabled. It can be enabled by setting the TIMEOUT bit in the Configuration register
(see Section 6.6, "Configuration Registers").
4.2.7 SMBUS AND I2C COMPATIBILITY
The major differences between SMBus and I2C devices are highlighted here. For more information, refer to the SMBus
2.0 and I2C specifications. For information on using the CAP1126 in an I2C system, refer to AN 14.0 Dedicated Slave
Devices in I2C Systems.
FIGURE 4-1: SMBus Timing Diagram
SMDATA
SMCLK
TLOW
TRISE
THIGH
TFALL
TBUF
THD:STA
P S S - Start Condition P - Stop Condition
THD:DAT TSU:DAT TSU:STA
THD:STA
P
TSU:STO
S
2015 Microchip Technology Inc. DS00001623B-page 13
CAP1126
1. CAP1126 supports I2C fast mode at 400kHz. This covers the SMBus max time of 100kHz.
2. Minimum frequency for SMBus communications is 10kHz.
3. The SMBus slave protocol will reset if the clock is held at a logic ‘0’ for longer than 30ms. This timeout functionality
is disabled by default in the CAP1126 and can be enabled by writing to the TIMEOUT bit. I2C does not have
a timeout.
4. The SMBus slave protocol will reset if both the clock and data lines are held at a logic ‘1’ for longer than 200µs
(idle condition). This function is disabled by default in the CAP1126 and can be enabled by writing to the TIMEOUT
bit. I2C does not have an idle condition.
5. I2C devices do not support the Alert Response Address functionality (which is optional for SMBus).
6. I2C devices support block read and write differently. I2C protocol allows for unlimited number of bytes to be sent
in either direction. The SMBus protocol requires that an additional data byte indicating number of bytes to read /
write is transmitted. The CAP1126 supports I2C formatting only.
4.3 SMBus Protocols
The CAP1126 is SMBus 2.0 compatible and supports Write Byte, Read Byte, Send Byte, and Receive Byte as valid
protocols as shown below.
All of the below protocols use the convention in Table 4-2.
4.3.1 SMBUS WRITE BYTE
The Write Byte is used to write one byte of data to a specific register as shown in Table 4-3.
4.3.2 SMBUS READ BYTE
The Read Byte protocol is used to read one byte of data from the registers as shown in Table 4-4.
4.3.3 SMBUS SEND BYTE
The Send Byte protocol is used to set the internal address register pointer to the correct address location. No data is
transferred during the Send Byte protocol as shown in Table 4-5.
APPLICATION NOTE: The Send Byte protocol is not functional in Deep Sleep (i.e., DSLEEP bit is set).
TABLE 4-2: PROTOCOL FORMAT
Data Sent to
Device
Data Sent to the
HOst
Data sent Data sent
TABLE 4-3: WRITE BYTE PROTOCOL
Start Slave
Address WR ACK Register
Address ACK Register Data ACK Stop
1 ->0 YYYY_YYY 0 0 XXh 0 XXh 0 0 -> 1
TABLE 4-4: READ BYTE PROTOCOL
Start Slave
Address WR ACK Register
Address ACK Start Slave
Address RD ACK Register
Data NACK Stop
1->0 YYYY_YYY 0 0 XXh 0 1 ->0 YYYY_YYY 1 0 XXh 1 0 -> 1
TABLE 4-5: SEND BYTE PROTOCOL
Start Slave Address WR ACK Register Address ACK Stop
1 -> 0 YYYY_YYY 0 0 XXh 0 0 -> 1
CAP1126
DS00001623B-page 14 2015 Microchip Technology Inc.
4.3.4 SMBUS RECEIVE BYTE
The Receive Byte protocol is used to read data from a register when the internal register address pointer is known to
be at the right location (e.g., set via Send Byte). This is used for consecutive reads of the same register as shown in
Table 4-6.
APPLICATION NOTE: The Receive Byte protocol is not functional in Deep Sleep (i.e., DSLEEP bit is set).
4.4 I2C Protocols
The CAP1126 supports I2C Block Write and Block Read.
The protocols listed below use the convention in Table 4-2.
4.4.1 BLOCK WRITE
The Block Write is used to write multiple data bytes to a group of contiguous registers as shown in Table 4-7.
APPLICATION NOTE: When using the Block Write protocol, the internal address pointer will be automatically
incremented after every data byte is received. It will wrap from FFh to 00h.
4.4.2 BLOCK READ
The Block Read is used to read multiple data bytes from a group of contiguous registers as shown in Table 4-8.
APPLICATION NOTE: When using the Block Read protocol, the internal address pointer will be automatically
incremented after every data byte is received. It will wrap from FFh to 00h.
4.5 SPI Interface
The SMBus has a predefined packet structure, the SPI does not. The SPI Bus can operate in two modes of operation,
normal 4-wire mode and bi-directional 3-wire mode. All SPI commands consist of 8-bit packets sent to a specific slave
device (identified by the CS pin).
The SPI bus will latch data on the rising edge of the clock and the clock and data both idle high.
All commands are supported via both operating modes. The supported commands are: Reset Serial interface, set
address pointer, write command and read command. Note that all other codes received during the command phase are
ignored and have no effect on the operation of the device.
TABLE 4-6: RECEIVE BYTE PROTOCOL
Start Slave Address RD ACK Register Data NACK Stop
1 -> 0 YYYY_YYY 1 0 XXh 1 0 -> 1
TABLE 4-7: BLOCK WRITE PROTOCOL
Start Slave
Address WR ACK Register
Address ACK Register Data ACK
1 ->0 YYYY_YYY 0 0 XXh 0 XXh 0
Register Data ACK Register
Data
ACK . . . Register
Data
ACK Stop
XXh 0 XXh 0 . . . XXh 0 0 -> 1
TABLE 4-8: BLOCK READ PROTOCOL
Start Slave
Address WR ACK Register
Address ACK Start Slave
Address RD ACK Register
Data
1->0 YYYY_YYY 0 0 XXh 0 1 ->0 YYYY_YYY 1 0 XXh
ACK Register
Data
ACK Register
Data
ACK Register
Data
ACK . . . Register
Data
NACK Stop
0 XXh 0 XXh 0 XXh 0 . . . XXh 1 0 -> 1
2015 Microchip Technology Inc. DS00001623B-page 15
CAP1126
4.5.1 SPI NORMAL MODE
The SPI Bus can operate in two modes of operation, normal and bi-directional mode. In the normal mode of operation,
there are dedicated input and output data lines. The host communicates by sending a command along the CAP1126
SPI_MOSI data line and reading data on the SPI_MISO data line. Both communications occur simultaneously which
allows for larger throughput of data transactions.
All basic transfers consist of two 8 bit transactions from the Master device while the slave device is simultaneously sending
data at the current address pointer value.
Data writes consist of two or more 8-bit transactions. The host sends a specific write command followed by the data to
write the address pointer. Data reads consist of one or more 8-bit transactions. The host sends the specific read data
command and continues clocking for as many data bytes as it wishes to receive.
4.5.2 SPI BI-DIRECTIONAL MODE
In the bi-directional mode of operation, the SPI data signals are combined into the SPI_MSIO line, which is shared for
data received by the device and transmitted by the device. The protocol uses a simple handshake and turn around
sequence for data communications based on the number of clocks transmitted during each phase.
All basic transfers consist of two 8 bit transactions. The first is an 8 bit command phase driven by the Master device.
The second is by an 8 bit data phase driven by the Master for writes, and by the CAP1126 for read operations.
The auto increment feature of the address pointer allows for successive reads or writes. The address pointer will return
to 00h after reaching FFh.
4.5.3 SPI_CS# PIN
The SPI Bus is a single master, multiple slave serial bus. Each slave has a dedicated CS pin (chip select) that the master
asserts low to identify that the slave is being addressed. There are no formal addressing options.
4.5.4 ADDRESS POINTER
All data writes and reads are accessed from the current address pointer. In both Bi-directional mode and Full Duplex
mode, the Address pointer is automatically incremented following every read command or every write command.
The address pointer will return to 00h after reaching FFh.
4.5.5 SPI TIMEOUT
The CAP1126 does not detect any timeout conditions on the SPI bus.
FIGURE 4-2: SPI Timing
SPI_MSIO or
SPI_MOSI or
SPI_MISO
SPI_CLK
tLOW
tRISE
tHIGH
tFALL
tD:CLK tHD:DAT
tSU:DAT
tP
2015 Microchip Technology Inc. DS00001623B-page 16
CAP1126 4.6 Normal SPI Protocols When operating in normal mode, the SPI bus internal address pointer is incremented depending upon which command has been transmitted. Multiple commands may be transmitted sequentually so long as the SPI_CS# pin is asserted low. Figure 4-3 shows an example of this operation.
4.6.1 RESET INTERFACE
Resets the Serial interface whenever two successive 7Ah codes are received. Regardless of the current phase of the transaction - command or data, the receipt of the
successive reset commands resets the Serial communication interface only. All other functions are not affected by the reset operation.
FIGURE 4-3: Example SPI Bus Communication - Normal Mode
SPI_CS#
SPI_MISO
SPI_MOSI
SPI Address Pointer
SPI Data output buffer
Register Address /
Data
7Ah
XXh
(invalid)
XXh
(invalid)
YYh
(invalid)
7Ah 7Dh 41h
YYh
(invalid)
7Eh 66h
XXh
(invalid) 45h
7Dh 41h
AAh
(invalid)
AAh
(invalid)
7Fh 7Fh
55h
(invalid) 66h
7Fh
AAh
7Dh
43h
40h
78h
7Fh
XXh
(invalid)
7Fh
56h
40h / 56h
41h / 45h
42h / AAh
43h / 55h
44h / 80h
45h / 43h
46h / 78h
41h
45h
40h / 56h
41h / 45h
42h / AAh
43h / 55h
44h / 80h
45h / 43h
46h / 78h
42h
AAh
40h / 56h
41h / 66h
42h / AAh
43h / 55h
44h / 80h
45h / 43h
46h / 78h
41h
55h
7Fh
AAh
40h / 56h
41h / 66h
42h / AAh
43h / 55h
44h / 80h
45h / 43h
46h / 78h
41h
66h
42h
AAh
40h / 56h
41h / 66h
42h / AAh
43h / 55h
44h / 80h
45h / 43h
46h / 78h
40h / 56h
41h / 66h
42h / AAh
43h / 55h
44h / 80h
45h / 43h
46h / 78h
40h / 56h
41h / 66h
42h / AAh
43h / 55h
44h / 80h
45h / 43h
46h /78h
44h
80h
40h
80h
40h
56h
40h / 56h
41h / 66h
42h / AAh
43h / 55h
44h / 80h
45h / 43h
46h /78h
43h
55h
7Fh 7Fh
55h
40h / 56h
41h / 66h
42h / AAh
43h / 55h
44h / 80h
45h / 43h
46h /78h
80h
45h
43h
46h
78h
40h / 56h
41h / 66h
42h / AAh
43h / 55h
44h / 80h
45h / 43h
46h / 78h
00h
XXh
Indicates SPI Address pointer incremented
2015 Microchip Technology Inc. DS00001623B-page 17
CAP1126
4.6.2 SET ADDRESS POINTER
The Set Address Pointer command sets the Address pointer for subsequent reads and writes of data. The pointer is set
on the rising edge of the final data bit. At the same time, the data that is to be read is fetched and loaded into the internal
output buffer but is not transmitted.
4.6.3 WRITE DATA
The Write Data protocol updates the contents of the register referenced by the address pointer. As the command is processed,
the data to be read is fetched and loaded into the internal output buffer but not transmitted. Then, the register
is updated with the data to be written. Finally, the address pointer is incremented.
FIGURE 4-4: SPI Reset Interface Command - Normal Mode
FIGURE 4-5: SPI Set Address Pointer Command - Normal Mode
Master SPDOUT
SPI_MOSI
SPI_CS#
SPI_CLK
Reset - 7Ah Reset - 7Ah
Invalid register data 00h – Internal Data buffer empty SPI_MISO
Master Drives Slave Drives
‘0’ ‘1’ ‘1’ ‘1’ ‘1’ ‘0’ ‘1’ ‘0’ ‘0’ ‘1’ ‘1’ ‘1’ ‘1’ ‘0’ ‘1’ ‘0’
Master SPDOUT
SPI_MOSI Register Address
SPI_CS#
SPI_CLK
Set Address Pointer – 7Dh
SPI_MISO Unknown, Invalid Data Unknown, Invalid Data
Master Drives Slave Drives Address pointer set
‘0’ ‘0’ ‘1’ ‘1’ ‘1’ ‘1’ ‘1’ ‘1’
CAP1126
DS00001623B-page 18 2015 Microchip Technology Inc.
4.6.4 READ DATA
The Read Data protocol is used to read data from the device. During the normal mode of operation, while the device is
receiving data, the CAP1126 is simultaneously transmitting data to the host. For the Set Address commands and the
Write Data commands, this data may be invalid and it is recommended that the Read Data command is used.
FIGURE 4-6: SPI Write Command - Normal Mode
FIGURE 4-7: SPI Read Command - Normal Mode
Master SPDOUT
SPI_MOSI Data to Write
SPI_CS#
SPI_CLK
Write Command – 7Eh
Unknown, Invalid Data Old Data at Current Address Pointer SPI_MISO
Master Drives Slave Drives
1. Data written at current
address pointer
2. Address pointer incremented
Master SPDOUT
SPI_MOSI
Master Drives Slave Drives
SPI_CLK
First Read Command – 7Fh
SPI_CS#
SPI_MISO Invalid, Unknown Data *
‘0’ ‘1’ ‘1’ ‘1’ ‘1’ ‘1’ ‘1’ ‘1’
Subsequent Read
Commands – 7F
Data at Current Address Pointer
Address Pointer
Incremented **
‘0’ ‘1’ ‘1’ ‘1’ ‘1’ ‘1’ ‘1’ ‘1’
* The first read command after any other command will return invalid data for the first
byte. Subsequent read commands will return the data at the Current Address Pointer
** The Address Pointer is incremented 8 clocks after the Read Command has been
received. Therefore continually sending Read Commands will result in each command
reporting new data. Once Read Commands have been finished, the last data byte will be
read during the next 8 clocks for any command
2015 Microchip Technology Inc. DS00001623B-page 19
CAP1126
4.7 Bi-Directional SPI Protocols
4.7.1 RESET INTERFACE
Resets the Serial interface whenever two successive 7Ah codes are received. Regardless of the current phase of the
transaction - command or data, the receipt of the successive reset commands resets the Serial communication interface
only. All other functions are not affected by the reset operation.
4.7.2 SET ADDRESS POINTER
Sets the address pointer to the register to be accessed by a read or write command. This command overrides the autoincrementing
of the address pointer.
FIGURE 4-8: SPI Read Command - Normal Mode - Full
FIGURE 4-9: SPI Reset Interface Command - Bi-directional Mode
Master SPDOUT
SPI_MOSI
Master Drives Slave Drives
SPI_CLK
Read Command – 7Fh
SPI_CS#
Data at previously set register address = current
address pointer
SPI_MISO ‘0’ ‘1’ ‘1’ ‘1’ ‘1’ ‘1’ ‘1’ ‘1’
Data at previously set register address = current
address pointer (SPI)
XXh
1. Register Read Address
updated to Current SPI Read
Address pointer
1. Register data loaded into
output buffer = data at current
address pointer
1. Output buffer transmitted =
data at previous address
pointer + 1 = current address
pointer
1. Register Read Address
incremented = current address
pointer + 1
1. SPI Read Address
Incremented = new current
address pointer
2. Register Read Address
Incremented = current address
pointer +1
Register Data loaded into
Output buffer = data at current
address pointer + 1
1. Output buffer transmitted =
data at current address pointer
+ 1
2. Flag set to increment SPI
Read Address at end of next 8
clocks
‘0’ ‘1’ ‘1’ ‘1’ ‘1’ ‘1’ ‘1’ ‘1’
Data at previously set register address = current
address pointer (SPI)
1. Register data loaded into
output buffer = data at current
address pointer
1. Output buffer transmitted =
data at previous register
address pointer + 1 = current
address pointer
1. Output buffer transmitted =
data at current address pointer
+ 1
2. Flag set to increment SPI
Read Address at end of next 8
clocks
Subsequent Read Commands – 7Fh
1. Register Read Address
updated to Current SPI Read
Address pointer.
2. Register Read Address
incremented = current address
pointer +1 – end result =
register address pointer doesn’t
change
Master SPDOUT
SPI_MSIO
SPI_CS#
SPI_CLK
Reset - 7Ah Reset - 7Ah
‘0’ ‘0’ ‘0’ ‘1’ ‘1’ ‘1’ ‘1’ ‘1’ ‘0’ ‘0’ ‘0’ ‘1’ ‘1’ ‘1’ ‘1’ ‘1’
CAP1126
DS00001623B-page 20 2015 Microchip Technology Inc.
4.7.3 WRITE DATA
Writes data value to the register address stored in the address pointer. Performs auto increment of address pointer after
the data is loaded into the register.
4.7.4 READ DATA
Reads data referenced by the address pointer. Performs auto increment of address pointer after the data is transferred
to the Master.
FIGURE 4-10: SPI Set Address Pointer Command - Bi-directional Mode
FIGURE 4-11: SPI Write Data Command - Bi-directional Mode
FIGURE 4-12: SPI Read Data Command - Bi-directional Mode
Master SPDOUT
SPI_MSIO Register Address
SPI_CS#
SPI_CLK
Set Address Pointer – 7Dh
‘0’ ‘1’ ‘0’ ‘1’ ‘1’ ‘1’ ‘1’ ‘1’
Master SPDOUT
SPI_MSIO Register Write Data
SPI_CS#
SPI_CLK
Write Command – 7Eh
‘0’ ‘1’ ‘1’ ‘1’ ‘1’ ‘1’ ‘1’ ‘0’
Master SPDOUT
SPI_MSIO
Master Drives Slave Drives Indeterminate
Register Read Data
SPI_CLK
Read Command – 7Fh
SPI_CS#
‘0’ ‘1’ ‘1’ ‘1’ ‘1’ ‘1’ ‘1’ ‘1’
2015 Microchip Technology Inc. DS00001623B-page 21
CAP1126
4.8 BC-Link Interface
The BC-Link is a proprietary bus developed to allow communication between a host controller device to a companion
device. This device uses this serial bus to read and write registers and for interrupt processing. The interface uses a
data port concept, where the base interface has an address register, data register and a control register, defined in the
8051’s SFR space.
Refer to documentation for the BC-Link compatible host controller for details on how to access the CAP1126 via the BCLink
Interface.
CAP1126
DS00001623B-page 22 2015 Microchip Technology Inc.
5.0 GENERAL DESCRIPTION
The CAP1126 is a multiple channel Capacitive Touch sensor with multiple power LED drivers. It contains six (6) individual
capacitive touch sensor inputs with programmable sensitivity for use in touch sensor applications. Each sensor input
automatically recalibrates to compensate for gradual environmental changes.
The CAP1126 also contains two (2) low side (or push-pull) LED drivers that offer full-on / off, variable rate blinking, dimness
controls, and breathing. Each of the LED drivers may be linked to one of the sensor inputs to be actuated when a
touch is detected. As well, each LED driver may be individually controlled via a host controller.
Finally, the device contains a dedicated RESET pin to act as a soft reset by the system.
The CAP1126 offers multiple power states. It operates at the lowest quiescent current during its Deep Sleep state. In
the low power Standby state, it can monitor one or more channels and respond to communications normally. The device
contains a wake pin (WAKE/SPI_MOSI) output to wake the system when a touch is detected in Standby and to wake
the device from Deep Sleep.
The device communicates with a host controller using the SPI bus, or via SMBus / I2C. The host controller may poll the
device for updated information at any time or it may configure the device to flag an interrupt whenever a touch is
detected on any sensor pad.
A typical system diagram is shown in Figure 5-1.
2015 Microchip Technology Inc. DS00001623B-page 23
CAP1126
5.1 Power States
The CAP1126 has three operating states depending on the status of the STBY and DSLEEP bits. When the device transitions
between power states, previously detected touches (for inactive channels) are cleared and the status bits reset.
1. Fully Active - The device is fully active. It is monitoring all active capacitive sensor inputs and driving all LED channels
as defined.
2. Standby - The device is in a lower power state. It will measure a programmable number of channels using the
Standby Configuration controls (see Section 6.20 through Section 6.22). Interrupts will still be generated based
on the active channels. The device will still respond to communications normally and can be returned to the Fully
Active state of operation by clearing the STBY bit.
FIGURE 5-1: System Diagram for CAP1126
CAP1126
CS6
SMDATA / BC_DATA / SPI_MSIO / SPI_MISO
SMCLK / BC_CLK / SPI_CLK
VDD Embedded Controller ALERT# / BC_IRQ#
CS4
CS2
3.3V – 5V
CS5
CS3
CS1
WAKE / SPI_MOSI
RESET
SPI_CS#
ADDR_COMM
LED1 LED2
3.3V – 5V
Touch
Button
Touch
Button
Touch
Button
Touch
Button
Touch
Button
Touch
Button
CAP1126
DS00001623B-page 24 2015 Microchip Technology Inc.
3. Deep Sleep - The device is in its lowest power state. It is not monitoring any capacitive sensor inputs and not
driving any LEDs. All LEDs will be driven to their programmed non-actuated state and no PWM operations will
be done. While in Deep Sleep, the device can be awakened by SMBus or SPI communications targeting the
device. This will not cause the DSLEEP to be cleared so the device will return to Deep Sleep once all communications
have stopped.
If the device is not communicating via the 4-wire SPI bus, then during this state of operation, if the WAKE/SPI_MOSI
pin is driven high by an external source, the device will clear the DSLEEP bit and return to Fully Active.
APPLICATION NOTE: In the Deep Sleep state, the LED output will be either high or low and will not be PWM’d at
the min or max duty cycle.
5.2 RESET Pin
The RESET pin is an active high reset that is driven from an external source. While it is asserted high, all the internal
blocks will be held in reset including the communications protocol used. No capacitive touch sensor inputs will be sampled
and the LEDs will not be driven. All configuration settings will be reset to default states and all readings will be
cleared.
The device will be held in Deep Sleep that can only be removed by driving the RESET pin low. This will cause the
RESET status bit to be set to a logic ‘1’ and generate an interrupt.
5.3 WAKE/SPI_MOSI Pin Operation
The WAKE / SPI_MOSI pin is a multi-function pin depending on device operation. When the device is configured to communicate
using the 4-wire SPI bus, this pin is an input.
However, when the CAP1126 is placed in Standby and is not communicating using the 4-wire SPI protocol, the WAKE
pin is an active high output. In this condition, the device will assert the WAKE/SPI_MOSI pin when a touch is detected
on one of its sampled sensor inputs. The pin will remain asserted until the INT bit has been cleared and then it will be
de-asserted.
When the CAP1126 is placed in Deep Sleep and it is not communicating using the 4-wire SPI protocol, the WAKE/SPI_-
MOSI pin is monitored by the device as an input. If the WAKE/SPI_MOSI pin is driven high by an external source, the
CAP1126will clear the DSLEEP bit causing the device to return to Fully Active.
When the device is placed in Deep Sleep, this pin is a High-Z input and must have a pull-down resistor to GND for proper
operation.
5.4 LED Drivers
The CAP1126 contains two (2) LED drivers. Each LED driver can be linked to its respective capacitive touch sensor
input or it can be controlled by the host. Each LED driver can be configured to operate in one of the following modes
with either push-pull or open drain drive.
1. Direct - The LED is configured to be on or off when the corresponding input stimulus is on or off (or inverted). The
brightness of the LED can be programmed from full off to full on (default). Additionally, the LED contains controls
to individually configure ramping on, off, and turn-off delay.
2. Pulse 1 - The LED is configured to “Pulse” (transition ON-OFF-ON) a programmable number of times with programmable
rate and min / max brightness. This behavior may be actuated when a press is detected or when a
release is detected.
3. Pulse 2 - The LED is configured to “Pulse” while actuated and then “Pulse” a programmable number of times with
programmable rate and min / max brightness when the sensor pad is released.
4. Breathe - The LED is configured to transition continuously ON-OFF-ON (i.e. to “Breathe”) with a programmable
rate and min / max brightness.
When an LED is not linked to a sensor and is actuated by the host, there’s an option to assert the ALERT# pin when
the initiated LED behavior has completed.
5.4.1 LINKING LEDS TO CAPACITIVE TOUCH SENSOR INPUTS
All LEDs can be linked to the corresponding capacitive touch sensor input so that when the sensor input detects a touch,
the corresponding LED will be actuated at one of the programmed responses.
2015 Microchip Technology Inc. DS00001623B-page 25
CAP1126
5.5 Capacitive Touch Sensing
The CAP1126 contains six (6) independent capacitive touch sensor inputs. Each sensor input has dynamic range to
detect a change of capacitance due to a touch. Additionally, each sensor input can be configured to be automatically
and routinely re-calibrated.
5.5.1 SENSING CYCLE
Each capacitive touch sensor input has controls to be activated and included in the sensing cycle. When the device is
active, it automatically initiates a sensing cycle and repeats the cycle every time it finishes. The cycle polls through each
active sensor input starting with CS1 and extending through CS6. As each capacitive touch sensor input is polled, its
measurement is compared against a baseline “Not Touched” measurement. If the delta measurement is large enough,
a touch is detected and an interrupt is generated.
The sensing cycle time is programmable (see Section 6.10, "Averaging and Sampling Configuration Register").
5.5.2 RECALIBRATING SENSOR INPUTS
There are various options for recalibrating the capacitive touch sensor inputs. Recalibration re-sets the Base Count Registers
(Section 6.24, "Sensor Input Base Count Registers") which contain the “not touched” values used for touch detection
comparisons.
APPLICATION NOTE: The device will recalibrate all sensor inputs that were disabled when it transitions from
Standby. Likewise, the device will recalibrate all sensor inputs when waking out of Deep
Sleep.
5.5.2.1 Manual Recalibration
The Calibration Activate Registers (Section 6.11, "Calibration Activate Register") force recalibration of selected sensor
inputs. When a bit is set, the corresponding capacitive touch sensor input will be recalibrated (both analog and digital).
The bit is automatically cleared once the recalibration routine has finished.
5.5.2.2 Automatic Recalibration
Each sensor input is regularly recalibrated at a programmable rate (see Section 6.17, "Recalibration Configuration Register").
By default, the recalibration routine stores the average 64 previous measurements and periodically updates the
base “not touched” setting for the capacitive touch sensor input.
5.5.2.3 Negative Delta Count Recalibration
It is possible that the device loses sensitivity to a touch. This may happen as a result of a noisy environment, an accidental
recalibration during a touch, or other environmental changes. When this occurs, the base untouched sensor input
may generate negative delta count values. The NEG_DELTA_CNT bits (see Section 6.17, "Recalibration Configuration
Register") can be set to force a recalibration after a specified number of consecutive negative delta readings.
5.5.2.4 Delayed Recalibration
It is possible that a “stuck button” occurs when something is placed on a button which causes a touch to be detected
for a long period. By setting the MAX_DUR_EN bit (see Section 6.6, "Configuration Registers"), a recalibration can be
forced when a touch is held on a button for longer than the duration specified in the MAX_DUR bits (see Section 6.8,
"Sensor Input Configuration Register").
Note: During this recalibration routine, the sensor inputs will not detect a press for up to 200ms and the Sensor
Base Count Register values will be invalid. In addition, any press on the corresponding sensor pads will
invalidate the recalibration.
Note: Automatic recalibration only works when the delta count is below the active sensor input threshold. It is disabled
when a touch is detected.
Note: During this recalibration, the device will not respond to touches.
CAP1126
DS00001623B-page 26 2015 Microchip Technology Inc.
5.5.3 PROXIMITY DETECTION
Each sensor input can be configured to detect changes in capacitance due to proximity of a touch. This circuitry detects
the change of capacitance that is generated as an object approaches, but does not physically touch, the enabled sensor
pad(s). When a sensor input is selected to perform proximity detection, it will be sampled from 1x to 128x per sampling
cycle. The larger the number of samples that are taken, the greater the range of proximity detection is available at the
cost of an increased overall sampling time.
5.5.4 MULTIPLE TOUCH PATTERN DETECTION
The multiple touch pattern (MTP) detection circuitry can be used to detect lid closure or other similar events. An event
can be flagged based on either a minimum number of sensor inputs or on specific sensor inputs simultaneously exceeding
an MTP threshold or having their Noise Flag Status Register bits set. An interrupt can also be generated. During an
MTP event, all touches are blocked (see Section 6.15, "Multiple Touch Pattern Configuration Register").
5.5.5 LOW FREQUENCY NOISE DETECTION
Each sensor input has an EMI noise detector that will sense if low frequency noise is injected onto the input with sufficient
power to corrupt the readings. If this occurs, the device will reject the corrupted sample and set the corresponding
bit in the Noise Status register to a logic ‘1’.
5.5.6 RF NOISE DETECTION
Each sensor input contains an integrated RF noise detector. This block will detect injected RF noise on the CS pin. The
detector threshold is dependent upon the noise frequency. If RF noise is detected on a CS line, that sample is removed
and not compared against the threshold.
5.6 ALERT# Pin
The ALERT# pin is an active low (or active high when configured) output that is driven when an interrupt event is
detected.
Whenever an interrupt is generated, the INT bit (see Section 6.1, "Main Control Register") is set. The ALERT# pin is
cleared when the INT bit is cleared by the user. Additionally, when the INT bit is cleared by the user, status bits are only
cleared if no touch is detected.
5.6.1 SENSOR INTERRUPT BEHAVIOR
The sensor interrupts are generated in one of two ways:
1. An interrupt is generated when a touch is detected and, as a user selectable option, when a release is detected
(by default - see Section 6.6). See Figure 5-3.
2. If the repeat rate is enabled then, so long as the touch is held, another interrupt will be generated based on the
programmed repeat rate (see Figure 5-2).
When the repeat rate is enabled, the device uses an additional control called MPRESS that determines whether a touch
is flagged as a simple “touch” or a “press and hold”. The MPRESS[3:0] bits set a minimum press timer. When the button
is touched, the timer begins. If the sensor pad is released before the minimum press timer expires, it is flagged as a
touch and an interrupt is generated upon release. If the sensor input detects a touch for longer than this timer value, it
is flagged as a “press and hold” event. So long as the touch is held, interrupts will be generated at the programmed
repeat rate and upon release (if enabled).
APPLICATION NOTE: Figure 5-2 and Figure 5-3 show default operation which is to generate an interrupt upon
sensor pad release and an active-low ALERT# pin.
APPLICATION NOTE: The host may need to poll the device twice to determine that a release has been detected.
Note: Delayed recalibration only works when the delta count is above the active sensor input threshold. If
enabled, it is invoked when a sensor pad touch is held longer than the MAX_DUR bit setting.
2015 Microchip Technology Inc. DS00001623B-page 27
CAP1126
FIGURE 5-2: Sensor Interrupt Behavior - Repeat Rate Enabled
FIGURE 5-3: Sensor Interrupt Behavior - No Repeat Rate Enabled
Touch Detected
INT bit
Button Status
Write to INT bit
Polling Cycle
(35ms)
Min Press Setting
(280ms)
Interrupt on
Touch
Button Repeat Rate
(175ms)
Button Repeat Rate
(175ms)
Interrupt on
Release
(optional)
ALERT# pin
(active low)
Touch Detected
INT bit
Button Status
Write to INT bit
Polling Cycle
(35ms) Interrupt on
Touch Interrupt on
Release
(optional)
ALERT# pin
(active low)
CAP1126
DS00001623B-page 28 2015 Microchip Technology Inc.
6.0 REGISTER DESCRIPTION
The registers shown in Table 6-1 are accessible through the communications protocol. An entry of ‘-’ indicates that the
bit is not used and will always read ‘0’.
TABLE 6-1: REGISTER SET IN HEXADECIMAL ORDER
Register
Address R/W Register Name Function Default Value Page
00h R/W Main Control Controls general power states and
power dissipation 00h Page 31
02h R General Status Stores general status bits 00h Page 32
03h R Sensor Input Status Returns the state of the sampled
capacitive touch sensor inputs 00h Page 32
04h R LED Status Stores status bits for LEDs 00h Page 32
0Ah R Noise Flag Status Stores the noise flags for sensor inputs 00h Page 33
10h R Sensor Input 1 Delta
Count Stores the delta count for CS1 00h Page 33
11h R Sensor Input 2 Delta
Count Stores the delta count for CS2 00h Page 33
12h R Sensor Input 3 Delta
Count Stores the delta count for CS3 00h Page 33
13h R Sensor Input 4 Delta
Count Stores the delta count for CS4 00h Page 33
14h R Sensor Input 5 Delta
Count Stores the delta count for CS5 00h Page 33
15h R Sensor Input 6 Delta
Count Stores the delta count for CS6 00h Page 33
1Fh R/W Sensitivity Control
Controls the sensitivity of the threshold
and delta counts and data scaling of
the base counts
2Fh Page 33
20h R/W Configuration Controls general functionality 20h Page 35
21h R/W Sensor Input Enable Controls whether the capacitive touch
sensor inputs are sampled 3Fh Page 36
22h R/W Sensor Input Configuration
Controls max duration and auto-repeat
delay for sensor inputs operating in the
full power state
A4h Page 36
23h R/W Sensor Input Configuration
2
Controls the MPRESS controls for all
sensor inputs 07h Page 38
24h R/W Averaging and Sampling
Config
Controls averaging and sampling window
39h Page 38
26h R/W Calibration Activate Forces re-calibration for capacitive
touch sensor inputs 00h Page 39
27h R/W Interrupt Enable Enables Interrupts associated with
capacitive touch sensor inputs 3Fh Page 40
28h R/W Repeat Rate Enable Enables repeat rate for all sensor
inputs 3Fh Page 40
2Ah R/W Multiple Touch Configuration
Determines the number of simultaneous
touches to flag a multiple touch
condition
80h Page 41
2Bh R/W Multiple Touch Pattern
Configuration
Determines the multiple touch pattern
(MTP) configuration 00h Page 41
2015 Microchip Technology Inc. DS00001623B-page 29
CAP1126
2Dh R/W Multiple Touch Pattern
Determines the pattern or number of
sensor inputs used by the MTP circuitry
3Fh Page 42
2Fh R/W Recalibration Configuration
Determines re-calibration timing and
sampling window 8Ah Page 43
30h R/W Sensor Input 1 Threshold
Stores the delta count threshold to
determine a touch for Capacitive
Touch Sensor Input 1
40h Page 44
31h R/W Sensor Input 2 Threshold
Stores the delta count threshold to
determine a touch for Capacitive
Touch Sensor Input 2
40h Page 44
32h R/W Sensor Input 3 Threshold
Stores the delta count threshold to
determine a touch for Capacitive
Touch Sensor Input 3
40h Page 44
33h R/W Sensor Input 4 Threshold
Stores the delta count threshold to
determine a touch for Capacitive
Touch Sensor Input 4
40h Page 44
34h R/W Sensor Input 5 Threshold
Stores the delta count threshold to
determine a touch for Capacitive
Touch Sensor Input 5
40h Page 44
35h R/W Sensor Input 6 Threshold
Stores the delta count threshold to
determine a touch for Capacitive
Touch Sensor Input 6
40h Page 44
38h R/W Sensor Input Noise
Threshold
Stores controls for selecting the noise
threshold for all sensor inputs 01h Page 44
Standby Configuration Registers
40h R/W Standby Channel Controls which sensor inputs are
enabled while in standby 00h Page 45
41h R/W Standby Configuration Controls averaging and cycle time
while in standby 39h Page 45
42h R/W Standby Sensitivity Controls sensitivity settings used while
in standby 02h Page 47
43h R/W Standby Threshold Stores the touch detection threshold
for active sensor inputs in standby 40h Page 47
44h R/W Configuration 2 Stores additional configuration controls
for the device 40h Page 35
Base Count Registers
50h R Sensor Input 1 Base
Count
Stores the reference count value for
sensor input 1 C8h Page 47
51h R Sensor Input 2 Base
Count
Stores the reference count value for
sensor input 2 C8h Page 47
52h R Sensor Input 3 Base
Count
Stores the reference count value for
sensor input 3 C8h Page 47
53h R Sensor Input 4 Base
Count
Stores the reference count value for
sensor input 4 C8h Page 47
54h R Sensor Input 5 Base
Count
Stores the reference count value for
sensor input 5 C8h Page 47
55h R Sensor Input 6 Base
Count
Stores the reference count value for
sensor input 6 C8h Page 47
TABLE 6-1: REGISTER SET IN HEXADECIMAL ORDER (CONTINUED)
Register
Address R/W Register Name Function Default Value Page
CAP1126
DS00001623B-page 30 2015 Microchip Technology Inc.
LED Controls
71h R/W LED Output Type Controls the output type for the LED
outputs 00h Page 48
72h R/W Sensor Input LED Linking
Controls linking of sensor inputs to
LED channels 00h Page 48
73h R/W LED Polarity Controls the output polarity of LEDs 00h Page 49
74h R/W LED Output Control Controls the output state of the LEDs 00h Page 50
77h R/W Linked LED
Transition Control
Controls the transition when LEDs are
linked to CS channels 00h Page 51
79h R/W LED Mirror Control Controls the mirroring of duty cycles
for the LEDs 00h Page 51
81h R/W LED Behavior 1 Controls the behavior and response of
LEDs 1 - 2 00h Page 51
84h R/W LED Pulse 1 Period Controls the period of each breathe
during a pulse 20h Page 53
85h R/W LED Pulse 2 Period Controls the period of the breathing
during breathe and pulse operation 14h Page 55
86h R/W LED Breathe Period Controls the period of an LED breathe
operation 5Dh Page 56
88h R/W LED Config Controls LED configuration 04h Page 56
90h R/W LED Pulse 1 Duty Cycle Determines the min and max duty
cycle for the pulse operation F0h Page 57
91h R/W LED Pulse 2 Duty Cycle Determines the min and max duty
cycle for breathe and pulse operation F0h Page 57
92h R/W LED Breathe Duty Cycle Determines the min and max duty
cycle for the breathe operation F0h Page 57
93h R/W LED Direct Duty Cycle Determines the min and max duty
cycle for Direct mode LED operation F0h Page 57
94h R/W LED Direct Ramp Rates Determines the rising and falling edge
ramp rates of the LEDs 00h Page 58
95h R/W LED Off Delay Determines the off delay for all LED
behaviors 00h Page 58
B1h R Sensor Input 1 Calibration
Stores the upper 8-bit calibration value
for sensor input 1 00h Page 61
B2h R Sensor Input 2 Calibration
Stores the upper 8-bit calibration value
for sensor input 2 00h Page 61
B3h R Sensor Input 3 Calibration
Stores the upper 8-bit calibration value
for sensor input 3 00h Page 61
B4h R Sensor Input 4 Calibration
Stores the upper 8-bit calibration value
for sensor input 4 00h Page 61
B5h R Sensor Input 5 Calibration
Stores the upper 8-bit calibration value
for sensor input 5 00h Page 61
B6h R Sensor Input 6 Calibration
Stores the upper 8-bit calibration value
for sensor input 6 00h Page 61
B9h R Sensor Input Calibration
LSB 1
Stores the 2 LSBs of the calibration
value for sensor inputs 1 - 4 00h Page 61
BAh R Sensor Input Calibration
LSB 2
Stores the 2 LSBs of the calibration
value for sensor inputs 5 - 6 00h Page 61
TABLE 6-1: REGISTER SET IN HEXADECIMAL ORDER (CONTINUED)
Register
Address R/W Register Name Function Default Value Page
2015 Microchip Technology Inc. DS00001623B-page 31
CAP1126
During Power-On-Reset (POR), the default values are stored in the registers. A POR is initiated when power is first
applied to the part and the voltage on the VDD supply surpasses the POR level as specified in the electrical characteristics.
Any reads to undefined registers will return 00h. Writes to undefined registers will not have an effect.
When a bit is “set”, this means that the user writes a logic ‘1’ to it. When a bit is “cleared”, this means that the user writes
a logic ‘0’ to it.
6.1 Main Control Register
The Main Control register controls the primary power state of the device.
Bits 7 - 6 - GAIN[1:0] - Controls the gain used by the capacitive touch sensing circuitry. As the gain is increased, the
effective sensitivity is likewise increased as a smaller delta capacitance is required to generate the same delta count
values. The sensitivity settings may need to be adjusted along with the gain settings such that data overflow does not
occur.
APPLICATION NOTE: The gain settings apply to both Standby and Active states.
Bit 5 - STBY - Enables Standby.
• ‘0’ (default) - Sensor input scanning is active and LEDs are functional.
• ‘1’ - Capacitive touch sensor input scanning is limited to the sensor inputs set in the Standby Channel register (see
Section 6.20). The status registers will not be cleared until read. LEDs that are linked to capacitive touch sensor
inputs will remain linked and active. Sensor inputs that are no longer sampled will flag a release and then remain
in a non-touched state. LEDs that are manually controlled will be unaffected.
• Bit 4 - DSLEEP - Enables Deep Sleep by deactivating all functions. This bit will be cleared when the WAKE pin is
driven high. ‘0’ (default) - Sensor input scanning is active and LEDs are functional.
• ‘1’ - All sensor input scanning is disabled. All LEDs are driven to their programmed non-actuated state and no
PWM operations will be done. The status registers are automatically cleared and the INT bit is cleared.
Bit 0 - INT - Indicates that there is an interrupt. When this bit is set, it asserts the ALERT# pin. If a channel detects a
touch and its associated interrupt enable bit is not set to a logic ‘1’, no action is taken.
FDh R Product ID Stores a fixed value that identifies
each product 53h Page 62
FEh R Manufacturer ID Stores a fixed value that identifies
Microchip 5Dh Page 62
FFh R Revision Stores a fixed value that represents
the revision number 83h Page 62
TABLE 6-2: MAIN CONTROL REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
00h R/W Main Control GAIN[1:0] STBY DSLEEP - - - INT 00h
TABLE 6-3: GAIN BIT DECODE
GAIN[1:0]
Capacitive Touch Sensor Gain
1 0
0 0 1
01 2
10 4
11 8
TABLE 6-1: REGISTER SET IN HEXADECIMAL ORDER (CONTINUED)
Register
Address R/W Register Name Function Default Value Page
CAP1126
DS00001623B-page 32 2015 Microchip Technology Inc.
This bit is cleared by writing a logic ‘0’ to it. When this bit is cleared, the ALERT# pin will be deasserted and all status
registers will be cleared if the condition has been removed. If the WAKE/SPI_MOSI pin is asserted as a result of a touch
detected while in Standby, it will likewise be deasserted when this bit is cleared.
Note that the WAKE / SPI_MOSI pin is not driven when communicating via the 4-wire SPI protocol.
• ‘0’ - No interrupt pending.
• ‘1’ - A touch has been detected on one or more channels and the interrupt has been asserted.
6.2 Status Registers
All status bits are cleared when the device enters the Deep Sleep (DSLEEP = ‘1’ - see Section 6.1).
6.2.1 GENERAL STATUS - 02H
Bit 4 - LED - Indicates that one or more LEDs have finished their programmed activity. This bit is set if any bit in the LED
Status register is set.
Bit 3 - RESET - Indicates that the device has come out of reset. This bit is set when the device exits a POR state or
when the RESET pin has been deasserted and qualified via the RESET pin filter (see Section 5.2). This bit will cause
the INT bit to be set and is cleared when the INT bit is cleared.
Bit 2 - MULT - Indicates that the device is blocking detected touches due to the Multiple Touch detection circuitry (see
Section 6.14). This bit will not cause the INT bit to be set and hence will not cause an interrupt.
Bit 1 - MTP - Indicates that the device has detected a number of sensor inputs that exceed the MTP threshold either via
the pattern recognition or via the number of sensor inputs (see Section 6.15). This bit will cause the INT bit to be set if
the MTP_ALERT bit is also set. This bit will not be cleared until the condition that caused it to be set has been removed.
Bit 0 - TOUCH - Indicates that a touch was detected. This bit is set if any bit in the Sensor Input Status register is set.
6.2.2 SENSOR INPUT STATUS - 03H
The Sensor Input Status Register stores status bits that indicate a touch has been detected. A value of ‘0’ in any bit
indicates that no touch has been detected. A value of ‘1’ in any bit indicates that a touch has been detected.
All bits are cleared when the INT bit is cleared and if a touch on the respective capacitive touch sensor input is no longer
present. If a touch is still detected, the bits will not be cleared (but this will not cause the interrupt to be asserted - see
Section 6.6).
Bit 5 - CS6 - Indicates that a touch was detected on Sensor Input 6.
Bit 4 - CS5 - Indicates that a touch was detected on Sensor Input 5.
Bit 3 - CS4 - Indicates that a touch was detected on Sensor Input 4.
Bit 2 - CS3 - Indicates that a touch was detected on Sensor Input 3.
Bit 1 - CS2 - Indicates that a touch was detected on Sensor Input 2. This sensor input can be linked to LED2.
Bit 0 - CS1 - Indicates that a touch was detected on Sensor Input 1. This sensor input can be linked to LED1.
6.2.3 LED STATUS - 04H
The LED Status Registers indicate when an LED has completed its configured behavior (see Section 6.31, "LED Behavior
Register") after being actuated by the host (see Section 6.28, "LED Output Control Register"). These bits are ignored
when the LED is linked to a capacitive sensor input. All LED Status bits are cleared when the INT bit is cleared.
Bit 1 - LED2_DN - Indicates that LED2 has finished its behavior after being actuated by the host.
Bit 0 - LED1_DN - Indicates that LED1 has finished its behavior after being actuated by the host.
TABLE 6-4: STATUS REGISTERS
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
02h R General Status - - - LED RESET MULT MTP TOUCH 00h
03h R Sensor Input Status
- - CS6 CS5 CS4 CS3 CS2 CS1 00h
04h R LED Status - - - - - - LED2_
DN
LED1_
DN 00h
2015 Microchip Technology Inc. DS00001623B-page 33
CAP1126
6.3 Noise Flag Status Registers
The Noise Flag Status registers store status bits that are generated from the analog block if the detected noise is above
the operating region of the analog detector or the RF noise detector. These bits indicate that the most recently received
data from the sensor input is invalid and should not be used for touch detection. So long as the bit is set for a particular
channel, the delta count value is reset to 00h and thus no touch is detected.
These bits are not sticky and will be cleared automatically if the analog block does not report a noise error.
APPLICATION NOTE: If the MTP detection circuitry is enabled, these bits count as sensor inputs above the MTP
threshold (see Section 5.5.4, "Multiple Touch Pattern Detection") even if the corresponding
delta count is not. If the corresponding delta count also exceeds the MTP threshold, it is not
counted twice.
APPLICATION NOTE: Regardless of the state of the Noise Status bits, if low frequency noise is detected on a
sensor input, that sample will be discarded unless the DIS_ANA_NOISE bit is set. As well,
if RF noise is detected on a sensor input, that sample will be discarded unless the
DIS_RF_NOISE bit is set.
6.4 Sensor Input Delta Count Registers
The Sensor Input Delta Count registers store the delta count that is compared against the threshold used to determine
if a touch has been detected. The count value represents a change in input due to the capacitance associated with a
touch on one of the sensor inputs and is referenced to a calibrated base “Not Touched” count value. The delta is an
instantaneous change and is updated once per sensor input per sensing cycle (see Section 5.5.1, "Sensing Cycle").
The value presented is a standard 2’s complement number. In addition, the value is capped at a value of 7Fh. A reading
of 7Fh indicates that the sensitivity settings are too high and should be adjusted accordingly (see Section 6.5).
The value is also capped at a negative value of 80h for negative delta counts which may result upon a release.
6.5 Sensitivity Control Register
TABLE 6-5: NOISE FLAG STATUS REGISTERS
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
0Ah R Noise Flag Status - - CS6_
NOISE
CS5_
NOISE
CS4_
NOISE
CS3_
NOISE
CS2_
NOISE
CS1_
NOISE 00h
TABLE 6-6: SENSOR INPUT DELTA COUNT REGISTERS
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
10h R Sensor Input 1
Delta Count Sign 64 32 16 8 4 2 1 00h
11h R Sensor Input 2
Delta Count Sign 64 32 16 8 4 2 1 00h
12h R Sensor Input 3
Delta Count Sign 64 32 16 8 4 2 1 00h
13h R Sensor Input 4
Delta Count Sign 64 32 16 8 4 2 1 00h
14h R Sensor Input 5
Delta Count Sign 64 32 16 8 4 2 1 00h
15h R Sensor Input 6
Delta Count Sign 64 32 16 8 4 2 1 00h
TABLE 6-7: SENSITIVITY CONTROL REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
1Fh R/W Sensitivity Control - DELTA_SENSE[2:0] BASE_SHIFT[3:0] 2Fh
CAP1126
DS00001623B-page 34 2015 Microchip Technology Inc.
The Sensitivity Control register controls the sensitivity of a touch detection.
Bits 6-4 DELTA_SENSE[2:0] - Controls the sensitivity of a touch detection. The sensitivity settings act to scale the relative
delta count value higher or lower based on the system parameters. A setting of 000b is the most sensitive while a
setting of 111b is the least sensitive. At the more sensitive settings, touches are detected for a smaller delta capacitance
corresponding to a “lighter” touch. These settings are more sensitive to noise, however, and a noisy environment may
flag more false touches with higher sensitivity levels.
APPLICATION NOTE: A value of 128x is the most sensitive setting available. At the most sensitivity settings, the
MSB of the Delta Count register represents 64 out of ~25,000 which corresponds to a touch
of approximately 0.25% of the base capacitance (or a ΔC of 25fF from a 10pF base
capacitance). Conversely, a value of 1x is the least sensitive setting available. At these
settings, the MSB of the Delta Count register corresponds to a delta count of 8192 counts
out of ~25,000 which corresponds to a touch of approximately 33% of the base capacitance
(or a ΔC of 3.33pF from a 10pF base capacitance).
Bits 3 - 0 - BASE_SHIFT[3:0] - Controls the scaling and data presentation of the Base Count registers. The higher the
value of these bits, the larger the range and the lower the resolution of the data presented. The scale factor represents
the multiplier to the bit-weighting presented in these register descriptions.
APPLICATION NOTE: The BASE_SHIFT[3:0] bits normally do not need to be updated. These settings will not affect
touch detection or sensitivity. These bits are sometimes helpful in analyzing the Cap Sensing
board performance and stability.
TABLE 6-8: DELTA_SENSE BIT DECODE
DELTA_SENSE[2:0]
Sensitivity Multiplier
210
0 0 0 128x (most sensitive)
0 0 1 64x
0 1 0 32x (default)
0 1 1 16x
1 0 0 8x
1 0 1 4x
1 1 0 2x
1 1 1 1x - (least sensitive)
TABLE 6-9: BASE_SHIFT BIT DECODE
BASE_SHIFT[3:0]
Data Scaling Factor
32 1 0
0 0 0 0 1x
0 0 0 1 2x
0 0 1 0 4x
0 0 1 1 8x
0 1 0 0 16x
0 1 0 1 32x
0 1 1 0 64x
0 1 1 1 128x
1 0 0 0 256x
All others 256x
(default = 1111b)
2015 Microchip Technology Inc. DS00001623B-page 35
CAP1126
6.6 Configuration Registers
The Configuration registers control general global functionality that affects the entire device.
6.6.1 CONFIGURATION - 20H
Bit 7 - TIMEOUT - Enables the timeout and idle functionality of the SMBus protocol.
• ‘0’ (default for Functional Revision C) - The SMBus timeout and idle functionality are disabled. The SMBus interface
will not time out if the clock line is held low. Likewise, it will not reset if both the data and clock lines are held
high for longer than 200us. This is used for I2C compliance.
• ‘1’ (default for Functional Revision B) - The SMBus timeout and idle functionality are enabled. The SMBus interface
will time out if the clock line is held low for longer than 30ms. Likewise, it will reset if both the data and clock
lines are held high for longer than 200us.
Bit 6 - WAKE_CFG - Configures the operation of the WAKE pin.
• ‘0’ (default) - The WAKE pin is not asserted when a touch is detected while the device is in Standby. It will still be
used to wake the device from Deep Sleep when driven high.
• ‘1’ - The WAKE pin will be asserted high when a touch is detected while the device is in Standby. It will also be
used to wake the device from Deep Sleep when driven high.
Bit 5 - DIS_DIG_NOISE - Determines whether the digital noise threshold (see Section 6.19, "Sensor Input Noise Threshold
Register") is used by the device. Setting this bit disables the feature.
• ‘0’ - The digital noise threshold is used. If a delta count value exceeds the noise threshold but does not exceed the
touch threshold, the sample is discarded and not used for the automatic re-calibration routine.
• ‘1’ (default) - The noise threshold is disabled. Any delta count that is less than the touch threshold is used for the
automatic re-calibration routine.
Bit 4 - DIS_ANA_NOISE - Determines whether the analog noise filter is enabled. Setting this bit disables the feature.
• ‘0’ (default) - If low frequency noise is detected by the analog block, the delta count on the corresponding channel
is set to 0. Note that this does not require that Noise Status bits be set.
• ‘1’ - A touch is not blocked even if low frequency noise is detected.
Bit 3 - MAX_DUR_EN - Determines whether the maximum duration recalibration is enabled.
• ‘0’ (default) - The maximum duration recalibration functionality is disabled. A touch may be held indefinitely and no
re-calibration will be performed on any sensor input.
• ‘1’ - The maximum duration recalibration functionality is enabled. If a touch is held for longer than the MAX_DUR
bit settings, then the re-calibration routine will be restarted (see Section 6.8).
6.6.2 CONFIGURATION 2 - 44H
Bit 7 - INV_LINK_TRAN - Determines the behavior of the Linked LED Transition controls (see Section 6.29).
• ‘0’ (default) - The Linked LED Transition controls set the min duty cycle equal to the max duty cycle.
• ‘1’ - The Linked LED Transition controls will invert the touch signal. For example, a touch signal will be inverted to
a non-touched signal.
Bit 6 - ALT_POL - Determines the ALERT# pin polarity and behavior.
• ‘0’ - The ALERT# pin is active high and push-pull.
• ‘1’ (default) - The ALERT# pin is active low and open drain.
TABLE 6-10: CONFIGURATION REGISTERS
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
20h R/W Configuration TIMEOUT WAKE_
CFG
DIS_ DIG_
NOISE
DIS_ ANA_
NOISE
MAX_
DUR_EN - --
A0h
(Rev B)
20h
(rev C)
44h R/W Configuration 2 INV_LINK_
TRAN
ALT_
POL
BLK_PWR_
CTRL
BLK_POL_
MIR
SHOW_
RF_
NOISE
DIS_
RF_
NOISE
- INT_
REL_n 40h
CAP1126
DS00001623B-page 36 2015 Microchip Technology Inc.
Bit 5 - BLK_PWR_CTRL - Determines whether the device will reduce power consumption while waiting between conversion
time completion and the end of the polling cycle.
• ‘0’ (default) - The device will always power down as much as possible during the time between the end of the last
conversion and the end of the polling cycle.
• ‘1’ - The device will not power down the Cap Sensor during the time between the end of the last conversion and
the end of the polling cycle.
Bit 4 - BLK_POL_MIR - Determines whether the LED Mirror Control register bits are linked to the LED Polarity bits. Setting
this bit blocks the normal behavior which is to automatically set and clear the LED Mirror Control bits when the LED
Polarity bits are set or cleared.
• ‘0’ (default) - When the LED Polarity controls are set, the corresponding LED Mirror control is automatically set.
Likewise, when the LED Polarity controls are cleared, the corresponding LED Mirror control is also cleared.
• ‘1’ - When the LED Polarity controls are set, the corresponding LED Mirror control is not automatically set.
Bit 3 - SHOW_RF_NOISE - Determines whether the Noise Status bits will show RF Noise as the only input source.
• ‘0’ (default) - The Noise Status registers will show both RF noise and low frequency EMI noise if either is detected
on a capacitive touch sensor input.
• ‘1’ - The Noise Status registers will only show RF noise if it is detected on a capacitive touch sensor input. EMI
noise will still be detected and touches will be blocked normally; however, the status bits will not be updated.
Bit 2 - DIS_RF_NOISE - Determines whether the RF noise filter is enabled. Setting this bit disables the feature.
• ‘0’ (default) - If RF noise is detected by the analog block, the delta count on the corresponding channel is set to 0.
Note that this does not require that Noise Status bits be set.
• ‘1’ - A touch is not blocked even if RF noise is detected.
Bit 0 - INT_REL_n - Controls the interrupt behavior when a release is detected on a button.
• ‘0’ (default) - An interrupt is generated when a press is detected and again when a release is detected and at the
repeat rate (if enabled - see Section 6.13).
• ‘1’ - An interrupt is generated when a press is detected and at the repeat rate but not when a release is detected.
6.7 Sensor Input Enable Registers
The Sensor Input Enable registers determine whether a capacitive touch sensor input is included in the sampling cycle.
The length of the sampling cycle is not affected by the number of sensor inputs measured.
Bit 5 - CS6_EN - Enables the CS6 input to be included during the sampling cycle.
• ‘0’ - The CS6 input is not included in the sampling cycle.
• ‘1’ (default) - The CS6 input is included in the sampling cycle.
Bit 4 - CS5_EN - Enables the CS5 input to be included during the sampling cycle.
Bit 3 - CS4_EN - Enables the CS4 input to be included during the sampling cycle.
Bit 2 - CS3_EN - Enables the CS3 input to be included during the sampling cycle.
Bit 1 - CS2_EN - Enables the CS2 input to be included during the sampling cycle.
Bit 0 - CS1_EN - Enables the CS1 input to be included during the sampling cycle.
6.8 Sensor Input Configuration Register
TABLE 6-11: SENSOR INPUT ENABLE REGISTERS
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
21h R/W Sensor Input
Enable - - CS6_EN CS5_EN CS4_EN CS3_EN CS2_EN CS1_EN 3Fh
TABLE 6-12: SENSOR INPUT CONFIGURATION REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
22h R/W Sensor Input
Configuration MAX_DUR[3:0] RPT_RATE[3:0] A4h
2015 Microchip Technology Inc. DS00001623B-page 37
CAP1126
The Sensor Input Configuration Register controls timings associated with the Capacitive sensor inputs 1 - 6.
Bits 7 - 4 - MAX_DUR[3:0] - (default 1010b) - Determines the maximum time that a sensor pad is allowed to be touched
until the capacitive touch sensor input is recalibrated, as shown in Table 6-13.
Bits 3 - 0 - RPT_RATE[3:0] - (default 0100b) Determines the time duration between interrupt assertions when auto
repeat is enabled. The resolution is 35ms the range is from 35ms to 560ms as shown in Table 6-14.
TABLE 6-13: MAX_DUR BIT DECODE
MAX_DUR[3:0]
Time Before Recalibration
32 1 0
0 0 0 0 560ms
0 0 0 1 840ms
0 0 1 0 1120ms
0 0 1 1 1400ms
0 1 0 0 1680ms
0 1 0 1 2240ms
0 1 1 0 2800ms
1 1 1 3360ms
1 0 0 0 3920ms
1 0 0 1 4480ms
1 0 1 0 5600ms (default)
1 0 1 1 6720ms
1 1 0 0 7840ms
1 1 0 1 8906ms
1 1 1 0 10080ms
1 1 1 1 11200ms
TABLE 6-14: RPT_RATE BIT DECODE
RPT_RATE[3:0]
Interrupt Repeat RATE
3 21 0
0 0 0 0 35ms
0 0 0 1 70ms
0 0 1 0 105ms
0 0 1 1 140ms
0 1 0 0 175ms (default)
0 1 0 1 210ms
0 1 1 0 245ms
0 1 1 1 280ms
1 0 0 0 315ms
1 0 0 1 350ms
1 0 1 0 385ms
1 0 1 1 420ms
1 1 0 0 455ms
1 1 0 1 490ms
1 1 1 0 525ms
1 1 1 1 560ms
CAP1126
DS00001623B-page 38 2015 Microchip Technology Inc.
6.9 Sensor Input Configuration 2 Register
Bits 3 - 0 - M_PRESS[3:0] - (default 0111b) - Determines the minimum amount of time that sensor inputs configured to
use auto repeat must detect a sensor pad touch to detect a “press and hold” event. If the sensor input detects a touch
for longer than the M_PRESS[3:0] settings, a “press and hold” event is detected. If a sensor input detects a touch for
less than or equal to the M_PRESS[3:0] settings, a touch event is detected.
The resolution is 35ms the range is from 35ms to 560ms as shown in Table 6-16.
6.10 Averaging and Sampling Configuration Register
The Averaging and Sampling Configuration register controls the number of samples taken and the total sensor input
cycle time for all active sensor inputs while the device is functioning in Active state.
Bits 6 - 4 - AVG[2:0] - Determines the number of samples that are taken for all active channels during the sensor cycle
as shown in Table 6-18. All samples are taken consecutively on the same channel before the next channel is sampled
and the result is averaged over the number of samples measured before updating the measured results.
For example, if CS1, CS2, and CS3 are sampled during the sensor cycle, and the AVG[2:0] bits are set to take 4 samples
per channel, then the full sensor cycle will be: CS1, CS1, CS1, CS1, CS2, CS2, CS2, CS2, CS3, CS3, CS3, CS3.
TABLE 6-15: SENSOR INPUT CONFIGURATION 2 REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
23h R/W Sensor Input
Configuration 2 - - - - M_PRESS[3:0] 07h
TABLE 6-16: M_PRESS BIT DECODE
M_PRESS[3:0]
M_PRESS SETTINGS
3 21 0
0 0 0 0 35ms
0 0 0 1 70ms
0 0 1 0 105ms
0 0 1 1 140ms
0 1 0 0 175ms
0 1 0 1 210ms
0 1 1 0 245ms
0 1 1 1 280ms (default)
1 0 0 0 315ms
1 0 0 1 350ms
1 0 1 0 385ms
1 0 1 1 420ms
1 1 0 0 455ms
1 1 0 1 490ms
1 1 1 0 525ms
1 1 1 1 560ms
TABLE 6-17: AVERAGING AND SAMPLING CONFIGURATION REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
24h R/W Averaging and
Sampling Config AVG[2:0] SAMP_TIME[1:0] CYCLE_TIME
[1:0] 39h
2015 Microchip Technology Inc. DS00001623B-page 39
CAP1126
Bits 3 - 2 - SAMP_TIME[1:0] - Determines the time to take a single sample as shown in Table 6-19.
Bits 1 - 0 - CYCLE_TIME[1:0] - Determines the overall cycle time for all measured channels during normal operation as
shown in Table 6-20. All measured channels are sampled at the beginning of the cycle time. If additional time is remaining,
then the device is placed into a lower power state for the remaining duration of the cycle.
APPLICATION NOTE: The programmed cycle time is only maintained if the total averaging time for all samples is
less than the programmed cycle. The AVG[2:0] bits will take priority so that if more samples
are required than would normally be allowed during the cycle time, the cycle time will be
extended as necessary to accommodate the number of samples to be measured.
6.11 Calibration Activate Register
The Calibration Activate register forces the respective sensor inputs to be re-calibrated affecting both the analog and
digital blocks. During the re-calibration routine, the sensor inputs will not detect a press for up to 600ms and the Sensor
Input Base Count register values will be invalid. During this time, any press on the corresponding sensor pads will invalidate
the re-calibration. When finished, the CALX[9:0] bits will be updated (see Section 6.39).
TABLE 6-18: AVG BIT DECODE
AVG[2:0] Number of Samples Taken per
Measurement 2 10
0 0 0 1
0 01 2
0 10 4
0 1 1 8 (default)
1 0 0 16
1 0 1 32
1 1 0 64
1 1 1 128
TABLE 6-19: SAMP_TIME BIT DECODE
SAMP_TIME[1:0]
Sample Time
1 0
0 0 320us
0 1 640us
1 0 1.28ms (default)
1 1 2.56ms
TABLE 6-20: CYCLE_TIME BIT DECODE
CYCLE_TIME[1:0]
Overall Cycle Time
1 0
0 0 35ms
0 1 70ms (default)
1 0 105ms
1 1 140ms
TABLE 6-21: CALIBRATION ACTIVATE REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
26h R/W Calibration
Activate - - CS6_
CAL
CS5_
CAL
CS4_
CAL
CS3_
CAL
CS2_
CAL
CS1_
CAL 00h
CAP1126
DS00001623B-page 40 2015 Microchip Technology Inc.
When the corresponding bit is set, the device will perform the calibration and the bit will be automatically cleared once
the re-calibration routine has finished.
Bit 5 - CS6_CAL - When set, the CS6 input is re-calibrated. This bit is automatically cleared once the sensor input has
been re-calibrated successfully.
Bit 4 - CS5_CAL - When set, the CS5 input is re-calibrated. This bit is automatically cleared once the sensor input has
been re-calibrated successfully.
Bit 3 - CS4_CAL - When set, the CS4 input is re-calibrated. This bit is automatically cleared once the sensor input has
been re-calibrated successfully.
Bit 2 - CS3_CAL - When set, the CS3 input is re-calibrated. This bit is automatically cleared once the sensor input has
been re-calibrated successfully.
Bit 1 - CS2_CAL - When set, the CS2 input is re-calibrated. This bit is automatically cleared once the sensor input has
been re-calibrated successfully.
Bit 0 - CS1_CAL - When set, the CS1 input is re-calibrated. This bit is automatically cleared once the sensor input has
been re-calibrated successfully.
6.12 Interrupt Enable Register
The Interrupt Enable register determines whether a sensor pad touch or release (if enabled) causes the interrupt pin to
be asserted.
Bit 5 - CS6_INT_EN - Enables the interrupt pin to be asserted if a touch is detected on CS6 (associated with the CS6
status bit).
• ‘0’ - The interrupt pin will not be asserted if a touch is detected on CS6 (associated with the CS6 status bit).
• ‘1’ (default) - The interrupt pin will be asserted if a touch is detected on CS6 (associated with the CS6 status bit).
Bit 4 - CS5_INT_EN - Enables the interrupt pin to be asserted if a touch is detected on CS5 (associated with the CS5
status bit).
Bit 3 - CS4_INT_EN - Enables the interrupt pin to be asserted if a touch is detected on CS4 (associated with the CS4
status bit).
Bit 2 - CS3_INT_EN - Enables the interrupt pin to be asserted if a touch is detected on CS3 (associated with the CS3
status bit).
Bit 1 - CS2_INT_EN - Enables the interrupt pin to be asserted if a touch is detected on CS2 (associated with the CS2
status bit).
Bit 0 - CS1_INT_EN - Enables the interrupt pin to be asserted if a touch is detected on CS1 (associated with the CS1
status bit).
6.13 Repeat Rate Enable Register
The Repeat Rate Enable register enables the repeat rate of the sensor inputs as described in Section 5.6.1.
Bit 5 - CS6_RPT_EN - Enables the repeat rate for capacitive touch sensor input 6.
• ‘0’ - The repeat rate for CS6 is disabled. It will only generate an interrupt when a touch is detected and when a
release is detected no matter how long the touch is held for.
• ‘1’ (default) - The repeat rate for CS6 is enabled. In the case of a “touch” event, it will generate an interrupt when a
TABLE 6-22: INTERRUPT ENABLE REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
27h R/W Interrupt
Enable - - CS6_
INT_EN
CS5_
INT_EN
CS4_
INT_EN
CS3_
INT_EN
CS2_
INT_EN
CS1_
INT_EN 3Fh
TABLE 6-23: REPEAT RATE ENABLE REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
28h R/W Repeat Rate
Enable - - CS6_
RPT_EN
CS5_
RPT_EN
CS4_
RPT_EN
CS3_
RPT_EN
CS2_
RPT_EN
CS1_
RPT_EN 3Fh
2015 Microchip Technology Inc. DS00001623B-page 41
CAP1126
touch is detected and a release is detected (as determined by the INT_REL_n bit - see Section 6.6). In the case of
a “press and hold” event, it will generate an interrupt when a touch is detected and at the repeat rate so long as
the touch is held.
Bit 4 - CS5_RPT_EN - Enables the repeat rate for capacitive touch sensor input 5.
Bit 3 - CS4_RPT_EN - Enables the repeat rate for capacitive touch sensor input 4.
Bit 2 - CS3_RPT_EN - Enables the repeat rate for capacitive touch sensor input 3.
Bit 1 - CS2_RPT_EN - Enables the repeat rate for capacitive touch sensor input 2.
Bit 0 - CS1_RPT_EN - Enables the repeat rate for capacitive touch sensor input 1.
6.14 Multiple Touch Configuration Register
The Multiple Touch Configuration register controls the settings for the multiple touch detection circuitry. These settings
determine the number of simultaneous buttons that may be pressed before additional buttons are blocked and the MULT
status bit is set.
Bit 7 - MULT_BLK_EN - Enables the multiple button blocking circuitry.
• ‘0’ - The multiple touch circuitry is disabled. The device will not block multiple touches.
• ‘1’ (default) - The multiple touch circuitry is enabled. The device will flag the number of touches equal to programmed
multiple touch threshold and block all others. It will remember which sensor inputs are valid and block all
others until that sensor pad has been released. Once a sensor pad has been released, the N detected touches
(determined via the cycle order of CS1 - CS6) will be flagged and all others blocked.
Bits 3 - 2 - B_MULT_T[1:0] - Determines the number of simultaneous touches on all sensor pads before a Multiple Touch
Event is detected and sensor inputs are blocked. The bit decode is given by Table 6-25.
6.15 Multiple Touch Pattern Configuration Register
The Multiple Touch Pattern Configuration register controls the settings for the multiple touch pattern detection circuitry.
This circuitry works like the multiple touch detection circuitry with the following differences:
1. The detection threshold is a percentage of the touch detection threshold as defined by the MTP_TH[1:0] bits
whereas the multiple touch circuitry uses the touch detection threshold.
2. The MTP detection circuitry either will detect a specific pattern of sensor inputs as determined by the Multiple
Touch Pattern register settings or it will use the Multiple Touch Pattern register settings to determine a minimum
number of sensor inputs that will cause the MTP circuitry to flag an event. When using pattern recognition mode,
TABLE 6-24: MULTIPLE TOUCH CONFIGURATION
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
2Ah R/W Multiple Touch
Config
MULT_
BLK_
EN
- - - B_MULT_T[1:0] - - 80h
TABLE 6-25: B_MULT_T BIT DECODE
B_MULT_T[1:0]
Number of Simultaneous Touches
1 0
0 0 1 (default)
01 2
10 3
11 4
TABLE 6-26: MULTIPLE TOUCH PATTERN CONFIGURATION
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
2Bh R/W Multiple Touch
Pattern Config MTP_ EN - - MTP_TH[1:0] COMP_
PTRN
MTP_
ALERT 00h
CAP1126
DS00001623B-page 42 2015 Microchip Technology Inc.
if all of the sensor inputs set by the Multiple Touch Pattern register have a delta count greater than the MTP
threshold or have their corresponding Noise Flag Status bits set, the MTP bit will be set. When using the absolute
number mode, if the number of sensor inputs with thresholds above the MTP threshold or with Noise Flag Status
bits set is equal to or greater than this number, the MTP bit will be set.
3. When an MTP event occurs, all touches are blocked and an interrupt is generated.
4. All sensor inputs will remain blocked so long as the requisite number of sensor inputs are above the MTP threshold
or have Noise Flag Status bits set. Once this condition is removed, touch detection will be restored. Note that
the MTP status bit is only cleared by writing a ‘0’ to the INT bit once the condition has been removed.
Bit 7 - MTP_EN - Enables the multiple touch pattern detection circuitry.
• ‘0’ (default) - The MTP detection circuitry is disabled.
• ‘1’ - The MTP detection circuitry is enabled.
Bits 3-2 - MTP_TH[1:0] - Determine the MTP threshold, as shown in Table 6-27. This threshold is a percentage of sensor
input threshold (see Section 6.18, "Sensor Input Threshold Registers") when the device is in the Fully Active state or of
the standby threshold (see Section 6.23, "Standby Threshold Register") when the device is in the Standby state.
Bit 1 - COMP_PTRN - Determines whether the MTP detection circuitry will use the Multiple Touch Pattern register as a
specific pattern of sensor inputs or as an absolute number of sensor inputs.
• ‘0’ (default) - The MTP detection circuitry will use the Multiple Touch Pattern register bit settings as an absolute
minimum number of sensor inputs that must be above the threshold or have Noise Flag Status bits set. The number
will be equal to the number of bits set in the register.
• ‘1’ - The MTP detection circuitry will use pattern recognition. Each bit set in the Multiple Touch Pattern register
indicates a specific sensor input that must have a delta count greater than the MTP threshold or have a Noise Flag
Status bit set. If the criteria are met, the MTP status bit will be set.
Bit 0 - MTP_ALERT - Enables an interrupt if an MTP event occurs. In either condition, the MTP status bit will be set.
• ‘0’ (default) - If an MTP event occurs, the ALERT# pin is not asserted.
• ‘1’ - If an MTP event occurs, the ALERT# pin will be asserted.
6.16 Multiple Touch Pattern Register
The Multiple Touch Pattern register acts as a pattern to identify an expected sensor input profile for diagnostics or other
significant events. There are two methods for how the Multiple Touch Pattern register is used: as specific sensor inputs
or number of sensor input that must exceed the MTP threshold or have Noise Flag Status bits set. Which method is used
is based on the COMP_PTRN bit (see Section 6.15). The methods are described below.
1. Specific Sensor Inputs: If, during a single polling cycle, the specific sensor inputs above the MTP threshold or
with Noise Flag Status bits set match those bits set in the Multiple Touch Pattern register, an MTP event is
flagged.
2. Number of Sensor Inputs: If, during a single polling cycle, the number of sensor inputs with a delta count above
the MTP threshold or with Noise Flag Status bits set is equal to or greater than the number of pattern bits set, an
MTP event is flagged.
TABLE 6-27: MTP_TH BIT DECODE
MTP_TH[1:0]
Threshold Divide Setting
1 0
0 0 12.5% (default)
0 1 25%
1 0 37.5%
1 1 100%
TABLE 6-28: MULTIPLE TOUCH PATTERN REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
2Dh R/W Multiple
Touch Pattern - - CS6_
PTRN
CS5_
PTRN
CS4_
PTRN
CS3_
PTRN
CS2_
PTRN
CS1_
PTRN 3Fh
2015 Microchip Technology Inc. DS00001623B-page 43
CAP1126
Bit 5 - CS6_PTRN - Determines whether CS6 is considered as part of the Multiple Touch Pattern.
• ‘0’ - CS6 is not considered a part of the pattern.
• ‘1’ - CS6 is considered a part of the pattern or the absolute number of sensor inputs that must have a delta count
greater than the MTP threshold or have the Noise Flag Status bit set is increased by 1.
Bit 4 - CS5_PTRN - Determines whether CS5 is considered as part of the Multiple Touch Pattern.
Bit 3 - CS4_PTRN - Determines whether CS4 is considered as part of the Multiple Touch Pattern.
Bit 2 - CS3_PTRN - Determines whether CS3 is considered as part of the Multiple Touch Pattern.
Bit 1 - CS2_PTRN - Determines whether CS2 is considered as part of the Multiple Touch Pattern.
Bit 0 - CS1_PTRN - Determines whether CS1 is considered as part of the Multiple Touch Pattern.
6.17 Recalibration Configuration Register
The Recalibration Configuration register controls the automatic re-calibration routine settings as well as advanced controls
to program the Sensor Input Threshold register settings.
Bit 7 - BUT_LD_TH - Enables setting all Sensor Input Threshold registers by writing to the Sensor Input 1 Threshold
register.
• ‘0’ - Each Sensor Input X Threshold register is updated individually.
• ‘1’ (default) - Writing the Sensor Input 1 Threshold register will automatically overwrite the Sensor Input Threshold
registers for all sensor inputs (Sensor Input Threshold 1 through Sensor Input Threshold 6). The individual Sensor
Input X Threshold registers (Sensor Input 2 Threshold through Sensor Input 6 Threshold) can be individually
updated at any time.
Bit 6 - NO_CLR_INTD - Controls whether the accumulation of intermediate data is cleared if the noise status bit is set.
• ‘0’ (default) - The accumulation of intermediate data is cleared if the noise status bit is set.
• ‘1’ - The accumulation of intermediate data is not cleared if the noise status bit is set.
APPLICATION NOTE: Bits 5 and 6 should both be set to the same value. Either both should be set to ‘0’ or both
should be set to ‘1’.
Bit 5 - NO_CLR_NEG - Controls whether the consecutive negative delta counts counter is cleared if the noise status bit
is set.
• ‘0’ (default) - The consecutive negative delta counts counter is cleared if the noise status bit is set.
• ‘1’ - The consecutive negative delta counts counter is not cleared if the noise status bit is set.
Bits 4 - 3 - NEG_DELTA_CNT[1:0] - Determines the number of negative delta counts necessary to trigger a digital recalibration
as shown in Table 6-30.
TABLE 6-29: RECALIBRATION CONFIGURATION REGISTERS
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
2Fh R/W Recalibration
Configuration
BUT_
LD_TH
NO_
CLR_
INTD
NO_
CLR_
NEG
NEG_DELTA_
CNT[1:0] CAL_CFG[2:0] 8Ah
TABLE 6-30: NEG_DELTA_CNT BIT DECODE
NEG_DELTA_CNT[1:0]
Number of Consecutive Negative Delta Count Values
1 0
00 8
0 1 16 (default)
1 0 32
1 1 None (disabled)
CAP1126
DS00001623B-page 44 2015 Microchip Technology Inc.
Bits 2 - 0 - CAL_CFG[2:0] - Determines the update time and number of samples of the automatic re-calibration routine.
The settings apply to all sensor inputs universally (though individual sensor inputs can be configured to support re-calibration
- see Section 6.11).
Note 6-1 Recalibration Samples refers to the number of samples that are measured and averaged before the
Base Count is updated however does not control the base count update period.
Note 6-2 Update Time refers to the amount of time (in polling cycle periods) that elapses before the Base
Count is updated. The time will depend upon the number of channels active, the averaging setting,
and the programmed cycle time.
6.18 Sensor Input Threshold Registers
The Sensor Input Threshold registers store the delta threshold that is used to determine if a touch has been detected.
When a touch occurs, the input signal of the corresponding sensor pad changes due to the capacitance associated with
a touch. If the sensor input change exceeds the threshold settings, a touch is detected.
When the BUT_LD_TH bit is set (see Section 6.17 - bit 7), writing data to the Sensor Input 1 Threshold register will
update all of the sensor input threshold registers (31h - 35h inclusive).
6.19 Sensor Input Noise Threshold Register
TABLE 6-31: CAL_CFG BIT DECODE
CAL_CFG[2:0] Recalibration Samples
(see Note 6-1)
Update Time (see
Note 6-2) 210
0 0 0 16 16
0 0 1 32 32
0 1 0 64 64 (default)
0 1 1 128 128
1 0 0 256 256
1 0 1 256 1024
1 1 0 256 2048
1 1 1 256 4096
TABLE 6-32: SENSOR INPUT THRESHOLD REGISTERS
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
30h R/W Sensor Input 1
Threshold - 64 32 16 8 4 2 1 40h
31h R/W Sensor Input 2
Threshold - 64 32 16 8 4 2 1 40h
32h R/W Sensor Input 3
Threshold - 64 32 16 8 4 2 1 40h
33h R/W Sensor Input 4
Threshold - 64 32 16 8 4 2 1 40h
34h R/W Sensor Input 5
Threshold - 64 32 16 8 4 2 1 40h
35h R/W Sensor Input 6
Threshold - 64 32 16 8 4 2 1 40h
TABLE 6-33: SENSOR INPUT NOISE THRESHOLD REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
38h R/W Sensor Input
Noise Threshold CS_BN_TH [1:0] 01h
2015 Microchip Technology Inc. DS00001623B-page 45
CAP1126
The Sensor Input Noise Threshold register controls the value of a secondary internal threshold to detect noise and
improve the automatic recalibration routine. If a capacitive touch sensor input exceeds the Sensor Input Noise Threshold
but does not exceed the sensor input threshold, it is determined to be caused by a noise spike. That sample is not used
by the automatic re-calibration routine. This feature can be disabled by setting the DIS_DIG_NOISE bit.
Bits 1-0 - CS1_BN_TH[1:0] - Controls the noise threshold for all capacitive touch sensor inputs, as shown in Table 6-34.
The threshold is proportional to the threshold setting.
6.20 Standby Channel Register
The Standby Channel register controls which (if any) capacitive touch sensor inputs are active during Standby.
Bit 5 - CS6_STBY - Controls whether the CS6 channel is active in Standby.
• ‘0’ (default) - The CS6 channel not be sampled during Standby mode.
• ‘1’ - The CS6 channel will be sampled during Standby Mode. It will use the Standby threshold setting, and the
standby averaging and sensitivity settings.
Bit 4 - CS5_STBY - Controls whether the CS5 channel is active in Standby.
Bit 3 - CS4_STBY - Controls whether the CS4 channel is active in Standby.
Bit 2 - CS3_STBY - Controls whether the CS3 channel is active in Standby.
Bit 1 - CS2_STBY - Controls whether the CS2 channel is active in Standby.
Bit 0 - CS1_STBY - Controls whether the CS1 channel is active in Standby.
6.21 Standby Configuration Register
The Standby Configuration register controls averaging and cycle time for those sensor inputs that are active in Standby.
This register is useful for detecting proximity on a small number of sensor inputs as it allows the user to change averaging
and sample times on a limited number of sensor inputs and still maintain normal functionality in the fully active
state.
Bit 7 - AVG_SUM - Determines whether the active sensor inputs will average the programmed number of samples or
whether they will accumulate for the programmed number of samples.
• ‘0’ - (default) - The active sensor input delta count values will be based on the average of the programmed number
of samples when compared against the threshold.
• ‘1’ - The active sensor input delta count values will be based on the summation of the programmed number of
samples when compared against the threshold. This bit should only be set when performing proximity detection as
TABLE 6-34: CSX_BN_TH BIT DECODE
CS_BN_TH[1:0]
Percent Threshold Setting
1 0
0 0 25%
0 1 37.5% (default)
1 0 50%
1 1 62.5%
TABLE 6-35: STANDBY CHANNEL REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
40h R/W Standby Channel - - CS6_
STBY
CS5_
STBY
CS4_
STBY
CS3_
STBY
CS2_
STBY
CS1_
STBY 00h
TABLE 6-36: STANDBY CONFIGURATION REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
41h R/W Standby Configuration
AVG_
SUM STBY_AVG[2:0] STBY_SAMP_
TIME[1:0]
STBY_CY_TIME
[1:0] 39h
CAP1126
DS00001623B-page 46 2015 Microchip Technology Inc.
a physical touch will overflow the delta count registers and may result in false readings.
Bits 6 - 4 - STBY_AVG[2:0] - Determines the number of samples that are taken for all active channels during the sensor
cycle as shown in Table 6-37. All samples are taken consecutively on the same channel before the next channel is sampled
and the result is averaged over the number of samples measured before updating the measured results.
Bit 3-2 - STBY SAMP_TIME[1:0] - Determines the time to take a single sample when the device is in Standby as shown
in Table 6-38.
Bits 1 - 0 - STBY_CY_TIME[2:0] - Determines the overall cycle time for all measured channels during standby operation
as shown in Table 6-39. All measured channels are sampled at the beginning of the cycle time. If additional time is
remaining, the device is placed into a lower power state for the remaining duration of the cycle.
APPLICATION NOTE: The programmed cycle time is only maintained if the total averaging time for all samples is
less than the programmed cycle. The STBY_AVG[2:0] bits will take priority so that if more
samples are required than would normally be allowed during the cycle time, the cycle time
will be extended as necessary to accommodate the number of samples to be measured.
TABLE 6-37: STBY_AVG BIT DECODE
STBY_AVG[2:0] Number of Samples Taken per
Measurement 2 10
0 0 0 1
0 01 2
0 10 4
0 1 1 8 (default)
1 0 0 16
1 0 1 32
1 1 0 64
1 1 1 128
TABLE 6-38: STBY_SAMP_TIME BIT DECODE
STBY_SAMP_TIME[1:0]
Sampling Time
1 0
0 0 320us
0 1 640us
1 0 1.28ms (default)
1 1 2.56ms
TABLE 6-39: STBY_CY_TIME BIT DECODE
STBY_CY_TIME[1:0]
Overall Cycle Time
1 0
0 0 35ms
0 1 70ms (default)
1 0 105ms
1 1 140ms
2015 Microchip Technology Inc. DS00001623B-page 47
CAP1126
6.22 Standby Sensitivity Register
The Standby Sensitivity register controls the sensitivity for sensor inputs that are active in Standby.
Bits 2 - 0 - STBY_SENSE[2:0] - Controls the sensitivity for sensor inputs that are active in Standby. The sensitivity settings
act to scale the relative delta count value higher or lower based on the system parameters. A setting of 000b is the
most sensitive while a setting of 111b is the least sensitive. At the more sensitive settings, touches are detected for a
smaller delta C corresponding to a “lighter” touch. These settings are more sensitive to noise however and a noisy environment
may flag more false touches than higher sensitivity levels.
APPLICATION NOTE: A value of 128x is the most sensitive setting available. At the most sensitivity settings, the
MSB of the Delta Count register represents 64 out of ~25,000 which corresponds to a touch
of approximately 0.25% of the base capacitance (or a ΔC of 25fF from a 10pF base
capacitance). Conversely a value of 1x is the least sensitive setting available. At these
settings, the MSB of the Delta Count register corresponds to a delta count of 8192 counts
out of ~25,000 which corresponds to a touch of approximately 33% of the base capacitance
(or a ΔC of 3.33pF from a 10pF base capacitance).
6.23 Standby Threshold Register
The Standby Threshold register stores the delta threshold that is used to determine if a touch has been detected. When
a touch occurs, the input signal of the corresponding sensor pad changes due to the capacitance associated with a
touch. If the sensor input change exceeds the threshold settings, a touch is detected.
6.24 Sensor Input Base Count Registers
TABLE 6-40: STANDBY SENSITIVITY REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
42h R/W Standby Sensitivity
- - - - - STBY_SENSE[2:0] 02h
TABLE 6-41: STBY_SENSE BIT DECODE
STBY_SENSE[2:0]
Sensitivity Multiplier
210
0 0 0 128x (most sensitive)
0 0 1 64x
0 1 0 32x (default)
0 1 1 16x
1 0 0 8x
1 0 1 4x
1 1 0 2x
1 1 1 1x - (least sensitive)
TABLE 6-42: STANDBY THRESHOLD REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
43h R/W Standby Threshold
- 64 32 16 8 4 2 1 40h
TABLE 6-43: SENSOR INPUT BASE COUNT REGISTERS
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
50h R Sensor Input 1
Base Count 128 64 32 16 8 4 2 1 C8h
CAP1126
DS00001623B-page 48 2015 Microchip Technology Inc.
The Sensor Input Base Count registers store the calibrated “Not Touched” input value from the capacitive touch sensor
inputs. These registers are periodically updated by the re-calibration routine.
The routine uses an internal adder to add the current count value for each reading to the sum of the previous readings
until sample size has been reached. At this point, the upper 16 bits are taken and used as the Sensor Input Base Count.
The internal adder is then reset and the re-calibration routine continues.
The data presented is determined by the BASE_SHIFT[3:0] bits (see Section 6.5).
6.25 LED Output Type Register
The LED Output Type register controls the type of output for the LED pins. Each pin is controlled by a single bit. Refer
to application note 21.4 CAP1126Family LED Configuration Options for more information about implementing LEDs.
Bit 1 - LED2_OT - Determines the output type of the LED2 pin.
• ‘0’ (default) - The LED2 pin is an open-drain output with an external pull-up resistor. When the appropriate pin is
set to the “active” state (logic ‘1’), the pin will be driven low. Conversely, when the pin is set to the “inactive” state
(logic ‘0’), then the pin will be left in a High Z state and pulled high via an external pull-up resistor.
• ‘1’ - The LED2 pin is a push-pull output. When driving a logic ‘1’, the pin is driven high. When driving a logic ‘0’, the
pin is driven low.
Bit 0 - LED1_OT - Determines the output type of the LED1 pin.
6.26 Sensor Input LED Linking Register
The Sensor Input LED Linking register controls whether a capacitive touch sensor input is linked to an LED output. If
the corresponding bit is set, then the appropriate LED output will change states defined by the LED Behavior controls
(see Section 6.31) in response to the capacitive touch sensor input.
Bit 1 - CS2_LED2 - Links the LED2 output to a detected touch on the CS2 sensor input. When a touch is detected, the
LED is actuated and will behave as determined by the LED Behavior controls.
• ‘0’ (default) - The LED 2 output is not associated with the CS2 input. If a touch is detected on the CS2 input, the
LED will not automatically be actuated. The LED is enabled and controlled via the LED Output Control register
(see Section 6.28) and the LED Behavior registers (see Section 6.31).
51h R Sensor Input 2
Base Count 128 64 32 16 8 4 2 1 C8h
52h R Sensor Input 3
Base Count 128 64 32 16 8 4 2 1 C8h
53h R Sensor Input 4
Base Count 128 64 32 16 8 4 2 1 C8h
54h R Sensor Input 5
Base Count 128 64 32 16 8 4 2 1 C8h
55h R Sensor Input 6
Base Count 128 64 32 16 8 4 2 1 C8h
TABLE 6-44: LED OUTPUT TYPE REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
71h R/W LED Output
Type ----- - LED2_
OT
LED1_
OT 00h
TABLE 6-45: SENSOR INPUT LED LINKING REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
72h R/W Sensor Input
LED Linking
- - - - - - CS2_
LED2
CS1_
LED1
00h
TABLE 6-43: SENSOR INPUT BASE COUNT REGISTERS (CONTINUED)
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
2015 Microchip Technology Inc. DS00001623B-page 49
CAP1126
• ‘1’ - The LED 2 output is associated with the CS2 input. If a touch is detected on the CS2 input, the LED will be
actuated and behave as defined in Table 6-52.
Bit 0 - CS1_LED1 - Links the LED1 output to a detected touch on the CS1 sensor input. When a touch is detected, the
LED is actuated and will behave as determined by the LED Behavior controls.
6.27 LED Polarity Register
The LED Polarity register controls the logical polarity of the LED outputs. When these bits are set or cleared, the corresponding
LED Mirror controls are also set or cleared (unless the BLK_POL_MIR bit is set - see Section 6.6, "Configuration
Registers"). Table 6-48, "LED Polarity Behavior" shows the interaction between the polarity controls, output
controls, and relative brightness.
APPLICATION NOTE: The polarity controls determine the final LED pin drive. A touch on a linked capacitive touch
sensor input is treated in the same way as the LED Output Control bit being set to a logic ‘1’.
APPLICATION NOTE: The LED drive assumes that the LEDs are configured such that if the LED pin is driven to
a logic ‘0’ then the LED will be on and that the CAP1126 LED pin is sinking the LED current.
Conversely, if the LED pin is driven to a logic ‘1’, the LED will be off and there is no current
flow. See Figure 5-1, "System Diagram for CAP1126".
APPLICATION NOTE: This application note applies when the LED polarity is inverted (LEDx_POL = ‘0’). For LED
operation, the duty cycle settings determine the % of time that the LED pin will be driven to
a logic ‘0’ state in. The Max Duty Cycle settings define the maximum % of time that the LED
pin will be driven low (i.e. maximum % of time that the LED is on) while the Min Duty Cycle
settings determine the minimum % of time that the LED pin will be driven low (i.e. minimum
% of time that the LED is on). When there is no touch detected or the LED Output Control
register bit is at a logic ‘0’, the LED output will be driven at the minimum duty cycle setting.
Breathe operations will ramp the duty cycle from the minimum duty cycle to the maximum
duty cycle.
APPLICATION NOTE: This application note applies when the LED polarity is non-inverted (LEDx_POL = ‘1’). For
LED operation, the duty cycle settings determine the % of time that the LED pin will be driven
to a logic ‘1’ state. The Max Duty Cycle settings define the maximum % of time that the LED
pin will be driven high (i.e. maximum % of time that the LED is off) while the Min Duty Cycle
settings determine the minimum % of time that the LED pin will be driven high (i.e. minimum
% of time that the LED is off). When there is no touch detected or the LED Output Control
register bit is at a logic ‘0’, the LED output will be driven at 100 minus the minimum duty
cycle setting. Breathe operations will ramp the duty cycle from 100 minus the minimum duty
cycle to 100 minus the maximum duty cycle.
APPLICATION NOTE: The LED Mirror controls (see Section 6.30, "LED Mirror Control Register") work with the
polarity controls with respect to LED brightness but will not have a direct effect on the output
pin drive.
Bit 1 - LED2_POL - Determines the polarity of the LED2 output.
• ‘0’ (default) - The LED2 output is inverted. For example, a setting of ‘1’ in the LED Output Control register will
cause the LED pin output to be driven to a logic ‘0’.
• ‘1’ - The LED2 output is non-inverted. For example, a setting of ‘1’ in the LED Output Control register will cause
the LED pin output to be driven to a logic ‘1’ or left in the high-z state as determined by its output type.
Bit 0 - LED1_POL - Determines the polarity of the LED1 output.
TABLE 6-46: LED POLARITY REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
73h R/W LED Polarity - - - - - - LED2_
POL
LED1_
POL 00h
CAP1126
DS00001623B-page 50 2015 Microchip Technology Inc.
6.28 LED Output Control Register
The LED Output Control Register controls the output state of the LED pins that are not linked to sensor inputs.
The LED Polarity Control Register will determine the non actuated state of the LED pins. The actuated LED behavior is
determined by the LED behavior controls (see Section 6.31, "LED Behavior Register").
Table 6-48 shows the interaction between the polarity controls, output controls, and relative brightness.
Bit 1 - LED2_DR - Determines whether LED2 output is driven high or low.
• ‘0’ (default) - The LED2 output is driven at the minimum duty cycle or not actuated.
• ‘1’ - The LED2 output is High Z or driven at the maximum duty cycle or actuated.
Bit 0 - LED1_DR - Determines whether LED1 output is driven high or low.
TABLE 6-47: LED OUTPUT CONTROL REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
74h R/W LED Output
Control --- - -- LED2_
DR
LED1_
DR 00h
Note: If an LED is linked to a sensor input in the Sensor Input LED Linking Register (Section 6.26, "Sensor Input
LED Linking Register"), the corresponding bit in the LED Output Control Register is ignored (i.e. a linked
LED cannot be host controlled).
TABLE 6-48: LED POLARITY BEHAVIOR
LED Output
Control
Register or
Touch
Polarity Max Duty Min Duty Brightness LED Appearance
0 inverted (‘0’) not used
minimum % of time
that the LED is on
(logic 0)
maximum brightness at
min duty cycle
on at min duty
cycle
1 inverted (‘0’)
maximum % of time
that the LED is on
(logic 0)
minimum % of time
that the LED is on
(logic 0)
maximum brightness at
max duty cycle. Brightness
ramps from min
duty cycle to max duty
cycle
according to LED
behavior
0 non-inverted
(‘1’) not used
minimum % of time
that the LED is off
(logic 1)
maximum brightness at
100 minus min duty
cycle.
on at 100 - min
duty cycle
1 non-inverted
(‘1’)
maximum % of time
that the LED is off
(logic 1)
minimum % of time
that the LED is off
(logic 1)
For Direct behavior,
maximum brightness is
100 minus max duty
cycle. When breathing,
max brightness is
100 minus min duty
cycle. Brightness
ramps from 100 - min
duty cycle to 100 - max
duty cycle.
according to LED
behavior
2015 Microchip Technology Inc. DS00001623B-page 51
CAP1126
6.29 Linked LED Transition Control Register
The Linked LED Transition Control register controls the LED drive when the LED is linked to a capacitive touch sensor
input. These controls work in conjunction with the INV_LINK_TRAN bit (see Section 6.6.2, "Configuration 2 - 44h") to
create smooth transitions from host control to linked LEDs.
Bit 1 - LED2_LTRAN - Determines the transition effect when LED2 is linked to CS2.
• ‘0’ (default) - When the LED output control bit for LED2 is ‘1’, and then LED2 is linked to CS2 and no touch is
detected, the LED will change states.
• ‘1’ - If the INV_LINK_TRAN bit is ‘1’, when the LED output control bit for CS2 is ‘1’, and then CS2 is linked to LED2
and no touch is detected, the LED will not change states. In addition, the LED state will change when the sensor
pad is touched. If the INV_LINK_TRAN bit is ‘0’, when the LED output control bit for CS2 is ‘1’, and then CS2 is
linked to LED2 and no touch is detected, the LED will not change states. However, the LED state will not change
when the sensor pad is touched.
APPLICATION NOTE: If the LED behavior is not “Direct” and the INV_LINK_TRAN bit it ‘0’, the LED will not perform
as expected when the LED2_LTRAN bit is set to ‘1’. Therefore, if breathe and pulse
behaviors are used, set the INV_LINK_TRAN bit to ‘1’.
Bit 0 - LED1_LTRAN - Determines the transition effect when LED1 is linked to CS1.
6.30 LED Mirror Control Register
The LED Mirror Control Registers determine the meaning of duty cycle settings when polarity is non-inverted for each
LED channel. When the polarity bit is set to ‘1’ (non-inverted), to obtain correct steps for LED ramping, pulse, and
breathe behaviors, the min and max duty cycles need to be relative to 100%, rather than the default, which is relative
to 0%.
APPLICATION NOTE: The LED drive assumes that the LEDs are configured such that if the LED pin is driven to
a logic ‘0’, the LED will be on and the CAP1126 LED pin is sinking the LED current. When
the polarity bit is set to ‘1’, it is considered non-inverted. For systems using the opposite LED
configuration, mirror controls would apply when the polarity bit is ‘0’.
These bits are changed automatically if the corresponding LED Polarity bit is changed (unless the BLK_POL_MIR bit is
set - see Section 6.6).
Bit 1 - LED2_MIR_EN - Determines whether the duty cycle settings are “biased” relative to 0% or 100% duty cycle.
• ‘0’ (default) - The duty cycle settings are determined relative to 0% and are determined directly with the settings.
• ‘1’ - The duty cycle settings are determined relative to 100%.
Bit 0 - LED1_MIR_EN - Determines whether the duty cycle settings are “biased” relative to 0% or 100% duty cycle.
6.31 LED Behavior Register
TABLE 6-49: LINKED LED TRANSITION CONTROL REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
77h R/W Linked LED Transition
Control - ----- LED2_
LTRAN
LED1_
LTRAN 00h
TABLE 6-50: LED MIRROR CONTROL REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
79h R/W LED Mirror Control
------
LED2_
MIR _
EN
LED1_
MIR _
EN
00h
TABLE 6-51: LED BEHAVIOR REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
81h R/W LED Behavior 1 - - - - LED2_CTL[1:0] LED1_CTL[1:0] 00h
CAP1126
DS00001623B-page 52 2015 Microchip Technology Inc.
The LED Behavior register controls the operation of LEDs. Each LED pin is controlled by a 2-bit field and the behavior
is determined by whether the LED is linked to a capacitive touch sensor input or not.
If the corresponding LED output is linked to a capacitive touch sensor input, the appropriate behavior will be enabled /
disabled based on touches and releases.
If the LED output is not associated with a capacitive touch sensor input, the appropriate behavior will be enabled / disabled
by the LED Output Control register. If the respective LEDx_DR bit is set to a logic ‘1’, this will be associated as a
“touch”, and if the LEDx_DR bit is set to a logic ‘0’, this will be associated as a “release”.
Table 6-52, "LEDx_CTL Bit Decode" shows the behavior triggers. The defined behavior will activate when the Start Trigger
is met and will stop when the Stop Trigger is met. Note the behavior of the Breathe Hold and Pulse Release option.
The LED Polarity Control register will determine the non actuated state of the LED outputs (see Section 6.27, "LED
Polarity Register").
APPLICATION NOTE: If an LED is not linked to a capacitive touch sensor input and is breathing (via the Breathe
or Pulse behaviors), it must be unactuated and then re-actuated before changes to behavior
are processed. For example, if the LED output is breathing and the Maximum duty cycle is
changed, this change will not take effect until the LED output control register is set to ‘0’ and
then re-set to ‘1’.
APPLICATION NOTE: If an LED is not linked to the capacitive touch sensor input and configured to operate using
Pulse 1 Behavior, then the circuitry will only be actuated when the corresponding output
control bit is set. It will not check the bit condition until the Pulse 1 behavior is finished. The
device will not remember if the bit was cleared and reset while it was actuated.
APPLICATION NOTE: If an LED is actuated and not linked and the desired LED behavior is changed, this new
behavior will take effect immediately; however, the first instance of the changed behavior
may act incorrectly (e.g. if changed from Direct to Pulse 1, the LED output may ‘breathe’ 4
times and then end at minimum duty cycle). LED Behaviors will operate normally once the
LED has been un-actuated and then re-actuated.
APPLICATION NOTE: If an LED is actuated and it is switched from linked to a capacitive touch sensor input to
unlinked (or vice versa), the LED will respond to the new command source immediately if
the behavior was Direct or Breathe. For Pulse behaviors, it will complete the behavior
already in progress. For example, if a linked LED was actuated by a touch and the control
is changed so that it is unlinked, it will check the status of the corresponding LED Output
Control bit. If that bit is ‘0’, then the LED will behave as if a release was detected. Likewise,
if an unlinked LED was actuated by the LED Output Control register and the control is
changed so that it is linked and no touch is detected, then the LED will behave as if a release
was detected.
Bits 3 - 2 - LED2_CTL[1:0] - Determines the behavior of LED2 as shown in Table 6-52.
Bits 1 - 0 - LED1_CTL[1:0] - Determines the behavior of LED1 as shown in Table 6-52.
2015 Microchip Technology Inc. DS00001623B-page 53
CAP1126
APPLICATION NOTE: The PWM frequency is determined based on the selected LED behavior, the programmed
breathe period, and the programmed min and max duty cycles. For the Direct behavior
mode, the PWM frequency is calculated based on the programmed Rise and Fall times. If
these are set at 0, then the maximum PWM frequency will be used based on the
programmed duty cycle settings.
6.32 LED Pulse 1 Period Register
The LED Pulse Period 1 register determines the overall period of a pulse operation as determined by the LED_CTL
registers (see Table 6-52 - setting 01b). The LSB represents 32ms so that a setting of 18h (24d) would represent a
period of 768ms (24 x 32ms = 768ms). The total range is from 32ms to 4.064 seconds as shown in Table 6-54 with the
default being 1024ms.
APPLICATION NOTE: Due to constraints on the LED Drive PWM operation, any Breathe Period less than 160ms
(05h) may not be achievable. The device will breathe at the minimum period possible as
determined by the period and min / max duty cycle settings.
Bit 7 - ST_TRIG - Determines the start trigger for the LED Pulse behavior.
• ‘0’ (default) - The LED will Pulse when a touch is detected or the drive bit is set.
• ‘1’ - The LED will Pulse when a release is detected or the drive bit is cleared.
TABLE 6-52: LEDX_CTL BIT DECODE
LEDx_CTL
[1:0] Operation Description Start TRigger Stop Trigger
1 0
0 0 Direct The LED is driven to the programmed state
(active or inactive). See Figure 6-7
Touch Detected or
LED Output Control
bit set
Release
Detected or
LED Output
Control bit
cleared
0 1 Pulse 1
The LED will “Pulse” a programmed number
of times. During each “Pulse” the LED will
breathe up to the maximum brightness and
back down to the minimum brightness so that
the total “Pulse” period matches the programmed
value.
Touch or Release
Detected or LED
Output Control bit
set or cleared
(see Section 6.32)
n/a
1 0 Pulse 2
The LED will “Pulse” when the start trigger is
detected. When the stop trigger is detected, it
will “Pulse” a programmable number of times
then return to its minimum brightness.
Touch Detected or
LED Output Control
bit set
Release
Detected or
LED Output
Control bit
cleared
1 1 Breathe
The LED will breathe. It will be driven with a
duty cycle that ramps up from the programmed
minimum duty cycle (default 0%) to
the programmed maximum duty cycle duty
cycle (default 100%) and then back down.
Each ramp takes up 50% of the programmed
period. The total period of each “breath” is
determined by the LED Breathe Period controls
- see Section 6.34.
Touch Detected or
LED Output Control
bit set
Release
Detected or
LED Output
Control bit
cleared
TABLE 6-53: LED PULSE 1 PERIOD REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
84h R/W LED Pulse 1
Period
ST_
TRIG
P1_
PER6
P1_
PER5
P1_
PER4
P1_
PER3
P1_
PER2
P1_
PER1
P1_
PER0 20h
CAP1126
DS00001623B-page 54 2015 Microchip Technology Inc.
The Pulse 1 operation is shown in Figure 6-1 when the LED output is configured for non-inverted polarity (LEDx_POL
= 1) and in Figure 6-2 for inverted polarity (LEDx_POL = 0).
.
FIGURE 6-1: Pulse 1 Behavior with Non-Inverted Polarity
FIGURE 6-2: Pulse 1 Behavior with Inverted Polarity
TABLE 6-54: LED PULSE / BREATHE PERIOD EXAMPLE
Setting (HEX) Setting (Decimal) Total Breathe / Pulse Period (MS)
00h 0 32
01h 1 32
02h 2 64
03h 3 96
. . . . . . . . .
7Dh 125 4000
Normal – untouched
operation Normal – untouched
operation
Touch Detected or
Release Detected
(100% - Pulse 1 Max Duty Cycle) * Brightness
X pulses after touch or after release
Pulse 1 Period
(P1_PER)
(100% - Pulse 1 Min Duty Cycle) * Brightness
LED
Brightness
Normal – untouched
operation
Normal – untouched
operation
Touch Detected or
Release Detected
Pulse 1 Min Duty Cycle * Brightness
X pulses after touch or after release
Pulse Period
(P1_PER)
Pulse 1 Max Duty Cycle * Brightness
LED
Brightness
2015 Microchip Technology Inc. DS00001623B-page 55
CAP1126
6.33 LED Pulse 2 Period Register
The LED Pulse 2 Period register determines the overall period of a pulse operation as determined by the LED_CTL
registers (see Table 6-52 - setting 10b). The LSB represents 32ms so that a setting of 18h (24d) would represent a
period of 768ms. The total range is from 32ms to 4.064 seconds (see Table 6-54) with a default of 640ms.
APPLICATION NOTE: Due to constraints on the LED Drive PWM operation, any Breathe Period less than 160ms
(05h) may not be achievable. The device will breathe at the minimum period possible as
determined by the period and min / max duty cycle settings.
The Pulse 2 Behavior is shown in Figure 6-3 for non-inverted polarity (LEDx_POL = 1) and in Figure 6-4 for inverted
polarity (LEDx_POL = 0).
7Eh 126 4032
7Fh 127 4064
TABLE 6-55: LED PULSE 2 PERIOD REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
85h R/W LED Pulse 2
Period - P2_
PER6
P2_
PER5
P2_
PER4
P2_
PER3
P2_
PER2
P2_
PER1
P2_
PER0 14h
FIGURE 6-3: Pulse 2 Behavior with Non-Inverted Polarity
TABLE 6-54: LED PULSE / BREATHE PERIOD EXAMPLE (CONTINUED)
Setting (HEX) Setting (Decimal) Total Breathe / Pulse Period (MS)
. . .
Normal – untouched
operation
Normal – untouched
operation
Touch Detected
(100% - Pulse 2 Min Duty Cycle) *
Brightness
(100% - Pulse 2 Max Duty Cycle) * Brightness
X additional pulses after release
Release Detected
Pulse
Period
(P2_PER)
LED
Brightness
CAP1126
DS00001623B-page 56 2015 Microchip Technology Inc.
6.34 LED Breathe Period Register
The LED Breathe Period register determines the overall period of a breathe operation as determined by the LED_CTL
registers (see Table 6-52 - setting 11b). The LSB represents 32ms so that a setting of 18h (24d) would represent a
period of 768ms. The total range is from 32ms to 4.064 seconds (see Table 6-54) with a default of 2976ms.
APPLICATION NOTE: Due to constraints on the LED Drive PWM operation, any Breathe Period less than 160ms
(05h) may not be achievable. The device will breathe at the minimum period possible as
determined by the period and min / max duty cycle settings.
6.35 LED Configuration Register
The LED Configuration register controls general LED behavior as well as the number of pulses that are sent for the
PULSE LED output behavior.
Bit 6 - RAMP_ALERT - Determines whether the device will assert the ALERT# pin when LEDs actuated by the LED
Output Control register bits have finished their respective behaviors. Interrupts will only be generated if the LED activity
is generated by writing the LED Output Control registers. Any LED activity associated with touch detection will not cause
an interrupt to be generated when the LED behavior has been finished.
• ‘0’ (default) - The ALERT# pin will not be asserted when LEDs actuated by the LED Output Control register have
finished their programmed behaviors.
• ‘1’ - The ALERT# pin will be asserted whenever any LED that is actuated by the LED Output Control register has
finished its programmed behavior.
Bits 5 - 3 - PULSE2_CNT[2:0] - Determines the number of pulses used for the Pulse 2 behavior as shown in Table 6-58.
Bits 2 - 0 - PULSE1_CNT[2:0] - Determines the number of pulses used for the Pulse 1 behavior as shown in Table 6-58.
FIGURE 6-4: Pulse 2 Behavior with Inverted Polarity
TABLE 6-56: LED BREATHE PERIOD REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
86h R/W LED Breathe
Period - BR_
PER6
BR_
PER5
BR_
PER4
BR_
PER3
BR_
PER2
BR_
PER1
BR_
PER0 5Dh
TABLE 6-57: LED CONFIGURATION REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
88h R/W LED Config - RAMP_
ALERT PULSE2_CNT[2:0] PULSE1_CNT[2:0] 04h
Normal – untouched
operation
Normal – untouched
operation
Touch Detected
Pulse 2 Max Duty Cycle * Brightness
Pulse 2 Min Duty Cycle * Brightness
X additional pulses after release
Release Detected
Pulse
Period
(P2_PER)
LED
Brightness . . .
2015 Microchip Technology Inc. DS00001623B-page 57
CAP1126
6.36 LED Duty Cycle Registers
The LED Duty Cycle registers determine the minimum and maximum duty cycle settings used for the LED for each LED
behavior. These settings affect the brightness of the LED when it is fully off and fully on.
The LED driver duty cycle will ramp up from the minimum duty cycle to the maximum duty cycle and back down again.
APPLICATION NOTE: When operating in Direct behavior mode, changes to the Duty Cycle settings will be applied
immediately. When operating in Breathe, Pulse 1, or Pulse 2 modes, the LED must be
unactuated and then re-actuated before changes to behavior are processed.
Bits 7 - 4 - X_MAX_DUTY[3:0] - Determines the maximum PWM duty cycle for the LED drivers as shown in Table 6-60.
Bits 3 - 0 - X_MIN_DUTY[3:0] - Determines the minimum PWM duty cycle for the LED drivers as shown in Table 6-60.
TABLE 6-58: PULSEX_CNT DECODE
PULSEX_CNT[2:0]
Number of Breaths
21 0
0 0 0 1 (default - Pulse 2)
00 1 2
01 0 3
01 1 4
1 0 0 5 (default - Pulse 1)
10 1 6
11 0 7
11 1 8
TABLE 6-59: LED DUTY CYCLE REGISTERS
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
90h R/W LED Pulse 1 Duty
Cycle P1_MAX_DUTY[3:0] P1_MIN_DUTY[3:0] F0h
91h R/W LED Pulse 2 Duty
Cycle P2_MAX_DUTY[3:0] P2_MIN_DUTY[3:0] F0h
92h R/W LED Breathe
Duty Cycle BR_MAX_DUTY[3:0] BR_MIN_DUTY[3:0] F0h
93h R/W Direct Duty Cycle DR_MAX_DUTY[3:0] DR_MIN_DUTY[3:0] F0h
TABLE 6-60: LED DUTY CYCLE DECODE
x_MAX/MIN_Duty [3:0]
Maximum Duty Cycle Minimum Duty Cycle
3 21 0
0 0 0 0 7% 0%
0 0 0 1 9% 7%
0 0 1 0 11% 9%
0 0 1 1 14% 11%
0 1 0 0 17% 14%
0 1 0 1 20% 17%
0 1 1 0 23% 20%
0 1 1 1 26% 23%
1 0 0 0 30% 26%
1 0 0 1 35% 30%
1 0 1 0 40% 35%
CAP1126
DS00001623B-page 58 2015 Microchip Technology Inc.
6.37 LED Direct Ramp Rates Register
The LED Direct Ramp Rates register control the rising and falling edge time of an LED that is configured to operate in
Direct behavior mode. The rising edge time corresponds to the amount of time the LED takes to transition from its minimum
duty cycle to its maximum duty cycle. Conversely, the falling edge time corresponds to the amount of time that
the LED takes to transition from its maximum duty cycle to its minimum duty cycle.
Bits 5 - 3 - RISE_RATE[2:0] - Determines the rising edge time of an LED when it transitions from its minimum drive state
to its maximum drive state as shown in Table 6-62.
Bits 2 - 0 - FALL_RATE[2:0] - Determines the falling edge time of an LED when it transitions from its maximum drive
state to its minimum drive state as shown in Table 6-62.
6.38 LED Off Delay Register
The LED Off Delay register determines the amount of time that an LED remains at its maximum duty cycle (or minimum
as determined by the polarity controls) before it starts to ramp down. If the LED is operating in Breathe mode, this delay
is applied at the top of each “breath”. If the LED is operating in the Direct mode, this delay is applied when the LED is
unactuated.
1 0 1 1 46% 40%
1 1 0 0 53% 46%
1 1 0 1 63% 53%
1 1 1 0 77% 63%
1 1 1 1 100% 77%
TABLE 6-61: LED DIRECT RAMP RATES REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
94h R/W LED Direct Ramp
Rates - - RISE_RATE[2:0] FALL_RATE[2:0] 00h
TABLE 6-62: RISE / FALL RATE DECODE
RISE_RATE/ FALL_RATE/ Bit Decode
Rise / Fall Time (TRISE / TFALL)
21 0
00 0 0
0 0 1 250ms
0 1 0 500ms
0 1 1 750ms
1 0 0 1s
1 0 1 1.25s
1 1 0 1.5s
1 1 1 2s
TABLE 6-63: LED OFF DELAY REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
95h R/W LED Off Delay
Register - BR_OFF_DLY[2:0] DIR_OFF_DLY[3:0] 00h
TABLE 6-60: LED DUTY CYCLE DECODE (CONTINUED)
x_MAX/MIN_Duty [3:0]
Maximum Duty Cycle Minimum Duty Cycle
3 21 0
2015 Microchip Technology Inc. DS00001623B-page 59
CAP1126
Bits 6 - 4 - BR_OFF_DLY[2:0] - Determines the Breathe behavior mode off delay, which is the amount of time an LED
in Breathe behavior mode remains inactive after it finishes a breathe pulse (ramp on and ramp off), as shown in Figure 6-
5 (non-inverted polarity LEDx_POL = 1) and Figure 6-6 (inverted polarity LEDx_POL = 0). Available settings are shown
in Table 6-64.
FIGURE 6-5: Breathe Behavior with Non-Inverted Polarity
FIGURE 6-6: Breathe Behavior with Inverted Polarity
LED Actuated
100% - Breathe Max Min Cycle * Brightness
100% - Breathe Min Duty Cycle *
Brightness
LED Unactuated
Breathe Off
Delay
(BR_OFF_DLY)
LED
Brightness
Breathe
Period
(BR_PER)
LED Actuated
Breathe Max Duty Cycle * Brightness
Breathe Min Duty Cycle * Brightness
LED Unactuated
Breathe Off
Delay
(BR_OFF_DLY)
LED
Brightness
Breathe
Period
(BR_PER)
CAP1126
DS00001623B-page 60 2015 Microchip Technology Inc.
Bits 3 - 0 - DIR_OFF_DLY[3:0] - Determines the turn-off delay, as shown in Table 6-65, for all LEDs that are configured
to operate in Direct behavior mode.
The Direct behavior operation is determined by the combination of programmed Rise Time, Fall Time, Min and Max Duty
cycles, Off Delay, and polarity. Figure 6-7 shows the behavior for non-inverted polarity (LEDx_POL = 1) while Figure 6-
8 shows the behavior for inverted polarity (LEDx_POL = 0).
TABLE 6-64: BREATHE OFF DELAY SETTINGS
BR_OFF_DLY [2:0]
OFF Delay
2 10
0 0 0 0 (default)
0 0 1 0.25s
0 1 0 0.5s
0 1 1 0.75s
1 0 0 1.0s
1 0 1 1.25s
1 1 0 1.5s
1 1 1 2.0s
FIGURE 6-7: Direct Behavior for Non-Inverted Polarity
FIGURE 6-8: Direct Behavior for Inverted Polarity
Normal –
untouched
operation
RISE_RATE
Setting (tRISE)
(100% - Max Duty
Cycle) * Brightness
Touch
Detected
Release
Detected
Off Delay
(tOFF_DLY)
FALL_RATE
Setting (tFALL)
Normal –
untouched
operation
(100% - Min Duty Cycle) *
Brightness LED
Brightness
Normal –
untouched
operation RISE_RATE
Setting (tRISE)
Min Duty Cycle * Brightness
Touch
Detected
Release
Detected
Off Delay
(tOFF_DLY)
FALL_RATE
Setting (tFALL)
Normal –
untouched
operation
Max Duty Cycle * Brightness
LED
Brightness
2015 Microchip Technology Inc. DS00001623B-page 61
CAP1126
6.39 Sensor Input Calibration Registers
The Sensor Input Calibration registers hold the 10-bit value that represents the last calibration value.
TABLE 6-65: OFF DELAY DECODE
OFF Delay[3:0] Bit Decode
OFF Delay (tOFF_DLY)
32 1 0
00 0 0 0
0 0 0 1 250ms
0 0 1 0 500ms
0 0 1 1 750ms
0 1 0 0 1s
0 1 0 1 1.25s
0 1 1 0 1.5s
0 1 1 1 2s
1 0 0 0 2.5s
1 0 0 1 3.0s
1 0 1 0 3.5s
1 0 1 1 4.0s
1 1 0 0 4.5s
All others 5.0s
TABLE 6-66: SENSOR INPUT CALIBRATION REGISTERS
ADDR Register R/W B7 B6 B5 B4 B3 B2 B1 B0 Default
B1h Sensor Input 1
Calibration R CAL1_9 CAL1_8 CAL1_7 CAL1_6 CAL1_5 CAL1_4 CAL1_3 CAL1_2 00h
B2h Sensor Input 2
Calibration R CAL2_9 CAL2_8 CAL2_7 CAL2_6 CAL2_5 CAL2_4 CAL2_3 CAL2_2 00h
B3h Sensor Input 3
Calibration R CAL3_9 CAL3_8 CAL3_7 CAL3_6 CAL3_5 CAL3_4 CAL3_3 CAL3_2 00h
B4h Sensor Input 4
Calibration R CAL4_9 CAL4_8 CAL4_7 CAL4_6 CAL4_5 CAL4_4 CAL4_3 CAL4_2 00h
B5h Sensor Input 5
Calibration R CAL5_9 CAL5_8 CAL5_7 CAL5_6 CAL5_5 CAL5_4 CAL5_3 CAL5_2 00h
B6h Sensor Input 6
Calibration R CAL6_9 CAL6_8 CAL6_7 CAL6_6 CAL6_5 CAL6_4 CAL6_3 CAL6_2 00h
B9h
Sensor Input
Calibration LSB
1
R CAL4_1 CAL4_0 CAL3_1 CAL3_0 CAL2_1 CAL2_0 CAL1_1 CAL1_0 00h
BAh
Sensor Input
Calibration LSB
2
R - - - - CAL6_1 CAL6_0 CAL5_1 CAL5_0 00h
CAP1126
DS00001623B-page 62 2015 Microchip Technology Inc.
6.40 Product ID Register
The Product ID register stores a unique 8-bit value that identifies the device.
6.41 Manufacturer ID Register
The Vendor ID register stores an 8-bit value that represents Microchip.
6.42 Revision Register
The Revision register stores an 8-bit value that represents the part revision.
TABLE 6-67: PRODUCT ID REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
FDh R Product ID 0 1 0 1 0 0 1 1 53h
TABLE 6-68: VENDOR ID REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
FEh R Manufacturer ID 0 1 0 1 1 1 0 1 5Dh
TABLE 6-69: REVISION REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
FFh R Revision 1 0 0 0 0 0 1 1 83h
2015 Microchip Technology Inc. DS00001623B-page 63
CAP1126
7.0 PACKAGE INFORMATION
7.1 CAP1126 Package Drawings
Note: For the most current package drawings, see the Microchip Packaging Specification at:
http://www.microchip.com/packaging.
FIGURE 7-1: 16-Pin QFN 4mm x 4mm Package Drawing
CAP1126
DS00001623B-page 64 2015 Microchip Technology Inc.
FIGURE 7-2: 16-Pin QFN 4mm x 4mm Package Dimensions
FIGURE 7-3: 16-Pin QFN 4mm x 4mm PCB Footprint
2015 Microchip Technology Inc. DS00001623B-page 65
CAP1126
7.2 Package Marking
FIGURE 7-4: CAP1126 Package Markings
C 1 26 - 1
Y WWN N N A
RCC
e3
TOP
BOTTOM
Bottom marking not allowed
PB-FREE/GREEN SYMBOL
(Matte Sn)
Lines 1-3:
Line 4:
Center Horizontal Alignment
Left Horizontal Alignment
PIN 1
0.41
3x 0.56
Line 1 – SMSC Logo without circled R symbol
Line 2 – Device ID, Version
Line 3 – Year, Week, Alphanumeric Traceability Code
Line 4 – Revision, Country Code
1
CAP1126
DS00001623B-page 66 2015 Microchip Technology Inc.
APPENDIX A: DEVICE DELTA
A.1 Delta from CAP1026 to CAP1126
1. Updated circuitry to improve power supply rejection.
2. Updated LED driver duty cycle decode values to have more distribution at lower values - closer to a logarithmic
curve. See Table 6-60, "LED Duty Cycle Decode".
3. Updated bug that breathe periods were not correct above 2.6s. This includes rise / fall time decodes above 1.5s.
4. Added filtering on RESET pin to prevent errant resets.
5. Updated controls so that the RESET pin assertion places the device into the lowest power state available and
causes an interrupt when released. See Section 5.2, "RESET Pin".
6. Added 1 bit to the LED Off Delay register (see Section 6.38, "LED Off Delay Register") to extend times from 2s
to 5s in 0.5s intervals.
7. Breathe behavior modified. A breathe off delay control was added to the LED Off Delay Register (see Section
6.38, "LED Off Delay Register") so the LEDs can be configured to remain inactive between breathes.
8. Added controls for the LED transition effects when linking LEDs to capacitive sensor inputs. See Section 6.29,
"Linked LED Transition Control Register".
9. Added controls to “mirror” the LED duty cycle outputs so that when polarity changes, the LED brightness levels
look right. These bits are automatically set when polarity is set. Added control to break this auto-set behavior.
See Section 6.30, "LED Mirror Control Register".
10. Added Multiple Touch Pattern detection circuitry. See Section 6.15, "Multiple Touch Pattern Configuration Register".
11. Added General Status register to flag Multiple touches, Multiple Touch Pattern issues and general touch detections.
See Section 6.2, "Status Registers".
12. Added bits 6 and 5 to the Recalibration Configuration register (2Fh - see Section 6.17, "Recalibration Configuration
Register"). These bits control whether the accumulation of intermediate data and the consecutive negative
delta counts counter are cleared when the noise status bit is set.
13. Added Configuration 2 register for LED linking controls, noise detection controls, and control to interrupt on press
but not on release. Added control to change alert pin polarity. See Section 6.6, "Configuration Registers".
14. Updated Deep Sleep behavior so that device does not clear DSLEEP bit on received communications but will
wake to communicate.
15. Changed PWM frequency for LED drivers. The PWM frequency was derived from the programmed breathe
period and duty cycle settings and it ranged from ~4Hz to ~8000 Hz. The PWM frequency has been updated to
be a fixed value of ~2000Hz.
16. Register delta:
Table A.1 Register Delta From CAP1026 to CAP1126
Address Register Delta Delta Default
00h
Page 31
Changed - Main Status /
Control
added bits 7-6 to control gain 00h
02h
Page 32
New - General Status new register to store MTP, MULT, LED,
RESET, and general TOUCH bits
00h
44h
Page 35
New - Configuration 2 new register to control alert polarity, LED
touch linking behavior, LED output behavior,
and noise detection, and interrupt on
release
40h
24h
Page 38
Changed - Averaging
Control
updated register bits - moved
SAMP_AVG[2:0] bits and added SAMP_-
TIME bit 1. Default changed
39h
2Bh
Page 41
New - Multiple Touch
Pattern Configuration
new register for Multiple Touch Pattern
configuration - enable and threshold settings
80h
2015 Microchip Technology Inc. DS00001623B-page 67
CAP1126
2Dh
Page 42
New - Multiple Touch
Pattern Register
new register for Multiple Touch Pattern
detection circuitry - pattern or number of
sensor inputs
3Fh
2Fh
Page 43
Changed - Recalibration
Configuration
updated register - updated CAL_CFG bit
decode to add a 128 averages setting and
removed highest time setting. Default
changed. Added bit 6 NO_CLR_INTD and
bit 5 NO_CLR_NEG.
8Ah
38h
Page 44
Changed - Sensor Input
Noise Threshold
updated register bits - removed bits 7 - 3
and consolidated all controls into bits 1 - 0.
These bits will set the noise threshold for
all channels. Default changed
01h
39h Removed - Noise
Threshold Register 2
removed register n/a
41h
Page 45
Changed - Standby Configuration
updated register bits - moved
STBY_AVG[2:0] bits and added STBY_-
TIME bit 1. Default changed
39h
77h
Page 51
New - Linked LED Transition
Control
new register to control transition effect
when LED linked to sensor inputs
00h
79h
Page 51
New - LED Mirror Control new register to control LED output mirroring
for brightness control when polarity
changed
00h
90h
Page 57
Changed - LED Pulse 1
Duty Cycle
changed bit decode to be more logarithmic F0h
91h
Page 57
Changed - LED Pulse 2
Duty Cycle
changed bit decode to be more logarithmic F0h
92h
Page 57
Changed - LED Breathe
Duty Cycle
changed bit decode to be more logarithmic F0h
93h
Page 57
Changed - LED Direct
Duty Cycle
changed bit decode to be more logarithmic F0h
95h Added controls - LED Off
Delay
Added bits 6-4 BR_OFF_DLY[2:0]
Added bit 3 DIR_OFF_DLY[3]
00h
FDh
Page 62
Changed - Product ID Changed bit decode for CAP1126 53h
Table A.1 Register Delta From CAP1026 to CAP1126 (continued)
Address Register Delta Delta Default
CAP1126
DS00001623B-page 68 2015 Microchip Technology Inc.
APPENDIX B: DATA SHEET REVISION HISTORY
Revision Section/Figure/Entry Correction
DS00001623B (02-09-15)
Features, Table 2-1, Table 2-
2, "Pin Types", Section 5.0,
"General Description"
References to BC-Link Interface, BC_DATA, BC_-
CLK, BC-IRQ#, BC-Link bus have been removed
Application Note under Table
2-6
[BC-Link] hidden in data sheet
Table 3-2, "Electrical Specifications"
BC-Link Timing Section hidden in data sheet
Table 4-1 Protocol Used for 68K Pull Down Resistor changed
from “BC-Link Communications” to “Reserved”
Section 4.2.2, "SMBus
Address and RD / WR Bit"
Replaced “client address” with “slave address” in this
section.
Section 4.2.4, SMBus ACK
and NACK Bits, Section 4.2.5,
SMBus Stop Bit,Section 4.2.7,
SMBus and I2C Compatibility
Replaced “client” with “slave” in these sections.
Table 4-4, "Read Byte Protocol"
Heading changed from “Client Address” to “Slave
Address”
Table 6-1 Register Name for Register Address 77h changed
from “LED Linked Transition Control” to “Linked LED
Transition Control”
Section 6.30 changed CS2 to LED2
Section 7.7 Package Marking Updated package drawing
Appendix A: Device Delta changed 2Dh to 2Fh in item #12
Product Identification System Removed BC-Link references
REV A REV A replaces previous SMSC version Rev. 1.32 (01-05-12)
Rev. 1.32 (01-05-12) Table 3-2, "Electrical Specifications"
Added conditions for tHD:DAT.
Section 4.2.7, "SMBus and
I2C Compatibility"
Renamed from “SMBus and I2C Compliance.”
First paragraph, added last sentence: “For information
on using the CAP1188 in an I2C system, refer to
SMSC AN 14.0 SMSC Dedicated Slave Devices in
I
2C Systems.”
Added: CAP1188 supports I2C fast mode at 400kHz.
This covers the SMBus max time of 100kHz.
Section 6.4, "Sensor Input
Delta Count Registers"
Changed negative value cap from FFh to 80h.
Rev. 1.31 (08-18-11) Section 4.3.3, "SMBus Send
Byte"
Added an application note: The Send Byte protocol
is not functional in Deep Sleep (i.e., DSLEEP bit is
set).
Section 4.3.4, "SMBus
Receive Byte"
Added an application note: The Receive Byte protocol
is not functional in Deep Sleep (i.e., DSLEEP bit
is set).
Rev. 1.3 (05-18-11) Section 6.42, "Revision Register"
Updated revision ID from 82h to 83h.
Rev. 1.2 (02-10-11) Section A.8, "Delta from Rev
B (Mask B0) to Rev C (Mask
B1)"
Added.
Cover Corrected block diagram. ALERT#/BC_IRQ# is an
output, not an input.
2015 Microchip Technology Inc. DS00001623B-page 69
CAP1126
Table 2-1, "Pin Description for
CAP1126"
Changed value in “Unused Connection” column for
the ADDR_COMM pin from “Connect to Ground” to
“n/a“.
Table 3-2, "Electrical Specifications"
PSR improvements made in functional revision B.
Changed PSR spec from ±100 typ and ±200 max
counts / V to ±3 and ±10 counts / V. Conditions
updated.
Section 5.5.2, "Recalibrating
Sensor Inputs"
Added more detail with subheadings for each type of
recalibration.
Section 6.6, "Configuration
Registers"
Added bit 5 BLK_PWR_CTRL to the Configuration 2
Register 44h.
The TIMEOUT bit is set to ‘1’ by default for functional
revision B and is set to ‘0’ by default for functional
revision C.
Section 6.42, "Revision Register"
Updated revision ID in register FFh from 81h to 82h.
Rev. 1.1 (11-17-10) Document Updated for functional revision B. See Section A.7,
"Delta from Rev A (Mask A0) to Rev B (Mask B0)".
Cover Added to General Description: “includes circuitry and
support for enhanced sensor proximity detection.”
Added the following Features:
Calibrates for Parasitic Capacitance
Analog Filtering for System Noise Sources
Press and Hold feature for Volume-like Applications
Table 3-2, "Electrical Specifications"
Conditions for Power Supply Rejection modified adding
the following:
Sampling time = 2.56ms
Averaging = 1
Negative Delta Counts = Disabled
All other parameters default
Section 6.11, "Calibration Activate
Register"
Updated register description to indicate which re-calibration
routine is used.
Section 6.14, "Multiple Touch
Configuration Register"
Updated register description to indicate what will
happen.
Table 6-34, "CSx_BN_TH Bit
Decode"
Table heading changed from “Threshold Divide Setting”
to “Percent Threshold Setting”.
Rev. 1.0 (06-14-10) Initial release
Revision Section/Figure/Entry Correction
CAP1126
DS00001623B-page 70 2015 Microchip Technology Inc.
THE MICROCHIP WEB SITE
Microchip provides online support via our WWW site at www.microchip.com. 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 (FAQ), 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
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. Under “Support”, click on “Customer Change Notification”
and follow the registration instructions.
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://www.microchip.com/support
2015 Microchip Technology Inc. DS00001623B-page 71
CAP1126
PRODUCT IDENTIFICATION SYSTEM
To order or obtain information, e.g., on pricing or delivery, refer to the factory or the listed sales office.
PART NO. [X] - 1 - XXX - [X](1)
l l l l
Device Temperature Package Tape and Reel
Range Option
Example:
Note 1: Tape and Reel identifier only appears in the catalog part number description. This identifier is used for ordering
purposes and is not printed on the device package. Check with your Microchip Sales Office for package availability
with the Tape and Reel option.
Device: CAP1126
Temperature
Range:
Blank = 0°C to +85°C (Extended Commercial)
Package: AP = QFN
Tape and
Reel Option:
TR = Tape and Reel(1)
CAP1126-1-AP-TR
16-pin QFN 4mm x 4mm (RoHS compliant)
Six capacitive touch sensor inputs, Two
LED drivers, Dedicated Wake, Reset,
SMBus / BC-Link / SPI interfaces
Reel size is 4,000 pieces
CAP1126
DS00001623B-page 72 2015 Microchip Technology Inc.
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, FlashFlex, flexPWR, JukeBlox, KEELOQ, KEELOQ logo, Kleer, LANCheck,
MediaLB, MOST, MOST logo, MPLAB, OptoLyzer, PIC, PICSTART, PIC32 logo, RightTouch, SpyNIC, SST, SST Logo, SuperFlash and
UNI/O are registered trademarks of Microchip Technology Incorporated in the U.S.A. and other countries.
The Embedded Control Solutions Company and mTouch are registered trademarks of Microchip Technology Incorporated in the U.S.A.
Analog-for-the-Digital Age, BodyCom, chipKIT, chipKIT logo, CodeGuard, dsPICDEM, dsPICDEM.net, ECAN, In-Circuit Serial
Programming, ICSP, Inter-Chip Connectivity, KleerNet, KleerNet logo, MiWi, MPASM, MPF, MPLAB Certified logo, MPLIB, MPLINK,
MultiTRAK, NetDetach, Omniscient Code Generation, PICDEM, PICDEM.net, PICkit, PICtail, RightTouch logo, REAL ICE, SQI, Serial
Quad I/O, Total Endurance, TSHARC, USBCheck, VariSense, ViewSpan, WiperLock, Wireless DNA, 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.
Silicon Storage Technology is a registered trademark of Microchip Technology Inc. in other countries.
GestIC is a registered trademarks of Microchip Technology Germany II GmbH & Co. KG, a subsidiary of Microchip Technology Inc., in
other countries.
All other trademarks mentioned herein are property of their respective companies.
© 2015, Microchip Technology Incorporated, Printed in the U.S.A., All Rights Reserved.
ISBN: 9781632770332
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.
QUALITY MANAGEMENT SYSTEM
CERTIFIED BY DNV
== ISO/TS 16949 ==
2015 Microchip Technology Inc. DS00001623B-page 73
AMERICAS
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
Atlanta
Duluth, GA
Tel: 678-957-9614
Fax: 678-957-1455
Austin, TX
Tel: 512-257-3370
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
Novi, MI
Tel: 248-848-4000
Houston, TX
Tel: 281-894-5983
Indianapolis
Noblesville, IN
Tel: 317-773-8323
Fax: 317-773-5453
Los Angeles
Mission Viejo, CA
Tel: 949-462-9523
Fax: 949-462-9608
New York, NY
Tel: 631-435-6000
San Jose, CA
Tel: 408-735-9110
Canada - Toronto
Tel: 905-673-0699
Fax: 905-673-6509
ASIA/PACIFIC
Asia Pacific Office
Suites 3707-14, 37th Floor
Tower 6, The Gateway
Harbour City, Kowloon
Hong Kong
Tel: 852-2943-5100
Fax: 852-2401-3431
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
China - Dongguan
Tel: 86-769-8702-9880
China - Hangzhou
Tel: 86-571-8792-8115
Fax: 86-571-8792-8116
China - Hong Kong SAR
Tel: 852-2943-5100
Fax: 852-2401-3431
China - Nanjing
Tel: 86-25-8473-2460
Fax: 86-25-8473-2470
China - Qingdao
Tel: 86-532-8502-7355
Fax: 86-532-8502-7205
China - Shanghai
Tel: 86-21-5407-5533
Fax: 86-21-5407-5066
China - Shenyang
Tel: 86-24-2334-2829
Fax: 86-24-2334-2393
China - Shenzhen
Tel: 86-755-8864-2200
Fax: 86-755-8203-1760
China - Wuhan
Tel: 86-27-5980-5300
Fax: 86-27-5980-5118
China - Xian
Tel: 86-29-8833-7252
Fax: 86-29-8833-7256
ASIA/PACIFIC
China - Xiamen
Tel: 86-592-2388138
Fax: 86-592-2388130
China - Zhuhai
Tel: 86-756-3210040
Fax: 86-756-3210049
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
India - Pune
Tel: 91-20-3019-1500
Japan - Osaka
Tel: 81-6-6152-7160
Fax: 81-6-6152-9310
Japan - Tokyo
Tel: 81-3-6880- 3770
Fax: 81-3-6880-3771
Korea - Daegu
Tel: 82-53-744-4301
Fax: 82-53-744-4302
Korea - Seoul
Tel: 82-2-554-7200
Fax: 82-2-558-5932 or
82-2-558-5934
Malaysia - Kuala Lumpur
Tel: 60-3-6201-9857
Fax: 60-3-6201-9859
Malaysia - Penang
Tel: 60-4-227-8870
Fax: 60-4-227-4068
Philippines - Manila
Tel: 63-2-634-9065
Fax: 63-2-634-9069
Singapore
Tel: 65-6334-8870
Fax: 65-6334-8850
Taiwan - Hsin Chu
Tel: 886-3-5778-366
Fax: 886-3-5770-955
Taiwan - Kaohsiung
Tel: 886-7-213-7828
Taiwan - Taipei
Tel: 886-2-2508-8600
Fax: 886-2-2508-0102
Thailand - Bangkok
Tel: 66-2-694-1351
Fax: 66-2-694-1350
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
Fax: 33-1-69-30-90-79
Germany - Dusseldorf
Tel: 49-2129-3766400
Germany - Munich
Tel: 49-89-627-144-0
Fax: 49-89-627-144-44
Germany - Pforzheim
Tel: 49-7231-424750
Italy - Milan
Tel: 39-0331-742611
Fax: 39-0331-466781
Italy - Venice
Tel: 39-049-7625286
Netherlands - Drunen
Tel: 31-416-690399
Fax: 31-416-690340
Poland - Warsaw
Tel: 48-22-3325737
Spain - Madrid
Tel: 34-91-708-08-90
Fax: 34-91-708-08-91
Sweden - Stockholm
Tel: 46-8-5090-4654
UK - Wokingham
Tel: 44-118-921-5800
Fax: 44-118-921-5820
Worldwide Sales and Service
01/27/15
2015 Microchip Technology Inc. DS00001622B-page 1
General Description
The CAP1128, which incorporates RightTouch® technology,
is a multiple channel Capacitive Touch sensor
with multiple power LED drivers. It contains eight (8)
individual capacitive touch sensor inputs with programmable
sensitivity for use in touch sensor applications.
Each sensor input automatically recalibrates to compensate
for gradual environmental changes.
The CAP1128 also contains two (2) LED drivers that
offer full-on / off, variable rate blinking, dimness controls,
and breathing. Each of the LED drivers may be
linked to one of the sensor inputs to be actuated when
a touch is detected. As well, each LED driver may be
individually controlled via a host controller.
The CAP1128 includes Multiple Pattern Touch recognition
that allows the user to select a specific set of buttons
to be touched simultaneously. If this pattern is
detected, then a status bit is set and an interrupt generated.
Additionally, the CAP1128 includes circuitry and support
for enhanced sensor proximity detection.
The CAP1128 offers multiple power states operating at
low quiescent currents. In the Standby state of operation,
one or more capacitive touch sensor inputs are
active and all LEDs may be used. If a touch is detected,
it will wake the system using the WAKE/SPI_MOSI pin.
Deep Sleep is the lowest power state available, drawing
5uA (typical) of current. In this state, no sensor
inputs are active. Driving the WAKE/SPI_MOSI pin or
communications will wake the device.
Applications
• Desktop and Notebook PCs
• LCD Monitors
• Consumer Electronics
• Appliances
Features
• Eight (8) Capacitive Touch Sensor Inputs
- Programmable sensitivity
- Automatic recalibration
- Individual thresholds for each button
• Proximity Detection
• Multiple Button Pattern Detection
• Calibrates for Parasitic Capacitance
• Analog Filtering for System Noise Sources
• Press and Hold feature for Volume-like Applications
• Multiple Communication Interfaces
- SMBus / I2C compliant interface
- SPI communications
- Pin selectable communications protocol and
multiple slave addresses (SMBus / I2C only)
• Low Power Operation
- 5uA quiescent current in Deep Sleep
- 50uA quiescent current in Standby (1 sensor
input monitored)
- Samples one or more channels in Standby
• Two (2) LED Driver Outputs
- Open Drain or Push-Pull
- Programmable blink, breathe, and dimness
controls
- Can be linked to Capacitive Touch Sensor
inputs
• Dedicated Wake output flags touches in low
power state
• System RESET pin
• Available in 20-pin 4mm x 4mm QFN RoHS compliant
package
CAP1128
8 Channel Capacitive Touch Sensor with 2 LED Drivers
CAP1128
DS00001622B-page 2 2015 Microchip Technology Inc.
TO OUR VALUED CUSTOMERS
It is our intention to provide our valued customers with the best documentation possible to ensure successful use of your Microchip
products. To this end, we will continue to improve our publications to better suit your needs. Our publications will be refined and
enhanced as new volumes and updates are introduced.
If you have any questions or comments regarding this publication, please contact the Marketing Communications Department via
E-mail at docerrors@microchip.com. We welcome your feedback.
Most Current Data Sheet
To obtain the most up-to-date version of this data sheet, please register at our Worldwide Web site at:
http://www.microchip.com
You can determine the version of a data sheet by examining its literature number found on the bottom outside corner of any page.
The last character of the literature number is the version number, (e.g., DS30000000A is version A of document DS30000000).
Errata
An errata sheet, describing minor operational differences from the data sheet and recommended workarounds, may exist for current
devices. As device/documentation issues become known to us, we will publish an errata sheet. The errata will specify the
revision of silicon and revision of document to which it applies.
To determine if an errata sheet exists for a particular device, please check with one of the following:
• Microchip’s Worldwide Web site; http://www.microchip.com
• Your local Microchip sales office (see last page)
When contacting a sales office, please specify which device, revision of silicon and data sheet (include -literature number) you are
using.
Customer Notification System
Register on our web site at www.microchip.com to receive the most current information on all of our products.
2015 Microchip Technology Inc. DS00001622B-page 3
CAP1128
Table of Contents
1.0 Block Diagram ................................................................................................................................................................................. 4
2.0 Pin Description ................................................................................................................................................................................ 5
3.0 Electrical Specifications .................................................................................................................................................................. 9
4.0 Communications ........................................................................................................................................................................... 12
5.0 General Description ...................................................................................................................................................................... 23
6.0 Register Description ...................................................................................................................................................................... 29
7.0 Package Information ..................................................................................................................................................................... 67
Appendix A: Device Delta ................................................................................................................................................................... 72
Appendix B: Data Sheet Revision History ........................................................................................................................................... 74
The Microchip Web Site ...................................................................................................................................................................... 76
Customer Change Notification Service ............................................................................................................................................... 76
Customer Support ............................................................................................................................................................................... 76
Product Identification System ............................................................................................................................................................. 77
CAP1128
DS00001622B-page 4 2015 Microchip Technology Inc.
1.0 BLOCK DIAGRAM
SMBus /
BC-Link /
SPI Slave
Protocol
SMCLK/ BC_CLK /
SPI_CLK
SMDATA / BC_DATA/ SPI_MSIO /
SPI_MISO
VDD GND
ALERT# / BC_IRQ#
Capacitive Touch Sensing Algorithm
LED1
CS1 CS2 CS3 CS4 CS5 CS6
LED Driver, Breathe,
and Dimness control
WAKE / SPI_MOSI
CS7 CS8
RESET
ADDR_COMM
SPI_CS#
LED2
2015 Microchip Technology Inc. DS00001622B-page 5
CAP1128
2.0 PIN DESCRIPTION
FIGURE 2-1: CAP1128 Pin Diagram (20-Pin QFN)
TABLE 2-1: PIN DESCRIPTION FOR CAP1128
Pin
Number Pin Name Pin Function Pin Type Unused
Connection
1 SPI_CS# Active low chip-select for SPI bus DI (5V) Connect to
Ground
2 WAKE / SPI_-
MOSI
WAKE - Active high wake / interrupt output
Standby power state - requires pull-down resistor DO
Pull-down
WAKE - Active high wake input - requires pull-down Resistor
resistor
Deep Sleep power state
DI
SPI_MOSI - SPI Master-Out-Slave-In port when used in
normal mode DI (5V) Connect to
Ground
1
2
3
4
15
14
13
12
20
19
18
17
6
7
8
9
GND
ALERT# / BC_IRQ#
WAKE / SPI_MOSI
SPI_CS#
SMCLK / BC_CLK / SPI_CLK
SMDAT / BC_DATA / SPI_MSIO /
SPI_MISO CS7 RESET
CS5
CS6
5
10
11
16
VDD
CS1
CS2
CS4
CS8
CS3
N/C*
LED1
LED2
ADDR_COMM
CAP1128
20 pin QFN
N/C*
*N/C pins must be connected to ground
CAP1128
DS00001622B-page 6 2015 Microchip Technology Inc.
3
SMDATA /
SPI_MSIO /
SPI_MISO
SMDATA - Bi-directional, open-drain SMBus data -
requires pull-up resistor DIOD (5V)
n/a
SPI_MSIO - SPI Master-Slave-In-Out bidirectional port
when used in bi-directional mode DIO
SPI_MISO - SPI Master-In-Slave-Out port when used in
normal mode DO
4 SMCLK / SPI_-
CLK
SMCLK - SMBus clock input - requires pull-up resistor DI (5V)
SPI_CLK - SPI clock input DI (5V) n/a
5 N/C Not Internally Connected n/a Connect to
Ground
6 LED1
Open drain LED 1 driver (default) OD (5V) Connect to
Ground
Push-pull LED 1 driver DO
leave open or
connect to
Ground
7 LED2
Open drain LED 2 driver (default) OD (5V) Connect to
Ground
Push-pull LED 2 driver DO
leave open or
connect to
Ground
8 N/C Not Internally Connected n/a Connect to
Ground
9 RESET Active high soft reset for system - resets all registers to
default values. If not used, connect to ground. DI (5V) Connect to
Ground
10 ALERT#
ALERT# - Active low alert / interrupt output for SMBus
alert or SPI interrupt OD (5V) Connect to
Ground
ALERT# - Active high push-pull alert / interrupt output
for SMBus alert or SPI interrupt DO leave open
11 ADDR_COMM Address / communications select pin - pull-down resistor
determines address / communications mechanism AI n/a
12 CS8 Capacitive Touch Sensor Input 8 AIO Connect to
Ground
13 CS7 Capacitive Touch Sensor Input 7 AIO Connect to
Ground
14 CS6 Capacitive Touch Sensor Input 6 AIO Connect to
Ground
15 CS5 Capacitive Touch Sensor Input 5 AIO Connect to
Ground
16 CS4 Capacitive Touch Sensor Input 4 AIO Connect to
Ground
TABLE 2-1: PIN DESCRIPTION FOR CAP1128 (CONTINUED)
Pin
Number Pin Name Pin Function Pin Type Unused
Connection
2015 Microchip Technology Inc. DS00001622B-page 7
CAP1128
APPLICATION NOTE: When the ALERT# pinis configured as an active low output, it will be open drain. When it is
configured as an active high output, it will be push-pull.
APPLICATION NOTE: For the 5V tolerant pins that have a pull-up resistor, the pull-up voltage must not exceed 3.6V
when the CAP1128 is unpowered.
APPLICATION NOTE: The SPI_CS# pin should be grounded when SMBus, or I2C,communications are used.
The pin types are described in Table 2-2. All pins labeled with (5V) are 5V tolerant.
17 CS3 Capacitive Touch Sensor Input 3 AIO Connect to
Ground
18 CS2 Capacitive Touch Sensor Input 2 AIO Connect to
Ground
19 CS1 Capacitive Touch Sensor Input 1 AIO Connect to
Ground
20 VDD Positive Power supply Power n/a
Bottom Pad GND Ground Power n/a
TABLE 2-2: PIN TYPES
Pin Type Description
Power This pin is used to supply power or ground to the device.
DI Digital Input - This pin is used as a digital input. This pin is 5V tolerant.
AIO Analog Input / Output -This pin is used as an I/O for analog signals.
DIOD Digital Input / Open Drain Output - This pin is used as a digital I/O. When it is used as an output,
it is open drain and requires a pull-up resistor. This pin is 5V tolerant.
OD Open Drain Digital Output - This pin is used as a digital output. It is open drain and requires a
pull-up resistor. This pin is 5V tolerant.
DO Push-pull Digital Output - This pin is used as a digital output and can sink and source current.
DIO Push-pull Digital Input / Output - This pin is used as an I/O for digital signals.
TABLE 2-1: PIN DESCRIPTION FOR CAP1128 (CONTINUED)
Pin
Number Pin Name Pin Function Pin Type Unused
Connection
CAP1128
DS00001622B-page 8 2015 Microchip Technology Inc.
3.0 ELECTRICAL SPECIFICATIONS
Note 3-1 Stresses above those listed could cause permanent damage to the device. This is a stress rating
only and functional operation of the device at any other condition above those indicated in the
operation sections of this specification is not implied.
Note 3-2 For the 5V tolerant pins that have a pull-up resistor, the voltage difference between V5VT_PIN and VDD
must never exceed 3.6V.
Note 3-3 The Package Power Dissipation specification assumes a recommended thermal via design consisting
of a 3x3 matrix of 0.3mm (12mil) vias at 1.0mm pitch connected to the ground plane with a 2.5 x
2.5mm thermal landing.
Note 3-4 Junction to Ambient (θJA) is dependent on the design of the thermal vias. Without thermal vias and
a thermal landing, the θJA is approximately 60°C/W including localized PCB temperature increase.
TABLE 3-1: ABSOLUTE MAXIMUM RATINGS
Voltage on 5V tolerant pins (V5VT_PIN) -0.3 to 5.5 V
Voltage on 5V tolerant pins (|V5VT_PIN - VDD|) Note 3-2 0 to 3.6 V
Voltage on VDD pin -0.3 to 4 V
Voltage on any other pin to GND -0.3 to VDD + 0.3 V
Package Power Dissipation up to TA = 85°C for 20 pin QFN
(see Note 3-3)
0.9 W
Junction to Ambient (θJA) (see Note 3-4) 58 °C/W
Operating Ambient Temperature Range -40 to 125 °C
Storage Temperature Range -55 to 150 °C
ESD Rating, All Pins, HBM 8000 V
2015 Microchip Technology Inc. DS00001622B-page 9
CAP1128
TABLE 3-2: ELECTRICAL SPECIFICATIONS
VDD = 3V to 3.6V, TA = 0°C to 85°C, all typical values at TA = 27°C unless otherwise noted.
Characteristic Symbol Min Typ Max Unit Conditions
DC Power
Supply Voltage VDD 3.0 3.3 3.6 V
Supply Current
ISTBY 120 170 uA
Standby state active
1 sensor input monitored
No LEDs active
Default conditions (8 avg, 70ms
cycle time)
ISTBY 50 uA
Standby state active
1 sensor input monitored
No LEDs active
1 avg, 140ms cycle time,
IDSLEEP 5 15 uA
Deep Sleep state active
LEDs at 100% or 0% Duty Cycle
No communications
TA < 40°C
3.135 < VDD < 3.465V
IDD 500 600 uA Capacitive Sensing Active
No LEDs active
Capacitive Touch Sensor Inputs
Maximum Base
Capacitance CBASE 50 pF Pad untouched
Minimum Detectable
Capacitive Shift ΔCTOUCH 20 fF
Pad touched - default conditions (1
avg, 35ms cycle time, 1x sensitivity)
Recommended Cap
Shift ΔCTOUCH 0.1 2 pF Pad touched - Not tested
Power Supply Rejection
PSR ±3 ±10 counts /
V
Untouched Current Counts
Base Capacitance 5pF - 50pF
Maximum sensitivity
Negative Delta Counts disabled
All other parameters default
Timing
RESET Pin Delay tRST_DLY 10 ms
Time to communications
ready tCOMM_DLY 15 ms
Time to first conversion
ready tCONV_DLY 170 200 ms
LED Drivers
Duty Cycle DUTYLED 0 100 % Programmable
Drive Frequency fLED 2 kHz
Sinking Current ISINK 24 mA VOL = 0.4
Sourcing Current ISOURCE 24 mA VOH = VDD - 0.4
Leakage Current ILEAK ±5 uA
powered or unpowered
TA < 85°C
pull-up voltage < 3.6V if unpowered
I/O Pins
Output Low Voltage VOL 0.4 V ISINK_IO = 8mA
Output High Voltage VOH VDD - 0.4 V ISOURCE_IO = 8mA
CAP1128
DS00001622B-page 10 2015 Microchip Technology Inc.
Note 3-5 The ALERT pin will not glitch high or low at power up if connected to VDD or another voltage.
Note 3-6 The SMCLK and SMDATA pins will not glitch low at power up if connected to VDD or another voltage.
Input High Voltage VIH 2.0 V
Input Low Voltage VIL 0.8 V
Leakage Current ILEAK ±5 uA
powered or unpowered
TA < 85°C
pull-up voltage < 3.6V if unpowered
RESET Pin Release
to conversion ready tRESET 170 200 ms
SMBus Timing
Input Capacitance CIN 5 pF
Clock Frequency fSMB 10 400 kHz
Spike Suppression tSP 50 ns
Bus Free Time Stop to
Start tBUF 1.3 us
Start Setup Time tSU:STA 0.6 us
Start Hold Time tHD:STA 0.6 us
Stop Setup Time tSU:STO 0.6 us
Data Hold Time tHD:DAT 0 us When transmitting to the master
Data Hold Time tHD:DAT 0.3 us When receiving from the master
Data Setup Time tSU:DAT 0.6 us
Clock Low Period tLOW 1.3 us
Clock High Period tHIGH 0.6 us
Clock / Data Fall Time tFALL 300 ns Min = 20+0.1CLOAD ns
Clock / Data Rise
Time tRISE 300 ns Min = 20+0.1CLOAD ns
Capacitive Load CLOAD 400 pF per bus line
SPI Timing
Clock Period tP 250 ns
Clock Low Period tLOW 0.4 x tP 0.6 x tP ns
Clock High Period tHIGH 0.4 x tP 0.6 x tP ns
Clock Rise / Fall time tRISE / tFALL 0.1 x tP ns
Data Output Delay tD:CLK 10 ns
Data Setup Time tSU:DAT 20 ns
Data Hold Time tHD:DAT 20 ns
SPI_CS# to SPI_CLK
setup time tSU:CS 0 ns
Wake Time tWAKE 10 20 us SPI_CS# asserted to CLK assert
TABLE 3-2: ELECTRICAL SPECIFICATIONS (CONTINUED)
VDD = 3V to 3.6V, TA = 0°C to 85°C, all typical values at TA = 27°C unless otherwise noted.
Characteristic Symbol Min Typ Max Unit Conditions
2015 Microchip Technology Inc. DS00001622B-page 11
CAP1128
4.0 COMMUNICATIONS
4.1 Communications
The CAP1128communicates using the 2-wire SMBus or I2C bus, the 2-wire proprietary BC-Link, or the SPI bus. If the
proprietary BC-Link protocol is required for your application, please contact your Microchip representative for ordering
instructions. Regardless of communication mechanism, the device functionality remains unchanged. The communications
mechanism as well as the SMBus (or I2C) slave address is determined by the resistor connected between the
ADDR_COMM pin and ground as shown in Table 4-1.
4.1.1 SMBUS (I2C) COMMUNICATIONS
When configured to communicate via the SMBus, the CAP1128 supports the following protocols: Send Byte, Receive
Byte, Read Byte, Write Byte, Read Block, and Write Block. In addition, the device supports I2C formatting for block read
and block write protocols.
APPLICATION NOTE: For SMBus/I2C communications, the SPI_CS# pin is not used and should be grounded; any
data presented to this pin will be ignored.
See Section 4.2 and Section 4.3 for more information on the SMBus bus and protocols respectively.
4.1.2 SPI COMMUNICATIONS
When configured to communicate via the SPI bus, the CAP1128supports both bi-directional 3-wire and normal 4-wire
protocols and uses the SPI_CS# pin to enable communications.
APPLICATION NOTE: See Section 4.5 and Section 4.6 for more information on the SPI bus and protocols
respectively.Upon power up, the CAP1128 will not respond to any communications for up to
15ms. After this time, full functionality is available.
4.2 System Management Bus
The CAP1128 communicates with a host controller, such as an SIO, through the SMBus. The SMBus is a two-wire serial
communication protocol between a computer host and its peripheral devices. A detailed timing diagram is shown in
Figure 4-1. Stretching of the SMCLK signal is supported; however, the CAP1128 will not stretch the clock signal.
TABLE 4-1: ADDR_COMM PIN DECODE
Pull-Down Resistor (+/- 5%) Protocol Used SMBus Address
GND SPI Communications using Normal
4-wire Protocol Used
n/a
56k SPI Communications using BiDirectional
3-wire Protocol Used
n/a
68k Reserved n/a
82k SMBus / I2C 0101_100(r/w)
100k SMBus / I2C 0101_011(r/w)
120k SMBus / I2C 0101_010(r/w)
150k SMBus / I2C 0101_001(r/w)
VDD SMBus / I2C 0101_000(r/w)
CAP1128
DS00001622B-page 12 2015 Microchip Technology Inc.
4.2.1 SMBUS START BIT
The SMBus Start bit is defined as a transition of the SMBus Data line from a logic ‘1’ state to a logic ‘0’ state while the
SMBus Clock line is in a logic ‘1’ state.
4.2.2 SMBUS ADDRESS AND RD / WR BIT
The SMBus Address Byte consists of the 7-bit slave address followed by the RD / WR indicator bit. If this RD / WR bit
is a logic ‘0’, then the SMBus Host is writing data to the slave device. If this RD / WR bit is a logic ‘1’, then the SMBus
Host is reading data from the slave device.
See Table 4-1 for available SMBus addresses.
4.2.3 SMBUS DATA BYTES
All SMBus Data bytes are sent most significant bit first and composed of 8-bits of information.
4.2.4 SMBUS ACK AND NACK BITS
The SMBus slave will acknowledge all data bytes that it receives. This is done by the slave device pulling the SMBus
Data line low after the 8th bit of each byte that is transmitted. This applies to both the Write Byte and Block Write protocols.
The Host will NACK (not acknowledge) the last data byte to be received from the slave by holding the SMBus data line
high after the 8th data bit has been sent. For the Block Read protocol, the Host will ACK each data byte that it receives
except the last data byte.
4.2.5 SMBUS STOP BIT
The SMBus Stop bit is defined as a transition of the SMBus Data line from a logic ‘0’ state to a logic ‘1’ state while the
SMBus clock line is in a logic ‘1’ state. When the CAP1128 detects an SMBus Stop bit and it has been communicating
with the SMBus protocol, it will reset its slave interface and prepare to receive further communications.
4.2.6 SMBUS TIMEOUT
The CAP1128 includes an SMBus timeout feature. Following a 30ms period of inactivity on the SMBus where the
SMCLK pin is held low, the device will timeout and reset the SMBus interface.
The timeout function defaults to disabled. It can be enabled by setting the TIMEOUT bit in the Configuration register
(see Section 6.6, "Configuration Registers").
4.2.7 SMBUS AND I2C COMPATIBILITY
The major differences between SMBus and I2C devices are highlighted here. For more information, refer to the SMBus
2.0 and I2C specifications. For information on using the CAP1128 in an I2C system, refer to AN 14.0 Dedicated Slave
Devices in I2C Systems.
FIGURE 4-1: SMBus Timing Diagram
SMDATA
SMCLK
TLOW
TRISE
THIGH
TFALL
TBUF
THD:STA
P S S - Start Condition P - Stop Condition
THD:DAT TSU:DAT TSU:STA
THD:STA
P
TSU:STO
S
2015 Microchip Technology Inc. DS00001622B-page 13
CAP1128
1. CAP1128 supports I2C fast mode at 400kHz. This covers the SMBus max time of 100kHz.
2. Minimum frequency for SMBus communications is 10kHz.
3. The SMBus slave protocol will reset if the clock is held at a logic ‘0’ for longer than 30ms. This timeout functionality
is disabled by default in the CAP1128 and can be enabled by writing to the TIMEOUT bit. I2C does not have
a timeout.
4. The SMBus slave protocol will reset if both the clock and data lines are held at a logic ‘1’ for longer than 200µs
(idle condition). This function is disabled by default in the CAP1128 and can be enabled by writing to the TIMEOUT
bit. I2C does not have an idle condition.
5. I2C devices do not support the Alert Response Address functionality (which is optional for SMBus).
6. I2C devices support block read and write differently. I2C protocol allows for unlimited number of bytes to be sent
in either direction. The SMBus protocol requires that an additional data byte indicating number of bytes to read /
write is transmitted. The CAP1128 supports I2C formatting only.
4.3 SMBus Protocols
The CAP1128 is SMBus 2.0 compatible and supports Write Byte, Read Byte, Send Byte, and Receive Byte as valid
protocols as shown below.
All of the below protocols use the convention in Table 4-2.
4.3.1 SMBUS WRITE BYTE
The Write Byte is used to write one byte of data to a specific register as shown in Table 4-3.
4.3.2 SMBUS READ BYTE
The Read Byte protocol is used to read one byte of data from the registers as shown in Table 4-4.
4.3.3 SMBUS SEND BYTE
The Send Byte protocol is used to set the internal address register pointer to the correct address location. No data is
transferred during the Send Byte protocol as shown in Table 4-5.
APPLICATION NOTE: The Send Byte protocol is not functional in Deep Sleep (i.e., DSLEEP bit is set).
TABLE 4-2: PROTOCOL FORMAT
Data Sent to
Device
Data Sent to the
HOst
Data sent Data sent
TABLE 4-3: WRITE BYTE PROTOCOL
Start Slave
Address WR ACK Register
Address ACK Register Data ACK Stop
1 ->0 YYYY_YYY 0 0 XXh 0 XXh 0 0 -> 1
TABLE 4-4: READ BYTE PROTOCOL
Start Slave
Address WR ACK Register
Address ACK Start Slave
Address RD ACK Register
Data NACK Stop
1->0 YYYY_YYY 0 0 XXh 0 1 ->0 YYYY_YYY 1 0 XXh 1 0 -> 1
TABLE 4-5: SEND BYTE PROTOCOL
Start Slave Address WR ACK Register Address ACK Stop
1 -> 0 YYYY_YYY 0 0 XXh 0 0 -> 1
CAP1128
DS00001622B-page 14 2015 Microchip Technology Inc.
4.3.4 SMBUS RECEIVE BYTE
The Receive Byte protocol is used to read data from a register when the internal register address pointer is known to
be at the right location (e.g., set via Send Byte). This is used for consecutive reads of the same register as shown in
Table 4-6.
APPLICATION NOTE: The Receive Byte protocol is not functional in Deep Sleep (i.e., DSLEEP bit is set).
4.4 I2C Protocols
The CAP1128 supports I2C Block Write and Block Read.
The protocols listed below use the convention in Table 4-2.
4.4.1 BLOCK WRITE
The Block Write is used to write multiple data bytes to a group of contiguous registers as shown in Table 4-7.
APPLICATION NOTE: When using the Block Write protocol, the internal address pointer will be automatically
incremented after every data byte is received. It will wrap from FFh to 00h.
4.4.2 BLOCK READ
The Block Read is used to read multiple data bytes from a group of contiguous registers as shown in Table 4-8.
APPLICATION NOTE: When using the Block Read protocol, the internal address pointer will be automatically
incremented after every data byte is received. It will wrap from FFh to 00h.
4.5 SPI Interface
The SMBus has a predefined packet structure, the SPI does not. The SPI Bus can operate in two modes of operation,
normal 4-wire mode and bi-directional 3-wire mode. All SPI commands consist of 8-bit packets sent to a specific slave
device (identified by the CS pin).
The SPI bus will latch data on the rising edge of the clock and the clock and data both idle high.
All commands are supported via both operating modes. The supported commands are: Reset Serial interface, set
address pointer, write command and read command. Note that all other codes received during the command phase are
ignored and have no effect on the operation of the device.
TABLE 4-6: RECEIVE BYTE PROTOCOL
Start Slave Address RD ACK Register Data NACK Stop
1 -> 0 YYYY_YYY 1 0 XXh 1 0 -> 1
TABLE 4-7: BLOCK WRITE PROTOCOL
Start Slave
Address WR ACK Register
Address ACK Register Data ACK
1 ->0 YYYY_YYY 0 0 XXh 0 XXh 0
Register Data ACK Register
Data
ACK . . . Register
Data
ACK Stop
XXh 0 XXh 0 . . . XXh 0 0 -> 1
TABLE 4-8: BLOCK READ PROTOCOL
Start Slave
Address WR ACK Register
Address ACK Start Slave
Address RD ACK Register
Data
1->0 YYYY_YYY 0 0 XXh 0 1 ->0 YYYY_YYY 1 0 XXh
ACK Register
Data
ACK Register
Data
ACK Register
Data
ACK . . . Register
Data
NACK Stop
0 XXh 0 XXh 0 XXh 0 . . . XXh 1 0 -> 1
2015 Microchip Technology Inc. DS00001622B-page 15
CAP1128
4.5.1 SPI NORMAL MODE
The SPI Bus can operate in two modes of operation, normal and bi-directional mode. In the normal mode of operation,
there are dedicated input and output data lines. The host communicates by sending a command along the CAP1128
SPI_MOSI data line and reading data on the SPI_MISO data line. Both communications occur simultaneously which
allows for larger throughput of data transactions.
All basic transfers consist of two 8 bit transactions from the Master device while the slave device is simultaneously sending
data at the current address pointer value.
Data writes consist of two or more 8-bit transactions. The host sends a specific write command followed by the data to
write the address pointer. Data reads consist of one or more 8-bit transactions. The host sends the specific read data
command and continues clocking for as many data bytes as it wishes to receive.
4.5.2 SPI BI-DIRECTIONAL MODE
In the bi-directional mode of operation, the SPI data signals are combined into the SPI_MSIO line, which is shared for
data received by the device and transmitted by the device. The protocol uses a simple handshake and turn around
sequence for data communications based on the number of clocks transmitted during each phase.
All basic transfers consist of two 8 bit transactions. The first is an 8 bit command phase driven by the Master device.
The second is by an 8 bit data phase driven by the Master for writes, and by the CAP1128 for read operations.
The auto increment feature of the address pointer allows for successive reads or writes. The address pointer will return
to 00h after reaching FFh.
4.5.3 SPI_CS# PIN
The SPI Bus is a single master, multiple slave serial bus. Each slave has a dedicated CS pin (chip select) that the master
asserts low to identify that the slave is being addressed. There are no formal addressing options.
4.5.4 ADDRESS POINTER
All data writes and reads are accessed from the current address pointer. In both Bi-directional mode and Full Duplex
mode, the Address pointer is automatically incremented following every read command or every write command.
The address pointer will return to 00h after reaching FFh.
4.5.5 SPI TIMEOUT
The CAP1128 does not detect any timeout conditions on the SPI bus.
FIGURE 4-2: SPI Timing
SPI_MSIO or
SPI_MOSI or
SPI_MISO
SPI_CLK
tLOW
tRISE
tHIGH
tFALL
tD:CLK tHD:DAT
tSU:DAT
tP
2015 Microchip Technology Inc. DS00001622B-page 16
CAP1128 4.6 Normal SPI Protocols When operating in normal mode, the SPI bus internal address pointer is incremented depending upon which command has been transmitted. Multiple commands may be transmitted sequentually so long as the SPI_CS# pin is asserted low. Figure 4-3 shows an example of this operation.
4.6.1 RESET INTERFACE
Resets the Serial interface whenever two successive 7Ah codes are received. Regardless of the current phase of the transaction - command or data, the receipt of the
successive reset commands resets the Serial communication interface only. All other functions are not affected by the reset operation.
FIGURE 4-3: Example SPI Bus Communication - Normal Mode
SPI_CS#
SPI_MISO
SPI_MOSI
SPI Address Pointer
SPI Data output buffer
Register Address /
Data
7Ah
XXh
(invalid)
XXh
(invalid)
YYh
(invalid)
7Ah 7Dh 41h
YYh
(invalid)
7Eh 66h
XXh
(invalid) 45h
7Dh 41h
AAh
(invalid)
AAh
(invalid)
7Fh 7Fh
55h
(invalid) 66h
7Fh
AAh
7Dh
43h
40h
78h
7Fh
XXh
(invalid)
7Fh
56h
40h / 56h
41h / 45h
42h / AAh
43h / 55h
44h / 80h
45h / 43h
46h / 78h
41h
45h
40h / 56h
41h / 45h
42h / AAh
43h / 55h
44h / 80h
45h / 43h
46h / 78h
42h
AAh
40h / 56h
41h / 66h
42h / AAh
43h / 55h
44h / 80h
45h / 43h
46h / 78h
41h
55h
7Fh
AAh
40h / 56h
41h / 66h
42h / AAh
43h / 55h
44h / 80h
45h / 43h
46h / 78h
41h
66h
42h
AAh
40h / 56h
41h / 66h
42h / AAh
43h / 55h
44h / 80h
45h / 43h
46h / 78h
40h / 56h
41h / 66h
42h / AAh
43h / 55h
44h / 80h
45h / 43h
46h / 78h
40h / 56h
41h / 66h
42h / AAh
43h / 55h
44h / 80h
45h / 43h
46h /78h
44h
80h
40h
80h
40h
56h
40h / 56h
41h / 66h
42h / AAh
43h / 55h
44h / 80h
45h / 43h
46h /78h
43h
55h
7Fh 7Fh
55h
40h / 56h
41h / 66h
42h / AAh
43h / 55h
44h / 80h
45h / 43h
46h /78h
80h
45h
43h
46h
78h
40h / 56h
41h / 66h
42h / AAh
43h / 55h
44h / 80h
45h / 43h
46h / 78h
00h
XXh
Indicates SPI Address pointer incremented
2015 Microchip Technology Inc. DS00001622B-page 17
CAP1128
4.6.2 SET ADDRESS POINTER
The Set Address Pointer command sets the Address pointer for subsequent reads and writes of data. The pointer is set
on the rising edge of the final data bit. At the same time, the data that is to be read is fetched and loaded into the internal
output buffer but is not transmitted.
4.6.3 WRITE DATA
The Write Data protocol updates the contents of the register referenced by the address pointer. As the command is processed,
the data to be read is fetched and loaded into the internal output buffer but not transmitted. Then, the register
is updated with the data to be written. Finally, the address pointer is incremented.
FIGURE 4-4: SPI Reset Interface Command - Normal Mode
FIGURE 4-5: SPI Set Address Pointer Command - Normal Mode
Master SPDOUT
SPI_MOSI
SPI_CS#
SPI_CLK
Reset - 7Ah Reset - 7Ah
Invalid register data 00h – Internal Data buffer empty SPI_MISO
Master Drives Slave Drives
‘0’ ‘1’ ‘1’ ‘1’ ‘1’ ‘0’ ‘1’ ‘0’ ‘0’ ‘1’ ‘1’ ‘1’ ‘1’ ‘0’ ‘1’ ‘0’
Master SPDOUT
SPI_MOSI Register Address
SPI_CS#
SPI_CLK
Set Address Pointer – 7Dh
SPI_MISO Unknown, Invalid Data Unknown, Invalid Data
Master Drives Slave Drives Address pointer set
‘0’ ‘0’ ‘1’ ‘1’ ‘1’ ‘1’ ‘1’ ‘1’
CAP1128
DS00001622B-page 18 2015 Microchip Technology Inc.
4.6.4 READ DATA
The Read Data protocol is used to read data from the device. During the normal mode of operation, while the device is
receiving data, the CAP1128 is simultaneously transmitting data to the host. For the Set Address commands and the
Write Data commands, this data may be invalid and it is recommended that the Read Data command is used.
FIGURE 4-6: SPI Write Command - Normal Mode
FIGURE 4-7: SPI Read Command - Normal Mode
Master SPDOUT
SPI_MOSI Data to Write
SPI_CS#
SPI_CLK
Write Command – 7Eh
Unknown, Invalid Data Old Data at Current Address Pointer SPI_MISO
Master Drives Slave Drives
1. Data written at current
address pointer
2. Address pointer incremented
Master SPDOUT
SPI_MOSI
Master Drives Slave Drives
SPI_CLK
First Read Command – 7Fh
SPI_CS#
SPI_MISO Invalid, Unknown Data *
‘0’ ‘1’ ‘1’ ‘1’ ‘1’ ‘1’ ‘1’ ‘1’
Subsequent Read
Commands – 7F
Data at Current Address Pointer
Address Pointer
Incremented **
‘0’ ‘1’ ‘1’ ‘1’ ‘1’ ‘1’ ‘1’ ‘1’
* The first read command after any other command will return invalid data for the first
byte. Subsequent read commands will return the data at the Current Address Pointer
** The Address Pointer is incremented 8 clocks after the Read Command has been
received. Therefore continually sending Read Commands will result in each command
reporting new data. Once Read Commands have been finished, the last data byte will be
read during the next 8 clocks for any command
2015 Microchip Technology Inc. DS00001622B-page 19
CAP1128
4.7 Bi-Directional SPI Protocols
4.7.1 RESET INTERFACE
Resets the Serial interface whenever two successive 7Ah codes are received. Regardless of the current phase of the
transaction - command or data, the receipt of the successive reset commands resets the Serial communication interface
only. All other functions are not affected by the reset operation.
4.7.2 SET ADDRESS POINTER
Sets the address pointer to the register to be accessed by a read or write command. This command overrides the autoincrementing
of the address pointer.
FIGURE 4-8: SPI Read Command - Normal Mode - Full
FIGURE 4-9: SPI Reset Interface Command - Bi-directional Mode
Master SPDOUT
SPI_MOSI
Master Drives Slave Drives
SPI_CLK
Read Command – 7Fh
SPI_CS#
Data at previously set register address = current
address pointer
SPI_MISO ‘0’ ‘1’ ‘1’ ‘1’ ‘1’ ‘1’ ‘1’ ‘1’
Data at previously set register address = current
address pointer (SPI)
XXh
1. Register Read Address
updated to Current SPI Read
Address pointer
1. Register data loaded into
output buffer = data at current
address pointer
1. Output buffer transmitted =
data at previous address
pointer + 1 = current address
pointer
1. Register Read Address
incremented = current address
pointer + 1
1. SPI Read Address
Incremented = new current
address pointer
2. Register Read Address
Incremented = current address
pointer +1
Register Data loaded into
Output buffer = data at current
address pointer + 1
1. Output buffer transmitted =
data at current address pointer
+ 1
2. Flag set to increment SPI
Read Address at end of next 8
clocks
‘0’ ‘1’ ‘1’ ‘1’ ‘1’ ‘1’ ‘1’ ‘1’
Data at previously set register address = current
address pointer (SPI)
1. Register data loaded into
output buffer = data at current
address pointer
1. Output buffer transmitted =
data at previous register
address pointer + 1 = current
address pointer
1. Output buffer transmitted =
data at current address pointer
+ 1
2. Flag set to increment SPI
Read Address at end of next 8
clocks
Subsequent Read Commands – 7Fh
1. Register Read Address
updated to Current SPI Read
Address pointer.
2. Register Read Address
incremented = current address
pointer +1 – end result =
register address pointer doesn’t
change
Master SPDOUT
SPI_MSIO
SPI_CS#
SPI_CLK
Reset - 7Ah Reset - 7Ah
‘0’ ‘0’ ‘0’ ‘1’ ‘1’ ‘1’ ‘1’ ‘1’ ‘0’ ‘0’ ‘0’ ‘1’ ‘1’ ‘1’ ‘1’ ‘1’
CAP1128
DS00001622B-page 20 2015 Microchip Technology Inc.
4.7.3 WRITE DATA
Writes data value to the register address stored in the address pointer. Performs auto increment of address pointer after
the data is loaded into the register.
4.7.4 READ DATA
Reads data referenced by the address pointer. Performs auto increment of address pointer after the data is transferred
to the Master.
FIGURE 4-10: SPI Set Address Pointer Command - Bi-directional Mode
FIGURE 4-11: SPI Write Data Command - Bi-directional Mode
FIGURE 4-12: SPI Read Data Command - Bi-directional Mode
Master SPDOUT
SPI_MSIO Register Address
SPI_CS#
SPI_CLK
Set Address Pointer – 7Dh
‘0’ ‘1’ ‘0’ ‘1’ ‘1’ ‘1’ ‘1’ ‘1’
Master SPDOUT
SPI_MSIO Register Write Data
SPI_CS#
SPI_CLK
Write Command – 7Eh
‘0’ ‘1’ ‘1’ ‘1’ ‘1’ ‘1’ ‘1’ ‘0’
Master SPDOUT
SPI_MSIO
Master Drives Slave Drives Indeterminate
Register Read Data
SPI_CLK
Read Command – 7Fh
SPI_CS#
‘0’ ‘1’ ‘1’ ‘1’ ‘1’ ‘1’ ‘1’ ‘1’
2015 Microchip Technology Inc. DS00001622B-page 21
CAP1128
4.8 BC-Link Interface
The BC-Link is a proprietary bus developed to allow communication between a host controller device to a companion
device. This device uses this serial bus to read and write registers and for interrupt processing. The interface uses a
data port concept, where the base interface has an address register, data register and a control register, defined in the
8051’s SFR space.
Refer to documentation for the BC-Link compatible host controller for details on how to access the CAP1128 via the BCLink
Interface.
CAP1128
DS00001622B-page 22 2015 Microchip Technology Inc.
5.0 GENERAL DESCRIPTION
The CAP1128 is a multiple channel Capacitive Touch sensor with multiple power LED drivers. It contains eight (8) individual
capacitive touch sensor inputs with programmable sensitivity for use in touch sensor applications. Each sensor
input automatically recalibrates to compensate for gradual environmental changes.
The CAP1128 also contains two (2) low side (or push-pull) LED drivers that offer full-on / off, variable rate blinking, dimness
controls, and breathing. Each of the LED drivers may be linked to one of the sensor inputs to be actuated when a
touch is detected. As well, each LED driver may be individually controlled via a host controller.
Finally, the device contains a dedicated RESET pin to act as a soft reset by the system.
The CAP1128 offers multiple power states. It operates at the lowest quiescent current during its Deep Sleep state. In
the low power Standby state, it can monitor one or more channels and respond to communications normally. The device
contains a wake pin (WAKE/SPI_MOSI) output to wake the system when a touch is detected in Standby and to wake
the device from Deep Sleep.
The device communicates with a host controller using the SPI bus, or via SMBus / I2C. The host controller may poll the
device for updated information at any time or it may configure the device to flag an interrupt whenever a touch is
detected on any sensor pad.
A typical system diagram is shown in Figure 5-1.
2015 Microchip Technology Inc. DS00001622B-page 23
CAP1128
FIGURE 5-1: System Diagram for CAP1128
CAP1128
CS6
SMDATA / BC_DATA / SPI_MSIO / SPI_MISO
SMCLK / BC_CLK / SPI_CLK
VDD Embedded Controller ALERT# / BC_IRQ#
CS4
CS2
3.3V – 5V
CS5
CS3
CS1
WAKE / SPI_MOSI
CS7 CS8 RESET SPI_CS#
ADDR_COMM
LED1 LED2
3.3V – 5V
Touch
Button
Touch
Button
Touch
Button
Touch
Button
Touch
Button
Touch
Button
Touch
Button
Touch
Button
CAP1128
DS00001622B-page 24 2015 Microchip Technology Inc.
5.1 Power States
The CAP1128 has three operating states depending on the status of the STBY and DSLEEP bits. When the device transitions
between power states, previously detected touches (for inactive channels) are cleared and the status bits reset.
1. Fully Active - The device is fully active. It is monitoring all active capacitive sensor inputs and driving all LED channels
as defined.
2. Standby - The device is in a lower power state. It will measure a programmable number of channels using the
Standby Configuration controls (see Section 6.20 through Section 6.22). Interrupts will still be generated based
on the active channels. The device will still respond to communications normally and can be returned to the Fully
Active state of operation by clearing the STBY bit.
3. Deep Sleep - The device is in its lowest power state. It is not monitoring any capacitive sensor inputs and not
driving any LEDs. All LEDs will be driven to their programmed non-actuated state and no PWM operations will
be done. While in Deep Sleep, the device can be awakened by SMBus or SPI communications targeting the
device. This will not cause the DSLEEP to be cleared so the device will return to Deep Sleep once all communications
have stopped.
If the device is not communicating via the 4-wire SPI bus, then during this state of operation, if the WAKE/SPI_MOSI
pin is driven high by an external source, the device will clear the DSLEEP bit and return to Fully Active.
APPLICATION NOTE: In the Deep Sleep state, the LED output will be either high or low and will not be PWM’d at
the min or max duty cycle.
5.2 RESET Pin
The RESET pin is an active high reset that is driven from an external source. While it is asserted high, all the internal
blocks will be held in reset including the communications protocol used. No capacitive touch sensor inputs will be sampled
and the LEDs will not be driven. All configuration settings will be reset to default states and all readings will be
cleared.
The device will be held in Deep Sleep that can only be removed by driving the RESET pin low. This will cause the
RESET status bit to be set to a logic ‘1’ and generate an interrupt.
5.3 WAKE/SPI_MOSI Pin Operation
The WAKE / SPI_MOSI pin is a multi-function pin depending on device operation. When the device is configured to communicate
using the 4-wire SPI bus, this pin is an input.
However, when the CAP1128 is placed in Standby and is not communicating using the 4-wire SPI protocol, the WAKE
pin is an active high output. In this condition, the device will assert the WAKE/SPI_MOSI pin when a touch is detected
on one of its sampled sensor inputs. The pin will remain asserted until the INT bit has been cleared and then it will be
de-asserted.
When the CAP1128 is placed in Deep Sleep and it is not communicating using the 4-wire SPI protocol, the WAKE/SPI_-
MOSI pin is monitored by the device as an input. If the WAKE/SPI_MOSI pin is driven high by an external source, the
CAP1128will clear the DSLEEP bit causing the device to return to Fully Active.
When the device is placed in Deep Sleep, this pin is a High-Z input and must have a pull-down resistor to GND for proper
operation.
5.4 LED Drivers
The CAP1128 contains two (2) LED drivers. Each LED driver can be linked to its respective capacitive touch sensor
input or it can be controlled by the host. Each LED driver can be configured to operate in one of the following modes
with either push-pull or open drain drive.
1. Direct - The LED is configured to be on or off when the corresponding input stimulus is on or off (or inverted). The
brightness of the LED can be programmed from full off to full on (default). Additionally, the LED contains controls
to individually configure ramping on, off, and turn-off delay.
2. Pulse 1 - The LED is configured to “Pulse” (transition ON-OFF-ON) a programmable number of times with programmable
rate and min / max brightness. This behavior may be actuated when a press is detected or when a
release is detected.
3. Pulse 2 - The LED is configured to “Pulse” while actuated and then “Pulse” a programmable number of times with
programmable rate and min / max brightness when the sensor pad is released.
2015 Microchip Technology Inc. DS00001622B-page 25
CAP1128
4. Breathe - The LED is configured to transition continuously ON-OFF-ON (i.e. to “Breathe”) with a programmable
rate and min / max brightness.
When an LED is not linked to a sensor and is actuated by the host, there’s an option to assert the ALERT# pin when
the initiated LED behavior has completed.
5.4.1 LINKING LEDS TO CAPACITIVE TOUCH SENSOR INPUTS
All LEDs can be linked to the corresponding capacitive touch sensor input so that when the sensor input detects a touch,
the corresponding LED will be actuated at one of the programmed responses.
5.5 Capacitive Touch Sensing
The CAP1128 contains eight (8) independent capacitive touch sensor inputs. Each sensor input has dynamic range to
detect a change of capacitance due to a touch. Additionally, each sensor input can be configured to be automatically
and routinely re-calibrated.
5.5.1 SENSING CYCLE
Each capacitive touch sensor input has controls to be activated and included in the sensing cycle. When the device is
active, it automatically initiates a sensing cycle and repeats the cycle every time it finishes. The cycle polls through each
active sensor input starting with CS1 and extending through CS8. As each capacitive touch sensor input is polled, its
measurement is compared against a baseline “Not Touched” measurement. If the delta measurement is large enough,
a touch is detected and an interrupt is generated.
The sensing cycle time is programmable (see Section 6.10, "Averaging and Sampling Configuration Register").
5.5.2 RECALIBRATING SENSOR INPUTS
There are various options for recalibrating the capacitive touch sensor inputs. Recalibration re-sets the Base Count Registers
(Section 6.24, "Sensor Input Base Count Registers") which contain the “not touched” values used for touch detection
comparisons.
APPLICATION NOTE: The device will recalibrate all sensor inputs that were disabled when it transitions from
Standby. Likewise, the device will recalibrate all sensor inputs when waking out of Deep
Sleep.
5.5.2.1 Manual Recalibration
The Calibration Activate Registers (Section 6.11, "Calibration Activate Register") force recalibration of selected sensor
inputs. When a bit is set, the corresponding capacitive touch sensor input will be recalibrated (both analog and digital).
The bit is automatically cleared once the recalibration routine has finished.
5.5.2.2 Automatic Recalibration
Each sensor input is regularly recalibrated at a programmable rate (see Section 6.17, "Recalibration Configuration Register").
By default, the recalibration routine stores the average 64 previous measurements and periodically updates the
base “not touched” setting for the capacitive touch sensor input.
Note: During this recalibration routine, the sensor inputs will not detect a press for up to 200ms and the Sensor
Base Count Register values will be invalid. In addition, any press on the corresponding sensor pads will
invalidate the recalibration.
Note: Automatic recalibration only works when the delta count is below the active sensor input threshold. It is disabled
when a touch is detected.
CAP1128
DS00001622B-page 26 2015 Microchip Technology Inc.
5.5.2.3 Negative Delta Count Recalibration
It is possible that the device loses sensitivity to a touch. This may happen as a result of a noisy environment, an accidental
recalibration during a touch, or other environmental changes. When this occurs, the base untouched sensor input
may generate negative delta count values. The NEG_DELTA_CNT bits (see Section 6.17, "Recalibration Configuration
Register") can be set to force a recalibration after a specified number of consecutive negative delta readings.
5.5.2.4 Delayed Recalibration
It is possible that a “stuck button” occurs when something is placed on a button which causes a touch to be detected
for a long period. By setting the MAX_DUR_EN bit (see Section 6.6, "Configuration Registers"), a recalibration can be
forced when a touch is held on a button for longer than the duration specified in the MAX_DUR bits (see Section 6.8,
"Sensor Input Configuration Register").
5.5.3 PROXIMITY DETECTION
Each sensor input can be configured to detect changes in capacitance due to proximity of a touch. This circuitry detects
the change of capacitance that is generated as an object approaches, but does not physically touch, the enabled sensor
pad(s). When a sensor input is selected to perform proximity detection, it will be sampled from 1x to 128x per sampling
cycle. The larger the number of samples that are taken, the greater the range of proximity detection is available at the
cost of an increased overall sampling time.
5.5.4 MULTIPLE TOUCH PATTERN DETECTION
The multiple touch pattern (MTP) detection circuitry can be used to detect lid closure or other similar events. An event
can be flagged based on either a minimum number of sensor inputs or on specific sensor inputs simultaneously exceeding
an MTP threshold or having their Noise Flag Status Register bits set. An interrupt can also be generated. During an
MTP event, all touches are blocked (see Section 6.15, "Multiple Touch Pattern Configuration Register").
5.5.5 LOW FREQUENCY NOISE DETECTION
Each sensor input has an EMI noise detector that will sense if low frequency noise is injected onto the input with sufficient
power to corrupt the readings. If this occurs, the device will reject the corrupted sample and set the corresponding
bit in the Noise Status register to a logic ‘1’.
5.5.6 RF NOISE DETECTION
Each sensor input contains an integrated RF noise detector. This block will detect injected RF noise on the CS pin. The
detector threshold is dependent upon the noise frequency. If RF noise is detected on a CS line, that sample is removed
and not compared against the threshold.
5.6 ALERT# Pin
The ALERT# pin is an active low (or active high when configured) output that is driven when an interrupt event is
detected.
Whenever an interrupt is generated, the INT bit (see Section 6.1, "Main Control Register") is set. The ALERT# pin is
cleared when the INT bit is cleared by the user. Additionally, when the INT bit is cleared by the user, status bits are only
cleared if no touch is detected.
5.6.1 SENSOR INTERRUPT BEHAVIOR
The sensor interrupts are generated in one of two ways:
1. An interrupt is generated when a touch is detected and, as a user selectable option, when a release is detected
(by default - see Section 6.6). See Figure 5-3.
2. If the repeat rate is enabled then, so long as the touch is held, another interrupt will be generated based on the
programmed repeat rate (see Figure 5-2).
Note: During this recalibration, the device will not respond to touches.
Note: Delayed recalibration only works when the delta count is above the active sensor input threshold. If
enabled, it is invoked when a sensor pad touch is held longer than the MAX_DUR bit setting.
2015 Microchip Technology Inc. DS00001622B-page 27
CAP1128
When the repeat rate is enabled, the device uses an additional control called MPRESS that determines whether a touch
is flagged as a simple “touch” or a “press and hold”. The MPRESS[3:0] bits set a minimum press timer. When the button
is touched, the timer begins. If the sensor pad is released before the minimum press timer expires, it is flagged as a
touch and an interrupt is generated upon release. If the sensor input detects a touch for longer than this timer value, it
is flagged as a “press and hold” event. So long as the touch is held, interrupts will be generated at the programmed
repeat rate and upon release (if enabled).
APPLICATION NOTE: Figure 5-2 and Figure 5-3 show default operation which is to generate an interrupt upon
sensor pad release and an active-low ALERT# pin.
APPLICATION NOTE: The host may need to poll the device twice to determine that a release has been detected.
FIGURE 5-2: Sensor Interrupt Behavior - Repeat Rate Enabled
FIGURE 5-3: Sensor Interrupt Behavior - No Repeat Rate Enabled
Touch Detected
INT bit
Button Status
Write to INT bit
Polling Cycle
(35ms)
Min Press Setting
(280ms)
Interrupt on
Touch
Button Repeat Rate
(175ms)
Button Repeat Rate
(175ms)
Interrupt on
Release
(optional)
ALERT# pin
(active low)
Touch Detected
INT bit
Button Status
Write to INT bit
Polling Cycle
(35ms) Interrupt on
Touch Interrupt on
Release
(optional)
ALERT# pin
(active low)
CAP1128
DS00001622B-page 28 2015 Microchip Technology Inc.
6.0 REGISTER DESCRIPTION
The registers shown in Table 6-1 are accessible through the communications protocol. An entry of ‘-’ indicates that the
bit is not used and will always read ‘0’.
TABLE 6-1: REGISTER SET IN HEXADECIMAL ORDER
Register
Address R/W Register Name Function Default Value Page
00h R/W Main Control Controls general power states and
power dissipation 00h Page 31
02h R General Status Stores general status bits 00h Page 32
03h R Sensor Input Status Returns the state of the sampled
capacitive touch sensor inputs 00h Page 32
04h R LED Status Stores status bits for LEDs 00h Page 32
0Ah R Noise Flag Status Stores the noise flags for sensor inputs 00h Page 33
10h R Sensor Input 1 Delta
Count Stores the delta count for CS1 00h Page 34
11h R Sensor Input 2 Delta
Count Stores the delta count for CS2 00h Page 34
12h R Sensor Input 3 Delta
Count Stores the delta count for CS3 00h Page 34
13h R Sensor Input 4 Delta
Count Stores the delta count for CS4 00h Page 34
14h R Sensor Input 5 Delta
Count Stores the delta count for CS5 00h Page 34
15h R Sensor Input 6 Delta
Count Stores the delta count for CS6 00h Page 34
16h R Sensor Input 7 Delta
Count Stores the delta count for CS7 00h Page 34
17h R Sensor Input 8 Delta
Count Stores the delta count for CS8 00h Page 34
1Fh R/W Sensitivity Control
Controls the sensitivity of the threshold
and delta counts and data scaling of
the base counts
2Fh Page 34
20h R/W Configuration Controls general functionality 20h Page 36
21h R/W Sensor Input Enable Controls whether the capacitive touch
sensor inputs are sampled FFh Page 37
22h R/W Sensor Input Configuration
Controls max duration and auto-repeat
delay for sensor inputs operating in the
full power state
A4h Page 38
23h R/W Sensor Input Configuration
2
Controls the MPRESS controls for all
sensor inputs 07h Page 39
24h R/W Averaging and Sampling
Config
Controls averaging and sampling window
39h Page 39
26h R/W Calibration Activate Forces re-calibration for capacitive
touch sensor inputs 00h Page 41
27h R/W Interrupt Enable Enables Interrupts associated with
capacitive touch sensor inputs FFh Page 41
28h R/W Repeat Rate Enable Enables repeat rate for all sensor
inputs FFh Page 42
2Ah R/W Multiple Touch Configuration
Determines the number of simultaneous
touches to flag a multiple touch
condition
80h Page 42
2015 Microchip Technology Inc. DS00001622B-page 29
CAP1128
2Bh R/W Multiple Touch Pattern
Configuration
Determines the multiple touch pattern
(MTP) configuration 00h Page 43
2Dh R/W Multiple Touch Pattern
Determines the pattern or number of
sensor inputs used by the MTP circuitry
FFh Page 44
2Fh R/W Recalibration Configuration
Determines re-calibration timing and
sampling window 8Ah Page 44
30h R/W Sensor Input 1 Threshold
Stores the delta count threshold to
determine a touch for Capacitive
Touch Sensor Input 1
40h Page 46
31h R/W Sensor Input 2 Threshold
Stores the delta count threshold to
determine a touch for Capacitive
Touch Sensor Input 2
40h Page 46
32h R/W Sensor Input 3 Threshold
Stores the delta count threshold to
determine a touch for Capacitive
Touch Sensor Input 3
40h Page 46
33h R/W Sensor Input 4 Threshold
Stores the delta count threshold to
determine a touch for Capacitive
Touch Sensor Input 4
40h Page 46
34h R/W Sensor Input 5 Threshold
Stores the delta count threshold to
determine a touch for Capacitive
Touch Sensor Input 5
40h Page 46
35h R/W Sensor Input 6 Threshold
Stores the delta count threshold to
determine a touch for Capacitive
Touch Sensor Input 6
40h Page 46
36h R/W Sensor Input 7 Threshold
Stores the delta count threshold to
determine a touch for Capacitive
Touch Sensor Input 7
40h Page 46
37h R/W Sensor Input 8 Threshold
Stores the delta count threshold to
determine a touch for Capacitive
Touch Sensor Input 8
40h
38h R/W Sensor Input Noise
Threshold
Stores controls for selecting the noise
threshold for all sensor inputs 01h Page 46
Standby Configuration Registers
40h R/W Standby Channel Controls which sensor inputs are
enabled while in standby 00h Page 47
41h R/W Standby Configuration Controls averaging and cycle time
while in standby 39h Page 47
42h R/W Standby Sensitivity Controls sensitivity settings used while
in standby 02h Page 48
43h R/W Standby Threshold Stores the touch detection threshold
for active sensor inputs in standby 40h Page 49
44h R/W Configuration 2 Stores additional configuration controls
for the device 40h Page 36
Base Count Registers
50h R Sensor Input 1 Base
Count
Stores the reference count value for
sensor input 1 C8h Page 49
51h R Sensor Input 2 Base
Count
Stores the reference count value for
sensor input 2 C8h Page 49
TABLE 6-1: REGISTER SET IN HEXADECIMAL ORDER (CONTINUED)
Register
Address R/W Register Name Function Default Value Page
CAP1128
DS00001622B-page 30 2015 Microchip Technology Inc.
52h R Sensor Input 3 Base
Count
Stores the reference count value for
sensor input 3 C8h Page 49
53h R Sensor Input 4 Base
Count
Stores the reference count value for
sensor input 4 C8h Page 49
54h R Sensor Input 5 Base
Count
Stores the reference count value for
sensor input 5 C8h Page 49
55h R Sensor Input 6 Base
Count
Stores the reference count value for
sensor input 6 C8h Page 49
56h R Sensor Input 7 Base
Count
Stores the reference count value for
sensor input 7 C8h Page 49
57h R Sensor Input 8 Base
Count
Stores the reference count value for
sensor input 8 C8h Page 49
LED Controls
71h R/W LED Output Type Controls the output type for the LED
outputs 00h Page 50
72h R/W Sensor Input LED Linking
Controls linking of sensor inputs to
LED channels 00h Page 50
73h R/W LED Polarity Controls the output polarity of LEDs 00h Page 50
74h R/W LED Output Control Controls the output state of the LEDs 00h Page 51
77h R/W Linked LED
Transition Control
Controls the transition when LEDs are
linked to CS channels 00h Page 52
79h R/W LED Mirror Control Controls the mirroring of duty cycles
for the LEDs 00h Page 53
81h R/W LED Behavior 1 Controls the behavior and response of
LEDs 1 - 2 00h Page 53
84h R/W LED Pulse 1 Period Controls the period of each breathe
during a pulse 20h Page 55
85h R/W LED Pulse 2 Period Controls the period of the breathing
during breathe and pulse operation 14h Page 56
86h R/W LED Breathe Period Controls the period of an LED breathe
operation 5Dh Page 57
88h R/W LED Config Controls LED configuration 04h Page 58
90h R/W LED Pulse 1 Duty Cycle Determines the min and max duty
cycle for the pulse operation F0h Page 58
91h R/W LED Pulse 2 Duty Cycle Determines the min and max duty
cycle for breathe and pulse operation F0h Page 58
92h R/W LED Breathe Duty Cycle Determines the min and max duty
cycle for the breathe operation F0h Page 58
93h R/W LED Direct Duty Cycle Determines the min and max duty
cycle for Direct mode LED operation F0h Page 58
94h R/W LED Direct Ramp Rates Determines the rising and falling edge
ramp rates of the LEDs 00h Page 59
95h R/W LED Off Delay Determines the off delay for all LED
behaviors 00h Page 60
B1h R Sensor Input 1 Calibration
Stores the upper 8-bit calibration value
for sensor input 1 00h Page 63
B2h R Sensor Input 2 Calibration
Stores the upper 8-bit calibration value
for sensor input 2 00h Page 63
TABLE 6-1: REGISTER SET IN HEXADECIMAL ORDER (CONTINUED)
Register
Address R/W Register Name Function Default Value Page
2015 Microchip Technology Inc. DS00001622B-page 31
CAP1128
During Power-On-Reset (POR), the default values are stored in the registers. A POR is initiated when power is first
applied to the part and the voltage on the VDD supply surpasses the POR level as specified in the electrical characteristics.
Any reads to undefined registers will return 00h. Writes to undefined registers will not have an effect.
When a bit is “set”, this means that the user writes a logic ‘1’ to it. When a bit is “cleared”, this means that the user writes
a logic ‘0’ to it.
6.1 Main Control Register
The Main Control register controls the primary power state of the device.
Bits 7 - 6 - GAIN[1:0] - Controls the gain used by the capacitive touch sensing circuitry. As the gain is increased, the
effective sensitivity is likewise increased as a smaller delta capacitance is required to generate the same delta count
values. The sensitivity settings may need to be adjusted along with the gain settings such that data overflow does not
occur.
APPLICATION NOTE: The gain settings apply to both Standby and Active states.
B3h R Sensor Input 3 Calibration
Stores the upper 8-bit calibration value
for sensor input 3 00h Page 63
B4h R Sensor Input 4 Calibration
Stores the upper 8-bit calibration value
for sensor input 4 00h Page 63
B5h R Sensor Input 5 Calibration
Stores the upper 8-bit calibration value
for sensor input 5 00h Page 63
B6h R Sensor Input 6 Calibration
Stores the upper 8-bit calibration value
for sensor input 6 00h Page 63
B7h R Sensor Input 7 Calibration
Stores the upper 8-bit calibration value
for sensor input 7 00h Page 63
B8h R Sensor Input 8 Calibration
Stores the upper 8-bit calibration value
for sensor input 8 00h Page 63
B9h R Sensor Input Calibration
LSB 1
Stores the 2 LSBs of the calibration
value for sensor inputs 1 - 4 00h Page 63
BAh R Sensor Input Calibration
LSB 2
Stores the 2 LSBs of the calibration
value for sensor inputs 5 - 8 00h Page 63
FDh R Product ID Stores a fixed value that identifies
each product 52h Page 63
FEh R Manufacturer ID Stores a fixed value that identifies
Microchip 5Dh Page 64
FFh R Revision Stores a fixed value that represents
the revision number 83h Page 64
TABLE 6-2: MAIN CONTROL REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
00h R/W Main Control GAIN[1:0] STBY DSLEEP - - - INT 00h
TABLE 6-3: GAIN BIT DECODE
GAIN[1:0]
Capacitive Touch Sensor Gain
1 0
0 0 1
01 2
TABLE 6-1: REGISTER SET IN HEXADECIMAL ORDER (CONTINUED)
Register
Address R/W Register Name Function Default Value Page
CAP1128
DS00001622B-page 32 2015 Microchip Technology Inc.
Bit 5 - STBY - Enables Standby.
• ‘0’ (default) - Sensor input scanning is active and LEDs are functional.
• ‘1’ - Capacitive touch sensor input scanning is limited to the sensor inputs set in the Standby Channel register (see
Section 6.20). The status registers will not be cleared until read. LEDs that are linked to capacitive touch sensor
inputs will remain linked and active. Sensor inputs that are no longer sampled will flag a release and then remain
in a non-touched state. LEDs that are manually controlled will be unaffected.
• Bit 4 - DSLEEP - Enables Deep Sleep by deactivating all functions. This bit will be cleared when the WAKE pin is
driven high. ‘0’ (default) - Sensor input scanning is active and LEDs are functional.
• ‘1’ - All sensor input scanning is disabled. All LEDs are driven to their programmed non-actuated state and no
PWM operations will be done. The status registers are automatically cleared and the INT bit is cleared.
Bit 0 - INT - Indicates that there is an interrupt. When this bit is set, it asserts the ALERT# pin. If a channel detects a
touch and its associated interrupt enable bit is not set to a logic ‘1’, no action is taken.
This bit is cleared by writing a logic ‘0’ to it. When this bit is cleared, the ALERT# pin will be deasserted and all status
registers will be cleared if the condition has been removed. If the WAKE/SPI_MOSI pin is asserted as a result of a touch
detected while in Standby, it will likewise be deasserted when this bit is cleared.
Note that the WAKE / SPI_MOSI pin is not driven when communicating via the 4-wire SPI protocol.
• ‘0’ - No interrupt pending.
• ‘1’ - A touch has been detected on one or more channels and the interrupt has been asserted.
6.2 Status Registers
All status bits are cleared when the device enters the Deep Sleep (DSLEEP = ‘1’ - see Section 6.1).
6.2.1 GENERAL STATUS - 02H
Bit 4 - LED - Indicates that one or more LEDs have finished their programmed activity. This bit is set if any bit in the LED
Status register is set.
Bit 3 - RESET - Indicates that the device has come out of reset. This bit is set when the device exits a POR state or
when the RESET pin has been deasserted and qualified via the RESET pin filter (see Section 5.2). This bit will cause
the INT bit to be set and is cleared when the INT bit is cleared.
Bit 2 - MULT - Indicates that the device is blocking detected touches due to the Multiple Touch detection circuitry (see
Section 6.14). This bit will not cause the INT bit to be set and hence will not cause an interrupt.
Bit 1 - MTP - Indicates that the device has detected a number of sensor inputs that exceed the MTP threshold either via
the pattern recognition or via the number of sensor inputs (see Section 6.15). This bit will cause the INT bit to be set if
the MTP_ALERT bit is also set. This bit will not be cleared until the condition that caused it to be set has been removed.
Bit 0 - TOUCH - Indicates that a touch was detected. This bit is set if any bit in the Sensor Input Status register is set.
10 4
11 8
TABLE 6-4: STATUS REGISTERS
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
02h R General Status - - - LED RESET MULT MTP TOUCH 00h
03h R Sensor Input Status
CS8 CS7 CS6 CS5 CS4 CS3 CS2 CS1 00h
04h R LED Status - - - - - - LED2_
DN
LED1_
DN 00h
TABLE 6-3: GAIN BIT DECODE (CONTINUED)
GAIN[1:0]
Capacitive Touch Sensor Gain
1 0
2015 Microchip Technology Inc. DS00001622B-page 33
CAP1128
6.2.2 SENSOR INPUT STATUS - 03H
The Sensor Input Status Register stores status bits that indicate a touch has been detected. A value of ‘0’ in any bit
indicates that no touch has been detected. A value of ‘1’ in any bit indicates that a touch has been detected.
All bits are cleared when the INT bit is cleared and if a touch on the respective capacitive touch sensor input is no longer
present. If a touch is still detected, the bits will not be cleared (but this will not cause the interrupt to be asserted - see
Section 6.6).
Bit 7 - CS8 - Indicates that a touch was detected on Sensor Input 8.
Bit 6 - CS7 - Indicates that a touch was detected on Sensor Input 7.
Bit 5 - CS6 - Indicates that a touch was detected on Sensor Input 6.
Bit 4 - CS5 - Indicates that a touch was detected on Sensor Input 5.
Bit 3 - CS4 - Indicates that a touch was detected on Sensor Input 4.
Bit 2 - CS3 - Indicates that a touch was detected on Sensor Input 3.
Bit 1 - CS2 - Indicates that a touch was detected on Sensor Input 2. This sensor input can be linked to LED2.
Bit 0 - CS1 - Indicates that a touch was detected on Sensor Input 1. This sensor input can be linked to LED1.
6.2.3 LED STATUS - 04H
The LED Status Registers indicate when an LED has completed its configured behavior (see Section 6.31, "LED Behavior
Register") after being actuated by the host (see Section 6.28, "LED Output Control Register"). These bits are ignored
when the LED is linked to a capacitive sensor input. All LED Status bits are cleared when the INT bit is cleared.
Bit 1 - LED2_DN - Indicates that LED2 has finished its behavior after being actuated by the host.
Bit 0 - LED1_DN - Indicates that LED1 has finished its behavior after being actuated by the host.
6.3 Noise Flag Status Registers
The Noise Flag Status registers store status bits that are generated from the analog block if the detected noise is above
the operating region of the analog detector or the RF noise detector. These bits indicate that the most recently received
data from the sensor input is invalid and should not be used for touch detection. So long as the bit is set for a particular
channel, the delta count value is reset to 00h and thus no touch is detected.
These bits are not sticky and will be cleared automatically if the analog block does not report a noise error.
APPLICATION NOTE: If the MTP detection circuitry is enabled, these bits count as sensor inputs above the MTP
threshold (see Section 5.5.4, "Multiple Touch Pattern Detection") even if the corresponding
delta count is not. If the corresponding delta count also exceeds the MTP threshold, it is not
counted twice.
APPLICATION NOTE: Regardless of the state of the Noise Status bits, if low frequency noise is detected on a
sensor input, that sample will be discarded unless the DIS_ANA_NOISE bit is set. As well,
if RF noise is detected on a sensor input, that sample will be discarded unless the
DIS_RF_NOISE bit is set.
TABLE 6-5: NOISE FLAG STATUS REGISTERS
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
0Ah R Noise Flag Status CS8_
NOISE
CS7_
NOISE
CS6_
NOISE
CS5_
NOISE
CS4_
NOISE
CS3_
NOISE
CS2_
NOISE
CS1_
NOISE 00h
CAP1128
DS00001622B-page 34 2015 Microchip Technology Inc.
6.4 Sensor Input Delta Count Registers
The Sensor Input Delta Count registers store the delta count that is compared against the threshold used to determine
if a touch has been detected. The count value represents a change in input due to the capacitance associated with a
touch on one of the sensor inputs and is referenced to a calibrated base “Not Touched” count value. The delta is an
instantaneous change and is updated once per sensor input per sensing cycle (see Section 5.5.1, "Sensing Cycle").
The value presented is a standard 2’s complement number. In addition, the value is capped at a value of 7Fh. A reading
of 7Fh indicates that the sensitivity settings are too high and should be adjusted accordingly (see Section 6.5).
The value is also capped at a negative value of 80h for negative delta counts which may result upon a release.
6.5 Sensitivity Control Register
The Sensitivity Control register controls the sensitivity of a touch detection.
Bits 6-4 DELTA_SENSE[2:0] - Controls the sensitivity of a touch detection. The sensitivity settings act to scale the relative
delta count value higher or lower based on the system parameters. A setting of 000b is the most sensitive while a
setting of 111b is the least sensitive. At the more sensitive settings, touches are detected for a smaller delta capacitance
corresponding to a “lighter” touch. These settings are more sensitive to noise, however, and a noisy environment may
flag more false touches with higher sensitivity levels.
APPLICATION NOTE: A value of 128x is the most sensitive setting available. At the most sensitivity settings, the
MSB of the Delta Count register represents 64 out of ~25,000 which corresponds to a touch
of approximately 0.25% of the base capacitance (or a ΔC of 25fF from a 10pF base
capacitance). Conversely, a value of 1x is the least sensitive setting available. At these
settings, the MSB of the Delta Count register corresponds to a delta count of 8192 counts
out of ~25,000 which corresponds to a touch of approximately 33% of the base capacitance
(or a ΔC of 3.33pF from a 10pF base capacitance).
TABLE 6-6: SENSOR INPUT DELTA COUNT REGISTERS
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
10h R Sensor Input 1
Delta Count Sign 64 32 16 8 4 2 1 00h
11h R Sensor Input 2
Delta Count Sign 64 32 16 8 4 2 1 00h
12h R Sensor Input 3
Delta Count Sign 64 32 16 8 4 2 1 00h
13h R Sensor Input 4
Delta Count Sign 64 32 16 8 4 2 1 00h
14h R Sensor Input 5
Delta Count Sign 64 32 16 8 4 2 1 00h
15h R Sensor Input 6
Delta Count Sign 64 32 16 8 4 2 1 00h
16h R Sensor Input 7
Delta Count Sign 64 32 16 8 4 2 1 00h
17h R Sensor Input 8
Delta Count Sign 64 32 16 8 4 2 1 00h
TABLE 6-7: SENSITIVITY CONTROL REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
1Fh R/W Sensitivity Control - DELTA_SENSE[2:0] BASE_SHIFT[3:0] 2Fh
2015 Microchip Technology Inc. DS00001622B-page 35
CAP1128
Bits 3 - 0 - BASE_SHIFT[3:0] - Controls the scaling and data presentation of the Base Count registers. The higher the
value of these bits, the larger the range and the lower the resolution of the data presented. The scale factor represents
the multiplier to the bit-weighting presented in these register descriptions.
APPLICATION NOTE: The BASE_SHIFT[3:0] bits normally do not need to be updated. These settings will not affect
touch detection or sensitivity. These bits are sometimes helpful in analyzing the Cap Sensing
board performance and stability.
TABLE 6-8: DELTA_SENSE BIT DECODE
DELTA_SENSE[2:0]
Sensitivity Multiplier
210
0 0 0 128x (most sensitive)
0 0 1 64x
0 1 0 32x (default)
0 1 1 16x
1 0 0 8x
1 0 1 4x
1 1 0 2x
1 1 1 1x - (least sensitive)
TABLE 6-9: BASE_SHIFT BIT DECODE
BASE_SHIFT[3:0]
Data Scaling Factor
32 1 0
0 0 0 0 1x
0 0 0 1 2x
0 0 1 0 4x
0 0 1 1 8x
0 1 0 0 16x
0 1 0 1 32x
0 1 1 0 64x
0 1 1 1 128x
1 0 0 0 256x
All others 256x
(default = 1111b)
CAP1128
DS00001622B-page 36 2015 Microchip Technology Inc.
6.6 Configuration Registers
The Configuration registers control general global functionality that affects the entire device.
6.6.1 CONFIGURATION - 20H
Bit 7 - TIMEOUT - Enables the timeout and idle functionality of the SMBus protocol.
• ‘0’ (default for Functional Revision C) - The SMBus timeout and idle functionality are disabled. The SMBus interface
will not time out if the clock line is held low. Likewise, it will not reset if both the data and clock lines are held
high for longer than 200us. This is used for I2C compliance.
• ‘1’ (default for Functional Revision B) - The SMBus timeout and idle functionality are enabled. The SMBus interface
will time out if the clock line is held low for longer than 30ms. Likewise, it will reset if both the data and clock
lines are held high for longer than 200us.
Bit 6 - WAKE_CFG - Configures the operation of the WAKE pin.
• ‘0’ (default) - The WAKE pin is not asserted when a touch is detected while the device is in Standby. It will still be
used to wake the device from Deep Sleep when driven high.
• ‘1’ - The WAKE pin will be asserted high when a touch is detected while the device is in Standby. It will also be
used to wake the device from Deep Sleep when driven high.
Bit 5 - DIS_DIG_NOISE - Determines whether the digital noise threshold (see Section 6.19, "Sensor Input Noise Threshold
Register") is used by the device. Setting this bit disables the feature.
• ‘0’ - The digital noise threshold is used. If a delta count value exceeds the noise threshold but does not exceed the
touch threshold, the sample is discarded and not used for the automatic re-calibration routine.
• ‘1’ (default) - The noise threshold is disabled. Any delta count that is less than the touch threshold is used for the
automatic re-calibration routine.
Bit 4 - DIS_ANA_NOISE - Determines whether the analog noise filter is enabled. Setting this bit disables the feature.
• ‘0’ (default) - If low frequency noise is detected by the analog block, the delta count on the corresponding channel
is set to 0. Note that this does not require that Noise Status bits be set.
• ‘1’ - A touch is not blocked even if low frequency noise is detected.
Bit 3 - MAX_DUR_EN - Determines whether the maximum duration recalibration is enabled.
• ‘0’ (default) - The maximum duration recalibration functionality is disabled. A touch may be held indefinitely and no
re-calibration will be performed on any sensor input.
• ‘1’ - The maximum duration recalibration functionality is enabled. If a touch is held for longer than the MAX_DUR
bit settings, then the re-calibration routine will be restarted (see Section 6.8).
6.6.2 CONFIGURATION 2 - 44H
Bit 7 - INV_LINK_TRAN - Determines the behavior of the Linked LED Transition controls (see Section 6.29).
• ‘0’ (default) - The Linked LED Transition controls set the min duty cycle equal to the max duty cycle.
• ‘1’ - The Linked LED Transition controls will invert the touch signal. For example, a touch signal will be inverted to
a non-touched signal.
Bit 6 - ALT_POL - Determines the ALERT# pin polarity and behavior.
• ‘0’ - The ALERT# pin is active high and push-pull.
• ‘1’ (default) - The ALERT# pin is active low and open drain.
TABLE 6-10: CONFIGURATION REGISTERS
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
20h R/W Configuration TIMEOUT WAKE_
CFG
DIS_ DIG_
NOISE
DIS_ ANA_
NOISE
MAX_
DUR_EN - --
A0h
(Rev B)
20h
(rev C)
44h R/W Configuration 2 INV_LINK_
TRAN
ALT_
POL
BLK_PWR_
CTRL
BLK_POL_
MIR
SHOW_
RF_
NOISE
DIS_
RF_
NOISE
- INT_
REL_n 40h
2015 Microchip Technology Inc. DS00001622B-page 37
CAP1128
Bit 5 - BLK_PWR_CTRL - Determines whether the device will reduce power consumption while waiting between conversion
time completion and the end of the polling cycle.
• ‘0’ (default) - The device will always power down as much as possible during the time between the end of the last
conversion and the end of the polling cycle.
• ‘1’ - The device will not power down the Cap Sensor during the time between the end of the last conversion and
the end of the polling cycle.
Bit 4 - BLK_POL_MIR - Determines whether the LED Mirror Control register bits are linked to the LED Polarity bits. Setting
this bit blocks the normal behavior which is to automatically set and clear the LED Mirror Control bits when the LED
Polarity bits are set or cleared.
• ‘0’ (default) - When the LED Polarity controls are set, the corresponding LED Mirror control is automatically set.
Likewise, when the LED Polarity controls are cleared, the corresponding LED Mirror control is also cleared.
• ‘1’ - When the LED Polarity controls are set, the corresponding LED Mirror control is not automatically set.
Bit 3 - SHOW_RF_NOISE - Determines whether the Noise Status bits will show RF Noise as the only input source.
• ‘0’ (default) - The Noise Status registers will show both RF noise and low frequency EMI noise if either is detected
on a capacitive touch sensor input.
• ‘1’ - The Noise Status registers will only show RF noise if it is detected on a capacitive touch sensor input. EMI
noise will still be detected and touches will be blocked normally; however, the status bits will not be updated.
Bit 2 - DIS_RF_NOISE - Determines whether the RF noise filter is enabled. Setting this bit disables the feature.
• ‘0’ (default) - If RF noise is detected by the analog block, the delta count on the corresponding channel is set to 0.
Note that this does not require that Noise Status bits be set.
• ‘1’ - A touch is not blocked even if RF noise is detected.
Bit 0 - INT_REL_n - Controls the interrupt behavior when a release is detected on a button.
• ‘0’ (default) - An interrupt is generated when a press is detected and again when a release is detected and at the
repeat rate (if enabled - see Section 6.13).
• ‘1’ - An interrupt is generated when a press is detected and at the repeat rate but not when a release is detected.
6.7 Sensor Input Enable Registers
The Sensor Input Enable registers determine whether a capacitive touch sensor input is included in the sampling cycle.
The length of the sampling cycle is not affected by the number of sensor inputs measured.
Bit 7 - CS8_EN - Enables the CS8 input to be included during the sampling cycle.
• ‘0’ - The CS8 input is not included in the sampling cycle.
• ‘1’ (default) - The CS8 input is included in the sampling cycle.
Bit 6 - CS7_EN - Enables the CS7 input to be included during the sampling cycle.
Bit 5 - CS6_EN - Enables the CS6 input to be included during the sampling cycle.
Bit 4 - CS5_EN - Enables the CS5 input to be included during the sampling cycle.
Bit 3 - CS4_EN - Enables the CS4 input to be included during the sampling cycle.
Bit 2 - CS3_EN - Enables the CS3 input to be included during the sampling cycle.
Bit 1 - CS2_EN - Enables the CS2 input to be included during the sampling cycle.
Bit 0 - CS1_EN - Enables the CS1 input to be included during the sampling cycle.
TABLE 6-11: SENSOR INPUT ENABLE REGISTERS
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
21h R/W Sensor Input
Enable CS8_EN CS7_EN CS6_EN CS5_EN CS4_EN CS3_EN CS2_EN CS1_EN FFh
CAP1128
DS00001622B-page 38 2015 Microchip Technology Inc.
6.8 Sensor Input Configuration Register
The Sensor Input Configuration Register controls timings associated with the Capacitive sensor inputs 1 - 8.
Bits 7 - 4 - MAX_DUR[3:0] - (default 1010b) - Determines the maximum time that a sensor pad is allowed to be touched
until the capacitive touch sensor input is recalibrated, as shown in Table 6-13.
Bits 3 - 0 - RPT_RATE[3:0] - (default 0100b) Determines the time duration between interrupt assertions when auto
repeat is enabled. The resolution is 35ms the range is from 35ms to 560ms as shown in Table 6-14.
TABLE 6-12: SENSOR INPUT CONFIGURATION REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
22h R/W Sensor Input
Configuration MAX_DUR[3:0] RPT_RATE[3:0] A4h
TABLE 6-13: MAX_DUR BIT DECODE
MAX_DUR[3:0]
Time Before Recalibration
32 1 0
0 0 0 0 560ms
0 0 0 1 840ms
0 0 1 0 1120ms
0 0 1 1 1400ms
0 1 0 0 1680ms
0 1 0 1 2240ms
0 1 1 0 2800ms
1 1 1 3360ms
1 0 0 0 3920ms
1 0 0 1 4480ms
1 0 1 0 5600ms (default)
1 0 1 1 6720ms
1 1 0 0 7840ms
1 1 0 1 8906ms
1 1 1 0 10080ms
1 1 1 1 11200ms
TABLE 6-14: RPT_RATE BIT DECODE
RPT_RATE[3:0]
Interrupt Repeat RATE
3 21 0
0 0 0 0 35ms
0 0 0 1 70ms
0 0 1 0 105ms
0 0 1 1 140ms
0 1 0 0 175ms (default)
0 1 0 1 210ms
0 1 1 0 245ms
0 1 1 1 280ms
1 0 0 0 315ms
1 0 0 1 350ms
1 0 1 0 385ms
2015 Microchip Technology Inc. DS00001622B-page 39
CAP1128
6.9 Sensor Input Configuration 2 Register
Bits 3 - 0 - M_PRESS[3:0] - (default 0111b) - Determines the minimum amount of time that sensor inputs configured to
use auto repeat must detect a sensor pad touch to detect a “press and hold” event. If the sensor input detects a touch
for longer than the M_PRESS[3:0] settings, a “press and hold” event is detected. If a sensor input detects a touch for
less than or equal to the M_PRESS[3:0] settings, a touch event is detected.
The resolution is 35ms the range is from 35ms to 560ms as shown in Table 6-16.
6.10 Averaging and Sampling Configuration Register
1 0 1 1 420ms
1 1 0 0 455ms
1 1 0 1 490ms
1 1 1 0 525ms
1 1 1 1 560ms
TABLE 6-15: SENSOR INPUT CONFIGURATION 2 REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
23h R/W Sensor Input
Configuration 2 - - - - M_PRESS[3:0] 07h
TABLE 6-16: M_PRESS BIT DECODE
M_PRESS[3:0]
M_PRESS SETTINGS
3 21 0
0 0 0 0 35ms
0 0 0 1 70ms
0 0 1 0 105ms
0 0 1 1 140ms
0 1 0 0 175ms
0 1 0 1 210ms
0 1 1 0 245ms
0 1 1 1 280ms (default)
1 0 0 0 315ms
1 0 0 1 350ms
1 0 1 0 385ms
1 0 1 1 420ms
1 1 0 0 455ms
1 1 0 1 490ms
1 1 1 0 525ms
1 1 1 1 560ms
TABLE 6-17: AVERAGING AND SAMPLING CONFIGURATION REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
24h R/W Averaging and
Sampling Config AVG[2:0] SAMP_TIME[1:0] CYCLE_TIME
[1:0] 39h
TABLE 6-14: RPT_RATE BIT DECODE (CONTINUED)
RPT_RATE[3:0]
Interrupt Repeat RATE
3 21 0
CAP1128
DS00001622B-page 40 2015 Microchip Technology Inc.
The Averaging and Sampling Configuration register controls the number of samples taken and the total sensor input
cycle time for all active sensor inputs while the device is functioning in Active state.
Bits 6 - 4 - AVG[2:0] - Determines the number of samples that are taken for all active channels during the sensor cycle
as shown in Table 6-18. All samples are taken consecutively on the same channel before the next channel is sampled
and the result is averaged over the number of samples measured before updating the measured results.
For example, if CS1, CS2, and CS3 are sampled during the sensor cycle, and the AVG[2:0] bits are set to take 4 samples
per channel, then the full sensor cycle will be: CS1, CS1, CS1, CS1, CS2, CS2, CS2, CS2, CS3, CS3, CS3, CS3.
Bits 3 - 2 - SAMP_TIME[1:0] - Determines the time to take a single sample as shown in Table 6-19.
Bits 1 - 0 - CYCLE_TIME[1:0] - Determines the overall cycle time for all measured channels during normal operation as
shown in Table 6-20. All measured channels are sampled at the beginning of the cycle time. If additional time is remaining,
then the device is placed into a lower power state for the remaining duration of the cycle.
APPLICATION NOTE: The programmed cycle time is only maintained if the total averaging time for all samples is
less than the programmed cycle. The AVG[2:0] bits will take priority so that if more samples
are required than would normally be allowed during the cycle time, the cycle time will be
extended as necessary to accommodate the number of samples to be measured.
TABLE 6-18: AVG BIT DECODE
AVG[2:0] Number of Samples Taken per
Measurement 2 10
0 0 0 1
0 01 2
0 10 4
0 1 1 8 (default)
1 0 0 16
1 0 1 32
1 1 0 64
1 1 1 128
TABLE 6-19: SAMP_TIME BIT DECODE
SAMP_TIME[1:0]
Sample Time
1 0
0 0 320us
0 1 640us
1 0 1.28ms (default)
1 1 2.56ms
TABLE 6-20: CYCLE_TIME BIT DECODE
CYCLE_TIME[1:0]
Overall Cycle Time
1 0
0 0 35ms
0 1 70ms (default)
1 0 105ms
1 1 140ms
2015 Microchip Technology Inc. DS00001622B-page 41
CAP1128
6.11 Calibration Activate Register
The Calibration Activate register forces the respective sensor inputs to be re-calibrated affecting both the analog and
digital blocks. During the re-calibration routine, the sensor inputs will not detect a press for up to 600ms and the Sensor
Input Base Count register values will be invalid. During this time, any press on the corresponding sensor pads will invalidate
the re-calibration. When finished, the CALX[9:0] bits will be updated (see Section 6.39).
When the corresponding bit is set, the device will perform the calibration and the bit will be automatically cleared once
the re-calibration routine has finished.
Bit 7 - CS8_CAL - When set, the CS8 input is re-calibrated. This bit is automatically cleared once the sensor input has
been re-calibrated successfully.
Bit 6 - CS7_CAL - When set, the CS7 input is re-calibrated. This bit is automatically cleared once the sensor input has
been re-calibrated successfully.
Bit 5 - CS6_CAL - When set, the CS6 input is re-calibrated. This bit is automatically cleared once the sensor input has
been re-calibrated successfully.
Bit 4 - CS5_CAL - When set, the CS5 input is re-calibrated. This bit is automatically cleared once the sensor input has
been re-calibrated successfully.
Bit 3 - CS4_CAL - When set, the CS4 input is re-calibrated. This bit is automatically cleared once the sensor input has
been re-calibrated successfully.
Bit 2 - CS3_CAL - When set, the CS3 input is re-calibrated. This bit is automatically cleared once the sensor input has
been re-calibrated successfully.
Bit 1 - CS2_CAL - When set, the CS2 input is re-calibrated. This bit is automatically cleared once the sensor input has
been re-calibrated successfully.
Bit 0 - CS1_CAL - When set, the CS1 input is re-calibrated. This bit is automatically cleared once the sensor input has
been re-calibrated successfully.
6.12 Interrupt Enable Register
The Interrupt Enable register determines whether a sensor pad touch or release (if enabled) causes the interrupt pin to
be asserted.
Bit 7 - CS8_INT_EN - Enables the interrupt pin to be asserted if a touch is detected on CS8 (associated with the CS8
status bit).
• ‘0’ - The interrupt pin will not be asserted if a touch is detected on CS8 (associated with the CS8 status bit).
• ‘1’ (default) - The interrupt pin will be asserted if a touch is detected on CS8 (associated with the CS8 status bit).
Bit 6 - CS7_INT_EN - Enables the interrupt pin to be asserted if a touch is detected on CS7 (associated with the CS7
status bit).
Bit 5 - CS6_INT_EN - Enables the interrupt pin to be asserted if a touch is detected on CS6 (associated with the CS6
status bit).
Bit 4 - CS5_INT_EN - Enables the interrupt pin to be asserted if a touch is detected on CS5 (associated with the CS5
status bit).
Bit 3 - CS4_INT_EN - Enables the interrupt pin to be asserted if a touch is detected on CS4 (associated with the CS4
status bit).
TABLE 6-21: CALIBRATION ACTIVATE REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
26h R/W Calibration
Activate
CS8_
CAL
CS7_
CAL
CS6_
CAL
CS5_
CAL
CS4_
CAL
CS3_
CAL
CS2_
CAL
CS1_
CAL 00h
TABLE 6-22: INTERRUPT ENABLE REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
27h R/W Interrupt
Enable
CS8_
INT_EN
CS7_
INT_EN
CS6_
INT_EN
CS5_
INT_EN
CS4_
INT_EN
CS3_
INT_EN
CS2_
INT_EN
CS1_
INT_EN FFh
CAP1128
DS00001622B-page 42 2015 Microchip Technology Inc.
Bit 2 - CS3_INT_EN - Enables the interrupt pin to be asserted if a touch is detected on CS3 (associated with the CS3
status bit).
Bit 1 - CS2_INT_EN - Enables the interrupt pin to be asserted if a touch is detected on CS2 (associated with the CS2
status bit).
Bit 0 - CS1_INT_EN - Enables the interrupt pin to be asserted if a touch is detected on CS1 (associated with the CS1
status bit).
6.13 Repeat Rate Enable Register
The Repeat Rate Enable register enables the repeat rate of the sensor inputs as described in Section 5.6.1.
Bit 7 - CS8_RPT_EN - Enables the repeat rate for capacitive touch sensor input 8.
• ‘0’ - The repeat rate for CS8 is disabled. It will only generate an interrupt when a touch is detected and when a
release is detected (if enabled) no matter how long the touch is held for.
• ‘1’ (default) - The repeat rate for CS8 is enabled. In the case of a “touch” event, it will generate an interrupt when a
touch is detected and a release is detected (as determined by the INT_REL_n bit - see Section 6.6). In the case of
a “press and hold” event, it will generate an interrupt when a touch is detected and at the repeat rate so long as
the touch is held.
Bit 6 - CS7_RPT_EN - Enables the repeat rate for capacitive touch sensor input 7.
Bit 5 - CS6_RPT_EN - Enables the repeat rate for capacitive touch sensor input 6.
Bit 4 - CS5_RPT_EN - Enables the repeat rate for capacitive touch sensor input 5.
Bit 3 - CS4_RPT_EN - Enables the repeat rate for capacitive touch sensor input 4.
Bit 2 - CS3_RPT_EN - Enables the repeat rate for capacitive touch sensor input 3.
Bit 1 - CS2_RPT_EN - Enables the repeat rate for capacitive touch sensor input 2.
Bit 0 - CS1_RPT_EN - Enables the repeat rate for capacitive touch sensor input 1.
6.14 Multiple Touch Configuration Register
The Multiple Touch Configuration register controls the settings for the multiple touch detection circuitry. These settings
determine the number of simultaneous buttons that may be pressed before additional buttons are blocked and the MULT
status bit is set.
Bit 7 - MULT_BLK_EN - Enables the multiple button blocking circuitry.
• ‘0’ - The multiple touch circuitry is disabled. The device will not block multiple touches.
• ‘1’ (default) - The multiple touch circuitry is enabled. The device will flag the number of touches equal to programmed
multiple touch threshold and block all others. It will remember which sensor inputs are valid and block all
others until that sensor pad has been released. Once a sensor pad has been released, the N detected touches
(determined via the cycle order of CS1 - CS8) will be flagged and all others blocked.
Bits 3 - 2 - B_MULT_T[1:0] - Determines the number of simultaneous touches on all sensor pads before a Multiple Touch
Event is detected and sensor inputs are blocked. The bit decode is given by Table 6-25.
TABLE 6-23: REPEAT RATE ENABLE REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
28h R/W Repeat Rate
Enable
CS8_
RPT_EN
CS7_
RPT_EN
CS6_
RPT_EN
CS5_
RPT_EN
CS4_
RPT_EN
CS3_
RPT_EN
CS2_
RPT_EN
CS1_
RPT_EN FFh
TABLE 6-24: MULTIPLE TOUCH CONFIGURATION
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
2Ah R/W Multiple Touch
Config
MULT_
BLK_
EN
- - - B_MULT_T[1:0] - - 80h
2015 Microchip Technology Inc. DS00001622B-page 43
CAP1128
6.15 Multiple Touch Pattern Configuration Register
The Multiple Touch Pattern Configuration register controls the settings for the multiple touch pattern detection circuitry.
This circuitry works like the multiple touch detection circuitry with the following differences:
1. The detection threshold is a percentage of the touch detection threshold as defined by the MTP_TH[1:0] bits
whereas the multiple touch circuitry uses the touch detection threshold.
2. The MTP detection circuitry either will detect a specific pattern of sensor inputs as determined by the Multiple
Touch Pattern register settings or it will use the Multiple Touch Pattern register settings to determine a minimum
number of sensor inputs that will cause the MTP circuitry to flag an event. When using pattern recognition mode,
if all of the sensor inputs set by the Multiple Touch Pattern register have a delta count greater than the MTP
threshold or have their corresponding Noise Flag Status bits set, the MTP bit will be set. When using the absolute
number mode, if the number of sensor inputs with thresholds above the MTP threshold or with Noise Flag Status
bits set is equal to or greater than this number, the MTP bit will be set.
3. When an MTP event occurs, all touches are blocked and an interrupt is generated.
4. All sensor inputs will remain blocked so long as the requisite number of sensor inputs are above the MTP threshold
or have Noise Flag Status bits set. Once this condition is removed, touch detection will be restored. Note that
the MTP status bit is only cleared by writing a ‘0’ to the INT bit once the condition has been removed.
Bit 7 - MTP_EN - Enables the multiple touch pattern detection circuitry.
• ‘0’ (default) - The MTP detection circuitry is disabled.
• ‘1’ - The MTP detection circuitry is enabled.
Bits 3-2 - MTP_TH[1:0] - Determine the MTP threshold, as shown in Table 6-27. This threshold is a percentage of sensor
input threshold (see Section 6.18, "Sensor Input Threshold Registers") when the device is in the Fully Active state or of
the standby threshold (see Section 6.23, "Standby Threshold Register") when the device is in the Standby state.
Bit 1 - COMP_PTRN - Determines whether the MTP detection circuitry will use the Multiple Touch Pattern register as a
specific pattern of sensor inputs or as an absolute number of sensor inputs.
• ‘0’ (default) - The MTP detection circuitry will use the Multiple Touch Pattern register bit settings as an absolute
minimum number of sensor inputs that must be above the threshold or have Noise Flag Status bits set. The number
will be equal to the number of bits set in the register.
TABLE 6-25: B_MULT_T BIT DECODE
B_MULT_T[1:0]
Number of Simultaneous Touches
1 0
0 0 1 (default)
01 2
10 3
11 4
TABLE 6-26: MULTIPLE TOUCH PATTERN CONFIGURATION
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
2Bh R/W Multiple Touch
Pattern Config MTP_ EN - - MTP_TH[1:0] COMP_
PTRN
MTP_
ALERT 00h
TABLE 6-27: MTP_TH BIT DECODE
MTP_TH[1:0]
Threshold Divide Setting
1 0
0 0 12.5% (default)
0 1 25%
1 0 37.5%
1 1 100%
CAP1128
DS00001622B-page 44 2015 Microchip Technology Inc.
• ‘1’ - The MTP detection circuitry will use pattern recognition. Each bit set in the Multiple Touch Pattern register
indicates a specific sensor input that must have a delta count greater than the MTP threshold or have a Noise Flag
Status bit set. If the criteria are met, the MTP status bit will be set.
Bit 0 - MTP_ALERT - Enables an interrupt if an MTP event occurs. In either condition, the MTP status bit will be set.
• ‘0’ (default) - If an MTP event occurs, the ALERT# pin is not asserted.
• ‘1’ - If an MTP event occurs, the ALERT# pin will be asserted.
6.16 Multiple Touch Pattern Register
The Multiple Touch Pattern register acts as a pattern to identify an expected sensor input profile for diagnostics or other
significant events. There are two methods for how the Multiple Touch Pattern register is used: as specific sensor inputs
or number of sensor input that must exceed the MTP threshold or have Noise Flag Status bits set. Which method is used
is based on the COMP_PTRN bit (see Section 6.15). The methods are described below.
1. Specific Sensor Inputs: If, during a single polling cycle, the specific sensor inputs above the MTP threshold or
with Noise Flag Status bits set match those bits set in the Multiple Touch Pattern register, an MTP event is
flagged.
2. Number of Sensor Inputs: If, during a single polling cycle, the number of sensor inputs with a delta count above
the MTP threshold or with Noise Flag Status bits set is equal to or greater than the number of pattern bits set, an
MTP event is flagged.
Bit 7 - CS8_PTRN - Determines whether CS8 is considered as part of the Multiple Touch Pattern.
• ‘0’ - CS8 is not considered a part of the pattern.
• ‘1’ - CS8 is considered a part of the pattern, or the absolute number of sensor inputs that must have a delta count
greater than the MTP threshold or have the Noise Flag Status bit set is increased by 1.
Bit 6 - CS7_PTRN - Determines whether CS7 is considered as part of the Multiple Touch Pattern.
Bit 5 - CS6_PTRN - Determines whether CS6 is considered as part of the Multiple Touch Pattern.
Bit 4 - CS5_PTRN - Determines whether CS5 is considered as part of the Multiple Touch Pattern.
Bit 3 - CS4_PTRN - Determines whether CS4 is considered as part of the Multiple Touch Pattern.
Bit 2 - CS3_PTRN - Determines whether CS3 is considered as part of the Multiple Touch Pattern.
Bit 1 - CS2_PTRN - Determines whether CS2 is considered as part of the Multiple Touch Pattern.
Bit 0 - CS1_PTRN - Determines whether CS1 is considered as part of the Multiple Touch Pattern.
6.17 Recalibration Configuration Register
The Recalibration Configuration register controls the automatic re-calibration routine settings as well as advanced controls
to program the Sensor Input Threshold register settings.
Bit 7 - BUT_LD_TH - Enables setting all Sensor Input Threshold registers by writing to the Sensor Input 1 Threshold
register.
• ‘0’ - Each Sensor Input X Threshold register is updated individually.
• ‘1’ (default) - Writing the Sensor Input 1 Threshold register will automatically overwrite the Sensor Input Threshold
registers for all sensor inputs (Sensor Input Threshold 1 through Sensor Input Threshold 8). The individual Sensor
TABLE 6-28: MULTIPLE TOUCH PATTERN REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
2Dh R/W Multiple
Touch Pattern
CS8_
PTRN
CS7_
PTRN
CS6_
PTRN
CS5_
PTRN
CS4_
PTRN
CS3_
PTRN
CS2_
PTRN
CS1_
PTRN FFh
TABLE 6-29: RECALIBRATION CONFIGURATION REGISTERS
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
2Fh R/W Recalibration
Configuration
BUT_
LD_TH
NO_
CLR_
INTD
NO_
CLR_
NEG
NEG_DELTA_
CNT[1:0] CAL_CFG[2:0] 8Ah
2015 Microchip Technology Inc. DS00001622B-page 45
CAP1128
Input X Threshold registers (Sensor Input 2 Threshold through Sensor Input 8 Threshold) can be individually
updated at any time.
Bit 6 - NO_CLR_INTD - Controls whether the accumulation of intermediate data is cleared if the noise status bit is set.
• ‘0’ (default) - The accumulation of intermediate data is cleared if the noise status bit is set.
• ‘1’ - The accumulation of intermediate data is not cleared if the noise status bit is set.
APPLICATION NOTE: Bits 5 and 6 should both be set to the same value. Either both should be set to ‘0’ or both
should be set to ‘1’.
Bit 5 - NO_CLR_NEG - Controls whether the consecutive negative delta counts counter is cleared if the noise status bit
is set.
• ‘0’ (default) - The consecutive negative delta counts counter is cleared if the noise status bit is set.
• ‘1’ - The consecutive negative delta counts counter is not cleared if the noise status bit is set.
Bits 4 - 3 - NEG_DELTA_CNT[1:0] - Determines the number of negative delta counts necessary to trigger a digital recalibration
as shown in Table 6-30.
Bits 2 - 0 - CAL_CFG[2:0] - Determines the update time and number of samples of the automatic re-calibration routine.
The settings apply to all sensor inputs universally (though individual sensor inputs can be configured to support re-calibration
- see Section 6.11).
Note 6-1 Recalibration Samples refers to the number of samples that are measured and averaged before the
Base Count is updated however does not control the base count update period.
Note 6-2 Update Time refers to the amount of time (in polling cycle periods) that elapses before the Base
Count is updated. The time will depend upon the number of channels active, the averaging setting,
and the programmed cycle time.
TABLE 6-30: NEG_DELTA_CNT BIT DECODE
NEG_DELTA_CNT[1:0]
Number of Consecutive Negative Delta Count Values
1 0
00 8
0 1 16 (default)
1 0 32
1 1 None (disabled)
TABLE 6-31: CAL_CFG BIT DECODE
CAL_CFG[2:0] Recalibration Samples
(see Note 6-1)
Update Time (see
Note 6-2) 210
0 0 0 16 16
0 0 1 32 32
0 1 0 64 64 (default)
0 1 1 128 128
1 0 0 256 256
1 0 1 256 1024
1 1 0 256 2048
1 1 1 256 4096
CAP1128
DS00001622B-page 46 2015 Microchip Technology Inc.
6.18 Sensor Input Threshold Registers
The Sensor Input Threshold registers store the delta threshold that is used to determine if a touch has been detected.
When a touch occurs, the input signal of the corresponding sensor pad changes due to the capacitance associated with
a touch. If the sensor input change exceeds the threshold settings, a touch is detected.
When the BUT_LD_TH bit is set (see Section 6.17 - bit 7), writing data to the Sensor Input 1 Threshold register will
update all of the sensor input threshold registers (31h - 37h inclusive).
6.19 Sensor Input Noise Threshold Register
The Sensor Input Noise Threshold register controls the value of a secondary internal threshold to detect noise and
improve the automatic recalibration routine. If a capacitive touch sensor input exceeds the Sensor Input Noise Threshold
but does not exceed the sensor input threshold, it is determined to be caused by a noise spike. That sample is not used
by the automatic re-calibration routine. This feature can be disabled by setting the DIS_DIG_NOISE bit.
Bits 1-0 - CS1_BN_TH[1:0] - Controls the noise threshold for all capacitive touch sensor inputs, as shown in Table 6-34.
The threshold is proportional to the threshold setting.
TABLE 6-32: SENSOR INPUT THRESHOLD REGISTERS
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
30h R/W Sensor Input 1
Threshold - 64 32 16 8 4 2 1 40h
31h R/W Sensor Input 2
Threshold - 64 32 16 8 4 2 1 40h
32h R/W Sensor Input 3
Threshold - 64 32 16 8 4 2 1 40h
33h R/W Sensor Input 4
Threshold - 64 32 16 8 4 2 1 40h
34h R/W Sensor Input 5
Threshold - 64 32 16 8 4 2 1 40h
35h R/W Sensor Input 6
Threshold - 64 32 16 8 4 2 1 40h
36h R/W Sensor Input 7
Threshold - 64 32 16 8 4 2 1 40h
37h R/W Sensor Input 8
Threshold - 64 32 16 8 4 2 1 40h
TABLE 6-33: SENSOR INPUT NOISE THRESHOLD REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
38h R/W Sensor Input
Noise Threshold CS_BN_TH [1:0] 01h
TABLE 6-34: CSX_BN_TH BIT DECODE
CS_BN_TH[1:0]
Percent Threshold Setting
1 0
0 0 25%
0 1 37.5% (default)
1 0 50%
1 1 62.5%
2015 Microchip Technology Inc. DS00001622B-page 47
CAP1128
6.20 Standby Channel Register
The Standby Channel register controls which (if any) capacitive touch sensor inputs are active during Standby.
Bit 7 - CS8_STBY - Controls whether the CS8 channel is active in Standby.
• ‘0’ (default) - The CS8 channel not be sampled during Standby.
• ‘1’ - The CS8 channel will be sampled during Standby. It will use the Standby threshold setting, and the standby
averaging and sensitivity settings.
Bit 6 - CS7_STBY - Controls whether the CS7 channel is active in Standby.
Bit 5 - CS6_STBY - Controls whether the CS6 channel is active in Standby.
Bit 4 - CS5_STBY - Controls whether the CS5 channel is active in Standby.
Bit 3 - CS4_STBY - Controls whether the CS4 channel is active in Standby.
Bit 2 - CS3_STBY - Controls whether the CS3 channel is active in Standby.
Bit 1 - CS2_STBY - Controls whether the CS2 channel is active in Standby.
Bit 0 - CS1_STBY - Controls whether the CS1 channel is active in Standby.
6.21 Standby Configuration Register
The Standby Configuration register controls averaging and cycle time for those sensor inputs that are active in Standby.
This register is useful for detecting proximity on a small number of sensor inputs as it allows the user to change averaging
and sample times on a limited number of sensor inputs and still maintain normal functionality in the fully active
state.
Bit 7 - AVG_SUM - Determines whether the active sensor inputs will average the programmed number of samples or
whether they will accumulate for the programmed number of samples.
• ‘0’ - (default) - The active sensor input delta count values will be based on the average of the programmed number
of samples when compared against the threshold.
• ‘1’ - The active sensor input delta count values will be based on the summation of the programmed number of
samples when compared against the threshold. This bit should only be set when performing proximity detection as
a physical touch will overflow the delta count registers and may result in false readings.
Bits 6 - 4 - STBY_AVG[2:0] - Determines the number of samples that are taken for all active channels during the sensor
cycle as shown in Table 6-37. All samples are taken consecutively on the same channel before the next channel is sampled
and the result is averaged over the number of samples measured before updating the measured results.
TABLE 6-35: STANDBY CHANNEL REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
40h R/W Standby Channel CS8_
STBY
CS7_
STBY
CS6_
STBY
CS5_
STBY
CS4_
STBY
CS3_
STBY
CS2_
STBY
CS1_
STBY 00h
TABLE 6-36: STANDBY CONFIGURATION REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
41h R/W Standby Configuration
AVG_
SUM STBY_AVG[2:0] STBY_SAMP_
TIME[1:0]
STBY_CY_TIME
[1:0] 39h
TABLE 6-37: STBY_AVG BIT DECODE
STBY_AVG[2:0] Number of Samples Taken per
Measurement 2 10
0 0 0 1
0 01 2
0 10 4
0 1 1 8 (default)
1 0 0 16
CAP1128
DS00001622B-page 48 2015 Microchip Technology Inc.
Bit 3-2 - STBY SAMP_TIME[1:0] - Determines the time to take a single sample when the device is in Standby as shown
in Table 6-38.
Bits 1 - 0 - STBY_CY_TIME[2:0] - Determines the overall cycle time for all measured channels during standby operation
as shown in Table 6-39. All measured channels are sampled at the beginning of the cycle time. If additional time is
remaining, the device is placed into a lower power state for the remaining duration of the cycle.
APPLICATION NOTE: The programmed cycle time is only maintained if the total averaging time for all samples is
less than the programmed cycle. The STBY_AVG[2:0] bits will take priority so that if more
samples are required than would normally be allowed during the cycle time, the cycle time
will be extended as necessary to accommodate the number of samples to be measured.
6.22 Standby Sensitivity Register
The Standby Sensitivity register controls the sensitivity for sensor inputs that are active in Standby.
Bits 2 - 0 - STBY_SENSE[2:0] - Controls the sensitivity for sensor inputs that are active in Standby. The sensitivity settings
act to scale the relative delta count value higher or lower based on the system parameters. A setting of 000b is the
most sensitive while a setting of 111b is the least sensitive. At the more sensitive settings, touches are detected for a
smaller delta C corresponding to a “lighter” touch. These settings are more sensitive to noise however and a noisy environment
may flag more false touches than higher sensitivity levels.
APPLICATION NOTE: A value of 128x is the most sensitive setting available. At the most sensitivity settings, the
MSB of the Delta Count register represents 64 out of ~25,000 which corresponds to a touch
1 0 1 32
1 1 0 64
1 1 1 128
TABLE 6-38: STBY_SAMP_TIME BIT DECODE
STBY_SAMP_TIME[1:0]
Sampling Time
1 0
0 0 320us
0 1 640us
1 0 1.28ms (default)
1 1 2.56ms
TABLE 6-39: STBY_CY_TIME BIT DECODE
STBY_CY_TIME[1:0]
Overall Cycle Time
1 0
0 0 35ms
0 1 70ms (default)
1 0 105ms
1 1 140ms
TABLE 6-40: STANDBY SENSITIVITY REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
42h R/W Standby Sensitivity
- - - - - STBY_SENSE[2:0] 02h
TABLE 6-37: STBY_AVG BIT DECODE (CONTINUED)
STBY_AVG[2:0] Number of Samples Taken per
Measurement 2 10
2015 Microchip Technology Inc. DS00001622B-page 49
CAP1128
of approximately 0.25% of the base capacitance (or a ΔC of 25fF from a 10pF base
capacitance). Conversely a value of 1x is the least sensitive setting available. At these
settings, the MSB of the Delta Count register corresponds to a delta count of 8192 counts
out of ~25,000 which corresponds to a touch of approximately 33% of the base capacitance
(or a ΔC of 3.33pF from a 10pF base capacitance).
6.23 Standby Threshold Register
The Standby Threshold register stores the delta threshold that is used to determine if a touch has been detected. When
a touch occurs, the input signal of the corresponding sensor pad changes due to the capacitance associated with a
touch. If the sensor input change exceeds the threshold settings, a touch is detected.
6.24 Sensor Input Base Count Registers
The Sensor Input Base Count registers store the calibrated “Not Touched” input value from the capacitive touch sensor
inputs. These registers are periodically updated by the re-calibration routine.
TABLE 6-41: STBY_SENSE BIT DECODE
STBY_SENSE[2:0]
Sensitivity Multiplier
210
0 0 0 128x (most sensitive)
0 0 1 64x
0 1 0 32x (default)
0 1 1 16x
1 0 0 8x
1 0 1 4x
1 1 0 2x
1 1 1 1x - (least sensitive)
TABLE 6-42: STANDBY THRESHOLD REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
43h R/W Standby Threshold
- 64 32 16 8 4 2 1 40h
TABLE 6-43: SENSOR INPUT BASE COUNT REGISTERS
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
50h R Sensor Input 1
Base Count 128 64 32 16 8 4 2 1 C8h
51h R Sensor Input 2
Base Count 128 64 32 16 8 4 2 1 C8h
52h R Sensor Input 3
Base Count 128 64 32 16 8 4 2 1 C8h
53h R Sensor Input 4
Base Count 128 64 32 16 8 4 2 1 C8h
54h R Sensor Input 5
Base Count 128 64 32 16 8 4 2 1 C8h
55h R Sensor Input 6
Base Count 128 64 32 16 8 4 2 1 C8h
56h R Sensor Input 7
Base Count 128 64 32 16 8 4 2 1 C8h
57h R Sensor Input 8
Base Count 128 64 32 16 8 4 2 1 C8h
CAP1128
DS00001622B-page 50 2015 Microchip Technology Inc.
The routine uses an internal adder to add the current count value for each reading to the sum of the previous readings
until sample size has been reached. At this point, the upper 16 bits are taken and used as the Sensor Input Base Count.
The internal adder is then reset and the re-calibration routine continues.
The data presented is determined by the BASE_SHIFT[3:0] bits (see Section 6.5).
6.25 LED Output Type Register
The LED Output Type register controls the type of output for the LED pins. Each pin is controlled by a single bit. Refer
to application note 21.4 CAP1128Family LED Configuration Options for more information about implementing LEDs.
Bit 1 - LED2_OT - Determines the output type of the LED2 pin.
• ‘0’ (default) - The LED2 pin is an open-drain output with an external pull-up resistor. When the appropriate pin is
set to the “active” state (logic ‘1’), the pin will be driven low. Conversely, when the pin is set to the “inactive” state
(logic ‘0’), then the pin will be left in a High Z state and pulled high via an external pull-up resistor.
• ‘1’ - The LED2 pin is a push-pull output. When driving a logic ‘1’, the pin is driven high. When driving a logic ‘0’, the
pin is driven low.
Bit 0 - LED1_OT - Determines the output type of the LED1 pin.
6.26 Sensor Input LED Linking Register
The Sensor Input LED Linking register controls whether a capacitive touch sensor input is linked to an LED output. If
the corresponding bit is set, then the appropriate LED output will change states defined by the LED Behavior controls
(see Section 6.31) in response to the capacitive touch sensor input.
Bit 1 - CS2_LED2 - Links the LED2 output to a detected touch on the CS2 sensor input. When a touch is detected, the
LED is actuated and will behave as determined by the LED Behavior controls.
• ‘0’ (default) - The LED 2 output is not associated with the CS2 input. If a touch is detected on the CS2 input, the
LED will not automatically be actuated. The LED is enabled and controlled via the LED Output Control register
(see Section 6.28) and the LED Behavior registers (see Section 6.31).
• ‘1’ - The LED 2 output is associated with the CS2 input. If a touch is detected on the CS2 input, the LED will be
actuated and behave as defined in Table 6-52.
Bit 0 - CS1_LED1 - Links the LED1 output to a detected touch on the CS1 sensor input. When a touch is detected, the
LED is actuated and will behave as determined by the LED Behavior controls.
6.27 LED Polarity Register
The LED Polarity register controls the logical polarity of the LED outputs. When these bits are set or cleared, the corresponding
LED Mirror controls are also set or cleared (unless the BLK_POL_MIR bit is set - see Section 6.6, "Configuration
Registers"). Table 6-48, "LED Polarity Behavior" shows the interaction between the polarity controls, output
controls, and relative brightness.
TABLE 6-44: LED OUTPUT TYPE REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
71h R/W LED Output
Type ----- - LED2_
OT
LED1_
OT 00h
TABLE 6-45: SENSOR INPUT LED LINKING REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
72h R/W Sensor Input
LED Linking
- - - - - - CS2_
LED2
CS1_
LED1
00h
TABLE 6-46: LED POLARITY REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
73h R/W LED Polarity - - - - - - LED2_
POL
LED1_
POL 00h
2015 Microchip Technology Inc. DS00001622B-page 51
CAP1128
APPLICATION NOTE: The polarity controls determine the final LED pin drive. A touch on a linked capacitive touch
sensor input is treated in the same way as the LED Output Control bit being set to a logic ‘1’.
APPLICATION NOTE: The LED drive assumes that the LEDs are configured such that if the LED pin is driven to
a logic ‘0’ then the LED will be on and that the CAP1128 LED pin is sinking the LED current.
Conversely, if the LED pin is driven to a logic ‘1’, the LED will be off and there is no current
flow. See Figure 5-1, "System Diagram for CAP1128".
APPLICATION NOTE: This application note applies when the LED polarity is inverted (LEDx_POL = ‘0’). For LED
operation, the duty cycle settings determine the % of time that the LED pin will be driven to
a logic ‘0’ state in. The Max Duty Cycle settings define the maximum % of time that the LED
pin will be driven low (i.e. maximum % of time that the LED is on) while the Min Duty Cycle
settings determine the minimum % of time that the LED pin will be driven low (i.e. minimum
% of time that the LED is on). When there is no touch detected or the LED Output Control
register bit is at a logic ‘0’, the LED output will be driven at the minimum duty cycle setting.
Breathe operations will ramp the duty cycle from the minimum duty cycle to the maximum
duty cycle.
APPLICATION NOTE: This application note applies when the LED polarity is non-inverted (LEDx_POL = ‘1’). For
LED operation, the duty cycle settings determine the % of time that the LED pin will be driven
to a logic ‘1’ state. The Max Duty Cycle settings define the maximum % of time that the LED
pin will be driven high (i.e. maximum % of time that the LED is off) while the Min Duty Cycle
settings determine the minimum % of time that the LED pin will be driven high (i.e. minimum
% of time that the LED is off). When there is no touch detected or the LED Output Control
register bit is at a logic ‘0’, the LED output will be driven at 100 minus the minimum duty
cycle setting. Breathe operations will ramp the duty cycle from 100 minus the minimum duty
cycle to 100 minus the maximum duty cycle.
APPLICATION NOTE: The LED Mirror controls (see Section 6.30, "LED Mirror Control Register") work with the
polarity controls with respect to LED brightness but will not have a direct effect on the output
pin drive.
Bit 1 - LED2_POL - Determines the polarity of the LED2 output.
• ‘0’ (default) - The LED2 output is inverted. For example, a setting of ‘1’ in the LED Output Control register will
cause the LED pin output to be driven to a logic ‘0’.
• ‘1’ - The LED2 output is non-inverted. For example, a setting of ‘1’ in the LED Output Control register will cause
the LED pin output to be driven to a logic ‘1’ or left in the high-z state as determined by its output type.
Bit 0 - LED1_POL - Determines the polarity of the LED1 output.
6.28 LED Output Control Register
The LED Output Control Register controls the output state of the LED pins that are not linked to sensor inputs.
The LED Polarity Control Register will determine the non actuated state of the LED pins. The actuated LED behavior is
determined by the LED behavior controls (see Section 6.31, "LED Behavior Register").
TABLE 6-47: LED OUTPUT CONTROL REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
74h R/W LED Output
Control --- - -- LED2_
DR
LED1_
DR 00h
Note: If an LED is linked to a sensor input in the Sensor Input LED Linking Register (Section 6.26, "Sensor Input
LED Linking Register"), the corresponding bit in the LED Output Control Register is ignored (i.e. a linked
LED cannot be host controlled).
CAP1128
DS00001622B-page 52 2015 Microchip Technology Inc.
Table 6-48 shows the interaction between the polarity controls, output controls, and relative brightness.
Bit 1 - LED2_DR - Determines whether LED2 output is driven high or low.
• ‘0’ (default) - The LED2 output is driven at the minimum duty cycle or not actuated.
• ‘1’ - The LED2 output is High Z or driven at the maximum duty cycle or actuated.
Bit 0 - LED1_DR - Determines whether LED1 output is driven high or low.
6.29 Linked LED Transition Control Register
The Linked LED Transition Control register controls the LED drive when the LED is linked to a capacitive touch sensor
input. These controls work in conjunction with the INV_LINK_TRAN bit (see Section 6.6.2, "Configuration 2 - 44h") to
create smooth transitions from host control to linked LEDs.
Bit 1 - LED2_LTRAN - Determines the transition effect when LED2 is linked to CS2.
• ‘0’ (default) - When the LED output control bit for LED2 is ‘1’, and then LED2 is linked to CS2 and no touch is
detected, the LED will change states.
• ‘1’ - If the INV_LINK_TRAN bit is ‘1’, when the LED output control bit for CS2 is ‘1’, and then CS2 is linked to LED2
and no touch is detected, the LED will not change states. In addition, the LED state will change when the sensor
pad is touched. If the INV_LINK_TRAN bit is ‘0’, when the LED output control bit for CS2 is ‘1’, and then CS2 is
linked to LED2 and no touch is detected, the LED will not change states. However, the LED state will not change
when the sensor pad is touched.
APPLICATION NOTE: If the LED behavior is not “Direct” and the INV_LINK_TRAN bit it ‘0’, the LED will not perform
as expected when the LED2_LTRAN bit is set to ‘1’. Therefore, if breathe and pulse
behaviors are used, set the INV_LINK_TRAN bit to ‘1’.
TABLE 6-48: LED POLARITY BEHAVIOR
LED Output
Control
Register or
Touch
Polarity Max Duty Min Duty Brightness LED Appearance
0 inverted (‘0’) not used
minimum % of time
that the LED is on
(logic 0)
maximum brightness at
min duty cycle
on at min duty
cycle
1 inverted (‘0’)
maximum % of time
that the LED is on
(logic 0)
minimum % of time
that the LED is on
(logic 0)
maximum brightness at
max duty cycle. Brightness
ramps from min
duty cycle to max duty
cycle
according to LED
behavior
0 non-inverted
(‘1’) not used
minimum % of time
that the LED is off
(logic 1)
maximum brightness at
100 minus min duty
cycle.
on at 100 - min
duty cycle
1 non-inverted
(‘1’)
maximum % of time
that the LED is off
(logic 1)
minimum % of time
that the LED is off
(logic 1)
For Direct behavior,
maximum brightness is
100 minus max duty
cycle. When breathing,
max brightness is
100 minus min duty
cycle. Brightness
ramps from 100 - min
duty cycle to 100 - max
duty cycle.
according to LED
behavior
TABLE 6-49: LINKED LED TRANSITION CONTROL REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
77h R/W Linked LED Transition
Control - ----- LED2_
LTRAN
LED1_
LTRAN 00h
2015 Microchip Technology Inc. DS00001622B-page 53
CAP1128
Bit 0 - LED1_LTRAN - Determines the transition effect when LED1 is linked to CS1.
6.30 LED Mirror Control Register
The LED Mirror Control Registers determine the meaning of duty cycle settings when polarity is non-inverted for each
LED channel. When the polarity bit is set to ‘1’ (non-inverted), to obtain correct steps for LED ramping, pulse, and
breathe behaviors, the min and max duty cycles need to be relative to 100%, rather than the default, which is relative
to 0%.
APPLICATION NOTE: The LED drive assumes that the LEDs are configured such that if the LED pin is driven to
a logic ‘0’, the LED will be on and the CAP1128 LED pin is sinking the LED current. When
the polarity bit is set to ‘1’, it is considered non-inverted. For systems using the opposite LED
configuration, mirror controls would apply when the polarity bit is ‘0’.
These bits are changed automatically if the corresponding LED Polarity bit is changed (unless the BLK_POL_MIR bit is
set - see Section 6.6).
Bit 1 - LED2_MIR_EN - Determines whether the duty cycle settings are “biased” relative to 0% or 100% duty cycle.
• ‘0’ (default) - The duty cycle settings are determined relative to 0% and are determined directly with the settings.
• ‘1’ - The duty cycle settings are determined relative to 100%.
Bit 0 - LED1_MIR_EN - Determines whether the duty cycle settings are “biased” relative to 0% or 100% duty cycle.
6.31 LED Behavior Register
The LED Behavior register controls the operation of LEDs. Each LED pin is controlled by a 2-bit field and the behavior
is determined by whether the LED is linked to a capacitive touch sensor input or not.
If the corresponding LED output is linked to a capacitive touch sensor input, the appropriate behavior will be enabled /
disabled based on touches and releases.
If the LED output is not associated with a capacitive touch sensor input, the appropriate behavior will be enabled / disabled
by the LED Output Control register. If the respective LEDx_DR bit is set to a logic ‘1’, this will be associated as a
“touch”, and if the LEDx_DR bit is set to a logic ‘0’, this will be associated as a “release”.
Table 6-52, "LEDx_CTL Bit Decode" shows the behavior triggers. The defined behavior will activate when the Start Trigger
is met and will stop when the Stop Trigger is met. Note the behavior of the Breathe Hold and Pulse Release option.
The LED Polarity Control register will determine the non actuated state of the LED outputs (see Section 6.27, "LED
Polarity Register").
APPLICATION NOTE: If an LED is not linked to a capacitive touch sensor input and is breathing (via the Breathe
or Pulse behaviors), it must be unactuated and then re-actuated before changes to behavior
are processed. For example, if the LED output is breathing and the Maximum duty cycle is
changed, this change will not take effect until the LED output control register is set to ‘0’ and
then re-set to ‘1’.
APPLICATION NOTE: If an LED is not linked to the capacitive touch sensor input and configured to operate using
Pulse 1 Behavior, then the circuitry will only be actuated when the corresponding output
control bit is set. It will not check the bit condition until the Pulse 1 behavior is finished. The
device will not remember if the bit was cleared and reset while it was actuated.
TABLE 6-50: LED MIRROR CONTROL REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
79h R/W LED Mirror Control
------
LED2_
MIR _
EN
LED1_
MIR _
EN
00h
TABLE 6-51: LED BEHAVIOR REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
81h R/W LED Behavior 1 - - - - LED2_CTL[1:0] LED1_CTL[1:0] 00h
CAP1128
DS00001622B-page 54 2015 Microchip Technology Inc.
APPLICATION NOTE: If an LED is actuated and not linked and the desired LED behavior is changed, this new
behavior will take effect immediately; however, the first instance of the changed behavior
may act incorrectly (e.g. if changed from Direct to Pulse 1, the LED output may ‘breathe’ 4
times and then end at minimum duty cycle). LED Behaviors will operate normally once the
LED has been un-actuated and then re-actuated.
APPLICATION NOTE: If an LED is actuated and it is switched from linked to a capacitive touch sensor input to
unlinked (or vice versa), the LED will respond to the new command source immediately if
the behavior was Direct or Breathe. For Pulse behaviors, it will complete the behavior
already in progress. For example, if a linked LED was actuated by a touch and the control
is changed so that it is unlinked, it will check the status of the corresponding LED Output
Control bit. If that bit is ‘0’, then the LED will behave as if a release was detected. Likewise,
if an unlinked LED was actuated by the LED Output Control register and the control is
changed so that it is linked and no touch is detected, then the LED will behave as if a release
was detected.
Bits 3 - 2 - LED2_CTL[1:0] - Determines the behavior of LED2 as shown in Table 6-52.
Bits 1 - 0 - LED1_CTL[1:0] - Determines the behavior of LED1 as shown in Table 6-52.
APPLICATION NOTE: The PWM frequency is determined based on the selected LED behavior, the programmed
breathe period, and the programmed min and max duty cycles. For the Direct behavior
mode, the PWM frequency is calculated based on the programmed Rise and Fall times. If
these are set at 0, then the maximum PWM frequency will be used based on the
programmed duty cycle settings.
TABLE 6-52: LEDX_CTL BIT DECODE
LEDx_CTL
[1:0] Operation Description Start TRigger Stop Trigger
1 0
0 0 Direct The LED is driven to the programmed state
(active or inactive). See Figure 6-7
Touch Detected or
LED Output Control
bit set
Release
Detected or
LED Output
Control bit
cleared
0 1 Pulse 1
The LED will “Pulse” a programmed number
of times. During each “Pulse” the LED will
breathe up to the maximum brightness and
back down to the minimum brightness so that
the total “Pulse” period matches the programmed
value.
Touch or Release
Detected or LED
Output Control bit
set or cleared
(see Section 6.32)
n/a
1 0 Pulse 2
The LED will “Pulse” when the start trigger is
detected. When the stop trigger is detected, it
will “Pulse” a programmable number of times
then return to its minimum brightness.
Touch Detected or
LED Output Control
bit set
Release
Detected or
LED Output
Control bit
cleared
1 1 Breathe
The LED will breathe. It will be driven with a
duty cycle that ramps up from the programmed
minimum duty cycle (default 0%) to
the programmed maximum duty cycle duty
cycle (default 100%) and then back down.
Each ramp takes up 50% of the programmed
period. The total period of each “breath” is
determined by the LED Breathe Period controls
- see Section 6.34.
Touch Detected or
LED Output Control
bit set
Release
Detected or
LED Output
Control bit
cleared
2015 Microchip Technology Inc. DS00001622B-page 55
CAP1128
6.32 LED Pulse 1 Period Register
The LED Pulse Period 1 register determines the overall period of a pulse operation as determined by the LED_CTL
registers (see Table 6-52 - setting 01b). The LSB represents 32ms so that a setting of 18h (24d) would represent a
period of 768ms (24 x 32ms = 768ms). The total range is from 32ms to 4.064 seconds as shown in Table 6-54 with the
default being 1024ms.
APPLICATION NOTE: Due to constraints on the LED Drive PWM operation, any Breathe Period less than 160ms
(05h) may not be achievable. The device will breathe at the minimum period possible as
determined by the period and min / max duty cycle settings.
Bit 7 - ST_TRIG - Determines the start trigger for the LED Pulse behavior.
• ‘0’ (default) - The LED will Pulse when a touch is detected or the drive bit is set.
• ‘1’ - The LED will Pulse when a release is detected or the drive bit is cleared.
The Pulse 1 operation is shown in Figure 6-1 when the LED output is configured for non-inverted polarity (LEDx_POL
= 1) and in Figure 6-2 for inverted polarity (LEDx_POL = 0).
.
TABLE 6-53: LED PULSE 1 PERIOD REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
84h R/W LED Pulse 1
Period
ST_
TRIG
P1_
PER6
P1_
PER5
P1_
PER4
P1_
PER3
P1_
PER2
P1_
PER1
P1_
PER0 20h
FIGURE 6-1: Pulse 1 Behavior with Non-Inverted Polarity
Normal – untouched
operation Normal – untouched
operation
Touch Detected or
Release Detected
(100% - Pulse 1 Max Duty Cycle) * Brightness
X pulses after touch or after release
Pulse 1 Period
(P1_PER)
(100% - Pulse 1 Min Duty Cycle) * Brightness
LED
Brightness
CAP1128
DS00001622B-page 56 2015 Microchip Technology Inc.
6.33 LED Pulse 2 Period Register
The LED Pulse 2 Period register determines the overall period of a pulse operation as determined by the LED_CTL
registers (see Table 6-52 - setting 10b). The LSB represents 32ms so that a setting of 18h (24d) would represent a
period of 768ms. The total range is from 32ms to 4.064 seconds (see Table 6-54) with a default of 640ms.
APPLICATION NOTE: Due to constraints on the LED Drive PWM operation, any Breathe Period less than 160ms
(05h) may not be achievable. The device will breathe at the minimum period possible as
determined by the period and min / max duty cycle settings.
The Pulse 2 Behavior is shown in Figure 6-3 for non-inverted polarity (LEDx_POL = 1) and in Figure 6-4 for inverted
polarity (LEDx_POL = 0).
FIGURE 6-2: Pulse 1 Behavior with Inverted Polarity
TABLE 6-54: LED PULSE / BREATHE PERIOD EXAMPLE
Setting (HEX) Setting (Decimal) Total Breathe / Pulse Period (MS)
00h 0 32
01h 1 32
02h 2 64
03h 3 96
. . . . . . . . .
7Dh 125 4000
7Eh 126 4032
7Fh 127 4064
TABLE 6-55: LED PULSE 2 PERIOD REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
85h R/W LED Pulse 2
Period - P2_
PER6
P2_
PER5
P2_
PER4
P2_
PER3
P2_
PER2
P2_
PER1
P2_
PER0 14h
Normal – untouched
operation
Normal – untouched
operation
Touch Detected or
Release Detected
Pulse 1 Min Duty Cycle * Brightness
X pulses after touch or after release
Pulse Period
(P1_PER)
Pulse 1 Max Duty Cycle * Brightness
LED
Brightness
2015 Microchip Technology Inc. DS00001622B-page 57
CAP1128
6.34 LED Breathe Period Register
The LED Breathe Period register determines the overall period of a breathe operation as determined by the LED_CTL
registers (see Table 6-52 - setting 11b). The LSB represents 32ms so that a setting of 18h (24d) would represent a
period of 768ms. The total range is from 32ms to 4.064 seconds (see Table 6-54) with a default of 2976ms.
APPLICATION NOTE: Due to constraints on the LED Drive PWM operation, any Breathe Period less than 160ms
(05h) may not be achievable. The device will breathe at the minimum period possible as
determined by the period and min / max duty cycle settings.
FIGURE 6-3: Pulse 2 Behavior with Non-Inverted Polarity
FIGURE 6-4: Pulse 2 Behavior with Inverted Polarity
TABLE 6-56: LED BREATHE PERIOD REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
86h R/W LED Breathe
Period - BR_
PER6
BR_
PER5
BR_
PER4
BR_
PER3
BR_
PER2
BR_
PER1
BR_
PER0 5Dh
. . .
Normal – untouched
operation
Normal – untouched
operation
Touch Detected
(100% - Pulse 2 Min Duty Cycle) *
Brightness
(100% - Pulse 2 Max Duty Cycle) * Brightness
X additional pulses after release
Release Detected
Pulse
Period
(P2_PER)
LED
Brightness
Normal – untouched
operation
Normal – untouched
operation
Touch Detected
Pulse 2 Max Duty Cycle * Brightness
Pulse 2 Min Duty Cycle * Brightness
X additional pulses after release
Release Detected
Pulse
Period
(P2_PER)
LED
Brightness . . .
CAP1128
DS00001622B-page 58 2015 Microchip Technology Inc.
6.35 LED Configuration Register
The LED Configuration register controls general LED behavior as well as the number of pulses that are sent for the
PULSE LED output behavior.
Bit 6 - RAMP_ALERT - Determines whether the device will assert the ALERT# pin when LEDs actuated by the LED
Output Control register bits have finished their respective behaviors. Interrupts will only be generated if the LED activity
is generated by writing the LED Output Control registers. Any LED activity associated with touch detection will not cause
an interrupt to be generated when the LED behavior has been finished.
• ‘0’ (default) - The ALERT# pin will not be asserted when LEDs actuated by the LED Output Control register have
finished their programmed behaviors.
• ‘1’ - The ALERT# pin will be asserted whenever any LED that is actuated by the LED Output Control register has
finished its programmed behavior.
Bits 5 - 3 - PULSE2_CNT[2:0] - Determines the number of pulses used for the Pulse 2 behavior as shown in Table 6-58.
Bits 2 - 0 - PULSE1_CNT[2:0] - Determines the number of pulses used for the Pulse 1 behavior as shown in Table 6-58.
6.36 LED Duty Cycle Registers
The LED Duty Cycle registers determine the minimum and maximum duty cycle settings used for the LED for each LED
behavior. These settings affect the brightness of the LED when it is fully off and fully on.
The LED driver duty cycle will ramp up from the minimum duty cycle to the maximum duty cycle and back down again.
APPLICATION NOTE: When operating in Direct behavior mode, changes to the Duty Cycle settings will be applied
immediately. When operating in Breathe, Pulse 1, or Pulse 2 modes, the LED must be
unactuated and then re-actuated before changes to behavior are processed.
TABLE 6-57: LED CONFIGURATION REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
88h R/W LED Config - RAMP_
ALERT PULSE2_CNT[2:0] PULSE1_CNT[2:0] 04h
TABLE 6-58: PULSEX_CNT DECODE
PULSEX_CNT[2:0]
Number of Breaths
21 0
0 0 0 1 (default - Pulse 2)
00 1 2
01 0 3
01 1 4
1 0 0 5 (default - Pulse 1)
10 1 6
11 0 7
11 1 8
TABLE 6-59: LED DUTY CYCLE REGISTERS
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
90h R/W LED Pulse 1 Duty
Cycle P1_MAX_DUTY[3:0] P1_MIN_DUTY[3:0] F0h
91h R/W LED Pulse 2 Duty
Cycle P2_MAX_DUTY[3:0] P2_MIN_DUTY[3:0] F0h
92h R/W LED Breathe
Duty Cycle BR_MAX_DUTY[3:0] BR_MIN_DUTY[3:0] F0h
93h R/W Direct Duty Cycle DR_MAX_DUTY[3:0] DR_MIN_DUTY[3:0] F0h
2015 Microchip Technology Inc. DS00001622B-page 59
CAP1128
Bits 7 - 4 - X_MAX_DUTY[3:0] - Determines the maximum PWM duty cycle for the LED drivers as shown in Table 6-60.
Bits 3 - 0 - X_MIN_DUTY[3:0] - Determines the minimum PWM duty cycle for the LED drivers as shown in Table 6-60.
6.37 LED Direct Ramp Rates Register
The LED Direct Ramp Rates register control the rising and falling edge time of an LED that is configured to operate in
Direct behavior mode. The rising edge time corresponds to the amount of time the LED takes to transition from its minimum
duty cycle to its maximum duty cycle. Conversely, the falling edge time corresponds to the amount of time that
the LED takes to transition from its maximum duty cycle to its minimum duty cycle.
Bits 5 - 3 - RISE_RATE[2:0] - Determines the rising edge time of an LED when it transitions from its minimum drive state
to its maximum drive state as shown in Table 6-62.
Bits 2 - 0 - FALL_RATE[2:0] - Determines the falling edge time of an LED when it transitions from its maximum drive
state to its minimum drive state as shown in Table 6-62.
TABLE 6-60: LED DUTY CYCLE DECODE
x_MAX/MIN_Duty [3:0]
Maximum Duty Cycle Minimum Duty Cycle
3 21 0
0 0 0 0 7% 0%
0 0 0 1 9% 7%
0 0 1 0 11% 9%
0 0 1 1 14% 11%
0 1 0 0 17% 14%
0 1 0 1 20% 17%
0 1 1 0 23% 20%
0 1 1 1 26% 23%
1 0 0 0 30% 26%
1 0 0 1 35% 30%
1 0 1 0 40% 35%
1 0 1 1 46% 40%
1 1 0 0 53% 46%
1 1 0 1 63% 53%
1 1 1 0 77% 63%
1 1 1 1 100% 77%
TABLE 6-61: LED DIRECT RAMP RATES REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
94h R/W LED Direct Ramp
Rates - - RISE_RATE[2:0] FALL_RATE[2:0] 00h
TABLE 6-62: RISE / FALL RATE DECODE
RISE_RATE/ FALL_RATE/ Bit Decode
Rise / Fall Time (TRISE / TFALL)
21 0
00 0 0
0 0 1 250ms
0 1 0 500ms
0 1 1 750ms
1 0 0 1s
1 0 1 1.25s
CAP1128
DS00001622B-page 60 2015 Microchip Technology Inc.
6.38 LED Off Delay Register
The LED Off Delay register determines the amount of time that an LED remains at its maximum duty cycle (or minimum
as determined by the polarity controls) before it starts to ramp down. If the LED is operating in Breathe mode, this delay
is applied at the top of each “breath”. If the LED is operating in the Direct mode, this delay is applied when the LED is
unactuated.
Bits 6 - 4 - BR_OFF_DLY[2:0] - Determines the Breathe behavior mode off delay, which is the amount of time an LED
in Breathe behavior mode remains inactive after it finishes a breathe pulse (ramp on and ramp off), as shown in Figure 6-
5 (non-inverted polarity LEDx_POL = 1) and Figure 6-6 (inverted polarity LEDx_POL = 0). Available settings are shown
in Table 6-64.
1 1 0 1.5s
1 1 1 2s
TABLE 6-63: LED OFF DELAY REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
95h R/W LED Off Delay
Register - BR_OFF_DLY[2:0] DIR_OFF_DLY[3:0] 00h
FIGURE 6-5: Breathe Behavior with Non-Inverted Polarity
TABLE 6-62: RISE / FALL RATE DECODE (CONTINUED)
RISE_RATE/ FALL_RATE/ Bit Decode
Rise / Fall Time (TRISE / TFALL)
21 0
LED Actuated
100% - Breathe Max Min Cycle * Brightness
100% - Breathe Min Duty Cycle *
Brightness
LED Unactuated
Breathe Off
Delay
(BR_OFF_DLY)
LED
Brightness
Breathe
Period
(BR_PER)
2015 Microchip Technology Inc. DS00001622B-page 61
CAP1128
Bits 3 - 0 - DIR_OFF_DLY[3:0] - Determines the turn-off delay, as shown in Table 6-65, for all LEDs that are configured
to operate in Direct behavior mode.
The Direct behavior operation is determined by the combination of programmed Rise Time, Fall Time, Min and Max Duty
cycles, Off Delay, and polarity. Figure 6-7 shows the behavior for non-inverted polarity (LEDx_POL = 1) while Figure 6-
8 shows the behavior for inverted polarity (LEDx_POL = 0).
FIGURE 6-6: Breathe Behavior with Inverted Polarity
TABLE 6-64: BREATHE OFF DELAY SETTINGS
BR_OFF_DLY [2:0]
OFF Delay
2 10
0 0 0 0 (default)
0 0 1 0.25s
0 1 0 0.5s
0 1 1 0.75s
1 0 0 1.0s
1 0 1 1.25s
1 1 0 1.5s
1 1 1 2.0s
LED Actuated
Breathe Max Duty Cycle * Brightness
Breathe Min Duty Cycle * Brightness
LED Unactuated
Breathe Off
Delay
(BR_OFF_DLY)
LED
Brightness
Breathe
Period
(BR_PER)
CAP1128
DS00001622B-page 62 2015 Microchip Technology Inc.
FIGURE 6-7: Direct Behavior for Non-Inverted Polarity
FIGURE 6-8: Direct Behavior for Inverted Polarity
TABLE 6-65: OFF DELAY DECODE
OFF Delay[3:0] Bit Decode
OFF Delay (tOFF_DLY)
32 1 0
00 0 0 0
0 0 0 1 250ms
0 0 1 0 500ms
0 0 1 1 750ms
0 1 0 0 1s
0 1 0 1 1.25s
0 1 1 0 1.5s
0 1 1 1 2s
1 0 0 0 2.5s
1 0 0 1 3.0s
1 0 1 0 3.5s
1 0 1 1 4.0s
1 1 0 0 4.5s
All others 5.0s
Normal –
untouched
operation
RISE_RATE
Setting (tRISE)
(100% - Max Duty
Cycle) * Brightness
Touch
Detected
Release
Detected
Off Delay
(tOFF_DLY)
FALL_RATE
Setting (tFALL)
Normal –
untouched
operation
(100% - Min Duty Cycle) *
Brightness LED
Brightness
Normal –
untouched
operation RISE_RATE
Setting (tRISE)
Min Duty Cycle * Brightness
Touch
Detected
Release
Detected
Off Delay
(tOFF_DLY)
FALL_RATE
Setting (tFALL)
Normal –
untouched
operation
Max Duty Cycle * Brightness
LED
Brightness
2015 Microchip Technology Inc. DS00001622B-page 63
CAP1128
6.39 Sensor Input Calibration Registers
The Sensor Input Calibration registers hold the 10-bit value that represents the last calibration value.
6.40 Product ID Register
The Product ID register stores a unique 8-bit value that identifies the device.
6.41 Manufacturer ID Register
The Vendor ID register stores an 8-bit value that represents Microchip.
TABLE 6-66: SENSOR INPUT CALIBRATION REGISTERS
ADDR Register R/W B7 B6 B5 B4 B3 B2 B1 B0 Default
B1h Sensor Input 1
Calibration R CAL1_9 CAL1_8 CAL1_7 CAL1_6 CAL1_5 CAL1_4 CAL1_3 CAL1_2 00h
B2h Sensor Input 2
Calibration R CAL2_9 CAL2_8 CAL2_7 CAL2_6 CAL2_5 CAL2_4 CAL2_3 CAL2_2 00h
B3h Sensor Input 3
Calibration R CAL3_9 CAL3_8 CAL3_7 CAL3_6 CAL3_5 CAL3_4 CAL3_3 CAL3_2 00h
B4h Sensor Input 4
Calibration R CAL4_9 CAL4_8 CAL4_7 CAL4_6 CAL4_5 CAL4_4 CAL4_3 CAL4_2 00h
B5h Sensor Input 5
Calibration R CAL5_9 CAL5_8 CAL5_7 CAL5_6 CAL5_5 CAL5_4 CAL5_3 CAL5_2 00h
B6h Sensor Input 6
Calibration R CAL6_9 CAL6_8 CAL6_7 CAL6_6 CAL6_5 CAL6_4 CAL6_3 CAL6_2 00h
B7h Sensor Input 7
Calibration R CAL7_9 CAL7_8 CAL7_7 CAL7_6 CAL7_5 CAL7_4 CAL7_3 CAL7_2 00h
B8h Sensor Input 8
Calibration R CAL8_9 CAL8_8 CAL8_7 CAL8_6 CAL8_5 CAL8_4 CAL8_3 CAL8_2 00h
B9h
Sensor Input
Calibration LSB
1
R CAL4_1 CAL4_0 CAL3_1 CAL3_0 CAL2_1 CAL2_0 CAL1_1 CAL1_0 00h
BAh
Sensor Input
Calibration LSB
2
R CAL8_1 CAL8_0 CAL7_1 CAL7_0 CAL6_1 CAL6_0 CAL5_1 CAL5_0 00h
TABLE 6-67: PRODUCT ID REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
FDh R Product ID 0 1 0 1 0 0 1 0 52h
TABLE 6-68: VENDOR ID REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
FEh R Manufacturer ID 0 1 0 1 1 1 0 1 5Dh
CAP1128
DS00001622B-page 64 2015 Microchip Technology Inc.
6.42 Revision Register
The Revision register stores an 8-bit value that represents the part revision.
TABLE 6-69: REVISION REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
FFh R Revision 1 0 0 0 0 0 1 1 83h
2015 Microchip Technology Inc. DS00001622B-page 65
CAP1128
7.0 PACKAGE INFORMATION
7.1 CAP1128 Package Drawings
Note: For the most current package drawings, see the Microchip Packaging Specification at:
http://www.microchip.com/packaging.
FIGURE 7-1: 20-Pin QFN 4mm x 4mm Package Drawing
CAP1128
DS00001622B-page 66 2015 Microchip Technology Inc.
FIGURE 7-2: 20-Pin QFN 4mm x 4mm Package Dimensions
FIGURE 7-3: 20-Pin QFN 4mm x 4mm PCB Drawing
2015 Microchip Technology Inc. DS00001622B-page 67
CAP1128
7.2 Package Marking
FIGURE 7-4: CAP1128 Package Markings
C 1 28 - 1
Y WWN N N A
RCC
e3
TOP
BOTTOM
Bottom marking not allowed
PB-FREE/GREEN SYMBOL
(Matte Sn)
Lines 1-3:
Line 4:
Center Horizontal Alignment
Left Horizontal Alignment
PIN 1
0.41
3x 0.56
Line 1 – SMSC Logo without circled R symbol
Line 2 – Device ID, Version
Line 3 – Year, Week, Alphanumeric Traceability Code
Line 4 – Revision, Country Code
1
CAP1128
DS00001622B-page 68 2015 Microchip Technology Inc.
APPENDIX A: DEVICE DELTA
A.1 Delta from CAP1028 to CAP1128
1. Updated circuitry to improve power supply rejection.
2. Updated LED driver duty cycle decode values to have more distribution at lower values - closer to a logarithmic
curve. See Table 6-60, "LED Duty Cycle Decode".
3. Updated bug that breathe periods were not correct above 2.6s. This includes rise / fall time decodes above 1.5s.
4. Added filtering on RESET pin to prevent errant resets.
5. Updated controls so that the RESET pin assertion places the device into the lowest power state available and
causes an interrupt when released. See Section 5.2, "RESET Pin".
6. Added 1 bit to the LED Off Delay register (see Section 6.38, "LED Off Delay Register") to extend times from 2s
to 5s in 0.5s intervals.
7. Breathe behavior modified. A breathe off delay control was added to the LED Off Delay Register (see Section
6.38, "LED Off Delay Register") so the LEDs can be configured to remain inactive between breathes.
8. Added controls for the LED transition effects when linking LEDs to capacitive sensor inputs. See Section 6.29,
"Linked LED Transition Control Register".
9. Added controls to “mirror” the LED duty cycle outputs so that when polarity changes, the LED brightness levels
look right. These bits are automatically set when polarity is set. Added control to break this auto-set behavior.
See Section 6.30, "LED Mirror Control Register".
10. Added Multiple Touch Pattern detection circuitry. See Section 6.15, "Multiple Touch Pattern Configuration Register".
11. Added General Status register to flag Multiple touches, Multiple Touch Pattern issues and general touch detections.
See Section 6.2, "Status Registers".
12. Added bits 6 and 5 to the Recalibration Configuration register (2Fh - see Section 6.17, "Recalibration Configuration
Register"). These bits control whether the accumulation of intermediate data and the consecutive negative
delta counts counter are cleared when the noise status bit is set.
13. Added Configuration 2 register for LED linking controls, noise detection controls, and control to interrupt on press
but not on release. Added control to change alert pin polarity. See Section 6.6, "Configuration Registers".
14. Updated Deep Sleep behavior so that device does not clear DSLEEP bit on received communications but will
wake to communicate.
15. Changed PWM frequency for LED drivers. The PWM frequency was derived from the programmed breathe
period and duty cycle settings and it ranged from ~4Hz to ~8000 Hz. The PWM frequency has been updated to
be a fixed value of ~2000Hz.
16. Register delta:
Table A.1 Register Delta From CAP1028 to CAP1128
Address Register Delta Delta Default
00h
Page 31
Changed - Main Status /
Control
added bits 7-6 to control gain 00h
02h
Page 32
New - General Status new register to store MTP, MULT, LED,
RESET, and general TOUCH bits
00h
44h
Page 36
New - Configuration 2 new register to control alert polarity, LED
touch linking behavior, LED output behavior,
and noise detection, and interrupt on
release
40h
24h
Page 39
Changed - Averaging
Control
updated register bits - moved
SAMP_AVG[2:0] bits and added SAMP_-
TIME bit 1. Default changed
39h
2Bh
Page 43
New - Multiple Touch
Pattern Configuration
new register for Multiple Touch Pattern
configuration - enable and threshold settings
80h
2015 Microchip Technology Inc. DS00001622B-page 69
CAP1128
2Dh
Page 44
New - Multiple Touch
Pattern Register
new register for Multiple Touch Pattern
detection circuitry - pattern or number of
sensor inputs
FFh
2Fh
Page 44
Changed - Recalibration
Configuration
updated register - updated CAL_CFG bit
decode to add a 128 averages setting and
removed highest time setting. Default
changed. Added bit 6 NO_CLR_INTD and
bit 5 NO_CLR_NEG.
8Ah
38h
Page 46
Changed - Sensor Input
Noise Threshold
updated register bits - removed bits 7 - 3
and consolidated all controls into bits 1 - 0.
These bits will set the noise threshold for
all channels. Default changed
01h
39h Removed - Noise
Threshold Register 2
removed register n/a
41h
Page 47
Changed - Standby Configuration
updated register bits - moved
STBY_AVG[2:0] bits and added STBY_-
TIME bit 1. Default changed
39h
77h
Page 52
New - Linked LED Transition
Control
new register to control transition effect
when LED linked to sensor inputs
00h
79h
Page 53
New - LED Mirror Control new register to control LED output mirroring
for brightness control when polarity
changed
00h
90h
Page 58
Changed - LED Pulse 1
Duty Cycle
changed bit decode to be more logarithmic F0h
91h
Page 58
Changed - LED Pulse 2
Duty Cycle
changed bit decode to be more logarithmic F0h
92h
Page 58
Changed - LED Breathe
Duty Cycle
changed bit decode to be more logarithmic F0h
93h
Page 58
Changed - LED Direct
Duty Cycle
changed bit decode to be more logarithmic F0h
95h Added controls - LED Off
Delay
Added bits 6-4 BR_OFF_DLY[2:0]
Added bit 3 DIR_OFF_DLY[3]
00h
FDh
Page 63
Changed - Product ID Changed bit decode for CAP1128 52h
Table A.1 Register Delta From CAP1028 to CAP1128 (continued)
Address Register Delta Delta Default
CAP1128
DS00001622B-page 70 2015 Microchip Technology Inc.
APPENDIX B: DATA SHEET REVISION HISTORY
Revision Section/Figure/Entry Correction
DS00001622B (02-09-15)
Features, Table 2-1, Table 2-
2, "Pin Types", Section 5.0,
"General Description"
References to BC-Link Interface, BC_DATA, BC_-
CLK, BC-IRQ#, BC-Link bus have been removed
Application Note under Table
2-6
[BC-Link] hidden in data sheet
Table 3-2, "Electrical Specifications"
BC-Link Timing Section hidden in data sheet
Table 4-1 Protocol Used for 68K Pull Down Resistor changed
from “BC-Link Communications” to “Reserved”
Section 4.2.2, "SMBus
Address and RD / WR Bit"
Replaced “client address” with “slave address” in this
section.
Section 4.2.4, SMBus ACK
and NACK Bits, Section 4.2.5,
SMBus Stop Bit,Section 4.2.7,
SMBus and I2C Compatibility
Replaced “client” with “slave” in these sections.
Table 4-4, "Read Byte Protocol"
Heading changed from “Client Address” to “Slave
Address”
Table 6-1 Register Name for Register Address 77h changed
from “LED Linked Transition Control” to “Linked LED
Transition Control”
Section 6.30 changed CS2 to LED2
Section 7.7 Package Marking Updated package drawing
Appendix A: Device Delta changed 2Dh to 2Fh in item #12
Product Identification System Removed BC-Link references
REV A REV A replaces previous SMSC version Rev. 1.32 (01-05-12)
Rev. 1.32 (01-05-12) Table 3-2, "Electrical Specifications"
Added conditions for tHD:DAT.
Section 4.2.7, "SMBus and
I2C Compatibility"
Renamed from “SMBus and I2C Compliance.”
First paragraph, added last sentence: “For information
on using the CAP1188 in an I2C system, refer to
SMSC AN 14.0 SMSC Dedicated Slave Devices in
I
2C Systems.”
Added: CAP1188 supports I2C fast mode at 400kHz.
This covers the SMBus max time of 100kHz.
Section 6.4, "Sensor Input
Delta Count Registers"
Changed negative value cap from FFh to 80h.
Rev. 1.31 (08-18-11) Section 4.3.3, "SMBus Send
Byte"
Added an application note: The Send Byte protocol
is not functional in Deep Sleep (i.e., DSLEEP bit is
set).
Section 4.3.4, "SMBus
Receive Byte"
Added an application note: The Receive Byte protocol
is not functional in Deep Sleep (i.e., DSLEEP bit
is set).
Rev. 1.3 (05-18-11) Section 6.42, "Revision Register"
Updated revision ID from 82h to 83h.
Rev. 1.2 (02-10-11) Section A.8, "Delta from Rev
B (Mask B0) to Rev C (Mask
B1)"
Added.
Table 2-1, "Pin Description for
CAP1128"
Changed value in “Unused Connection” column for
the ADDR_COMM pin from “Connect to Ground” to
“n/a“.
2015 Microchip Technology Inc. DS00001622B-page 71
CAP1128
Table 3-2, "Electrical Specifications"
PSR improvements made in functional revision B.
Changed PSR spec from ±100 typ and ±200 max
counts / V to ±3 and ±10 counts / V. Conditions
updated.
Section 5.5.2, "Recalibrating
Sensor Inputs"
Added more detail with subheadings for each type of
recalibration.
Section 6.6, "Configuration
Registers"
Added bit 5 BLK_PWR_CTRL to the Configuration 2
Register 44h.
The TIMEOUT bit is set to ‘1’ by default for functional
revision B and is set to ‘0’ by default for functional
revision C.
Section 6.42, "Revision Register"
Updated revision ID in register FFh from 81h to 82h.
Rev. 1.1 (11-17-10) Document Updated for functional revision B. See Section A.7,
"Delta from Rev A (Mask A0) to Rev B (Mask B0)".
Cover Added to General Description: “includes circuitry and
support for enhanced sensor proximity detection.”
Added the following Features:
Calibrates for Parasitic Capacitance
Analog Filtering for System Noise Sources
Press and Hold feature for Volume-like Applications
Table 3-2, "Electrical Specifications"
Conditions for Power Supply Rejection modified adding
the following:
Sampling time = 2.56ms
Averaging = 1
Negative Delta Counts = Disabled
All other parameters default
Section 6.11, "Calibration Activate
Register"
Updated register description to indicate which re-calibration
routine is used.
Section 6.14, "Multiple Touch
Configuration Register"
Updated register description to indicate what will
happen.
Table 6-34, "CSx_BN_TH Bit
Decode"
Table heading changed from “Threshold Divide Setting”
to “Percent Threshold Setting”.
Rev. 1.0 (06-14-10) Initial release
Revision Section/Figure/Entry Correction
CAP1128
DS00001622B-page 72 2015 Microchip Technology Inc.
THE MICROCHIP WEB SITE
Microchip provides online support via our WWW site at www.microchip.com. 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 (FAQ), 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
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. Under “Support”, click on “Customer Change Notification”
and follow the registration instructions.
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://www.microchip.com/support
2015 Microchip Technology Inc. DS00001622B-page 73
CAP1128
PRODUCT IDENTIFICATION SYSTEM
To order or obtain information, e.g., on pricing or delivery, refer to the factory or the listed sales office.
PART NO. [X] - 1 - XXX - [X](1)
l l l l
Device Temperature Package Tape and Reel
Range Option
Example:
Note 1: Tape and Reel identifier only appears in the catalog part number description. This identifier is used for ordering
purposes and is not printed on the device package. Check with your Microchip Sales Office for package availability
with the Tape and Reel option.
Device: CAP1128
Temperature
Range:
Blank = 0°C to +85°C (Extended Commercial)
Package: BP = QFN
Tape and
Reel Option:
TR = Tape and Reel(1)
CAP1128-1-BP-TR
20-pin QFN 4mm x 4mm (RoHS compliant)
Eight capacitive touch sensor inputs, Two
LED drivers, Dedicated Wake, Reset,
SMBus / BC-Link / SPI interfaces
Reel size is 4,000 pieces
CAP1128
DS00001622B-page 74 2015 Microchip Technology Inc.
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, FlashFlex, flexPWR, JukeBlox, KEELOQ, KEELOQ logo, Kleer, LANCheck,
MediaLB, MOST, MOST logo, MPLAB, OptoLyzer, PIC, PICSTART, PIC32 logo, RightTouch, SpyNIC, SST, SST Logo, SuperFlash and
UNI/O are registered trademarks of Microchip Technology Incorporated in the U.S.A. and other countries.
The Embedded Control Solutions Company and mTouch are registered trademarks of Microchip Technology Incorporated in the U.S.A.
Analog-for-the-Digital Age, BodyCom, chipKIT, chipKIT logo, CodeGuard, dsPICDEM, dsPICDEM.net, ECAN, In-Circuit Serial
Programming, ICSP, Inter-Chip Connectivity, KleerNet, KleerNet logo, MiWi, MPASM, MPF, MPLAB Certified logo, MPLIB, MPLINK,
MultiTRAK, NetDetach, Omniscient Code Generation, PICDEM, PICDEM.net, PICkit, PICtail, RightTouch logo, REAL ICE, SQI, Serial
Quad I/O, Total Endurance, TSHARC, USBCheck, VariSense, ViewSpan, WiperLock, Wireless DNA, 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.
Silicon Storage Technology is a registered trademark of Microchip Technology Inc. in other countries.
GestIC is a registered trademarks of Microchip Technology Germany II GmbH & Co. KG, a subsidiary of Microchip Technology Inc., in
other countries.
All other trademarks mentioned herein are property of their respective companies.
© 2015, Microchip Technology Incorporated, Printed in the U.S.A., All Rights Reserved.
ISBN: 9781632770325
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.
QUALITY MANAGEMENT SYSTEM
CERTIFIED BY DNV
== ISO/TS 16949 ==
2015 Microchip Technology Inc. DS00001622B-page 75
AMERICAS
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
Atlanta
Duluth, GA
Tel: 678-957-9614
Fax: 678-957-1455
Austin, TX
Tel: 512-257-3370
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
Novi, MI
Tel: 248-848-4000
Houston, TX
Tel: 281-894-5983
Indianapolis
Noblesville, IN
Tel: 317-773-8323
Fax: 317-773-5453
Los Angeles
Mission Viejo, CA
Tel: 949-462-9523
Fax: 949-462-9608
New York, NY
Tel: 631-435-6000
San Jose, CA
Tel: 408-735-9110
Canada - Toronto
Tel: 905-673-0699
Fax: 905-673-6509
ASIA/PACIFIC
Asia Pacific Office
Suites 3707-14, 37th Floor
Tower 6, The Gateway
Harbour City, Kowloon
Hong Kong
Tel: 852-2943-5100
Fax: 852-2401-3431
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
China - Dongguan
Tel: 86-769-8702-9880
China - Hangzhou
Tel: 86-571-8792-8115
Fax: 86-571-8792-8116
China - Hong Kong SAR
Tel: 852-2943-5100
Fax: 852-2401-3431
China - Nanjing
Tel: 86-25-8473-2460
Fax: 86-25-8473-2470
China - Qingdao
Tel: 86-532-8502-7355
Fax: 86-532-8502-7205
China - Shanghai
Tel: 86-21-5407-5533
Fax: 86-21-5407-5066
China - Shenyang
Tel: 86-24-2334-2829
Fax: 86-24-2334-2393
China - Shenzhen
Tel: 86-755-8864-2200
Fax: 86-755-8203-1760
China - Wuhan
Tel: 86-27-5980-5300
Fax: 86-27-5980-5118
China - Xian
Tel: 86-29-8833-7252
Fax: 86-29-8833-7256
ASIA/PACIFIC
China - Xiamen
Tel: 86-592-2388138
Fax: 86-592-2388130
China - Zhuhai
Tel: 86-756-3210040
Fax: 86-756-3210049
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
India - Pune
Tel: 91-20-3019-1500
Japan - Osaka
Tel: 81-6-6152-7160
Fax: 81-6-6152-9310
Japan - Tokyo
Tel: 81-3-6880- 3770
Fax: 81-3-6880-3771
Korea - Daegu
Tel: 82-53-744-4301
Fax: 82-53-744-4302
Korea - Seoul
Tel: 82-2-554-7200
Fax: 82-2-558-5932 or
82-2-558-5934
Malaysia - Kuala Lumpur
Tel: 60-3-6201-9857
Fax: 60-3-6201-9859
Malaysia - Penang
Tel: 60-4-227-8870
Fax: 60-4-227-4068
Philippines - Manila
Tel: 63-2-634-9065
Fax: 63-2-634-9069
Singapore
Tel: 65-6334-8870
Fax: 65-6334-8850
Taiwan - Hsin Chu
Tel: 886-3-5778-366
Fax: 886-3-5770-955
Taiwan - Kaohsiung
Tel: 886-7-213-7828
Taiwan - Taipei
Tel: 886-2-2508-8600
Fax: 886-2-2508-0102
Thailand - Bangkok
Tel: 66-2-694-1351
Fax: 66-2-694-1350
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
Fax: 33-1-69-30-90-79
Germany - Dusseldorf
Tel: 49-2129-3766400
Germany - Munich
Tel: 49-89-627-144-0
Fax: 49-89-627-144-44
Germany - Pforzheim
Tel: 49-7231-424750
Italy - Milan
Tel: 39-0331-742611
Fax: 39-0331-466781
Italy - Venice
Tel: 39-049-7625286
Netherlands - Drunen
Tel: 31-416-690399
Fax: 31-416-690340
Poland - Warsaw
Tel: 48-22-3325737
Spain - Madrid
Tel: 34-91-708-08-90
Fax: 34-91-708-08-91
Sweden - Stockholm
Tel: 46-8-5090-4654
UK - Wokingham
Tel: 44-118-921-5800
Fax: 44-118-921-5820
Worldwide Sales and Service
01/27/15
Au format texte
2015 Microchip Technology Inc. DS00001621B-page 1
General Description
The CAP1166, which incorporates RightTouch® technology,
is a multiple channel Capacitive Touch sensor
with multiple power LED drivers. It contains six (6) individual
capacitive touch sensor inputs with programmable
sensitivity for use in touch sensor applications.
Each sensor input automatically recalibrates to compensate
for gradual environmental changes.
The CAP1166 also contains six (6) LED drivers that
offer full-on / off, variable rate blinking, dimness controls,
and breathing. Each of the LED drivers may be
linked to one of the sensor inputs to be actuated when
a touch is detected. As well, each LED driver may be
individually controlled via a host controller.
The CAP1166 includes Multiple Pattern Touch recognition
that allows the user to select a specific set of buttons
to be touched simultaneously. If this pattern is
detected, then a status bit is set and an interrupt generated.
Additionally, the CAP1166 includes circuitry and support
for enhanced sensor proximity detection.
The CAP1166 offers multiple power states operating at
low quiescent currents. In the Standby state of operation,
one or more capacitive touch sensor inputs are
active and all LEDs may be used. If a touch is detected,
it will wake the system using the WAKE/SPI_MOSI pin.
Deep Sleep is the lowest power state available, drawing
5uA (typical) of current. In this state, no sensor
inputs are active. Driving the WAKE/SPI_MOSI pin or
communications will wake the device.
Applications
• Desktop and Notebook PCs
• LCD Monitors
• Consumer Electronics
• Appliances
Features
• Six (6) Capacitive Touch Sensor Inputs
- Programmable sensitivity
- Automatic recalibration
- Individual thresholds for each button
• Proximity Detection
• Multiple Button Pattern Detection
• Calibrates for Parasitic Capacitance
• Analog Filtering for System Noise Sources
• Press and Hold feature for Volume-like Applications
• Multiple Communication Interfaces
- SMBus / I2C compliant interface
- SPI communications
- Pin selectable communications protocol and
multiple slave addresses (SMBus / I2C only)
• Low Power Operation
- 5uA quiescent current in Deep Sleep
- 50uA quiescent current in Standby (1 sensor
input monitored)
- Samples one or more channels in Standby
• Six (6) LED Driver Outputs
- Open Drain or Push-Pull
- Programmable blink, breathe, and dimness
controls
- Can be linked to Capacitive Touch Sensor
inputs
• Dedicated Wake output flags touches in low
power state
• System RESET pin
• Available in 20-pin 4mm x 4mm QFN or 24-pin
SSOP RoHS compliant package
CAP1166
6 Channel Capacitive Touch Sensor with 6 LED Drivers
CAP1166
DS00001621B-page 2 2015 Microchip Technology Inc.
TO OUR VALUED CUSTOMERS
It is our intention to provide our valued customers with the best documentation possible to ensure successful use of your Microchip
products. To this end, we will continue to improve our publications to better suit your needs. Our publications will be refined and
enhanced as new volumes and updates are introduced.
If you have any questions or comments regarding this publication, please contact the Marketing Communications Department via
E-mail at docerrors@microchip.com. We welcome your feedback.
Most Current Data Sheet
To obtain the most up-to-date version of this data sheet, please register at our Worldwide Web site at:
http://www.microchip.com
You can determine the version of a data sheet by examining its literature number found on the bottom outside corner of any page.
The last character of the literature number is the version number, (e.g., DS30000000A is version A of document DS30000000).
Errata
An errata sheet, describing minor operational differences from the data sheet and recommended workarounds, may exist for current
devices. As device/documentation issues become known to us, we will publish an errata sheet. The errata will specify the
revision of silicon and revision of document to which it applies.
To determine if an errata sheet exists for a particular device, please check with one of the following:
• Microchip’s Worldwide Web site; http://www.microchip.com
• Your local Microchip sales office (see last page)
When contacting a sales office, please specify which device, revision of silicon and data sheet (include -literature number) you are
using.
Customer Notification System
Register on our web site at www.microchip.com to receive the most current information on all of our products.
2015 Microchip Technology Inc. DS00001621B-page 3
CAP1166
Table of Contents
1.0 Block Diagram ................................................................................................................................................................................. 4
2.0 Pin Description ................................................................................................................................................................................ 5
3.0 Electrical Specifications .................................................................................................................................................................. 9
4.0 Communications ........................................................................................................................................................................... 12
5.0 General Description ...................................................................................................................................................................... 23
6.0 Register Description ...................................................................................................................................................................... 29
7.0 Package Information ..................................................................................................................................................................... 67
Appendix A: Device Delta ................................................................................................................................................................... 72
Appendix B: Data Sheet Revision History ........................................................................................................................................... 74
The Microchip Web Site ...................................................................................................................................................................... 76
Customer Change Notification Service ............................................................................................................................................... 76
Customer Support ............................................................................................................................................................................... 76
Product Identification System ............................................................................................................................................................. 77
2015 Microchip Technology Inc. DS00001621B-page 4
CAP1166
1.0 BLOCK DIAGRAM
SMBus /
BC-Link or
SPI Slave
Protocol
SMCLK / BC_CLK /
SPI_CLK
SMDATA BC_DATA / SPI_MSIO/
SPI_MISO
VDD GND
ALERT# / BC_IRQ#
Capacitive Touch Sensing Algorithm
LED1
CS1 CS2 CS3 CS4 CS5 CS6
LED Driver, Breathe, and
Dimness control
RESET WAKE / SPI_MOSI
ADDR_COMM
SPI_CS#
LED2 LED3
LED4 LED5 LED6
CAP1166
DS00001621B-page 5 2015 Microchip Technology Inc.
2.0 PIN DESCRIPTION
FIGURE 2-1: CAP1166 Pin Diagram (20-Pin QFN)
1
2
3
4
15
14
13
12
20
19
18
17
6
7
8
9
5
10
11
16
CAP1166
20 pin QFN
GND
LED2
LED3
LED4
LED5
LED6
SMCLK / BC_CLK / SPI_CLK
WAKE / SPI_MOSI
SPI_CS#
LED1
SMDATA / BC_DATA / SPI_MSIO /
SPI_MISO
RESET
CS1
CS2
CS3
CS6
CS5
ADDR_COMM
CS4
ALERT# / BC_IRQ#
VDD
2015 Microchip Technology Inc. DS00001621B-page 6
CAP1166
FIGURE 2-2: CAP1166 Pin Diagram (24-pin SSOP)
TABLE 2-1: PIN DESCRIPTION FOR CAP1166
Pin
Number
(QFN 20)
Pin
Number
(SSOP 24)
Pin Name Pin Function Pin Type Unused
Connection
1 4 SPI_CS# Active low chip-select for SPI bus DI (5V) Connect to
Ground
2 5 WAKE / SPI_-
MOSI
WAKE - Active high wake / interrupt output
Standby power state - requires pull-down resistor
WAKE - Active high wake input - requires pull-down
resistor
Deep Sleep power state
DO
Pull-down
Resistor DI
SPI_MOSI - SPI Master-Out-Slave-In port when used
in normal mode DI (5V) Connect to
GND
CAP1166
24 SSOP
24
23
22
21
20
17
19
18
16
13
15
14
1
2
3
4
5
8
6
7
9
12
10
11
CS1
RESET
SPI_CS#
WAKE / SPI_MOSI
SMDATA /SPI_MSIO / SPI_MISO
SMCLK / SPI_CLK
LED1
LED2
LED3
GND LED4
GND
LED5
LED6
ALERT# / BC_IRQ#
ADDR_COMM
CS6
CS5
CS4
CS3
CS2
VDD
N/C
N/C
CAP1166
DS00001621B-page 7 2015 Microchip Technology Inc.
3 6
SMDATA /
SPI_MSIO /
SPI_MISO
SMDATA - Bi-directional, open-drain SMBus data -
requires pull-up resistor DIOD (5V)
n/a SPI_MSIO - SPI Master-Slave-In-Out bidirectional port
when used in bi-directional mode DIO
SPI_MISO - SPI Master-In-Slave-Out port when used
in normal mode DO
4 8 SMCLK /
SPI_CLK
SMCLK - SMBus clock input - requires pull-up resistor DI (5V)
SPI_CLK - SPI clock input DI (5V) n/a
5 9 LED1
Open drain LED 1 driver (default) OD (5V) Connect to
Ground
Push-pull LED 1 driver DO
leave open or
connect to
Ground
6 10 LED2
Open drain LED 2 driver (default) OD (5V) Connect to
Ground
Push-pull LED 2 driver DO
leave open or
connect to
Ground
7 11 LED3
Open drain LED 3 driver (default) OD (5V) Connect to
Ground
Push-pull LED 3 driver DO
leave open or
connect to
Ground
8 13 LED4
Open drain LED 4 driver (default) OD (5V) Connect to
Ground
Push-pull LED 4 driver DO
leave open or
connect to
Ground
9 15 LED5
Open drain LED 5 driver (default) OD (5V) Connect to
Ground
Push-pull LED 5 driver DO
leave open or
connect to
Ground
10 16 LED6
Open drain LED 6 driver (default) OD (5V) Connect to
Ground
Push-pull LED 6 driver DO
leave open or
connect to
Ground
TABLE 2-1: PIN DESCRIPTION FOR CAP1166 (CONTINUED)
Pin
Number
(QFN 20)
Pin
Number
(SSOP 24)
Pin Name Pin Function Pin Type Unused
Connection
2015 Microchip Technology Inc. DS00001621B-page 8
CAP1166
APPLICATION NOTE: When the ALERT# pinis configured as an active low output, it will be open drain. When it is
configured as an active high output, it will be push-pull.
APPLICATION NOTE: For the 5V tolerant pins that have a pull-up resistor, the pull-up voltage must not exceed 3.6V
when the CAP1166 is unpowered.
APPLICATION NOTE: The SPI_CS# pin should be grounded when SMBus, or I2C,communications are used.
The pin types are described in Table 2-2. All pins labeled with (5V) are 5V tolerant.
11 17 ALERT#
ALERT# - Active low alert / interrupt output for SMBus
alert or SPI interrupt
- requires pull-up resistor (default)
OD (5V) Connect to
GND
ALERT# - Active high push-pull alert / interrupt output
for SMBus alert or SPI interrupt DO High-Z
12 18 ADDR_
COMM
Address / communications select pin - pull-down resistor
determines address / communications mechanism AI n/a
13 19 CS6 Capacitive Touch Sensor Input 6 AIO Connect to
Ground
14 20 CS5 Capacitive Touch Sensor Input 5 AIO Connect to
Ground
15 21 CS4 Capacitive Touch Sensor Input 4 AIO Connect to
Ground
16 22 CS3 Capacitive Touch Sensor Input 3 AIO Connect to
Ground
17 23 CS2 Capacitive Touch Sensor Input 2 AIO Connect to
Ground
18 24 CS1 Capacitive Touch Sensor Input 1 AIO Connect to
Ground
19 1 VDD Positive Power supply Power n/a
20 1 RESET Active high soft reset for system - resets all registers to
default values. If not used, connect to ground. DI (5V) Connect to
Ground
Bottom Pad
12 GND Ground Power n/a
14 GND Ground Power n/a
TABLE 2-1: PIN DESCRIPTION FOR CAP1166 (CONTINUED)
Pin
Number
(QFN 20)
Pin
Number
(SSOP 24)
Pin Name Pin Function Pin Type Unused
Connection
CAP1166
DS00001621B-page 9 2015 Microchip Technology Inc.
TABLE 2-2: PIN TYPES
Pin Type Description
Power This pin is used to supply power or ground to the device.
DI Digital Input - This pin is used as a digital input. This pin is 5V tolerant.
AIO Analog Input / Output -This pin is used as an I/O for analog signals.
DIOD Digital Input / Open Drain Output - This pin is used as a digital I/O. When it is used as an output,
it is open drain and requires a pull-up resistor. This pin is 5V tolerant.
OD Open Drain Digital Output - This pin is used as a digital output. It is open drain and requires a
pull-up resistor. This pin is 5V tolerant.
DO Push-pull Digital Output - This pin is used as a digital output and can sink and source current.
DIO Push-pull Digital Input / Output - This pin is used as an I/O for digital signals.
2015 Microchip Technology Inc. DS00001621B-page 10
CAP1166
3.0 ELECTRICAL SPECIFICATIONS
Note 3-1 Stresses above those listed could cause permanent damage to the device. This is a stress rating
only and functional operation of the device at any other condition above those indicated in the
operation sections of this specification is not implied.
Note 3-2 For the 5V tolerant pins that have a pull-up resistor, the voltage difference between V5VT_PIN and VDD
must never exceed 3.6V.
Note 3-3 The Package Power Dissipation specification assumes a recommended thermal via design consisting
of a 3x3 matrix of 0.3mm (12mil) vias at 1.0mm pitch connected to the ground plane with a 2.5 x
2.5mm thermal landing.
Note 3-4 Junction to Ambient (θJA) is dependent on the design of the thermal vias. Without thermal vias and
a thermal landing, the θJA is approximately 60°C/W including localized PCB temperature increase.
TABLE 3-1: ABSOLUTE MAXIMUM RATINGS
Voltage on 5V tolerant pins (V5VT_PIN) -0.3 to 5.5 V
Voltage on 5V tolerant pins (|V5VT_PIN - VDD|) Note 3-2 0 to 3.6 V
Voltage on VDD pin -0.3 to 4 V
Voltage on any other pin to GND -0.3 to VDD + 0.3 V
Package Power Dissipation up to TA = 85°C for 20 pin QFN
(see Note 3-3)
0.9 W
Junction to Ambient (θJA) (see Note 3-4) 58 °C/W
Operating Ambient Temperature Range -40 to 125 °C
Storage Temperature Range -55 to 150 °C
ESD Rating, All Pins, HBM 8000 V
CAP1166
DS00001621B-page 11 2015 Microchip Technology Inc.
TABLE 3-2: ELECTRICAL SPECIFICATIONS
VDD = 3V to 3.6V, TA = 0°C to 85°C, all typical values at TA = 27°C unless otherwise noted.
Characteristic Symbol Min Typ Max Unit Conditions
DC Power
Supply Voltage VDD 3.0 3.3 3.6 V
Supply Current
ISTBY 120 170 uA
Standby state active
1 sensor input monitored
No LEDs active
Default conditions (8 avg, 70ms
cycle time)
ISTBY 50 uA
Standby state active
1 sensor input monitored
No LEDs active
1 avg, 140ms cycle time,
IDSLEEP 5 15 uA
Deep Sleep state active
LEDs at 100% or 0% Duty Cycle
No communications
TA < 40°C
3.135 < VDD < 3.465V
IDD 500 600 uA Capacitive Sensing Active
No LEDs active
Capacitive Touch Sensor Inputs
Maximum Base
Capacitance CBASE 50 pF Pad untouched
Minimum Detectable
Capacitive Shift ΔCTOUCH 20 fF
Pad touched - default conditions (1
avg, 35ms cycle time, 1x sensitivity)
Recommended Cap
Shift ΔCTOUCH 0.1 2 pF Pad touched - Not tested
Power Supply Rejection
PSR ±3 ±10 counts /
V
Untouched Current Counts
Base Capacitance 5pF - 50pF
Maximum sensitivity
Negative Delta Counts disabled
All other parameters default
Timing
RESET Pin Delay tRST_DLY 10 ms
Time to communications
ready tCOMM_DLY 15 ms
Time to first conversion
ready tCONV_DLY 170 200 ms
LED Drivers
Duty Cycle DUTYLED 0 100 % Programmable
Drive Frequency fLED 2 kHz
Sinking Current ISINK 24 mA VOL = 0.4
Sourcing Current ISOURCE 24 mA VOH = VDD - 0.4
Leakage Current ILEAK ±5 uA
powered or unpowered
TA < 85°C
pull-up voltage < 3.6V if unpowered
I/O Pins
Output Low Voltage VOL 0.4 V ISINK_IO = 8mA
Output High Voltage VOH VDD - 0.4 V ISOURCE_IO = 8mA
2015 Microchip Technology Inc. DS00001621B-page 12
CAP1166
Note 3-5 The ALERT pin will not glitch high or low at power up if connected to VDD or another voltage.
Note 3-6 The SMCLK and SMDATA pins will not glitch low at power up if connected to VDD or another voltage.
Input High Voltage VIH 2.0 V
Input Low Voltage VIL 0.8 V
Leakage Current ILEAK ±5 uA
powered or unpowered
TA < 85°C
pull-up voltage < 3.6V if unpowered
RESET Pin Release
to conversion ready tRESET 170 200 ms
SMBus Timing
Input Capacitance CIN 5 pF
Clock Frequency fSMB 10 400 kHz
Spike Suppression tSP 50 ns
Bus Free Time Stop to
Start tBUF 1.3 us
Start Setup Time tSU:STA 0.6 us
Start Hold Time tHD:STA 0.6 us
Stop Setup Time tSU:STO 0.6 us
Data Hold Time tHD:DAT 0 us When transmitting to the master
Data Hold Time tHD:DAT 0.3 us When receiving from the master
Data Setup Time tSU:DAT 0.6 us
Clock Low Period tLOW 1.3 us
Clock High Period tHIGH 0.6 us
Clock / Data Fall Time tFALL 300 ns Min = 20+0.1CLOAD ns
Clock / Data Rise
Time tRISE 300 ns Min = 20+0.1CLOAD ns
Capacitive Load CLOAD 400 pF per bus line
SPI Timing
Clock Period tP 250 ns
Clock Low Period tLOW 0.4 x tP 0.6 x tP ns
Clock High Period tHIGH 0.4 x tP 0.6 x tP ns
Clock Rise / Fall time tRISE / tFALL 0.1 x tP ns
Data Output Delay tD:CLK 10 ns
Data Setup Time tSU:DAT 20 ns
Data Hold Time tHD:DAT 20 ns
SPI_CS# to SPI_CLK
setup time tSU:CS 0 ns
Wake Time tWAKE 10 20 us SPI_CS# asserted to CLK assert
TABLE 3-2: ELECTRICAL SPECIFICATIONS (CONTINUED)
VDD = 3V to 3.6V, TA = 0°C to 85°C, all typical values at TA = 27°C unless otherwise noted.
Characteristic Symbol Min Typ Max Unit Conditions
2015 Microchip Technology Inc. DS00001621B-page 13
CAP1166
4.0 COMMUNICATIONS
4.1 Communications
The CAP1166communicates using the 2-wire SMBus or I2C bus, the 2-wire proprietary BC-Link, or the SPI bus. If the
proprietary BC-Link protocol is required for your application, please contact your Microchip representative for ordering
instructions. Regardless of communication mechanism, the device functionality remains unchanged. The communications
mechanism as well as the SMBus (or I2C) slave address is determined by the resistor connected between the
ADDR_COMM pin and ground as shown in Table 4-1.
4.1.1 SMBUS (I2C) COMMUNICATIONS
When configured to communicate via the SMBus, the CAP1166 supports the following protocols: Send Byte, Receive
Byte, Read Byte, Write Byte, Read Block, and Write Block. In addition, the device supports I2C formatting for block read
and block write protocols.
APPLICATION NOTE: For SMBus/I2C communications, the SPI_CS# pin is not used and should be grounded; any
data presented to this pin will be ignored.
See Section 4.2 and Section 4.3 for more information on the SMBus bus and protocols respectively.
4.1.2 SPI COMMUNICATIONS
When configured to communicate via the SPI bus, the CAP1166supports both bi-directional 3-wire and normal 4-wire
protocols and uses the SPI_CS# pin to enable communications.
APPLICATION NOTE: See Section 4.5 and Section 4.6 for more information on the SPI bus and protocols
respectively.Upon power up, the CAP1166 will not respond to any communications for up to
15ms. After this time, full functionality is available.
4.2 System Management Bus
The CAP1166 communicates with a host controller, such as an SIO, through the SMBus. The SMBus is a two-wire serial
communication protocol between a computer host and its peripheral devices. A detailed timing diagram is shown in
Figure 4-1. Stretching of the SMCLK signal is supported; however, the CAP1166 will not stretch the clock signal.
TABLE 4-1: ADDR_COMM PIN DECODE
Pull-Down Resistor (+/- 5%) Protocol Used SMBus Address
GND SPI Communications using Normal
4-wire Protocol Used
n/a
56k SPI Communications using BiDirectional
3-wire Protocol Used
n/a
68k Reserved n/a
82k SMBus / I2C 0101_100(r/w)
100k SMBus / I2C 0101_011(r/w)
120k SMBus / I2C 0101_010(r/w)
150k SMBus / I2C 0101_001(r/w)
VDD SMBus / I2C 0101_000(r/w)
CAP1166
DS00001621B-page 14 2015 Microchip Technology Inc.
4.2.1 SMBUS START BIT
The SMBus Start bit is defined as a transition of the SMBus Data line from a logic ‘1’ state to a logic ‘0’ state while the
SMBus Clock line is in a logic ‘1’ state.
4.2.2 SMBUS ADDRESS AND RD / WR BIT
The SMBus Address Byte consists of the 7-bit slave address followed by the RD / WR indicator bit. If this RD / WR bit
is a logic ‘0’, then the SMBus Host is writing data to the slave device. If this RD / WR bit is a logic ‘1’, then the SMBus
Host is reading data from the slave device.
See Table 4-1 for available SMBus addresses.
4.2.3 SMBUS DATA BYTES
All SMBus Data bytes are sent most significant bit first and composed of 8-bits of information.
4.2.4 SMBUS ACK AND NACK BITS
The SMBus slave will acknowledge all data bytes that it receives. This is done by the slave device pulling the SMBus
Data line low after the 8th bit of each byte that is transmitted. This applies to both the Write Byte and Block Write protocols.
The Host will NACK (not acknowledge) the last data byte to be received from the slave by holding the SMBus data line
high after the 8th data bit has been sent. For the Block Read protocol, the Host will ACK each data byte that it receives
except the last data byte.
4.2.5 SMBUS STOP BIT
The SMBus Stop bit is defined as a transition of the SMBus Data line from a logic ‘0’ state to a logic ‘1’ state while the
SMBus clock line is in a logic ‘1’ state. When the CAP1166 detects an SMBus Stop bit and it has been communicating
with the SMBus protocol, it will reset its slave interface and prepare to receive further communications.
4.2.6 SMBUS TIMEOUT
The CAP1166 includes an SMBus timeout feature. Following a 30ms period of inactivity on the SMBus where the
SMCLK pin is held low, the device will timeout and reset the SMBus interface.
The timeout function defaults to disabled. It can be enabled by setting the TIMEOUT bit in the Configuration register
(see Section 6.6, "Configuration Registers").
4.2.7 SMBUS AND I2C COMPATIBILITY
The major differences between SMBus and I2C devices are highlighted here. For more information, refer to the SMBus
2.0 and I2C specifications. For information on using the CAP1166 in an I2C system, refer to AN 14.0 Dedicated Slave
Devices in I2C Systems.
FIGURE 4-1: SMBus Timing Diagram
SMDATA
SMCLK
TLOW
TRISE
THIGH
TFALL
TBUF
THD:STA
P S S - Start Condition P - Stop Condition
THD:DAT TSU:DAT TSU:STA
THD:STA
P
TSU:STO
S
2015 Microchip Technology Inc. DS00001621B-page 15
CAP1166
1. CAP1166 supports I2C fast mode at 400kHz. This covers the SMBus max time of 100kHz.
2. Minimum frequency for SMBus communications is 10kHz.
3. The SMBus slave protocol will reset if the clock is held at a logic ‘0’ for longer than 30ms. This timeout functionality
is disabled by default in the CAP1166 and can be enabled by writing to the TIMEOUT bit. I2C does not have
a timeout.
4. The SMBus slave protocol will reset if both the clock and data lines are held at a logic ‘1’ for longer than 200µs
(idle condition). This function is disabled by default in the CAP1166 and can be enabled by writing to the TIMEOUT
bit. I2C does not have an idle condition.
5. I2C devices do not support the Alert Response Address functionality (which is optional for SMBus).
6. I2C devices support block read and write differently. I2C protocol allows for unlimited number of bytes to be sent
in either direction. The SMBus protocol requires that an additional data byte indicating number of bytes to read /
write is transmitted. The CAP1166 supports I2C formatting only.
4.3 SMBus Protocols
The CAP1166 is SMBus 2.0 compatible and supports Write Byte, Read Byte, Send Byte, and Receive Byte as valid
protocols as shown below.
All of the below protocols use the convention in Table 4-2.
4.3.1 SMBUS WRITE BYTE
The Write Byte is used to write one byte of data to a specific register as shown in Table 4-3.
4.3.2 SMBUS READ BYTE
The Read Byte protocol is used to read one byte of data from the registers as shown in Table 4-4.
4.3.3 SMBUS SEND BYTE
The Send Byte protocol is used to set the internal address register pointer to the correct address location. No data is
transferred during the Send Byte protocol as shown in Table 4-5.
APPLICATION NOTE: The Send Byte protocol is not functional in Deep Sleep (i.e., DSLEEP bit is set).
TABLE 4-2: PROTOCOL FORMAT
Data Sent to
Device
Data Sent to the
HOst
Data sent Data sent
TABLE 4-3: WRITE BYTE PROTOCOL
Start Slave
Address WR ACK Register
Address ACK Register Data ACK Stop
1 ->0 YYYY_YYY 0 0 XXh 0 XXh 0 0 -> 1
TABLE 4-4: READ BYTE PROTOCOL
Start Slave
Address WR ACK Register
Address ACK Start Slave
Address RD ACK Register
Data NACK Stop
1->0 YYYY_YYY 0 0 XXh 0 1 ->0 YYYY_YYY 1 0 XXh 1 0 -> 1
TABLE 4-5: SEND BYTE PROTOCOL
Start Slave Address WR ACK Register Address ACK Stop
1 -> 0 YYYY_YYY 0 0 XXh 0 0 -> 1
CAP1166
DS00001621B-page 16 2015 Microchip Technology Inc.
4.3.4 SMBUS RECEIVE BYTE
The Receive Byte protocol is used to read data from a register when the internal register address pointer is known to
be at the right location (e.g., set via Send Byte). This is used for consecutive reads of the same register as shown in
Table 4-6.
APPLICATION NOTE: The Receive Byte protocol is not functional in Deep Sleep (i.e., DSLEEP bit is set).
4.4 I2C Protocols
The CAP1166 supports I2C Block Write and Block Read.
The protocols listed below use the convention in Table 4-2.
4.4.1 BLOCK WRITE
The Block Write is used to write multiple data bytes to a group of contiguous registers as shown in Table 4-7.
APPLICATION NOTE: When using the Block Write protocol, the internal address pointer will be automatically
incremented after every data byte is received. It will wrap from FFh to 00h.
4.4.2 BLOCK READ
The Block Read is used to read multiple data bytes from a group of contiguous registers as shown in Table 4-8.
APPLICATION NOTE: When using the Block Read protocol, the internal address pointer will be automatically
incremented after every data byte is received. It will wrap from FFh to 00h.
4.5 SPI Interface
The SMBus has a predefined packet structure, the SPI does not. The SPI Bus can operate in two modes of operation,
normal 4-wire mode and bi-directional 3-wire mode. All SPI commands consist of 8-bit packets sent to a specific slave
device (identified by the CS pin).
The SPI bus will latch data on the rising edge of the clock and the clock and data both idle high.
All commands are supported via both operating modes. The supported commands are: Reset Serial interface, set
address pointer, write command and read command. Note that all other codes received during the command phase are
ignored and have no effect on the operation of the device.
TABLE 4-6: RECEIVE BYTE PROTOCOL
Start Slave Address RD ACK Register Data NACK Stop
1 -> 0 YYYY_YYY 1 0 XXh 1 0 -> 1
TABLE 4-7: BLOCK WRITE PROTOCOL
Start Slave
Address WR ACK Register
Address ACK Register Data ACK
1 ->0 YYYY_YYY 0 0 XXh 0 XXh 0
Register Data ACK Register
Data
ACK . . . Register
Data
ACK Stop
XXh 0 XXh 0 . . . XXh 0 0 -> 1
TABLE 4-8: BLOCK READ PROTOCOL
Start Slave
Address WR ACK Register
Address ACK Start Slave
Address RD ACK Register
Data
1->0 YYYY_YYY 0 0 XXh 0 1 ->0 YYYY_YYY 1 0 XXh
ACK Register
Data
ACK Register
Data
ACK Register
Data
ACK . . . Register
Data
NACK Stop
0 XXh 0 XXh 0 XXh 0 . . . XXh 1 0 -> 1
2015 Microchip Technology Inc. DS00001621B-page 17
CAP1166
4.5.1 SPI NORMAL MODE
The SPI Bus can operate in two modes of operation, normal and bi-directional mode. In the normal mode of operation,
there are dedicated input and output data lines. The host communicates by sending a command along the CAP1166
SPI_MOSI data line and reading data on the SPI_MISO data line. Both communications occur simultaneously which
allows for larger throughput of data transactions.
All basic transfers consist of two 8 bit transactions from the Master device while the slave device is simultaneously sending
data at the current address pointer value.
Data writes consist of two or more 8-bit transactions. The host sends a specific write command followed by the data to
write the address pointer. Data reads consist of one or more 8-bit transactions. The host sends the specific read data
command and continues clocking for as many data bytes as it wishes to receive.
4.5.2 SPI BI-DIRECTIONAL MODE
In the bi-directional mode of operation, the SPI data signals are combined into the SPI_MSIO line, which is shared for
data received by the device and transmitted by the device. The protocol uses a simple handshake and turn around
sequence for data communications based on the number of clocks transmitted during each phase.
All basic transfers consist of two 8 bit transactions. The first is an 8 bit command phase driven by the Master device.
The second is by an 8 bit data phase driven by the Master for writes, and by the CAP1166 for read operations.
The auto increment feature of the address pointer allows for successive reads or writes. The address pointer will return
to 00h after reaching FFh.
4.5.3 SPI_CS# PIN
The SPI Bus is a single master, multiple slave serial bus. Each slave has a dedicated CS pin (chip select) that the master
asserts low to identify that the slave is being addressed. There are no formal addressing options.
4.5.4 ADDRESS POINTER
All data writes and reads are accessed from the current address pointer. In both Bi-directional mode and Full Duplex
mode, the Address pointer is automatically incremented following every read command or every write command.
The address pointer will return to 00h after reaching FFh.
4.5.5 SPI TIMEOUT
The CAP1166 does not detect any timeout conditions on the SPI bus.
FIGURE 4-2: SPI Timing
SPI_MSIO or
SPI_MOSI or
SPI_MISO
SPI_CLK
tLOW
tRISE
tHIGH
tFALL
tD:CLK tHD:DAT
tSU:DAT
tP
2015 Microchip Technology Inc. DS00001621B-page 18
CAP1166 4.6 Normal SPI Protocols When operating in normal mode, the SPI bus internal address pointer is incremented depending upon which command has been transmitted. Multiple commands may be transmitted sequentually so long as the SPI_CS# pin is asserted low. Figure 4-3 shows an example of this operation.
4.6.1 RESET INTERFACE
Resets the Serial interface whenever two successive 7Ah codes are received. Regardless of the current phase of the transaction - command or data, the receipt of the
successive reset commands resets the Serial communication interface only. All other functions are not affected by the reset operation.
FIGURE 4-3: Example SPI Bus Communication - Normal Mode
SPI_CS#
SPI_MISO
SPI_MOSI
SPI Address Pointer
SPI Data output buffer
Register Address /
Data
7Ah
XXh
(invalid)
XXh
(invalid)
YYh
(invalid)
7Ah 7Dh 41h
YYh
(invalid)
7Eh 66h
XXh
(invalid) 45h
7Dh 41h
AAh
(invalid)
AAh
(invalid)
7Fh 7Fh
55h
(invalid) 66h
7Fh
AAh
7Dh
43h
40h
78h
7Fh
XXh
(invalid)
7Fh
56h
40h / 56h
41h / 45h
42h / AAh
43h / 55h
44h / 80h
45h / 43h
46h / 78h
41h
45h
40h / 56h
41h / 45h
42h / AAh
43h / 55h
44h / 80h
45h / 43h
46h / 78h
42h
AAh
40h / 56h
41h / 66h
42h / AAh
43h / 55h
44h / 80h
45h / 43h
46h / 78h
41h
55h
7Fh
AAh
40h / 56h
41h / 66h
42h / AAh
43h / 55h
44h / 80h
45h / 43h
46h / 78h
41h
66h
42h
AAh
40h / 56h
41h / 66h
42h / AAh
43h / 55h
44h / 80h
45h / 43h
46h / 78h
40h / 56h
41h / 66h
42h / AAh
43h / 55h
44h / 80h
45h / 43h
46h / 78h
40h / 56h
41h / 66h
42h / AAh
43h / 55h
44h / 80h
45h / 43h
46h /78h
44h
80h
40h
80h
40h
56h
40h / 56h
41h / 66h
42h / AAh
43h / 55h
44h / 80h
45h / 43h
46h /78h
43h
55h
7Fh 7Fh
55h
40h / 56h
41h / 66h
42h / AAh
43h / 55h
44h / 80h
45h / 43h
46h /78h
80h
45h
43h
46h
78h
40h / 56h
41h / 66h
42h / AAh
43h / 55h
44h / 80h
45h / 43h
46h / 78h
00h
XXh
Indicates SPI Address pointer incremented
2015 Microchip Technology Inc. DS00001621B-page 19
CAP1166
4.6.2 SET ADDRESS POINTER
The Set Address Pointer command sets the Address pointer for subsequent reads and writes of data. The pointer is set
on the rising edge of the final data bit. At the same time, the data that is to be read is fetched and loaded into the internal
output buffer but is not transmitted.
4.6.3 WRITE DATA
The Write Data protocol updates the contents of the register referenced by the address pointer. As the command is processed,
the data to be read is fetched and loaded into the internal output buffer but not transmitted. Then, the register
is updated with the data to be written. Finally, the address pointer is incremented.
FIGURE 4-4: SPI Reset Interface Command - Normal Mode
FIGURE 4-5: SPI Set Address Pointer Command - Normal Mode
Master SPDOUT
SPI_MOSI
SPI_CS#
SPI_CLK
Reset - 7Ah Reset - 7Ah
Invalid register data 00h – Internal Data buffer empty SPI_MISO
Master Drives Slave Drives
‘0’ ‘1’ ‘1’ ‘1’ ‘1’ ‘0’ ‘1’ ‘0’ ‘0’ ‘1’ ‘1’ ‘1’ ‘1’ ‘0’ ‘1’ ‘0’
Master SPDOUT
SPI_MOSI Register Address
SPI_CS#
SPI_CLK
Set Address Pointer – 7Dh
SPI_MISO Unknown, Invalid Data Unknown, Invalid Data
Master Drives Slave Drives Address pointer set
‘0’ ‘0’ ‘1’ ‘1’ ‘1’ ‘1’ ‘1’ ‘1’
CAP1166
DS00001621B-page 20 2015 Microchip Technology Inc.
4.6.4 READ DATA
The Read Data protocol is used to read data from the device. During the normal mode of operation, while the device is
receiving data, the CAP1166 is simultaneously transmitting data to the host. For the Set Address commands and the
Write Data commands, this data may be invalid and it is recommended that the Read Data command is used.
FIGURE 4-6: SPI Write Command - Normal Mode
FIGURE 4-7: SPI Read Command - Normal Mode
Master SPDOUT
SPI_MOSI Data to Write
SPI_CS#
SPI_CLK
Write Command – 7Eh
Unknown, Invalid Data Old Data at Current Address Pointer SPI_MISO
Master Drives Slave Drives
1. Data written at current
address pointer
2. Address pointer incremented
Master SPDOUT
SPI_MOSI
Master Drives Slave Drives
SPI_CLK
First Read Command – 7Fh
SPI_CS#
SPI_MISO Invalid, Unknown Data *
‘0’ ‘1’ ‘1’ ‘1’ ‘1’ ‘1’ ‘1’ ‘1’
Subsequent Read
Commands – 7F
Data at Current Address Pointer
Address Pointer
Incremented **
‘0’ ‘1’ ‘1’ ‘1’ ‘1’ ‘1’ ‘1’ ‘1’
* The first read command after any other command will return invalid data for the first
byte. Subsequent read commands will return the data at the Current Address Pointer
** The Address Pointer is incremented 8 clocks after the Read Command has been
received. Therefore continually sending Read Commands will result in each command
reporting new data. Once Read Commands have been finished, the last data byte will be
read during the next 8 clocks for any command
2015 Microchip Technology Inc. DS00001621B-page 21
CAP1166
4.7 Bi-Directional SPI Protocols
4.7.1 RESET INTERFACE
Resets the Serial interface whenever two successive 7Ah codes are received. Regardless of the current phase of the
transaction - command or data, the receipt of the successive reset commands resets the Serial communication interface
only. All other functions are not affected by the reset operation.
4.7.2 SET ADDRESS POINTER
Sets the address pointer to the register to be accessed by a read or write command. This command overrides the autoincrementing
of the address pointer.
FIGURE 4-8: SPI Read Command - Normal Mode - Full
FIGURE 4-9: SPI Reset Interface Command - Bi-directional Mode
Master SPDOUT
SPI_MOSI
Master Drives Slave Drives
SPI_CLK
Read Command – 7Fh
SPI_CS#
Data at previously set register address = current
address pointer
SPI_MISO ‘0’ ‘1’ ‘1’ ‘1’ ‘1’ ‘1’ ‘1’ ‘1’
Data at previously set register address = current
address pointer (SPI)
XXh
1. Register Read Address
updated to Current SPI Read
Address pointer
1. Register data loaded into
output buffer = data at current
address pointer
1. Output buffer transmitted =
data at previous address
pointer + 1 = current address
pointer
1. Register Read Address
incremented = current address
pointer + 1
1. SPI Read Address
Incremented = new current
address pointer
2. Register Read Address
Incremented = current address
pointer +1
Register Data loaded into
Output buffer = data at current
address pointer + 1
1. Output buffer transmitted =
data at current address pointer
+ 1
2. Flag set to increment SPI
Read Address at end of next 8
clocks
‘0’ ‘1’ ‘1’ ‘1’ ‘1’ ‘1’ ‘1’ ‘1’
Data at previously set register address = current
address pointer (SPI)
1. Register data loaded into
output buffer = data at current
address pointer
1. Output buffer transmitted =
data at previous register
address pointer + 1 = current
address pointer
1. Output buffer transmitted =
data at current address pointer
+ 1
2. Flag set to increment SPI
Read Address at end of next 8
clocks
Subsequent Read Commands – 7Fh
1. Register Read Address
updated to Current SPI Read
Address pointer.
2. Register Read Address
incremented = current address
pointer +1 – end result =
register address pointer doesn’t
change
Master SPDOUT
SPI_MSIO
SPI_CS#
SPI_CLK
Reset - 7Ah Reset - 7Ah
‘0’ ‘0’ ‘0’ ‘1’ ‘1’ ‘1’ ‘1’ ‘1’ ‘0’ ‘0’ ‘0’ ‘1’ ‘1’ ‘1’ ‘1’ ‘1’
CAP1166
DS00001621B-page 22 2015 Microchip Technology Inc.
4.7.3 WRITE DATA
Writes data value to the register address stored in the address pointer. Performs auto increment of address pointer after
the data is loaded into the register.
4.7.4 READ DATA
Reads data referenced by the address pointer. Performs auto increment of address pointer after the data is transferred
to the Master.
FIGURE 4-10: SPI Set Address Pointer Command - Bi-directional Mode
FIGURE 4-11: SPI Write Data Command - Bi-directional Mode
FIGURE 4-12: SPI Read Data Command - Bi-directional Mode
Master SPDOUT
SPI_MSIO Register Address
SPI_CS#
SPI_CLK
Set Address Pointer – 7Dh
‘0’ ‘1’ ‘0’ ‘1’ ‘1’ ‘1’ ‘1’ ‘1’
Master SPDOUT
SPI_MSIO Register Write Data
SPI_CS#
SPI_CLK
Write Command – 7Eh
‘0’ ‘1’ ‘1’ ‘1’ ‘1’ ‘1’ ‘1’ ‘0’
Master SPDOUT
SPI_MSIO
Master Drives Slave Drives Indeterminate
Register Read Data
SPI_CLK
Read Command – 7Fh
SPI_CS#
‘0’ ‘1’ ‘1’ ‘1’ ‘1’ ‘1’ ‘1’ ‘1’
2015 Microchip Technology Inc. DS00001621B-page 23
CAP1166
4.8 BC-Link Interface
The BC-Link is a proprietary bus developed to allow communication between a host controller device to a companion
device. This device uses this serial bus to read and write registers and for interrupt processing. The interface uses a
data port concept, where the base interface has an address register, data register and a control register, defined in the
8051’s SFR space.
Refer to documentation for the BC-Link compatible host controller for details on how to access the CAP1166 via the BCLink
Interface.
2015 Microchip Technology Inc. DS00001621B-page 24
CAP1166
5.0 GENERAL DESCRIPTION
The CAP1166 is a multiple channel Capacitive Touch sensor with multiple power LED drivers. It contains six (6) individual
capacitive touch sensor inputs with programmable sensitivity for use in touch sensor applications. Each sensor input
automatically recalibrates to compensate for gradual environmental changes.
The CAP1166 also contains six (6) low side (or push-pull) LED drivers that offer full-on / off, variable rate blinking, dimness
controls, and breathing. Each of the LED drivers may be linked to one of the sensor inputs to be actuated when a
touch is detected. As well, each LED driver may be individually controlled via a host controller.
Finally, the device contains a dedicated RESET pin to act as a soft reset by the system.
The CAP1166 offers multiple power states. It operates at the lowest quiescent current during its Deep Sleep state. In
the low power Standby state, it can monitor one or more channels and respond to communications normally. The device
contains a wake pin (WAKE/SPI_MOSI) output to wake the system when a touch is detected in Standby and to wake
the device from Deep Sleep.
The device communicates with a host controller using the SPI bus, or via SMBus / I2C. The host controller may poll the
device for updated information at any time or it may configure the device to flag an interrupt whenever a touch is
detected on any sensor pad.
A typical system diagram is shown in Figure 5-1.
CAP1166
DS00001621B-page 25 2015 Microchip Technology Inc.
5.1 Power States
The CAP1166 has three operating states depending on the status of the STBY and DSLEEP bits. When the device transitions
between power states, previously detected touches (for inactive channels) are cleared and the status bits reset.
1. Fully Active - The device is fully active. It is monitoring all active capacitive sensor inputs and driving all LED channels
as defined.
2. Standby - The device is in a lower power state. It will measure a programmable number of channels using the
Standby Configuration controls (see Section 6.20 through Section 6.22). Interrupts will still be generated based
on the active channels. The device will still respond to communications normally and can be returned to the Fully
FIGURE 5-1: System Diagram for CAP1166
CAP1166
CS4
SMDATA / BC_DATA / SPI_MSIO / SPI_MISO
SMCLK / BC_CLK / SPI_CLK
VDD Embedded Controller ALERT# / BC_IRQ#
CS5
CS6
3.3V – 5V
CS3
CS2
CS1
WAKE / SPI_MOSI
RESET
SPI_CS#
ADDR_COMM
LED6
LED5
LED4
LED1
LED2
LED3
3.3V – 5V
Touch
Button
Touch
Button
Touch
Button
Touch
Button
Touch
Button
Touch
Button
2015 Microchip Technology Inc. DS00001621B-page 26
CAP1166
Active state of operation by clearing the STBY bit.
3. Deep Sleep - The device is in its lowest power state. It is not monitoring any capacitive sensor inputs and not
driving any LEDs. All LEDs will be driven to their programmed non-actuated state and no PWM operations will
be done. While in Deep Sleep, the device can be awakened by SMBus or SPI communications targeting the
device. This will not cause the DSLEEP to be cleared so the device will return to Deep Sleep once all communications
have stopped.
If the device is not communicating via the 4-wire SPI bus, then during this state of operation, if the WAKE/SPI_MOSI
pin is driven high by an external source, the device will clear the DSLEEP bit and return to Fully Active.
APPLICATION NOTE: In the Deep Sleep state, the LED output will be either high or low and will not be PWM’d at
the min or max duty cycle.
5.2 RESET Pin
The RESET pin is an active high reset that is driven from an external source. While it is asserted high, all the internal
blocks will be held in reset including the communications protocol used. No capacitive touch sensor inputs will be sampled
and the LEDs will not be driven. All configuration settings will be reset to default states and all readings will be
cleared.
The device will be held in Deep Sleep that can only be removed by driving the RESET pin low. This will cause the
RESET status bit to be set to a logic ‘1’ and generate an interrupt.
5.3 WAKE/SPI_MOSI Pin Operation
The WAKE / SPI_MOSI pin is a multi-function pin depending on device operation. When the device is configured to communicate
using the 4-wire SPI bus, this pin is an input.
However, when the CAP1166 is placed in Standby and is not communicating using the 4-wire SPI protocol, the WAKE
pin is an active high output. In this condition, the device will assert the WAKE/SPI_MOSI pin when a touch is detected
on one of its sampled sensor inputs. The pin will remain asserted until the INT bit has been cleared and then it will be
de-asserted.
When the CAP1166 is placed in Deep Sleep and it is not communicating using the 4-wire SPI protocol, the WAKE/SPI_-
MOSI pin is monitored by the device as an input. If the WAKE/SPI_MOSI pin is driven high by an external source, the
CAP1166will clear the DSLEEP bit causing the device to return to Fully Active.
When the device is placed in Deep Sleep, this pin is a High-Z input and must have a pull-down resistor to GND for proper
operation.
5.4 LED Drivers
The CAP1166 contains six (6) LED drivers. Each LED driver can be linked to its respective capacitive touch sensor input
or it can be controlled by the host. Each LED driver can be configured to operate in one of the following modes with
either push-pull or open drain drive.
1. Direct - The LED is configured to be on or off when the corresponding input stimulus is on or off (or inverted). The
brightness of the LED can be programmed from full off to full on (default). Additionally, the LED contains controls
to individually configure ramping on, off, and turn-off delay.
2. Pulse 1 - The LED is configured to “Pulse” (transition ON-OFF-ON) a programmable number of times with programmable
rate and min / max brightness. This behavior may be actuated when a press is detected or when a
release is detected.
3. Pulse 2 - The LED is configured to “Pulse” while actuated and then “Pulse” a programmable number of times with
programmable rate and min / max brightness when the sensor pad is released.
4. Breathe - The LED is configured to transition continuously ON-OFF-ON (i.e. to “Breathe”) with a programmable
rate and min / max brightness.
When an LED is not linked to a sensor and is actuated by the host, there’s an option to assert the ALERT# pin when
the initiated LED behavior has completed.
5.4.1 LINKING LEDS TO CAPACITIVE TOUCH SENSOR INPUTS
All LEDs can be linked to the corresponding capacitive touch sensor input so that when the sensor input detects a touch,
the corresponding LED will be actuated at one of the programmed responses.
CAP1166
DS00001621B-page 27 2015 Microchip Technology Inc.
5.5 Capacitive Touch Sensing
The CAP1166 contains six (6) independent capacitive touch sensor inputs. Each sensor input has dynamic range to
detect a change of capacitance due to a touch. Additionally, each sensor input can be configured to be automatically
and routinely re-calibrated.
5.5.1 SENSING CYCLE
Each capacitive touch sensor input has controls to be activated and included in the sensing cycle. When the device is
active, it automatically initiates a sensing cycle and repeats the cycle every time it finishes. The cycle polls through each
active sensor input starting with CS1 and extending through CS6. As each capacitive touch sensor input is polled, its
measurement is compared against a baseline “Not Touched” measurement. If the delta measurement is large enough,
a touch is detected and an interrupt is generated.
The sensing cycle time is programmable (see Section 6.10, "Averaging and Sampling Configuration Register").
5.5.2 RECALIBRATING SENSOR INPUTS
There are various options for recalibrating the capacitive touch sensor inputs. Recalibration re-sets the Base Count Registers
(Section 6.24, "Sensor Input Base Count Registers") which contain the “not touched” values used for touch detection
comparisons.
APPLICATION NOTE: The device will recalibrate all sensor inputs that were disabled when it transitions from
Standby. Likewise, the device will recalibrate all sensor inputs when waking out of Deep
Sleep.
5.5.2.1 Manual Recalibration
The Calibration Activate Registers (Section 6.11, "Calibration Activate Register") force recalibration of selected sensor
inputs. When a bit is set, the corresponding capacitive touch sensor input will be recalibrated (both analog and digital).
The bit is automatically cleared once the recalibration routine has finished.
5.5.2.2 Automatic Recalibration
Each sensor input is regularly recalibrated at a programmable rate (see Section 6.17, "Recalibration Configuration Register").
By default, the recalibration routine stores the average 64 previous measurements and periodically updates the
base “not touched” setting for the capacitive touch sensor input.
5.5.2.3 Negative Delta Count Recalibration
It is possible that the device loses sensitivity to a touch. This may happen as a result of a noisy environment, an accidental
recalibration during a touch, or other environmental changes. When this occurs, the base untouched sensor input
may generate negative delta count values. The NEG_DELTA_CNT bits (see Section 6.17, "Recalibration Configuration
Register") can be set to force a recalibration after a specified number of consecutive negative delta readings.
5.5.2.4 Delayed Recalibration
It is possible that a “stuck button” occurs when something is placed on a button which causes a touch to be detected
for a long period. By setting the MAX_DUR_EN bit (see Section 6.6, "Configuration Registers"), a recalibration can be
forced when a touch is held on a button for longer than the duration specified in the MAX_DUR bits (see Section 6.8,
"Sensor Input Configuration Register").
Note: During this recalibration routine, the sensor inputs will not detect a press for up to 200ms and the Sensor
Base Count Register values will be invalid. In addition, any press on the corresponding sensor pads will
invalidate the recalibration.
Note: Automatic recalibration only works when the delta count is below the active sensor input threshold. It is disabled
when a touch is detected.
Note: During this recalibration, the device will not respond to touches.
2015 Microchip Technology Inc. DS00001621B-page 28
CAP1166
5.5.3 PROXIMITY DETECTION
Each sensor input can be configured to detect changes in capacitance due to proximity of a touch. This circuitry detects
the change of capacitance that is generated as an object approaches, but does not physically touch, the enabled sensor
pad(s). When a sensor input is selected to perform proximity detection, it will be sampled from 1x to 128x per sampling
cycle. The larger the number of samples that are taken, the greater the range of proximity detection is available at the
cost of an increased overall sampling time.
5.5.4 MULTIPLE TOUCH PATTERN DETECTION
The multiple touch pattern (MTP) detection circuitry can be used to detect lid closure or other similar events. An event
can be flagged based on either a minimum number of sensor inputs or on specific sensor inputs simultaneously exceeding
an MTP threshold or having their Noise Flag Status Register bits set. An interrupt can also be generated. During an
MTP event, all touches are blocked (see Section 6.15, "Multiple Touch Pattern Configuration Register").
5.5.5 LOW FREQUENCY NOISE DETECTION
Each sensor input has an EMI noise detector that will sense if low frequency noise is injected onto the input with sufficient
power to corrupt the readings. If this occurs, the device will reject the corrupted sample and set the corresponding
bit in the Noise Status register to a logic ‘1’.
5.5.6 RF NOISE DETECTION
Each sensor input contains an integrated RF noise detector. This block will detect injected RF noise on the CS pin. The
detector threshold is dependent upon the noise frequency. If RF noise is detected on a CS line, that sample is removed
and not compared against the threshold.
5.6 ALERT# Pin
The ALERT# pin is an active low (or active high when configured) output that is driven when an interrupt event is
detected.
Whenever an interrupt is generated, the INT bit (see Section 6.1, "Main Control Register") is set. The ALERT# pin is
cleared when the INT bit is cleared by the user. Additionally, when the INT bit is cleared by the user, status bits are only
cleared if no touch is detected.
5.6.1 SENSOR INTERRUPT BEHAVIOR
The sensor interrupts are generated in one of two ways:
1. An interrupt is generated when a touch is detected and, as a user selectable option, when a release is detected
(by default - see Section 6.6). See Figure 5-3.
2. If the repeat rate is enabled then, so long as the touch is held, another interrupt will be generated based on the
programmed repeat rate (see Figure 5-2).
When the repeat rate is enabled, the device uses an additional control called MPRESS that determines whether a touch
is flagged as a simple “touch” or a “press and hold”. The MPRESS[3:0] bits set a minimum press timer. When the button
is touched, the timer begins. If the sensor pad is released before the minimum press timer expires, it is flagged as a
touch and an interrupt is generated upon release. If the sensor input detects a touch for longer than this timer value, it
is flagged as a “press and hold” event. So long as the touch is held, interrupts will be generated at the programmed
repeat rate and upon release (if enabled).
APPLICATION NOTE: Figure 5-2 and Figure 5-3 show default operation which is to generate an interrupt upon
sensor pad release and an active-low ALERT# pin.
APPLICATION NOTE: The host may need to poll the device twice to determine that a release has been detected.
Note: Delayed recalibration only works when the delta count is above the active sensor input threshold. If
enabled, it is invoked when a sensor pad touch is held longer than the MAX_DUR bit setting.
CAP1166
DS00001621B-page 29 2015 Microchip Technology Inc.
FIGURE 5-2: Sensor Interrupt Behavior - Repeat Rate Enabled
FIGURE 5-3: Sensor Interrupt Behavior - No Repeat Rate Enabled
Touch Detected
INT bit
Button Status
Write to INT bit
Polling Cycle
(35ms)
Min Press Setting
(280ms)
Interrupt on
Touch
Button Repeat Rate
(175ms)
Button Repeat Rate
(175ms)
Interrupt on
Release
(optional)
ALERT# pin
(active low)
Touch Detected
INT bit
Button Status
Write to INT bit
Polling Cycle
(35ms) Interrupt on
Touch Interrupt on
Release
(optional)
ALERT# pin
(active low)
2015 Microchip Technology Inc. DS00001621B-page 30
CAP1166
6.0 REGISTER DESCRIPTION
The registers shown in Table 6-1 are accessible through the communications protocol. An entry of ‘-’ indicates that the
bit is not used and will always read ‘0’.
TABLE 6-1: REGISTER SET IN HEXADECIMAL ORDER
Register
Address R/W Register Name Function Default Value Page
00h R/W Main Control Controls general power states and
power dissipation 00h Page 33
02h R General Status Stores general status bits 00h Page 34
03h R Sensor Input Status Returns the state of the sampled
capacitive touch sensor inputs 00h Page 34
04h R LED Status Stores status bits for LEDs 00h Page 34
0Ah R Noise Flag Status Stores the noise flags for sensor inputs 00h Page 35
10h R Sensor Input 1 Delta
Count Stores the delta count for CS1 00h Page 35
11h R Sensor Input 2 Delta
Count Stores the delta count for CS2 00h Page 35
12h R Sensor Input 3 Delta
Count Stores the delta count for CS3 00h Page 35
13h R Sensor Input 4 Delta
Count Stores the delta count for CS4 00h Page 35
14h R Sensor Input 5 Delta
Count Stores the delta count for CS5 00h Page 35
15h R Sensor Input 6 Delta
Count Stores the delta count for CS6 00h Page 35
1Fh R/W Sensitivity Control
Controls the sensitivity of the threshold
and delta counts and data scaling of
the base counts
2Fh Page 36
20h R/W Configuration Controls general functionality 20h Page 37
21h R/W Sensor Input Enable Controls whether the capacitive touch
sensor inputs are sampled 3Fh Page 38
22h R/W Sensor Input Configuration
Controls max duration and auto-repeat
delay for sensor inputs operating in the
full power state
A4h Page 39
23h R/W Sensor Input Configuration
2
Controls the MPRESS controls for all
sensor inputs 07h Page 40
24h R/W Averaging and Sampling
Config
Controls averaging and sampling window
39h Page 41
26h R/W Calibration Activate Forces re-calibration for capacitive
touch sensor inputs 00h Page 42
27h R/W Interrupt Enable Enables Interrupts associated with
capacitive touch sensor inputs 3Fh Page 42
28h R/W Repeat Rate Enable Enables repeat rate for all sensor
inputs 3Fh Page 43
2Ah R/W Multiple Touch Configuration
Determines the number of simultaneous
touches to flag a multiple touch
condition
80h Page 43
2Bh R/W Multiple Touch Pattern
Configuration
Determines the multiple touch pattern
(MTP) configuration 00h Page 44
CAP1166
DS00001621B-page 31 2015 Microchip Technology Inc.
2Dh R/W Multiple Touch Pattern
Determines the pattern or number of
sensor inputs used by the MTP circuitry
3Fh Page 45
2Fh R/W Recalibration Configuration
Determines re-calibration timing and
sampling window 8Ah Page 45
30h R/W Sensor Input 1 Threshold
Stores the delta count threshold to
determine a touch for Capacitive
Touch Sensor Input 1
40h Page 47
31h R/W Sensor Input 2 Threshold
Stores the delta count threshold to
determine a touch for Capacitive
Touch Sensor Input 2
40h Page 47
32h R/W Sensor Input 3 Threshold
Stores the delta count threshold to
determine a touch for Capacitive
Touch Sensor Input 3
40h Page 47
33h R/W Sensor Input 4 Threshold
Stores the delta count threshold to
determine a touch for Capacitive
Touch Sensor Input 4
40h Page 47
34h R/W Sensor Input 5 Threshold
Stores the delta count threshold to
determine a touch for Capacitive
Touch Sensor Input 5
40h Page 47
35h R/W Sensor Input 6 Threshold
Stores the delta count threshold to
determine a touch for Capacitive
Touch Sensor Input 6
40h Page 47
38h R/W Sensor Input Noise
Threshold
Stores controls for selecting the noise
threshold for all sensor inputs 01h Page 47
Standby Configuration Registers
40h R/W Standby Channel Controls which sensor inputs are
enabled while in standby 00h Page 47
41h R/W Standby Configuration Controls averaging and cycle time
while in standby 39h Page 48
42h R/W Standby Sensitivity Controls sensitivity settings used while
in standby 02h Page 49
43h R/W Standby Threshold Stores the touch detection threshold
for active sensor inputs in standby 40h Page 50
44h R/W Configuration 2 Stores additional configuration controls
for the device 40h Page 37
Base Count Registers
50h R Sensor Input 1 Base
Count
Stores the reference count value for
sensor input 1 C8h Page 50
51h R Sensor Input 2 Base
Count
Stores the reference count value for
sensor input 2 C8h Page 50
52h R Sensor Input 3 Base
Count
Stores the reference count value for
sensor input 3 C8h Page 50
53h R Sensor Input 4 Base
Count
Stores the reference count value for
sensor input 4 C8h Page 50
54h R Sensor Input 5 Base
Count
Stores the reference count value for
sensor input 5 C8h Page 50
55h R Sensor Input 6 Base
Count
Stores the reference count value for
sensor input 6 C8h Page 50
TABLE 6-1: REGISTER SET IN HEXADECIMAL ORDER (CONTINUED)
Register
Address R/W Register Name Function Default Value Page
2015 Microchip Technology Inc. DS00001621B-page 32
CAP1166
LED Controls
71h R/W LED Output Type Controls the output type for the LED
outputs 00h Page 50
72h R/W Sensor Input LED Linking
Controls linking of sensor inputs to
LED channels 00h Page 51
73h R/W LED Polarity Controls the output polarity of LEDs 00h Page 51
74h R/W LED Output Control Controls the output state of the LEDs 00h Page 52
77h R/W Linked LED
Transition Control
Controls the transition when LEDs are
linked to CS channels 00h Page 53
79h R/W LED Mirror Control Controls the mirroring of duty cycles
for the LEDs 00h Page 54
81h R/W LED Behavior 1 Controls the behavior and response of
LEDs 1 - 4 00h Page 55
82h R/W LED Behavior 2 Controls the behavior and response of
LEDs 5 - 6 00h Page 55
84h R/W LED Pulse 1 Period Controls the period of each breathe
during a pulse 20h Page 56
85h R/W LED Pulse 2 Period Controls the period of the breathing
during breathe and pulse operation 14h Page 58
86h R/W LED Breathe Period Controls the period of an LED breathe
operation 5Dh Page 59
88h R/W LED Config Controls LED configuration 04h Page 59
90h R/W LED Pulse 1 Duty Cycle Determines the min and max duty
cycle for the pulse operation F0h Page 60
91h R/W LED Pulse 2 Duty Cycle Determines the min and max duty
cycle for breathe and pulse operation F0h Page 60
92h R/W LED Breathe Duty Cycle Determines the min and max duty
cycle for the breathe operation F0h Page 60
93h R/W LED Direct Duty Cycle Determines the min and max duty
cycle for Direct mode LED operation F0h Page 60
94h R/W LED Direct Ramp Rates Determines the rising and falling edge
ramp rates of the LEDs 00h Page 61
95h R/W LED Off Delay Determines the off delay for all LED
behaviors 00h Page 61
B1h R Sensor Input 1 Calibration
Stores the upper 8-bit calibration value
for sensor input 1 00h Page 64
B2h R Sensor Input 2 Calibration
Stores the upper 8-bit calibration value
for sensor input 2 00h Page 64
B3h R Sensor Input 3 Calibration
Stores the upper 8-bit calibration value
for sensor input 3 00h Page 64
B4h R Sensor Input 4 Calibration
Stores the upper 8-bit calibration value
for sensor input 4 00h Page 64
B5h R Sensor Input 5 Calibration
Stores the upper 8-bit calibration value
for sensor input 5 00h Page 64
B6h R Sensor Input 6 Calibration
Stores the upper 8-bit calibration value
for sensor input 6 00h Page 64
B9h R Sensor Input Calibration
LSB 1
Stores the 2 LSBs of the calibration
value for sensor inputs 1 - 4 00h Page 64
TABLE 6-1: REGISTER SET IN HEXADECIMAL ORDER (CONTINUED)
Register
Address R/W Register Name Function Default Value Page
CAP1166
DS00001621B-page 33 2015 Microchip Technology Inc.
During Power-On-Reset (POR), the default values are stored in the registers. A POR is initiated when power is first
applied to the part and the voltage on the VDD supply surpasses the POR level as specified in the electrical characteristics.
Any reads to undefined registers will return 00h. Writes to undefined registers will not have an effect.
When a bit is “set”, this means that the user writes a logic ‘1’ to it. When a bit is “cleared”, this means that the user writes
a logic ‘0’ to it.
6.1 Main Control Register
The Main Control register controls the primary power state of the device.
Bits 7 - 6 - GAIN[1:0] - Controls the gain used by the capacitive touch sensing circuitry. As the gain is increased, the
effective sensitivity is likewise increased as a smaller delta capacitance is required to generate the same delta count
values. The sensitivity settings may need to be adjusted along with the gain settings such that data overflow does not
occur.
APPLICATION NOTE: The gain settings apply to both Standby and Active states.
Bit 5 - STBY - Enables Standby.
• ‘0’ (default) - Sensor input scanning is active and LEDs are functional.
• ‘1’ - Capacitive touch sensor input scanning is limited to the sensor inputs set in the Standby Channel register (see
Section 6.20). The status registers will not be cleared until read. LEDs that are linked to capacitive touch sensor
inputs will remain linked and active. Sensor inputs that are no longer sampled will flag a release and then remain
in a non-touched state. LEDs that are manually controlled will be unaffected.
• Bit 4 - DSLEEP - Enables Deep Sleep by deactivating all functions. This bit will be cleared when the WAKE pin is
driven high. ‘0’ (default) - Sensor input scanning is active and LEDs are functional.
• ‘1’ - All sensor input scanning is disabled. All LEDs are driven to their programmed non-actuated state and no
PWM operations will be done. The status registers are automatically cleared and the INT bit is cleared.
Bit 0 - INT - Indicates that there is an interrupt. When this bit is set, it asserts the ALERT# pin. If a channel detects a
touch and its associated interrupt enable bit is not set to a logic ‘1’, no action is taken.
BAh R Sensor Input Calibration
LSB 2
Stores the 2 LSBs of the calibration
value for sensor inputs 5 - 6 00h Page 64
FDh R Product ID Stores a fixed value that identifies
each product 51h Page 65
FEh R Manufacturer ID Stores a fixed value that identifies
Microchip 5Dh Page 65
FFh R Revision Stores a fixed value that represents
the revision number 83h Page 65
TABLE 6-2: MAIN CONTROL REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
00h R/W Main Control GAIN[1:0] STBY DSLEEP - - - INT 00h
TABLE 6-3: GAIN BIT DECODE
GAIN[1:0]
Capacitive Touch Sensor Gain
1 0
0 0 1
01 2
10 4
11 8
TABLE 6-1: REGISTER SET IN HEXADECIMAL ORDER (CONTINUED)
Register
Address R/W Register Name Function Default Value Page
2015 Microchip Technology Inc. DS00001621B-page 34
CAP1166
This bit is cleared by writing a logic ‘0’ to it. When this bit is cleared, the ALERT# pin will be deasserted and all status
registers will be cleared if the condition has been removed. If the WAKE/SPI_MOSI pin is asserted as a result of a touch
detected while in Standby, it will likewise be deasserted when this bit is cleared.
Note that the WAKE / SPI_MOSI pin is not driven when communicating via the 4-wire SPI protocol.
• ‘0’ - No interrupt pending.
• ‘1’ - A touch has been detected on one or more channels and the interrupt has been asserted.
6.2 Status Registers
All status bits are cleared when the device enters the Deep Sleep (DSLEEP = ‘1’ - see Section 6.1).
6.2.1 GENERAL STATUS - 02H
Bit 4 - LED - Indicates that one or more LEDs have finished their programmed activity. This bit is set if any bit in the LED
Status register is set.
Bit 3 - RESET - Indicates that the device has come out of reset. This bit is set when the device exits a POR state or
when the RESET pin has been deasserted and qualified via the RESET pin filter (see Section 5.2). This bit will cause
the INT bit to be set and is cleared when the INT bit is cleared.
Bit 2 - MULT - Indicates that the device is blocking detected touches due to the Multiple Touch detection circuitry (see
Section 6.14). This bit will not cause the INT bit to be set and hence will not cause an interrupt.
Bit 1 - MTP - Indicates that the device has detected a number of sensor inputs that exceed the MTP threshold either via
the pattern recognition or via the number of sensor inputs (see Section 6.15). This bit will cause the INT bit to be set if
the MTP_ALERT bit is also set. This bit will not be cleared until the condition that caused it to be set has been removed.
Bit 0 - TOUCH - Indicates that a touch was detected. This bit is set if any bit in the Sensor Input Status register is set.
6.2.2 SENSOR INPUT STATUS - 03H
The Sensor Input Status Register stores status bits that indicate a touch has been detected. A value of ‘0’ in any bit
indicates that no touch has been detected. A value of ‘1’ in any bit indicates that a touch has been detected.
All bits are cleared when the INT bit is cleared and if a touch on the respective capacitive touch sensor input is no longer
present. If a touch is still detected, the bits will not be cleared (but this will not cause the interrupt to be asserted - see
Section 6.6).
Bit 5 - CS6 - Indicates that a touch was detected on Sensor Input 6. This sensor input can be linked to LED6.
Bit 4 - CS5 - Indicates that a touch was detected on Sensor Input 5. This sensor input can be linked to LED5.
Bit 3 - CS4 - Indicates that a touch was detected on Sensor Input 4. This sensor input can be linked to LED4.
Bit 2 - CS3 - Indicates that a touch was detected on Sensor Input 3. This sensor input can be linked to LED3.
Bit 1 - CS2 - Indicates that a touch was detected on Sensor Input 2. This sensor input can be linked to LED2.
Bit 0 - CS1 - Indicates that a touch was detected on Sensor Input 1. This sensor input can be linked to LED1.
6.2.3 LED STATUS - 04H
The LED Status Registers indicate when an LED has completed its configured behavior (see Section 6.31, "LED Behavior
Registers") after being actuated by the host (see Section 6.28, "LED Output Control Register"). These bits are
ignored when the LED is linked to a capacitive sensor input. All LED Status bits are cleared when the INT bit is cleared.
Bit 5 - LED6_DN - Indicates that LED6 has finished its behavior after being actuated by the host.
Bit 4 - LED5_DN - Indicates that LED5 has finished its behavior after being actuated by the host.
TABLE 6-4: STATUS REGISTERS
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
02h R General Status - - - LED RESET MULT MTP TOUCH 00h
03h R Sensor Input Status
- - CS6 CS5 CS4 CS3 CS2 CS1 00h
04h R LED Status - - LED6_
DN
LED5_
DN
LED4_
DN
LED3_
DN
LED2_
DN
LED1_
DN 00h
CAP1166
DS00001621B-page 35 2015 Microchip Technology Inc.
Bit 3 - LED4_DN - Indicates that LED4 has finished its behavior after being actuated by the host.
Bit 2 - LED3_DN - Indicates that LED3 has finished its behavior after being actuated by the host.
Bit 1 - LED2_DN - Indicates that LED2 has finished its behavior after being actuated by the host.
Bit 0 - LED1_DN - Indicates that LED1 has finished its behavior after being actuated by the host.
6.3 Noise Flag Status Registers
The Noise Flag Status registers store status bits that are generated from the analog block if the detected noise is above
the operating region of the analog detector or the RF noise detector. These bits indicate that the most recently received
data from the sensor input is invalid and should not be used for touch detection. So long as the bit is set for a particular
channel, the delta count value is reset to 00h and thus no touch is detected.
These bits are not sticky and will be cleared automatically if the analog block does not report a noise error.
APPLICATION NOTE: If the MTP detection circuitry is enabled, these bits count as sensor inputs above the MTP
threshold (see Section 5.5.4, "Multiple Touch Pattern Detection") even if the corresponding
delta count is not. If the corresponding delta count also exceeds the MTP threshold, it is not
counted twice.
APPLICATION NOTE: Regardless of the state of the Noise Status bits, if low frequency noise is detected on a
sensor input, that sample will be discarded unless the DIS_ANA_NOISE bit is set. As well,
if RF noise is detected on a sensor input, that sample will be discarded unless the
DIS_RF_NOISE bit is set.
6.4 Sensor Input Delta Count Registers
The Sensor Input Delta Count registers store the delta count that is compared against the threshold used to determine
if a touch has been detected. The count value represents a change in input due to the capacitance associated with a
touch on one of the sensor inputs and is referenced to a calibrated base “Not Touched” count value. The delta is an
instantaneous change and is updated once per sensor input per sensing cycle (see Section 5.5.1, "Sensing Cycle").
The value presented is a standard 2’s complement number. In addition, the value is capped at a value of 7Fh. A reading
of 7Fh indicates that the sensitivity settings are too high and should be adjusted accordingly (see Section 6.5).
The value is also capped at a negative value of 80h for negative delta counts which may result upon a release.
TABLE 6-5: NOISE FLAG STATUS REGISTERS
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
0Ah R Noise Flag Status - - CS6_
NOISE
CS5_
NOISE
CS4_
NOISE
CS3_
NOISE
CS2_
NOISE
CS1_
NOISE 00h
TABLE 6-6: SENSOR INPUT DELTA COUNT REGISTERS
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
10h R Sensor Input 1
Delta Count Sign 64 32 16 8 4 2 1 00h
11h R Sensor Input 2
Delta Count Sign 64 32 16 8 4 2 1 00h
12h R Sensor Input 3
Delta Count Sign 64 32 16 8 4 2 1 00h
13h R Sensor Input 4
Delta Count Sign 64 32 16 8 4 2 1 00h
14h R Sensor Input 5
Delta Count Sign 64 32 16 8 4 2 1 00h
15h R Sensor Input 6
Delta Count Sign 64 32 16 8 4 2 1 00h
2015 Microchip Technology Inc. DS00001621B-page 36
CAP1166
6.5 Sensitivity Control Register
The Sensitivity Control register controls the sensitivity of a touch detection.
Bits 6-4 DELTA_SENSE[2:0] - Controls the sensitivity of a touch detection. The sensitivity settings act to scale the relative
delta count value higher or lower based on the system parameters. A setting of 000b is the most sensitive while a
setting of 111b is the least sensitive. At the more sensitive settings, touches are detected for a smaller delta capacitance
corresponding to a “lighter” touch. These settings are more sensitive to noise, however, and a noisy environment may
flag more false touches with higher sensitivity levels.
APPLICATION NOTE: A value of 128x is the most sensitive setting available. At the most sensitivity settings, the
MSB of the Delta Count register represents 64 out of ~25,000 which corresponds to a touch
of approximately 0.25% of the base capacitance (or a ΔC of 25fF from a 10pF base
capacitance). Conversely, a value of 1x is the least sensitive setting available. At these
settings, the MSB of the Delta Count register corresponds to a delta count of 8192 counts
out of ~25,000 which corresponds to a touch of approximately 33% of the base capacitance
(or a ΔC of 3.33pF from a 10pF base capacitance).
Bits 3 - 0 - BASE_SHIFT[3:0] - Controls the scaling and data presentation of the Base Count registers. The higher the
value of these bits, the larger the range and the lower the resolution of the data presented. The scale factor represents
the multiplier to the bit-weighting presented in these register descriptions.
APPLICATION NOTE: The BASE_SHIFT[3:0] bits normally do not need to be updated. These settings will not affect
touch detection or sensitivity. These bits are sometimes helpful in analyzing the Cap Sensing
board performance and stability.
TABLE 6-7: SENSITIVITY CONTROL REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
1Fh R/W Sensitivity Control - DELTA_SENSE[2:0] BASE_SHIFT[3:0] 2Fh
TABLE 6-8: DELTA_SENSE BIT DECODE
DELTA_SENSE[2:0]
Sensitivity Multiplier
210
0 0 0 128x (most sensitive)
0 0 1 64x
0 1 0 32x (default)
0 1 1 16x
1 0 0 8x
1 0 1 4x
1 1 0 2x
1 1 1 1x - (least sensitive)
TABLE 6-9: BASE_SHIFT BIT DECODE
BASE_SHIFT[3:0]
Data Scaling Factor
32 1 0
0 0 0 0 1x
0 0 0 1 2x
0 0 1 0 4x
0 0 1 1 8x
0 1 0 0 16x
0 1 0 1 32x
0 1 1 0 64x
CAP1166
DS00001621B-page 37 2015 Microchip Technology Inc.
6.6 Configuration Registers
The Configuration registers control general global functionality that affects the entire device.
6.6.1 CONFIGURATION - 20H
Bit 7 - TIMEOUT - Enables the timeout and idle functionality of the SMBus protocol.
• ‘0’ (default for Functional Revision C) - The SMBus timeout and idle functionality are disabled. The SMBus interface
will not time out if the clock line is held low. Likewise, it will not reset if both the data and clock lines are held
high for longer than 200us. This is used for I2C compliance.
• ‘1’ (default for Functional Revision B) - The SMBus timeout and idle functionality are enabled. The SMBus interface
will time out if the clock line is held low for longer than 30ms. Likewise, it will reset if both the data and clock
lines are held high for longer than 200us.
Bit 6 - WAKE_CFG - Configures the operation of the WAKE pin.
• ‘0’ (default) - The WAKE pin is not asserted when a touch is detected while the device is in Standby. It will still be
used to wake the device from Deep Sleep when driven high.
• ‘1’ - The WAKE pin will be asserted high when a touch is detected while the device is in Standby. It will also be
used to wake the device from Deep Sleep when driven high.
Bit 5 - DIS_DIG_NOISE - Determines whether the digital noise threshold (see Section 6.19, "Sensor Input Noise Threshold
Register") is used by the device. Setting this bit disables the feature.
• ‘0’ - The digital noise threshold is used. If a delta count value exceeds the noise threshold but does not exceed the
touch threshold, the sample is discarded and not used for the automatic re-calibration routine.
• ‘1’ (default) - The noise threshold is disabled. Any delta count that is less than the touch threshold is used for the
automatic re-calibration routine.
Bit 4 - DIS_ANA_NOISE - Determines whether the analog noise filter is enabled. Setting this bit disables the feature.
• ‘0’ (default) - If low frequency noise is detected by the analog block, the delta count on the corresponding channel
is set to 0. Note that this does not require that Noise Status bits be set.
• ‘1’ - A touch is not blocked even if low frequency noise is detected.
Bit 3 - MAX_DUR_EN - Determines whether the maximum duration recalibration is enabled.
• ‘0’ (default) - The maximum duration recalibration functionality is disabled. A touch may be held indefinitely and no
re-calibration will be performed on any sensor input.
• ‘1’ - The maximum duration recalibration functionality is enabled. If a touch is held for longer than the MAX_DUR
bit settings, then the re-calibration routine will be restarted (see Section 6.8).
0 1 1 1 128x
1 0 0 0 256x
All others 256x
(default = 1111b)
TABLE 6-10: CONFIGURATION REGISTERS
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
20h R/W Configuration TIMEOUT WAKE_
CFG
DIS_ DIG_
NOISE
DIS_ ANA_
NOISE
MAX_
DUR_EN - --
A0h
(Rev B)
20h
(rev C)
44h R/W Configuration 2 INV_LINK_
TRAN
ALT_
POL
BLK_PWR_
CTRL
BLK_POL_
MIR
SHOW_
RF_
NOISE
DIS_
RF_
NOISE
- INT_
REL_n 40h
TABLE 6-9: BASE_SHIFT BIT DECODE (CONTINUED)
BASE_SHIFT[3:0]
Data Scaling Factor
32 1 0
2015 Microchip Technology Inc. DS00001621B-page 38
CAP1166
6.6.2 CONFIGURATION 2 - 44H
Bit 7 - INV_LINK_TRAN - Determines the behavior of the Linked LED Transition controls (see Section 6.29).
• ‘0’ (default) - The Linked LED Transition controls set the min duty cycle equal to the max duty cycle.
• ‘1’ - The Linked LED Transition controls will invert the touch signal. For example, a touch signal will be inverted to
a non-touched signal.
Bit 6 - ALT_POL - Determines the ALERT# pin polarity and behavior.
• ‘0’ - The ALERT# pin is active high and push-pull.
• ‘1’ (default) - The ALERT# pin is active low and open drain.
Bit 5 - BLK_PWR_CTRL - Determines whether the device will reduce power consumption while waiting between conversion
time completion and the end of the polling cycle.
• ‘0’ (default) - The device will always power down as much as possible during the time between the end of the last
conversion and the end of the polling cycle.
• ‘1’ - The device will not power down the Cap Sensor during the time between the end of the last conversion and
the end of the polling cycle.
Bit 4 - BLK_POL_MIR - Determines whether the LED Mirror Control register bits are linked to the LED Polarity bits. Setting
this bit blocks the normal behavior which is to automatically set and clear the LED Mirror Control bits when the LED
Polarity bits are set or cleared.
• ‘0’ (default) - When the LED Polarity controls are set, the corresponding LED Mirror control is automatically set.
Likewise, when the LED Polarity controls are cleared, the corresponding LED Mirror control is also cleared.
• ‘1’ - When the LED Polarity controls are set, the corresponding LED Mirror control is not automatically set.
Bit 3 - SHOW_RF_NOISE - Determines whether the Noise Status bits will show RF Noise as the only input source.
• ‘0’ (default) - The Noise Status registers will show both RF noise and low frequency EMI noise if either is detected
on a capacitive touch sensor input.
• ‘1’ - The Noise Status registers will only show RF noise if it is detected on a capacitive touch sensor input. EMI
noise will still be detected and touches will be blocked normally; however, the status bits will not be updated.
Bit 2 - DIS_RF_NOISE - Determines whether the RF noise filter is enabled. Setting this bit disables the feature.
• ‘0’ (default) - If RF noise is detected by the analog block, the delta count on the corresponding channel is set to 0.
Note that this does not require that Noise Status bits be set.
• ‘1’ - A touch is not blocked even if RF noise is detected.
Bit 0 - INT_REL_n - Controls the interrupt behavior when a release is detected on a button.
• ‘0’ (default) - An interrupt is generated when a press is detected and again when a release is detected and at the
repeat rate (if enabled - see Section 6.13).
• ‘1’ - An interrupt is generated when a press is detected and at the repeat rate but not when a release is detected.
6.7 Sensor Input Enable Registers
The Sensor Input Enable registers determine whether a capacitive touch sensor input is included in the sampling cycle.
The length of the sampling cycle is not affected by the number of sensor inputs measured.
Bit 5 - CS6_EN - Enables the CS6 input to be included during the sampling cycle.
• ‘0’ - The CS6 input is not included in the sampling cycle.
• ‘1’ (default) - The CS6 input is included in the sampling cycle.
Bit 4 - CS5_EN - Enables the CS5 input to be included during the sampling cycle.
Bit 3 - CS4_EN - Enables the CS4 input to be included during the sampling cycle.
Bit 2 - CS3_EN - Enables the CS3 input to be included during the sampling cycle.
TABLE 6-11: SENSOR INPUT ENABLE REGISTERS
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
21h R/W Sensor Input
Enable - - CS6_EN CS5_EN CS4_EN CS3_EN CS2_EN CS1_EN 3Fh
CAP1166
DS00001621B-page 39 2015 Microchip Technology Inc.
Bit 1 - CS2_EN - Enables the CS2 input to be included during the sampling cycle.
Bit 0 - CS1_EN - Enables the CS1 input to be included during the sampling cycle.
6.8 Sensor Input Configuration Register
The Sensor Input Configuration Register controls timings associated with the Capacitive sensor inputs 1 - 6.
Bits 7 - 4 - MAX_DUR[3:0] - (default 1010b) - Determines the maximum time that a sensor pad is allowed to be touched
until the capacitive touch sensor input is recalibrated, as shown in Table 6-13.
Bits 3 - 0 - RPT_RATE[3:0] - (default 0100b) Determines the time duration between interrupt assertions when auto
repeat is enabled. The resolution is 35ms the range is from 35ms to 560ms as shown in Table 6-14.
TABLE 6-12: SENSOR INPUT CONFIGURATION REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
22h R/W Sensor Input
Configuration MAX_DUR[3:0] RPT_RATE[3:0] A4h
TABLE 6-13: MAX_DUR BIT DECODE
MAX_DUR[3:0]
Time Before Recalibration
32 1 0
0 0 0 0 560ms
0 0 0 1 840ms
0 0 1 0 1120ms
0 0 1 1 1400ms
0 1 0 0 1680ms
0 1 0 1 2240ms
0 1 1 0 2800ms
1 1 1 3360ms
1 0 0 0 3920ms
1 0 0 1 4480ms
1 0 1 0 5600ms (default)
1 0 1 1 6720ms
1 1 0 0 7840ms
1 1 0 1 8906ms
1 1 1 0 10080ms
1 1 1 1 11200ms
TABLE 6-14: RPT_RATE BIT DECODE
RPT_RATE[3:0]
Interrupt Repeat RATE
3 21 0
0 0 0 0 35ms
0 0 0 1 70ms
0 0 1 0 105ms
0 0 1 1 140ms
0 1 0 0 175ms (default)
0 1 0 1 210ms
0 1 1 0 245ms
0 1 1 1 280ms
2015 Microchip Technology Inc. DS00001621B-page 40
CAP1166
6.9 Sensor Input Configuration 2 Register
Bits 3 - 0 - M_PRESS[3:0] - (default 0111b) - Determines the minimum amount of time that sensor inputs configured to
use auto repeat must detect a sensor pad touch to detect a “press and hold” event. If the sensor input detects a touch
for longer than the M_PRESS[3:0] settings, a “press and hold” event is detected. If a sensor input detects a touch for
less than or equal to the M_PRESS[3:0] settings, a touch event is detected.
The resolution is 35ms the range is from 35ms to 560ms as shown in Table 6-16.
1 0 0 0 315ms
1 0 0 1 350ms
1 0 1 0 385ms
1 0 1 1 420ms
1 1 0 0 455ms
1 1 0 1 490ms
1 1 1 0 525ms
1 1 1 1 560ms
TABLE 6-15: SENSOR INPUT CONFIGURATION 2 REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
23h R/W Sensor Input
Configuration 2 - - - - M_PRESS[3:0] 07h
TABLE 6-16: M_PRESS BIT DECODE
M_PRESS[3:0]
M_PRESS SETTINGS
3 21 0
0 0 0 0 35ms
0 0 0 1 70ms
0 0 1 0 105ms
0 0 1 1 140ms
0 1 0 0 175ms
0 1 0 1 210ms
0 1 1 0 245ms
0 1 1 1 280ms (default)
1 0 0 0 315ms
1 0 0 1 350ms
1 0 1 0 385ms
1 0 1 1 420ms
1 1 0 0 455ms
1 1 0 1 490ms
1 1 1 0 525ms
1 1 1 1 560ms
TABLE 6-14: RPT_RATE BIT DECODE (CONTINUED)
RPT_RATE[3:0]
Interrupt Repeat RATE
3 21 0
CAP1166
DS00001621B-page 41 2015 Microchip Technology Inc.
6.10 Averaging and Sampling Configuration Register
The Averaging and Sampling Configuration register controls the number of samples taken and the total sensor input
cycle time for all active sensor inputs while the device is functioning in Active state.
Bits 6 - 4 - AVG[2:0] - Determines the number of samples that are taken for all active channels during the sensor cycle
as shown in Table 6-18. All samples are taken consecutively on the same channel before the next channel is sampled
and the result is averaged over the number of samples measured before updating the measured results.
For example, if CS1, CS2, and CS3 are sampled during the sensor cycle, and the AVG[2:0] bits are set to take 4 samples
per channel, then the full sensor cycle will be: CS1, CS1, CS1, CS1, CS2, CS2, CS2, CS2, CS3, CS3, CS3, CS3.
Bits 3 - 2 - SAMP_TIME[1:0] - Determines the time to take a single sample as shown in Table 6-19.
Bits 1 - 0 - CYCLE_TIME[1:0] - Determines the overall cycle time for all measured channels during normal operation as
shown in Table 6-20. All measured channels are sampled at the beginning of the cycle time. If additional time is remaining,
then the device is placed into a lower power state for the remaining duration of the cycle.
TABLE 6-17: AVERAGING AND SAMPLING CONFIGURATION REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
24h R/W Averaging and
Sampling Config AVG[2:0] SAMP_TIME[1:0] CYCLE_TIME
[1:0] 39h
TABLE 6-18: AVG BIT DECODE
AVG[2:0] Number of Samples Taken per
Measurement 2 10
0 0 0 1
0 01 2
0 10 4
0 1 1 8 (default)
1 0 0 16
1 0 1 32
1 1 0 64
1 1 1 128
TABLE 6-19: SAMP_TIME BIT DECODE
SAMP_TIME[1:0]
Sample Time
1 0
0 0 320us
0 1 640us
1 0 1.28ms (default)
1 1 2.56ms
TABLE 6-20: CYCLE_TIME BIT DECODE
CYCLE_TIME[1:0]
Overall Cycle Time
1 0
0 0 35ms
0 1 70ms (default)
1 0 105ms
1 1 140ms
2015 Microchip Technology Inc. DS00001621B-page 42
CAP1166
APPLICATION NOTE: The programmed cycle time is only maintained if the total averaging time for all samples is
less than the programmed cycle. The AVG[2:0] bits will take priority so that if more samples
are required than would normally be allowed during the cycle time, the cycle time will be
extended as necessary to accommodate the number of samples to be measured.
6.11 Calibration Activate Register
The Calibration Activate register forces the respective sensor inputs to be re-calibrated affecting both the analog and
digital blocks. During the re-calibration routine, the sensor inputs will not detect a press for up to 600ms and the Sensor
Input Base Count register values will be invalid. During this time, any press on the corresponding sensor pads will invalidate
the re-calibration. When finished, the CALX[9:0] bits will be updated (see Section 6.39).
When the corresponding bit is set, the device will perform the calibration and the bit will be automatically cleared once
the re-calibration routine has finished.
Bit 5 - CS6_CAL - When set, the CS6 input is re-calibrated. This bit is automatically cleared once the sensor input has
been re-calibrated successfully.
Bit 4 - CS5_CAL - When set, the CS5 input is re-calibrated. This bit is automatically cleared once the sensor input has
been re-calibrated successfully.
Bit 3 - CS4_CAL - When set, the CS4 input is re-calibrated. This bit is automatically cleared once the sensor input has
been re-calibrated successfully.
Bit 2 - CS3_CAL - When set, the CS3 input is re-calibrated. This bit is automatically cleared once the sensor input has
been re-calibrated successfully.
Bit 1 - CS2_CAL - When set, the CS2 input is re-calibrated. This bit is automatically cleared once the sensor input has
been re-calibrated successfully.
Bit 0 - CS1_CAL - When set, the CS1 input is re-calibrated. This bit is automatically cleared once the sensor input has
been re-calibrated successfully.
6.12 Interrupt Enable Register
The Interrupt Enable register determines whether a sensor pad touch or release (if enabled) causes the interrupt pin to
be asserted.
Bit 5 - CS6_INT_EN - Enables the interrupt pin to be asserted if a touch is detected on CS6 (associated with the CS6
status bit).
• ‘0’ - The interrupt pin will not be asserted if a touch is detected on CS6 (associated with the CS6 status bit).
• ‘1’ (default) - The interrupt pin will be asserted if a touch is detected on CS6 (associated with the CS6 status bit).
Bit 4 - CS5_INT_EN - Enables the interrupt pin to be asserted if a touch is detected on CS5 (associated with the CS5
status bit).
Bit 3 - CS4_INT_EN - Enables the interrupt pin to be asserted if a touch is detected on CS4 (associated with the CS4
status bit).
Bit 2 - CS3_INT_EN - Enables the interrupt pin to be asserted if a touch is detected on CS3 (associated with the CS3
status bit).
Bit 1 - CS2_INT_EN - Enables the interrupt pin to be asserted if a touch is detected on CS2 (associated with the CS2
status bit).
TABLE 6-21: CALIBRATION ACTIVATE REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
26h R/W Calibration
Activate - - CS6_
CAL
CS5_
CAL
CS4_
CAL
CS3_
CAL
CS2_
CAL
CS1_
CAL 00h
TABLE 6-22: INTERRUPT ENABLE REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
27h R/W Interrupt
Enable - - CS6_
INT_EN
CS5_
INT_EN
CS4_
INT_EN
CS3_
INT_EN
CS2_
INT_EN
CS1_
INT_EN 3Fh
CAP1166
DS00001621B-page 43 2015 Microchip Technology Inc.
Bit 0 - CS1_INT_EN - Enables the interrupt pin to be asserted if a touch is detected on CS1 (associated with the CS1
status bit).
6.13 Repeat Rate Enable Register
The Repeat Rate Enable register enables the repeat rate of the sensor inputs as described in Section 5.6.1.
Bit 5 - CS6_RPT_EN - Enables the repeat rate for capacitive touch sensor input 6.
• ‘0’ - The repeat rate for CS6 is disabled. It will only generate an interrupt when a touch is detected and when a
release is detected no matter how long the touch is held for.
• ‘1’ (default) - The repeat rate for CS6 is enabled. In the case of a “touch” event, it will generate an interrupt when a
touch is detected and a release is detected (as determined by the INT_REL_n bit - see Section 6.6). In the case of
a “press and hold” event, it will generate an interrupt when a touch is detected and at the repeat rate so long as
the touch is held.
Bit 4 - CS5_RPT_EN - Enables the repeat rate for capacitive touch sensor input 5.
Bit 3 - CS4_RPT_EN - Enables the repeat rate for capacitive touch sensor input 4.
Bit 2 - CS3_RPT_EN - Enables the repeat rate for capacitive touch sensor input 3.
Bit 1 - CS2_RPT_EN - Enables the repeat rate for capacitive touch sensor input 2.
Bit 0 - CS1_RPT_EN - Enables the repeat rate for capacitive touch sensor input 1.
6.14 Multiple Touch Configuration Register
The Multiple Touch Configuration register controls the settings for the multiple touch detection circuitry. These settings
determine the number of simultaneous buttons that may be pressed before additional buttons are blocked and the MULT
status bit is set.
Bit 7 - MULT_BLK_EN - Enables the multiple button blocking circuitry.
• ‘0’ - The multiple touch circuitry is disabled. The device will not block multiple touches.
• ‘1’ (default) - The multiple touch circuitry is enabled. The device will flag the number of touches equal to programmed
multiple touch threshold and block all others. It will remember which sensor inputs are valid and block all
others until that sensor pad has been released. Once a sensor pad has been released, the N detected touches
(determined via the cycle order of CS1 - CS6) will be flagged and all others blocked.
Bits 3 - 2 - B_MULT_T[1:0] - Determines the number of simultaneous touches on all sensor pads before a Multiple Touch
Event is detected and sensor inputs are blocked. The bit decode is given by Table 6-25.
TABLE 6-23: REPEAT RATE ENABLE REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
28h R/W Repeat Rate
Enable - - CS6_
RPT_EN
CS5_
RPT_EN
CS4_
RPT_EN
CS3_
RPT_EN
CS2_
RPT_EN
CS1_
RPT_EN 3Fh
TABLE 6-24: MULTIPLE TOUCH CONFIGURATION
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
2Ah R/W Multiple Touch
Config
MULT_
BLK_
EN
- - - B_MULT_T[1:0] - - 80h
TABLE 6-25: B_MULT_T BIT DECODE
B_MULT_T[1:0]
Number of Simultaneous Touches
1 0
0 0 1 (default)
01 2
10 3
11 4
2015 Microchip Technology Inc. DS00001621B-page 44
CAP1166
6.15 Multiple Touch Pattern Configuration Register
The Multiple Touch Pattern Configuration register controls the settings for the multiple touch pattern detection circuitry.
This circuitry works like the multiple touch detection circuitry with the following differences:
1. The detection threshold is a percentage of the touch detection threshold as defined by the MTP_TH[1:0] bits
whereas the multiple touch circuitry uses the touch detection threshold.
2. The MTP detection circuitry either will detect a specific pattern of sensor inputs as determined by the Multiple
Touch Pattern register settings or it will use the Multiple Touch Pattern register settings to determine a minimum
number of sensor inputs that will cause the MTP circuitry to flag an event. When using pattern recognition mode,
if all of the sensor inputs set by the Multiple Touch Pattern register have a delta count greater than the MTP
threshold or have their corresponding Noise Flag Status bits set, the MTP bit will be set. When using the absolute
number mode, if the number of sensor inputs with thresholds above the MTP threshold or with Noise Flag Status
bits set is equal to or greater than this number, the MTP bit will be set.
3. When an MTP event occurs, all touches are blocked and an interrupt is generated.
4. All sensor inputs will remain blocked so long as the requisite number of sensor inputs are above the MTP threshold
or have Noise Flag Status bits set. Once this condition is removed, touch detection will be restored. Note that
the MTP status bit is only cleared by writing a ‘0’ to the INT bit once the condition has been removed.
Bit 7 - MTP_EN - Enables the multiple touch pattern detection circuitry.
• ‘0’ (default) - The MTP detection circuitry is disabled.
• ‘1’ - The MTP detection circuitry is enabled.
Bits 3-2 - MTP_TH[1:0] - Determine the MTP threshold, as shown in Table 6-27. This threshold is a percentage of sensor
input threshold (see Section 6.18, "Sensor Input Threshold Registers") when the device is in the Fully Active state or of
the standby threshold (see Section 6.23, "Standby Threshold Register") when the device is in the Standby state.
Bit 1 - COMP_PTRN - Determines whether the MTP detection circuitry will use the Multiple Touch Pattern register as a
specific pattern of sensor inputs or as an absolute number of sensor inputs.
• ‘0’ (default) - The MTP detection circuitry will use the Multiple Touch Pattern register bit settings as an absolute
minimum number of sensor inputs that must be above the threshold or have Noise Flag Status bits set. The number
will be equal to the number of bits set in the register.
• ‘1’ - The MTP detection circuitry will use pattern recognition. Each bit set in the Multiple Touch Pattern register
indicates a specific sensor input that must have a delta count greater than the MTP threshold or have a Noise Flag
Status bit set. If the criteria are met, the MTP status bit will be set.
Bit 0 - MTP_ALERT - Enables an interrupt if an MTP event occurs. In either condition, the MTP status bit will be set.
• ‘0’ (default) - If an MTP event occurs, the ALERT# pin is not asserted.
• ‘1’ - If an MTP event occurs, the ALERT# pin will be asserted.
TABLE 6-26: MULTIPLE TOUCH PATTERN CONFIGURATION
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
2Bh R/W Multiple Touch
Pattern Config MTP_ EN - - MTP_TH[1:0] COMP_
PTRN
MTP_
ALERT 00h
TABLE 6-27: MTP_TH BIT DECODE
MTP_TH[1:0]
Threshold Divide Setting
1 0
0 0 12.5% (default)
0 1 25%
1 0 37.5%
1 1 100%
CAP1166
DS00001621B-page 45 2015 Microchip Technology Inc.
6.16 Multiple Touch Pattern Register
The Multiple Touch Pattern register acts as a pattern to identify an expected sensor input profile for diagnostics or other
significant events. There are two methods for how the Multiple Touch Pattern register is used: as specific sensor inputs
or number of sensor input that must exceed the MTP threshold or have Noise Flag Status bits set. Which method is used
is based on the COMP_PTRN bit (see Section 6.15). The methods are described below.
1. Specific Sensor Inputs: If, during a single polling cycle, the specific sensor inputs above the MTP threshold or
with Noise Flag Status bits set match those bits set in the Multiple Touch Pattern register, an MTP event is
flagged.
2. Number of Sensor Inputs: If, during a single polling cycle, the number of sensor inputs with a delta count above
the MTP threshold or with Noise Flag Status bits set is equal to or greater than the number of pattern bits set, an
MTP event is flagged.
Bit 5 - CS6_PTRN - Determines whether CS6 is considered as part of the Multiple Touch Pattern.
• ‘0’ - CS6 is not considered a part of the pattern.
• ‘1’ - CS6 is considered a part of the pattern or the absolute number of sensor inputs that must have a delta count
greater than the MTP threshold or have the Noise Flag Status bit set is increased by 1.
Bit 4 - CS5_PTRN - Determines whether CS5 is considered as part of the Multiple Touch Pattern.
Bit 3 - CS4_PTRN - Determines whether CS4 is considered as part of the Multiple Touch Pattern.
Bit 2 - CS3_PTRN - Determines whether CS3 is considered as part of the Multiple Touch Pattern.
Bit 1 - CS2_PTRN - Determines whether CS2 is considered as part of the Multiple Touch Pattern.
Bit 0 - CS1_PTRN - Determines whether CS1 is considered as part of the Multiple Touch Pattern.
6.17 Recalibration Configuration Register
The Recalibration Configuration register controls the automatic re-calibration routine settings as well as advanced controls
to program the Sensor Input Threshold register settings.
Bit 7 - BUT_LD_TH - Enables setting all Sensor Input Threshold registers by writing to the Sensor Input 1 Threshold
register.
• ‘0’ - Each Sensor Input X Threshold register is updated individually.
• ‘1’ (default) - Writing the Sensor Input 1 Threshold register will automatically overwrite the Sensor Input Threshold
registers for all sensor inputs (Sensor Input Threshold 1 through Sensor Input Threshold 6). The individual Sensor
Input X Threshold registers (Sensor Input 2 Threshold through Sensor Input 6 Threshold) can be individually
updated at any time.
Bit 6 - NO_CLR_INTD - Controls whether the accumulation of intermediate data is cleared if the noise status bit is set.
• ‘0’ (default) - The accumulation of intermediate data is cleared if the noise status bit is set.
• ‘1’ - The accumulation of intermediate data is not cleared if the noise status bit is set.
APPLICATION NOTE: Bits 5 and 6 should both be set to the same value. Either both should be set to ‘0’ or both
should be set to ‘1’.
Bit 5 - NO_CLR_NEG - Controls whether the consecutive negative delta counts counter is cleared if the noise status bit
is set.
TABLE 6-28: MULTIPLE TOUCH PATTERN REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
2Dh R/W Multiple
Touch Pattern - - CS6_
PTRN
CS5_
PTRN
CS4_
PTRN
CS3_
PTRN
CS2_
PTRN
CS1_
PTRN 3Fh
TABLE 6-29: RECALIBRATION CONFIGURATION REGISTERS
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
2Fh R/W Recalibration
Configuration
BUT_
LD_TH
NO_
CLR_
INTD
NO_
CLR_
NEG
NEG_DELTA_
CNT[1:0] CAL_CFG[2:0] 8Ah
2015 Microchip Technology Inc. DS00001621B-page 46
CAP1166
• ‘0’ (default) - The consecutive negative delta counts counter is cleared if the noise status bit is set.
• ‘1’ - The consecutive negative delta counts counter is not cleared if the noise status bit is set.
Bits 4 - 3 - NEG_DELTA_CNT[1:0] - Determines the number of negative delta counts necessary to trigger a digital recalibration
as shown in Table 6-30.
Bits 2 - 0 - CAL_CFG[2:0] - Determines the update time and number of samples of the automatic re-calibration routine.
The settings apply to all sensor inputs universally (though individual sensor inputs can be configured to support re-calibration
- see Section 6.11).
Note 6-1 Recalibration Samples refers to the number of samples that are measured and averaged before the
Base Count is updated however does not control the base count update period.
Note 6-2 Update Time refers to the amount of time (in polling cycle periods) that elapses before the Base
Count is updated. The time will depend upon the number of channels active, the averaging setting,
and the programmed cycle time.
TABLE 6-30: NEG_DELTA_CNT BIT DECODE
NEG_DELTA_CNT[1:0]
Number of Consecutive Negative Delta Count Values
1 0
00 8
0 1 16 (default)
1 0 32
1 1 None (disabled)
TABLE 6-31: CAL_CFG BIT DECODE
CAL_CFG[2:0] Recalibration Samples
(see Note 6-1)
Update Time (see
Note 6-2) 210
0 0 0 16 16
0 0 1 32 32
0 1 0 64 64 (default)
0 1 1 128 128
1 0 0 256 256
1 0 1 256 1024
1 1 0 256 2048
1 1 1 256 4096
CAP1166
DS00001621B-page 47 2015 Microchip Technology Inc.
6.18 Sensor Input Threshold Registers
The Sensor Input Threshold registers store the delta threshold that is used to determine if a touch has been detected.
When a touch occurs, the input signal of the corresponding sensor pad changes due to the capacitance associated with
a touch. If the sensor input change exceeds the threshold settings, a touch is detected.
When the BUT_LD_TH bit is set (see Section 6.17 - bit 7), writing data to the Sensor Input 1 Threshold register will
update all of the sensor input threshold registers (31h - 35h inclusive).
6.19 Sensor Input Noise Threshold Register
The Sensor Input Noise Threshold register controls the value of a secondary internal threshold to detect noise and
improve the automatic recalibration routine. If a capacitive touch sensor input exceeds the Sensor Input Noise Threshold
but does not exceed the sensor input threshold, it is determined to be caused by a noise spike. That sample is not used
by the automatic re-calibration routine. This feature can be disabled by setting the DIS_DIG_NOISE bit.
Bits 1-0 - CS1_BN_TH[1:0] - Controls the noise threshold for all capacitive touch sensor inputs, as shown in Table 6-34.
The threshold is proportional to the threshold setting.
6.20 Standby Channel Register
TABLE 6-32: SENSOR INPUT THRESHOLD REGISTERS
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
30h R/W Sensor Input 1
Threshold - 64 32 16 8 4 2 1 40h
31h R/W Sensor Input 2
Threshold - 64 32 16 8 4 2 1 40h
32h R/W Sensor Input 3
Threshold - 64 32 16 8 4 2 1 40h
33h R/W Sensor Input 4
Threshold - 64 32 16 8 4 2 1 40h
34h R/W Sensor Input 5
Threshold - 64 32 16 8 4 2 1 40h
35h R/W Sensor Input 6
Threshold - 64 32 16 8 4 2 1 40h
TABLE 6-33: SENSOR INPUT NOISE THRESHOLD REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
38h R/W Sensor Input
Noise Threshold CS_BN_TH [1:0] 01h
TABLE 6-34: CSX_BN_TH BIT DECODE
CS_BN_TH[1:0]
Percent Threshold Setting
1 0
0 0 25%
0 1 37.5% (default)
1 0 50%
1 1 62.5%
TABLE 6-35: STANDBY CHANNEL REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
40h R/W Standby Channel - - CS6_
STBY
CS5_
STBY
CS4_
STBY
CS3_
STBY
CS2_
STBY
CS1_
STBY 00h
2015 Microchip Technology Inc. DS00001621B-page 48
CAP1166
The Standby Channel register controls which (if any) capacitive touch sensor inputs are active during Standby.
Bit 5 - CS6_STBY - Controls whether the CS6 channel is active in Standby.
• ‘0’ (default) - The CS6 channel not be sampled during Standby mode.
• ‘1’ - The CS6 channel will be sampled during Standby Mode. It will use the Standby threshold setting, and the
standby averaging and sensitivity settings.
Bit 4 - CS5_STBY - Controls whether the CS5 channel is active in Standby.
Bit 3 - CS4_STBY - Controls whether the CS4 channel is active in Standby.
Bit 2 - CS3_STBY - Controls whether the CS3 channel is active in Standby.
Bit 1 - CS2_STBY - Controls whether the CS2 channel is active in Standby.
Bit 0 - CS1_STBY - Controls whether the CS1 channel is active in Standby.
6.21 Standby Configuration Register
The Standby Configuration register controls averaging and cycle time for those sensor inputs that are active in Standby.
This register is useful for detecting proximity on a small number of sensor inputs as it allows the user to change averaging
and sample times on a limited number of sensor inputs and still maintain normal functionality in the fully active
state.
Bit 7 - AVG_SUM - Determines whether the active sensor inputs will average the programmed number of samples or
whether they will accumulate for the programmed number of samples.
• ‘0’ - (default) - The active sensor input delta count values will be based on the average of the programmed number
of samples when compared against the threshold.
• ‘1’ - The active sensor input delta count values will be based on the summation of the programmed number of
samples when compared against the threshold. This bit should only be set when performing proximity detection as
a physical touch will overflow the delta count registers and may result in false readings.
Bits 6 - 4 - STBY_AVG[2:0] - Determines the number of samples that are taken for all active channels during the sensor
cycle as shown in Table 6-37. All samples are taken consecutively on the same channel before the next channel is sampled
and the result is averaged over the number of samples measured before updating the measured results.
Bit 3-2 - STBY SAMP_TIME[1:0] - Determines the time to take a single sample when the device is in Standby as shown
in Table 6-38.
TABLE 6-36: STANDBY CONFIGURATION REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
41h R/W Standby Configuration
AVG_
SUM STBY_AVG[2:0] STBY_SAMP_
TIME[1:0]
STBY_CY_TIME
[1:0] 39h
TABLE 6-37: STBY_AVG BIT DECODE
STBY_AVG[2:0] Number of Samples Taken per
Measurement 2 10
0 0 0 1
0 01 2
0 10 4
0 1 1 8 (default)
1 0 0 16
1 0 1 32
1 1 0 64
1 1 1 128
CAP1166
DS00001621B-page 49 2015 Microchip Technology Inc.
Bits 1 - 0 - STBY_CY_TIME[2:0] - Determines the overall cycle time for all measured channels during standby operation
as shown in Table 6-39. All measured channels are sampled at the beginning of the cycle time. If additional time is
remaining, the device is placed into a lower power state for the remaining duration of the cycle.
APPLICATION NOTE: The programmed cycle time is only maintained if the total averaging time for all samples is
less than the programmed cycle. The STBY_AVG[2:0] bits will take priority so that if more
samples are required than would normally be allowed during the cycle time, the cycle time
will be extended as necessary to accommodate the number of samples to be measured.
6.22 Standby Sensitivity Register
The Standby Sensitivity register controls the sensitivity for sensor inputs that are active in Standby.
Bits 2 - 0 - STBY_SENSE[2:0] - Controls the sensitivity for sensor inputs that are active in Standby. The sensitivity settings
act to scale the relative delta count value higher or lower based on the system parameters. A setting of 000b is the
most sensitive while a setting of 111b is the least sensitive. At the more sensitive settings, touches are detected for a
smaller delta C corresponding to a “lighter” touch. These settings are more sensitive to noise however and a noisy environment
may flag more false touches than higher sensitivity levels.
APPLICATION NOTE: A value of 128x is the most sensitive setting available. At the most sensitivity settings, the
MSB of the Delta Count register represents 64 out of ~25,000 which corresponds to a touch
of approximately 0.25% of the base capacitance (or a ΔC of 25fF from a 10pF base
capacitance). Conversely a value of 1x is the least sensitive setting available. At these
settings, the MSB of the Delta Count register corresponds to a delta count of 8192 counts
out of ~25,000 which corresponds to a touch of approximately 33% of the base capacitance
(or a ΔC of 3.33pF from a 10pF base capacitance).
TABLE 6-38: STBY_SAMP_TIME BIT DECODE
STBY_SAMP_TIME[1:0]
Sampling Time
1 0
0 0 320us
0 1 640us
1 0 1.28ms (default)
1 1 2.56ms
TABLE 6-39: STBY_CY_TIME BIT DECODE
STBY_CY_TIME[1:0]
Overall Cycle Time
1 0
0 0 35ms
0 1 70ms (default)
1 0 105ms
1 1 140ms
TABLE 6-40: STANDBY SENSITIVITY REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
42h R/W Standby Sensitivity
- - - - - STBY_SENSE[2:0] 02h
TABLE 6-41: STBY_SENSE BIT DECODE
STBY_SENSE[2:0]
Sensitivity Multiplier
210
0 0 0 128x (most sensitive)
0 0 1 64x
2015 Microchip Technology Inc. DS00001621B-page 50
CAP1166
6.23 Standby Threshold Register
The Standby Threshold register stores the delta threshold that is used to determine if a touch has been detected. When
a touch occurs, the input signal of the corresponding sensor pad changes due to the capacitance associated with a
touch. If the sensor input change exceeds the threshold settings, a touch is detected.
6.24 Sensor Input Base Count Registers
The Sensor Input Base Count registers store the calibrated “Not Touched” input value from the capacitive touch sensor
inputs. These registers are periodically updated by the re-calibration routine.
The routine uses an internal adder to add the current count value for each reading to the sum of the previous readings
until sample size has been reached. At this point, the upper 16 bits are taken and used as the Sensor Input Base Count.
The internal adder is then reset and the re-calibration routine continues.
The data presented is determined by the BASE_SHIFT[3:0] bits (see Section 6.5).
6.25 LED Output Type Register
0 1 0 32x (default)
0 1 1 16x
1 0 0 8x
1 0 1 4x
1 1 0 2x
1 1 1 1x - (least sensitive)
TABLE 6-42: STANDBY THRESHOLD REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
43h R/W Standby Threshold
- 64 32 16 8 4 2 1 40h
TABLE 6-43: SENSOR INPUT BASE COUNT REGISTERS
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
50h R Sensor Input 1
Base Count 128 64 32 16 8 4 2 1 C8h
51h R Sensor Input 2
Base Count 128 64 32 16 8 4 2 1 C8h
52h R Sensor Input 3
Base Count 128 64 32 16 8 4 2 1 C8h
53h R Sensor Input 4
Base Count 128 64 32 16 8 4 2 1 C8h
54h R Sensor Input 5
Base Count 128 64 32 16 8 4 2 1 C8h
55h R Sensor Input 6
Base Count 128 64 32 16 8 4 2 1 C8h
TABLE 6-44: LED OUTPUT TYPE REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
71h R/W LED Output
Type - - LED6_
OT
LED5_
OT
LED4_
OT
LED3_
OT
LED2_
OT
LED1_
OT 00h
TABLE 6-41: STBY_SENSE BIT DECODE (CONTINUED)
STBY_SENSE[2:0]
Sensitivity Multiplier
210
CAP1166
DS00001621B-page 51 2015 Microchip Technology Inc.
The LED Output Type register controls the type of output for the LED pins. Each pin is controlled by a single bit. Refer
to application note 21.4 CAP1166Family LED Configuration Options for more information about implementing LEDs.
Bit 5 - LED6_OT - Determines the output type of the LED6 pin.
• ‘0’ (default) - The LED6 pin is an open-drain output with an external pull-up resistor. When the appropriate pin is
set to the “active” state (logic ‘1’), the pin will be driven low. Conversely, when the pin is set to the “inactive” state
(logic ‘0’), then the pin will be left in a High Z state and pulled high via an external pull-up resistor.
• ‘1’ - The LED6 pin is a push-pull output. When driving a logic ‘1’, the pin is driven high. When driving a logic ‘0’, the
pin is driven low.
Bit 4 - LED5_OT - Determines the output type of the LED5 pin.
Bit 3 - LED4_OT - Determines the output type of the LED4 pin.
Bit 2 - LED3_OT - Determines the output type of the LED3 pin.
Bit 1 - LED2_OT - Determines the output type of the LED2 pin.
Bit 0 - LED1_OT - Determines the output type of the LED1 pin.
6.26 Sensor Input LED Linking Register
The Sensor Input LED Linking register controls whether a capacitive touch sensor input is linked to an LED output. If
the corresponding bit is set, then the appropriate LED output will change states defined by the LED Behavior controls
(see Section 6.31) in response to the capacitive touch sensor input.
Bit 5 - CS6_LED6 - Links the LED6 output to a detected touch on the CS6 sensor input. When a touch is detected, the
LED is actuated and will behave as determined by the LED Behavior controls.
• ‘0’ (default) - The LED6 output is not associated with the CS6 input. If a touch is detected on the CS6 input, the
LED will not automatically be actuated. The LED is enabled and controlled via the LED Output Control register
(see Section 6.28) and the LED Behavior registers (see Section 6.31).
• ‘1’ - The LED6 output is associated with the CS6 input. If a touch is detected on the CS6 input, the LED will be
actuated and behave as defined in Table 6-52.
Bit 4 - CS5_LED5 - Links the LED5 output to a detected touch on the CS5 sensor input. When a touch is detected, the
LED is actuated and will behave as determined by the LED Behavior controls.
Bit 3 - CS4_LED4 - Links the LED4 output to a detected touch on the CS4 sensor input. When a touch is detected, the
LED is actuated and will behave as determined by the LED Behavior controls.
Bit 2 - CS3_LED3 - Links the LED3 output to a detected touch on the CS3 sensor input. When a touch is detected, the
LED is actuated and will behave as determined by the LED Behavior controls.
Bit 1 - CS2_LED2 - Links the LED2 output to a detected touch on the CS2 sensor input. When a touch is detected, the
LED is actuated and will behave as determined by the LED Behavior controls.
Bit 0 - CS1_LED1 - Links the LED1 output to a detected touch on the CS1 sensor input. When a touch is detected, the
LED is actuated and will behave as determined by the LED Behavior controls.
6.27 LED Polarity Register
TABLE 6-45: SENSOR INPUT LED LINKING REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
72h R/W Sensor Input
LED Linking
- - CS6_
LED6
CS5_
LED5
CS4_
LED4
CS3_
LED3
CS2_
LED2
CS1_
LED1
00h
TABLE 6-46: LED POLARITY REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
73h R/W LED Polarity - - LED6_
POL
LED5_
POL
LED4_
POL
LED3_
POL
LED2_
POL
LED1_
POL 00h
2015 Microchip Technology Inc. DS00001621B-page 52
CAP1166
The LED Polarity register controls the logical polarity of the LED outputs. When these bits are set or cleared, the corresponding
LED Mirror controls are also set or cleared (unless the BLK_POL_MIR bit is set - see Section 6.6, "Configuration
Registers"). Table 6-48, "LED Polarity Behavior" shows the interaction between the polarity controls, output
controls, and relative brightness.
APPLICATION NOTE: The polarity controls determine the final LED pin drive. A touch on a linked capacitive touch
sensor input is treated in the same way as the LED Output Control bit being set to a logic ‘1’.
APPLICATION NOTE: The LED drive assumes that the LEDs are configured such that if the LED pin is driven to
a logic ‘0’ then the LED will be on and that the CAP1166 LED pin is sinking the LED current.
Conversely, if the LED pin is driven to a logic ‘1’, the LED will be off and there is no current
flow. See Figure 5-1, "System Diagram for CAP1166".
APPLICATION NOTE: This application note applies when the LED polarity is inverted (LEDx_POL = ‘0’). For LED
operation, the duty cycle settings determine the % of time that the LED pin will be driven to
a logic ‘0’ state in. The Max Duty Cycle settings define the maximum % of time that the LED
pin will be driven low (i.e. maximum % of time that the LED is on) while the Min Duty Cycle
settings determine the minimum % of time that the LED pin will be driven low (i.e. minimum
% of time that the LED is on). When there is no touch detected or the LED Output Control
register bit is at a logic ‘0’, the LED output will be driven at the minimum duty cycle setting.
Breathe operations will ramp the duty cycle from the minimum duty cycle to the maximum
duty cycle.
APPLICATION NOTE: This application note applies when the LED polarity is non-inverted (LEDx_POL = ‘1’). For
LED operation, the duty cycle settings determine the % of time that the LED pin will be driven
to a logic ‘1’ state. The Max Duty Cycle settings define the maximum % of time that the LED
pin will be driven high (i.e. maximum % of time that the LED is off) while the Min Duty Cycle
settings determine the minimum % of time that the LED pin will be driven high (i.e. minimum
% of time that the LED is off). When there is no touch detected or the LED Output Control
register bit is at a logic ‘0’, the LED output will be driven at 100 minus the minimum duty
cycle setting. Breathe operations will ramp the duty cycle from 100 minus the minimum duty
cycle to 100 minus the maximum duty cycle.
APPLICATION NOTE: The LED Mirror controls (see Section 6.30, "LED Mirror Control Register") work with the
polarity controls with respect to LED brightness but will not have a direct effect on the output
pin drive.
Bit 5 - LED6_POL - Determines the polarity of the LED6 output.
• ‘0’ (default) - The LED6 output is inverted. For example, a setting of ‘1’ in the LED Output Control register will
cause the LED pin output to be driven to a logic ‘0’.
• ‘1’ - The LED6 output is non-inverted. For example, a setting of ‘1’ in the LED Output Control register will cause
the LED pin output to be driven to a logic ‘1’ or left in the high-z state as determined by its output type.
Bit 4 - LED5_POL - Determines the polarity of the LED5 output.
Bit 3 - LED4_POL - Determines the polarity of the LED4 output.
Bit 2 - LED3_POL - Determines the polarity of the LED3 output.
Bit 1 - LED2_POL - Determines the polarity of the LED2 output.
Bit 0 - LED1_POL - Determines the polarity of the LED1 output.
6.28 LED Output Control Register
The LED Output Control Register controls the output state of the LED pins that are not linked to sensor inputs.
TABLE 6-47: LED OUTPUT CONTROL REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
74h R/W LED Output
Control - - LED6_
DR
LED5_
DR
LED4_
DR
LED3_
DR
LED2_
DR
LED1_
DR 00h
CAP1166
DS00001621B-page 53 2015 Microchip Technology Inc.
The LED Polarity Control Register will determine the non actuated state of the LED pins. The actuated LED behavior is
determined by the LED behavior controls (see Section 6.31, "LED Behavior Registers").
Table 6-48 shows the interaction between the polarity controls, output controls, and relative brightness.
Bit 5 - LED6_DR - Determines whether LED6 output is driven high or low.
• ‘0’ (default) - The LED6 output is driven at the minimum duty cycle or not actuated.
• ‘1’ - The LED6 output is driven at the maximum duty cycle or is actuated.
Bit 4 - LED5_DR - Determines whether LED5 output is driven high or low.
Bit 3 - LED4_DR - Determines whether LED4 output is driven high or low.
Bit 2 - LED3_DR - Determines whether LED3 output is driven high or low.
Bit 1 - LED2_DR - Determines whether LED2 output is driven high or low.
Bit 0 - LED1_DR - Determines whether LED1 output is driven high or low.
6.29 Linked LED Transition Control Register
The Linked LED Transition Control register controls the LED drive when the LED is linked to a capacitive touch sensor
input. These controls work in conjunction with the INV_LINK_TRAN bit (see Section 6.6.2, "Configuration 2 - 44h") to
create smooth transitions from host control to linked LEDs.
Note: If an LED is linked to a sensor input in the Sensor Input LED Linking Register (Section 6.26, "Sensor Input
LED Linking Register"), the corresponding bit in the LED Output Control Register is ignored (i.e. a linked
LED cannot be host controlled).
TABLE 6-48: LED POLARITY BEHAVIOR
LED Output
Control
Register or
Touch
Polarity Max Duty Min Duty Brightness LED Appearance
0 inverted (‘0’) not used
minimum % of time
that the LED is on
(logic 0)
maximum brightness at
min duty cycle
on at min duty
cycle
1 inverted (‘0’)
maximum % of time
that the LED is on
(logic 0)
minimum % of time
that the LED is on
(logic 0)
maximum brightness at
max duty cycle. Brightness
ramps from min
duty cycle to max duty
cycle
according to LED
behavior
0 non-inverted
(‘1’) not used
minimum % of time
that the LED is off
(logic 1)
maximum brightness at
100 minus min duty
cycle.
on at 100 - min
duty cycle
1 non-inverted
(‘1’)
maximum % of time
that the LED is off
(logic 1)
minimum % of time
that the LED is off
(logic 1)
For Direct behavior,
maximum brightness is
100 minus max duty
cycle. When breathing,
max brightness is
100 minus min duty
cycle. Brightness
ramps from 100 - min
duty cycle to 100 - max
duty cycle.
according to LED
behavior
TABLE 6-49: LINKED LED TRANSITION CONTROL REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
77h R/W Linked LED Transition
Control - - LED6_
LTRAN
LED5_
LTRAN
LED4_
LTRAN
LED3_
LTRAN
LED2_
LTRAN
LED1_
LTRAN 00h
2015 Microchip Technology Inc. DS00001621B-page 54
CAP1166
Bit 5 - LED6_LTRAN - Determines the transition effect when LED6 is linked to CS6.
• ‘0’ (default) - When the LED output control bit for LED6 is ‘1’, and then LED6 is linked to CS6 and no touch is
detected, the LED will change states.
• ‘1’ - If the INV_LINK_TRAN bit is ‘1’, when the LED output control bit for CS6 is ‘1’, and then CS6 is linked to LED6
and no touch is detected, the LED will not change states. In addition, the LED state will change when the sensor
pad is touched. If the INV_LINK_TRAN bit is ‘0’, when the LED output control bit for CS6 is ‘1’, and then CS6 is
linked to LED6 and no touch is detected, the LED will not change states. However, the LED state will not change
when the sensor pad is touched.
APPLICATION NOTE: If the LED behavior is not “Direct” and the INV_LINK_TRAN bit it ‘0’, the LED will not perform
as expected when the LED6_LTRAN bit is set to ‘1’. Therefore, if breathe and pulse
behaviors are used, set the INV_LINK_TRAN bit to ‘1’.
Bit 4 - LED5_LTRAN - Determines the transition effect when LED5 is linked to CS5.
Bit 3 - LED4_LTRAN - Determines the transition effect when LED4 is linked to CS4.
Bit 2 - LED3_LTRAN - Determines the transition effect when LED3 is linked to CS3.
Bit 1 - LED2_LTRAN - Determines the transition effect when LED2 is linked to CS2.
Bit 0 - LED1_LTRAN - Determines the transition effect when LED1 is linked to CS1.
6.30 LED Mirror Control Register
The LED Mirror Control Registers determine the meaning of duty cycle settings when polarity is non-inverted for each
LED channel. When the polarity bit is set to ‘1’ (non-inverted), to obtain correct steps for LED ramping, pulse, and
breathe behaviors, the min and max duty cycles need to be relative to 100%, rather than the default, which is relative
to 0%.
APPLICATION NOTE: The LED drive assumes that the LEDs are configured such that if the LED pin is driven to
a logic ‘0’, the LED will be on and the CAP1166 LED pin is sinking the LED current. When
the polarity bit is set to ‘1’, it is considered non-inverted. For systems using the opposite LED
configuration, mirror controls would apply when the polarity bit is ‘0’.
These bits are changed automatically if the corresponding LED Polarity bit is changed (unless the BLK_POL_MIR bit is
set - see Section 6.6).
Bit 5 - LED6_MIR_EN - Determines whether the duty cycle settings are “biased” relative to 0% or 100% duty cycle.
• ‘0’ (default) - The duty cycle settings are determined relative to 0% and are determined directly with the settings.
• ‘1’ - The duty cycle settings are determined relative to 100%.
Bit 4 - LED5_MIR_EN - Determines whether the duty cycle settings are “biased” relative to 0% or 100% duty cycle.
Bit 3 - LED4_MIR_EN - Determines whether the duty cycle settings are “biased” relative to 0% or 100% duty cycle.
Bit 2 - LED3_MIR_EN - Determines whether the duty cycle settings are “biased” relative to 0% or 100% duty cycle.
Bit 1 - LED2_MIR_EN - Determines whether the duty cycle settings are “biased” relative to 0% or 100% duty cycle.
Bit 0 - LED1_MIR_EN - Determines whether the duty cycle settings are “biased” relative to 0% or 100% duty cycle.
TABLE 6-50: LED MIRROR CONTROL REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
79h R/W LED Mirror Control
- -
LED6_
MIR _
EN
LED5_
MIR _
EN
LED4_M
IR_
EN
LED3_
MIR_
EN
LED2_
MIR _
EN
LED1_
MIR _
EN
00h
CAP1166
DS00001621B-page 55 2015 Microchip Technology Inc.
6.31 LED Behavior Registers
The LED Behavior registers control the operation of LEDs. Each LED pin is controlled by a 2-bit field and the behavior
is determined by whether the LED is linked to a capacitive touch sensor input or not.
If the corresponding LED output is linked to a capacitive touch sensor input, the appropriate behavior will be enabled /
disabled based on touches and releases.
If the LED output is not associated with a capacitive touch sensor input, the appropriate behavior will be enabled / disabled
by the LED Output Control register. If the respective LEDx_DR bit is set to a logic ‘1’, this will be associated as a
“touch”, and if the LEDx_DR bit is set to a logic ‘0’, this will be associated as a “release”.
Table 6-52, "LEDx_CTL Bit Decode" shows the behavior triggers. The defined behavior will activate when the Start Trigger
is met and will stop when the Stop Trigger is met. Note the behavior of the Breathe Hold and Pulse Release option.
The LED Polarity Control register will determine the non actuated state of the LED outputs (see Section 6.27, "LED
Polarity Register").
APPLICATION NOTE: If an LED is not linked to a capacitive touch sensor input and is breathing (via the Breathe
or Pulse behaviors), it must be unactuated and then re-actuated before changes to behavior
are processed. For example, if the LED output is breathing and the Maximum duty cycle is
changed, this change will not take effect until the LED output control register is set to ‘0’ and
then re-set to ‘1’.
APPLICATION NOTE: If an LED is not linked to the capacitive touch sensor input and configured to operate using
Pulse 1 Behavior, then the circuitry will only be actuated when the corresponding output
control bit is set. It will not check the bit condition until the Pulse 1 behavior is finished. The
device will not remember if the bit was cleared and reset while it was actuated.
APPLICATION NOTE: If an LED is actuated and not linked and the desired LED behavior is changed, this new
behavior will take effect immediately; however, the first instance of the changed behavior
may act incorrectly (e.g. if changed from Direct to Pulse 1, the LED output may ‘breathe’ 4
times and then end at minimum duty cycle). LED Behaviors will operate normally once the
LED has been un-actuated and then re-actuated.
APPLICATION NOTE: If an LED is actuated and it is switched from linked to a capacitive touch sensor input to
unlinked (or vice versa), the LED will respond to the new command source immediately if
the behavior was Direct or Breathe. For Pulse behaviors, it will complete the behavior
already in progress. For example, if a linked LED was actuated by a touch and the control
is changed so that it is unlinked, it will check the status of the corresponding LED Output
Control bit. If that bit is ‘0’, then the LED will behave as if a release was detected. Likewise,
if an unlinked LED was actuated by the LED Output Control register and the control is
changed so that it is linked and no touch is detected, then the LED will behave as if a release
was detected.
6.31.1 LED BEHAVIOR 1 - 81H
Bits 7 - 6 - LED4_CTL[1:0] - Determines the behavior of LED4 as shown in Table 6-52.
Bits 5 - 4 - LED3_CTL[1:0] - Determines the behavior of LED3 as shown in Table 6-52.
Bits 3 - 2 - LED2_CTL[1:0] - Determines the behavior of LED2 as shown in Table 6-52.
Bits 1 - 0 - LED1_CTL[1:0] - Determines the behavior of LED1 as shown in Table 6-52.
6.31.2 LED BEHAVIOR 2 - 82H
Bits 3 - 2 - LED6_CTL[1:0] - Determines the behavior of LED6 as shown in Table 6-52.
Bits 1 - 0 - LED5_CTL[1:0] - Determines the behavior of LED5 as shown in Table 6-52.
TABLE 6-51: LED BEHAVIOR REGISTERS
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
81h R/W LED Behavior 1 LED4_CTL[1:0] LED3_CTL[1:0] LED2_CTL[1:0] LED1_CTL[1:0] 00h
82h R/W LED Behavior 2 - - - - LED6_CTL[1:0] LED5_CTL[1:0] 00h
2015 Microchip Technology Inc. DS00001621B-page 56
CAP1166
APPLICATION NOTE: The PWM frequency is determined based on the selected LED behavior, the programmed
breathe period, and the programmed min and max duty cycles. For the Direct behavior
mode, the PWM frequency is calculated based on the programmed Rise and Fall times. If
these are set at 0, then the maximum PWM frequency will be used based on the
programmed duty cycle settings.
6.32 LED Pulse 1 Period Register
The LED Pulse Period 1 register determines the overall period of a pulse operation as determined by the LED_CTL
registers (see Table 6-52 - setting 01b). The LSB represents 32ms so that a setting of 18h (24d) would represent a
period of 768ms (24 x 32ms = 768ms). The total range is from 32ms to 4.064 seconds as shown in Table 6-54 with the
default being 1024ms.
APPLICATION NOTE: Due to constraints on the LED Drive PWM operation, any Breathe Period less than 160ms
(05h) may not be achievable. The device will breathe at the minimum period possible as
determined by the period and min / max duty cycle settings.
Bit 7 - ST_TRIG - Determines the start trigger for the LED Pulse behavior.
• ‘0’ (default) - The LED will Pulse when a touch is detected or the drive bit is set.
• ‘1’ - The LED will Pulse when a release is detected or the drive bit is cleared.
TABLE 6-52: LEDX_CTL BIT DECODE
LEDx_CTL
[1:0] Operation Description Start TRigger Stop Trigger
1 0
0 0 Direct The LED is driven to the programmed state
(active or inactive). See Figure 6-7
Touch Detected or
LED Output Control
bit set
Release
Detected or
LED Output
Control bit
cleared
0 1 Pulse 1
The LED will “Pulse” a programmed number
of times. During each “Pulse” the LED will
breathe up to the maximum brightness and
back down to the minimum brightness so that
the total “Pulse” period matches the programmed
value.
Touch or Release
Detected or LED
Output Control bit
set or cleared
(see Section 6.32)
n/a
1 0 Pulse 2
The LED will “Pulse” when the start trigger is
detected. When the stop trigger is detected, it
will “Pulse” a programmable number of times
then return to its minimum brightness.
Touch Detected or
LED Output Control
bit set
Release
Detected or
LED Output
Control bit
cleared
1 1 Breathe
The LED will breathe. It will be driven with a
duty cycle that ramps up from the programmed
minimum duty cycle (default 0%) to
the programmed maximum duty cycle duty
cycle (default 100%) and then back down.
Each ramp takes up 50% of the programmed
period. The total period of each “breath” is
determined by the LED Breathe Period controls
- see Section 6.34.
Touch Detected or
LED Output Control
bit set
Release
Detected or
LED Output
Control bit
cleared
TABLE 6-53: LED PULSE 1 PERIOD REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
84h R/W LED Pulse 1
Period
ST_
TRIG
P1_
PER6
P1_
PER5
P1_
PER4
P1_
PER3
P1_
PER2
P1_
PER1
P1_
PER0 20h
CAP1166
DS00001621B-page 57 2015 Microchip Technology Inc.
The Pulse 1 operation is shown in Figure 6-1 when the LED output is configured for non-inverted polarity (LEDx_POL
= 1) and in Figure 6-2 for inverted polarity (LEDx_POL = 0).
.
FIGURE 6-1: Pulse 1 Behavior with Non-Inverted Polarity
FIGURE 6-2: Pulse 1 Behavior with Inverted Polarity
TABLE 6-54: LED PULSE / BREATHE PERIOD EXAMPLE
Setting (HEX) Setting (Decimal) Total Breathe / Pulse Period (MS)
00h 0 32
01h 1 32
02h 2 64
03h 3 96
. . . . . . . . .
7Dh 125 4000
Normal – untouched
operation Normal – untouched
operation
Touch Detected or
Release Detected
(100% - Pulse 1 Max Duty Cycle) * Brightness
X pulses after touch or after release
Pulse 1 Period
(P1_PER)
(100% - Pulse 1 Min Duty Cycle) * Brightness
LED
Brightness
Normal – untouched
operation
Normal – untouched
operation
Touch Detected or
Release Detected
Pulse 1 Min Duty Cycle * Brightness
X pulses after touch or after release
Pulse Period
(P1_PER)
Pulse 1 Max Duty Cycle * Brightness
LED
Brightness
2015 Microchip Technology Inc. DS00001621B-page 58
CAP1166
6.33 LED Pulse 2 Period Register
The LED Pulse 2 Period register determines the overall period of a pulse operation as determined by the LED_CTL
registers (see Table 6-52 - setting 10b). The LSB represents 32ms so that a setting of 18h (24d) would represent a
period of 768ms. The total range is from 32ms to 4.064 seconds (see Table 6-54) with a default of 640ms.
APPLICATION NOTE: Due to constraints on the LED Drive PWM operation, any Breathe Period less than 160ms
(05h) may not be achievable. The device will breathe at the minimum period possible as
determined by the period and min / max duty cycle settings.
The Pulse 2 Behavior is shown in Figure 6-3 for non-inverted polarity (LEDx_POL = 1) and in Figure 6-4 for inverted
polarity (LEDx_POL = 0).
7Eh 126 4032
7Fh 127 4064
TABLE 6-55: LED PULSE 2 PERIOD REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
85h R/W LED Pulse 2
Period - P2_
PER6
P2_
PER5
P2_
PER4
P2_
PER3
P2_
PER2
P2_
PER1
P2_
PER0 14h
FIGURE 6-3: Pulse 2 Behavior with Non-Inverted Polarity
TABLE 6-54: LED PULSE / BREATHE PERIOD EXAMPLE (CONTINUED)
Setting (HEX) Setting (Decimal) Total Breathe / Pulse Period (MS)
. . .
Normal – untouched
operation
Normal – untouched
operation
Touch Detected
(100% - Pulse 2 Min Duty Cycle) *
Brightness
(100% - Pulse 2 Max Duty Cycle) * Brightness
X additional pulses after release
Release Detected
Pulse
Period
(P2_PER)
LED
Brightness
CAP1166
DS00001621B-page 59 2015 Microchip Technology Inc.
6.34 LED Breathe Period Register
The LED Breathe Period register determines the overall period of a breathe operation as determined by the LED_CTL
registers (see Table 6-52 - setting 11b). The LSB represents 32ms so that a setting of 18h (24d) would represent a
period of 768ms. The total range is from 32ms to 4.064 seconds (see Table 6-54) with a default of 2976ms.
APPLICATION NOTE: Due to constraints on the LED Drive PWM operation, any Breathe Period less than 160ms
(05h) may not be achievable. The device will breathe at the minimum period possible as
determined by the period and min / max duty cycle settings.
6.35 LED Configuration Register
The LED Configuration register controls general LED behavior as well as the number of pulses that are sent for the
PULSE LED output behavior.
Bit 6 - RAMP_ALERT - Determines whether the device will assert the ALERT# pin when LEDs actuated by the LED
Output Control register bits have finished their respective behaviors. Interrupts will only be generated if the LED activity
is generated by writing the LED Output Control registers. Any LED activity associated with touch detection will not cause
an interrupt to be generated when the LED behavior has been finished.
• ‘0’ (default) - The ALERT# pin will not be asserted when LEDs actuated by the LED Output Control register have
finished their programmed behaviors.
• ‘1’ - The ALERT# pin will be asserted whenever any LED that is actuated by the LED Output Control register has
finished its programmed behavior.
Bits 5 - 3 - PULSE2_CNT[2:0] - Determines the number of pulses used for the Pulse 2 behavior as shown in Table 6-58.
Bits 2 - 0 - PULSE1_CNT[2:0] - Determines the number of pulses used for the Pulse 1 behavior as shown in Table 6-58.
FIGURE 6-4: Pulse 2 Behavior with Inverted Polarity
TABLE 6-56: LED BREATHE PERIOD REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
86h R/W LED Breathe
Period - BR_
PER6
BR_
PER5
BR_
PER4
BR_
PER3
BR_
PER2
BR_
PER1
BR_
PER0 5Dh
TABLE 6-57: LED CONFIGURATION REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
88h R/W LED Config - RAMP_
ALERT PULSE2_CNT[2:0] PULSE1_CNT[2:0] 04h
Normal – untouched
operation
Normal – untouched
operation
Touch Detected
Pulse 2 Max Duty Cycle * Brightness
Pulse 2 Min Duty Cycle * Brightness
X additional pulses after release
Release Detected
Pulse
Period
(P2_PER)
LED
Brightness . . .
2015 Microchip Technology Inc. DS00001621B-page 60
CAP1166
6.36 LED Duty Cycle Registers
The LED Duty Cycle registers determine the minimum and maximum duty cycle settings used for the LED for each LED
behavior. These settings affect the brightness of the LED when it is fully off and fully on.
The LED driver duty cycle will ramp up from the minimum duty cycle to the maximum duty cycle and back down again.
APPLICATION NOTE: When operating in Direct behavior mode, changes to the Duty Cycle settings will be applied
immediately. When operating in Breathe, Pulse 1, or Pulse 2 modes, the LED must be
unactuated and then re-actuated before changes to behavior are processed.
Bits 7 - 4 - X_MAX_DUTY[3:0] - Determines the maximum PWM duty cycle for the LED drivers as shown in Table 6-60.
Bits 3 - 0 - X_MIN_DUTY[3:0] - Determines the minimum PWM duty cycle for the LED drivers as shown in Table 6-60.
TABLE 6-58: PULSEX_CNT DECODE
PULSEX_CNT[2:0]
Number of Breaths
21 0
0 0 0 1 (default - Pulse 2)
00 1 2
01 0 3
01 1 4
1 0 0 5 (default - Pulse 1)
10 1 6
11 0 7
11 1 8
TABLE 6-59: LED DUTY CYCLE REGISTERS
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
90h R/W LED Pulse 1 Duty
Cycle P1_MAX_DUTY[3:0] P1_MIN_DUTY[3:0] F0h
91h R/W LED Pulse 2 Duty
Cycle P2_MAX_DUTY[3:0] P2_MIN_DUTY[3:0] F0h
92h R/W LED Breathe
Duty Cycle BR_MAX_DUTY[3:0] BR_MIN_DUTY[3:0] F0h
93h R/W Direct Duty Cycle DR_MAX_DUTY[3:0] DR_MIN_DUTY[3:0] F0h
TABLE 6-60: LED DUTY CYCLE DECODE
x_MAX/MIN_Duty [3:0]
Maximum Duty Cycle Minimum Duty Cycle
3 21 0
0 0 0 0 7% 0%
0 0 0 1 9% 7%
0 0 1 0 11% 9%
0 0 1 1 14% 11%
0 1 0 0 17% 14%
0 1 0 1 20% 17%
0 1 1 0 23% 20%
0 1 1 1 26% 23%
1 0 0 0 30% 26%
1 0 0 1 35% 30%
1 0 1 0 40% 35%
CAP1166
DS00001621B-page 61 2015 Microchip Technology Inc.
6.37 LED Direct Ramp Rates Register
The LED Direct Ramp Rates register control the rising and falling edge time of an LED that is configured to operate in
Direct behavior mode. The rising edge time corresponds to the amount of time the LED takes to transition from its minimum
duty cycle to its maximum duty cycle. Conversely, the falling edge time corresponds to the amount of time that
the LED takes to transition from its maximum duty cycle to its minimum duty cycle.
Bits 5 - 3 - RISE_RATE[2:0] - Determines the rising edge time of an LED when it transitions from its minimum drive state
to its maximum drive state as shown in Table 6-62.
Bits 2 - 0 - FALL_RATE[2:0] - Determines the falling edge time of an LED when it transitions from its maximum drive
state to its minimum drive state as shown in Table 6-62.
6.38 LED Off Delay Register
The LED Off Delay register determines the amount of time that an LED remains at its maximum duty cycle (or minimum
as determined by the polarity controls) before it starts to ramp down. If the LED is operating in Breathe mode, this delay
is applied at the top of each “breath”. If the LED is operating in the Direct mode, this delay is applied when the LED is
unactuated.
1 0 1 1 46% 40%
1 1 0 0 53% 46%
1 1 0 1 63% 53%
1 1 1 0 77% 63%
1 1 1 1 100% 77%
TABLE 6-61: LED DIRECT RAMP RATES REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
94h R/W LED Direct Ramp
Rates - - RISE_RATE[2:0] FALL_RATE[2:0] 00h
TABLE 6-62: RISE / FALL RATE DECODE
RISE_RATE/ FALL_RATE/ Bit Decode
Rise / Fall Time (TRISE / TFALL)
21 0
00 0 0
0 0 1 250ms
0 1 0 500ms
0 1 1 750ms
1 0 0 1s
1 0 1 1.25s
1 1 0 1.5s
1 1 1 2s
TABLE 6-63: LED OFF DELAY REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
95h R/W LED Off Delay
Register - BR_OFF_DLY[2:0] DIR_OFF_DLY[3:0] 00h
TABLE 6-60: LED DUTY CYCLE DECODE (CONTINUED)
x_MAX/MIN_Duty [3:0]
Maximum Duty Cycle Minimum Duty Cycle
3 21 0
2015 Microchip Technology Inc. DS00001621B-page 62
CAP1166
Bits 6 - 4 - BR_OFF_DLY[2:0] - Determines the Breathe behavior mode off delay, which is the amount of time an LED
in Breathe behavior mode remains inactive after it finishes a breathe pulse (ramp on and ramp off), as shown in Figure 6-
5 (non-inverted polarity LEDx_POL = 1) and Figure 6-6 (inverted polarity LEDx_POL = 0). Available settings are shown
in Table 6-64.
FIGURE 6-5: Breathe Behavior with Non-Inverted Polarity
FIGURE 6-6: Breathe Behavior with Inverted Polarity
LED Actuated
100% - Breathe Max Min Cycle * Brightness
100% - Breathe Min Duty Cycle *
Brightness
LED Unactuated
Breathe Off
Delay
(BR_OFF_DLY)
LED
Brightness
Breathe
Period
(BR_PER)
LED Actuated
Breathe Max Duty Cycle * Brightness
Breathe Min Duty Cycle * Brightness
LED Unactuated
Breathe Off
Delay
(BR_OFF_DLY)
LED
Brightness
Breathe
Period
(BR_PER)
CAP1166
DS00001621B-page 63 2015 Microchip Technology Inc.
Bits 3 - 0 - DIR_OFF_DLY[3:0] - Determines the turn-off delay, as shown in Table 6-65, for all LEDs that are configured
to operate in Direct behavior mode.
The Direct behavior operation is determined by the combination of programmed Rise Time, Fall Time, Min and Max Duty
cycles, Off Delay, and polarity. Figure 6-7 shows the behavior for non-inverted polarity (LEDx_POL = 1) while Figure 6-
8 shows the behavior for inverted polarity (LEDx_POL = 0).
TABLE 6-64: BREATHE OFF DELAY SETTINGS
BR_OFF_DLY [2:0]
OFF Delay
2 10
0 0 0 0 (default)
0 0 1 0.25s
0 1 0 0.5s
0 1 1 0.75s
1 0 0 1.0s
1 0 1 1.25s
1 1 0 1.5s
1 1 1 2.0s
FIGURE 6-7: Direct Behavior for Non-Inverted Polarity
FIGURE 6-8: Direct Behavior for Inverted Polarity
Normal –
untouched
operation
RISE_RATE
Setting (tRISE)
(100% - Max Duty
Cycle) * Brightness
Touch
Detected
Release
Detected
Off Delay
(tOFF_DLY)
FALL_RATE
Setting (tFALL)
Normal –
untouched
operation
(100% - Min Duty Cycle) *
Brightness LED
Brightness
Normal –
untouched
operation RISE_RATE
Setting (tRISE)
Min Duty Cycle * Brightness
Touch
Detected
Release
Detected
Off Delay
(tOFF_DLY)
FALL_RATE
Setting (tFALL)
Normal –
untouched
operation
Max Duty Cycle * Brightness
LED
Brightness
2015 Microchip Technology Inc. DS00001621B-page 64
CAP1166
6.39 Sensor Input Calibration Registers
The Sensor Input Calibration registers hold the 10-bit value that represents the last calibration value.
TABLE 6-65: OFF DELAY DECODE
OFF Delay[3:0] Bit Decode
OFF Delay (tOFF_DLY)
32 1 0
00 0 0 0
0 0 0 1 250ms
0 0 1 0 500ms
0 0 1 1 750ms
0 1 0 0 1s
0 1 0 1 1.25s
0 1 1 0 1.5s
0 1 1 1 2s
1 0 0 0 2.5s
1 0 0 1 3.0s
1 0 1 0 3.5s
1 0 1 1 4.0s
1 1 0 0 4.5s
All others 5.0s
TABLE 6-66: SENSOR INPUT CALIBRATION REGISTERS
ADDR Register R/W B7 B6 B5 B4 B3 B2 B1 B0 Default
B1h Sensor Input 1
Calibration R CAL1_9 CAL1_8 CAL1_7 CAL1_6 CAL1_5 CAL1_4 CAL1_3 CAL1_2 00h
B2h Sensor Input 2
Calibration R CAL2_9 CAL2_8 CAL2_7 CAL2_6 CAL2_5 CAL2_4 CAL2_3 CAL2_2 00h
B3h Sensor Input 3
Calibration R CAL3_9 CAL3_8 CAL3_7 CAL3_6 CAL3_5 CAL3_4 CAL3_3 CAL3_2 00h
B4h Sensor Input 4
Calibration R CAL4_9 CAL4_8 CAL4_7 CAL4_6 CAL4_5 CAL4_4 CAL4_3 CAL4_2 00h
B5h Sensor Input 5
Calibration R CAL5_9 CAL5_8 CAL5_7 CAL5_6 CAL5_5 CAL5_4 CAL5_3 CAL5_2 00h
B6h Sensor Input 6
Calibration R CAL6_9 CAL6_8 CAL6_7 CAL6_6 CAL6_5 CAL6_4 CAL6_3 CAL6_2 00h
B9h
Sensor Input
Calibration LSB
1
R CAL4_1 CAL4_0 CAL3_1 CAL3_0 CAL2_1 CAL2_0 CAL1_1 CAL1_0 00h
BAh
Sensor Input
Calibration LSB
2
R - - - - CAL6_1 CAL6_0 CAL5_1 CAL5_0 00h
CAP1166
DS00001621B-page 65 2015 Microchip Technology Inc.
6.40 Product ID Register
The Product ID register stores a unique 8-bit value that identifies the device.
6.41 Manufacturer ID Register
The Vendor ID register stores an 8-bit value that represents Microchip.
6.42 Revision Register
The Revision register stores an 8-bit value that represents the part revision.
TABLE 6-67: PRODUCT ID REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
FDh R Product ID 0 1 0 1 0 0 0 1 51h
TABLE 6-68: VENDOR ID REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
FEh R Manufacturer ID 0 1 0 1 1 1 0 1 5Dh
TABLE 6-69: REVISION REGISTER
ADDR R/W Register B7 B6 B5 B4 B3 B2 B1 B0 Default
FFh R Revision 1 0 0 0 0 0 1 1 83h
2015 Microchip Technology Inc. DS00001621B-page 66
CAP1166
7.0 PACKAGE INFORMATION
7.1 CAP1166 Package Drawings
Note: For the most current package drawings, see the Microchip Packaging Specification at:
http://www.microchip.com/packaging.
FIGURE 7-1: 24-Pin SSOP Package Drawing
CAP1166
DS00001621B-page 67 2015 Microchip Technology Inc.
FIGURE 7-2: 24-Pin SSOP Package Dimensions
2015 Microchip Technology Inc. DS00001621B-page 68
CAP1166
FIGURE 7-3: CAP1166 PCB Land Pattern - 24-Pin SSOP
CAP1166
DS00001621B-page 69 2015 Microchip Technology Inc.
FIGURE 7-4: 20-Pin QFN 4mm x 4mm Package Drawing
2015 Microchip Technology Inc. DS00001621B-page 70
CAP1166
FIGURE 7-5: 20-Pin QFN 4mm x 4mm Package Dimensions
FIGURE 7-6: 20-Pin QFN 4mm x 4mm PCB Drawing
CAP1166
DS00001621B-page 71 2015 Microchip Technology Inc.
7.2 Package Marking
FIGURE 7-7: CAP1166 Package Markings - 20-Pin QFN
FIGURE 7-8: CAP1166 Package Markings - 24-Pin SSOP
C 1 66 - 1
Y WWN N N A
RCC
e3
TOP
BOTTOM
Bottom marking not allowed
PB-FREE/GREEN SYMBOL
(Matte Sn)
Lines 1-3:
Line 4:
Center Horizontal Alignment
Left Horizontal Alignment
PIN 1
0.41
3x 0.56
Line 1 – SMSC Logo without circled R symbol
Line 2 – Device ID, Version
Line 3 – Year, Week, Alphanumeric Traceability Code
Line 4 – Revision, Country Code
1
e3
TOP
BOTTOM
PB-FREE/GREEN SYMBOL
(Matte Sn)
PIN 1
0.6
2x 1.5pt
Line 1 – SMSC Logo with circled R symbol
Line 2 – Device ID, Version
Line 3 – Revision, Year, Week, Traceability Code
Line 2 – Vendor Code, Country Code
PIN 1
C A 11 P 6 6 - 1
Y W NNNA W
®
R
B B 9 3
V V V CC -
Line 1 – Engineering Code
2x 1.5pt
2015 Microchip Technology Inc. DS00001621B-page 72
CAP1166
APPENDIX A: DEVICE DELTA
A.1 Delta from CAP1066 to CAP1166
1. Updated circuitry to improve power supply rejection.
2. Updated LED driver duty cycle decode values to have more distribution at lower values - closer to a logarithmic
curve. See Table 6-60, "LED Duty Cycle Decode".
3. Updated bug that breathe periods were not correct above 2.6s. This includes rise / fall time decodes above 1.5s.
4. Added filtering on RESET pin to prevent errant resets.
5. Updated controls so that the RESET pin assertion places the device into the lowest power state available and
causes an interrupt when released. See Section 5.2, "RESET Pin".
6. Added 1 bit to the LED Off Delay register (see Section 6.38, "LED Off Delay Register") to extend times from 2s
to 5s in 0.5s intervals.
7. Breathe behavior modified. A breathe off delay control was added to the LED Off Delay Register (see Section
6.38, "LED Off Delay Register") so the LEDs can be configured to remain inactive between breathes.
8. Added controls for the LED transition effects when linking LEDs to capacitive sensor inputs. See Section 6.29,
"Linked LED Transition Control Register".
9. Added controls to “mirror” the LED duty cycle outputs so that when polarity changes, the LED brightness levels
look right. These bits are automatically set when polarity is set. Added control to break this auto-set behavior.
See Section 6.30, "LED Mirror Control Register".
10. Added Multiple Touch Pattern detection circuitry. See Section 6.15, "Multiple Touch Pattern Configuration Register".
11. Added General Status register to flag Multiple touches, Multiple Touch Pattern issues and general touch detections.
See Section 6.2, "Status Registers".
12. Added bits 6 and 5 to the Recalibration Configuration register (2Fh - see Section 6.17, "Recalibration Configuration
Register"). These bits control whether the accumulation of intermediate data and the consecutive negative
delta counts counter are cleared when the noise status bit is set.
13. Added Configuration 2 register for LED linking controls, noise detection controls, and control to interrupt on press
but not on release. Added control to change alert pin polarity. See Section 6.6, "Configuration Registers".
14. Updated Deep Sleep behavior so that device does not clear DSLEEP bit on received communications but will
wake to communicate.
15. Changed PWM frequency for LED drivers. The PWM frequency was derived from the programmed breathe
period and duty cycle settings and it ranged from ~4Hz to ~8000 Hz. The PWM frequency has been updated to
be a fixed value of ~2000Hz.
16. Register delta:
Table A.1 Register Delta From CAP1066 to CAP1166
Address Register Delta Delta Default
00h
Page 33
Changed - Main Status /
Control
added bits 7-6 to control gain 00h
02h
Page 34
New - General Status new register to store MTP, MULT, LED,
RESET, and general TOUCH bits
00h
44h
Page 37
New - Configuration 2 new register to control alert polarity, LED
touch linking behavior, LED output behavior,
and noise detection, and interrupt on
release
40h
24h
Page 41
Changed - Averaging
Control
updated register bits - moved
SAMP_AVG[2:0] bits and added SAMP_-
TIME bit 1. Default changed
39h
2Bh
Page 44
New - Multiple Touch
Pattern Configuration
new register for Multiple Touch Pattern
configuration - enable and threshold settings
80h
CAP1166
DS00001621B-page 73 2015 Microchip Technology Inc.
2Dh
Page 45
New - Multiple Touch
Pattern Register
new register for Multiple Touch Pattern
detection circuitry - pattern or number of
sensor inputs
3Fh
2Fh
Page 45
Changed - Recalibration
Configuration
updated register - updated CAL_CFG bit
decode to add a 128 averages setting and
removed highest time setting. Default
changed. Added bit 6 NO_CLR_INTD and
bit 5 NO_CLR_NEG.
8Ah
38h
Page 47
Changed - Sensor Input
Noise Threshold
updated register bits - removed bits 7 - 3
and consolidated all controls into bits 1 - 0.
These bits will set the noise threshold for
all channels. Default changed
01h
39h Removed - Noise
Threshold Register 2
removed register n/a
41h
Page 48
Changed - Standby Configuration
updated register bits - moved
STBY_AVG[2:0] bits and added STBY_-
TIME bit 1. Default changed
39h
77h
Page 53
New - Linked LED Transition
Control
new register to control transition effect
when LED linked to sensor inputs
00h
79h
Page 54
New - LED Mirror Control new register to control LED output mirroring
for brightness control when polarity
changed
00h
90h
Page 60
Changed - LED Pulse 1
Duty Cycle
changed bit decode to be more logarithmic F0h
91h
Page 60
Changed - LED Pulse 2
Duty Cycle
changed bit decode to be more logarithmic F0h
92h
Page 60
Changed - LED Breathe
Duty Cycle
changed bit decode to be more logarithmic F0h
93h
Page 60
Changed - LED Direct
Duty Cycle
changed bit decode to be more logarithmic F0h
95h Added controls - LED Off
Delay
Added bits 6-4 BR_OFF_DLY[2:0]
Added bit 3 DIR_OFF_DLY[3]
00h
FDh
Page 65
Changed - Product ID Changed bit decode for CAP1166 51h
Table A.1 Register Delta From CAP1066 to CAP1166 (continued)
Address Register Delta Delta Default
2015 Microchip Technology Inc. DS00001621B-page 74
CAP1166
APPENDIX B: DATA SHEET REVISION HISTORY
Revision Section/Figure/Entry Correction
DS00001621B (02-09-15)
Features, Table 2-1, Table 2-
2, "Pin Types", Section 5.0,
"General Description"
References to BC-Link Interface, BC_DATA, BC_-
CLK, BC-IRQ#, BC-Link bus have been removed
Application Note under Table
2-6
[BC-Link] hidden in data sheet
Table 3-2, "Electrical Specifications"
BC-Link Timing Section hidden in data sheet
Table 4-1 Protocol Used for 68K Pull Down Resistor changed
from “BC-Link Communications” to “Reserved”
Section 4.2.2, "SMBus
Address and RD / WR Bit"
Replaced “client address” with “slave address” in this
section.
Section 4.2.4, SMBus ACK
and NACK Bits, Section 4.2.5,
SMBus Stop Bit,Section 4.2.7,
SMBus and I2C Compatibility
Replaced “client” with “slave” in these sections.
Table 4-4, "Read Byte Protocol"
Heading changed from “Client Address” to “Slave
Address”
Table 6-1 Register Name for Register Address 77h changed
from “LED Linked Transition Control” to “Linked LED
Transition Control”
Section 6.30 changed CS6 to LED6
Table 6-53 Modified B3 bit name
Section 7.7 Package Marking Updated package drawing
Appendix A: Device Delta changed 2Dh to 2Fh in item #12
Product Identification System Removed BC-Link references
REV A REV A replaces previous SMSC version Rev. 1.32 (01-05-12)
Rev. 1.32 (01-05-12) Table 3-2, "Electrical Specifications"
Added conditions for tHD:DAT.
Section 4.2.7, "SMBus and
I2C Compatibility"
Renamed from “SMBus and I2C Compliance.”
First paragraph, added last sentence: “For information
on using the CAP1188 in an I2C system, refer to
SMSC AN 14.0 SMSC Dedicated Slave Devices in
I
2C Systems.”
Added: CAP1188 supports I2C fast mode at 400kHz.
This covers the SMBus max time of 100kHz.
Section 6.4, "Sensor Input
Delta Count Registers"
Changed negative value cap from FFh to 80h.
Rev. 1.31 (08-18-11) Section 4.3.3, "SMBus Send
Byte"
Added an application note: The Send Byte protocol
is not functional in Deep Sleep (i.e., DSLEEP bit is
set).
Section 4.3.4, "SMBus
Receive Byte"
Added an application note: The Receive Byte protocol
is not functional in Deep Sleep (i.e., DSLEEP bit
is set).
Rev. 1.3 (05-18-11) Section 6.42, "Revision Register"
Updated revision ID from 82h to 83h.
Rev. 1.2 (02-10-11) Section A.8, "Delta from Rev
B (Mask B0) to Rev C (Mask
B1)"
Added.
CAP1166
DS00001621B-page 75 2015 Microchip Technology Inc.
Table 2-1, "Pin Description for
CAP1166"
Changed value in “Unused Connection” column for
the ADDR_COMM pin from “Connect to Ground” to
“n/a“.
Table 3-2, "Electrical Specifications"
PSR improvements made in functional revision B.
Changed PSR spec from ±100 typ and ±200 max
counts / V to ±3 and ±10 counts / V. Conditions
updated.
Section 5.5.2, "Recalibrating
Sensor Inputs"
Added more detail with subheadings for each type of
recalibration.
Section 6.6, "Configuration
Registers"
Added bit 5 BLK_PWR_CTRL to the Configuration 2
Register 44h.
The TIMEOUT bit is set to ‘1’ by default for functional
revision B and is set to ‘0’ by default for functional
revision C.
Section 6.42, "Revision Register"
Updated revision ID in register FFh from 81h to 82h.
Rev. 1.1 (11-17-10) Document Updated for functional revision B. See Section A.7,
"Delta from Rev A (Mask A0) to Rev B (Mask B0)".
Cover Added to General Description: “includes circuitry and
support for enhanced sensor proximity detection.”
Added the following Features:
Calibrates for Parasitic Capacitance
Analog Filtering for System Noise Sources
Press and Hold feature for Volume-like Applications
Table 3-2, "Electrical Specifications"
Conditions for Power Supply Rejection modified adding
the following:
Sampling time = 2.56ms
Averaging = 1
Negative Delta Counts = Disabled
All other parameters default
Section 6.11, "Calibration Activate
Register"
Updated register description to indicate which re-calibration
routine is used.
Section 6.14, "Multiple Touch
Configuration Register"
Updated register description to indicate what will
happen.
Table 6-34, "CSx_BN_TH Bit
Decode"
Table heading changed from “Threshold Divide Setting”
to “Percent Threshold Setting”.
Section 7.0, "Package Information"
Added PCB land pattern.
CAP1166-1 added in an SSOP package.
Rev. 1.0 (06-14-10) Initial release
Revision Section/Figure/Entry Correction
2015 Microchip Technology Inc. DS00001621B-page 76
CAP1166
THE MICROCHIP WEB SITE
Microchip provides online support via our WWW site at www.microchip.com. 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 (FAQ), 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
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. Under “Support”, click on “Customer Change Notification”
and follow the registration instructions.
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://www.microchip.com/support
2015 Microchip Technology Inc. DS00001621B-page 77
CAP1166
PRODUCT IDENTIFICATION SYSTEM
To order or obtain information, e.g., on pricing or delivery, refer to the factory or the listed sales office.
PART NO. [X] - 1 - XXX - [X](1)
l l l l
Device Temperature Package Tape and Reel
Range Option
Examples:
Note 1: Tape and Reel identifier only appears in the catalog part number description. This identifier is used for ordering
purposes and is not printed on the device package. Check with your Microchip Sales Office for package availability
with the Tape and Reel option.
Device: CAP1166
Temperature
Range:
Blank = 0°C to +85°C (Extended Commercial)
Package: BP = QFN
CZC = SSOP
Tape and
Reel Option:
TR = Tape and Reel(1)
CAP1166-1-BP-TR
20-pin QFN 4mm x 4mm (RoHS compliant)
Six capacitive touch sensor inputs, Six LED
drivers, Dedicated Wake, Reset, SMBus /
BC-Link / SPI interfaces
Reel size is 4,000 pieces
CAP1166-1-CZC-TR
24-pin SSOP (RoHS compliant)
Six capacitive touch sensor inputs, Six LED
drivers, Dedicated Wake, Reset, SMBus /
BC-Link / SPI interfaces
Reel size is 2,500 pieces
2015 Microchip Technology Inc. DS00001621B-page 78
CAP1166
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, FlashFlex, flexPWR, JukeBlox, KEELOQ, KEELOQ logo, Kleer, LANCheck,
MediaLB, MOST, MOST logo, MPLAB, OptoLyzer, PIC, PICSTART, PIC32 logo, RightTouch, SpyNIC, SST, SST Logo, SuperFlash and
UNI/O are registered trademarks of Microchip Technology Incorporated in the U.S.A. and other countries.
The Embedded Control Solutions Company and mTouch are registered trademarks of Microchip Technology Incorporated in the U.S.A.
Analog-for-the-Digital Age, BodyCom, chipKIT, chipKIT logo, CodeGuard, dsPICDEM, dsPICDEM.net, ECAN, In-Circuit Serial
Programming, ICSP, Inter-Chip Connectivity, KleerNet, KleerNet logo, MiWi, MPASM, MPF, MPLAB Certified logo, MPLIB, MPLINK,
MultiTRAK, NetDetach, Omniscient Code Generation, PICDEM, PICDEM.net, PICkit, PICtail, RightTouch logo, REAL ICE, SQI, Serial
Quad I/O, Total Endurance, TSHARC, USBCheck, VariSense, ViewSpan, WiperLock, Wireless DNA, 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.
Silicon Storage Technology is a registered trademark of Microchip Technology Inc. in other countries.
GestIC is a registered trademarks of Microchip Technology Germany II GmbH & Co. KG, a subsidiary of Microchip Technology Inc., in
other countries.
All other trademarks mentioned herein are property of their respective companies.
© 2015, Microchip Technology Incorporated, Printed in the U.S.A., All Rights Reserved.
ISBN: 9781632770318
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.
QUALITY MANAGEMENT SYSTEM
CERTIFIED BY DNV
== ISO/TS 16949 ==
2015 Microchip Technology Inc. DS00001621B-page 79
AMERICAS
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
Atlanta
Duluth, GA
Tel: 678-957-9614
Fax: 678-957-1455
Austin, TX
Tel: 512-257-3370
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
Novi, MI
Tel: 248-848-4000
Houston, TX
Tel: 281-894-5983
Indianapolis
Noblesville, IN
Tel: 317-773-8323
Fax: 317-773-5453
Los Angeles
Mission Viejo, CA
Tel: 949-462-9523
Fax: 949-462-9608
New York, NY
Tel: 631-435-6000
San Jose, CA
Tel: 408-735-9110
Canada - Toronto
Tel: 905-673-0699
Fax: 905-673-6509
ASIA/PACIFIC
Asia Pacific Office
Suites 3707-14, 37th Floor
Tower 6, The Gateway
Harbour City, Kowloon
Hong Kong
Tel: 852-2943-5100
Fax: 852-2401-3431
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
China - Dongguan
Tel: 86-769-8702-9880
China - Hangzhou
Tel: 86-571-8792-8115
Fax: 86-571-8792-8116
China - Hong Kong SAR
Tel: 852-2943-5100
Fax: 852-2401-3431
China - Nanjing
Tel: 86-25-8473-2460
Fax: 86-25-8473-2470
China - Qingdao
Tel: 86-532-8502-7355
Fax: 86-532-8502-7205
China - Shanghai
Tel: 86-21-5407-5533
Fax: 86-21-5407-5066
China - Shenyang
Tel: 86-24-2334-2829
Fax: 86-24-2334-2393
China - Shenzhen
Tel: 86-755-8864-2200
Fax: 86-755-8203-1760
China - Wuhan
Tel: 86-27-5980-5300
Fax: 86-27-5980-5118
China - Xian
Tel: 86-29-8833-7252
Fax: 86-29-8833-7256
ASIA/PACIFIC
China - Xiamen
Tel: 86-592-2388138
Fax: 86-592-2388130
China - Zhuhai
Tel: 86-756-3210040
Fax: 86-756-3210049
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
India - Pune
Tel: 91-20-3019-1500
Japan - Osaka
Tel: 81-6-6152-7160
Fax: 81-6-6152-9310
Japan - Tokyo
Tel: 81-3-6880- 3770
Fax: 81-3-6880-3771
Korea - Daegu
Tel: 82-53-744-4301
Fax: 82-53-744-4302
Korea - Seoul
Tel: 82-2-554-7200
Fax: 82-2-558-5932 or
82-2-558-5934
Malaysia - Kuala Lumpur
Tel: 60-3-6201-9857
Fax: 60-3-6201-9859
Malaysia - Penang
Tel: 60-4-227-8870
Fax: 60-4-227-4068
Philippines - Manila
Tel: 63-2-634-9065
Fax: 63-2-634-9069
Singapore
Tel: 65-6334-8870
Fax: 65-6334-8850
Taiwan - Hsin Chu
Tel: 886-3-5778-366
Fax: 886-3-5770-955
Taiwan - Kaohsiung
Tel: 886-7-213-7828
Taiwan - Taipei
Tel: 886-2-2508-8600
Fax: 886-2-2508-0102
Thailand - Bangkok
Tel: 66-2-694-1351
Fax: 66-2-694-1350
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
Fax: 33-1-69-30-90-79
Germany - Dusseldorf
Tel: 49-2129-3766400
Germany - Munich
Tel: 49-89-627-144-0
Fax: 49-89-627-144-44
Germany - Pforzheim
Tel: 49-7231-424750
Italy - Milan
Tel: 39-0331-742611
Fax: 39-0331-466781
Italy - Venice
Tel: 39-049-7625286
Netherlands - Drunen
Tel: 31-416-690399
Fax: 31-416-690340
Poland - Warsaw
Tel: 48-22-3325737
Spain - Madrid
Tel: 34-91-708-08-90
Fax: 34-91-708-08-91
Sweden - Stockholm
Tel: 46-8-5090-4654
UK - Wokingham
Tel: 44-118-921-5800
Fax: 44-118-921-5820
Worldwide Sales and Service
01/27/15