S12ZVC, I2C , removing stop bit in the sequence

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

S12ZVC, I2C , removing stop bit in the sequence

1,582 次查看
sungyulchu
Contributor II

Dear,

 

Hello,

 

I'd like to generate proper Send and Receive Message between S12ZVC (MCU) and Slave IC.

 

However, the slave IC that I used requires some special I2C protocols.

 

Herer are the sequences.

 

Write Sequence: Start -> Slave Address -> Ack(slave) -> Sub Address -> Ack(slave) -> Data -> Ack(slave) ........ -> Data -> Ack (slave) -> Stop.

 

Read Sequence: Start -> Slave Address (LSB=0)  -> Ack(slave) -> Sub Address -> Ack (slave) -> Start -> Slave Address (LSB=1) -> Ack(slave) -> Data -> Ack(master) -> ......Data -> NAck(Master) -> Stop

 

 

Currently, I am using InternalI2C library. (CI2C1.c and CI2C1.h)

 

I used

byte CI2C1_SendBlock(void* Ptr,word Siz,word *Snt)

for Write Sequence.

 

Herer are the codes.

word send;

word send_len;

send= 0x0927;

send_len=2U;

CI2C1_SelectSlave(0x48);

CI2C1_SendBlock(&send, 2U, &send_len);

 

This SendBlock makes the write sequence well.

 

However, the problem is that the read sequence requires No Stop bit, One single Start bit in the middle of the sequence.

Using SendBlock, and RecvChar,they generate Stop bit and Start bit, Slave Address.

ex)

Case : Master reads Slave's 0x07 data. (Slave address is 0x91 including read bit. 7-bit address is 0x48)

 

 

unsigned char a;

CI2C1_SelectSlave(0x48);

CI2C1_SendChar(0x07);

CI2C1_RecvChar(&a);

 

then, the results are shown below.

 

Start-> 0x90 (0x48 + Write bit:0 ) -> Ack(slave) -> 0x07 -> Ack(slave) -> Stop --> Start ->0x91 (0x48 + Read bit:1) -> Ack(slave) -> DATA -> NAck(Master)=1 -> Stop

 

because of the Stop bit, the received data (DATA) are incorrect. ( the read data after the stop bit always represents initial data (0x00 address's data).

 

How to remove the Stop bit?

标签 (1)
0 项奖励
回复
1 回复

1,072 次查看
ldom
Contributor I

STOP signal generation is under software control: You can generate a STOP condition by writing the MS/SL bit to zero in the IBCR register. Similarly you could do a byte transfer without writing this bit to zero, and avoid generating the stop condition you want to remove. For this we need to look inside your libraries, probably inside the CI2C1_RecvChar() function.

0 项奖励
回复