74. Unions-II

Question.1

An ADC result register is decoded using a union with bitfields (GCC/ARM, LSB-first):

typedef union {
   uint16_t raw;
   struct {
       uint16_t adc_value : 12;
       uint16_t channel   : 4;
   } bits;
} ADC_Result;

ADC_Result r;
r.raw = 0x7A3F;
printf("CH=%u ADC=%u", r.bits.channel, r.bits.adc_value);

What is the output?

Need Help? Refer to the Quick Guide below

Select Answer

Restart quiz!