commanderx16 / x16-rom

Other
153 stars 44 forks source link

Cannot set RTC due to Z flag semantics in i2c_write #323

Open jburks opened 2 years ago

jburks commented 2 years ago

In #271 the sda_low function was changed to use a tsb instruction instead of an ora/sta pair. It is possible for i2c_write to branch to rec_bit and then fall through to sda_low which can ultimately cause i2c_write to return with the Z flag set using different semantics than expected.

This issue is causing i2c_write_byte to branch to its error exit point when no error has occurred. This is the root cause of failures to set the time on the real-time clock on r40 and r41.