This Application note explains the implementation of a pulse
oximeter which communicates with a computer using the USB
Personal Healthcare Device Class. Implementation is done on
the Freescale MK53N512 Kinetis microcontroller, but can be
implemented on any Freescale USB capable microcontroller.
This Application note is intended for medical solutions
developers, biomedical engineers or any person interested on
the USB personal healthcare device class. Nevertheless, some
skills in C programming and microcontrollers handling are
required.
This Application note is closely related with the application
note “AN4327 Pulse Oximeter Fundamentals and Design”. It
is recommended to read AN4327 for better understanding.
2Personal Healthcare Device
Class Overview
Universal Serial Bus (USB) is a standard which defines
hardware and protocols for intercommunication between a
host (usually a PC) and one or more devices. Each USB
device has its own purpose, and therefore, they are divided in
different classes according to their function. One example is
the Human Interface Device (HID) class which is used in
devices like computer keyboards and mouse.
Personal Healthcare Device Class (PHDC) defines the requirements to establish communication and seamless interoperability
between personal USB medical devices and USB hosts, to be then processed, stored or transmitted to a doctor or relative via
internet.
USB PHDC is used by healthcare exchange protocols like ISO/IEEE 11073-20601 as the transportation method for the
communication packets between the host and the personal healthcare device. It standardizes the way in which the data and
messages are sent over USB.
3Pulse Oximeter Implementation
Pulse Oximeter is implemented using Freescale TWR-K53N512, a tower development board including the medical oriented
microcontroller MK53N512, MED-SPO2 an analog front end board for pulse oximetry solutions development and TWRSER a tower system board for designs including serial communications. This is the same hardware used in AN4327 “Pulse
Oximeter Fundamentals and Design”. Please refer to this application note for more information about pulse oximetry
principles and the hardware used in the pulse oximeter development.
System is based on the Freescale USB stack with PHDC which is free code for developing solutions that require USB
connectivity and can be downloaded from the Freescale web page. This stack contains functions that can be used at device
level (configure clocks, initialize USB module, etc…) and the class level (send-receive packets, send descriptors, etc…).
Please refer to Freescale USB Stack with PHDC Stack Users Guide and Freescale USB Stack with PHDC Device API
Reference Manual for better understanding.
Software is basically divided in three main parts: System Initialization, Application Initialization and Application Execution.
Final application is executed in an infinite loop as shown in the following flow diagram (Figure 1).
Figure 1. Software model flow diagram
Pulse Oximeter Using USB PHDC, Rev. 0, 03/2012
2Freescale Semiconductor, Inc.
Pulse Oximeter Implementation
For a better understanding of this chapter, it is highly recommended to open the MED-SPO2 PDHC C project and view it as
you read these lines.
3.1System Initialization
System initialization is executed when the function Init_Sys is called at the beginning of the program. Init_Sys is a device
level function and varies upon the microcontroller. It initializes the required peripherals on the microcontroller for the stack
functionality. Init_Sys first enables the interrupts on the USB module configuring the NVICICER2 and NVICISER2
registers. Then it enables the GPIO modules required by the microcontroller calling the function GPIO_Init. Init_Sys now
calls pll_init function which configures the microcontroller for working at 50MHz using an external clock source. Once the
microcontroller’s clock has been configured, MPU_CESR register is cleared and microcontroller is configured to energize
and bring clock signal to USB module for future enumeration.
3.2Application Initialization
Application initialization configures the previously initialized modules for use of the pulse oximetry PHDC application. This
configuration starts when the function TestApp_Init is called. TestApp_Init first calls the function PHD_Transport_Init. This
function manages the enumeration of the microcontroller’s USB module as PHDC by enabling the Pull-Up resistors and
handling the enumeration process. PHD_Transport_Init returns an error value. If error “OK” is returned it means that the
device has been already enumerated as a PHD (Personal Healthcare Device) otherwise something went wrong during the
enumeration and device might not be recognized by the host PC. At this point, the device is recognized by the host as a PHD
but it is not defined yet as a pulse oximeter device using the standard ISO/IEEE 11073-20601.
After enumeration, TWR-K53N512 on-board LEDs and push buttons are configured for future use. SwTimer_Init function is
called for initializing the software timer. More information about the software timer can be found on the application note
“AN4327 Pulse Oximeter Fundamentals and Design”: Appendix A Software Timer.
The last function called is vfnSpO2_AFE_Init. This function initializes the required peripherals (OpAmps, TRIAMPs, ADCs
and timers) required by the MED-SPO2 board.
3.3Application Execution
Once the peripherals have been configured, a connection between the host PC and the device is established. Host PC
recognizes the device as a PHD but it is not fully functional yet. A communication protocol between the host PC and the
device is required in order to exchange the information in a standardized and reliable manner.
Several communication protocols exist, including some vendor specific protocols. Nevertheless, engineering bets on
standardized protocols that ensure same interoperability between medical devices.
Continua Health Alliance® is an organization that promotes the enhanced interoperability among medical devices. The
implementation of this demo is based on the Continua® standard for health data communication between host PC and device
which uses the standard ISO/IEEE 11073-20601 “Personal health device communication: Optimized exchange protocol” as a
base.
A brief explanation of the 11073-20601 communication protocol is shown below. For a complete explanation of the
communication protocol refer to the ISO/IEEE 11073-20601 standard.
3.3.1ISO/IEEE 11073-20601 communication process
The standard 11073-20601 defines the communication protocol between medical devices or “Agents” and hosts or
“Managers”.
Pulse Oximeter Using USB PHDC, Rev. 0, 03/2012
Freescale Semiconductor, Inc.3
Pulse Oximeter Implementation
The Agent can be defined as a set of objects called MDS (Medical Device System). Each MDS describes a behavior of the
agent (e.g. pulse oximeter or blood pressure monitor). Each Agent can contain one or more of these MDS objects.
In the same manner, each MDS object contains sub-objects that define its behavior (e.g. measurements to report). All this
information must be reported to the Manager so it can control the behavior of the Agent. Nevertheless only one MDS object
must be reported at a time (e.g. an Agent cannot be a pulse oximeter and a blood pressure monitor at the same time).
Following diagram represents an Agent capable of being a pulse oximeter and a blood pressure monitor).
Figure 2. Agent representation
In the case of this demo, the Agent contains only one MDS object corresponding to the pulse oximeter application. More
detailed information about the Agent representation can be found on the ISO/IEEE 11073-20601:2010 document, in the
chapter 6, Personal health device DIM.
IEEE standard defines a state machine for the Agents and other state machine for the Managers. Since our demo application
is a device, we will only explain the Agent’s state machine. Following diagram is a simplified representation of the state
machine shown in the Chapter 8, Figure 10 of the ISO/IEEE 11073-20601:2010 standard.
Pulse Oximeter Using USB PHDC, Rev. 0, 03/2012
4Freescale Semiconductor, Inc.
Pulse Oximeter Implementation
Figure 3. Agent's state machine
At the beginning, the Agent is disconnected from the Manager. Agent must be connected to the manager in order to establish
a communication. When the connection has been established (in our case when the USB device has been enumerated as
PHDC device) the Agent passes to be in a connected state.
Once connected, the Agent is initially in an “Unassociated” state. The Agent must send an “Association Request” to start
communications. Association request is sent as an APDU (application protocol data unit), a data packet containing the
required information to start the association and it must correspond to the MDS object to associate. The association request
APDU must look like the following.
When the Agent sends the association request, it goes to the “Associating” state waiting for response from the Manager. The
Manager will process the association request and send the Association Response according with the APDU received. If the
APDU corresponds to an already known MDS, the Manager will send an “Accepted” association response indicating that the
configuration is already known, and then the Agent must transition to the Operating state. If the association request is
accepted but the Manager does not recognize the MDS, it will send back an “accepted-unknown-config” association response
asking to the Agent for the MDS configuration. If the association request is rejected, the Agent must transition to the
Unassociated state and try again. A Manager’s association response looks like the following.
Either if the Agent receives an accepted or accepted-unknown-config association response, the Agent must transition to the
“Associated” state. In this case, the Manager accepted the association request, but it did not recognize the MDS returning an
accepted-unknown-config association response. As a result of this, Agent must send a Configuration Report like the
following.