Developing ARM bare metal programs under Ubuntu - S3C6410 - LED

Publisher:科技奇才Latest update time:2016-06-06 Source: eefocusKeywords:ubuntu  S3C6410  LED Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
Many people develop ARM bare metal programs in ads, rvds or keil. Although using such development tools is simple, it does not enable developers to master more program principles. If you want to better master more program details, it is better to use arm-linux- for development.

Please indicate the source when reprinting, thank you, Zhang Tonghao: http://blog.csdn.net/muge0913/article/details/15016959

Email: muge0913@sina.com

 

The following is a simple program to light up the LED lamp, running on the tiny6410. The set_peri_port function must be added so that the peripheral space of the s3c6410 can be accessed.

 

@
@ File:led_on.S
@ Function: LED lighting program, light up LED1
@       

.equ		WATCHDOGCON,	0x7e004000
.equ		LEDCON,			0x7f008800
.equ		LEDDAT,			0X7f008808
.text
.global _start
_start:     
			bl		setup_peri_port
			bl		disable_watch_dog
			bl		setup_sp
			bl		display_led
MAIN_LOOP:
            b       MAIN_LOOP



disable_watch_dog:
			@Write 0 to the WATCHDOG register
			ldr r0,=WATCHDOGCON
			mov r1,#0x0
			str r1,[r0]
			mov pc,lr
	
setup_sp:
			@Currently the stack size cannot exceed 8k
			ldr	sp,=1024*8
			mov pc,lr

setup_peri_port:
			ldr r0,=0x70000013		@base addres:0x70000000,size:256MB
			mcr p15,0,r0,c15,c2,4
			mov pc,lr
display_led:
            ldr r0,=LEDCON @ R0 is set to LEDCON, that is, GPKCON0 register. This register
                                    @ Used to select the function of each pin of port K:
                                    @ is output, input, or something else
            mov r1,#0x110000        
            str r1,[r0] @ Set GPK4,5 as output port
            ldr r0,=LEDDAT @ R0 is set to GPKDAT register. This register
                                    @ Used to read/write data of each pin of port B
            mov r1,#0x00000000 @ This value is 0x000000, low level lights up the LED
            str r1,[r0] @ GPK4,5 output 0, LED4,5 lights up
			mov	pc,lr


 

The Makefile is as follows:

 

led_on.bin : led_on.s
	arm-linux-gcc -g -O0 -c -o led_on.o led_on.s
	arm-linux-ld -Ttext 0x0000000 -g led_on.o -o led_on_elf
	arm-linux-objcopy -O binary -S led_on_elf led_on.bin
clean:
	rm -f   led_on.bin led_on_elf *.o
 
Keywords:ubuntu  S3C6410  LED Reference address:Developing ARM bare metal programs under Ubuntu - S3C6410 - LED

Previous article:Jlink debugs ARM bare metal program
Next article:ARM bare metal debugging environment construction under pure Linux (GDB + JLink)

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号