Skip to main content

Embedded Systems · Interrupts, concurrency, and shared state

USART2 is clocked by f_CK=36.00 MHz

Problem

Embedded Systems practice problem

USART2 is clocked by fCK=36.00 MHzf_{\mathrm{CK}}=36.00\,\mathrm{MHz}. For OVER8=0\mathtt{OVER8}=0, the 16-bit BRR packs a 12-bit mantissa mm in bits [15:4][15:4] and a 4-bit fraction ff in bits [3:0][3:0], withUSARTDIV=m+f/16,fbaud=fCK/(16⋅USARTDIV).\mathtt{USARTDIV}=m+f/16,\qquad f_{\mathrm{baud}}=f_{\mathrm{CK}}/(16\cdot\mathtt{USARTDIV}).For OVER8=1\mathtt{OVER8}=1, BRR packs mm in bits [15:4][15:4] and a 3-bit fraction f8f_8 in bits [2:0][2:0] (bit 33 must be 00), withUSARTDIV=m+f8/8,fbaud=fCK/(8⋅USARTDIV).\mathtt{USARTDIV}=m+f_8/8,\qquad f_{\mathrm{baud}}=f_{\mathrm{CK}}/(8\cdot\mathtt{USARTDIV}).The target baud rate is 115200 Bd115200\,\mathrm{Bd}. mm is a positive integer and the fraction field is an integer in its legal range.

(a) With OVER8=0\mathtt{OVER8}=0, compute the exact real USARTDIV\mathtt{USARTDIV} that would produce 115200 Bd115200\,\mathrm{Bd} with no error. Then quantise to the nearest multiple of 1/161/16 (halfway away from zero toward +∞+\infty), encode BRR as a 16-bit hexadecimal value, and compute the actual baud and the signed relative error (fbaud−115200)/115200(f_{\mathrm{baud}}-115200)/115200.

(b) Repeat part (a) with OVER8=1\mathtt{OVER8}=1, quantising to the nearest multiple of 1/81/8.

(c) Determine which oversampling setting yields the smaller absolute relative error, and compute the bit-time error accumulated over one 10-bit frame (start + 8 data + stop) at the actual baud of that setting, in microseconds, relative to the ideal 115200 Bd115200\,\mathrm{Bd} frame duration.

(d) If BRR is programmed as 0x0027\mathtt{0x0027} with OVER8=0\mathtt{OVER8}=0, decode mm and ff, compute fbaudf_{\mathrm{baud}}, and state whether this encoding matches part (a).

Hint

Hint

The exact divisor is fCKf_{\mathrm{CK}} divided by 1616 (or 88) times the target baud; it generally does not already lie on the hardware grid.

Check your work

Work the problem yourself first. Then open it in Training to check your answer and read the full worked solution.

The answer check and full solution for this problem come with ProofAnvil Practice membership ($19 USD monthly). See membership. Or start with the free Embedded Systems sample problem: Try the free sample problem.

More Embedded Systems practice problems

Back to Embedded Systems

An original ProofAnvil practice problem, written for this course. ProofAnvil is a practice course, not a homework-answer service.