Chapter 4 - IO Port Programming IO编程.ppt

  1. 1、本文档共40页,可阅读全部内容。
  2. 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
Chapter 4 - IO Port Programming IO编程

PORT 3 For typical I/O use, identical to PORT 1 and 2. Each pin provides a different dual function. Port 3 does not need any pull-up resistors since it already has pull-up resistors internally. Although port 3 is configured as an output port upon reset, this is not the way it is most commonly used. Port 3 has the additional function of providing signals. Serial communications signal:RxD, TxD(Chapter 10) External interrupt:/INT0, /INT1(Chapter 11) Timer/counter:T0, T1(Chapter 9) External memory accesses in 8031-based system:/WR, /RD(Chapter 14) Port 3 Alternate Functions 17 RD P3.7 16 WR P3.6 15 T1 P3.5 14 T0 P3.4 13 INT1 P3.3 12 INT0 P3.2 11 TxD P3.1 10 RxD P3.0 Pin Function P3 Bit ? Accessing Entire Ports MOV A, #0FH MOV P1, A MOV P1, #0F0H XRL P1, #0FFH MOV P1, R0 … Bit Manipulation To toggle every bit of P1 continuously, 3 ways exists: Way 1: Send data to Port 1 through ACC: BACK: MOV A,#55H ;A MOV P1,A ACALL DELAY MOV A,#0AAH ;A MOV P1,A ACALL DELAY SJMP BACK Way 2: Access Port 1 directly: BACK: MOV P1,#55H ;P1 ACALL DELAY MOV P1,#0AAH ;P1 ACALL DELAY SJMP BACK Read-modify-write feature: MOV P1,#55H ;P1 AGAIN: XRL P1,#0FFH ACALL DELAY SJMP AGAIN The instruction XRL P1,#0FFH do EX-OR P1 and FFH (That is, to toggle P1.) Bit Manipulation Sometimes we need to access only 1 or 2 bits of the port instead of the entire 8 bits. This table shows how to name each pin for each I/O port. ? Example: Write a program to perform the following. (a) Keep monitoring the P1.2 bit until it becomes high, (b) When P1.2 becomes high, write value 45H to port 0, and (c) Send a high-to-low (H-to-L) pulse to P2.3. Solution: SETB P1.2 ;make P1.2 an input MOV A,#45H ;A=45H AGAIN:JNB P1.2,AGAIN;get out when P.2=1 MOV P0,A ;issue A to P0 SETB P2.3 ;make P2.3 h

文档评论(0)

xcs88858 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

版权声明书
用户编号:8130065136000003

1亿VIP精品文档

相关文档