2012-06-20 03:14 PM
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
2012-07-04 06:11 AM
Yes, I have configured the pin PA.3. I will check the vector table again. It's strange why the SYSCFG->EXTICR0 is always zero even I changed the pin to PB.3? Anyway, thank you for your kindly support.
2012-10-30 03:38 AM
Did you guys sorted out what was the problem meanwhile?
It seems I'm experiencing exactly the same problem. I compared my code to the above listings several times now and I can't find any mistakes.2012-10-30 06:56 AM
I haven't dwelt on it since.
If it's not the software, examine the hardware. Look at some of the STM322xG-EVAL examples.2012-10-30 09:21 AM
It was the software after all of course …
I’m working on a STM3220G evaluation board so the chances that anything was wrong there were pretty low.
The plan was to have an interrupt on pressing the key listed ‘key’ on the silkscreen of the evaluation board. (B4) – This key is connected to port PG15.
It seems I then managed to look at the wrong bit in the interrupt pending register of the NVIC.
PG15 can be connected to EXTI12 till EXTI15.
EXTI lines 10 till 15 have their own vector in the vector table and I managed to overlook that. (Waiting for the IRQ arriving on EXTI4 … and being surprised that nothing happens!)
Now that I found out how it work this looks pretty silly I know.
/* Enable and set EXTI Line10-15 Interrupt to the lowest priority */
NVIC_InitStructure.NVIC_IRQChannel =
EXTI15_10_IRQn
;NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x0F;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x0F;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
2012-10-30 10:15 AM
That's certainly an easy thing to do, one of my big gripes with the library is the lack of numeric parameters, so general/adaptable solutions are difficult.
Change a DMA stream and you have to resolve a dozen references, catching them all. Thing2, SomethingElse2, SimilarButDifferent2, ... which all have enumerations other than TWO. I understand the implementation efficiency of using bit vectors and masks, but it becomes a bugger to retarget a peripheral, or use two without duplicating code.