S3C2440 development board uses external interrupts to implement button switching of different functions

Publisher:落霞与孤鹜Latest update time:2019-11-06 Source: 51heiKeywords:S3C2440 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere


#include "def.h"

#include "option.h"

#include "2440addr.h"

#include "mmu.h" 

#include "stdio.h"


/*Interrupt processing function Press different buttons to enter the interrupt processing, and start different functions according to the different buttons pressed to realize the button functions of the function control panel*/

void __irq Eint_Isr(void)

{

  switch(rEINTPEND)

  {

    case 1<<13: //Function 1 starts and function 2 is turned off at the same time

         rGPBDAT=0<<6|1<<7;

         rEINTPEND=1<<13; //Wait for the next interrupt to enter

         break;

    case 1<<14: //Function 2 starts and function 1 is turned off at the same time

         rGPBDAT=1<<6|0<<7;

         rEINTPEND=1<<14; //Wait for the next interrupt to enter

         break;

    case 1<<8: //Close functions 1 and 2

         rGPBDAT=1<<6|1<<7;

         rEINTPEND=1<<8; //Wait for the next interrupt to enter

         break;

    default:

         rGPBDAT=1<<6|1<<7;

         break;

  }

  ClearPending(BIT_EINT8_23); //Wait for the next interrupt in this interrupt vector to arrive

}


/*Set the default function after startup*/

void Led_on()

{

     //Set up the LED light

   rGPBCON=0x155555; //Set GPB to output 

   rGPBDAT=(0x1<<6)|(0x1<<7); //GPB7 pin is set, LED is off

}



/*Set button trigger mode*/

void Eint_func()

{

   //Key interrupt source settings

   rGPGCON=(rGPGCON&~((0x3<<0)|(0x3<<10)|(0x3<<12)))|(0x1<<1)|(0x1<<11)|(0x1<<13); //Set GPG0, 5, 6 pins to EINT8, 13, 14

   rGPGUP|=(0x1<<0)|(0x1<<5)|(0x1<<6); //Pin uses the second function

   rEXTINT1=rEXTINT1&~(0x7<<0);//|(0x1<<2); //Button 1 is set to low level edge trigger

   rEXTINT1=rEXTINT1&~(0x7<<20);//|(0x1<<22); //Button 2 is set to low level edge trigger

   rEXTINT1=rEXTINT1&~(0x7<<24);//|(0x1<<26); //Button 3 is set to low level edge trigger

}

                             

/*Interrupt initialization*/

void Eint_init()

{

   rEINTMASK=rEINTMASK&~((0x1<<8)|(0x1<<13)|(0x1<<14)); // Enable external interrupt mask, do not mask interrupt when it is 0

   /*Set up interrupt controller*/

   rINTMOD&=~BIT_EINT8_23; //Set the interrupt mode to IRQ

   rINTMSK&=~BIT_EINT8_23; //Start interrupt enable

}



/*Interrupt pending, waiting for interrupt*/

void Eint_wait()

{

   rSRCPND=rSRCPND; //Interrupt pending register clear

   rINTPND=rINTPND; //Interrupt source pending register clear

   rEINTPEND|=(0x1<<8)|(0x1<<13)|(0x1<<14); //External interrupt suspend register, Eint13 suspends waiting for interrupt

   rSRCPND=BIT_EINT8_23; //Interrupt source pending register corresponding position 1 waiting for interrupt

   rINTPND=BIT_EINT8_23; //Interrupt pending register corresponding position 1 waiting for interrupt

}



/*Set interrupt pointer*/

void Eint_p()

{

   pISR_EINT8_23 =(U32)Eint_Isr; //Set interrupt to Eint11 response

}



/*Main program starts*/

void Main()

{

// isr_asm(); // Enable the I bit of the CPSR register

   Led_on(); //Turn off the LED at startup

   Eint_init(); //Interrupt initialization

   Eint_func(); //Interrupt trigger status initialization

   Eint_wait(); //Wait for interrupt

   Eint_p(); //Interrupt pointer

}


Keywords:S3C2440 Reference address:S3C2440 development board uses external interrupts to implement button switching of different functions

Previous article:S3C2440 external interrupt response register setting method
Next article:S3C2440 processor UART dedicated registers

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

S3C2440 address space allocation and startup process
1. Allocation of S3C2440 address space 1. The memory controller of s3c2440A has the following features: l Big and small endian (selected by software) l Address space: 128M bytes per bank (1G bytes/8 banks in total) l Programmable access bit width, bank0 (16/32 bits), other banks (8/16/32 bits) l A total of 8
[Microcontroller]
S3C2440 address space allocation and startup process
s3c2440 bare metal-I2c programming-2.i2c controller
1.The relationship between I2c master control and slave device   For write operations, the master acts as a transmitter and the slave device acts as a receiver. For read operations, the master acts as a receiver and the slave acts as a transmitter. 2.I2c controller 2.1 General block diagram   Pclk = 50Mhz, after div
[Microcontroller]
s3c2440 bare metal-I2c programming-2.i2c controller
S3C2440 DMA driver writing and testing (32)
DMA (Direct Memory Access) That is, direct storage access. The DMA transmission method does not require the CPU to directly control the transmission. It opens a direct data transmission path for RAM and I/O devices through hardware, which can greatly improve the efficiency of the CPU. After learning so many driver
[Microcontroller]
S3C2440 DMA driver writing and testing (32)
Understanding of link address 0x30008000 (S3C2440)
When we write the linker script, we will set the starting link address of the code segment to 0x30008000 (S3C2440). If you misunderstand the link address, you may encounter problems like mine. Q: The link address written in the gboot linker script is actually 0x30008000 in the memory. When the cross-tool is used to
[Microcontroller]
s3c2440 bare metal-I2c programming-1.i2c protocol
 1.Hardware circuit The I2C bus is a simple, bidirectional two-wire synchronous serial bus developed by Philips. As shown below: SDA (serial data line) and SCL (serial clock line) are bidirectional I/O lines and need to be connected to the power supply VCC through a pull-up resistor. When the bus is idle. Both lines a
[Microcontroller]
s3c2440 bare metal-I2c programming-1.i2c protocol
How to determine the address space used by peripherals
The S3C2410/S3C2440 storage controller has the following features: 1. The address space of each BANK is 128MB, totaling 1GB (8 BANKs); 2. Programmable control bus width (8/16/32-bit), but BANK0 can only choose two bit widths (16/32-bit); 3. There are 8 banks in total, BANK0~BANK5 can support external ROM, SRAM,
[Microcontroller]
How to determine the address space used by peripherals
05-S3C2440 learning kernel (porting) linux3.4.2 porting (3) support DM9000C network card and modify support serial port 2
We have previously cut and transplanted the linux3.4.2 kernel http://blog.csdn.net/fengyuwuzu0519/article/details/70162666 I also learned how to port the DM9000C network card driver to the linux2.2.26 kernel http://blog.csdn.net/fengyuwuzu0519/article/details/72821567 Next, based on this, we transplant the DM9000c
[Microcontroller]
05-S3C2440 learning kernel (porting) linux3.4.2 porting (3) support DM9000C network card and modify support serial port 2
Touch screen driver on S3C2440
Create the touch screen driver my2440_ts.c, first implement the loading and unloading parts. In the driver loading part, we mainly do the following: enable the clock required by ADC, map IO ports, initialize registers, apply for interrupts, initialize input devices, and register input devices to the input subsystem. T
[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号