MQX 3.8.1 I2C Master mode question

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

MQX 3.8.1 I2C Master mode question

1,217件の閲覧回数
miniwang
Contributor III

Hi,

I meet some problem when I use MQX I2C.

The environment is [MQX3.8.1] & [CW10.2].

I2C mode is master mode.

 

1.

I would like to read one byte, but it transmit 2 bytes.

I have searched the information on this forum, there is a similar issue to mine. But it's happened in MQC 3.6.0 and slave mode. The code seems not the same, so I can't fix my issue with the solution.

please refer:  I2C Slave sample code

 

In _ki2c_polled_rx_tx funtion, there is a dummy read after send the receive requested, is it necessary?

Because this dummy read so I always see the extra waveform from my oscilloscope. I'm not familiar with I2C driver, don't know how to fix this issue.

(location-> C:\Program Files\Freescale\Freescale MQX 3.8\mqx\source\io\i2c\polled\i2c_pol_ki2c.c)

 

2.

When I call I2C_ReadByte(0x34,0x26). Although it transmit 2 bytes after the receive request, I can get the right return value : 0x0E, and the data/clock bus are fine(all high).

2945_2945.pngtek00001.png

 

But when I call I2C_ReadByte(0x34,0x27), I can't get the return value, cause the data bus keep low after the sceond byte is read.

2946_2946.pngtek00002.png

 

Why it's different result when I call the same funtion?

I have tried many address/offset, only I2C_ReadByte(0x34,0x26) can retrun the right value so far.

 

3.

the attached file: I2C.c is my code that refer to the sample code and document. In this file, only the I2C_WriteByte function is OK. If any one familiar with I2C, please help me to check is it any problem with my code? Thank you very much.

 

Thank you in advance.

 

Mini


Original Attachment has been moved to: I2C.c.zip

タグ(2)
0 件の賞賛
返信
1 返信

621件の閲覧回数
miniwang
Contributor III

one more question:

in i2c_pol_ki2c.c

-----------------------------------------------------------------

371      case IO_IOCTL_I2C_SET_RX_REQUEST:

372         if (NULL == param_ptr)

373         {

374            result = I2C_ERROR_INVALID_PARAMETER;

375         }

376         else

377         {

378            io_info_ptr->RX_REQUEST = *param_ptr;

379         }

380         break;

-----------------------------------------------------------------

After I set IO_IOCTL_I2C_SET_RX_REQUEST, the value of io_info_ptr->RX_REQUEST is 0x081FFF01 or 0x0281FFF01 or 0xC81FFF01(not the same every time). Should be this value?

in _ki2c_polled_rx_tx function, because the value is never equal to zero, so the code is never be executed.

-----------------------------------------------------------------

801    if (0 == io_info_ptr->RX_REQUEST)

802    {

803        i2c_ptr->C1 &= (~ I2C_C1_TX_MASK);

804        io_info_ptr->STATE = I2C_STATE_FINISHED;

805        length = i + 1;

806        i = length;

807    }

-----------------------------------------------------------------

Should I do another setting before I send IO_IOCTL_I2C_SET_RX_REQUEST?

I thought this value should be 0 or 1. not this huge one.

Thank you very much.

Mini

0 件の賞賛
返信