to doomleo(leo) :我贴子中已经纠正过,说明00000000的情况不可以。另外,按键接VCC还是接GND,和你的程序对IO口配置有关,都可以实现。我在脑海里想象,四层是可以的,但是我懒得去protel布线,所以说“布线做成6层PCB肯定可以实现255个键”。对于PCB,通常的要求是尺寸小,所以唯有增加层数了。protel99里可以布16层pcb,不知道一般pcb厂加工能做多少层?好像做手机、主板的很多都布6层。
突然想起些东西,按键最好还是接VCC,每次定时中断后令P1=0,没有按键就是0。
单片机数据手册提到:Port 1 is an 8-bit bidirectional I/O port with internal pull-ups on all pins.Port 1 pins that have 1s written to them are pulled high by the internal pull-ups and can be used as inputs. As inputs, port 1 pins that are externally pulled low will
source current because of the internal pull-ups. (See DC Electrical Characteristics:
IIL).所以,如果按键接GND,按钮按下的时候,电平被外部拉低,这时候就出现source current(估计是内部上拉电阻集电),集电自然要放电,这样会有什么不良影响,我也不清楚。而对于我的方案,按键在不接通Vcc的时候,IO只是悬空。