/**
  @page COMP_PulseWidthMeasurement COMP1 Pulse width measurement example
  
  @verbatim
  ******************** (C) COPYRIGHT 2015 STMicroelectronics *******************
  * @file    COMP/COMP_PulseWidthMeasurement/readme.txt 
  * @author  MCD Application Team
  * @version V1.1.3
  * @date    15-December-2021
  * @brief   Description of the COMP1 Pulse width measurement example.
  ******************************************************************************
  *
  * Copyright (c) 2015 STMicroelectronics.
  * All rights reserved.
  *
  * This software is licensed under terms that can be found in the LICENSE file
  * in the root directory of this software component.
  * If no LICENSE file comes with this software, it is provided AS-IS.
  *
  ******************************************************************************
   @endverbatim

@par Example Description 

This example shows how to configure the COMP1 peripheral to measure pulse width.
This method (measuring signal pulse using comparator is interesting when
external signal doesn't respect the VIL and VIH levels).

  - COMP1 is configured as following:
     - Inverting input is internally connected to DAC1 output
     - Non Inverting input is connected to PA1
     - Output is internally connected to TIM2 Input Capture 4 (IC4)

  - DAC channel 1 is used as a digital threshold for measurement, DAC1 output
    is internally connected to COMP1 inverting input. 
    DAC1 is configured in 12-bit right alignment. DAC1 output = VREF * DOR / 4095
                                                               = 3.3 * 2000 / 4095
                                                               = 1.61V

    In this example, the pulse of an external signal of around 1.6V 
    (e.g. high level = 1.7V and low level = 1.5V) can be performed.

  - TIM2 counter is clocked by TIM2CLK = 72MHz, TIM2 channel 4 is configured in
    input capture mode.
    TIM2 counter is captured at each transition detection: rising or falling edges
    (each time COMP1 inverting input crosses DAC1 output)

  - External signal should be connected to PA1. 
    Pulse is computed in microsecond then displayed on Color LCD 
    for STM32303C-EVAL.
    Pulse duration shouldn't be higher than 65535 * TIM2CLK = 0.910 ms
    Pulse duration shouldn't be lower than TIM2 ISR processing time / TIM2CLK 
                                         ~ 110 (clock cycle) / 72 MHz = 1.5 us
 

@par Directory contents 

  - COMP/COMP_PulseWidthMeasurement/stm32f30x_conf.h    Library Configuration file
  - COMP/COMP_PulseWidthMeasurement/stm32f30x_it.c      Interrupt handlers
  - COMP/COMP_PulseWidthMeasurement/stm32f30x_it.h      Interrupt handlers header file
  - COMP/COMP_PulseWidthMeasurement/main.c              Main program
  - COMP/COMP_PulseWidthMeasurement/system_stm32f30x.c  STM32F30x system source file
  
@note The "system_stm32f30x.c" is generated by an automatic clock configuration 
      system and can be easily customized to your own configuration. 
      To select different clock setup, use the "STM32F30x_Clock_Configuration_V1.0.0.xls" 
      provided with the AN4152 package available on <a href="http://www.st.com/internet/mcu/family/141.jsp">  ST Microcontrollers </a>
         
@par Hardware and Software environment

  - This example runs on STM32F303xC and STM32F303xE Devices.
  
  - This example has been tested with STMicroelectronics STM32303C-EVAL (STM32F30x)
    evaluation board and can be easily tailored to any other supported device 
    and development board.

  - STM32303C-EVAL Set-up
    - Connect an external signal to PA.01 pin.

@par How to use it ? 

In order to make the program work, you must do the following :
 - Copy all source files from this example folder to the template folder under
   Projects\STM32F30x_StdPeriph_Templates
 - Open your preferred toolchain 
 - Add the following files to the project source list
    - Utilities\STM32_EVAL\STM32303C_EVAL\stm32303c_eval_lcd.c
 - Rebuild all files and load your image into target memory
 - Run the example
    

 */
