cancel
Showing results for 
Search instead for 
Did you mean: 

STM8AL318A PORT I EXTI registers mapping

Johan Nylund
Associate II
Posted on February 18, 2017 at 20:13

Hello

I am using stm8al318a lqfp80 package with GPIO pins PI0 - PI3.

The datasheet says 'all IOs mappable to interupt vectors' and the pin description has a check for ext. Interrupt.

But when reading reference manual RM0031 and the interrupt controller chapter with the EXTI registers specified, there are no bits in the registers mapping PORT I to interrupt vectors. There is a note in chapter 12.6 saying 'Port G, H and I are available on medium+ and high-density devices only'

My question is how can I map a GPIO on for example PI2 to an external interrupt?

/Johan

2 REPLIES 2
Szymon PANECKI
Senior III
Posted on February 19, 2017 at 11:24

Hello Johan,

It is possible to configure GPIOs as external interrupts. For this purpose you need to use GPIO CR2 (GPIO Control Register 2). Please refer to the

http://www.st.com/resource/en/reference_manual/CD00218714.pdf

, page 124.0690X00000606ILQAY.png

As a reference example here is a code for PC1 pin mapped as an external interrupt:

GPIOC->DDR &= ~(1<<1);       //configure PC1 as input

GPIOC->CR1 &= ~(1<<1);       //configure PC1 in input floating mode

GPIOC->CR2 |= 1<<1;             //enable external interrupt for PC1

EXTI->CR1 |= 1<<3;                //configure PC1 external interrupt sensivity as falling edge

_rim_()                                     //enable interrupts

After executing this code PC1 is configured as external interrupt and when the falling edge on this pin is detected, MCU will jump to external interrupt handler.

Best regards

Szymon
Posted on February 19, 2017 at 13:37

Hi Szymon

Thanks for your answer!

I know how to configure a GPIO as an external interrupt using the gpio registers and the exti registers.

But i dont know how to do it if Port I is used. If you look at the exti registers of rm0031 there are no bits for configuring Port I (either on CR, SR or CONF register). Chapter 12.6 states the different external interrupts possible but port I is not part of the description. For example the EXTI->CR1 registers you are using in your example is stated to be valid for port A,B,C,D and/or E in the bit description of the register (12.9.3).

I am afraid Port I cannot be used as interrupt source?

Regards

/Johan