the problem is : may i drive the led(commom anod) and read the pin input at the same time? reading the input pin just need take 1us only, but many configuration will make the led not working when i push the button...
any suggestion (without use any external IC) to realise that?
use analog mux.... since you need only 1µs for your switch functioning i think analog mux is the best idea.... analog mux consists of nothing but a MOSFET which acts as a switch and it is bidirectional.... you can multiplex them i.e.give a clock as input to selection line so when it is high one line say the switch gets selected and when it is in low the LED circuit will be selected.... this 1µs will not be noticed due to the storage time of the LED....
So you need to "toggle" the function of input and output on the same port pin, this technique is very popular in microcontroller circuits, that you have to get familiar with as soon as possible.
For example, you may find out at Microchip website the application note AN557 (Four Channel Digital Voltmeter with Display and Keyboard) with source codes, in which there are 4 subprograms of 4 degrees, you will find out the needed subprogram with the technique for toggling input/output functions. This AN557 is very comprehensive for the PIC beginers.
Show us the schematic of your existing circuit, please? How many 7-segment displays?
Mike
Added after 15 minutes:
If you're using something of a 'traditional' 7 segment display setup you should be able to implement a single-pin column driven switch matrix. This will however require an additional pin.
Since you're only ever driving 1 column driver transistor low at any given time, connect each switch through a diode for isolation to that active low PIC pin. You really should be using an interrupt service routine for driving the display and this routine should be selecting and driving a different PIC column pin each interrupt cycle. I normally use a "ring counter" variable to keep track of the column number and I use it as a mask for testing the switches (test 1 switch each interrupt).
Code:
;
comf COLPOS,W ; example ~Column 3 = 11110111
andwf SWITCH,F ; turn off switch flag bit
movf COLPOS,W ; example Column 3 = 00001000
btfsc PORTA,SwInPin ; switch pushed? no, skip, else
iorwf SWITCH,F ; indicate switch pressed (1)
;
; advance column ring counter for next interrupt cycle
;
rlf COLPOS,W ; rlf into W to preserve C
rlf COLPOS,F ; (similar to 18F rlncf instruction)
;