T O P I C R E V I E W |
sohomcu |
Posted - 09/20/2007 : 00:14:54 Dear all,
Would anyone please help to solve my problem on using CodeVision C compiler.
I need to pass a variable parameter to the function delay_us( ) which only accept constant expression. Is it possible?
Thanks a lot
Eddy Lau |
6 L A T E S T R E P L I E S (Newest First) |
sohomcu |
Posted - 09/23/2007 : 23:34:50 I am sure the problem has nothing concerned with the two #pragma lines.
Anyway, thanks for your kind concern to my problem.
|
ZLM |
Posted - 09/23/2007 : 23:06:26 It looks fine but I do not know what is "#pragma used+" for.
How about remove those two #pragma lines?
|
sohomcu |
Posted - 09/22/2007 : 23:36:17 the content of delay.h is as follows:
// CodeVisionAVR C Compiler // (C) 1998-2000 Pavel Haiduc, HP InfoTech S.R.L.
#ifndef _DELAY_INCLUDED_ #define _DELAY_INCLUDED_
#pragma used+
void delay_us(unsigned int n); void delay_ms(unsigned int n);
#pragma used-
#endif
I wonder whether this is compiler bug or not? Who can tell me the answer?
Thanks 
|
ZLM |
Posted - 09/21/2007 : 14:30:29 What is the delay_us() function prototype looks like? |
sohomcu |
Posted - 09/21/2007 : 02:15:02 I tried your suggestion but it produce an error of invalid typecast.
Just can't understand why the function delay_ms( ) can accept variable as parameter but delay_us( ) cannot.
What's the purposeof making this limitation?

|
ZLM |
Posted - 09/20/2007 : 07:18:37 Did you try cast the varible?
Example:
unsigned char delayInMs;
delay_us((const unsigned char) delayInMs);
|