cancel
Showing results for 
Search instead for 
Did you mean: 

Cannot set EXTICR register in STM32F205

jpeacock2399
Associate II
Posted on June 21, 2012 at 00:14

Following the example for the STM3240G I set up the KEY pushbutton (PG15) as an external interrupt:

RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOG, ENABLE); // enable port 
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE); // enable external interrupts 
SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOG, EXTI_PinSource15); // KEY switch IRQ 
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN; // inputs 
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; // external pull-ups 
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; // slow inputs 
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_15; 
GPIO_Init(GPIOG, &GPIO_InitStructure); // PG15 KEY pushbutton 
// Enable the EXTI line 15 on falling edge for KEY pushbutton 
EXTI_ClearITPendingBit(EXTI_Line15); // clear pending IRQs 
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt; 
EXTI_InitStructure.EXTI_Line = EXTI_Line15; // set up irq trigger 
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling; // falling edge on button push 
EXTI_InitStructure.EXTI_LineCmd = ENABLE; 
EXTI_Init(&EXTI_InitStructure); 
NVIC_InitStructure.NVIC_IRQChannel = EXTI15_10_IRQn; // KEY irq vector (shared) 
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = GPIODEV_EXT_PRIORITY; 
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; 
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; 
NVIC_Init(&NVIC_InitStructure);

I verified the SYSCFG is enabled, RCC_APB2ENR is set to 0x4000 (SYSCFG clock on). However, after I do the

SYSCFG_EXTILineConfig

call the SYSCFG->EXTICR4 register is still set to 0x0000. Pin PG15 is not linked to EXTI No interrupt occurs. Is there some setting which holds SYSCFG in reset? The obvious suspect is the SYSCFG peripheral clock but it shows as enabled. The PG15 pin itself is working. The pushbutton shows up in the GPIOG->IDR register, so the problem seems to be the SYSCFG EXTICRn registers. I tried directly writing to the EXTICR4 register (0x6000, G15) but it reads back as zero. Jack Peacock #syscfg-exti
14 REPLIES 14
Posted on June 21, 2012 at 00:36

Looks about right. I would however move the SYSCFG_EXTILineConfig() past the GPIO_Init() as there might be a clock/pipeline/write-buffer sensitivity between enabling the clock and programming the peripheral.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
jpeacock2399
Associate II
Posted on June 21, 2012 at 03:16

jpeacock2399
Associate II
Posted on June 21, 2012 at 20:22

The problem was a typo elsewhere in code:

RCC_APB2PeriphResetCmd(RCC_APB2Periph_SYSCFG, ENABLE); // enable external interrupts   should have been RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE); // enable external interrupts    The SYSCFG was being held in reset, so no updates.  Jack Peacock

blacksu6
Associate II
Posted on July 04, 2012 at 12:27

I also meet the same problem as you. Do you solve this issue? Could you let me know the solution if it is fixed. Thanks.

Posted on July 04, 2012 at 13:00

I also meet the same problem as you. Do you solve this issue? Could you let me know the solution if it is fixed.

Please read the previous post, the cause and the solution were expressed.

ResetCmd should have been ClockCmd

Suggest you paste in your code so people can actually assess if your problem is the same or where it might be.
Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
blacksu6
Associate II
Posted on July 04, 2012 at 13:10

I just use pin PA3 as the interrupt pin when button is pressed. Pelase refers to code below.

[CODE]

 NVIC_InitTypeDef NVIC_InitStruct;

 EXTI_InitTypeDef EXTI_InitStruct;

   RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);

   SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOA,EXTI_PinSource3);

   RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);

   EXTI_ClearITPendingBit( EXTI_Line3 );

   EXTI_InitStruct.EXTI_Line=EXTI_Line3;

   EXTI_InitStruct.EXTI_Mode=EXTI_Mode_Interrupt;

   EXTI_InitStruct.EXTI_Trigger=EXTI_Trigger_Rising;

   EXTI_InitStruct.EXTI_LineCmd=ENABLE;

   NVIC_InitStruct.NVIC_IRQChannelCmd=EXTI3_IRQn;

   NVIC_InitStruct.NVIC_IRQChannelPreemptionPriority=0;

   NVIC_InitStruct.NVIC_IRQChannelSubPriority=0;

   NVIC_InitStruct.NVIC_IRQChannelCmd=ENABLE;

      EXTI_Init(&EXTI_InitStruct);

   //NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4);

   NVIC_Init(&NVIC_InitStruct);

Posted on July 04, 2012 at 13:20

Looks reasonable, what's not happening? Not seeing interrupts?

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
blacksu6
Associate II
Posted on July 04, 2012 at 14:35

1. After button is pressed, it should enter the IRQ handler. But it doesn't. I check the register ''EXTI->PR'', its value is 0x So MCU is able to detect the interrupt. Could you hive me some hint?

2. I also check the EXTICR value by calling

SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOX, EXTI_PinSourceX)

, it always return the value zero. Why?
Posted on July 04, 2012 at 14:59

Have you configured the pin? Does the IRQ handler name match the value in the vector table?

void Config_EXTI3(void)
{
NVIC_InitTypeDef NVIC_InitStruct;
EXTI_InitTypeDef EXTI_InitStruct;
GPIO_InitTypeDef GPIO_InitStruct;
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IN;
GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL; // Assuming external, adjust if required
GPIO_InitStruct.GPIO_Pin = GPIO_Pin_3;
GPIO_Init(GPIOA, &GPIO_InitStructure);
SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOA,EXTI_PinSource3);
EXTI_ClearITPendingBit( EXTI_Line3 );
EXTI_InitStruct.EXTI_Line=EXTI_Line3;
EXTI_InitStruct.EXTI_Mode=EXTI_Mode_Interrupt;
EXTI_InitStruct.EXTI_Trigger=EXTI_Trigger_Falling; // Grounding button
EXTI_InitStruct.EXTI_LineCmd=ENABLE;
EXTI_Init(&EXTI_InitStruct);
NVIC_InitStruct.NVIC_IRQChannelCmd=EXTI3_IRQn;
NVIC_InitStruct.NVIC_IRQChannelPreemptionPriority=0;
NVIC_InitStruct.NVIC_IRQChannelSubPriority=0;
NVIC_InitStruct.NVIC_IRQChannelCmd=ENABLE;
NVIC_Init(&NVIC_InitStruct);
}
void EXTI3_IRQHandler(void)
{
if(EXTI_GetITStatus(EXTI_Line3) != RESET)
{
/* Toggle LED1 */
STM_EVAL_LEDToggle(LED1);
/* Clear the EXTI line 3 pending bit */
EXTI_ClearITPendingBit(EXTI_Line3);
}
}

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..