读写24LCxx系列的EEPROM的实例程序
;********************************************************
;* *
;* ? PIC16F877A ?I2C Master 家Α???﹃?Α EEPROM ?絛ㄒ祘Α *
;* *
;* Written by: Richard Yang *
;* Sr. Corporate Application Engineer *
;* Microchip Technology电感器生产厂家 Inc. *
;* Date: Oct. 2nd '2002 *
;* Revision: 1.00 *
;********************************************************
;****************************功率电感*********************
; This source code provides a demonstration of the MSSP peripheral
; on the PIC16F87x MCU.
;
;
;*********** The subroutines for EEPROM *****************
;
; EE_Random_Read ; EEPROM Random address Read from EEPROM
; EE_SEQU_Read ; EEPROM Sequential Read form EEPROM
; EE_Ack_Check ; Polling current status of EEPROM
; EE_Page_Write ; Page Write function for EEPROM
; EE_Byte_Write ; Write a byte to EEPROM with address setting
;
;*********** The subroutines for I2C *****************
;
; Init_I2C_Master ; Initial I2C Module for Master Mode , 7-bit address
; StartI2C ; Send a START Condition !!
; StopI2C ; Send s STOP Condition
; RstartI2C ; Send a Repeat Start conditional to I2C
; Non_Ack ; Send a Non-acknowledge signal to I2C
; 模压电感器An_Ack ; Send a acknowledge signal to I2C
; Sebd_Byte ; Send a byte to I2C bus
; RecI2C ; Enable Read a byte form slave device
; I2C_Done : Wait the I2C completed the currect process
;
;***************************************************
list p=16f877a
#i nclude <p16f877a.inc>
;
;***************************************
; ﹚竡跑计?RAM???
;
CBLOCK 0x20
I2C_Ctrl
I2C_Addr
I2C_Data
I2C_Page_Length
D_Count
ENDC
cblock 0x40
I2C_Page_Buffer:8
I2C_SEQU_Buffer:8
endc
;
;***************************************
; ﹚竡い耞?既?竟??
w_temp EQU 0x72
status_temp EQU 0x73
pclath_temp EQU 0x74
;
;***************************************
; ﹚竡 I2C ???の竲?
;
EEPROM_CMD equ 0xA0 ; Device adress of Slave Point
EE_Read equ .1
EE_Write equ .0
;
#define SCL PORTC,3 ; I2C SCL pin
#define SDA PORTC,4 ; I2C SDA pin
;
;********************************************
; Locates startup code @ the reset vector
;********************************************
Reset_Addr
org 0x00
nop
goto Main_Init
;
org 0x04
goto ISR
;
;*************************************************************
;**** The Start Address of ISR is 0x004
;**** "PUSH" & "POP" ?ㄏノ絛ㄒ : 続ノ?钩 PIC16F877 ΤSHARE BANK ?PIC
;**************************************************************
ISR
Push movwf w_temp ; save off current W register contents
movf STATUS,w ; move status register into W register
movwf status_temp ; save off contents of STATUS register
movf PCLATH,W
movwf pclath_temp
;
; Put your interrupt code here
;
Pop movf pclath_temp,W
movwf PCLATH
movf status_temp,w ; retrieve copy of STATUS register
movwf STATUS ; restore pre-isr STATUS register contents
swapf w_temp,f
swapf w_temp,w ; restore pre-isr W register contents
;
retfie ; return from interrupt
;----------------------------------------------------------------------
Main_Init
pagesel Init_I2C_Master ; Set PAGE to PCLATH Register
call Init_I2C_Master ; Init the MSSP for I2C Master
;
banksel I2C_Ctrl
movlw EEPROM_CMD ; Load EEPROM command address @ 0xA0
movwf I2C电感器生产厂家_Ctrl
;
;
Main
;
;----------------------------------------------------------------------
;
;* ???代刚祘Α穦?盢?舱计?(0x40-0x47)糶??RMA0x40-0x47??竚
;* ?ノPage Write?よΑ盢8??じ舱?戈?糶? EEPROM ?
;* 秈︽?篈?盎代EEPROM琌??ЧΘ糶??笆??程?盢?糶
;* ??戈??Sequential Read?よΑ眖EEPROM弄?ㄓ??I2C_SEQU_Bufferい
;
Test_Page_RW
movlw 0x08
movwf I2C铁硅铝电感器_Page_Length
movlw I2C_Page_Buffer
_Fill_RAM movwf FSR
movwf INDF
incf FSR,W
decfsz I2C_Page_Length,F
goto _Fill_RAM
;
Test_Page_Write
; banksel I2C_Ctrl
movlw EEPROM_CMD ; Load EEPROM command address @ 0xA0
movwf I2C_Ctrl
movlw 0x10 ; Select EEPROM location at 0x00
movwf I2C_Addr
movlw .8
基于微控制器的数字式温度伺服控制系统 摘要:温度伺服控制系统是数码变温空调的一个重要的子系统,是数码变温空调的执行机构。本文根据数码变温空调的工作原理,提出了一种基于ARM微控制器的全数字式温度伺服控制系统。温度伺服系统硬件电路是以基于
蓝牙无线电调制解调器Siw1701原理与应用 摘要:Siw1701无线电调制解调器是用来解决蓝牙无线通信用的单片集成电路。芯片内部包含一个2.4GHz无线电收发器、GFSK调制解调器和数字控制功能电路。Siw1701可与Siw1750/1760
基于XC164CM的汽车电动助力转向系统前言 近年来, 动力转向系统已成为一些轿车的标准设置,全世界约有一半的轿车采用动力转向。随着汽车电子技术的发展,目前一些轿车已经使用电动助力转向系统(EPS),使汽车的经济性、动力性和机动性都有所提高