Last week, the thing that interrupted the CPU was a timer. Nearly everything we discussed in this context (the NVIC admitting the request, the vector table naming the handler, the ISR staying short, the volatile flag communicating with main()) was the interrupt mechanism, and none of it changes when we look at other interrupt sources.
A pin change interrupt requires us to configure one more piece of hardware (the EXTI, between the pins and the NVIC). We need to look at three new registers to do so, and a fourth one that we use inside the ISR.
In last night’s homework you added a heartbeat to ADCPot.c: the ADC keeps printing while a TIM14 interrupt blinks the on-board LED one-third of a second on, one-third of a second off. Compare your version with your neighbors’ and note any differences in implementation.
One detail to notice: The hint was to toggle the LED directly in the ISR, so most solutions contain a line like GPIOA->ODR ^= LED; inside TIM14_IRQHandler. The ISR thus loads a peripheral register, changes its value and writes it back. Keep that line in mind: We’ll come back to it at the end of class.
PSC = 3999, ARR = 999 is one exact answer. Both are written minus one, so that is divide-by-4000 and count-to-1000: 12 MHz ÷ 4000 = 3 kHz, and 1000 ticks of that is ⅓ s. Other pairs work; the product is what matters.