Skip to content
Snippets Groups Projects
Commit 017a17fc authored by Samuel Karlsson's avatar Samuel Karlsson
Browse files

added updated bare6

parent eb556cf4
Branches
No related tags found
No related merge requests found
...@@ -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_64mhz_low_speed" // sove the the picture as "bare_6_84mhz_low_speed"
// //
// commit your answers (bare6_24) // commit your answers (bare6_6)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment