Question about I2C

Post Reply
johan.b
Posts: 8
Joined: Thu Jan 31, 2008 8:39 am

Question about I2C

Post by johan.b » Fri Feb 15, 2008 8:49 am

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
Site Admin - Expert
Posts: 616
Joined: Wed Mar 07, 2007 11:23 pm
Location: Bayonne- France
Contact:

Re: Question about I2C

Post by LubinKerhuel » Mon Feb 18, 2008 11:10 pm

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.
Enable_Subsystem.png
The model :
Model_General.png
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.
FSM_1_3_5.png
FSM_1_3_5.png (14.85 KiB) Viewed 8998 times
FSM_2_4_6.png
FSM_2_4_6.png (12.26 KiB) Viewed 8999 times
The merge block output the most recent data (refere to simulink help)

I2C_MultipleSequence_FinitStateMachine.mdl
(39.31 KiB) Downloaded 525 times

johan.b
Posts: 8
Joined: Thu Jan 31, 2008 8:39 am

Re: Question about I2C

Post by johan.b » Thu Feb 21, 2008 9:25 am

Hello Lubin and thank you for your answer.
I will test your model and adapt it to my need.
Thank you.
Johan

Post Reply

Who is online

Users browsing this forum: No registered users and 14 guests