This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

程序赋值



这是用位或给P1.0端口赋值,与直接给P1.0端口赋值(P1DIR=0X01;                  //设置P1.0端口为输出端口

   P1OUT=0x01;                  //设置 P1.0口的输出为高电平)的现象是一样的,不知是为什么,这两者有什么区别?

  • 你好!

    P1OUT |= 0x01; 等价于 P1OUT = P1OUT | 0x01; 即将P1口的输出状态读回来,然后修改P1.0口的状态,然后再送至P1OUT 寄存器, 这样做,仅修改P1.0 的状态。

    P1OUT = 0x01; 就是P10输入高电平,其他口(P1.1 ~ P1.7)输入低电平。

    欢迎继续提问!