当前位置:网站首页>1. Mx6u bare metal program (5) - external interrupt
1. Mx6u bare metal program (5) - external interrupt
2022-06-23 01:48:00 【Chongyou research Sen】
Catalog
1. Start up the idea of document preparation ——start.s
2. Interrupt service function ideas to write ——int. c
3.GPIO Module idea compilation ——gpio.c
4. Key interrupt execution function idea writing ——exti.c
1. Start up the idea of document preparation ——start.s
1. Program entrance ——_start:
Interrupt vector table : When executing a function , Just jump to a function

2. Reset interrupt ——Reset_Handler:
When sending reset , Function execution here .
(1) close IRQ interrupt
(2) close I,Dcash etc.
(3) Vector offset ( It can also be in C The language says )
(4) Set each mode (IRQ,SYS,SVC)
(5) open IRQ interrupt
(6) Jump to the c function


3.IRQ interrupt ——IRQ_Handler:
When the interrupt function is executed , The function executes here
(1) preservation lr ro-r3,r12 register —— In order to return to the previous state after executing the interrupt
(2) hold r0 A register set to hold a special register
(3) hold r1 Set to set to GIC First address of register group
(4) Set up r1 by gic Interface address in
(5) Set up r0 by gic in IAR A register used to hold interrupt numbers
(6) preservation r0 and r1
(2) Get into SVC Pattern
(1) preservation lr
(2) Set up r2 by system_irqhandler
(3) Get into r2, And r0 Input parameters for this function
After interrupt execution
(4) Out of the stack lr
(3) Get into IRQ
(1) Out of the stack r0,r1
(2) hold r0 writes r1+0x10—— hold GICC_IAR Worth writing GICC_EOIR Inside
(3) Out of the stack r0
(4) take r0 writes spsr Special register
(5) Out of the stack ro-r3,r12 Registers and lr
(6) take lr-4 The value is assigned to pc—— because lr-4 It's just pc Current value to run

4. Other default functions
Just write the loop

2. Interrupt service function ideas to write ——int. c
1. Interrupt initialization function
(1)GIC initialization
(2) Initialize the interrupt table to the default value —— The service function of each element of the array is an endless loop , Parameter is NULL
(3) Set interrupt offset

2. Interrupt the registration function —— Used to assign values to interrupt functions in the interrupt array table
(1) In the array 1 No. position function assignment
(2) In the array 1 No. position parameter assignment

3. Interrupt service function
(1) First judge whether the interrupt number is correct
(2) According to the interruption ID Assign a value to the corresponding interrupt service function in the array

3.GPIO Module idea compilation ——gpio.c
1.gpio Interrupt settings
(1) close EDGE_SEL—— Irrelevant changes ,ICR invalid
(2) Judgment is ICR1 still ICR2—— low 16 yes 1, high 16 yes 2
(3) utilize switch Statement to select the triggering method , To adjust the register

2.gpio Initialize settings
(1) On the basis of the original , Introduce interrupt setting initialization —— Before, there was only input and output , Output potential

3.gpio Interrupt enable and disable functions
(1) Can make : Set up IMR Register bit 1
(2) prohibit : Set up IMR Register bit 0

4.gpio Interrupt flag bit clear function ideas to write
(1) Set up ISR The register is 1

4. Key interrupt execution function idea writing ——exti.c
1.gpio And interrupt initialization
(1)GOIO initialization ( Reuse , Input and output , Trigger )
(2)GIC initialization —— Initialization interrupt ID
(3) Interrupt the initialization of the registration function —— Prevent the current interrupt from ending and the next interrupt from coming again

2. Interrupt execution function settings
(1) Read the pin value and change it beep state
(2) Clears the interrupt flag bit

5. summary
Startup file : Set up interrupt vector table , And reset and IRQ Write down the specific implementation contents ( Mainly cp15)
Interrupt file ——int.c: Set an array , And the content is the structure ( function + Parameters ), And initialize each element of the array ( function = Dead cycle , Parameters =NULL), Then create the registration function , Interrupt function corresponding to startup file
Interrupt initialization ——gpio.c: Initialize the trigger mode
Key interrupt ——exit.c: Initialization for keys ( Reuse , Input and output , Trigger ),GIC, Register function . And write the specific execution interrupt function
边栏推荐
- There are animation characters interacting with each other when the mouse slides in the web page
- C#. Net universal database access encapsulation classes (access, sqlserver, Oracle)
- Found several packages [runtime, main] in ‘/usr/local/Cellar/go/1.18/libexec/src/runtime;
- OOP multiple storage (class template)
- 魔王冷饭||#099 魔王说西游;老板的本质;再答中年危机;专业选择
- HDU - 7072 double ended queue + opposite top
- Extend your kubernetes API using the aggregation API
- Cmake passing related macros to source code
- It's still like this
- Three methods for solving Fibonacci sequence feibonacci (seeking rabbit) - program design
猜你喜欢

1. introduction to MySQL database connection pool function technology points

Foundation Consolidation - Flex width is content width

8. destruct, construct, deep copy, shallow copy, assignment operator overload

2022-1-14

Unique in Pimpl_ PTR compilation errors and Solutions

There are animation characters interacting with each other when the mouse slides in the web page
![[learning notes] roll back Mo team](/img/19/d374dd172b9609a3f57de50791b19e.png)
[learning notes] roll back Mo team

Charles garbled code problem solving

2D prefix and

JS to paste pictures into web pages
随机推荐
How to download online printing on Web pages to local PDF format (manual personal test)
Philosopher's walk gym divide and conquer + fractal
"Initial C language" (Part 1)
10. static member variables, static member methods, and pointers to class members
Unit of RMB in words
[cmake command notes]target_ compile_ options
4. functions and inline functions with default values for formal parameters
Unique in Pimpl_ PTR compilation errors and Solutions
Summary of the first week of winter vacation
Day500: keyboard line
Exercise analysis summary
Debian10 LVM logical volumes
Vector 6 (inheritance)
Zabbix5 series - use temperature and humidity sensor to monitor the temperature and humidity of the machine room (XX)
Up the Strip
Game (sanziqi & minesweeping)
Cmake passing related macros to source code
[hdu] P6964 I love counting
Error reported when compiling basalt
MySQL -- how to access the database of a computer in the same LAN (prenatal education level teaching)