2015-12-15 01:05 AM
I'm using STM32F4 Discovery. I configured a GPIO pin PB8 for external interupt for both rising and falling edges, so that I have to reset a flag when it is high->low or set when low->high which is done by reading the status of the Pin in the ISR.
But I'm getting the status of the pin is low always when I read status using function GPIO_ReadInputDataBit, here is my code(flag value is always low/reset). What am I doing wrong here ? Note: I ensured the logic levels on pin using DSO and my ISR is getting hit on rising/falling edge but the status of that pin is always read lowbool
test =
false
;
void
Init_Sleep_Detect(
void
)
{
/* Set variables used */
GPIO_InitTypeDef GPIO_InitStruct;
EXTI_InitTypeDef EXTI_InitStruct;
NVIC_InitTypeDef NVIC_InitStruct;
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IN;
GPIO_InitStruct.GPIO_OType = GPIO_OType_PP;
GPIO_InitStruct.GPIO_Pin = GPIO_Pin_8;
GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_InitStruct.GPIO_Speed = GPIO_Speed_100MHz;
GPIO_Init(GPIOB, &GPIO_InitStruct);
SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOB, EXTI_PinSource8);
EXTI_InitStruct.EXTI_Line = EXTI_Line8;
EXTI_InitStruct.EXTI_LineCmd = ENABLE;
EXTI_InitStruct.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStruct.EXTI_Trigger = EXTI_Trigger_Rising_Falling;
EXTI_Init(&EXTI_InitStruct);
NVIC_InitStruct.NVIC_IRQChannel = EXTI9_5_IRQn;
NVIC_InitStruct.NVIC_IRQChannelPreemptionPriority = 0x00;
NVIC_InitStruct.NVIC_IRQChannelSubPriority = 0x00;
NVIC_InitStruct.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStruct);
}
void
EXTI9_5_IRQHandler(
void
)
{
if
(EXTI_GetITStatus(EXTI_Line8) != RESET)
{
/* Clear the EXTI line 0 pending bit */
EXTI_ClearITPendingBit(EXTI_Line8);
if
(GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_8))
{
test=
true
;
}
else
{
test=
false
;
}
}
}
#stm32f4 #discovery #exti #stm32f4-disco
2015-12-15 02:40 AM
Sorry , Figured out the problem,
The gpio library file got corrupted