Problems with literal constants

I am using the Hi-Tech C compiler to program the PIC16F876. I am at the point where I should use a delay, the duration of which is different each time the program starts.

I would like to feature

__delay_us() 

but

This function accepts only as indicated in the manual; Arguments "Literal Constant". I thought that after calculating the delay duration => duration, I could use:

__delay_us(D);

So far, D is assigned like this:

#define D duration  //where duration is an unsigned long

However, the method does not work. It seems that when I use #define, if the value I assign is a variable, does the compiler throw an error ?? (I would not have expected this, I would have thought that the current value of the variable would be converted to a constant during assignment.)

If I assign a real number, for example:

#define D 20 

, D.

, : Hi-tech C , , ( ).

, , 1us , , , ( , ).

, ?

+4
1

(~ 10 ), ( ) , C.

.

, ( T) . .

C #asm - #endasm asm , .

P.S.: , , , ON 1 -.

+2

All Articles