Gpio (2) C program

Source: Internet
Author: User
Gpio (2) C program

@*************************************** ***************************************
@ File: crt0.s
@ Function: transfer it to the C program
@*************************************** ***************************************

. Text
. Global _ start
_ Start:
LDR r0, = 0x53000000 @ watchdog Register address
MoV R1, #0x0
STR R1, [R0] @ write 0, prohibit watchdog, otherwise the CPU will continue to restart

LDR sp, = 1024*4 @ set the stack. Note: it cannot be greater than 4 kb, because the available memory is only 4 kb.
@ The code in NAND Flash will be moved to the internal RAM after the reset. This Ram only has 4 K
BL main @ calls the main function in the C program
Halt_loop:
B halt_loop

 

 

# Define gpbcon (* (volatile unsigned long *) 0x56000010)
# Define gpbdat (* (volatile unsigned long *) 0x56000014)

Int main ()
{
Gpbcon = 0x00015400; // set the GPB5-8 to the output port
// [11: 10] = 0b01, [13: 12] = 0b01,
// [15: 14] = 0b01, [17: 16] = 0b01,
Gpbdat = 0x00000000; // GPB5-8 output 0, led1 light

Return 0;
}

 

 

Use the following command to compile and connect

Arm-Linux-gcc-g-c-o crt0.o crt0.s
Arm-Linux-gcc-g-C-nostdlib-O led_on_c.o led_on_c.c
Arm-Linux-LD-ttext 0x0000000-G crt0.o led_on_c.o-O led_on_c_elf
Arm-Linux-objcopy-O Binary-s led_on_c_elf led_on_c.bin

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.