The Microcontroller Idea Book - Jan Axelson's Lakeview Research
The Microcontroller Idea Book - Jan Axelson's Lakeview Research
The Microcontroller Idea Book - Jan Axelson's Lakeview Research
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
To set or clear a different bit, determine which bits to set and clear for the result you want,<br />
convert the value to decimal or hexadecimal, and write the value to 0FC03h.<br />
Adding Handshaking<br />
For many applications, Mode 0 is all you need. Modes 1 and 2 add handshaking, or control,<br />
signals for components that require them.<br />
Mode 1 is Strobed Input/Output. It uses Port C for handshaking signals that let the<br />
8052-BASIC and the peripheral tell each other whether or not they’re ready to send or receive<br />
data, and to confirm that data has been received. Mode 1 also latches the input data, so you<br />
can use an external signal to latch data into U15, and save it until the 8052-BASIC has time<br />
to read it. In Mode 1, you can configure Ports A and B to be inputs, outputs, or one of each.<br />
Each port has its own set of handshaking signals on Port C, as described in Table 6-2.<br />
Input Control. For input ports, these are the added signals:<br />
STB (strobe input) causes data to load into the 8255’s input latch. In Mode 1, the 8052-BASIC<br />
can’t read the data at U15’s ports until STB’s rising edge latches the data in. You can use an<br />
output of a clock or counter chip to latch data into U15 at timed intervals, or latch data when<br />
a user presses a key.<br />
IBF (input buffer full output) goes high to indicate that the 8255 has loaded data in response<br />
to STB. When the 8052-BASIC reads the data, the rising edge of RD brings IBF low again.<br />
You can use IBF to clear or reset the device that generated STB.<br />
INTE (interrupt enable) is an internal signal that you must set to enable INTR, described next.<br />
For Group A, you set INTE by writing 1 to Port C, bit 4. For Group B, write 1 to Port C, bit<br />
2. <strong>The</strong> BASIC-52 statement to set INTE for Port A is this:<br />
XBY(0F03h)=9<br />
For Port B, it’s this:<br />
XBY(0F03h)=5<br />
Inputs and Outputs<br />
Writing to these locations sets internal bits in U12. However, these write operations have<br />
no effect on the STB inputs, which share the same bit addresses at Port C.<br />
INTR (interrupt request output) goes high when INTE is set and both STB and IBF are high,<br />
to signal that the 8255 has data waiting to be read. INTR can connect to an interrupt input on<br />
the 8052-BASIC (pin 13, for example), to cause it to jump to an interrupt routine that reads<br />
<strong>The</strong> <strong>Microcontroller</strong> <strong>Idea</strong> <strong>Book</strong> 107