What type to pass to _delay_ms
i'm using studio 7 ver 7.0.1006 , come error
__build_avr_delay_cycles expects compile time integer constant.
snippet works when inline _delay_ms (), put in function, won't build.
__build_avr_delay_cycles expects compile time integer constant.
snippet works when inline _delay_ms (), put in function, won't build.
code: [select]
#define f_cpu 16000000l
#define led (1 << pinb4)
#include "avr/io.h"
#include "util/delay.h"
void wait ( uint32_t msec) {
_delay_ms( msec );
}
int main (void) {
int count = 10;
ddrb = (1 << pinb4) | (1 << pinb5);
portb = ~(1 << pinb5);
while (count) {
portb = led;
wait( 350 );
portb = ~led;
wait( 500 );
count--;
}
}
i don't know else except echo error message @ you, tells problem is. parameter _delay_ms() must constant value can calculated @ compile time. when have wrapped function, you're passing variable, not constant. when inlines it, passing literal values 350 , 500, satisfy requirements.
Arduino Forum > Using Arduino > Programming Questions > What type to pass to _delay_ms
arduino
Comments
Post a Comment