Embedded Linux bare Metal Development (i)--light LED

Source: Internet
Author: User

Embedded Linux Bare Metal Development (i)--light Led

Development Board: Friendly arm smart210

First, Circuit Diagram Inspection 1. Floor circuit diagram

Consult the Board circuit diagram of the development boards, consult the LED related parts

LED Circuit Working principle:

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M01/82/5E/wKioL1dSyoCwaSpsAAAbV0ZVsno967.png "title=" Picture 1.png "alt=" Wkiol1dsyocwaspsaaabv0zvsno967.png "/>

The positive electrode of the LED is connected to 3.3V, the cathode is grounded, and LED is illuminated.

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/82/5F/wKiom1dSyZeChSxmAABFJfhHZso637.png "title=" Picture 2.png "alt=" Wkiom1dsyzechsxmaabfjfhhzso637.png "/>

Development Boards Total four PCs led, positive connection 3.3V, negative connector to the LED1_LED4 pin of the development Board, if the LED light is required to enter the low level.

2. Core Board circuit diagram

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/82/5E/wKioL1dSyrmjXqYzAADTf__16yU234.png "title=" Picture 3.png "alt=" Wkiol1dsyrmjxqyzaadtf__16yu234.png "/>

Check the core Board circuit diagram, The LEDs are lit when the led1-led4 is connected to the gpj2_0-gpj2_3 of the SOC and the corresponding GPIO PIN output level is low by controlling the registers of the gpj2_0-gpj2_3.

Second, SoC Manual Review

Check the dadasheet:s5pv210_um_rev1.1 documentation for the Samsung S5PV210 Soc, Gpio is located in the Gpio section of the Section2-system section of the document, looking for gpj2_0-gpj2_3 corresponding registers, get gpj2_0- Gpj2_3 the corresponding register address and configuration parameters.

Gpj2con  = 0xe0200280 set to 0001 = Output Way

Gpj2dat  = 0xe020028 4 set bit0-bit3 to Low, or 0

Third, Program Implementation

Start. s source file:

#define GPJ2CON 0xe0200280

#define GPJ2DAT 0xe0200284

. Global _start

_start:

set gpj2con

LDR r0,=0xe0200280//gpj2con

LDR r1,=0x00001111// set led1--led4 to output

Str R1,[r0] // set Gpj2con to 0x00001111

LED Flashing

Led_blink:

LDR r0,=0xe0200284//gpj2dat

Ldr r1,= (0<<0 | 0<<1 | 0<<2 | 0<<3)//led1--led4 lit

STR R1,[R0]

BL Delay // delay

LDR r0,=0xe0200284

Ldr r1,= (1<<0 | 1<<1 | 1<<2 | 1<<3)// close led1--led4

STR R1,[R0]

BL Delay // delay

LDR r0,=0xe0200284

Ldr r1,= (0<<0 | 1<<1 | 1<<2 | 1<<3)// light led1, other off

STR R1,[R0]

BL Delay // delay

LDR r0,=0xe0200284

Ldr r1,= (1<<0 | 0<<1 | 1<<2 | 1<<3)// light led2, other off

STR R1,[R0]

BL delay

LDR r0,=0xe0200284

Ldr r1,= (1<<0 | 1<<1 | 0<<2 | 1<<3)// light led3, other off

STR R1,[R0]

BL delay

LDR r0,=0xe0200284

Ldr r1,= (1<<0 | 1<<1 | 1<<2 | 0<<3)// light led4, other off

STR R1,[R0]

BL delay

b led_blink // circulating water lamp

Delay Function

Delay

LDR R2,=0X1FFFFFF

LDR r3,=0x0

Loop

Sub R2,r2, #1

CMP R2,R3

BNE Loop

MOV PC,LR

. end

Makefile:

Led.bin:start.o

Arm-linux-ld-ttext 0x0-o led.elf $^

Arm-linux-objcopy-o binary led.elf Led.bin

arm-linux-objdump-d led.elf > Led_elf.dis

GCC Mkv210_image.c-o mkmini210

./mkmini210 Led.bin smart210 . Bin

%.O:%. S

Arm-linux-gcc-o [email protected] $<-C

%.O:%.c

Arm-linux-gcc-o [email protected] $<-C

Clean

RM *.o *.elf *.bin *.dis–f

after compiling, use the tool to Smart210.bin Burn to sd card, SD card inserted into the development Board, switch to SD card boot mode, start the Development Board can see four led first full light, after all out, then led1-led4 respectively lit, so cycle.

Description: mkv210_image.c compile the resulting mkmini210 Tools for making SD image.


This article from "Endless life, Struggle not only" blog, please be sure to keep this source http://9291927.blog.51cto.com/9281927/1786139

Embedded Linux bare Metal Development (i)--light LED

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.