Primer 2 EXTI not working for Joystick's Left,Right,Up & Down pins
Hi,
This is my first post to this forum. I got my new Primer2 last week & I've been trying to test my STM32 standard peripheral API knowledge by running simple task (bypassing CircleOS)
I cannot get the EXTI configuration working for the Joystick Left,Right,Up & Down buttons. (Only exception is the centre button of the joystick which generates interrupt properly. This works)
I wanted to test the EXTI interrupt handlers when any button on the joystick is pressed. In the handler one of the LED is toggled.
Re: Primer 2 EXTI not working for Joystick's Left,Right,Up & Down pins
Whew.. I found the solution for the above problem. For EXTI to work with GPIOE(Joystick) port, the clock for AFIO should be enabled which I was not doing earlier. After enabling RCC_APB2Periph_AFIO, the interrupts were serviced. Surprisingly EXTI worked for GPIOA(Pushbutton) port without enabling AFIO clock. Wonder whether this has been documented anywhere. Going to get goodnight sleep tonight
Offline
#
3
2010-03-03 10:12:35Primer 2 EXTI not working for Joystick's Left,Right,Up & Down pins
Re: Primer 2 EXTI not working for Joystick's Left,Right,Up & Down pins
Hello satishgn,
i tried your Primer2BasicTest, it runs well but i can't modify the Push Button definition. I just want to push the button to shut down with modifing your code:
GPIO_EXTILineConfig(GPIO_PUSH_BUTTON, GPIO_PUSH_BUTTON_PIN); // Connect PUSH_BUTTON to shutdown EXTI_InitStructure.EXTI_Line = EXTI_Line2; /* Configure PUSH_BUTTON to generate an interrupt on rising edge */ EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt; EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising; EXTI_InitStructure.EXTI_LineCmd = ENABLE; EXTI_Init(&EXTI_InitStructure);
it's not functionable, i also tried with JSTK_UP & DOWN and they do, but LEFT & RIGHT don't, why is that? Another questions is, how do you choose the EXTI_Line? Is there some certain routine or how do you know the line is not occupied?
Thanks a lot!
Last edited by thefly (2010-03-03 10:19:16)
Offline
#
4
2010-03-03 11:01:06Primer 2 EXTI not working for Joystick's Left,Right,Up & Down pins
if(EXTI_GetITStatus(EXTI_Line6) != RESET) { //Toggle Led GPIO_WriteBit(GPIO_LED, GPIO_LED0_PIN, (BitAction)((1-GPIO_ReadOutputDataBit(GPIO_LED, GPIO_LED0_PIN))));
EXTI_ClearITPendingBit(EXTI_Line6); }
if(EXTI_GetITStatus(EXTI_Line8) != RESET) { //Toggle Led GPIO_WriteBit(GPIO_LED, GPIO_LED0_PIN, (BitAction)((1-GPIO_ReadOutputDataBit(GPIO_LED, GPIO_LED0_PIN))));
EXTI_ClearITPendingBit(EXTI_Line8); } }
I figured out that the PUSH Button is on GPIOA_PIN8, so i'd use the EXTI_line8, but "error: 'EXTI8_IRQn' undeclared (first use in this function) ". In the ST Firmware library there are only EXTI_IRQChannel 0-4. How did u use the EXTI_Line8?
Offline
#
5
2010-03-03 11:09:24Primer 2 EXTI not working for Joystick's Left,Right,Up & Down pins