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,756 次查看
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 回复数

628 次查看
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 项奖励
回复

628 次查看
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 项奖励
回复

628 次查看
JimDon
Senior Contributor III
You could do it polled. Just better be a tight loop.

0 项奖励
回复