FORUM TOPIC · READ ONLY

Question about I2C

Question about I2C

Forum : Request for new functions / Peripheral / Chip support

3 message(s) · archive en lecture seule

johan.b
Good morning all,



I have tried to use the I2C Master for my application and I have some questions concerning it.

My dspic reads I2C data, but the sequence of data changes as a function of the operating mode.



The state machine has 6 modes and these modes are identified by numbers: 1,2,3,4,5 and 6



In practice I have 2 sequences:



- The 1st for the operating mode numbers 2, 4 and 6. The dspic must read 12 words in these modes.

- The 2nd for the operating mode numbers 1, 3 and 5. The dspic must read 18 words in these modes.



At present, I have no available simulink model and I don't see how to manage this with the I2C master.



Maybe that anybody can help me ? Thank you in advance.



Johan
LubinKerhuel

Re: Question about I2C

Hi Johan,



On the example I have build, I read only

- 4 data for states 1 ; 3 and 5

- 2 data for states 2 ; 3 and 6

But you can easily adapt it to read 18 and 12 data.



I use an Enabled Subsystem to choose wether I am reading 4 or 2 data.


The model :

I use a bus to gather the data. When reading only 2 data, I place 0 into into the unfilled data.

Using a bus with a constant width of 4 is up to you. You could use the I2C data in a different way.


The merge block output the most recent data (refere to simulink help)




Pièce jointe : Enable_Subsystem.png

Pièce jointe : Model_General.png

Pièce jointe : FSM_1_3_5.png

Pièce jointe : FSM_2_4_6.png

Pièce jointe : I2C_MultipleSequence_FinitStateMachine.mdl

johan.b

Re: Question about I2C

Hello Lubin and thank you for your answer.

I will test your model and adapt it to my need.

Thank you.

Johan