Bit Fields - mikroElektronika PIC Microcontrollers PIC12 User Manual

Mikroc user's manual
Table of Contents

Advertisement

mikroC - C Compiler for Microchip PIC microcontrollers
Referring to declarations from the previous example:
mu.d = 4.016;
Lcd_Out_Cp(FloatToStr(mu.d));
Lcd_Out_Cp(IntToStr(mu.i));
pm->i = 3;
Lcd_Out_Cp(IntToStr(mu.i));
The second
pattern in
it probably does not provide a useful integer interpretation.
When properly converted, a pointer to a union points to each of its members, and
vice versa.

Bit Fields

Bit fields are specified numbers of bits that may or may not have an associated
identifier. Bit fields offer a way of subdividing structures into named parts of user-
defined sizes.
mikroC implementation of bit fields requires you to set aside a structure for the
purpose, i.e. you cannot have a structure containing bit fields and other objects.
Bit fields structure can contain up to 8 bits.
You cannot take the address of a bit field.
Note: If you need to handle specific bits of 8-bit variables (char and unsigned
short) or registers, you don't need to declare bit fields. Much more elegant solu-
tion is to use mikroC's intrinsic ability for individual bit access — see Accessing
Individual Bits for more information.
Bit Fields Declaration
Bit fields can be declared only in structures. Declare a structure normally, and
assign individual fields like this (fields need to be unsigned):
struct tag { unsigned bitfield-declarator-list ; }
page
80
is legal, since
Lcd_Out_Cp
corresponds to parts of the previously assigned
mu.i
MikroElektronika: Development tools - Books - Compilers
// OK: displays mu.d = 4.016
// peculiar result
// OK: displays mu.i = 3
is an integral type. However, the bit
mu.i
mikroC
making it simple...
. As such,
double

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the PIC Microcontrollers PIC12 and is the answer not in the manual?

Subscribe to Our Youtube Channel

This manual is also suitable for:

Pic microcontrollers pic16Pic microcontrollers pic18

Table of Contents