at89c4051 spi
As I've told you the SPI interface (MCP3208 ADC) it's more suitable for your design.
In order to be helped by other members you must to provide more details regarding your design.
How do you expect that someone will figure out how did you connect the LED to port P3 ?
Do you use 7 LEDs directly tied to P3 (obvious through current limiter resistors) ?
Or did you use a BCD 7 segment convertor (which requires only 4 lines, rather than 7) ?
Look at the unsigned int a[10]={0x40,0x60,0x44,0x64,0x50,0x68,0x4C,0x6C,0x50,0x70};
First why unsigned int and not unsigned char ? Since are not declared as constant, will be stored in RAM, thus waste of space for "int".
If an element of the array will be sent to P3, then according to your declaration
P3^7 = 0
P3^6 = 1
P3^1 = 0
P3^0 = 0
are constant regardless of element 0, 1, 2, ...9, thus you'll waste 4 lines.
Nevertheless that you don't have control of P3^6 which is tied hardware internal to comparator output.
No back to hardware. You can't use P3^0 and P3^1 as control lines (/WR and /INTR) and LED display.
Bear in mind that once a conversion was started, another raising pulse on /WR line (WRITE=0; WRITE=1; ) will start another conversion, even if the previous conversion wasn't finished.
Thus, if you tied on P3^0 to /WR and LED display as well, you must be sure that the LED signal will not overide the /WR signal.
The best solution is to use P1 for both reading ADC (input) and writing LED (output) (wiring them parallel on the "bus").
But you have to use the /RD signal which is actually hardware tied to GND (I bet it's so, otherwise you aren't able to read the data conversion).
Obvious the /CS could be kept tied to GND (like present) or tied to P3 as well.
During display procedure the /RD signal must be high and will only goes low for a short time during reading of ADC conversion results when /INTR goes low.
Because the read cycle is short you can not even see the display LED flickering (as a matter of fact the same data read from ADC will be delivered immediately to the display on same port).
Thus you can set P3 as bellow:
P3^0 = /CS
P3^1 = /WR
P3^2 = /INTR you can use /INT0 feature of 8051 rather than polling for EOC (while(INTR==1)
P3^4 = /RD
Funny enough if you set the ADC0804 running in continuos mode (/WR and /INTR tied together, and /CS = 0, /RD = 0) you don't even need a micro.
You need only 3 things:
1. 2 diodes, one resistor and a switch to start the conversion on /WR pin
2. A buffer to drive the LEDs
3. Finnaly a smart brain to make the display conversion (if 0xFF means for you +5V as full scale, then 0x80 means 2,5V)
You must admit that you need the brain to see data on LED.
Just a joke.