Skip to main content
Contents Index
Search Book
Search Results:
No results.
Readability settings Prev Up Next
\(\newcommand{\N}{\mathbb N}
\newcommand{\Z}{\mathbb Z}
\newcommand{\R}{\mathbb R}
\newcommand{\lt}{<}
\newcommand{\gt}{>}
\newcommand{\amp}{&}
\definecolor{fillinmathshade}{gray}{0.9}
\newcommand{\fillinmath}[1]{\mathchoice{\colorbox{fillinmathshade}{$\displaystyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\textstyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\scriptstyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\scriptscriptstyle\phantom{\,#1\,}$}}}
\)
Subsection 2.2.1 Part 1: Code Review (blinkyCNT.c)
Each student has 2 late days, used at your discretion for lab assignments. Say so in a submission comment.
Submit within 24 hours of the deadline using a late day โ no penalty.
Otherwise: late labs accepted up to two days late (due date adjusted for used late days) at 10% per day.
After two days beyond the deadline, lab assignments are not accepted for credit.
You work alone on the labs unless we specifically say otherwise.
Interaction while learning is encouraged, but exchange ideas, not code. The work you turn in must be your own.
Copying any portion of another personโs code (or a design posted online / from another course) violates the Honor Principle.
Always cite your lab and study partners by name.
Give notice that you used an AI tool, and how, in your code comments and lab report.
If you base work on generated code, test it and adapt it to the assignment and to your own understanding.
You must understand any code you submit and be able to explain it. All comments must be in your own words.
Code review: blinkyCNT.c from Lab 1
Making measurements with the Analog Discovery 2 oscilloscope
Wiring and reading a pushbutton switch
Button exercises: a head start on Lab 2
Wire up three LEDs.
blinkySIM.c: blink all three LEDs simultaneously.
blinkySEQ.c: blink the LEDs sequentially (a running light).
blinkyCNT.c: display a 3-bit binary count on the LEDs.
Weโll start with your
blinkyCNT.c from Lab 1. Share it within your table group, read each otherโs solutions, and explain the approach you used to display a 3-bit binary count on three LEDs. Reading somebody elseโs code and being able to explain it back is what a code review is.
Activity 2.2.1 . blinkyCNT Code Review.
(a)
Read your partnersโ code. Can you follow the logic? For each solution you read, identify how bits are placed into the correct LED positions in
GPIOA->ODR.
(b)
Compare the approach in the code below with your own. What does the shift
count << LED1_BIT accomplish? Why is it necessary to clear the LED bits first?
// Clear the three LED bits, then write the new count
GPIOA->ODR &= ~LED_ALL;
GPIOA->ODR |= (count << LED1_BIT);
Read each otherโs
blinkyCNT.c at your table, then compare with the approach below:
// Clear the three LED bits, then write the new count
GPIOA->ODR &= ~LED_ALL;
GPIOA->ODR |= (count << LED1_BIT);
In each solution you read, how do the countโs bits end up in the correct LED positions in GPIOA->ODR?
What does the shift count << LED1_BIT accomplish?
Why is it necessary to clear the LED bits first?