Embedded Systems · Microcontrollers, memory-mapped I/O, and peripherals
GPIOA on Anvil-M0 provides three 32-bit registers that affect the same 16 output…
Problem
GPIOA on Anvil-M0 provides three 32-bit registers that affect the same 16 output latches \(\mathrm{ODR}[15:0]\). Unused upper bits of each register read as zero and ignore writes. Starting value: \(\mathrm{ODR}=\mathtt{0x0000C351}\). The port pins are all outputs. - A write of word \(X\) to \(\mathrm{ODR}\) replaces \(\mathrm{ODR}[15:0]\) by \(X[15:0]\). - A write of word \(S\) to \(\mathrm{SET}\) sets every latch \(n\) for which \(S[n]=1\) and leaves latches with \(S[n]=0\) unchanged. - A write of word \(C\) to \(\mathrm{CLR}\) clears every latch \(n\) for which \(C[n]=1\) and leaves latches with \(C[n]=0\) unchanged. The desired update is: set pin \(2\), clear pin \(8\), and leave every other latch unchanged. No concurrent writer exists. Ignore pull-ups, modes, and BSRR. (a) Decode \(\mathtt{0xC351}\) into bits \(15\) through \(0\). State the present values of pins \(2\) and \(8\). (b) Compute the 16-bit image that a read-modify-write to \(\mathrm{ODR}\) must write, namely \((\mathrm{ODR}\mathbin{|}\mathtt{0x0004})\mathbin{\&}\mathord\sim\mathtt{0x0100}\), and give it as four hexadecimal digits. (c) Compute a \(\mathrm{SET}\) write word and a \(\mathrm{CLR}\) write word that together realize the same update (order: SET then CLR). Give each as eight hexadecimal digits, with bits \(31:16\) equal to \(0\). (d) Starting from \(\mathtt{0xC351}\), determine the \(\mathrm{ODR}\) that results if the firmware writes \(\mathtt{0x0004}\) to \(\mathrm{ODR}\) instead of to \(\mathrm{SET}\), intending to “set pin \(2\).” Identify every latch that is corrupted relative to the requirement. Then state, using only the three register semantics, why a SET write of \(\mathtt{0x0004}\) does not have that corruption.
Hint
Writing ODR replaces every latch; writing SET or CLR names only the one-bits.
Check your work
Work the problem yourself first. Then open it in Training to check your answer and read the full worked solution.
Create a free account to check your answer and see the solution. Create a free account.
More Embedded Systems practice problems
- 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
- USART2 is clocked by f_CK=36.00 MHzInterrupts, concurrency, and shared state
- 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