2013-02-04 11:39 PM
Hello Guys,
I am trying to play with EXTI of STM32VL but what seems to be the problem in this code why I can't make it work
int main(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
EXTI_InitTypeDef EXTI_InitStructure;
NVIC_InitTypeDef NVIC_InitStructure;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_Init(GPIOA, &GPIO_InitStructure);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
EXTI_InitStructure.EXTI_Line = EXTI_Line1;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);
NVIC_InitStructure.NVIC_IRQChannel = EXTI1_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x0F;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x0F;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
STM32vldiscovery_LEDInit(LED3);
//STM32vldiscovery_PBInit(BUTTON_USER, BUTTON_MODE_EXTI);
while (1)
{
}
}
in the stm32f10x_it.c
void EXTI1_IRQHandler(void)
{
if(EXTI_GetITStatus(EXTI_Line1) != RESET)
{
/* Toggle LED3 */
STM32vldiscovery_LEDToggle(LED3);
/* Clear the User Button EXTI line pending bit */
EXTI_ClearITPendingBit(EXTI_Line4);
}
}
2013-02-05 01:19 AM
I found my mistake
EXTI_ClearITPendingBit(EXTI_Line4);
is should be line1
2013-02-05 01:21 AM
I still accept comments and addons for this code... if you can add something helpfull about EXTI please add.. thank you!