I need the C libraries to do a I2C comunication with a mi...

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

I need the C libraries to do a I2C comunication with a mi...

1,759件の閲覧回数
Nico_elect
Contributor I
I need the C libraries to do a I2C comunication with a microcontroller that hasn't the hardware. Can someone get me it?
Thanks.
ラベル(1)
0 件の賞賛
返信
3 返答(返信)

631件の閲覧回数
JimDon
Senior Contributor III
Processor Expert will generate the code for you for this task.

Create a PE project, then in the Add Bean dialog, look under "CPU External Devices"/"COmmunication"/ SW_IC2. This bean is a software I2C driver, that just uses GPIO bits.
You will have to select the bits for Data Pin and Clock Pin.

Here is a link to a project that does this. There is also some other handy code in it.
You can add a CPU bean for your processor.

0 件の賞賛
返信

631件の閲覧回数
fabio
Contributor IV
Hi Nico,

The bean Jim mentioned is a master-only software-emulated I2C interface. If you need an I2C slave device, it will be slightly more difficult. You will need to used the keyboard interrupts (or GPIO interrupts) to detect the clock as well as START and STOP conditions.

Of course, the I2C bus speed will be limited by the speed of your slave MCU. Your slave code could use the "clock-stretching" feature to slow-down the I2C bus.

Best regards,
0 件の賞賛
返信

631件の閲覧回数
JimDon
Senior Contributor III
You could do it polled. Just better be a tight loop.

0 件の賞賛
返信