The attached picture shows connection between a proximity sensor and 8051 microcontroller without isolation via. Interrupt_0 pin ..
These switches have usually N/O [normally-open] output, that is when nothing is in the proximity of the sensor the output is in high-impedance stage and the voltage is determined by the pull-up [4.7k] resistor ..
On power-on the 8051-derivative has the Interrupt_0 active on the falling edge, so when something triggers the sensor the voltage drops down and the Interrupt_0 will become active ..
In the beginning of your code define a flag as:
Code:
Flags DATA 20h
Proximity_1 BIT Flags.0
And then set it in the ISR[Interrupt Service Routine]:
Code:
Int_0:
SETB Proximity_1
RETI
Do we have to write this code in the program as it is?
---------- Post added at 19:41 ---------- Previous post was at 19:31 ----------
And can you pls explain is how it works....