HOMEWORK1 » Historie » Verze 1
Ján Hýbl, 2026-11-13 16:16
| 1 | 1 | Ján Hýbl | h1. Homework 1: Control the LEDs on PC10 and PC12 |
|---|---|---|---|
| 2 | |||
| 3 | h2. Objective |
||
| 4 | |||
| 5 | 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. |
||
| 6 | |||
| 7 | Your solution must demonstrate that you understand the template code and can correctly use loops and a software delay. |
||
| 8 | |||
| 9 | h2. Hardware and documentation |
||
| 10 | |||
| 11 | Use the PCB documentation provided in the @docs@ folder, especially the pin map and the [[STM32_UNO_Programmer_Guide|STM32-UNO Programmer Guide]]. |
||
| 12 | |||
| 13 | |_. GPIO pin |_. Connector pin |_. LED indicators | |
||
| 14 | | PC10 | CONN-DIG2, pin 5 | D_B11 (blue), D_R11 (red) | |
||
| 15 | | PC12 | CONN-DIG2, pin 7 | D_B10 (blue), D_R10 (red) | |
||
| 16 | |||
| 17 | SKIP this part |
||
| 18 | _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._ |
||
| 19 | |||
| 20 | h2. Task |
||
| 21 | |||
| 22 | # Start from @SURNAME_1_STM32-UNO-LED_template@ and modify @Src/main.c@. |
||
| 23 | # Use the register-based approach shown in the template to enable the GPIOC clock and configure @PC10@ and @PC12@ as outputs. |
||
| 24 | # Design and implement your own repeating pattern. Both outputs must change state during each complete sequence, and the changes must be clearly visible. |
||
| 25 | # Use at least one @for@, @while@, or @do...while@ loop to control repetition within your pattern or to implement the delay. The existing empty infinite loop alone is not sufficient. |
||
| 26 | # 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. |
||
| 27 | # Build the project - if is it possibel and pripare elf file to next lesson. |
||
| 28 | |||
| 29 | You may choose alternating indicators, groups of flashes, different delays, or another pattern of your own. |
||
| 30 | |||
| 31 | h2. Explain your code |
||
| 32 | |||
| 33 | Include brief comments in @main.c@ explaining: |
||
| 34 | |||
| 35 | * Your chosen sequence and the expected behaviour of both LED indicators. |
||
| 36 | * How the GPIOC peripheral clock is enabled. |
||
| 37 | * How the mode-register bit masks configure PC10 and PC12 as outputs. |
||
| 38 | * How writes to the GPIO bit set/reset register change the output levels. |
||
| 39 | * How your loop and delay work, including what determines the delay length. |
||
| 40 | |||
| 41 | 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. |
||
| 42 | |||
| 43 | h2. Submission |
||
| 44 | |||
| 45 | Submit *only the modified C source file @main.c@*. Include your name in a comment at the beginning of the file. |
||
| 46 | |||
| 47 | 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. |
||
| 48 | |||
| 49 | h2. Assessment |
||
| 50 | |||
| 51 | * Correct configuration and control of PC10 and PC12. |
||
| 52 | * A working, repeating pattern chosen by the student. |
||
| 53 | * Correct and meaningful use of a loop and software delay. |
||
| 54 | * Comments demonstrating understanding of the register operations and algorithm. |
||
| 55 | * Clear, readable C code that builds within the supplied template project. |