2017-09-21 02:41 AM
My aim is to generate interrupts on various pins of STM32F103 Nucleo-64, for that i used these steps as mentioned bellow ,
In cubeMx firstly i used 5 pins which are connected to switches and configured them as GPIO_EXTIx also enabled their respective interrupts in NVIC in configuration tab that are External Interrupt 3, External Interrupt 9:5 and External Interrupt 15:10, also for indication i have connected 5 pins to different LEDs and configured them as Pull up and triggered when falling edge
And then generated code with some changes as per required also for indication in code i have used an variable and assigned values from 1 to 5 to the variable which get updated on respective interrupt ,
I have used a switch statement and in that i have described 5 cases
But when i am pressing any switch or activating any Interrupt the first switch case is executed and then the respective case is executed so even if i want the case 5 to executed (Pressing switch 5) it is getting executed but before that case 1 is also getting executed so this is disturbing by functionality
so i have attached my code below please check with it and help in this concern if i am wrong any where
BELOW ATTACHED BOTH THE FILES HAVE SAME CODE ONE IS IN NOTEPAD AND ANOTHER IS IN .C EXTENSION
2017-09-21 05:15 AM
Hello!
>>>' but before that case 1 is also getting executed so this is disturbing by functionality '
Check your compiler optimisations to be -O0 (no optimisation).
if-else statements forbids to execute more than one case.
2017-09-21 10:25 PM
Thank You for your Reply,
I am new to STM so i would request you to please if you can elaborate the step by step procedure of the above mentioned comment,
Also i have updated the code which includes Switch case statement instead of if else statement, But still i am getting same issue
Please check with the snippet in which i have made changes,
\\*********************\\
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{ uint16_t ui16PinNumber; ui16PinNumber = GPIO_Pin; switch(ui16PinNumber){
case GPIO_PIN_9: ui16Value=1; HAL_GPIO_WritePin(GPIOB, GPIO_PIN_8, GPIO_PIN_RESET); HAL_Delay(500);break;
case GPIO_PIN_5: ui16Value=2; HAL_GPIO_WritePin(GPIOB, GPIO_PIN_4, GPIO_PIN_RESET); HAL_Delay(500);break;
case GPIO_PIN_3: ui16Value=3; HAL_GPIO_WritePin(GPIOD, GPIO_PIN_2, GPIO_PIN_RESET); HAL_Delay(500);break;
case GPIO_PIN_12:ui16Value=4;
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_11, GPIO_PIN_RESET); HAL_Delay(500);break;
case GPIO_PIN_10:ui16Value=5;
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_15, GPIO_PIN_RESET); HAL_Delay(500);break;
default:
}
}
2017-09-22 02:46 AM
But still i am getting same issue
Is this mean that PB8 LED from case 1 blinks also?
2017-09-22 02:50 AM
Yes for every condition it blinks