打印
[Atmel]

Atmel Studio 6中延时函数错误的解决方法

[复制链接]
876|3
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
ji7423|  楼主 | 2015-2-26 17:22 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
错误 __builtin_avr_delay_cycles expects an integer constant.

经过查找发现是头文件版本更新所致。delay.h文件214行说明如下:

Note: The new implementation of _delay_us(double __us) with

__builtin_avr_delay_cycles(unsigned long) support is not backward compatible.

User can define __DELAY_BACKWARD_COMPATIBLE__ to get a backward compatible delay.

Also, the backward compatible

algorithm will be chosen if the code is compiled in a freestanding

environment (GCC option \c -ffreestanding), as the math functions

required for rounding are not available to the compiler then.

这样解决方法就明显了,新的定义和之前的不兼容,

因此调用延时文件#include 之前加入#define __DELAY_BACKWARD_COMPATIBLE__ 即可。

例如:

#define F_CPU 8000000UL

#include

#define __DELAY_BACKWARD_COMPATIBLE__

#include


相关帖子

沙发
sssha| | 2015-2-26 17:28 | 只看该作者
路过~

使用特权

评论回复
板凳
ddllxxrr| | 2015-2-26 20:36 | 只看该作者
楼主写的不错,顶一下

使用特权

评论回复
地板
catking25| | 2015-2-26 22:11 | 只看该作者
感谢楼主分享!

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

10

主题

401

帖子

0

粉丝