Skip to main content

Subsection 1.2.5 Before Day 1X: Design and Build in the Simulator

Tomorrow we’ll run blinkySlowToFast.c on your Nucleo: the LED starts slow, speeds up blink by blink, then resets to slow and repeats. Before class, get it working in the ENGS 28 board simulator. The link at the bottom of this page opens it in a new tab. The simulator runs the same register-level C right in your browser and shows a simulated LED, so you can get the logic right without any hardware. In class we’ll port your working code to the real board.

Activity 1.2.5. Design and Build blinkySlowToFast in the Simulator.

Your job is to make the LED start slow, speed up blink by blink, then reset to slow and repeat. Design the logic first, then build it in the simulator. You already know that the delay-loop bound controls the blink rate, so the ramp is really a question of how that bound changes over time.

(a)

Design first. What variable will control the delay, and how does it change from one blink to the next? How will the program know it has reached “fast” and should reset to “slow”? Start by writing the logic of main() in plain English or pseudocode before you write any C.

(b)

Warm up. Open the simulator, which comes loaded with the same blinky.c you ran in class. Confirm the simulated LED blinks and that you can read the register panel as your code runs.

(c)

Build it. Implement your blinkySlowToFast design in the simulator until the LED ramps slow → fast → reset → repeat. Use descriptive constant names for the starting delay, the ending delay, and the step size.

(d)

The simulator does not save your code. If you reload or close the tab your work is gone, so use the download button (the downward arrow) to keep a copy on your own computer before you move on. Tomorrow you will port it to the real Nucleo. Note one thing you are unsure will behave the same on real hardware.
The link below opens the simulator we built for this course in a new tab, loaded with blinky.c as you saw it in class. Edit it, press Run to watch the simulated LED, or Step to walk the program one line at a time and watch MODER and ODR change in the register panel.