- 1、本文档共6页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
PIC 单片机的 I2C 应用程序 1
; File: an734.asm; data: feb.23.2001; Functionality:;; This code implements the basic functions for an I2C slave device; using the SSP module. All I2C functions are handled in an ISR.; Bytes written to the slave are stored in a buffer. After a number; of bytes have been written, the master device can then read the; bytes back from the buffer.;; Variables and Constants used in the program:;; The st ; File: an734.asm
; data: feb.23.2001
; Functionality:
J
; This code implements the basic functions for an I2C slave device ; using the SSP module. All I2C functions are handled in an ISR. ; Bytes written to the slave are stored in a buffer. After a number ; of bytes have been written, the master device can then read the ; bytes back from the buffer.
J
; Variables and Constants used in the program:
J
; The start address for the receive buffer is stored in the variable
; 'RXBuffer'. The length of the buffer is denoted by the constant
; value 'RX_BUF_LEN'. The current buffer index is stored in the ; variable 'Index'.
; The following files should be included in the MPLAB project:
J
; an734.asm-- Main source code file
J
; 16f872.lkr-- Linker script file
; (change this file for the device
; you are using) #include <p16f872.inc> ; Change to device that you are using.
;Constant Definitions #define NODE_ADDR 0x02 ; I2C address of this node ; Change this value to address that
; you wish to use.
; Buffer Length Definition
#define RX_BUF_LEN 32 ; Length of receive buffer
; Variable declarations udata
WREGsave res 1
STATUSsave res 1
FSRsave res 1
PCLATHsave res 1
Index res 1 ; Index to receive buffer
Temp res 1 ;
RXBuffer res RX_BUF_LEN ; Holds rec'd bytes from master ; device.
; Vectors
STARTUP code nop goto Startup ; nop ; 0x0002 nop ; 0x0003 goto ISR ; 0x0004
PROG code
; Macros memset macro Buf_addr,Value,Length
movlw Length ; This macro loads a range of data memory movwf Temp ; with a specified value. The starting movlw Buf_addr ; address and number of bytes ar
您可能关注的文档
- mm_fs_cnj_0276出口粮谷及油籽中特普残留量检验方法.docx
- mm_fs_cnj_0262出口坚果及坚果制品中喹硫磷残留量检验方法.docx
- mm_fs_cnj_0265出口坚果及坚果制品中抑芽丹残留量检验方法分光光度法.docx
- mm_fs_cnj_0259出口干果中六六六、滴滴涕残留量检验方法.docx
- mp02.05.01.02成品油价格管理.docx
- mp02.05.01.03天然气价格管理.docx
- mm_fs_cnj_0261出口坚果及坚果制品中地乐酚残留量检验方法.docx
- mp02.05.01.04管输价格管理.docx
- mp02.05.03价格信息反馈.docx
- mro采购供应链管理策略分析.docx
文档评论(0)