Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
rtfm-app
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
Model registry
Operate
Environments
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
Samuel Karlsson
rtfm-app
Commits
017a17fc
Commit
017a17fc
authored
7 years ago
by
Samuel Karlsson
Browse files
Options
Downloads
Patches
Plain Diff
added updated bare6
parent
eb556cf4
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/bare6.rs
+36
-7
36 additions, 7 deletions
examples/bare6.rs
with
36 additions
and
7 deletions
examples/bare6.rs
+
36
−
7
View file @
017a17fc
...
@@ -2,15 +2,16 @@
...
@@ -2,15 +2,16 @@
//! Simple bare metal application
//! Simple bare metal application
//!
//!
#![feature(used)]
#![feature(used)]
#![feature(use_nested_groups)]
#![no_std]
#![no_std]
extern
crate
f4
;
extern
crate
stm32f40x
;
extern
crate
stm32f40x
;
#[macro_use]
#[macro_use]
extern
crate
cortex_m_debug
;
extern
crate
cortex_m_debug
;
use
f4
::
clock
;
use
stm32f40x
::{
DWT
,
GPIOA
,
GPIOC
,
RCC
};
use
f4
::
prelude
::
*
;
use
stm32f40x
::{
DWT
,
FLASH
,
GPIOA
,
GPIOC
,
RCC
};
fn
main
()
{
fn
main
()
{
ipln!
(
"init"
);
ipln!
(
"init"
);
...
@@ -18,9 +19,11 @@ fn main() {
...
@@ -18,9 +19,11 @@ fn main() {
let
rcc
=
unsafe
{
&
mut
*
RCC
.get
()
};
// get the reference to RCC in memory
let
rcc
=
unsafe
{
&
mut
*
RCC
.get
()
};
// get the reference to RCC in memory
let
gpioa
=
unsafe
{
&
mut
*
GPIOA
.get
()
};
// get the reference to GPIOA in memory
let
gpioa
=
unsafe
{
&
mut
*
GPIOA
.get
()
};
// get the reference to GPIOA in memory
let
gpioc
=
unsafe
{
&
mut
*
GPIOC
.get
()
};
// get the reference to GPIOC in memory
let
gpioc
=
unsafe
{
&
mut
*
GPIOC
.get
()
};
// get the reference to GPIOC in memory
let
flash
=
unsafe
{
&
mut
*
FLASH
.get
()
};
// get the reference to FLASH in memory
dwt
.enable_cycle_counter
();
dwt
.enable_cycle_counter
();
clock_out
(
rcc
,
gpioc
);
clock_out
(
rcc
,
gpioc
);
//clock::set_84_mhz(rcc, flash);
idle
(
dwt
,
rcc
,
gpioa
);
idle
(
dwt
,
rcc
,
gpioa
);
}
}
...
@@ -60,9 +63,11 @@ fn clock_out(rcc: &mut RCC, gpioc: &mut GPIOC) {
...
@@ -60,9 +63,11 @@ fn clock_out(rcc: &mut RCC, gpioc: &mut GPIOC) {
.ospeedr
.ospeedr
.modify
(|
_
,
w
|
unsafe
{
w
.ospeedr9
()
.bits
(
0b11
)
});
.modify
(|
_
,
w
|
unsafe
{
w
.ospeedr9
()
.bits
(
0b11
)
});
}
}
// user application
// user application
fn
idle
(
dwt
:
&
mut
DWT
,
rcc
:
&
mut
RCC
,
gpioa
:
&
mut
GPIOA
)
{
fn
idle
(
dwt
:
&
mut
DWT
,
rcc
:
&
mut
RCC
,
gpioa
:
&
mut
GPIOA
)
{
ipln!
(
"idle"
);
ipln!
(
"idle"
);
// power on GPIOA, RM0368 6.3.11
// power on GPIOA, RM0368 6.3.11
rcc
.ahb1enr
.modify
(|
_
,
w
|
w
.gpioaen
()
.set_bit
());
rcc
.ahb1enr
.modify
(|
_
,
w
|
w
.gpioaen
()
.set_bit
());
...
@@ -145,9 +150,33 @@ fn idle(dwt: &mut DWT, rcc: &mut RCC, gpioa: &mut GPIOA) {
...
@@ -145,9 +150,33 @@ fn idle(dwt: &mut DWT, rcc: &mut RCC, gpioa: &mut GPIOA) {
//
//
// commit your answers (bare6_4)
// commit your answers (bare6_4)
//
//
// 5. now reprogram the PC9 to be "Low Speed", and re-run at 64Mz
// 5. now we will put the MCU in 84MHz using the function
// clock::set_84_mhz(rcc, flash);
//
// this function is part of the `f4` support crate (by Johonnes Sjölund)
// besides `rcc` (for clocking) it takes `flash` as a parameter to set
// up correct latency (wait states) for the flash memory (where our
// program typically resides). This is required since the flash cannot
// operate at the full 84MHz, so the MCU has to wait for the memory.
//
// repeat the experiment 2.
// what is the frequency of MCO2 read by the oscilloscope
// ** your answer here **
//
// compute the value of SYSCLK based on the oscilloscope reading
// ** your answer here **
// what is the peak to peak reading of the signal
//
// ** your answer here **
//
// make a screen dump or photo of the oscilloscope output
// sove the the picture as "bare_6_84mhz_high_speed"
//
// commit your answers (bare6_5)
//
// 6. now reprogram the PC9 to be "Low Speed", and re-run at 64Mz
//
//
// did the frequency change in comparison to assignment
4
.
// did the frequency change in comparison to assignment
5
.
// ** your answer here **
// ** your answer here **
//
//
// what is the peak to peak reading of the signal
// what is the peak to peak reading of the signal
...
@@ -157,6 +186,6 @@ fn idle(dwt: &mut DWT, rcc: &mut RCC, gpioa: &mut GPIOA) {
...
@@ -157,6 +186,6 @@ fn idle(dwt: &mut DWT, rcc: &mut RCC, gpioa: &mut GPIOA) {
// ** your answer here **
// ** your answer here **
//
//
// make a screen dump or photo of the oscilloscope output
// make a screen dump or photo of the oscilloscope output
// sove the the picture as "bare_6_
6
4mhz_low_speed"
// sove the the picture as "bare_6_
8
4mhz_low_speed"
//
//
// commit your answers (bare6_
24
)
// commit your answers (bare6_
6
)
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