atmega_common/periph/spi: bugfix for CLOCK_CORECLOCK != 16MHz#16811
Closed
hugueslarrive wants to merge 3 commits intoRIOT-OS:masterfrom
Closed
atmega_common/periph/spi: bugfix for CLOCK_CORECLOCK != 16MHz#16811hugueslarrive wants to merge 3 commits intoRIOT-OS:masterfrom
hugueslarrive wants to merge 3 commits intoRIOT-OS:masterfrom
Conversation
hugueslarrive
added a commit
to hugueslarrive/RIOT
that referenced
this pull request
Sep 4, 2021
drivers/include/periph/spi.h: add a function which return the effective SPI clock rate for a requested clock frequency cpu/stm32/periph/spi: implementation cpu/atmega_common/periph/spi: implementation + bugfix (RIOT-OS#16811) cpu/atxmega/periph/spi: implementation cpu/cc2538/periph/spi: implementation cpu/efm32/periph/spi: implementation cpu/esp_common/periph/spi: implementation cpu/fe310/periph/spi: implementation cpu/kinetis/periph/spi: implementation cpu/lm4f120/periph/spi: implementation cpu/lpc23xx/periph/spi: implementation cpu/msp430fxyz/periph/spi: implementation cpu/nrf51/periph/spi: implementation cpu/nrf52/periph/spi: implementation cpu/qn908x/periph/spi: implementation cpu/sam0_common/periph/spi: implementation cpu/sam3/periph/spi: implementation
38 tasks
hugueslarrive
added a commit
to hugueslarrive/RIOT
that referenced
this pull request
Sep 8, 2021
- adapted to the new API (RIOT-OS#15904) - arbitrary bus speed support (improves RIOT-OS#16811)
Contributor
Author
|
Improved with arbitrary speed support in #16727. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Contribution description
In
atmega_common/include/periph_cpu_common.hsti_clk_t enum was overridden with a kind of encoded register bits assuming a master clock speed of 16MHz.This leads into a (CLOCK_CORECLOCK / 16MHz) ratio for SPI_CLK_* for boards boards like atmega1284p where CLOCK_CORECLOCK differ from 16MHz.
In addition, the first two values were greater than the named values which does not comply with the usual rule.
Testing procedure
With ENABLE_DEBUG set to 1, build tests/periph_spi for atmega1284p:
CLOCK_CORECLOCK (8000000UL)
Measured period on SCK pin
CLOCK_CORECLOCK (10000000UL)
CLOCK_CORECLOCK (16000000UL)
I do not have a 16MHz crystal so the serial connection was made at 4800 bauds and the period measurements were divided by 2.
Measured period on SCK pin
CLOCK_CORECLOCK (20000000UL)
CLOCK_CORECLOCK (32000000UL)
Measured period on SCK pin
Issues/PRs references
#16727 (comment)