Hi,
Well.. I'm new to C programming also... one reason to switch was to force myself to learn C ..
That explains a lot.
anyway I tried passing double type variables into the delay.h library but resulted in getting the same result.. I'm guessing what ever the case for any variable that is passed it uses the floating point....!
Firstly, delay.h is NOT the library. It is just the header file which gets included to "declare" external references in your '.c' file for compiler to be happy. To actually resolve these externals they must be "defined" elsewhere - that is library. Usually libraries have extension of ".lib", but GNU tools use extension -".a" for archieve. Look for "libc.a" & "libm.a" in 'avr/lib' folder. Your makefile will add them with name 'c' & 'm' i.e. without 'lib' which is assumed by linker.
void _delay_ms( double );
void _delay_us( double );
Note that these are function prototypes which specifies the "type" of argument it takes. Now whenever you call these functions, with argument of "any type", they will be automatically converted to 'double'. This is called type conversion. You normally must specify these type conversions to make your code clear to compiler as well as to you.
On the other hand, when you pass it a "compile-time" constant, preprocessor(cpp) wii do the all the calculations(with double precesion) & pass final result to function which now does not need to do any floating-point calcs.
Look at this...
uint16_t j, k;
uint32_t i;
i = j * k; // does 16 x 16 = 16 bit, overflow ignored !!!!, may be wrong
i = (uint32_t)j*k; // does 16 x 16 = 32 bit, that's correct
Run few examples with wide range of j & k, you will see why type conversion & type checking is done by c/c++ compilers. If you turn on all the warnings, compiler will flag first of above code as warning !!
Also I suggest you to learn using 'make' as well as 'lint'. 'make' will make your life a lot easier. & 'lint' will catch many errors which gets passed through compiler/linker unnoticed.
regards,
sam_des