I2C GPIO Configuration

Status
Not open for further replies.

chandu.kurapati

Full Member level 3
Joined
Oct 31, 2013
Messages
186
Helped
5
Reputation
10
Reaction score
5
Trophy points
1,298
Location
Bengaluru, India
Visit site
Activity points
2,778
Hi every one,
Iam working with I2C now, iam configured the GPIO pin for SDA line as a output but iam reading and writing the data to/from the micro controller, my question is when we configured the GPIO pin as a output it is acted output only but in I2C why it is acted as a input also and reading the data, please suggest me a best answer.

Thanks & Regards,
Chandu.kurapati
 

Hi,
What microcontroller do you use?

The SDA line of I2C has to be bidirectional. Otherwise the I2C does not work.

If you configure the port pin to be the SDA line it is input and output.
On some microcontroller enabling of I2C overwrites the port setting.


Hope this helps.
Klaus
 

Iam working with different types of micro controllers,and i am communicating with the slave RTC PCF8523, what ever your saying that is correct I2C is a bi-directional.

But iam configuring the GPIO pin as a output first written the all RTC data i.e sec,min etc.. into the RTC register it is correct, then iam reading the all RTC data from the slave correctly but here point is micro controller reading the data from the slave that means GPIO pin must be input but here iam configuring as GPIO as output only why is it working

i can n't understand please reply me with best answer.

Thanks&Regards
Chandu.Kurapati

- - - Updated - - -

Iam getting one solution for this, when we configuring the I2C or other protocol GPIO configuration is independent on input or output it is depend only on alternative function is it correct or wrong, if it is wrong please suggest me correct solution.

Thanks & Regards
Chandu.Kurapati
 

In micro-controller when you are configuring I2C module the the SDA pin will configure as output first and after that it depends on read/write bit.
 

Hi Heram,
when we are working with the I2C or other high end protocols like UART,SPI etc... , there some defined functionality implemented for that GPIO is as an alternative function, when we configuring the GPIO for this protocols mask the alternative functionality also at that time that pin works as input or output depend upon the data and clock direction.

Thanks & Regards,
Chandu.Kurapati.
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…