How can I define time integer constan ?

Go To Last Post
3 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Guys,

How can I define time integer constan ?

I define my function :

void tone(int freq,int wait)
{
	OCR1A=freq;
	_delay_ms(wait);
}

when I call :

tone(0,1000);

I got :

Error 7 __builtin_avr_delay_cycles expects a compile time integer constant c:\program files (x86)\atmel\atmel toolchain\avr8 gcc\native\3.4.2.939\avr8-gnu-toolchain\bin\../lib/gcc/avr/4.7.2/../../../../avr/include/util/delay.h 164 28 main_buzzer

Any ideas on how to rectify it ?

thanks

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

_delay_ routine requires a constant. Create a for loop that loops _delay_ms(1) for "wait" times instead.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
Any ideas on how to rectify it ?

An error message is often a very good search term, since others with the same problem has probably quoted the error message verbatim.

Google this: "__builtin_avr_delay_cycles expects a compile time integer constant site:www.avrfreaks.net".

https://www.avrfreaks.net/index.p...
https://www.avrfreaks.net/index.p...
https://www.avrfreaks.net/index.p...
https://www.avrfreaks.net/index.p...
https://www.avrfreaks.net/index.p...
.
.
.

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]