英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论