cpu/sam0: add support for SAMD5x/SAME5x#11305
Conversation
|
@Sizurka found a clever way to automatically generate I actually used this (with Maybe we can make this common for all sam0 SoCs here too. |
|
@benpicco Nice PR ! I have zero experience with SAM4 but this should not belongs to cpu/sam0 |
|
@dylad I think this has more in common with sam0 than with the older sam parts. saml1x doesn't come with a Cortex-M0+ either, it's pretty much just that but with a Cortex-M4F instead of Cortex-M23. I feel like the thing that separates the sam0 from the sam is that it comes with the SERCOM peripherals - there are differences in other peripherals too that are different between the sam and the sam0 families but similar across sam0 members, but that's the most prominent difference imho. |
8dc03f0 to
23d901e
Compare
be14127 to
b2a9490
Compare
cpu/samd5x/periph/pm.c
Outdated
| while (PM->SLEEPCFG.bit.SLEEPMODE != _mode) {} | ||
| } | ||
|
|
||
| cortexm_sleep(mode); |
There was a problem hiding this comment.
There are now four variants of this (see cpu/sam*/periph/pm.c), all have a different approach to call cortexm_sleep. In this implementation it is important to identify that only mode == 0 does a light sleep. The other modes do a deep sleep. I don't see it being documented.
Also the mapping 0->STANDBY, 1->IDLE2, 2->IDLE1, 3->IDLE0 needs explanation or documentation.
There was a problem hiding this comment.
Actually all modes but 0 do a light sleep - but just looking at the power consumption, PM_SLEEPCFG_SLEEPMODE_IDLE2 is the default anyway if only cortexm_sleep() is called.
This MCU also supports three deep sleep states (STANDBY, HIBERNATE & BACKUP) but since pm_layered only supports 4 sleep modes (and on all other sam0 boards modes 1-3 are used for light sleep / idle and I wanted to keep the semantics the same), only the deepest one is exposed. The RTC still can wake the MCU in this mode which is good enough for me.
Since all the sam0s expose different sets of sleep states I think the pain of light code duplication is still less than that that of a confusing mess of #ifdefs in a common version.
There was a problem hiding this comment.
Ok, so BACKUP only works if Vbat is connected (but allows to retain some RAM) whereas HIBERNATE always works, so I'm switching to that by default.
Apparently they both work fine, just not right after flashing the device - I have to disconnect the power and reconnect it again after I flash the device, then it's working.
|
The two "sam0_common:" commits should preferably have their own PullRequest. No? Even if this PR depends on it. |
|
(( Shit, these buttons are too close :-( |
98fb9a6 to
a703cf9
Compare
|
This keeps puzzling me. When I use the 48 MHz DFLL I get
With 120 MHz DPLL0 :
Only when I overclock the CPU to 128 MHz I get both a stable and correct clock. |
Enabling a second PLL may not be the best solution especially for the power consumption.
Could you elaborate which clock and what is wrong there ? I also tried this conf but I don't have a burst of 4600us.
I don't get why we have a so much offset with this config... |
(120 MHz / 4) / 16 = 1.875 MHz - but xtimer expects a 1MHz clock. same for (120 MHz / 2) / 64 = 0.9375 MHz I can't explain the offset either - especially since we are using the same timer to set the alarm and measure the offset. |
|
periph_flashpage should work now. I've tested the change on both the same54-xpro & samr21-xpro, the output of Interestingly, |
|
An update on the xtimer situation: When I add edit: In fact, it looks like a delay is needed between writing I found |
|
The timer tests should work now with #11610 applied. |
cae1013 to
c400894
Compare
72b1ac1 to
b990da0
Compare
a5b726e to
2e6df02
Compare
Atmel Software Framework (ASF) provides a set of low-level header files that give access to different hardware peripherals of Atmel's ICs. Origin: Atmel SAME54 Series Device Support (1.0.87) License: Apache-2.0 URL: http://packs.download.atmel.com/Atmel.SAME54_DFP.1.0.87.atpack
Atmel Software Framework (ASF) provides a set of low-level header files that give access to different hardware peripherals of Atmel's ICs. Origin: Atmel SAMD51 Series Device Support (1.1.96) License: Apache-2.0 URL: http://packs.download.atmel.com/Atmel.SAMD51_DFP.1.1.96.atpack
This adds supoprt for the Atmel SAMD51 & SAME54 SoC. The SAME5x/SAMD5x is a line of Cortex-M4F MCUs that share peripherals with the samd2x Cortex-M0+ and saml1x Cortex-M23 parts.
This adds support for the Atmel SAM E54 Xplained Pro Evaluation Kit. Only basic functionality has been enabled.
|
Here we go |
Contribution description
This adds support for the Atmel SAMD51 & SAME54 Cortex M4F MCU from the SAM D5x/E5x family and the SAM E54 Xplained Pro Evaluation Board.
The SAMD5x family shares it's peripherals with other sam0 MCUs like the saml1x on which most of this code is based.
So far, UART, I2C, SPI, Timer, RTC and GPIOs have been tested.
There is an awful lot of copy and paste going on between
saml1x/periphandsame54/periphwith only minor differences inpm.candtimer.c(SAMD5x supports more sleep states and needs to combine two timers to make a 32bit timer).Testing procedure
Flash an example application (e.g.
examples/defaultorexamples/timer_periodic_wakeup) usingmake BOARD=same54-xpro flash termand observe that the application behaves as expected.