比较器COMP的输出,按照手册里的说明,可以从某个IO输出,可是测试未能功能,不知哪位高手经历过??请指导
1、GPIO Config
sta
tic void COMP1_OUT_GPIO_Init(void)
{
GPIO_InitTypeDef GPIO_InitStruct;
/* Configure PA.11 as COMP1 output */
GPIO_InitStruct.GPIO_Pin = GPIO_Pin_11;
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF; //¸´Óù¦ÄÜģʽ
GPIO_InitStruct.GPIO_OType = GPIO_OType_PP;
GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOA, &GPIO_InitStruct);
/* COMP_1 OUT to GPIO Config */
GPIO_PinAFConfig(GPIOA,GPIO_PinSource11,GPIO_AF_7); //PA.00¸´Óù¦ÄÜ - COMP_1 OUT
}
2、Comp1 config
COMP_StructInit(&COMP_InitStructure);
COMP_InitStructure.COMP_InvertingInput = COMP_InvertingInput_IO; //±È½ÏÆ÷¸º¼«£º PA.00(to GND) COMP_InvertingInput_IO COMP_InvertingInput_1_4VREFINT
COMP_InitStructure.COMP_Output = COMP_Output_TIM2IC4; //TIM2IC4
// COMP_InitStructure.COMP_Output = COMP_Output_None; // IO output NG
COMP_InitStructure.COMP_OutputPol = COMP_OutputPol_NonInverted; //Êä³öͬÏò COMP_OutputPol_Inverted / COMP_OutputPol_NonInverted
COMP_InitStructure.COMP_Hysteresis = COMP_Hysteresis_Low; //ÎÞ³ÙÖÍ COMP_Hysteresis_Low
COMP_InitStructure.COMP_Mode = COMP_Mode_HighSpeed; //ËÙÂʺÍËðºÄ¸ß
COMP_Init(COMP_Selection_COMP1, &COMP_InitStructure);
COMP_Cmd(COMP_Selection_COMP1, ENABLE); //ʹÄÜ COMP1
一周热门 更多>