Dear all,
Is it possible to pass a variable parameter to the function delay_us( )
which accept only constant expression?
If it's impossible, I think this function has no great use.
Thanks a lot
Eddy Lau
Need help on using AVR CodeVision C compiler
the function was declared as void delay_us(unsigned int n) in the header
file delay.h
I need to pass a variable to this function to control the delay according
to my actual need. But when I pass a variable to this function, it produce
an error saying that it only accept constant expression!
Just can't understand why another function delay_ms( ) can accept variable parameter while the function delay_us() cannot?
What's the reason of making this limitation?
Does anybody know and can provide a positive solution?
Really thanks a lot
file delay.h
I need to pass a variable to this function to control the delay according
to my actual need. But when I pass a variable to this function, it produce
an error saying that it only accept constant expression!
Just can't understand why another function delay_ms( ) can accept variable parameter while the function delay_us() cannot?
What's the reason of making this limitation?
Does anybody know and can provide a positive solution?
Really thanks a lot
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
// 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
the space doesn't matter.
I assume the PIND is defined.
The code looks ok. The only thing that comes to mind is what does the pragma do in the context of declaring the prototype. Is there documentation for delay_us()?
Try removing the delay include and declaring a dummy delay_us. see if it compiles.
does this error come from the compiler or the linker phase?
I assume the PIND is defined.
The code looks ok. The only thing that comes to mind is what does the pragma do in the context of declaring the prototype. Is there documentation for delay_us()?
Try removing the delay include and declaring a dummy delay_us. see if it compiles.
does this error come from the compiler or the linker phase?
- GoingFastTurningLeft
- Posts: 163
- Joined: Wed Sep 06, 2006 7:33 pm
- Contact:
According to their info, the time needed to handle parameter passing in a function call
is longer than the delay provided by the function delay_us( ). So it only accept constant expression for that function to work correctly.
Although they didn't help to solve my programming need, at least I know the limitation of that function.
May be I will try to stick with WinAVR and AVRstudio as an alternative!
is longer than the delay provided by the function delay_us( ). So it only accept constant expression for that function to work correctly.
Although they didn't help to solve my programming need, at least I know the limitation of that function.
May be I will try to stick with WinAVR and AVRstudio as an alternative!
Who is online
Users browsing this forum: No registered users and 28 guests