什么在C中做了什么? [重复]

时间:2022-01-13 04:03:02

This question already has an answer here:

这个问题在这里已有答案:

I am trying to understand what the C Operator |= do:

我试图了解C运算符| =做什么:

// Initialize the green led
// Enable the clock for PORT D.  See Page 216 of the Datasheet
SIM_SCGC5 |= (1U<<12);

// Enable the mux as GPIO.  See Page 193 of the Datasheet
PORTD_PCR5 = 0x100;

I also don't understand what the 0x100 means.

我也不明白0x100的意思。

1 个解决方案

#1


4  

It is a bitwise OR compound assignment, it is the same as :

它是一个按位OR复合赋值,它与:

SIM_SCGC5 = SIM_SCGC5 | (1U<<12);

The 0x100 it is the value 100 in hexadecimal, the 0x prefix means hexadecimal value.

0x100是十六进制值100,0x前缀表示十六进制值。

#1


4  

It is a bitwise OR compound assignment, it is the same as :

它是一个按位OR复合赋值,它与:

SIM_SCGC5 = SIM_SCGC5 | (1U<<12);

The 0x100 it is the value 100 in hexadecimal, the 0x prefix means hexadecimal value.

0x100是十六进制值100,0x前缀表示十六进制值。