This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| en:multiasm:exercisesbook:avr:sut [2026/04/30 10:01] – [Handling of the buffered 4 digit, 7-segment display] pczekalski | en:multiasm:exercisesbook:avr:sut [2026/05/04 14:50] (current) – [Visualising Instruction Execution Time Using an Oscilloscope] pczekalski | ||
|---|---|---|---|
| Line 31: | Line 31: | ||
| - | ==== Handling of the buffered 4 digit, 7-segment display ==== | + | ==== Handling of the buffered 4-digit, 7-segment display ==== |
| To display a digit in the 4x7seg. display, there are two definitions needed: the shape of a digit (or other symbol), and its position (1,2,3,4: a binary mask). | To display a digit in the 4x7seg. display, there are two definitions needed: the shape of a digit (or other symbol), and its position (1,2,3,4: a binary mask). | ||
| Line 42: | Line 42: | ||
| .byte 0xC0, 0xF9, 0xA4, 0xB0, 0x99, 0x92, 0x82, 0xF8, 0x80, 0x90 | .byte 0xC0, 0xF9, 0xA4, 0xB0, 0x99, 0x92, 0x82, 0xF8, 0x80, 0x90 | ||
| </ | </ | ||
| + | In a common-anode configuration, | ||
| + | |||
| <note tip> | <note tip> | ||
| Line 146: | Line 148: | ||
| <note important> | <note important> | ||
| - | <note tip> | + | <note tip> |
| - | ** Display single digit: how to use to display | + | ** Display single digit: how to use it to display |
| Sample code that uses the function declared above and displays 1975 is presented below. Note, the MCU runs here at full speed, constantly updating the display. While it is not necessary to (a minimum, comfortable LED display refresh rate should be around 10Hz), we do not present such a solution here for the sake of simplicity. It is common to address timers for this job to periodically refresh the screen. | Sample code that uses the function declared above and displays 1975 is presented below. Note, the MCU runs here at full speed, constantly updating the display. While it is not necessary to (a minimum, comfortable LED display refresh rate should be around 10Hz), we do not present such a solution here for the sake of simplicity. It is common to address timers for this job to periodically refresh the screen. | ||
| <code asm> | <code asm> | ||
| Line 188: | Line 190: | ||
| clr r25 | clr r25 | ||
| clr r23 | clr r23 | ||
| - | ; --- Idle Main Loop --- | + | ; --- Main Loop, displays in sequence 1-> |
| LOOP: | LOOP: | ||
| ldi r24,0 | ldi r24,0 | ||
| Line 211: | Line 213: | ||
| </ | </ | ||
| In the function above, we used fixed (constant) digits to display. A common scenario, however, is when the number is stored in some register or in a memory variable. | In the function above, we used fixed (constant) digits to display. A common scenario, however, is when the number is stored in some register or in a memory variable. | ||
| - | |||
| ** Convert number to digits: function definition **\\ | ** Convert number to digits: function definition **\\ | ||
| Line 339: | Line 340: | ||
| <note tip> | <note tip> | ||
| + | |||
| + | ==== Visualising Instruction Execution Time Using an Oscilloscope ==== | ||
| + | Let's try to visualise how code operates the GPIO. Naturally, in the remote lab, it is not possible to do it remotely, so here we present some desk-based experiments.\\ | ||
| + | The '' | ||
| + | In the function that displays a single digit, there is a section that loads a binary mask into the internal registers, enabling the LED segments that constitute the digit to be turned on and off. It is: | ||
| + | <code asm> | ||
| + | ... | ||
| + | sbi LAT_PORT, LAT_PIN | ||
| + | cbi LAT_PORT, LAT_PIN | ||
| + | ... | ||
| + | </ | ||
| + | |||
| + | The figures {{ref> | ||
| + | '' | ||
| + | The Arduino Uno operates at 16 MHz, so each cycle is 1/16000000 s, which is about 63 ns. According to the documentation, | ||
| + | |||
| + | <figure arduinounodigitoscilloscope1> | ||
| + | {{: | ||
| + | < | ||
| + | </ | ||
| + | |||
| + | <figure arduinounodigitoscilloscope2> | ||
| + | {{: | ||
| + | < | ||
| + | </ | ||