K60 GPIO external interrupt

Publisher:淡雅时光Latest update time:2016-04-11 Source: eefocusKeywords:K60  GPIO Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
K60 can use almost any GPIO as an 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()
{
 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);
}
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()
{
 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;
   }
 
}
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.

 
Keywords:K60  GPIO Reference address:K60 GPIO external interrupt

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]
STM32 re-understand GPIO configuration and configure PWM wave output
[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]
【STM32】GPIO working principle (super detailed analysis of eight working modes)
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]
Latest Microcontroller Articles
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号