UART Baud Error & Timer Prescaler
Will this clock talk to that device, and which prescaler gives this timer frequency?
Could not save your rating. Try again.
هذه الصفحة غير مترجمة بالكامل بعد. الأجزاء غير المترجمة معروضة بالإنجليزية.
المدخلات
Receiver limit
النتائج
المعيار: total ≤ L = 2.0 % (the AVR figure, ATmega328P datasheet, D = 8), failing past 3.0 % (1.5 × L, design margin): 1.085 % here
أظهر خطوات الحساب
- Ideal divider
x = f_CK / (16 × baud) = 16 MHz / (16 × 115 200) = 8.681 → mantissa 8, fraction 11, BRR = 0x8B - Actual baud rate
baud = f_CK / (16 × (mantissa + fraction / 16)) = 16 MHz / (16 × (8 + 11 / 16)) = 115.108 kb/s - Baud error at this end
e = baud_actual / baud − 1 = 115108 / 115 200 − 1 = −0.07994 % - Total link error
|e| + tol + remote = 0.07994 % + 0.005 % + 1 % = 1.085 %
this end −0.07994 % from 115 200 b/s
mantissa 8, fraction 11
كل النتائج (3)
the AVR figure, ATmega328P datasheet, D = 8
whole multiples of 115 200 b/s
fCK / (16 × baud), before rounding to sixteenths
إلى أي حد نعرف هذا الرقم
- Microchip (Atmel) ATmega328P datasheet: USART baud rate register settings
- STMicroelectronics STM32F1 reference manual (RM0008): USART fractional baud rate generation
Microchip (Atmel) ATmega328P datasheet: USART baud rate register settings المعادلة
STMicroelectronics STM32F1 reference manual (RM0008): USART fractional baud rate generation, and the TIMx_PSC and TIMx_ARR registers المعادلة
يُقاس مقابل: Microchip (Atmel) ATmega328P datasheet: asynchronous operational range and recommended maximum receiver error
The link total is a first-order sum of this end's error, its clock tolerance and the far end's error. Held against the datasheet's default, one end's share of the receiver's range, it is conservative. Of the inputs, the far end's error is usually the least known.
3 حالات في هذا الموقع تقارن هذه الحاسبة بأرقام حُسبت من دون كودها. اطّلع على الحساب.
هذه أداة مساعدة للتصميم. يبقى المهندس مسؤولاً عن التصميم وعن قراءة المرجع القياسي نفسه حيث يهم ذلك.
المسح البارامتري
غيّر مدخلاً واحداً على مدى، وشاهد الإجابة والحكم والهامش عند كل خطوة، جدولاً ومنحنى.Proأسوأ الحالات
أضف التفاوتات إلى المدخلات لتحصل على النطاق المضمون حول الإجابة الاسمية، لا الحالة النموذجية وحدها.Proأعطِ مدخلاً واحداً على الأقل تفاوتاً أكبر من صفر.
Waveform
المبدأ
A UART receiver times each bit from the falling edge of the start bit and samples it near the middle. When the two ends run at different rates, the sample point slips a little each bit, and by the last bit of the frame it can miss. Each end makes its rate by dividing a clock, with an integer divider or one with a 1/16 fraction, so most clocks cannot hit a standard rate exactly. This page works out the divider and the error it leaves, adds the clock tolerance and the far end's error, and checks the total against the receiver's limit. In timer mode it finds the prescaler and auto-reload values that come nearest a target frequency.
- the USART clock
- the divider: AVR UBRR, and the STM32 divider held in BRR
- the baud rate wanted
- this end's baud error
- clock tolerance
- the far end's total error
- the allowed total error
- data + parity bits in a frame
- the data bits, least significant first
- one bit time, 1/baud
- samples per bit: 16, or 8 with U2X
- the first and middle majority samples: 8 and 9 at 16 samples, 4 and 5 at 8
- the timer clock, into its prescaler
- prescaler and auto-reload register values
- clock cycles per counter step
- counter steps per period
- the timer frequency, and its period 1/f
تفاصيل إضافية
Where the error goes
The receiver allows a total mismatch between the two rates, and both ends spend it: each one's divider error, and each one's clock tolerance. A crystal holds tens of ppm, which hardly counts; an internal RC oscillator is often 1 % or more, which can take the whole allowance. Longer frames leave less: Rslow and Rfast close in on 1 as data and parity bits are added.
Clocks that divide exactly
With an integer divider, a clock that is a whole multiple of 16 × the baud rate (8 × with U2X) gives no divider error. A fractional divider needs only a whole multiple of the baud rate. The page gives the two such clocks nearest yours.
Timer resolution
Of the pairs that give the same frequency, the largest ARR gives the finest PWM duty steps, 1/(ARR + 1) of the period.
إصدار المحرك 1.26.4