Help i2c protocol

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Help i2c protocol

跳至解决方案
1,730 次查看
Eliezer
Contributor I

Hello, does anyone know how to set up a communication routine i2c register but without using the microcontroller without the SDA end SCL pins, only with common pins

标签 (1)
0 项奖励
回复
1 解答
1,263 次查看
rocco
Senior Contributor II

And here is the macro file.

在原帖中查看解决方案

0 项奖励
回复
4 回复数
1,263 次查看
rocco
Senior Contributor II

Hi Eliezer,

 

Are you asking for code to "bit-bang" the I2C protocol?  If so, do you need C or assembly language? Are you using an HC08 or S08?

 

I you are using assembly language on an 08, I've implemented I2C as a bunch of macros (originally for the HC05). It uses a lot of in-line code to try to be fast, but it is still rather slow. Bit-timing may be an issue, as you may need to pad some macros with NOPs on the faster S08s.

0 项奖励
回复
1,263 次查看
Eliezer
Contributor I

Hello Rocco.

Yes, I need a code in C for the I2C protocol. I am using KA8 the RS08 family, but I canbe what you

have, already helps me a lot.

Grateful.

0 项奖励
回复
1,263 次查看
rocco
Senior Contributor II

Hi Eliezer,

 

The KA8 is neither an S08 or an HC08, but an RS08, so the assembly language code may not work (I have never used an RS08, as I consider them brain-damaged.

 

But here is my I2C macro file anyway. IYou use it by stringing I2C commands together, such as this routine from an HC08 project:

;
;
; Read all just the motor limit parameters from the EEPROM,
; from the page pointed to by 'ParameterPage'. The parameters
; we need to read are 'MinPosition' and 'MaxPosition'.
;
ParamLoadLimits:
 EE_READ ParameterPage,#(MinPosition-EEP_Start),EER_ERR2
    ;node page, byte in EEPROM, error exit
;
 EE_BYTE_IN  ;get a data byte from EEPROM
 EE_ACK   ;ACK it to continue
 sta MinPosition ;store the data byte
;
 EE_BYTE_IN  ;get a data byte from EEPROM
 EE_ACK   ;ACK it to continue
 sta MinPosition+1 ;store the data byte
;
 EE_BYTE_IN  ;get a data byte from EEPROM
 EE_ACK   ;ACK it to continue
 sta MinPosition+2 ;store the data byte
;
 EE_BYTE_IN  ;get a data byte from EEPROM
 EE_ACK   ;ACK it to continue
 sta MaxPosition ;store the data byte
;
 EE_BYTE_IN  ;get a data byte from EEPROM
 EE_ACK   ;ACK it to continue
 sta MaxPosition+1 ;store the data byte
;
 EE_BYTE_IN  ;get a data byte from EEPROM
 EE_NAK   ;NAK it to make it stop
 sta MaxPosition+2 ;store the data byte
;
; done reading bytes
;
 EE_STOP   ;and issue the stop sequence.
;
 jsr SetLimits ;update the DSP on the situation
 clc   ;clear carry
 rts   ;return happy with carry clear
;
;
; EEPROM error routine for a Read of limit parameters.
;
EER_ERR2:
 EE_STOP   ;drop the EEPROM
 ErrLog E_EEPRMread ;"EEPROM Read Error"
 sec   ;set carry
 rts   ;return empty handed with carry set

 

0 项奖励
回复
1,264 次查看
rocco
Senior Contributor II

And here is the macro file.

0 项奖励
回复