|
发表于 2012-2-16 20:32:56
|
显示全部楼层
看CVAVR的HELP,不过你必须具备更多的基础,否则看不懂的。
简单贴上一点载录:
关于Data Stack
The Data Stack area is used to dynamically store local variables, passing function parameters and saving registers during interrupt routine servicing:
· standard core: R0, R1, R15, R22, R23, R24, R25, R26, R27, R30, R31 and SREG
· reduced core: R16, R17, R22, R23, R24, R25, R26, R27, R30, R31 and SREG.
The Data Stack Pointer is implemented using the Y register.
At start-up the Data Stack Pointer is initialized with the value 5Fh (or FFh for some chips)+Data Stack Size.
When saving a value in the Data Stack, the Data Stack Pointer is decremented.
When the value is retrieved, the Data Stack Pointer is incremented back.
When configuring the compiler, in the Project|Configure|C Compiler|Code Generation menu, you must specify a sufficient Data Stack Size, so it will not overlap the I/O Register area during program execution.
要自己定义它的值的话,是高手做的事情
关于delay函数
These functions are intended for generating delays in C programs.
The prototypes for these functions are placed in the file delay.h, located in the .\INC subdirectory. This file must be #include -d before using the functions.
Before calling the functions the interrupts must be disabled, otherwise the delays will be much longer then expected.
Also it is very important to specify the correct AVR chip Clock frequency in the Project|Configure|C Compiler|Code Generation menu.
The functions are:
void delay_us(unsigned int n)
generates a delay of n mseconds. n must be a constant expression.
void delay_ms(unsigned int n)
generates a delay of n milliseconds.
This function automatically resets the wtachdog timer every 1ms by generating the wdr instruction.
1.这两个函数是CVAVR提供的内部函数,在CVAVR中没有C的原代码,只提供二进制的执行代码库。你一旦调用,连接时会加入到你的执行代码中的。
2.这个delay是采用软件延时的。
3.如果要看代码,可以看编译连接后的反汇编代码,看到的是汇编代码(一个子程序调用)
4.go to definition/declaration是看你自己的定义声明,两个函数系统的定义声明在DELAY.H中,它在CVAVR系统的\INC下面。你#include就是表示声明了,但go to definition/declaration是不看的
5.DELAY.h 的声明如下,就是几行:
// CodeVisionAVR C Compiler
// (C) 1998-2000 Pavel Haiduc, HP InfoTech S.R.L.
#ifndef _DELAY_INCLUDED_
#define _DELAY_INCLUDED_
#pragma used+
void delay_us(unsigned int n);
void delay_ms(unsigned int n);
#pragma used-
#endif |
|