chap8 - Chapter 8 Single-bit Instructions and Programming 1...

This preview shows page 1 - 13 out of 42 pages.

The preview shows page 12 - 13 out of 42 pages.
1Chapter 8Single-bit Instructions andProgramming
2Objective8051 has a powerful function :8051 allowsprogrammer to access a single bit (not a byte) ontheRAM or register. This type of accessingmethod is called bit-addressable.The bit-addressing mode can only provide onspecific area of the RAM or some specifiedregisters.8051 provides a set of bit-addressable commandsfor this operation.This chapter is to understand how to use these bit-addressable commands.
3Sections8.1Single-bit Instruction Programming8.2Single-bit Operations with CY8.3Reading Input Pins vs. Port Latch
4Section 8.1Single-bit Instruction Programming
5Bit-addressability (1/2)In most microprocessors, data is accessed in byte-sized chunks.However, in many applications we need to changeone bit, for example, to turn on or off a device.The bit-addressability of the 8051The ability to access data in single bit instead of thewhole byte.Make 8051 become one of the most powerful 8-bitmicroprocessors.
Bit-addressability (2/2)Which portions of the microprocessor, I/O ports,registers, RAM, or ROM are bit-addressable?
6
7I/O Ports and Bit-addressabilityWe can access either the entire 8 bits or any singlebit without altering the rest.Example:SETB P2.3;set pin 3 of P2 to high(1)CLRP1.0;clear pin 0 of P1(0)Remember that D0 is the LSB and D7 is the MSB.
8Example 8-1 (a-1)Write the following program.(a)Create a square wave of 50% duty cycle on bit 0 of port 1.in8051P1.0
9Example 8-1 (a-2)(a)Create a square wave of 50% duty cycle on bit 0 of port 1.HERE:SETBP1.0;set to high bit 0 of port 1LCALL DELAY ;call the delay subroutineCLRP1.0;P1.0=0LCALL DELAYSJMPHEREAnother way to write the above program is:HERE:CPLP1.0;complement bit 0 of port 1LCALL DELAY ;call the delay subroutineSJMPHERE
Example 8-1 (b-1)Write the following programs.(b) Create a square wave of 66% duty cycle on bit 3 of port 1.in
10
11Example 8-1 (b-2)(b) Create a square wave of 66% duty cycle on bit 3 of port 1.BACK:SETB P1.3;set port 1 bit 3 highLCALL DELAYLACLL DELAYCLRP1.3;clear bit 2 of port 1LACLL DELAYSJMPBACK
12Bit Address of I/O PortsEach port has itsbyteaddress.Ex: P0 has address 80H.

Upload your study docs or become a

Course Hero member to access this document

Upload your study docs or become a

Course Hero member to access this document

End of preview. Want to read all 42 pages?

Upload your study docs or become a

Course Hero member to access this document

Term
Fall
Professor
cheung
Tags
X86, Status register, Carry flag, Cy, Overflow Flag

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture