2nd program: Use C language to illuminate an LED

Source: Internet
Author: User

  1. A total of three files: head. S LED_ON_C.C Makefile

  2. Head. The contents of s are as follows:
  3. 1 /*2* * Time: 2016year April 8: About: *3 * * location: Dormitory. 4 * * Function: Initialize some hardware related things, call C function. 5 **  6 * * Additional information:7**1, operating Environment: JZ2440V2 Development Board. 8**2, program compilation Environment: UBUNTU9.Ten+ cross-compilation tool ARM-LINUX-GCC. 9**3, the registers used are: Gpfcon, Gpfdat, Wtcon. Ten**4, the pin that the led1 receives is the GPF4 pin.  One */ A  - . equ Wtcon, 0X53000000 @ macro definition Wtcon to 0x53000000 -  the . Text -  - . Global _start -  + _start: - / * Close the watchdog to prevent the CPU from constantly starting. */ + Ldr R0, = Wtcon A     movR1, #0 at     StrR1, [R0] -  - / * Set the stack first before calling the C function. */ -Ldr sp, =4096 -  - / * Call the C function. */ in BL main -  to Halt_loop: +b halt_loop

  4. LED_ON_C.C content is as follows:
  5. 1 /* 2* * Time: 2016year April 8: to: at3 * * location: Dormitory. 4 * * Function: Light the first led:led1. 5 */6 7 #define GPFCON * (volatile unsigned long *) 0x56000050)8 #define GPFDAT * (volatile unsigned long *) 0x56000054)9 Ten intmain (void) One { A / * Configure the GPF4 pin as the output pin. */ -Gpfcon = 0x00000100; -  the / * Let the GPF4 pin output low, light led1. */ -Gpfdat = 0x00000000; -  -while (1); +  -Return0; +}

  6. The contents of the makefile file are as follows:
  7. #
    #时间: April 8, 2016 17:11:09
    #

    Led_on_c.bin:head. S LED_ON_C.C
    Arm-linux-gcc-wall-g-C head. S-o HEAD.O
    Arm-linux-gcc-wall-g-C Led_on_c.c-o LED_ON_C.O
    Arm-linux-ld-ttext 0x00000000-g HEAD.O Led_on_c.o-o led_on_c_elf
    Arm-linux-objcopy-o binary-s led_on_c_elf Led_on_c.bin
    arm-linux-objdump-d-M arm led_on_c_elf > Led_on_c_elf.dis
    arm-linux-objdump-d-B binary-m arm led_on_c.bin > Led_on_c_bin.dis

    Clean:
    Rm-f *.o *.dis *.bin *elf

2nd program: Use C language to illuminate an 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.