S3c2410 bare board programming introduction --- single button (I)

Publisher:RadiantJourneyLatest update time:2019-12-24 Source: elecfansKeywords:S3c2410 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

That's a bit of an introduction. Okay, let's start learning something a little more complicated and write a single-button program.


Some people may laugh, this is complicated? Indeed, it is relatively simple to have only one button, but the key is that we need to use this button to lead to the interrupt processing part, which is more core. Interrupts are one of the most important parts of learning a CPU.


This time we will use the initialization file provided by realview and learn to configure it by ourselves (we will write it by ourselves in the future). Then we will complete the function of triggering an interrupt processing function once a key is pressed. How to judge whether an interrupt is triggered? Didn’t we write a serial port program? Once an interrupt occurs, the serial port sends data to the PC.


1 Configuration (configuration corresponding to s3c2410a.s):


I'll take a few screenshots later, as I don't have any screenshot tools at hand right now.


2 Several snippets from s3c2410a.s, focusing on the interrupts.


159IntVT_SETUP

 EQU

 1

 160IntVTAddress

 EQU

 0x33FFFF20

...........


795

 AREA

 RESET

,

CODE

,

READONLY

 796

 ARM

799; Exception Vectors

 800; Mapped to Address 0.

 801; Absolute addressing mode must be used.

 802; Dummy Handlers are implemented as infinite loops which can be modified.

 803

 804Vectors

 LDR

 PC

,

Reset_Addr

 805

 LDR

 PC

,

Undef_Addr

 806

 LDR

 PC

,

SWI_Addr

 807

 LDR

 PC

,

PAbt_Addr

 808

 LDR

 PC

,

DAbt_Addr

 809

 NOP

 ; Reserved Vector

 810

 LDR

 PC

,

IRQ_Addr

 811

 LDR

 PC

,

FIQ_Addr

813

 814

 IF

 IntVT_SETUP

<>

0

816;Interrupt Vector Table Address

 817HandleEINT0

 EQU

 IntVTAddress

 818HandleEINT1

 EQU

 IntVTAddress

+

4

 819HandleEINT2

 EQU

 IntVTAddress

+

4

*

2

 820HandleEINT3

 EQU

 IntVTAddress

+

4

*

3

 821HandleEINT4_7

 EQU

 IntVTAddress

+

4

*

4

 822HandleEINT8_23

 EQU

 IntVTAddress

+

4

*

5

 823HandleReserved

 EQU

 IntVTAddress

+

4

*

6


850IRQ_Entry

 851

 sub

 sp

,

sp

,

#4 ;reserved for PC

 852

 stmfd

 sp!,{r8-r9} ; backup r8 r9

 853

 854

 ldr

 r9

,=

INTOFFSET ; interrupt offset

 855

 ldr

 r9

,[

r9

]

856

 ldr

 r8

,=

HandleEINT0; Get the base address of the interrupt handling function address

 857

 add

 r8

,

r8

,

r9

,

lsl

 #2; Get the actual interrupt handling function address based on the base address and offset

 858

 ldr

 r8

,[

r8

]

859

 str

 r8

