新聞中心

EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > 51單片機(jī)對(duì)SAA7113初始化和控制的程序代碼

51單片機(jī)對(duì)SAA7113初始化和控制的程序代碼

作者: 時(shí)間:2012-02-13 來(lái)源:網(wǎng)絡(luò) 收藏

 RET

本文引用地址:http://m.butianyuan.cn/article/172108.htm

  ;*******通過(guò)I2C總線讀出某一寄存器的數(shù)據(jù)*********

  I2C_READ: ACALL I2C_START

  MOV A, # DeviceaddressW ;調(diào)7113地址,寫(xiě)入

  ACALL I2C_SEND_1BYTE

  ACALL CHECK_ACK

  JNB I2C_ERROR, RD200

  RD100: ACALL I2C_STOP

  RET

  RD200: MOV A, Subaddress ;調(diào)要讀的寄存器地址

  ACALL I2C_SEND_1BYTE ; 發(fā)送寄存器地址字節(jié)

  ACALL CHECK_ACK

  JB I2C_ERROR, RD100

  ACALL I2C_START ;重發(fā)起動(dòng)信號(hào)

  MOV A, # DeviceaddressR ;調(diào)7113地址,讀

  ACALL I2C_SEND_1BYTE

  ACALL CHECK_ACK

  JB I2C_ERROR, RD100

  ACALL I2C_RECEIVE_1BYTE ;接收讀出的數(shù)據(jù)

  MOV DATA_I2C,A ;讀出數(shù)據(jù)轉(zhuǎn)存

  ACALL SEND_NOACK ;發(fā)送非應(yīng)答位

  ACALL I2C_STOP ;停止

  RET

  ;***************化7113,配置各寄存器************************

  INIT_: MOV DPTR, #_Subaddress

  MOV R7, #28

  INIT100: MOV A, #0

  MOV C A, @A+DPTR

  MOV Subaddress, A ;調(diào)寄存器地址

  MOV A,#28

  MOVC A, @A+DPTR

  MOV DATA_I2C, A ;調(diào)寄存器配置數(shù)據(jù)

  INC DPTR

  ACALL I2C_WRITE ;配置1個(gè)寄存器

  JB I2C_ERROR, INIT200

  DJNZ R7,INIT100

  INIT200: RET

  ;***************寄存器化配置數(shù)據(jù)**********************

  SAA7113_Subaddress:

  DB 01H,02H,03H,04H,05H,06H,07H,08H,09H,0AH,0BH,0CH,0DH,0EH

  DB 0FH,10H,11H,12H,13H,15H,16H,17H,40H,58H,59H,5AH,5BH,5EH

  ;共28個(gè)

  I2C_REG_VALUE_AI11:

  DB 08H,0C0H,33H,00H,00H,0EBH,0E0H,0B8H,01H,7EH,46H,43H,01H,01H

  DB 0FH,00H,0CH,0A7H,00H,00H,00H,00H,02H,00H,54H,07H,80H,00H

  ;*************對(duì)SAA7113某一寄存器的改寫(xiě)與讀出*******************

  WRITE_READ: MOV Subaddress, #0AH ; 設(shè)寄存器地址為0AH

  MOV DATA_I2C, #88H ;改寄存器的值為88H

  ACALL I2C_WRITE ;改寫(xiě)

  ACALL I2C_READ ;讀出


上一頁(yè) 1 2 3 下一頁(yè)

評(píng)論


相關(guān)推薦

技術(shù)專(zhuān)區(qū)

關(guān)閉