I need to assign the port pins to 0 to 15 binary bits,as i'm using c compiler it's not compiling the following code,even though i have added the stdint.h header file,so is any other way i can compile this...
uint8_t v
I need to assign the port pins to 0 to 15 binary bits,as i'm using c compiler it's not compiling the following code,even though i have added the stdint.h header file,so is any other way i can compile this...
uint8_t v
What machine and what compiler are you using? 0 to 15 bits seems like you'd want a 16 bit unsigned integer, not an 8 bit one. On your compiler, how many bits are there in an "unsigned short"?
Did you also compile under the C99 standard? Depending on the compiler, the steps needed will be different. stdint.h is not a header in older standards. For gcc the switch you need to flip is -std=c99, then you should have it.
Or you can use char, which is guaranteed to be 1 byte.
uint8_t is a 8 bit number, not 16. You probably want uint16_t
Assuming compilation under C99 or later, support of uintN_t (N = 8, 16, 32, 64) types by an implementation is optional.
It strikes me as strange trying to use uint8_t to represent something that is 16 bits, rather than a uint16_t. Presumably an array of two of them .....
Assuming a digital target machine (:eek:), the unsigned char type will always be implemented with at least eight bits.
I think you're all misinterpreting him. He seems to mean a 4-bit quantity. I.e enough to represent 0 to 15.
Just add this to an appropriate header file:
Even better, use preprocessor macros which determine whether the #include stdint.h, or just use this typedef, so that it works everywhere. This is a common way to deal with code that needs to run across multiple compilers.Code:typedef unsigned char uint8_t;
Right yeah sorry, I do think the goal certainly was misstated originally. It is hard to interpret strangely worded descriptions with the correct intent.
Post #5 clarified it somewhat though.