ARM basic interface external interrupt experiment

Publisher:德州小孙Latest update time:2018-12-19 Source: eefocusKeywords:ARM Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Purpose:


1. Understand the role of interrupts;


2. Master the interrupt processing flow of embedded systems;


3. Master ARM external interrupt programming.


Experimental content (including steps):


1. Overall steps: compile first, start the target machine, wait for the display to show 2440, then create a link, download, run, and observe whether HELLOO is displayed. Press the EXINT2 button to see whether the LED light changes the display effect.


2. Experimental process: During the experiment, the hardware connection failed. The team members thought it was a problem with the connection between the target machine and the computer. They unplugged and plugged it in, but it still didn't work. Later, they changed the computer connection many times and spent a lot of time to finally solve the problem. Then they modified the code, compiled, linked, downloaded, and ran it within a tight time, and finally successfully displayed the effect. After understanding the principle, by running the digital tube display code in the main program, the host machine can correctly display the word HELLOO, and then press the EXINT2 button to request an interrupt and execute the interrupt service program, so that the LED light can change the display


3. The code is as follows:


/****************************************************** ***************************/

 

/*Experimental phenomenon: The common anode digital tube displays HELLOO. After the external interrupt is triggered, the LED light changes from odd-numbered tubes on (off) to even-numbered tubes on (off)*/

 

/****************************************************** ***************************/

 

#define U8 unsigned char

 

/*HELLOO character encoding*/

 

unsigned char hello[6] = {

 

0x89, 0x86, 0xc7, 0xc7, 0xc0, 0xc0,

 

};

 

/*Status code of only one of the six digital tubes is on*/

 

unsigned char con[6] = {

 

0xdf, 0xef, 0xf7, 0xfb, 0xfd, 0xfe

 

};

  

void myDelay(int time);

 

Void Delay(int time);

  

/****************************************************** *********************

// Function name: Isr_Init

// Description    : Interrupt initialization function

// Return type: void

// Argument : void

*************************************************** *******************/

 

void Isr_Init(void)

 

{

 

    pISR_UNDEF = (unsigned)HaltUndef;

 

    pISR_SWI = (unsigned)HaltSwi;

 

    pISR_PABORT = (unsigned)HaltPabort;

 

    pISR_DABORT = (unsigned)HaltDabort;

 

 

 

    rINTMOD = 0x0; //Interrupt mode is set to IRQ

 

    rINTMSK = BIT_ALLMSK; //All interrupt is masked.

 

    rINTSUBMSK = BIT_SUB_ALLMSK; //All sub-interrupt is masked.

 

}

 

/****************************************************** *********************

// Function name: Isr_Request

// Description    : Register interrupt function (interrupt request)

// Return type: void

// Argument : int irq_no

// #define IRQ_EINT0 1

// #define IRQ_EINT1 2

// #define IRQ_EINT2 3

// #define IRQ_EINT3 4 //**

// #define IRQ_EINT4_7 5

// #define IRQ_EINT8_23 6

// #define IRQ_NOTUSED6 7

// #define IRQ_BAT_FLT 8

// #define IRQ_TICK 9

// #define IRQ_WDT 10

// #define IRQ_TIMER0 11

// #define IRQ_TIMER1 12

// #define IRQ_TIMER2 13

// #define IRQ_TIMER3 14

// #define IRQ_TIMER4 15

// #define IRQ_UART2 16

// #define IRQ_LCD 17

// #define IRQ_DMA0 18

// #define IRQ_DMA1 19

// #define IRQ_DMA2 20

// #define IRQ_DMA3 21

// #define IRQ_SDI 22

// #define IRQ_SPI0 23

// #define IRQ_UART1 24

// #define IRQ_NOTUSED24 25

// #define IRQ_USBD 26

// #define IRQ_USBH 27

// #define IRQ_IIC 28

// #define IRQ_UART0 29

// #define IRQ_SPI1 30

// #define IRQ_RTC 31

// #define IRQ_ADC 32

// Argument: void* irq_routine

*************************************************** *******************/

 

//The first parameter indicates the interrupt request source, and the second parameter is the interrupt service function defined by the interrupt request source

 

void Irq_Request(int irq_no, void* irq_routine)

 

{

 

if(irq_no >= IRQ_MIN && irq_no <= IRQ_MAX)

 

*(unsigned int*)((irq_no - 1) * sizeof(unsigned int) + (unsigned int)(_ISR_STARTADDRESS+0x20)) = (unsigned int)irq_routine;

 

// _ISR_STARTADDRESS+0x20 is to skip the previous exception vector and enter the IRQ interrupt vector

 

// Three-level jump to the specified address, that is, jump from the flash to the interrupt entry of the RAM, and then jump from the interrupt entry to the interrupt // distribution routine entry

 

}

  

