Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
E
e7020e_2021
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
Package 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
Carl Österberg
e7020e_2021
Commits
5e1feb41
Commit
5e1feb41
authored
4 years ago
by
Carl Österberg
Browse files
Options
Downloads
Patches
Plain Diff
bare6_5
parent
07af795f
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
examples/rtic_bare6.rs
+20
-12
20 additions, 12 deletions
examples/rtic_bare6.rs
pictures/bare_6_16mhz_high_speed
+0
-0
0 additions, 0 deletions
pictures/bare_6_16mhz_high_speed
pictures/bare_6_48mhz_high_speed
+0
-0
0 additions, 0 deletions
pictures/bare_6_48mhz_high_speed
with
20 additions
and
12 deletions
examples/rtic_bare6.rs
+
20
−
12
View file @
5e1feb41
...
@@ -18,7 +18,8 @@ use stm32f4xx_hal::{
...
@@ -18,7 +18,8 @@ use stm32f4xx_hal::{
stm32
::{
self
,
GPIOC
,
RCC
},
stm32
::{
self
,
GPIOC
,
RCC
},
};
};
const
OFFSET
:
u32
=
8_000_000
;
//const OFFSET: u32 = 8_000_000;
const
OFFSET
:
u32
=
24_000_000
;
#[rtic::app(device
=
stm32f4xx_hal::stm32,
monotonic
=
rtic::cyccnt::CYCCNT,
peripherals
=
true
)]
#[rtic::app(device
=
stm32f4xx_hal::stm32,
monotonic
=
rtic::cyccnt::CYCCNT,
peripherals
=
true
)]
const
APP
:
()
=
{
const
APP
:
()
=
{
...
@@ -55,15 +56,14 @@ const APP: () = {
...
@@ -55,15 +56,14 @@ const APP: () = {
let
rcc
=
device
.RCC
.constrain
();
let
rcc
=
device
.RCC
.constrain
();
let
_clocks
=
rcc
.cfgr
.freeze
();
//let _clocks = rcc.cfgr.freeze();
//rprintln!("mhz: {:?}", _clocks.sysclk());
//Set up the system clock. 48 MHz?
//Set up the system clock. 48 MHz?
//
let _clocks = rcc
let
_clocks
=
rcc
//
.cfgr
.cfgr
//
.sysclk(48.mhz())
.sysclk
(
48
.mhz
())
//
.pclk1(24.mhz())
.pclk1
(
24
.mhz
())
//
.freeze();
.freeze
();
// let _clocks = rcc
// let _clocks = rcc
// .cfgr
// .cfgr
...
@@ -123,22 +123,22 @@ fn clock_out(rcc: &RCC, gpioc: &GPIOC) {
...
@@ -123,22 +123,22 @@ fn clock_out(rcc: &RCC, gpioc: &GPIOC) {
// mco2 : SYSCLK = 0b00
// mco2 : SYSCLK = 0b00
// mcopre : divide by 4 = 0b110
// mcopre : divide by 4 = 0b110
rcc
.cfgr
rcc
.cfgr
.modify
(|
_
,
w
|
unsafe
{
w
.mco2
()
.
bits
(
0b00
)
.mco2pre
()
.
bits
(
0b110
)
});
.modify
(|
_
,
w
|
unsafe
{
w
.mco2
()
.
sysclk
(
)
.mco2pre
()
.
div4
(
)
});
// power on GPIOC, RM0368 6.3.11
// power on GPIOC, RM0368 6.3.11
rcc
.ahb1enr
.modify
(|
_
,
w
|
w
.gpiocen
()
.
set_bit
());
rcc
.ahb1enr
.modify
(|
_
,
w
|
w
.gpiocen
()
.
enabled
());
// MCO_2 alternate function AF0, STM32F401xD STM32F401xE data sheet
// MCO_2 alternate function AF0, STM32F401xD STM32F401xE data sheet
// table 9
// table 9
// AF0, gpioc reset value = AF0
// AF0, gpioc reset value = AF0
// configure PC9 as alternate function 0b10, RM0368 6.2.10
// configure PC9 as alternate function 0b10, RM0368 6.2.10
gpioc
.moder
.modify
(|
_
,
w
|
w
.moder9
()
.
bits
(
0b10
));
gpioc
.moder
.modify
(|
_
,
w
|
w
.moder9
()
.
alternate
(
));
// otyper reset state push/pull, in reset state (don't need to change)
// otyper reset state push/pull, in reset state (don't need to change)
// ospeedr 0b11 = very high speed
// ospeedr 0b11 = very high speed
gpioc
.ospeedr
.modify
(|
_
,
w
|
w
.ospeedr9
()
.
bits
(
0b11
));
gpioc
.ospeedr
.modify
(|
_
,
w
|
w
.ospeedr9
()
.
high_speed
(
));
}
}
// 0. Background reading:
// 0. Background reading:
...
@@ -264,10 +264,12 @@ fn clock_out(rcc: &RCC, gpioc: &GPIOC) {
...
@@ -264,10 +264,12 @@ fn clock_out(rcc: &RCC, gpioc: &GPIOC) {
// Compute the value of SYSCLK based on the oscilloscope reading
// Compute the value of SYSCLK based on the oscilloscope reading
//
//
// ** your answer here **
// ** your answer here **
// (1 / 250*10^(-9))*4 = 16 MHz
//
//
// What is the peak to peak (voltage) reading of the signal?
// What is the peak to peak (voltage) reading of the signal?
//
//
// ** your answer here **
// ** your answer here **
// 8V
//
//
// Make a folder called "pictures" in your git project.
// Make a folder called "pictures" in your git project.
// Make a screen dump or photo of the oscilloscope output.
// Make a screen dump or photo of the oscilloscope output.
...
@@ -281,10 +283,13 @@ fn clock_out(rcc: &RCC, gpioc: &GPIOC) {
...
@@ -281,10 +283,13 @@ fn clock_out(rcc: &RCC, gpioc: &GPIOC) {
// What is the frequency of blinking?
// What is the frequency of blinking?
//
//
// ** your answer here **
// ** your answer here **
// 3 blinks per second
//
//
// Now change the constant `OFFSET` so you get the same blinking frequency as in 1.
// Now change the constant `OFFSET` so you get the same blinking frequency as in 1.
// Test and validate that you got the desired behavior.
// Test and validate that you got the desired behavior.
//
//
// Multiply OFFSET by a factor 3 and you will get the same results as before.
//
// Commit your answers (bare6_3)
// Commit your answers (bare6_3)
//
//
// 4. Repeat experiment 2
// 4. Repeat experiment 2
...
@@ -292,14 +297,17 @@ fn clock_out(rcc: &RCC, gpioc: &GPIOC) {
...
@@ -292,14 +297,17 @@ fn clock_out(rcc: &RCC, gpioc: &GPIOC) {
// What is the frequency of MCO2 read by the oscilloscope?
// What is the frequency of MCO2 read by the oscilloscope?
//
//
// ** your answer here **
// ** your answer here **
// 12MHz
//
//
// Compute the value of SYSCLK based on the oscilloscope reading.
// Compute the value of SYSCLK based on the oscilloscope reading.
//
//
// ** your answer here **
// ** your answer here **
// 48MHz
//
//
// What is the peak to peak reading of the signal?
// What is the peak to peak reading of the signal?
//
//
// ** your answer here **
// ** your answer here **
// 7.75V
//
//
// Make a screen dump or photo of the oscilloscope output.
// Make a screen dump or photo of the oscilloscope output.
// Save the the picture as "bare_6_48mhz_high_speed".
// Save the the picture as "bare_6_48mhz_high_speed".
...
...
This diff is collapsed.
Click to expand it.
pictures/
oscilloscope
→
pictures/
bare_6_16mhz_high_speed
+
0
−
0
View file @
5e1feb41
File moved
This diff is collapsed.
Click to expand it.
pictures/bare_6_48mhz_high_speed
0 → 100644
+
0
−
0
View file @
5e1feb41
File added
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