Subsection 9.3.1 The Four EXTICR Registers, in General
In class we used
EXTI_EXTICR2 and read its four fields off the Reference Manual page. The general form, for a line other than EXTI4:
EXTI_EXTICRx register as RM0490 §12.5.6 prints it. There is not one such register but four, at address offset \(0x060 + 0x4 \times (x-1)\) for \(x = 1\) to \(4\text{,}\) and each holds four eight-bit fields: EXTIm in bits [7:0], EXTIm+1 in [15:8], EXTIm+2 in [23:16] and EXTIm+3 in [31:24], where \(m = 4 \times (x-1)\text{.}\) Each field holds a code saying which port drives that line.To find the register and byte for any line \(n\text{:}\) the register number is \(x = \lfloor n/4 \rfloor + 1\text{,}\) and the field within it is
EXTIn at bits \([8k+7 : 8k]\) where \(k = n \bmod 4\text{.}\) Checking it against the case we used, \(n = 4\) gives \(x = 2\) and \(k = 0\text{,}\) EXTI_EXTICR2, bits [7:0], which is what we found by reading the page. In C the register is EXTI->EXTICR[x-1].
The port codes are 0x00 for PA, 0x01 for PB, 0x02 for PC, 0x03 for PD and 0x05 for PF. 0x04 is reserved: no STM32C0 has a port E.
