使用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);<