"Tiny6410 Bare-Metal Program" chapter II: LED Racing Lights RVDS Compact MAIN.C Description _ hardware-related

Source: Internet
Author: User
Tags compact volatile

1. The rewritten procedure requires the following source files: Startup.s retarget_.s fpinit.c vfpinit.s system_.s main.c

2. Also need linker settings file: 6410_scatter.txt (RealView linker select scattered settings);

DRAM 0x5020 0000{
  dode 0x5020 0000 startup.o (Init,+first)
  * (+ro) * (+rw,+zi)
}
Description: Scatter file, also known as a decentralized load description file, which specifies the download and runtime configuration for each zone within the mirrored file. Armlink will produce some area-related symbols based on the scatter file, which is used globally for the user to establish a running environment. The starting address for the code snippet specified in 6410_scatter.txt is 0x5020 0000, the entry target file is STARTUP.O, and the Program Entry section is init, followed by the section containing RO (code and read-only data), RW (read-write variable), and Zi (uninitialized variable).

Note: There is a difference between a C program and a simple assembly; if the simple assembly code we can not select the scattered in the RealView linker and direct the RO address (that is, the code segment address) is compiled and run, but the C language needs the stack, So when there is a C language, the stack space setting must be done by the Assembly before its main function. Therefore, this program needs to compile the assembly part code and set the scattered in the RealView linker.

3. Link configuration file: Option.inc (the SRC directory can be placed, do not need to add to the project);

assembly language Predefined files: RealView assembler.xml (set when predefines in RealView assembler).

4. The following is the first to look at the changes streamlined, MAIN.C

#define LED1_ON ~ (1<<4) #define LED2_ON ~ (1<<5) #define LED3_ON ~ (1<<6) #define LED4_ON ~ (1&lt    &LT;7) #define LED1_OFF (1<<4) #define LED2_OFF (1<<5) #define LED3_OFF (1<<6) #define Led4_off

(1<<7) #define LEDALL_OFF (0xf<<4) typedef unsigned long u32;

#define RGPIOKCON0 (* (volatile u32 *) 0x7f008800) #define RGPIOKDAT (* volatile u32 *) 0x7f008808) void delay (int times);
  int main (void) {u32 uconvalue;
  Uconvalue = rGPIOKCON0; 
  Uconvalue &= ~ (0xffff<<16);    
  Uconvalue |= 0x1111<<16;
  rGPIOKCON0 = Uconvalue;
  Rgpiokdat |= Ledall_off;
    while (1) {Rgpiokdat &= led1_on;
    Delay (1000);

    Rgpiokdat |= Ledall_off;
    Rgpiokdat &= led2_on;
    Delay (1000);

    Rgpiokdat |= Ledall_off;
    Rgpiokdat &= led3_on;
    Delay (1000);

    Rgpiokdat |= Ledall_off;
    Rgpiokdat &= led4_on;
    Delay (1000);
  Rgpiokdat |= Ledall_off;
  } void delay (int times) {int i; For(; times>0;times--) for (i=0;i<3000;i++); }
=============================================================================================================== =====================

The following are problems you may encounter:

First, the basic C problem

Compilation error: expected an expression

Reason:

#define RGPIOKCON0 (* (volatile u32 *) 0x7f008800);
#define RGPIOKDAT (* (volatile u32 *) 0x7f008808)
Second, the link library (assembly part) compilation problem

link library compilation error: Bad symbol ' Vic_mode '

Reason:

The Debug Settings tab under the Project menu; the Predefines->import Panel under the RealView Assembler (assembly language setting) under Language settings,

Select the following file: RealView assembler.xml

<?xml version= "1.0" encoding= "UTF-8" standalone= "yes"?> <?codewarrior "exportversion=" 1.0 "5.5"? > <! DOCTYPE Exportedpanel [<! ELEMENT Exportedpanel (NAME, settinglist| VALUE) > <! ELEMENT settinglist (setting+) > <! ELEMENT SETTING (NAME?, value| ( setting+)) > <! ELEMENT NAME (#PCDATA) > <! ELEMENT VALUE (#PCDATA) >]> <EXPORTEDPANEL> <NAME>Panel_for_armasm</NAME> <settinglist > <SETTING><NAME>Panel_for_armasm</NAME> <setting><name>version</n Ame><value>261</value></setting> <setting><name>created By</NAME><VA Lue>realview assembler</value></setting> <setting><name>modified by</NAME>&lt ; Value>realview assembler</value></setting> <setting><name>tool name</NAME>&lt ;
Value>armasm</value></setting>            <setting><name>arguments</name><value>--debug--keep--cpu=ARM1176JZF-S--predefine= "V Ic_mode SETA 1 "--predefine=" USE_TCM SETA 1 "</VALUE></SETTING> </SETTING> &LT;/SETTINGLIST&G
T </EXPORTEDPANEL>
Third, the program runs the problem, is also the stack set incomplete problem

Link libraries are as follows: FPINIT.O startup.o retarget_.o system_.o vfpinit.o MAIN.O

The following document: Fpinit.c startup.s retarget_.s system_.s vfpinit.s main.c

Iv. non-implementation of procedures

If you do not select scattered in RealView linker and directly in simple to give the RO address (that is, the code segment address) compiled, the source file only MAIN.C, you can also compile through. However, when running in the Development Board from the RVDS single Step debugging, the program code is not implemented. The reason is simple: just as the Java language runtime requires the Java virtual machine as a prerequisite, C cannot run without the previous set of stacks.

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.