K60 can use almost any GPIO as an external interrupt
gpio_init_struct.GPIO_PTx = PTA; //PORTA
gpio_init_struct.GPIO_Pins = GPIO_Pin19; //Pins 6, 7
gpio_init_struct.GPIO_Dir = DIR_INPUT; //Input
gpio_init_struct.GPIO_PinControl = INPUT_PULL_UP|IRQC_FA; //Internal pull-up|rising edge interrupt
gpio_init_struct.GPIO_Isr = porta_isr; //interrupt function
LPLD_GPIO_Init(gpio_init_struct);
// Enable interrupt
LPLD_GPIO_EnableIrq(gpio_init_struct);
gpio_init_struct.GPIO_PTx=PTA;
gpio_init_struct.GPIO_Pins = GPIO_Pin10;
gpio_init_struct.GPIO_Dir = DIR_OUTPUT;
gpio_init_struct.GPIO_Output = OUTPUT_H;
gpio_init_struct.GPIO_PinControl = IRQC_DIS;
LPLD_GPIO_Init(gpio_init_struct);
if(LPLD_GPIO_IsPinxExt(PORTA, GPIO_Pin19))
{
//Debounce
delay();
if(PTA19_I==0)
{
PTA10_O=0;
delay();delay();delay();
delay();delay();delay();
delay();delay();delay();
PTA10_O=1;
}
}
Keywords:K60 GPIO
Reference address:K60 GPIO external interrupt
To use external interrupts, you need to configure the registers and write the interrupt function.
Here I use pin 19 of port A as the key external interrupt detection, and pin 10 of port A as the LED output
void init_gpio()
{
}
The fifth line gpio_init_struct.GPIO_Isr = porta_isr; assigns the name of the interrupt function to GPIO_Isr, which is used to store the address pointer of the interrupt function and then enable the interrupt.
Interrupt function
void porta_isr()
{
}
The name of this interrupt function is the value given to GPIO_Isr. Each GPIO pin has an interrupt flag, and LPLD_GPIO_IsPinxExt(PORTx, GPIO_Piny) is the interrupt flag of the Piny port of PORTx. Once an interrupt occurs, the flag is 1 and the interrupt function content is executed.
There is also a tip, the interrupt function here needs to be declared, which is different from 51, where the 51 does not need to be declared.
Previous article:K60 PIT Timer
Next article:About the first operating system on an ARM processor
Recommended ReadingLatest update time:2024-11-23 07:33
STM32 re-understand GPIO configuration and configure PWM wave output
I recently made an SD card BOOTLOARDER program. During the test, I thought of using the LED light of the board to make a firefly light. I downloaded the APP file to the board through BOOTLOARDER to check the flashing of the LED light. Maybe because I was too confident that such a small program could handle it, I didn'
[Microcontroller]
[AVR ASF4 library function study notes] 2. GPIO
Platform: Microchip Studio (formerly Atmel Studio 7) Xinshiji DMAVR-L Atmega 128A - AU The header file is port.h Enumeration Types enum port_pull_mode { PORT_PULL_OFF, PORT_PULL_UP, }; enum port_dir { PORT_DIR_IN, PORT_DIR_OUT, PORT_DIR_OFF, }; function X = ABCDEFG static inline bool PORTX_get_pin_
[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]
STM32 GPIO structure
1. STM32 GPIO structure diagram GPIO has 8 setting modes: input floating, input pull-up, input pull-down, analog input, open drain output, push-pull output, push-pull multiplexing function, open drain multiplexing function, a total of 4 inputs, 2 inputs, and 2 multiplexing functions. 2. Mode description ① The Sc
[Microcontroller]
C51 GPIO port simulates IIC reading and writing 24CXX
#include reg52.h #define delayNOP() {_nop_(); _nop_(); _nop_(); _nop_();} //IIC start signal void iic_start(void) { SDA = 1; SCL = 1; delayNOP(); SDA = 0; delayNOP(); SCL = 0; } //IIC stop signal void iic_stop(void) { SDA = 0; delayNOP(); SCL = 1; delayNOP(); SDA = 1; }
[Microcontroller]
【STM32】GPIO working principle (super detailed analysis of eight working modes)
STM32F1xx official information: "STM32 Chinese Reference Manual V10" - Chapter 8 General and Multiplexed Function IO (GPIO and AFIO) Chip data sheet STM32 GPIO Introduction STM32 pin description GPIO is the abbreviation of general purpose input/output port, which is a controllable pin of STM32. GPIO pins are conn
[Microcontroller]
ARM learning GPIO to realize water light
Today, when I was learning about MMU, I wrote a pipeline program. Although it is very simple, I am not afraid of being laughed at. Since I did not learn degree calculation operations when I learned C language, and I did not do many hardware experiments, it took a lot of effort to realize this. /* * leds.c: Cycle to
[Microcontroller]
- Popular Resources
- Popular amplifiers
- 100 Examples of Microcontroller C Language Applications (with CD-ROM, 3rd Edition) (Wang Huiliang, Wang Dongfeng, Dong Guanqiang)
- Digilent Vivado library
- Basics of Machine Learning: From Getting Started to Job Hunting (Hu Huanwu)
- Switching Power Supply Simulation and Design - Based on SPICE (Second Edition)
Recommended Content
Latest Microcontroller Articles
- Naxin Micro and Xinxian jointly launched the NS800RT series of real-time control MCUs
- How to learn embedded systems based on ARM platform
- Summary of jffs2_scan_eraseblock issues
- Application of SPCOMM Control in Serial Communication of Delphi7.0
- Using TComm component to realize serial communication in Delphi environment
- Bar chart code for embedded development practices
- Embedded Development Learning (10)
- Embedded Development Learning (8)
- Embedded Development Learning (6)
He Limin Column
Microcontroller and Embedded Systems Bible
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
MoreSelected Circuit Diagrams
MorePopular Articles
- Intel promotes AI with multi-dimensional efforts in technology, application, and ecology
- ChinaJoy Qualcomm Snapdragon Theme Pavilion takes you to experience the new changes in digital entertainment in the 5G era
- Infineon's latest generation IGBT technology platform enables precise control of speed and position
- Two test methods for LED lighting life
- Don't Let Lightning Induced Surges Scare You
- Application of brushless motor controller ML4425/4426
- Easy identification of LED power supply quality
- World's first integrated photovoltaic solar system completed in Israel
- Sliding window mean filter for avr microcontroller AD conversion
- What does call mean in the detailed explanation of ABB robot programming instructions?
MoreDaily News
- STMicroelectronics discloses its 2027-2028 financial model and path to achieve its 2030 goals
- 2024 China Automotive Charging and Battery Swapping Ecosystem Conference held in Taiyuan
- State-owned enterprises team up to invest in solid-state battery giant
- The evolution of electronic and electrical architecture is accelerating
- The first! National Automotive Chip Quality Inspection Center established
- BYD releases self-developed automotive chip using 4nm process, with a running score of up to 1.15 million
- GEODNET launches GEO-PULSE, a car GPS navigation device
- Should Chinese car companies develop their own high-computing chips?
- Infineon and Siemens combine embedded automotive software platform with microcontrollers to provide the necessary functions for next-generation SDVs
- Continental launches invisible biometric sensor display to monitor passengers' vital signs
Guess you like
- Solution to debugging DAbt_Handler problem
- 【Gravity:AS7341 Review】+ Comparative Analysis between Color Sensors
- The next industrial revolution relies on wireless connectivity
- Playing with Zynq Serial 20: Modular Design Based on FPGA
- A novice asked a question about the if statement in C language
- [SAMR21 New Gameplay] 9. Serial Communication-2
- I just used the 1904 version of AD and why can't I get 3D display in LIB
- 35 "Ten Thousand Miles" Raspberry Pi Car——ROS Learning (Realizing Hello World)
- Ask for a lithium battery boost solution
- Phase-Locked Loop (PLL)