CAT2 Peripheral Driver Library
MSC (Multi-Sense Converter)

The MSC HW block represents the devices of the fifth CAPSENSE™ generation. More...

Modules

 Macros
 
 Functions
 
 Data Structures
 
 Enumerated Types
 

Detailed Description

The MSC HW block represents the devices of the fifth CAPSENSE™ generation.

It enables multiple sensing capabilities on PSOC™ devices, including self-cap and mutual-cap capacitive touch-sense solutions.

The CAPSENSE™ solution includes:

capsense_solution_msc.png
CAPSENSE™ Solution

This section describes only the MSC driver. Refer to the corresponding sections for documentation of middleware supported by the MSC HW block.

The MSC driver is a low-level peripheral driver that provides an interface to a complex mixed signal of the MSC HW block.

The MSC driver alone does not provide system-level functions. Instead, it is used by upper-level middleware to configure the MSC HW block required by an application.

The MSC HW block can support only one function at a time. To allow seamless time-multiplex implementation of functionality and to avoid conflicting access to hardware from the upper level, the MSC driver also implements a lock semaphore mechanism.

The MSC driver supports re-entrance. If a device contains several MSC HW blocks, the same MSC driver is used to configure any HW block. For that, each function of the MSC driver contains a base address to define the MSC HW block to which the MSC driver communicates.

There is no restriction on the MSC Driver usage in RTOS.

Usage

The MSC driver is a simple wrapper driver specifically designed to be used by higher level middleware. Hence, is highly not recommended to use the MSC driver directly in the application program. To incorporate MSC HW block functionality in the application program, an associated middleware should be used.

The MSC Driver can be used to implement a custom sensing solution. In such a case, the application program must acquire and lock the MSC HW block prior to accessing it.

Setting up and using the MSC driver can be summed up in these four stages:

The following code snippet demonstrates how to capture the MSC HW block for custom implementation:

/*
* Scenario: Need to capture MSC HW block to perform a conversion.
* This scenario does not cover Pins, Clock, Interrupt, configuration.
*/
/*...*/
/* Allocate MSC configuration structure and initialize it with user's configuration */
const cy_stc_msc_base_config_t customConfig = CUSTOM_CONFIG;
/* Check if the MSC block if free */
key = Cy_MSC_GetLockStatus(MSC0, &mscContext);
if (CY_MSC_NONE_KEY == key)
{
/* Capture the MSC block and initialize it with user's configuration */
status = Cy_MSC_Init(MSC0, &customConfig, CY_MSC_USER_DEFINED_KEY, &mscContext);
/* Check if the MSC block was captured successfully */
if (CY_MSC_SUCCESS == status)
{
/* Block is captured successfully. User's application code can be placed and executed here. */
}
}
/*...*/
Note
User's application code should follow these recommendations:
  1. The last sensor configuration in the frame should have the LAST bit of SNS_CTL register set.
  2. The START_FRAME bit of FRAME_CMD register should be set prior to calling the Cy_MSC_ConfigureScan() API. It should be set once per frame if the frame contains multiple sensor configurations, and each frame if the frame contains only one sensor configuration.
  3. The START_SCAN bit of SNS_CTL register should be set in the sensor frame to start the conversion.

The entire solution, like CAPSENSE™, in addition to the MSC HW block, incorporates the following instances:

The MSC driver does not configure those blocks and they should be managed by an upper level. When using CAPSENSE™, those blocks are managed by the middleware.

Clocks

The MSC HW block requires a peripheral clock (clk_peri) input. It can be assigned using two methods:

GPIO Pins

CAPSENSE™ provides the ability to form a user interface using widgets. Each widget consists of one or more sensors. These sensors are connected to the GPIO pins.

The MSC HW block supports two types of the connection GPIO pin-to-block:

  1. Through analog buses.

This is a legacy connection through an analog multiplexed bus (AMUXBUS) available in previous generations of CAPSENSE™ devices.

Any analog-capable GPIO pin that can be connected to an analog multiplexed bus (AMUXBUS) can be connected to the MSC HW block as an input / sensor.

A GPIO input can be assigned to the MSC HW block using the following methods:

If middleware is used, pin configuration is managed by the middleware. Under the MSC driver custom implementation, the application program must manage the pin connections.

Each AMUXBUS can be split into multiple segments. Ensure that the MSC HW block and a GPIO belong to the same bus segment or join the segments to establish the connection GPIO-to-MSC HW block.

For more information about pin configuration, refer to the GPIO (General Purpose Input Output) driver.

  1. With a direct pin-to-block wire.

The enhanced direct HW-wire connection pin-to-MSC HW block is available in the devices of the fifth generation CAPSENSE™.

Only dedicated pins can be used for such a type of connection. Refer to the device datasheet for the exact pin definition.

