cancel
Showing results for 
Search instead for 
Did you mean: 

STM8S103f3 interrupt

Glodhi
Associate II

Dear ST team,

 

STM8S103f3   I need to initialize interrupt but how I can define particular pin of the port for interrupt .

Or how to initialize two interrupt in one port.

please share example or library 

Glodhi_0-1767244137138.png

 

 

RM0016

Glodhi_1-1767244178968.png

thanks and regards

Guddu

 

 

3 REPLIES 3
AA1
Senior III

See RM0016 page 109, section 11.7.2 - Interrupt capability.

Code example for pin PA7:

EXTI_CR1 |= 0x01;	// Rising edge only
PA_DDR &= 0x7F;		// PA7 is input
PA_CR2 |= 0x80;		// enable interrupt on PA7
_asm("rim");		// Enable global interrupts

In Interrupt vector table, put the address of your interrupt handler in EXTI0 entry.

You can't have two interrupt pins on same port because you can't know which pin generated the interrupt. Use two ports.

 

Glodhi
Associate II

for different interrupt pins need to use different port what if i use PC3 and PC4 two different interrupt on one port then 

i can't be able to identify interrupt ?
can you share example code for this PC3 or pC4 if not  then share 

example for different port

 

The answer to your question is already here:

You can't have two interrupt pins on same port because you can't know which pin generated the interrupt. Use two ports.

PC3 and PC4 pins are on same port and when an interrupt occurs, you can't know if it happened due to a transition on PC3 or on PC4.

Code example for pin PC3:

EXTI_CR1 |= 0x10;	// Rising edge only
PC_DDR &= 0xF7;		// PC3 is input
PC_CR2 |= 0x08;		// enable interrupt on PC3
_asm("rim");		// Enable global interrupts

 In Interrupt vector table, put the address of your interrupt handler in EXTI2 entry.