Embedded Systems · Interrupts, concurrency, and shared state
USART2 is clocked by f_CK=36.00 MHz
Problem
USART2 is clocked by \(f_{\mathrm{CK}}=36.00\,\mathrm{MHz}\). For \(\mathtt{OVER8}=0\), the 16-bit BRR packs a 12-bit mantissa \(m\) in bits \([15:4]\) and a 4-bit fraction \(f\) in bits \([3:0]\), with \[ \mathtt{USARTDIV}=m+f/16,\qquad f_{\mathrm{baud}}=f_{\mathrm{CK}}/(16\cdot\mathtt{USARTDIV}). \] For \(\mathtt{OVER8}=1\), BRR packs \(m\) in bits \([15:4]\) and a 3-bit fraction \(f_8\) in bits \([2:0]\) (bit \(3\) must be \(0\)), with \[ \mathtt{USARTDIV}=m+f_8/8,\qquad f_{\mathrm{baud}}=f_{\mathrm{CK}}/(8\cdot\mathtt{USARTDIV}). \] The target baud rate is \(115200\,\mathrm{Bd}\). \(m\) is a positive integer and the fraction field is an integer in its legal range. (a) With \(\mathtt{OVER8}=0\), compute the exact real \(\mathtt{USARTDIV}\) that would produce \(115200\,\mathrm{Bd}\) with no error. Then quantise to the nearest multiple of \(1/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 \((f_{\mathrm{baud}}-115200)/115200\). (b) Repeat part (a) with \(\mathtt{OVER8}=1\), quantising to the nearest multiple of \(1/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\,\mathrm{Bd}\) frame duration. (d) If BRR is programmed as \(\mathtt{0x0027}\) with \(\mathtt{OVER8}=0\), decode \(m\) and \(f\), compute \(f_{\mathrm{baud}}\), and state whether this encoding matches part (a).
Hint
The exact divisor is \(f_{\mathrm{CK}}\) divided by \(16\) (or \(8\)) 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
- GPIOA on Anvil-M0 provides three 32-bit registers that affect the same 16 output…Microcontrollers, memory-mapped I/O, and peripherals
- A 12-bit ADC with V_REF=3.300 V and V_LSB=V_REF/4096 is read sixteen times in…Microcontrollers, memory-mapped I/O, and peripherals
- A UART RX FIFO is 16 bytes deepInterrupts, concurrency, and shared state
- A complementary PWM pair drives one leg of an H-bridgeTimers, scheduling, and real-time constraints
- Two 16-bit timers are cascaded to form a 32-bit timestampTimers, scheduling, and real-time constraints
- A brushless-DC commutation computer runs two independent implicit-deadline periodic…Serial buses and communication protocols
- A single fully preemptive uniprocessor hosts three independent implicit-deadline…Serial buses and communication protocols
- Standard-mode I^2C requires t_LOW≥ 4.70 μs and t_HIGH≥ 4.00 μs on SCL, t_r≤ 1.00 μs…Memory, energy, and reliability budgets
- A two-door airlock is modelled by Boolean variables L and R, each 1 when that door is…State-machine verification and safety boundaries