#include "stm32f4xx.h" #include "LCD2x16.c" int IRQcounter = 0; // declare & initialize IRQ counter void main (void){ RCC->AHB1ENR |= 0x10; // Clock for PortE RCC->APB2ENR |= 0x00004000; // Clock for SYSCFG - system configuration controller GPIOE->MODER |= 0x55550000; // upper half port E == outputs LCD_init(); // init LCD LCD_string("Number of IRQs:", 0x00); // display title string NVIC_EnableIRQ(EXTI3_IRQn); // Enable IRQ for external signals, line EXTI3_IRQn SYSCFG->EXTICR[0] = 0x4000; // select PE to make IRQ EXTI3 EXTI->RTSR |= 0x00000008; // allow positive edge interrupt for EXTI3 EXTI->IMR |= 0x00000008; // enable interrupt on EXTI3 while (1) { LCD_uInt16(IRQcounter,0x40,1); // write IRQ count to LCD LCD_uInt16(GPIOE->IDR & 0x3f,0x48,1); // write keycode to LCD for (int i = 0; i<100000; i++) {}; // waste some time }; } void EXTI3_IRQHandler (void) { IRQcounter++; // do the actual work EXTI->PR = 0x08; // clear interrupt flag for EXTI3 GPIOE->ODR |= 0x0100; // added to signal the execution of the IRQ function GPIOE->ODR &= ~0x0100; // end of execution, about 300ns later }