How can I define time integer constan ?

Status
Not open for further replies.

bianchi77

Advanced Member level 4
Joined
Jun 11, 2009
Messages
1,313
Helped
21
Reputation
44
Reaction score
20
Trophy points
1,318
Location
California
Visit site
Activity points
9,442
Guys,

How can I define time integer constan ?

I define my function :
Code:
void tone(int freq,int wait)
{
	OCR1A=freq;
	_delay_ms(wait);
}
when I call :
Code:
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
 

Were you call tone(0,1000), replace it directly by lines bellow instead :

Code:
	int freq = 0 ;
        int wait = 1000 ;
        OCR1A=freq;
	_delay_ms(wait);

This way you can determine whose of these lines are the responsible for the above error.


+++
 

It sounds like _delay_ms() is a macro which needs to know the value at compile time - you cannot supply it with a variable.

Keith
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…