Microchip® Advanced Software Framework

Quickstart guide for SAM FREQM driver

This is the quickstart guide for the SAM FREQM driver, with step-by-step instructions on how to configure and use the driver in a selection of use cases.

The use cases contain several code fragments. The code fragments in the steps for setup can be copied into a custom initialization function, while the steps for usage can be copied into, e.g., the main application function.

Basic use case

In this basic use case, the FREQM module are configured for:

  • Select CLK32K as refclk
  • Select CLK_CPU as msrclk.
  • Duration of a measurement is 128

Prerequisites

  1. System Clock Management (Sysclock)

Setup steps

Example code

Add to application C-file:

Workflow

  1. Initializes Frequency Meter configuration structure to defaults:
  2. Configure FREQM line with specified mode:
    • freqm_set_configure(FREQM, 1, 0, 128);
  3. Start Measurement.
  4. Get measurement result:
    cpu_clk = (freqm_get_result_blocking(FREQM) / 128) * 32768;