Homework 1: Control the LEDs on PC10 and PC12¶
Objective¶
Modify the project SURNAME_1_STM32-UNO-LED_template to control the LED indicators connected to PC10 and PC12. Create your own repeating blinking pattern.
Your solution must demonstrate that you understand the template code and can correctly use loops and a software delay.
Hardware and documentation¶
Use the PCB documentation provided in the docs folder, especially the pin map and the STM32-UNO Programmer Guide.
| GPIO pin | Connector pin | LED indicators |
|---|---|---|
| PC10 | CONN-DIG2, pin 5 | D_B11 (blue), D_R11 (red) |
| PC12 | CONN-DIG2, pin 7 | D_B10 (blue), D_R10 (red) |
SKIP this part
Fit jumpers JP1 and JP2 to enable both LED indicator branches. According to the schematic, logic 0 lights the blue indicator and logic 1 lights the red indicator. With both jumpers fitted, changing the output level changes the indicated colour.
Task¶
- Start from
SURNAME_1_STM32-UNO-LED_templateand modifySrc/main.c. - Use the register-based approach shown in the template to enable the GPIOC clock and configure
PC10andPC12as outputs. - Design and implement your own repeating pattern. Both outputs must change state during each complete sequence, and the changes must be clearly visible.
- Use at least one
for,while, ordo...whileloop to control repetition within your pattern or to implement the delay. The existing empty infinite loop alone is not sufficient. - Implement and use a software delay between output changes. Ensure that the compiler does not remove the delay loop. Precise timing in milliseconds is not required.
- Build the project - if is it possibel and pripare elf file to next lesson.
You may choose alternating indicators, groups of flashes, different delays, or another pattern of your own.
Explain your code¶
Include brief comments in main.c explaining:
- Your chosen sequence and the expected behaviour of both LED indicators.
- How the GPIOC peripheral clock is enabled.
- How the mode-register bit masks configure PC10 and PC12 as outputs.
- How writes to the GPIO bit set/reset register change the output levels.
- How your loop and delay work, including what determines the delay length.
Explain the operations used in your solution in your own words. Check that comments copied from the template describe the pins and registers actually used.
Submission¶
Submit only the modified C source file main.c. Include your name in a comment at the beginning of the file.
Do not submit the complete project, compiled files, screenshots, or a separate report. All explanations must be included as comments in the submitted source file.
Assessment¶
- Correct configuration and control of PC10 and PC12.
- A working, repeating pattern chosen by the student.
- Correct and meaningful use of a loop and software delay.
- Comments demonstrating understanding of the register operations and algorithm.
- Clear, readable C code that builds within the supplied template project.