STM8 IO external interrupt setting problem

Publisher:rnm888Latest update time:2020-02-29 Source: eefocusKeywords:STM8 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

STM8 IO external interrupt setting problem (using library function)


STM8, fall into the pit:


In the program, first enable the general interrupt, enableInterrupts(); // Enable the general interrupt  


In the subsequent program, set the IO port external interrupt to open and set the trigger level. The code is as follows: (The pit is here, pay attention!!!)


GPIO_Init(PORT_BLE_STA, PIN_BLE_STA, GPIO_Mode_In_PU_IT); //Pull up, open interrupt

EXTI_SetPinSensitivity(EXTI_PIN_BLE_STA, EXTI_Trigger_Falling); //Falling edge interrupt


Then the tragedy happened. Once a falling edge occurred at the IO port, the program died immediately and the watchdog was reset.


After locating, it was found that the interrupt was triggered continuously. But why was the interrupt triggered continuously? Wasn't it set to the falling edge interrupt?


reason:


Because the general interrupt has been turned on when setting the trigger level, the setting is invalid!!! This means that the falling edge trigger is not set at all!!! Then the default value is used, which is low level trigger. When the IO port is pulled low, the interrupt will be triggered continuously.


Solution: Be sure to set the level trigger when the general interrupt is turned off.

If you don't need interrupts at the beginning, you can disable IO port interrupts, but you need to set the trigger level first. When you need interrupts later, just turn on the interrupts, and you don't need to set the trigger level again.


example:


1. No interrupt is needed at the beginning, IO interrupt is disabled, but the trigger level must be set


GPIO_Init(PORT_BLE_STA, PIN_BLE_STA, GPIO_Mode_In_PU_No_IT);

EXTI_SetPinSensitivity(EXTI_PIN_BLE_STA, EXTI_Trigger_Falling); //When setting the trigger mode, be sure to turn off the total interrupt, otherwise it will fail


2. In the subsequent programs, you need to enable interrupts. Just turn on the IO interrupts. There is no need to set the trigger level here.


   GPIO_Init(PORT_BLE_STA, PIN_BLE_STA, GPIO_Mode_In_PU_IT);

Keywords:STM8 Reference address:STM8 IO external interrupt setting problem

Previous article:stm8 GPIO button input
Next article:STM8 STM8S208MB registers

Recommended ReadingLatest update time:2024-11-16 13:27

In-depth analysis of STM8 MCU timer driver
In the previous section, we introduced the driver of STM8 microcontroller GPIO based on the standard library. This section mainly introduces the driver of STM8 timer. Let's first open the specification sheet of the STM8L10x microcontroller and take a brief look at the timer function of the STM8L10X microcontroller.
[Microcontroller]
In-depth analysis of STM8 MCU timer driver
Detailed explanation and application of STM8's ADC multiple acquisition modes
First, the ADC of STM8S supports 5 conversion modes: single mode, continuous mode, buffered continuous mode, single scan mode, and continuous scan mode. 1Single mode In single-shot mode, the STM8S ADC performs only one ADC conversion on the selected channel, and the conversion result is stored in the ADC_DR register
[Microcontroller]
Detailed explanation and application of STM8's ADC multiple acquisition modes
STC8 MCU IO port simple simulation serial communication
We all know how to use the system configured serial port initialization function to use our serial port, that is, we can only use fixed pins for serial communication, which is the following method, If you want to use other pins for serial communication, you can't do that. The following will teach you how to use anal
[Microcontroller]
STC8 MCU IO port simple simulation serial communication
STM8 MCU ADC Application (IAR)
The STM8 chip integrates a 10-bit successive approximation analog-to-digital converter. There is a potentiometer connected to AIN3 on the development board, but there is no LED digital tube or LCD display to display data. What should I do? The AD acquisition data can be sent to the computer through UART for display. #
[Microcontroller]
IAR configuration implementation based on STM8
  Take STM8 as an example:   Copy the icf file of the MCU model used in the project to the project. ICF is usually placed in   C:Program FilesIAR SystemsEmbedded Workbench 6.5stm8config   In this directory.   1. Copy lnkstm8s207rb.icf   For example, if I use STM8S207RB, I will copy the file lnkstm8s207rb.icf into my
[Microcontroller]
IAR configuration implementation based on STM8
STM8 ISP serial port download instructions
1. Run the installation file “Flash_Loader_Demonstrator_v 2.5.0_Setup.exe” in the folder “stm32-stm8_flash_loader_demo”. You can choose the default path during installation. 2. Take the STM8-QC development board as an example to explain the download process. 3. Use the PL2303 download cable and the PL2303 driver i
[Microcontroller]
IAR for STM8 Issue 1
IAR for STM8 pop-up window: Fatal error while generating source browse infomation. See the Source Browse Log window for more infomation This happens because there are Chinese characters in the include path of the .c or .h file. After changing Chinese to English and resetting the path, it will run normally as follows.
[Microcontroller]
IAR for STM8 Issue 1
ADI’s Smart Factory Expertise Helps You Select the Right IO-Link Slave Transceiver
An excellent IO-Link slave transceiver should be able to meet all application requirements. This is the final blog post in the Smart Factory series. It discusses the factors to consider when selecting an IO-Link slave transceiver and explains how the features of Analog Devices' IO-Link transceiver product family can
[Analog Electronics]
ADI’s Smart Factory Expertise Helps You Select the Right IO-Link Slave Transceiver
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号