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] rework TWI module #340

Merged
merged 19 commits into from
Jun 10, 2022
Merged

[rtl] rework TWI module #340

merged 19 commits into from
Jun 10, 2022

Conversation

stnolting
Copy link
Owner

@stnolting stnolting commented Jun 9, 2022

Triggered by the issues found in #339 this PR provides a complete makeover of the TWI module's hardware. These changes do not impact hardware utilization.

✔️ Optimizations and Fixes

  • VHDL code clean-up
  • fixed problem with synchronization of a new operation (START, STOP, transmission) to the TWI clock
  • SDA will be set LOW after a byte transmission to keep the bus claimed
  • data is now sampled from the bus right in the center of SCL's high period
  • less transmission overhead (faster)

✨ New Features

  • add new status flag to the TWI control register to check if the TWI is currently claimed (by the NEORV32 TWI module or by any other controller): bit 29, TWI_CTRL_CLAIMED, read-only; set if the TWI is busy or if SDA and SCL are both low

⚠️ Relevant Changes

  • the "START condition executed" interrupt is removed
  • the "STOP condition executed" interrupt is removed
  • the interrupt will only fire when a byte transmission has completed

Exemplary TWI operation using the modified module from this PR:

twi

START condition, transfer 0x70, transfer 0xF1, STOP condition. TWI bus is not connected to any device; SDA and SCL are just connected to "pull-up resistors" (-> 'H'); hence, a high level is sampled in the ACK time slot (=NACK). Note the interrupt requests right at the end of each byte transmission.

@stnolting stnolting added HW Hardware-related optimization Make things faster, smaller and more efficient labels Jun 9, 2022
@stnolting stnolting self-assigned this Jun 9, 2022
@stnolting stnolting linked an issue Jun 9, 2022 that may be closed by this pull request
@stnolting stnolting marked this pull request as ready for review June 9, 2022 13:48
@stnolting stnolting added the enhancement New feature or request label Jun 9, 2022
stnolting added 4 commits June 9, 2022 17:40
* make sure TWI bus stays claimed (SDA = SCL = low) after a byte transmission
* make sure the ACK sample time slot has the same "length" as the other data sampling time slots
@stnolting stnolting merged commit 2ddad3f into main Jun 10, 2022
@stnolting stnolting deleted the rework_twi branch June 10, 2022 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request HW Hardware-related optimization Make things faster, smaller and more efficient
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TWI Accidentally bit left shift after byte transmission
1 participant