Microchip® Advanced Software Framework

Quick Start Guide for TSENS - Basic

In this use case, the TSENS will be configured with the following settings:

  • GCLK generator 0 (GCLK main) clock source
  • Free running disabled
  • Run in standby
  • Window monitor disabled
  • All events (input and generation) disabled
  • Calibration value which read from NVM or user set

Setup

Prerequisites

There are no special setup requirements for this use-case.

Copy-paste the following setup code to your user application:

void configure_tsens(void)
{
struct tsens_config config_tsens;
tsens_get_config_defaults(&config_tsens);
tsens_init(&config_tsens);
}

Add to user application initialization (typically the start of main()):

configure_tsens();

Workflow

  1. Configure the TSENS module.
    1. Create a TSENS module configuration struct, which can be filled out to adjust the configuration of a physical TSENS peripheral.
      struct tsens_config config_tsens;
    2. Initialize the TSENS configuration struct with the module's default values.
      tsens_get_config_defaults(&config_tsens);
      Note
      This should always be performed before using the configuration struct to ensure that all values are initialized to known default settings.
    3. Set TSENS configurations.
      tsens_init(&config_tsens);
    4. Enable the TSENS module so that conversions can be made.

Use Case

Code

Copy-paste the following code to your user application:

int32_t result;
do {
/* Wait for conversion to be done and read out result */
} while (tsens_read(&result) != STATUS_OK);
while (1) {
/* Infinite loop */
}

Workflow

  1. Start conversion.
  2. Wait until conversion is done and read result.
    int32_t result;
    do {
    /* Wait for conversion to be done and read out result */
    } while (tsens_read(&result) != STATUS_OK);
  3. Enter an infinite loop once the conversion is complete.
    while (1) {
    /* Infinite loop */
    }