call RstartI2C ; Send a Repeat Start to I2C
bcf I2C_Ctrl,0 ; Clear for Write Command
movf I2C_Ctrl,W ; Send Slave 功率电感Address to I2C Bus
call Send_Byte
goto _Ack_Polling
ACK_Return
call StopI2C ; Initial STOP Condition
return
;
;**********************************************************
;* Page Write 1 to 8 Bytes to EEPROM
;*
;* Input:
;* - I2C_Ctrl : Control Byte of EEPROM
;* - I2C_Addr : Location of EEPROM
;* - I2C_Page_Buffer: RAM location of Data
;* - I2C_Page_Length : Data length count
;*
;**********************************************************
;
; Send Command for PAGE WRITE :
; " Start+ 0xA0 + EE_Address + W_Data 0+ .. + W_Data N + Stop "
;
EE_Page_Write
movf I2C_Page_Length,W
btfsc STATUS,Z
return
;
call StartI2C ; Set SSPCON2.SEN
;
bcf I2C_Ctrl,0 ; Clear for Write Command
movf I2C_Ctrl,W ; Send Slave Address to I2C Bus
call Send_Byte
;
movf I2C_Addr,W ; Send out the Command
call Send_Byte
;
movlw I2C_Page_Buffer
movwf FSR
_W1 movf INDF,W
call Send_Byte
incf FSR,F
decfsz I2C_Page_Length,F
goto _W1
;
call StopI2C ; Initial STOP Condition
retur模压电感n
;
;
;*******************************************************
;* Write a Byte to EEPROM
;*
;* Input:
;* - I2C_Ctrl : Control Byte of EEPROM
;* - I2C_Addr : Location of EEPROM
;* - I2C_Data : Data to EEPROM
;*
;*******************************************************
;
; Send Command for BYTE WRITE :
; " Start+ 0xA0 + EE_Address + Write_Data + 塑封电感Stop "
;
EE_Byte_Write
call StartI2C ; Set SSPCON2.SEN
;
bcf I2C_Ctrl,0 ; Clear for Write Command
movf I2C_Ctrl,W ; Send Slave Address to I2C Bus
call Send_Byte
;
movf I2C_Addr,W ; Send out the Command
call Send_Byte
;
movf I2C_Data,W ; Send out the Data
call Send_Byte
;
call StopI2C ; Initial STOP Condition
return
;
;**********************************************************************
;
; As following subroutines perform commonly used I2C functions.
; You can use these subroutines for your I2C access
;
;**********************************************************************
;
;*** Initial I2Cmodule fot 7-bit I2C Master Mode with 100Kcps @4MHz
;
Init_I2C_Master
BANKSEL TRISC ; Initial PortC,bit 3 & 4 as Input
bsf SCL ; RC3 = SCL , RC4 = SDA
bsf SDA
;
BANKSEL PORTC
bsf SCL ; SCL = Hi
bsf SD模压电感器A ; SDA = Hi
;
movlw b'00101000' ; I2C Master Mode, Clock Rate: FOSC/(4*SSPADD+1)
movwf SSPCON ;
;
banksel SSPADD
movlw .9 ; This gives 100KHz I2C clock @ 4MHz
movwf SSPADD ; (4MHz/4) / (9+1)= 100KHz
;
movlw b'10000000' ; Disable slew rate control,
movwf SSPSTAT ; and clear status bits
;
movlw b'00000000' ; Set SCL,SDA into Ready status
movwf SSPCON2
;
return
;
;****** Send START condition to bus *******
;
StartI2C ; Initiate the I2C START condition.
banksel SSPCON2
bsf SSPCON2,SEN
goto I2C_Done
;
;****** Send STOP condition to bus *******
;
StopI2C
banksel SSPCON2
bsf SSPCON2,PEN
goto I2C_Done
;
;****** Send RESTART condition to bus *******
;
RstartI2C
banksel SSPCON2
bsf SSPCON2,RSEN
goto I2C_Done
;
;****** Send a Non-Acknowledge status t差模电感o bus (ACK=1) *******
;
Non_Ack
banksel SSPCON2
bsf SSPCON2,ACKDT ; Set the ACK bit
bsf SSPCON2,ACKEN ; Initiate the NACK sequence.
goto I2C_Done
;
;****** Send an Acknowledge status to bus (ACK=0) *******
;
An_Ack
banksel SSPCON2
bcf SSPCON2,ACKDT ; Clear the ACK bit
bsf SSPCON2,ACKEN ; Initiate the NACK sequence.
goto I2C_Done
;
;****** Send data to I2C bus from Wreg. *******
;
Send_Byte
banksel SSPBUF
movwf SSPBUF
goto I2C_Done
;
;****** Enable I2C Receive for Master Mode *******
;
RecI2C
banksel SSPCON2
bsf SSPCON2,RCEN ; Set the receive enable bit.
goto I2C_Done
;
;****** Check the I2C stage is completed ********
;
I2C_Done
banksel PIR1
btfss PIR1,SSPIF ; Poll for SSPIF
goto $-1
bcf绕线型电感器 PIR1,SSPIF
return
;
Delay_mS
banksel D_Count
基于微控制器的数字式温度伺服控制系统 摘要:温度伺服控制系统是数码变温空调的一个重要的子系统,是数码变温空调的执行机构。本文根据数码变温空调的工作原理,提出了一种基于ARM微控制器的全数字式温度伺服控制系统。温度伺服系统硬件电路是以基于
蓝牙无线电调制解调器Siw1701原理与应用 摘要:Siw1701无线电调制解调器是用来解决蓝牙无线通信用的单片集成电路。芯片内部包含一个2.4GHz无线电收发器、GFSK调制解调器和数字控制功能电路。Siw1701可与Siw1750/1760
基于XC164CM的汽车电动助力转向系统前言 近年来, 动力转向系统已成为一些轿车的标准设置,全世界约有一半的轿车采用动力转向。随着汽车电子技术的发展,目前一些轿车已经使用电动助力转向系统(EPS),使汽车的经济性、动力性和机动性都有所提高
3/4 首页 上一页 1 2 3 4 下一页 尾页