Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RIOT
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cm-projects
RIOT
Commits
de4611f8
Commit
de4611f8
authored
7 years ago
by
Hauke Petersen
Committed by
GitHub
7 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #6989 from photonthunder/samd21_waitstates
samd21/cpu:waitstates for low voltage
parents
5d5d4dc5
7a855157
Loading
Loading
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cpu/samd21/cpu.c
+20
-4
20 additions, 4 deletions
cpu/samd21/cpu.c
with
20 additions
and
4 deletions
cpu/samd21/cpu.c
+
20
−
4
View file @
de4611f8
...
@@ -22,6 +22,24 @@
...
@@ -22,6 +22,24 @@
#include
"periph_conf.h"
#include
"periph_conf.h"
#include
"periph/init.h"
#include
"periph/init.h"
#ifndef VDD
/**
* @brief Set system voltage level in mV (determines flash wait states)
*
* @note Override this value in your boards periph_conf.h file
* if a different system voltage is used.
*/
#define VDD (3300U)
#endif
/* determine the needed flash wait states based on the system voltage (Vdd)
* see SAMD21 datasheet Rev A (2017) table 37-40 , page 816 */
#if (VDD > 2700)
#define WAITSTATES ((CLOCK_CORECLOCK - 1) / 24000000)
#else
#define WAITSTATES ((CLOCK_CORECLOCK - 1) / 14000000)
#endif
/**
/**
* @brief Configure clock sources and the cpu frequency
* @brief Configure clock sources and the cpu frequency
*/
*/
...
@@ -31,12 +49,10 @@ static void clk_init(void)
...
@@ -31,12 +49,10 @@ static void clk_init(void)
PM
->
APBAMASK
.
reg
=
(
PM_APBAMASK_PM
|
PM_APBAMASK_SYSCTRL
|
PM
->
APBAMASK
.
reg
=
(
PM_APBAMASK_PM
|
PM_APBAMASK_SYSCTRL
|
PM_APBAMASK_GCLK
);
PM_APBAMASK_GCLK
);
/* adjust NVM wait states, see table 42.30 (p. 1070) in the datasheet */
/* adjust NVM wait states */
#if (CLOCK_CORECLOCK > 24000000)
PM
->
APBBMASK
.
reg
|=
PM_APBBMASK_NVMCTRL
;
PM
->
APBBMASK
.
reg
|=
PM_APBBMASK_NVMCTRL
;
NVMCTRL
->
CTRLB
.
reg
|=
NVMCTRL_CTRLB_RWS
(
1
);
NVMCTRL
->
CTRLB
.
reg
|=
NVMCTRL_CTRLB_RWS
(
WAITSTATES
);
PM
->
APBBMASK
.
reg
&=
~
PM_APBBMASK_NVMCTRL
;
PM
->
APBBMASK
.
reg
&=
~
PM_APBBMASK_NVMCTRL
;
#endif
/* configure internal 8MHz oscillator to run without prescaler */
/* configure internal 8MHz oscillator to run without prescaler */
SYSCTRL
->
OSC8M
.
bit
.
PRESC
=
0
;
SYSCTRL
->
OSC8M
.
bit
.
PRESC
=
0
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment