MCUmall EPROM BIOS Chip Burner Forum
MCUmall EPROM BIOS Chip Burner Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 MCUmall Forums
 Using the AVR JTAG ICE and AVRISP ISP programmer
 Need help on AVR CodeVision
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

sohomcu

4 Posts

Posted - 09/20/2007 :  00:14:54  Show Profile  Reply with Quote
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
Reply #1

ZLM

2936 Posts

Posted - 09/20/2007 :  07:18:37  Show Profile  Reply with Quote
Did you try cast the varible?

Example:

unsigned char delayInMs;

delay_us((const unsigned char) delayInMs);

Go to Top of Page
Reply #2

sohomcu

4 Posts

Posted - 09/21/2007 :  02:15:02  Show Profile  Reply with Quote
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?


Go to Top of Page
Reply #3

ZLM

2936 Posts

Posted - 09/21/2007 :  14:30:29  Show Profile  Reply with Quote
What is the delay_us() function prototype looks like?
Go to Top of Page
Reply #4

sohomcu

4 Posts

Posted - 09/22/2007 :  23:36:17  Show Profile  Reply with Quote
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
Go to Top of Page
Reply #5

ZLM

2936 Posts

Posted - 09/23/2007 :  23:06:26  Show Profile  Reply with Quote
It looks fine but I do not know what is "#pragma used+" for.

How about remove those two #pragma lines?
Go to Top of Page
Reply #6

sohomcu

4 Posts

Posted - 09/23/2007 :  23:34:50  Show Profile  Reply with Quote
I am sure the problem has nothing concerned with the two
#pragma lines.

Anyway, thanks for your kind concern to my problem.

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
MCUmall EPROM BIOS Chip Burner Forum © Copyright 2003 - 2009 Mcumall Electronics Inc. Go To Top Of Page
Generated in 0.17 sec. Snitz Forums 2000