h4breeze 发表于 2012-1-24 18:26:38

cvavr中RAM下的Data Stack size是指什么,还没查出来

马老师书的例子好像都是256吧,这个值应该设为多少好呢?根据什么原则呢?
还有个问题,我用cvavr不能go to definition/declaration啊,到现在还没查到delay_ms()函数在哪儿申明的。。。唉。。。
http://cache.amobbs.com/bbs_upload782111/files_51/ourdev_714350FNVZEK.jpg
(原文件名:1.jpg)
它这里go to definition/declaration这个选项卡都已经激活了的啊,那说明应该可以定位的嘛

machao 发表于 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 andSREG
·      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

Cybers 发表于 2012-7-24 08:33:52

学习中,谢谢马老师的讲解!
页: [1]
查看完整版本: cvavr中RAM下的Data Stack size是指什么,还没查出来