/**
  @page OPAMP_TimerControlledMux OPAMP in timer controlled mux example
  
  @verbatim
  ******************** (C) COPYRIGHT 2015 STMicroelectronics *******************
  * @file    OPAMP/OPAMP_TimerControlledMux/readme.txt 
  * @author  MCD Application Team
  * @version V1.1.3
  * @date    15-December-2021
  * @brief   Description of OPMAP1 in timer-controlled multiplexer 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 OPAMP1 peripheral in timer-controlled multiplexer.
In this mode, the selection of OPAMP inverting and non inverting inputs can be
done automatically. This automatic switch is triggered by the TIM1 OC6 output.

OPAMP1 is configured as following:
   - Inverting input is connected to PC5
   - Non Inverting input is connected to PA7 (default) and to PA5 (secondary) 
   - Output is available on PA2 (ADC1 channel 3)
   - Timer-controlled multiplxer is enabled: TIM1 OC6 state selects either
     default non-inverting input (PA7) or secondary non-inverting input (PA5)

TIM1 is configured in center-aligned mode 3: The counter counts up and down
alternatively. Output compare event is set when the counter is counting up or down.
TIM1 Time Base is configured at APB2 clock / ((prescaler+1) * period) 
= 72000000 / (20 * 65535) = 54 Hz
So an update event is generated every 18.5 ms. This event is used as trigger source
for ADC conversion (ADC conversion is performed every 18.5 ms).
TIM1 channel 6 (OC6) is configured in PWM mode with duty cycle set to
pulse / period = 100 * (32767 / 65535) =  50%
At compare event of TIM1 channel 6 (OC6), the OPAMP1 non Inverting input is switched
from PA7 to PA5 and vice versa.

The Analog to Digital Converter is used to convert voltage applied on OPAMP1
output (PA2). The ADC conversion is triggered by update event coming from TIM1.
The end of conversion interrupt is enabled and digital conversions are
stored in ADCVal[] array.

In order to test this example, follow these steps:
- Connect the OPAMP1 inverting input (PC5) to OPAMP1 output (PA2) to create an
  external follower
- Connect an external signal to the default non-inverting input (PA7)
- Connect another external signal to the secondary non-inverting input (PA5)

As OPAMP1 is configured in external follower, the first conversion value ADCVal[0]
should correspond to the voltage applied on default non-inverting input (PA7) and
the second one should correspond to the voltage applied on the secondary non-inverting
input (PA5).

@par Directory contents 

  - OPAMP/OPAMP_TimerControlledMux/stm32f30x_conf.h    Library Configuration file
  - OPAMP/OPAMP_TimerControlledMux/stm32f30x_it.c      Interrupt handlers
  - OPAMP/OPAMP_TimerControlledMux/stm32f30x_it.h      Interrupt handlers header file
  - OPAMP/OPAMP_TimerControlledMux/main.c              Main program
  - OPAMP/OPAMP_TimerControlledMux/main.h              Main Header file
  - OPAMP/OPAMP_TimerControlledMux/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.

@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 
 - Rebuild all files and load your image into target memory
 - Run the example
    

 */
