EFM32 ACMP模拟比较器的使用

使用EFM32 的ACMP(模拟比较器)对I/O口电压进行比较,并在边沿触发中断。

void VCMP_Initial(void)
{
/* Enable clocks required */
CMU_ClockEnable(cmuClock_GPIO, true);
CMU_ClockEnable(cmuClock_ACMP0, true);

const ACMP_Init_TypeDef acmp_init =
{
false, /* Full bias current*/
false, /* Half bias current */
7, /* Biasprog current configuration */
true, /* Enable interrupt for falling edge */
false, /* Enable interrupt for rising edge */
acmpWarmTime256, /* Warm-up time in clock cycles, >140 cycles for 10us with 14MHz */
acmpHysteresisLevel1, /* Hysteresis configuration */
0, /* Inactive comparator output value */
false, /* Enable low power mode */
(int)(2.5*63/3.5), /* Vdd reference scaling */
true, /* Enable ACMP */
};

/* Init and set ACMP channel */
ACMP_Init(ACMP0, &acmp_init);
ACMP_ChannelSet(ACMP0, acmpChannel2V5, acmpChannel0);
ACMP_IntEnable(ACMP0, ACMP_IEN_EDGE); /* Enable edge interrupt */

/* Wait for warmup */
while (!(ACMP0->STATUS & ACMP_STATUS_ACMPACT)) ;

/* Enable interrupts */
NVIC_ClearPendingIRQ(ACMP0_IRQn);
NVIC_EnableIRQ(ACMP0_IRQn);

}
extern char IsFallIntoWater;
void ACMP0_IRQHandler(void)
{
/* Clear interrupt flag */
ACMP0->IFC = ACMP_IFC_EDGE;

}

附找到比较完整的使用手册,主要有中断输出模式及IO输出模式

http://www.docin.com/p-1185078307.html

版权声明:本文为-Donny原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/-Donny/p/9069822.html