,[

sp

,

#8]

 860

 ldmfd

 sp!,{r8-r9,pc}; Modify the pc pointer and jump to the secondary interrupt processing function

 861

 862

 ENDIF

 863

 864Reset_Addr

 DCD

 Reset_Handler

 865Undef_Addr

 DCD

 Undef_Handler

 866SWI_Addr

 DCD

 SWI_Handler

 867PAbt_Addr

 DCD

 PAbt_Handler

 868DAbt_Addr

 DCD

 DAbt_Handler

 869

 DCD

 0

 ; Reserved Address

 870IRQ_Addr

 DCD

 IRQ_Handler

 871FIQ_Addr

 DCD

 FIQ_Handler

 872

 873Undef_Handler

 B

 Undef_Handler

 874SWI_Handler

 B

 SWI_Handler

 875PAbt_Handler

 B

 PAbt_Handler

 876DAbt_Handler

 B

 DAbt_Handler

 877

 878

 IF

 IntVT_SETUP

<>

1

 879IRQ_Handler

 B

 IRQ_Handler

 880

 ENDIF

 881

 882

 IF

 IntVT_SETUP

<>

0

 883IRQ_Handler

 B

 IRQ_Entry

 884

 ENDIF

 885

 886FIQ_Handler

 B

 FIQ_Handler

It can be seen that when the irq interrupt is triggered, the cpu automatically saves the cpsr to the spsr and sets the pc pointer to 0x18. After LDR PC, IRQ_Addr, IRQ_Handler B IRQ_Entry, two jumps, it finally jumps to IRQ_ENTRY, which is actually the first-level interrupt processing function. The function of the first-level interrupt processing function is to check the address of its processing function according to the interrupt offset register. Please see the comments in the code.


Because I pasted the code using HTML, it told me that the article was too long, so I had to open a new article.

Keywords:S3c2410 Reference address:S3c2410 bare board programming introduction --- single button (I)

Previous article:S3c2410 bare board program introduction --- serial port
Next article:Read ARM Memory (L1/L2/MMU) notes

Recommended ReadingLatest update time:2024-11-15 07:41

S3C2410 LCD
1. Turn on the LCD backlight Set the GPIO corresponding to the LCD backlight to disable pull-up (write 1 to the corresponding bit of GPxUP), select the output type (write 01 to the corresponding bit of GPxCON), and output to high level (write 1 to the corresponding bit of GPxDAT). 2. Turn on the LCD power You can s
[Microcontroller]
S3C2410/S3C2440 NAND flash working principle
        The addressing method of NAND Flash is closely related to the memory organization of NAND Flash. The data of NAND Flash is stored in the memory cell in the form of bits. Generally speaking, only one bit can be stored in a cell. These cells are connected into bit lines in units of 8 or 16, forming the so-called
[Microcontroller]
NAND flash boot of S3C2410X
S3C2410X has two boot modes: NOR flash boot and NAND flash boot. NOR flash boot: NOR flash can be read randomly like SDRAM, and the reading speed is fast. It can not only store programs, but also run programs. When the power is on, NOR flash is mapped to address 0x0, and the program can be executed from the first state
[Microcontroller]
NAND flash boot of S3C2410X
Design of digital image system for assisting reverse driving based on S3C2410
1. Introduction  According to statistics, traffic accidents caused by blind spots behind vehicles account for about 30% in China and 20% in the United States. The first two generations of reversing assistance products are reversing horns and reversing radars. The former can only remind passers-by to dodge on their o
[Microcontroller]
Design of digital image system for assisting reverse driving based on S3C2410
How to access IO ports in S3c2410 LINUX
In the ARM architecture, a driver module is required to access IO. The request_mem_region() function can be used to request IO memory during module initialization, and then the ioremap() function can be used to remap the obtained IO memory. For example, to control the LED display of s3c2410, use the GPF port and you c
[Microcontroller]
SDRAM-MEMORY CONTROLLER
Focus on analyzing the memory mapping of s3c2410 after reset and its application. 1. Basic Configuration     EDUKIT-III adopts the design of core daughter board plus expansion board. I am learning ARM9, so I use the core daughter board of s3c2410. The core daughter board resources are as follows:       MCU      : S3
[Microcontroller]
Linux (ARM-S3C2410) kernel tick timer driver
/*===============================================================*/                                             Dependent on the hardware platform /*=============================================================================*/ 1):arch/arm/plat-s3c24xx/time.c    static void __init s3c2410_timer_init (void)    {
[Microcontroller]
Porting standard Linux operating system to S3C2410
    1 Introduction     At present, embedded processors based on ARM core have become the mainstream in the embedded system market. With the widespread application of ARM technology, the establishment of embedded operating systems for ARM architecture has become a hot topic in current research. S3C2410 is a 16/32-bit e
[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号