i2c connection with a DEMO9S08QG8

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

i2c connection with a DEMO9S08QG8

938 次查看
marmor
Contributor III

 

Hi I am trying to connect the DEMO9S08QG8 to a lcd  through Connection i2c but not working. This is the library I'm using for i2c communication does anyone know tell me what is wrong? I've been modifying a thousand times but do not know what the problem is

 

 

Mensaje editado por: Maria Mor

Original Attachment has been moved to: i2c.rar

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

727 次查看
iansmusical
Contributor V

Hi Maria,

I can't completely see a path through your code but presuming your S08 is the master and the LCD is a slave, I would have a look at the IICC MST bit. I'm not sure if you have it set when you start a transmission?

I'm also not sure that the two lines below the /* Reset 24c02 */ comment are necessary.

Thanks,

Ian

0 项奖励
回复

727 次查看
marmor
Contributor III

Hi Ian.

Effectively the DEMO9S08QG8 is the master and the slave plantalla lcd.
Regarding the MST bit, I think it's okay, it has to be 0 while not want to send a stop signal and when you want to stop sending data is the i2c_stop_condition () function to send the stop sign.

I do not understand what you mean with the "two lines below the / * Reset 24c02 * / comment".

I appreciate your comment and you've taken the time to look at the code.

0 项奖励
回复

727 次查看
iansmusical
Contributor V

Hi Maria,

Here is some code I used recently to read a status byte from an I2C slave. It looks quite similar to your code but I have to admit I am no expert on I2C ;-)

IICC_TXAK = 0;

  IICC |= 0x30;          // Generate START

  IICD = 0xEE;           // write to slave device

  while (!IICS_IICIF);   // wait until flag is set

  IICS_IICIF=1;          // Clear the int flag

  while(IICS_RXAK);      // Check for RXAK

  IICD = 0xD0;           // write command

  while (!IICS_IICIF);   // wait until flag is set

  IICS_IICIF=1;          // Clear the int flag

  while(IICS_RXAK);      // Check for RXAK

  IICC_RSTA = 1;         // setup repeated start

  IICD = 0xEE|1;         // (slave_address)|(RW = 1), read from slave

  while (!IICS_IICIF);   // wait until flag is set

  IICS_IICIF=1;          // Clear the int flag

  while(IICS_RXAK);      // Check for RXAK

  IICC_TX = 0;           // Setup to receive

  IICC_TXAK = 1;         // Acknowledge disable

  RD_data = IICD;        // Dummy read

  while (!IICS_IICIF);   // Wait until IBIF flag is set

  IICS_IICIF=1;          // Clear the flag

  IICC_MST = 0;          // Generate STOP

  RD_data = IICD;        // Read data

The MST bit is set on the "// Generate start" line but I can't fully see how it is configured in your code taken on board the comments you made in your email.

What I meant by the comment is that I don't think you need the I2C start and stop function calls under the /* Reset 24c02 */ comment, unless of course a 24c02 does require these calls :-) Usually slaves by default are listening for I2C bus activity etc.

Thanks,

Ian

0 项奖励
回复