14.11.2014 Views

P89LPC935 Microcontroller Tutorial - gmitWEB

P89LPC935 Microcontroller Tutorial - gmitWEB

P89LPC935 Microcontroller Tutorial - gmitWEB

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Accessing Port Pins<br />

• The microcontroller port should be configured at the start of the program.<br />

//configure port 2 to be quasi bi-directional<br />

P2M1 = 0x00;<br />

P2M2 = 0x00; //all 8 pins are quasi bi-directional<br />

• Writing to an entire port<br />

P2 = 0x12;<br />

//Port 2 = 12H (00010010 binary)<br />

P2 &= 0xF0; //clear lower 4 bits of Port 2<br />

P2 |= 0x03; //set P2.0 and P2.1<br />

• Reading from a port<br />

unsigned char data status;<br />

status = P1; //read from Port 1<br />

Diploma Project <strong>Tutorial</strong> 24

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!