Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
portapack-mayhem
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
mcules
portapack-mayhem
Commits
30f2bc41
Commit
30f2bc41
authored
7 years ago
by
Jared Boone
Browse files
Options
Downloads
Patches
Plain Diff
Clock Manager: Add API to measure LPC43xx clock inputs against IRC oscillator.
parent
804ebd25
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
firmware/application/clock_manager.cpp
+24
-0
24 additions, 0 deletions
firmware/application/clock_manager.cpp
firmware/application/clock_manager.hpp
+4
-0
4 additions, 0 deletions
firmware/application/clock_manager.hpp
with
28 additions
and
0 deletions
firmware/application/clock_manager.cpp
+
24
−
0
View file @
30f2bc41
...
...
@@ -422,6 +422,30 @@ void ClockManager::disable_gp_clkin_source() {
clock_generator
.
disable_output
(
clock_generator_output_mcu_clkin
);
}
void
ClockManager
::
start_frequency_monitor_measurement
(
const
cgu
::
CLK_SEL
clk_sel
)
{
// Measure a clock input for 480 cycles of the LPC43xx IRC.
LPC_CGU
->
FREQ_MON
=
LPC_CGU_FREQ_MON_Type
{
.
RCNT
=
480
,
.
FCNT
=
0
,
.
MEAS
=
0
,
.
CLK_SEL
=
toUType
(
clk_sel
),
.
RESERVED0
=
0
};
LPC_CGU
->
FREQ_MON
.
MEAS
=
1
;
}
void
ClockManager
::
wait_For_frequency_monitor_measurement_done
()
{
// FREQ_MON mechanism fails to finish if there's no clock present on selected input?!
while
(
LPC_CGU
->
FREQ_MON
.
MEAS
==
1
);
}
uint32_t
ClockManager
::
get_frequency_monitor_measurement_in_hertz
()
{
// Measurement is only as accurate as the LPC43xx IRC oscillator,
// which is +/- 1.5%. Measurement is for 480 IRC clcocks. Scale
// the cycle count to get a value in Hertz.
return
LPC_CGU
->
FREQ_MON
.
FCNT
*
25000
;
}
void
ClockManager
::
enable_xtal_oscillator
()
{
LPC_CGU
->
XTAL_OSC_CTRL
.
BYPASS
=
0
;
LPC_CGU
->
XTAL_OSC_CTRL
.
ENABLE
=
1
;
...
...
This diff is collapsed.
Click to expand it.
firmware/application/clock_manager.hpp
+
4
−
0
View file @
30f2bc41
...
...
@@ -66,6 +66,8 @@ public:
void
set_reference_ppb
(
const
int32_t
ppb
);
uint32_t
get_frequency_monitor_measurement_in_hertz
();
private
:
I2C
&
i2c0
;
si5351
::
Si5351
&
clock_generator
;
...
...
@@ -75,6 +77,8 @@ private:
void
enable_gp_clkin_source
();
void
disable_gp_clkin_source
();
void
start_frequency_monitor_measurement
(
const
cgu
::
CLK_SEL
clk_sel
);
void
wait_For_frequency_monitor_measurement_done
();
void
enable_xtal_oscillator
();
void
disable_xtal_oscillator
();
...
...
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