[f28335] I2C transmit status

17 views (last 30 days)
Jirada Gosumbonggot
Jirada Gosumbonggot on 10 Jan 2019
Answered: Venkatesh Chilapur on 27 Mar 2019
Hi
I'm trying to program the DSP F28335 using simulink.
I want the program to send the numerical data (either 0 or 1) via the I2C transmit block. The I2C should send the data and received by the connected arduino.
I also would like to check whether the I2C is really send the data so I checked the "output transmitting status" option in the block.
However, when I run the program the status displays the number "5254" which I don't know what this value means. Also the arduino seems does not receive the transmitted data. I tried look up in "help", but it shows no explanation on the number.
Could you please suggest me the meaning of 5254 status and how can I check whether the I2C block is working or not?
Thank you
JJ
Capture.JPG
Capture1.PNG
Capture2.PNG

Answers (2)

Venkatesh Chilapur
Venkatesh Chilapur on 10 Jan 2019
Hi,
Please refer to below link:
The status value is the value as contained in the device I2C status register.
"Status values from the I2C status register (I2CSTR)."
You can decode the status by comparing the bitfields from the I2C status register to the value '5254'.
You can also refer the I2C examples for more information around these blocks.
Regards,
Venkatesh C

Venkatesh Chilapur
Venkatesh Chilapur on 27 Mar 2019
Hi,
Please note when trying to use the I2C Tx and Rx blocks in an implementation for reading multiple bytes of data from slave, one needs to taken in to account the sequencing of the I2C Tx and Rx blocks execution. The reason for this to be done is, the I2C Tx block tries to first set the register address with slave from which to read the value and while this operation is active at the device level(I2C module is shifting the FIFO register content out on bus) the I2C Rx block would get executed. Since the success of I2C Rx block depends on the successful completion of operation I2C Tx block at hardware level, so a small delay is required before I2C Rx operation can be initiated.
There are multiple ways to achieve the same.
  1. A small software delay can be introduced between I2C Tx block and I2C Rx block and block priority can be set such that order of execution of these blocks follows this: - > I2C_Tx->Delay->I2C_Rx. An implementation of the same can be found in our example model: c28x_i2c_eeprom - under 'EEPROM Data Read' subsystem.
  2. You can also configure the I2C_Tx block to execute at the end of the current of cycle, such that the data for read is ready for next cycle. The block priority of I2C_Tx block is lower(higher number) than I2C_Rx block thus keeping the I2C_Tx block in the end to keep device ready for read for next cycle. Please refer the example: c28x_i2c_sensor for more details.
  3. Lastly, you can configure the I2C receive interrupt and react on the interrupt to read the data. This eliminates the drawbacks of 2 approach we took above. While in 1st case we can get away with delay, in the 2nd case we are reading the delayed data. Please refer the model - c28x_i2c_eeprom_interrupt.
All above models are discussed in detail at the following page:
Regards,
Venkatesh C

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!