AC Synchronous Driver

The functions in the Analog Comparator (AC) synchronous driver will block (i.e. not return) until the operation is done.

The comparison result can be get by ac_sync_get_result, if the return is not ERR_NOT_READY then it's the result of voltage comparison for two input channels.

Summary of the API's Functional Features

The API provides functions to:
  • Initialize and deinitialize the driver and associated hardware

  • Enable or disable the AC comparator

  • Start single-short comparison if signal-shot mode is enabled (no need to start for continuous sampling mode)

  • Read back the comparison result

Summary of Configuration Options

Below is a list of the main AC parameters that can be configured in START. Many of these parameters are used by the ac_sync_init function when initializing the driver and underlying hardware.
  • Select positive and negative input for the AC comparator

  • Select single shot or continuous measurement mode

  • Filter length and hysteresis setting, etc.

  • Run in Standby or Debug mode

  • Various aspects of Event control

Driver Implementation Description

After AC hardware initialization, the comparison result can be get by ac_sync_get_result. If the AC hardware is configured to single-shot mode, then ac_sync_start_comparison is needed to start conversion, otherwise the comparator is continuously enabled and performing comparisons.

Example of Usage

The following shows a simple example of using the AC. The AC must have been initialized by ac_sync_init. This initialization will configure the operation of the AC, such as input pins, single-shot, or continuous measurement mode, etc.

The example enables comparator 0 of AC, and finally starts a voltage comparison on this comparator.

          /**
           * Example of using AC_0 to compare the voltage level.
           */
          void AC_0_example(void)
          {
              int32_t cmp_result;
              ac_sync_enable(&AC_0);
              ac_sync_start_comparison(&AC_0, 0);
              while (true) {
                  cmp_result = ac_sync_get_result(&AC_0, 0);
              }
          }
        

Dependencies

  • The AC peripheral and its related I/O lines and clocks