Ejemplo n.º 1
0
void initial_opa(void) {
	OPAMP_InitTypeDef OPAMP_InitStructure;
	RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);
	//OPA1
	OPAMP_InitStructure.OPAMP_NonInvertingInput = OPAMP_NonInvertingInput_IO4;
  OPAMP_InitStructure.OPAMP_InvertingInput =  OPAMP_InvertingInput_Vout;
  OPAMP_Init(OPAMP_Selection_OPAMP1, &OPAMP_InitStructure);
	OPAMP_PGAConfig(OPAMP_Selection_OPAMP1, OPAMP_OPAMP_PGAGain_2, OPAMP_PGAConnect_No);
	//OPA2
	OPAMP_InitStructure.OPAMP_NonInvertingInput = OPAMP_NonInvertingInput_IO3;
	OPAMP_Init(OPAMP_Selection_OPAMP2, &OPAMP_InitStructure);
	OPAMP_PGAConfig(OPAMP_Selection_OPAMP2, OPAMP_OPAMP_PGAGain_2, OPAMP_PGAConnect_No);
	//OPA3
	OPAMP_InitStructure.OPAMP_NonInvertingInput = OPAMP_NonInvertingInput_IO1;
	OPAMP_Init(OPAMP_Selection_OPAMP3, &OPAMP_InitStructure);
	OPAMP_PGAConfig(OPAMP_Selection_OPAMP3, OPAMP_OPAMP_PGAGain_2, OPAMP_PGAConnect_No);
	//OPA4
	OPAMP_InitStructure.OPAMP_NonInvertingInput = OPAMP_NonInvertingInput_IO1;
	OPAMP_Init(OPAMP_Selection_OPAMP4, &OPAMP_InitStructure);
	OPAMP_PGAConfig(OPAMP_Selection_OPAMP4, OPAMP_OPAMP_PGAGain_2, OPAMP_PGAConnect_No);
	
	OPAMP_Cmd(OPAMP_Selection_OPAMP1, ENABLE);
	OPAMP_Cmd(OPAMP_Selection_OPAMP2, ENABLE);
	OPAMP_Cmd(OPAMP_Selection_OPAMP3, ENABLE);
	OPAMP_Cmd(OPAMP_Selection_OPAMP4, ENABLE);
}
Ejemplo n.º 2
0
/**
  * @brief  Configure OPAMP2
  * @param  None
  * @retval None
  */
void OPAMP_Config(void)
{
  GPIO_InitTypeDef   GPIO_InitStructure;

  /* GPIOA and GPIOB Peripheral clock enable */
  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA | RCC_AHBPeriph_GPIOB, ENABLE);

  /* Configure PB0 (OPAMP2 output) in analog mode */
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN;
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
  GPIO_Init(GPIOB, &GPIO_InitStructure);

  /* Configure PA6 (OPAMP2 positive input) and PA7 (OPAMP2 negative input) in analog mode */
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN;
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
  GPIO_Init(GPIOA, &GPIO_InitStructure);

  /* COMP Peripheral clock enable: COMP and OPAMP share the same Peripheral clock enable */
  RCC_APB1PeriphClockCmd(RCC_APB1Periph_COMP, ENABLE);

  /* Enable OPAMP2 */
  OPAMP_Cmd(OPAMP_Selection_OPAMP2, ENABLE);

  /* Close S4 and S5 swicthes */
  OPAMP_SwitchCmd(OPAMP_OPAMP2Switch4 | OPAMP_OPAMP2Switch5, ENABLE);
}
Ejemplo n.º 3
0
/**
  * @brief  OPAMP configuration.
  * @param  None
  * @retval None
  */
static void OPAMP_Config(void)
{
  GPIO_InitTypeDef   GPIO_InitStructure;
  OPAMP_InitTypeDef OPAMP_InitStructure;

  /* GPIOA Peripheral clock enable */
  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);
  
  /* Configure OPAMP1 non inverting input IO1 (PA7)
           and OPAMP1 Out (PA2) in analog mode */
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2 | GPIO_Pin_7;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN;
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ;
  GPIO_Init(GPIOA, &GPIO_InitStructure);

  /* Enable SYSCFG clock */
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);

  /* Select Vout as inverting input (internal follower) for OPAMP1 */
  OPAMP_InitStructure.OPAMP_InvertingInput = OPAMP_InvertingInput_Vout;
  /* Select IO1 (PA7) as non inverting input for OPAMP1 */
  OPAMP_InitStructure.OPAMP_NonInvertingInput = OPAMP_NonInvertingInput_IO1;
  OPAMP_Init(OPAMP_Selection_OPAMP1, &OPAMP_InitStructure);

  /* Enable OPAMP1 */
  OPAMP_Cmd(OPAMP_Selection_OPAMP1, ENABLE);
}