This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| en:multiasm:exercisesbook:arduinouno [2026/05/04 14:30] – [Use of Timers to Generate PWM] pczekalski | en:multiasm:exercisesbook:arduinouno [2026/05/04 14:55] (current) – [Function Call Standards] ktokarz | ||
|---|---|---|---|
| Line 471: | Line 471: | ||
| Where **Fcpu** is 16MHz for regular Arduino Uno (AtMega 328P). Note that this calculation yields ~9615 bps, not exactly 9600 bps. A tolerance of up to 2% is acceptable (here, it is 0.16%). | Where **Fcpu** is 16MHz for regular Arduino Uno (AtMega 328P). Note that this calculation yields ~9615 bps, not exactly 9600 bps. A tolerance of up to 2% is acceptable (here, it is 0.16%). | ||
| - | Next step is to enable UART: | + | Next step is to configure frame format (8 bits, no parity, 1 stop bit, shortly 8N1 - the most common case): |
| <code asm> | <code asm> | ||
| - | ldi r16, (1 << | + | ldi r18, (1<<UCSZ01) | (1<< |
| - | sts UCSR0B, r16 | + | sts UCSR0C, r18 |
| </ | </ | ||
| - | and configure frame format (8 bits, no parity, 1 stop bit, shortly 8N1 - the most common case): | + | |
| + | and enable | ||
| <code asm> | <code asm> | ||
| ldi r16, (1 << TXEN0) | ldi r16, (1 << TXEN0) | ||
| sts UCSR0B, r16 | sts UCSR0B, r16 | ||
| </ | </ | ||
| - | Now it is time to send the string to the transmitter, | + | |
| + | Now it is time to send the string to the transmitter, | ||
| <code asm> | <code asm> | ||
| main: | main: | ||
| Line 962: | Line 964: | ||
| Start conversion by setting the ADSC bit (6) of ADSCRA to 1. | Start conversion by setting the ADSC bit (6) of ADSCRA to 1. | ||
| - | ADC requires some time to read the value and complete the conversion | + | ADC requires some time to complete the conversion; thus, when the result |
| Here, we do not use any interrupts, just dummy pulling. | Here, we do not use any interrupts, just dummy pulling. | ||
| <code asm> | <code asm> | ||
| Line 998: | Line 1000: | ||
| ** Speed vs Quality ** | ** Speed vs Quality ** | ||
| - | ADC converts an analogue value to its digital representation using a capacitor. Charging and discharging of the capacitor require time and depend on the impedance of the analogue signal' | + | ADC converts an analogue value to its digital representation using a method called successive approximation, |
| <table arduinoadcprescaler> | <table arduinoadcprescaler> | ||
| Line 1195: | Line 1197: | ||
| To use a string (e.g. constant) that is stored in Flash, convert this line: | To use a string (e.g. constant) that is stored in Flash, convert this line: | ||
| '' | '' | ||
| - | <note important> | + | <note important> |
| ** Delay (in ms) **\\ | ** Delay (in ms) **\\ | ||