4535 views|7 replies

4

Posts

0

Resources
The OP
 

Applying MQ2 on STM32 [Copy link]

void Mq2_Init(void) { GPIO_InitTypeDef GPIO_InitStruct; EXTI_InitTypeDef EXTI_InitStruct; NVIC_InitTypeDef NVIC_InitStruct; RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB,ENABLE); RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO,ENABLE); GPIO_EXTILineConfig(GPIO_PortSourceGPIOB,GPIO_PinSource2); GPIO_InitStruct.GPIO_Mode=GPIO_Mode_IPD; GPIO_InitStruct.GPIO_Pin=GPIO_Pin_2; GPIO_InitStruct.GPIO_Speed=GPIO_Speed_50MHz; GPIO_Init(GPIO,&GPIO_InitStruct); GPIO_SetBits(GPIOB,GPIO_Pin_2); NVIC_InitStruct.NVIC_IRQChannel=TIM2_IRQn; NVIC_InitStruct.NVIC_IRQChannelCmd=ENABLE; NVIC_InitStruct.NVIC_IRQChannelPreemptionPriority=2; NVIC_InitStruct.NVIC_IRQChannelSubPriority=2; NVIC_Init(&NVIC_InitStruct); EXTI_ClearITPendingBit(EXTI_Line2); EXTI_InitStruct.EXTI_Line=EXTI_Line2; EXTI_InitStruct.EXTI_LineCmd=ENABLE; EXTI_InitStruct.EXTI_Mode=EXTI_Mode_Interrupt; EXTI_InitStruct.EXTI_Trigger=EXTI_Trigger_Falling; EXTI_Init(&EXTI_InitStruct); } void EXTI2_IRQHandler(void) { delay_ms(10); PCout(2)=0; LED0=!LED0; delay_ms(500); LED0=!LED0; printf("dangerous\r\n"); EXTI_ClearITPendingBit(EXTI_Line2); } MQ2 is working normally, STM32 is not working properly?




This post is from stm32/stm8

Latest reply

If the interrupt is OK, then look at the sensor. Maybe it is a sensor problem.   Details Published on 2017-12-21 17:23
 

3471

Posts

11

Resources
2
 
Why is STM32 not responding? What does it mean? Is it an interrupt or something else? You can refer to the official routine.
This post is from stm32/stm8
 
 

4

Posts

0

Resources
3
 
ienglgge posted on 2017-12-13 09:57 Why is STM32 not responding? What does it mean? Is it interrupted or something else? You can refer to the official examples.
It is not possible to enter the interrupt. What is the problem?
This post is from stm32/stm8

Comments

If you are detecting the falling edge, then the GPIO should be set to IPU (input pull-up)  Details Published on 2017-12-13 17:01
 
 

466

Posts

0

Resources
4
 
The seventh chapter of Night was published on 2017-12-13 15:33 It is not possible to enter the interrupt, what is the problem?
You are detecting the falling edge, so the GPIO should be set to IPU (input pull-up)
This post is from stm32/stm8
 
 
 

4

Posts

0

Resources
5
 
weizhongc posted on 2017-12-13 17:01 You are detecting the falling edge, so the GPIO should be set to IPU (input pull-up)
It still doesn't work
This post is from stm32/stm8
 
 
 

4

Posts

0

Resources
6
 
weizhongc posted on 2017-12-13 17:01 You are detecting the falling edge, so the GPIO should be set to IPU (input pull-up)
MQ2 detects smoke and outputs a low level
This post is from stm32/stm8

Comments

Then don't connect your PIN to the module yet, try giving it a low level yourself, or use tweezers to short it to the ground.  Details Published on 2017-12-21 17:23
Then don't connect your PIN to the module yet, try giving it a low level yourself, or use tweezers to short it to the ground.  Details Published on 2017-12-21 17:23
 
 
 

466

Posts

0

Resources
7
 
The seventh chapter of Night was published on 2017-12-17 22:35 MQ2 detects smoke and outputs a low level
Then don't connect the PIN to the module first, give it a low level yourself, or use tweezers to short it to the ground and try.
This post is from stm32/stm8
 
 
 

466

Posts

0

Resources
8
 
The seventh chapter of Night was published on 2017-12-17 22:35 MQ2 detects smoke and outputs a low level
If the interrupt is OK, then look at the sensor. Maybe it is a sensor problem.
This post is from stm32/stm8
 
 
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list