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::{ ...@@ -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".
......
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