What did I do when I started the AVR application (head. s)

Source: Internet
Author: User

Because our firmware does not want to use the C library, the linker script and C-runtime both need to be written by themselves, but they have not been written yet. It is nothing more than a few lines of the C library. There is nothing to say, so we will write the main record of the avr c-runtime:

 

1. set the interrupt vector table (vector), which is defined in Datasheet. Each chip is different, and the number of vectors is also different. To achieve this purpose, a vector of more than 100 is defined here, in fact, a separate chip defines _ vectors_size to control the number of vectors in the end;

 

2. Default interrupt handler. When the user does not register the interrupt handler, it points to the default handler. The default handler is reset;

 

3. initialize some registers, such as clearing;

 

4. initialize the. Data Segment and copy data from flash to ram;

The initialization of 4.1 heap is useless and will not be performed;

4.2 stack Address Settings (can be passed in externally );

 

5. initialization. BSS segments are cleared. This is the function of libgcc. It directly decomassembles a program compiled with aVR-libc and copies several calls, such as _ do_clear_bss. After this, it jumps to main ();

 

6. Jump to main (). In fact, the jump will be completed in step 5, which is not needed here.

 

We have just been in touch with AVR for a few days, but we have not seen the details. We have not understood many things and can leave the C library. Compiling and running are the first steps that have been completed successfully.

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.