I2C

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决
1,967 次查看
Psy_coder
Contributor II

When to use the function "I2C_MasterDeinit"

0 项奖励
回复
1 解答
1,961 次查看
nxf56274
NXP Employee
NXP Employee

Hi,

This is the function to deinitialize the i2c. When you do not need the i2c function, you can call it.

The other usage is this:  when the mcu has few pins, you may use different peripheral function at the same pin. For example, the pin has i2c and spi function. You can configure the pin as i2c at firstly , and then deinitialize the i2c. Configure the pin as spi. Finally, you can deinitialize  the spi and configure the pin as i2c. This is called Time division multiplexing.

 

 

Have a great day,
TIC

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 days after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

在原帖中查看解决方案

3 回复数
1,962 次查看
nxf56274
NXP Employee
NXP Employee

Hi,

This is the function to deinitialize the i2c. When you do not need the i2c function, you can call it.

The other usage is this:  when the mcu has few pins, you may use different peripheral function at the same pin. For example, the pin has i2c and spi function. You can configure the pin as i2c at firstly , and then deinitialize the i2c. Configure the pin as spi. Finally, you can deinitialize  the spi and configure the pin as i2c. This is called Time division multiplexing.

 

 

Have a great day,
TIC

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 days after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

1,947 次查看
myke_predko
Senior Contributor III

@nxf56274 

I understand the function of "I2C_MasterDeinit" but why would you use it in a practical application?  There's two aspects to this question:

The first is, wouldn't it be much more efficient to simply change the pin muxes to the new function and ignore using Deinit all together?  Maybe some SRAM resources would be freed, but I don't know how much would be saved vs the Flash space taken up by the method's code.  

Secondly, I know it's just your example, but I would never recommend that you share pins devoted to an I2C device with anything else - I2C devices run on an open drain "dotted AND" bus which means that I2C devices could attempt to drive the bus low if the signals to other devices cause them to respond.  

I know that when you're in an IO limited situation you need to start coming up with creative solutions to the problem, but implementing multiple bus types on the same IO pins should be discouraged.  

1,952 次查看
Psy_coder
Contributor II

Thanks, have a great day too

0 项奖励
回复