s3c2440——Key interrupt

Publisher:脑力激荡Latest update time:2023-09-25 Source: elecfansKeywords:s3c2440 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Exception vector table for s3c2440:

The IRQ interrupt address is 0x18. Therefore, based on the previous exception handling method, we write the startup file:

Why do you need to reduce lr by 4? You can refer to this article: http://blog.csdn.net/zzsfqiuyigui/article/details/23334177

This is to ensure that when the CPU is executing an instruction and is interrupted by an interrupt, when the interrupt returns, the interrupted instruction must continue to be executed. If 4 is not subtracted, the CPU will be interrupted after processing the interrupt. If the next instruction following the interrupted instruction starts executing (because lr_irq saves the address of the next instruction executed), the execution of the interrupted instruction will be lost. Therefore, it is important to save the return address after the interrupt is processed. .


void handle_irq_c(void)

{

    /* Identify interrupt source*/

    int bit = INTOFFSET;


    /* Call the corresponding processing function */

    irq_array[bit](bit);

    

    /* Clear interrupt: start clearing from source */

    SRCPND = (1<    INTPND = (1<}


 

 Button schematic diagram:

Corresponding offset: 0,2,5

irq_array[bit](bit);

Let’s not talk about this function pointer array first, let’s talk about the subsequent clearing operation first.

Since we have different requests from the same source, the corresponding bit of the SRCPND register needs to be cleared.

The clearing operation is just to write a value to this register (because the chip manual says so), here we use the method of writing 1.

 

This is also consistent with the clearing sequence of our program. To clear the interrupt pending bit, we still write 1.
Now let’s talk about this array of function pointers:
[object Object]

If I don't use this function pointer array, it will be very troublesome when I write another interrupt service function. I need to add a lot of code to the handle_irq_c function in the startup file. But after we adopt the C language skills, we can easily There are many introductions. It can also be seen that C language skills are very important for our code encapsulation.


Keywords:s3c2440 Reference address:s3c2440——Key interrupt

Previous article:One of the seven modes of S3C2440 - undefined mode (remove bl print1 bug to solve)
Next article:s3c2440 code relocation and introduction of segments - apply what you have learned and practice comprehensive Makefile

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号