STM8 line interrupt and port interrupt

Publisher:phi31Latest update time:2021-09-14 Source: eefocusKeywords:STM8 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

There are two modes of STM8L interrupts, namely Pin mode and Port mode, which are the so-called line interrupts and port interrupts.

In short, line interrupt means that the interrupts of the same pin of all register groups use the same interrupt number, such as,


void KEY2Init()

{

  PB_DDR_bit.DDR2 = 0; //GPB->PIN2 Set the input and output direction register of port PB->2 to input direction 

  PB_CR1_bit.C12 = 1; //GPB->PIN2 input with pull-up resistor

  PB_CR2_bit.C22 = 1; //GPB->PIN2 enables external interrupt

                            // Use the second port as interrupt so select P2Is 

  EXTI_CR1_bit.P2IS = 2; //10 tx port bit2 external interrupt line 2 is a falling edge triggered interrupt

  EXTI_CONF_bit.PBLIS = 0; //Set PB[3:0] as the lower 4 bits of the external general interrupt PB port

}


Port interrupt means that all the pins of the same or multiple register groups use the same interrupt number.


void KEY3Init()

{

  PD_DDR_bit.DDR3 = 0; //GPD->PIN3 Set port PD->3 input direction

  PD_CR1_bit.C13 = 1; //GPD->PIN3 input with pull-up resistor

  PD_CR2_bit.C23 = 1; //GPD->PIN3 enables external interrupt

  

  EXTI_CR3_bit.PDIS = 2; //PortD port external interrupt line 2 is a falling edge triggered interrupt

  EXTI_CONF_bit.PDLIS = 1; //Set PD as external general interrupt

}


For example,

The interrupt of Pin1 of all Port A/B/C/D/E is EXTI1.

All pin interrupts of Port B and Port G are EXTIB/G

It can be understood that line interruption is specific to that pin, and port interruption is specific to that port.

A type of port can contain many pins.

When written in register mode, the two are very similar, with the following difference (please look carefully at the following two lines of code):


 1. EXTI_CR1_bit.P2IS = 2; //10 tx port bit2 external interrupt line 2 is a falling edge triggered interrupt

 2. EXTI_CR3_bit.PDIS = 2; //PortD port external interrupt line 2 is a falling edge triggered interrupt

Keywords:STM8 Reference address:STM8 line interrupt and port interrupt

Previous article:STM8S Self-study Notes-006 GPIO input: key input and key filtering
Next article:Build STM8S001 development environment

Recommended ReadingLatest update time:2024-11-15 21:09

STM8 can communication
The speed of CAN communication can be tested with an oscilloscope, TX or RX, and the narrowest waveform. If it is 16us, it is 62500, and if it is 8us, it is 125000. I also don't understand why STM8 selects the internal clock CLK_HSIPrescalerConfig(CLK_PRESCALER_HSIDIV1); that is, 16M And CAN_Prescaler = 8; //8@125KHZ
[Microcontroller]
Functions of IAR for stm8 memory window
After entering debug mode, click the menu view-Memory Can view online, RAM, FLASH, OPTION, etc.
[Microcontroller]
Functions of IAR for stm8 memory window
IAR stm8 bit determination method
When writing a program, I used the bitwise judgment. At the beginning, I wrote it like this: if (a & 0x02) == 1) { } else { } If the second bit of a is 1, execute the program in if, otherwise execute the program in else. But after compiling, the development of things cruelly deviated from my original intentio
[Microcontroller]
STM8S study notes 2 (STM8 GPIO output function)
After getting the STM8 board, I downloaded the 30-day trial version of IAR for STM8s from IAR official website. After installing it on the computer, I found that when installing IAR, the STLink drivers would also be automatically installed. It was very convenient. . Because my AVR was developed on IAR before, I was fa
[Microcontroller]
Common problems and solutions for STM8 microcontrollers
Simulation error error30220 When using STVD software to simulate a program, sometimes an error occurs and a warning window of error 30220 pops up. The reason for this problem may be that the STVP software has just burned the program, and the STLINK is occupied by the burning software. At this time, you can close
[Microcontroller]
Common problems and solutions for STM8 microcontrollers
STM8 User Boot Region (UBC)
The User Boot Area (UBC) contains the reset and interrupt vector tables, which can be used to store IAP and communication routines. UBC has a two-level protection structure to protect user code and data from accidental erasure or modification during IAP programming. This means that this area is always write-protected,
[Microcontroller]
STM8 User Boot Region (UBC)
STM8 Study Notes 3 - Error: no definition for "assert_failed"
During the STM8 program compilation process, I encountered such an error: Error : no definition for "assert_failed" The reason for this problem is that the function "void assert_failed(u8* file, u32 line);" is simply declared in the file "stm8s_conf.h". It is called when the return value verification fails during ser
[Microcontroller]
Interrupt priority of STM8 microcontroller
The interrupt of STM8S is controlled by the interrupt controller (ITC). All IOs of STM8 support interrupts and are divided into 5 groups: PA~PE. Each group of IO corresponds to an interrupt service function (that is, each group of IO has only one vector). STM8 does not have a dedicated interrupt status register, so it
[Microcontroller]
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号