Skip to main content

Subsection 2.2.1 Part 1: Code Review (blinkyCNT.c)

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);