Solution to AVRStudio 6 delay function error

Publisher:CrystalDawnLatest update time:2017-01-05 Source: eefocusKeywords:AVRStudio  6  delay Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

I have been using winavr as the avr development tool before. Versions after AVRstudio 5 directly include the GCCAVR tool chain. The development environment has also changed a lot. Overall, it is still very powerful, so I have been following the version updates. The original program cannot be compiled by directly copying it. The most common error is this:

错误 __builtin_avr_delay_cycles expects an integer constant.   

After searching, it was found that it was caused by the header file version update. The description of line 214 of the delay.h file is as follows:

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.

 

The solution is obvious. The new definition is incompatible with the previous one, so just add define __DELAY_BACKWARD_COMPATIBLE__ before calling the header file.

 

Finally, I have to sigh that AVR is out of date and has no advantages anymore. I don't need to consider 8-bit AVR for future projects. The emulator is still so expensive. Alas.


Keywords:AVRStudio  6  delay Reference address:Solution to AVRStudio 6 delay function error

Previous article:Translated and modified AVR-gcc3.3 makefile. (Usage: make clean /make all)
Next article:CPLD and AVR communication PWM control program

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号