A GPIO input can be assigned to the MSC HW block only by proper configuration of the MSC HW block. If middleware is used, pin configuration is managed by the middleware.

Under the MSC driver custom implementation, the application program must manage the pin connections.

The advantages of this type of a connection under the CAPSENSE™ MW usage are the following:

Interrupts

The MSC HW block has one interrupt. The MSC HW block can generate interrupts on the following events:

Additionally, the MSC interrupt can wake the device from the Sleep power mode. The MSC HW block is powered down in the Deep Sleep power mode. So, it cannot be used as a wake-up source in this power mode.

If a CAPSENSE™ is used, the interrupt service routine is managed by middleware. When using the MSC driver for custom implementation or other middleware, the application program must manage the interrupt service routine.

Implement an interrupt routine and assign it to the MSC interrupt. Use the pre-defined enumeration as the interrupt source of the MSC HW block. The MSC interrupt to the NVIC is raised any time the intersection (logic AND) of the interrupt flags and the corresponding interrupt masks are non-zero. The peripheral interrupt status register should be read in the ISR to detect which condition generated the interrupt. The appropriate interrupt registers should be cleared so that subsequent interrupts can be handled.

The following code snippet demonstrates how to implement a routine to handle the interrupt. The routine is called when a MSC interrupt is triggered.

void snippet_Cy_MSC_IntHandler(void)
{
uint32_t intrStatus;
/* Read interrupt status register */
/* Check an event that triggered the interrupt */
if ((intrStatus & MSC_INTR_SET_SCAN_Msk) == MSC_INTR_SET_SCAN_Msk)
{
/* End of scan occurred, get the result and do something with it here */
}
/* Clear pending interrupt */
}

The following code snippet demonstrates how to configure and enable the MSC interrupt:

const cy_stc_sysint_t MSC0_ISR_cfg =
{
.intrSrc = msc_0_interrupt_IRQn, /* Interrupt source is the MSC interrupt */
.intrPriority = 3u, /* Interrupt priority is 3 */
};
/* Configure the interrupt with vector at snippet_Cy_MSC_IntHandler() */
(void)Cy_SysInt_Init(&MSC0_ISR_cfg, snippet_Cy_MSC_IntHandler);
/* Enable the interrupt */
NVIC_EnableIRQ(MSC0_ISR_cfg.intrSrc);
/* Enable the MSC SCAN interrupt mask */
Cy_MSC_WriteReg(MSC0, CY_MSC_REG_OFFSET_INTR_MASK, MSC_INTR_MASK_SCAN_Msk);

For more information, refer to the SysInt (System Interrupt) driver.

Alternatively, instead of handling the interrupts, the Cy_MSC_GetConversionStatus() function allows for firmware polling of the MSC block status.

Power Modes

The MSC HW block can operate in Active and Sleep CPU power modes. It is also possible to switch between Low power and Ultra Low power system modes. In Deep Sleep power mode, the MSC HW block is powered off. When the device wakes up from Deep Sleep, the MSC HW block resumes operation without the need for re-initialization.

Note
  1. The MSC driver does not provide a callback function to facilitate the low-power mode transitions. The responsibility belongs to an upper level that uses the MSC HW block to ensure the MSC HW block is not busy prior to a power mode transition.
  2. A power mode transition is not recommended while the MSC HW block is busy. The MSC HW block status must be checked using the Cy_MSC_GetStatus() function prior to a power mode transition. Instead, use the same power mode for active operation of the MSC HW block. This restriction is not applicable to Sleep mode and the device can seamlessly enter and exit Sleep mode while the MSC HW block is busy.
Warning
  1. Do not enter Deep Sleep power mode if the MSC HW block conversion is in progress. Unexpected behavior may occur.
  2. The MSC HW block initializes in several microseconds after Power on / Deep Sleep exit. Refer to the technical reference manual (TRM) and the device datasheet for the exact number.

Refer to the SysPm (System Power Management) driver for more information about low-power mode transitions.

More Information

Important information about the CAPSENSE™ technology overview, appropriate Infineon device for the design, CAPSENSE™ system and sensor design guidelines, different interfaces and tuning guidelines necessary for a successful design of a CAPSENSE™ system is available in the Getting Started with CAPSENSE™ document and the product-specific CAPSENSE™ design guide. Infineon highly recommends starting with these documents. They can be found on the Infineon web site at www.infineon.com

For more information, refer to the following documents:

Note
The links to another software component's documentation (middleware and PDL) point to GitHub to the latest available version of the software. To get documentation of the specified version, download from GitHub and unzip the component archive. The documentation is available in the docs folder.

Changelog

VersionChangesReason for Change
1.10.2 Minor documentation updates Documentation improvement
1.10.1 Update the paths to the code snippets PDL structure update
1.10 Added Cy_MSC_Capture() function CAPSENSE™ memory consumption optimization
1.0 The initial version