This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| en:multiasm:exercisesbook:avr:sut:scenarios:avr2 [2026/05/03 19:16] – pczekalski | en:multiasm:exercisesbook:avr:sut:scenarios:avr2 [2026/05/03 19:35] (current) – pczekalski | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== AVR2: Create | + | ====== AVR2: Create |
| In this scenario, you will implement a pattern using multiple LEDS. There are 4 LEDs connected to GPIOs 13, 12, 11, and 10 (D1 on top is GPIO 13; D4 at the bottom is GPIO 10). In this scenario, you will use blocking nested loops and manual calculation of the ticks needed to run them, to obtain precise '' | In this scenario, you will implement a pattern using multiple LEDS. There are 4 LEDs connected to GPIOs 13, 12, 11, and 10 (D1 on top is GPIO 13; D4 at the bottom is GPIO 10). In this scenario, you will use blocking nested loops and manual calculation of the ticks needed to run them, to obtain precise '' | ||
| Line 55: | Line 55: | ||
| reset: | reset: | ||
| - | ; 1. Initialise Stack Pointer using hi8 and lo8 functions | + | ; Initialise Stack Pointer using hi8 and lo8 functions |
| ldi r16, lo8(RAM_END) | ldi r16, lo8(RAM_END) | ||
| out SPL, r16 | out SPL, r16 | ||
| Line 65: | Line 65: | ||
| Configure GPIO13 <-> GPIO10 as outputs. Note, we do it in a bunch, not individually, | Configure GPIO13 <-> GPIO10 as outputs. Note, we do it in a bunch, not individually, | ||
| <code asm> | <code asm> | ||
| - | ; 2. Configure GPIO: Set PB2-PB5 as outputs | + | ; Configure GPIO: Set PB2-PB5 as outputs |
| ldi r16, LED_MASK | ldi r16, LED_MASK | ||
| out DDRB, r16 | out DDRB, r16 | ||
| Line 88: | Line 88: | ||
| **Step 4 **\\ | **Step 4 **\\ | ||
| - | Implement a delay function as presented | + | Implement a delay function as shown in other examples |
| + | You may want to use '' | ||
| <note tip> A good approach is to run the outer loop 208 times and two inner, nested loops 255 times each. ; | <note tip> A good approach is to run the outer loop 208 times and two inner, nested loops 255 times each. ; | ||
| Line 96: | Line 97: | ||
| ** FAQ **\\ | ** FAQ **\\ | ||
| - | When using the printed version of this manual, please refer to the latest online version | + | When using the printed version of this manual, please refer to the latest online version |
| **It does not flash**: Did you compile and upload to the device? Those are separate steps: it is not enough to just compile, but you also need to " | **It does not flash**: Did you compile and upload to the device? Those are separate steps: it is not enough to just compile, but you also need to " | ||
| - | // | ||
| + | **I need a longer delay**: To obtain a delay function with a period of about 2.5s, you need to introduce a fourth loop (an outer loop) in the delay; 3 will not provide you enough ticks. Eventually, you can switch to 16-bit counters. | ||
| + | // | ||