Skip to content
Snippets Groups Projects
Commit 5e1feb41 authored by Carl Österberg's avatar Carl Österberg
Browse files

bare6_5

parent 07af795f
No related branches found
No related tags found
No related merge requests found
......@@ -18,7 +18,8 @@ use stm32f4xx_hal::{
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)]
const APP: () = {
......@@ -55,15 +56,14 @@ const APP: () = {
let rcc = device.RCC.constrain();
let _clocks = rcc.cfgr.freeze();
//rprintln!("mhz: {:?}", _clocks.sysclk());
//let _clocks = rcc.cfgr.freeze();
//Set up the system clock. 48 MHz?
// let _clocks = rcc
// .cfgr
// .sysclk(48.mhz())
// .pclk1(24.mhz())
// .freeze();
let _clocks = rcc
.cfgr
.sysclk(48.mhz())
.pclk1(24.mhz())
.freeze();
// let _clocks = rcc
// .cfgr
......@@ -123,22 +123,22 @@ fn clock_out(rcc: &RCC, gpioc: &GPIOC) {
// mco2 : SYSCLK = 0b00
// mcopre : divide by 4 = 0b110
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
rcc.ahb1enr.modify(|_, w| w.gpiocen().set_bit());
rcc.ahb1enr.modify(|_, w| w.gpiocen().enabled());
// MCO_2 alternate function AF0, STM32F401xD STM32F401xE data sheet
// table 9
// AF0, gpioc reset value = AF0
// 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)
// ospeedr 0b11 = very high speed
gpioc.ospeedr.modify(|_, w| w.ospeedr9().bits(0b11));
gpioc.ospeedr.modify(|_, w| w.ospeedr9().high_speed());
}
// 0. Background reading:
......@@ -264,10 +264,12 @@ fn clock_out(rcc: &RCC, gpioc: &GPIOC) {
// Compute the value of SYSCLK based on the oscilloscope reading
//
// ** your answer here **
// (1 / 250*10^(-9))*4 = 16 MHz
//
// What is the peak to peak (voltage) reading of the signal?
//
// ** your answer here **
// 8V
//
// Make a folder called "pictures" in your git project.
// Make a screen dump or photo of the oscilloscope output.
......@@ -281,10 +283,13 @@ fn clock_out(rcc: &RCC, gpioc: &GPIOC) {
// What is the frequency of blinking?
//
// ** your answer here **
// 3 blinks per second
//
// Now change the constant `OFFSET` so you get the same blinking frequency as in 1.
// 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)
//
// 4. Repeat experiment 2
......@@ -292,14 +297,17 @@ fn clock_out(rcc: &RCC, gpioc: &GPIOC) {
// What is the frequency of MCO2 read by the oscilloscope?
//
// ** your answer here **
// 12MHz
//
// Compute the value of SYSCLK based on the oscilloscope reading.
//
// ** your answer here **
// 48MHz
//
// What is the peak to peak reading of the signal?
//
// ** your answer here **
// 7.75V
//
// Make a screen dump or photo of the oscilloscope output.
// Save the the picture as "bare_6_48mhz_high_speed".
......
File moved
File added
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment