STM8L151 内部比较器COMP1怎么用?唤醒不了
如题,使用STM8L151G4U6的COMP1作为比较器检测外部输入电压是否高于内部参考1.24V的时候,在单片机没有休眠的情况下,可以正常触发中断,也可以读取比较器输出结果,但是一旦单片机进入halt();就无法中断唤醒了,又或者一直触发中断,不知道是哪里没设置好,有大神能帮忙分析下吗?下面贴出相关初始化代码:GPIO_Init(GPIOA,GPIO_Pin_5,GPIO_Mode_In_FL_No_IT);
static void COMP_Config(void)
{
CLK_PeripheralClockConfig(CLK_Peripheral_COMP, ENABLE);
/* Connect internal reference voltage to COMP1 inverting input */
COMP_VrefintToCOMP1Connect(ENABLE);
/* close the analog switch number 0 */
SYSCFG_RIAnalogSwitchConfig(RI_AnalogSwitch_0, ENABLE);
/* close the analog switch number 1 */
SYSCFG_RIAnalogSwitchConfig(RI_AnalogSwitch_14, ENABLE);
/* close the I/O switch number 2 */
SYSCFG_RIIOSwitchConfig(RI_IOSwitch_2, ENABLE);// PA5
COMP_EdgeConfig(COMP_Selection_COMP1, COMP_Edge_Rising);
/* Enable COMP1 Interrupt */
COMP_ITConfig(COMP_Selection_COMP1, ENABLE);
/* Configure the event detection */
}
INTERRUPT_HANDLER(ADC1_COMP_IRQHandler,18)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
COMP_ClearITPendingBit(COMP_Selection_COMP1);
}
回复 编辑 支持 反对评分
返回列表https://www.stmcu.org.cn/module/forum/static/image/common/pn_post.pnghttps://www.stmcu.org.cn/module/forum/static/image/common/pn_reply.png
https://www.stmcu.org.cn/module/forum/uc_server/avatar.php?uid=2117415&size=middle
https://www.stmcu.org.cn/module/forum/static/image/smiley/default/smile.gifhttps://www.stmcu.org.cn/module/forum/static/image/smiley/default/sad.gifhttps://www.stmcu.org.cn/module/forum/static/image/smiley/default/biggrin.gifhttps://www.stmcu.org.cn/module/forum/static/image/smiley/default/cry.gif
https://www.stmcu.org.cn/module/forum/static/image/smiley/default/huffy.gifhttps://www.stmcu.org.cn/module/forum/static/image/smiley/default/shocked.gifhttps://www.stmcu.org.cn/module/forum/static/image/smiley/default/tongue.gifhttps://www.stmcu.org.cn/module/forum/static/image/smiley/default/shy.gif
https://www.stmcu.org.cn/module/forum/static/image/smiley/default/titter.gifhttps://www.stmcu.org.cn/module/forum/static/image/smiley/default/sweat.gifhttps://www.stmcu.org.cn/module/forum/static/image/smiley/default/mad.gifhttps://www.stmcu.org.cn/module/forum/static/image/smiley/default/lol.gif
https://www.stmcu.org.cn/module/forum/static/image/smiley/default/loveliness.gifhttps://www.stmcu.org.cn/module/forum/static/image/smiley/default/funk.gifhttps://www.stmcu.org.cn/module/forum/static/image/smiley/default/curse.gifhttps://www.stmcu.org.cn/module/forum/static/image/smiley/default/dizzy.gif
高级模式BColorImageLinkQuoteCodeSmilies@朋友|
本版积分规则发表回复 回帖后跳转到最后一页
https://www.stmcu.org.cn/module/forum/source/plugin/are_problem/statics/img/url.png关于ST ST使用说明 FAQ 法律及版权声明 网站地图 Archiver
Email: stmcu@eefocus.com Tel: 0512-80981663-8064 备案号: 沪ICP备12005910号-3
页:
[1]