/****************************************************** *********************

// Function name: Irq_Enable

// Description    : Enable interrupt

// Return type: void

// Argument : int irq_no

*************************************************** *******************/

 

//The parameter indicates the interrupt request source. This function enables an interrupt.

 

void Irq_Enable(int irq_no)

 

{

 

if(irq_no >= IRQ_MIN && irq_no <= IRQ_MAX)

 

rINTMSK &= ~(1 << (irq_no - 1)); //Set all to zero, enable interrupt

 

}

  

/****************************************************** *********************

// Function name:Irq_Disable

// Description    : Disable interrupt

// Return type: void

// Argument : int irq_no

*************************************************** *******************/

 

//The parameter indicates the interrupt request source. This function disables a certain interrupt

 

void Irq_Disable(int irq_no)

 

{

 

if(irq_no >= IRQ_MIN && irq_no <= IRQ_MAX)

 

rINTMSK |= (1 << (irq_no - 1)); //Set to 1, disable interrupt

 

}

  

/****************************************************** *********************

// Function name: Irq_Clear

// Description    : Clear interrupt

// Return type: void

// Argument : int irq_no

*************************************************** *******************/

 

//The parameter indicates the interrupt request source. This function clears an interrupt request.

 

void Irq_Clear(int irq_no)

 

{

 

    rSRCPND = (1 << (irq_no - 1)); //Set to 1 and clear the corresponding bit of the register

 

    rINTPND = (1 << (irq_no - 1)); //Set to 1 and clear the corresponding bit of the register

 

    rINTPND;

 

}

 

 

 

/****************************************************** ******************************

// Function name: eint2_isr

// Description    : Main function

// Return type: void

// Argument : void

*************************************************** ***************************/

 

void Main(void)

 

{

 

/* Configure system clock */

 

    ChangeClockDivider(2,1);

 

    U32 mpll_val = 0 ;

 

    mpll_val = (92<<12)|(1<<4)|(1);

 

    ChangeMPllValue((mpll_val>>12)&0xff, (mpll_val>>4)&0x3f, mpll_val&3);

 

 

 

/* Interrupt initialization */

 

    Isr_Init();

 

    /* Initialize port */

 

    Port_Init();

 

 

 

    /* Initialize the serial port */

 

    Uart_Init(0,115200);

 

    Uart_Select(0);

 

 

 

    /* Print prompt information */

 

PRINTF("\n---External interrupt test program---\n");

 

PRINTF("\nPlease connect UART0 to the PC serial port, and then start the HyperTerminal program (115200, 8, N, 1)\n");

 

PRINTF("\nExternal interrupt test starts\n");

 

 

 

/* Request interrupt */

 

Irq_Request(IRQ_EINT3, eint3_isr);

 

 

 

    /* Enable interrupt */

 

    Irq_Enable(IRQ_EINT3);

 

 

 

    dither_count2 = 0;

 

    dither_count3 = 0;

 

 

 

    while(1){

 

    int i, j;

 

        int flag = 1;

 

 

 

        for(j=0; ; j++){

 

            *((U8*) 0x20007000) = 0x80;

 

            /* The digital tube displays characters from 0 to F in sequence*/

 

            for(i=0;i<6;i++){

 

                /* Look up the table and output data*/

 

                *((U8*) 0x20007000) = con[i];

 

                *((U8*) 0x20006000) = hello[i];

 

                myDelay(1);

 

            }

 

            dither_count3++;

 

         }

 

    }

 

}

 

 

 

/****************************************************** ******************************

// Function name: eint3_isr

// Description    : EINT3 interrupt handler

// Return type: int

// Argument : void

*************************************************** ***************************/

 

void eint3_isr(void)

 

{

 

Irq_Clear(IRQ_EINT3); // Clear interrupt

 

 

 

    if(dither_count3 > 10) //If count is greater than 10, change the LED display

 

    {

 

   dither_count3 = 0; // clear

 

Led_Display(nLed); //led display

 

nLed = ~nLed;

 

}

 

}


Experimental summary:


lg: I have come across interrupts in computer composition and operating systems, and I have a general understanding of them, but they are all theoretical. Through this external interrupt experiment, I feel that theory is connected with practice, and I remember the MASK mentioned in the composition principle. In the experiment, I learned how to register interrupts, enable interrupts, clear interrupts, write to interrupt registers INTMSK, SRCPND, and INTPND, and the three-level jump of interrupt execution, which gave me a deeper understanding of interrupts.


