OK6410-led Light control based on SD card for bare metal development

Source: Internet
Author: User

In the previous article, the installation of the SD card's bare-metal development environment and the OK6410 start-up settings were mentioned, and this chapter began to enter the blinking control of the LED lights.

1, first open the OK6410 Development Board schematic diagram, find led and other control schematic parts, such as 1 shown.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/7F/9D/wKiom1ck2dLi84vGAAB3zB129Fg191.png "title=" Untitled. png "alt=" Wkiom1ck2dli84vgaab3zb129fg191.png "/>

Fig. 1 Schematic diagram of LED light control

As shown in Figure 1, the CPU PIN for the control LED lamp is nled1~nled4,nled1~nled4 corresponding to the CPU Pin name GPM0~GPM3 (CPU schematics not given).

2, write the procedure Led.s, the following directly give Led.s source code.

. globl _start

_start:

/* Hardware-related Settings */

Ldr R0, =0x70000000

Orr R0, R0, #0x13

MCR p15,0,r0,c15,c2,4 @ 256M (0X70000000-0X7FFFFFFF)

/* off watchdog */

/* Write to Wtcon (0x7e004000) 0 */

Ldr R0, =0x7e004000

mov r1, #0

str R1, [R0]

/* Set Gpmcon let GPM0/1/2/3 as output pin */

LDR R1, =0x7f008820

Ldr R0, =0x1111

str r0, [R1]


/* Set Gpmdat */

LDR R1, =0x7f008824

Loop

/* Set Gpmdat let GPM0/1/2/3 as output high level 1,led light all out */

mov r0, #0x0f

str r0, [R1]

/* Time delay */

BL delay

/* Set Gpmdat let GPM0/1/2/3 as output high-level 0,led light full light */

mov r0, #0

str r0, [R1]

/* Time delay */

BL delay

/* Dead Loop */

B Loop


/* Delay subroutine */

Delay

LDR R2, =0XFFFFFF

Delay_loop:

Sub R2, R2, #1

CMP R2, #0

bne Delay_loop

mov pc, LR

3. CP15 co-processor instruction description

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M00/7F/A1/wKiom1cmGbKDzx7yAAESU7cNDzc489.png "title=" Untitled 1.png "alt=" Wkiom1cmgbkdzx7yaaesu7cndzc489.png "/>

ARM11 the memory and peripheral interface, the above red Dash code in the initialization is to tell the CPU peripheral registers the base address and address empty room .

Register format:

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M01/7F/A1/wKiom1cmHC_AH9OZAAA-T7T-MJA439.png "title=" Untitled 2.png "alt=" Wkiom1cmhc_ah9ozaaa-t7t-mja439.png "/>

View the SC6410 's chip manual to see the base address of the peripheral addresses as 0x70000000, as shown in:

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M01/7F/9F/wKioL1cmHrWAbVeuAADEaoX-1XM643.png "title=" Untitled 3.png "alt=" Wkiol1cmhrwabveuaadeaox-1xm643.png "/>

4. Gpio instruction Description

LED using the Gpio port for GPM0~GPM3, view the chip manual, and GPM related registers mainly under the three registers, as shown in;

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/7F/A1/wKiom1cmHsvAVRfxAAEwOcPju-Y919.png "title=" Untitled 4.png "alt=" Wkiom1cmhsvavrfxaaewocpju-y919.png "/>

The Gpmcon is a port mode register, where the port mode is set to the output mode;

The Gpmdat register is an IO data register, and each bit corresponds to the corresponding IO port, and the LED flicker function only needs to write 0 or write 1 to the register at a fixed time interval;

5, program compilation makefile

Makefile file into the following:

CC = ARM-LINUX-GCC

LD = Arm-linux-ld

Objcopy = Arm-linux-objcopy

CFLAGS =-c-o

Ldflags =-E _start-ttext 0x0c000000-o


Led.bin:led.elf

$ (objcopy)-o binary $< [email protected]

Led.elf:start.o

$ (LD) $ (ldflags) [email protected] $<


Start.o:start. S

$ (CC) $ (CFLAGS) [email protected] $<


Clean

RM *.o Led.elf Led.bin

Input make, compile to generate Led.bin burn write file

6, program Burn Write

Copy the Led.bin file generated by the previous action to the Windows environment and use the Winhex software to write the program.

A. Open the Winhex software, the version used here is Winhex 15.1 SR-8, while inserting the SD card, the software opens the interface as shown:

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M01/7F/9F/wKioL1cmJAOSOYKIAADdyEmYkuQ542.png "title=" Untitled 5.png "alt=" Wkiol1cmjaosoykiaaddyemykuq542.png "/>

B. Open the SD card, as shown in the following:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/7F/9F/wKioL1cmJMfTDmx3AAE5pzpiUuM236.png "title=" Untitled 6.png "alt=" Wkiol1cmjmftdmx3aae5pzpiuum236.png "/>

C. Open the Led.bin file as shown in:

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M01/7F/A1/wKiom1cmJPOQPEdrAAEh_BsAOCQ665.png "title=" Untitled 7.png "alt=" Wkiom1cmjpoqpedraaeh_bsaocq665.png "/>

D. Write the copied content to the location of the specified SD card, in the following steps:

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M02/7F/A1/wKiom1cmJfzz_nmzAAGErAtNcZc872.png "title=" Untitled 8.png "alt=" Wkiom1cmjfzz_nmzaageratnczc872.png "/>

E. When finished, insert the SD card into the SD card slot of the development Board, then power on and the LED will blink continuously.






This article is from the "Gavin" blog, make sure to keep this source http://gavin2.blog.51cto.com/1703264/1769427

OK6410-led Light control based on SD card for bare metal development

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.