cancel
Showing results for 
Search instead for 
Did you mean: 

GPIO Interrupt Issue

blue_dolphin1987
Associate II
Posted on February 23, 2013 at 10:32

Hi ,

I am using the following code to configure my external interrupt on PH10 , PH11, PH However , the interrupt does not occur when a signal is applied to PH10 , bothe PH11 and PH12 is working fine . Is there something i missed out ?

GPIO_InitTypeDef GPIO_InitStructure;
EXTI_InitTypeDef EXTI_InitStructure;
/* GPIOH clock enable */
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOH, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);
/* TIMER channel 1 pin (PA1) configuration */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10 |GPIO_Pin_11 | GPIO_Pin_12;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN;
GPIO_Init(GPIOH, &GPIO_InitStructure);
/* Connect EXTI Interrupt Pin */
SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOH, EXTI_PinSource10);
SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOH, EXTI_PinSource11);
SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOH, EXTI_PinSource12);
/* Configure EXTI Line */
EXTI_InitStructure.EXTI_Line = EXTI_Line10;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);
EXTI_InitStructure.EXTI_Line = EXTI_Line11 ;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);
EXTI_InitStructure.EXTI_Line = EXTI_Line12 ;
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 = EXTI15_10_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
void EXTI15_10_IRQHandler(void) {
if(EXTI_GetITStatus(EXTI_Line10) != RESET){
EXTI_ClearITPendingBit(EXTI_Line10);
if (activeChannel == 1)
channel1Count++;
}
else if(EXTI_GetITStatus(EXTI_Line11) != RESET){
EXTI_ClearITPendingBit(EXTI_Line11);
if (activeChannel == 2)
channel1Count++;
}
else if(EXTI_GetITStatus(EXTI_Line12) != RESET){
EXTI_ClearITPendingBit(EXTI_Line12);
if (activeChannel == 3)
channel1Count++;
}
}

5 REPLIES 5
Posted on February 23, 2013 at 14:06

Doesn't look unreasonable. I would lose the ELSE clauses in the interrupt routine unless the events are mutually exclusive over the service window. Are you incrementing the right counts? Can you count each EXTI separately to confirm your diagnosis?

You should perhaps double check the connections to PH10 externally. Make sure you have the right pin, it's not shorted, and the signal look correct, and of sufficient duration to generate an interrupt.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
jj2
Associate II
Posted on February 23, 2013 at 18:11

Agree w/Clive1's comments - yet would suggest that you carefully, properly probe PH10 (ideally @ edge connector {if one exists} and then moving to MCU pin itself. (if probe reveals other than ''near ground'' w/out your signal input) 

Does your MCU ''read'' PH0 as a ''1'' - when you temporarily configure it as a simple input and drive it with a logic high?  And then a ''0'' when driving signal is logic low?

You are interrupting on a ''high'' signal transition (bit non-standard) and should PH10 have lifted from its pcb pad - or be otherwise encumbered by a ''foreign'' voltage level seen as ''high'' - your injection of your signal's ''high'' will not be ''felt.''

When such GPIO issues arise - we normally config all as outputs - and generate a ''walking 1'' which is monitored via an array of Leds on one of our standard test set-ups.  Leds confirm/verify that each/every GPIO meets both Voh and Vol spec - under some current load.  (2 Led banks - monitor GPIO = 1 or 0)  Such test will confirm that GPIO is functional - and ''makes it'' to your edge connector.

Again - as Clive1 notes code does seem reasonable (at minimum its consistent - channel to channel) but we're not shown any ''follow on'' code - which may modify and/or over-ride.  Beware...

As always - when such ''strangeness'' emerges - time to visit latest errata - and even the MCU manual - to see if such pin requires special ''care/handling.''

blue_dolphin1987
Associate II
Posted on February 26, 2013 at 12:51 Hi Clive and jj.sprague, Just want to say thanks and give back a little something to the forum. Firstly , I followed through Clive's steps of trouble-shooting of the hardware and software using a oscilloscope and function generator , checking for damage IO pin or poor contact etc. However , nothing strange came up. Finally, i pinpointed the issues in the ERRATA sheet (as suggested by jj.sprague) in section 2.1.8.

Configuration of PH10 and PI10 as external interrupts is erroneous

Description

PH10 or PI10 is selected as the source for the EXTI10 external interrupt by setting bits
EXTI10[3:0] of SYSCFG_EXTICR3 register to 0x0111 or 0x1000, respectively. However,
this erroneous operation enables PH2 and PI2 as external interrupt inputs.

As a result, it is not possible to use PH10/PI10 as interrupt sources if PH2/PI2 are not
selected as the interrupt source, as well. This means that bits EXTI10[3:0] of

SYSCFG_EXTICR3 register and bits EXTI2[3:0] of SYSCFG_EXTICR1 should be
programmed to the same value:
�? 0x0111 to select PH10/PH2
�? 0x1000 to select PI10/PI2

Workaround
None.

The workaround is simply add the following statement.

/* Connect EXTI Interrupt Pin */
SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOH, EXTI_PinSource2);

Hopes it help someone. Nevertheless, the step by step approach provided by both of you will be beneficial to troubleshoot a wide range of issues. Thank !
Posted on February 26, 2013 at 15:47

Hi Sean, thanks for the update. I hadn't encountered that issue before.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
jj2
Associate II
Posted on February 26, 2013 at 16:01

More proof that even a ''blind squirrel'' (this reporter) may occasionally stumble across a fresh walnut...   Glad you persisted - and ''got it.''