zhy: In this experiment, our group spent a lot of time on connecting the devices. There were few actual code modifications, so we had more time to read the code. The entire interrupt process was implemented in the code, using two important registers: the interrupt pending register (INTPND) and the interrupt mask register (INTMSK). There are reasons for setting it to 0 or 1. This time, the external interrupt was interrupted by pressing a button, and the LED light was turned on at odd and even intervals, which gave a sense of interruption.


wq: The interrupts we learned before were superficial and our understanding was shallow. Through this interrupt experiment, we entered the hardware bottom layer and gained a deeper understanding of the interrupt process in the machine. We also learned the specific functions of registering interrupts, opening interrupts, and clearing interrupts. This external interrupt interrupts the current program by pressing a button, so that the LED light can change the display. Unfortunately, because our group spent too much time connecting to the machine, the experiment time was very short and we did not learn enough.


yy: The subject of this experiment is external interrupts of ARM basic interface. The typical steps of interrupts are: save the scene, switch mode, get the interrupt source, handle the interrupt, and return from the interrupt. I have to say that this experiment is more difficult than before, the code is more obscure to read, and it also involves more knowledge about the underlying layer, but after completing the experiment, I do feel that I have a better understanding of interrupts.


cxy: The content of this experiment is interrupts. I have often heard about interrupts in operating systems and computer composition principles, but I have never really understood the specific implementation of interrupts. This experiment allowed me to understand the details of interrupts.

Keywords:ARM Reference address:ARM basic interface external interrupt experiment

Previous article:ARM interrupt processing
Next article:About s3c2410 interrupt exception handling

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

【ARM】s3c2440 bare metal RTC digital clock
Function Bare metal program to realize LCD display digital clock Main code 1) Background drawing void Brush_ U32 c) {     int x,y ;     for ( y = 0 ; y LCD_HEIGHT ; y++ )     {         for ( x = 0 ; x LCD_WIDTH ; x++ )         {             LCD_BUFFER = c ;         }     } } 2) Text drawing void Draw_Te
[Microcontroller]
【ARM】s3c2440 bare metal RTC digital clock
ARM BIN file disassembly method
When I was debugging the uboot code recently, I used a new version of uboot. The lowlevel_init function was empty, and there was no link to lowlevel_init.o in the link file. I added two lights before and during bl lowlevel_init, and found that the part after bl was not executed, so I wanted to see if the specific prog
[Microcontroller]
ARM assembly learning registers
------------------------------------------------------------- Author :tiger-john WebSite :blog.csdn.net/tigerjb Email : jibo.tiger@gmail.com Update-Time : Monday, February 14, 2011 Tiger Statement: I despise individuals or groups who directly copy my articles without adding the source, but I do not exclude other
[Microcontroller]
ARM assembly learning registers
ARM_S3C2440 interrupt analysis
1. What is an interrupt? An interrupt is when the CPU is running a program normally and, due to internal/external events or events pre-arranged by the program, it interrupts the running program and switches to the interrupt program that serves the internal/external events or pre-arranged events. After the service is c
[Microcontroller]
【ARM bare board】Software interrupt analysis and examples
1. How to switch modes in APP APP generally runs in User Mode and is subject to restrictions (for example, it cannot access hardware) If the APP wants to access the hardware, it must switch modes How to switch? When an exception occurs: Soft interrupt, swi #val Interrupt Undefined instruction exception 2. Soft process
[Microcontroller]
【ARM bare board】Software interrupt analysis and examples
Application of AP2953 in ARM-based netbooks
With the improvement and popularization of network speed, low-priced and long-lasting netbooks are becoming more and more popular among consumers. ARM-based netbooks have attracted the attention of many manufacturers and consumers for their small size, light weight, low cost, low power consumption, long-lasting battery
[Microcontroller]
Application of AP2953 in ARM-based netbooks
Nvidia responds to ARM merger: Exaggerated publicity by outsiders will lead to serious consequences of banning acquisitions
In September 2020, Nvidia announced that it would spend $40 billion to acquire ARM. Due to the surge in NVIDIA's stock price, the actual value of the transaction exceeded $50 billion, or more than 300 billion yuan. However, more than a year has passed, and the hope of acquiring ARM is getting smaller and smaller, and
[Semiconductor design/manufacturing]
Research on Embedded Minimum System Architecture Based on ARM Microcontroller
1. Introduction With the rapid development of embedded related technologies, the functions of embedded systems are becoming more and more powerful, and the application interfaces are becoming richer. Designing specific embedded minimum systems and application systems according to the needs of actual applica
[Microcontroller]
Research on Embedded Minimum System Architecture Based on ARM 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号