I'm driving a open collector device (I2C memory) using self made driver. I use PTB2 and PTB3 as SDA and SCL. On another pin of the same port (PTB4) I have a LED which blink at low frequency (25z). To drive SDA I switch the associated data direction bit (PTBDD3) to input, with external pullup resistor, if I want an high level, to output with value 0 if I want a low level.
In this situation, if I run the firmware it give to me write errors after a random time (2s, 9s, ...). I have the same problem if I remove physically the led but I keep unaltered the led driver (square wave at 25Hz).
I solve the problem if I remove the square wave on the led pin and/or change the port, from PTB to PTA.
This is a very annoying problem. Could anyone help me?
Thank you in advance