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
解決済! 解決策の投稿を見る。
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.
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.
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
And here is the macro file.