Complete the code to enable the ITM by setting the correct bit in the control register.
ITM->[1] = 1;
The ITM Control Register (TCR) is used to enable the ITM. Setting it to 1 enables the ITM.
Complete the code to check if ITM Port 0 is enabled before sending data.
if (ITM->[1] & 1) { send_data(); }
The Trace Enable Register (TER) controls which stimulus ports are enabled. Checking bit 0 of TER tells if Port 0 is enabled.
Fix the error in the code to write a byte to ITM Port 1 correctly.
while (ITM->[1][1] == 0) {} ITM->[1][1] = data;
When read, the ITM PORT[1] register returns a non-zero value if Port 1 is enabled in TER and ready to accept data. The while loop polls until ready.
Fill both blanks to configure ITM to enable Port 2 and set the privilege level.
ITM->[1] |= (1 << 2); ITM->[2] = 0x0;
Setting bit 2 in TER enables Port 2. The TPR (Trace Privilege Register) set to 0x0 configures privileged access only.
Fill all three blanks to create a dictionary comprehension that maps ITM ports to their enable status for ports 0 to 2.
port_status = {{'{'}}[1]: bool(ITM->TER & (1 << [2])) for [3] in range(3){{'}}'}}The variable 'i' is used as the loop variable and key in the dictionary. The expression checks if bit i in TER is set, indicating if port i is enabled.
