Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
en:multiasm:exercisesbook:arduinouno [2026/05/04 14:30] – [Use of Timers to Generate PWM] pczekalskien: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 << TXEN0+ldi r18, (1<<UCSZ01) | (1<<UCSZ00
-sts UCSR0Br16+sts UCSR0Cr18
 </code> </code>
-and configure frame format (8 bits, no parity, 1 stop bit, shortly 8N1 - the most common case):+ 
 +and enable the UART:
 <code asm> <code asm>
 ldi r16, (1 << TXEN0) ldi r16, (1 << TXEN0)
 sts UCSR0B, r16 sts UCSR0B, r16
 </code> </code>
-Now it is time to send the string to the transmitter, byte by byte. Pointer to the string is loaded to Z register (ZH and ZL respectively) using ''ldi''. The string is processed character by character until it encounters 0 (the end of the string).+ 
 +Now it is time to send the string to the transmitter, byte by byte. A pointer to the string is loaded into the Z register (ZH and ZLrespectively) using ''ldi''. The string is processed character by character until it encounters 0 (the end of the string).
 <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 (it is based on a capacitor); thus, when it is ready to read, the ADSC bit is cleared by the ADC hardware.+ADC requires some time to complete the conversion; thus, when the result is ready to read, the ADSC bit is cleared by the ADC hardware.
 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's input source. The general rule says that the faster the conversion, the lower the quality and the higher the error ratio. Conversion speed can be controlled using a prescaler value (bits ADPS2, ADPS1, and ADPS0 of the ADCSRA register). The prescaler divides the clock frequency (16MHz) to slow down the conversion process. Prescaler value and related conversion speed and time is presented in table {{ref>arduinoadcprescaler}}.+ADC converts an analogue value to its digital representation using a method called successive approximation, measuring the voltage stored in a capacitor. Charging and discharging of the capacitor require time and depend on the impedance of the analogue signal's input source. The general rule says that the faster the conversion, the lower the quality and the higher the error ratio. Conversion speed can be controlled using a prescaler value (bits ADPS2, ADPS1, and ADPS0 of the ADCSRA register). The prescaler divides the clock frequency (16MHz) to slow down the conversion process. Prescaler value and related conversion speed and time are presented in table {{ref>arduinoadcprescaler}}.
  
 <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:
 ''ld   r18, Z+'' -> ''lpm   r18, Z+''.</note> ''ld   r18, Z+'' -> ''lpm   r18, Z+''.</note>
-<note important>If you run this function in a loop, give it a delay after each Serial port sending session is finished to let the hardware clean buffers. </note>+<note important>If you run this function in a loop, add a delay after each Serial port sending session to let the hardware clear buffers. </note>
  
 ** Delay (in ms) **\\ ** Delay (in ms) **\\
en/multiasm/exercisesbook/arduinouno.1777894259.txt.gz · Last modified: by pczekalski
CC Attribution-Share Alike 4.0 International
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0