Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[rtl] TWD idle when NoACK during reading #1158

Closed
wants to merge 1 commit into from

Conversation

LukasP46
Copy link
Contributor

Fixes #1157 and to my understanding should be TWI compliant.

@LukasP46
Copy link
Contributor Author

Explanation: this prevents the MSB to pull the SDA line down and thus preventing the stop command to be recognized.

@stnolting
Copy link
Owner

Ah I see. So we should also check for a STOP condition in the ACK time slot? Shouldn't we do this for read and write accesses?

@LukasP46
Copy link
Contributor Author

I guess checking for the stop anytime makes sense, but this problem might occur anyway since in my example the stop signal comes afterwards:
image
(Green with the patch, yellow without)

if (ctrl.enable = '0') then -- disabled?
if (
(ctrl.enable = '0') or -- disabled?
((engine.cmd = '1') and (smp.scl_rise = '1') and (smp.sda = '1') ) -- or no ACK while read?
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically, cou are checking for a STOP condition here, right?
Can't we use the smp.stop signal?

((engine.cmd = '1') and (smp.stop = '1')) -- STOP while read?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, as the stop signal is a SDA rise with SCL being one and not the other way around. This is more like reading the 9th bit: is the ack set or not? If not => I'm done (technically waiting for the stop), if yes => I send the next byte.

@stnolting
Copy link
Owner

Something isn't right with the TWD... 🙈
I'll take a close look at this tonight.

@stnolting stnolting marked this pull request as draft January 16, 2025 10:47
@stnolting
Copy link
Owner

I think there are several design flaws in the TWD 🙈
#1161 tries to fix them.

@LukasP46
Copy link
Contributor Author

Works with #1161, thanks!

@LukasP46 LukasP46 closed this Jan 17, 2025
@stnolting
Copy link
Owner

Great to hear and thanks for the feedback!

@LukasP46 LukasP46 deleted the twd-fixed branch January 24, 2025 12:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TWD going into idle depends on TX Fifo content
2 participants