TRIS寄存器中的哪些位用于PIC编程。

huangapple go评论101阅读模式
英文:

PIC programming which bits are which in TRIS register

问题

TRISB &= 0b11100000 这段代码将 RB0-RB5 设置为输入。

英文:

I am trying to understand PIC18 code in a format like TRISB &= 0b11100000.
What is the order the individual RB pins appear in? i.e. is this register setting RB0-RB2 as input, or RB5-RB7 as input?

答案1

得分: 1

After using TRISB &= 0b11100000, RB5-RB7 will keep their state and RB0-RB4 will be cleared - set to outputs.

通常情况下,通过 TRISB &= ~(0b00011111) 来清除位,以增加代码的清晰度。

英文:

After using TRISB &= 0b11100000, RB5-RB7 will keep their state and RB0-RB4 will be cleared - set to outputs.

Usually clearing bits is done with TRISB &= ~(0b00011111) for 'clarity'

答案2

得分: 0

在代码中 TRISB &= 0b11100000,二进制值设置了最低的引脚 RB0-RB2 为输出,最高的引脚 RB5-RB7 为输入。

英文:

in the code TRISB &= 0b11100000, the binary value sets the direction of the lowest pins, RB0-RB2, as outputs, and the highest, RB5-RB7, as inputs.

huangapple
  • 本文由 发表于 2023年5月17日 06:56:44
  • 转载请务必保留本文链接:https://go.coder-hub.com/76267574.html
  • pic
  • pic18
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定