Trace data through a microcontroller system
A microcontroller combines a processor, program memory, working memory and input/output peripherals. The processor fetches an instruction, decodes it and carries out the operation; a program counter identifies the next instruction address. RAM holds changing values, while nonvolatile program memory retains code when power is removed. Exact register names, memory maps, instruction timing and pin functions depend on the selected device, so use its datasheet before wiring or programming hardware.
Worked practice example
A training controller samples a 10-bit ADC connected to an ideal 0–5 V temperature sensor. In this exercise the sensor scale is 10 mV per °C with zero offset. Estimate the temperature from ADC code 154 using the stated endpoint scale V = code × 5/1023.
| Step | Working |
|---|---|
| Convert the code to voltage | V = 154 × 5/1023 = 0.7527 V. |
| Apply the sensor scale | T = 0.7527/0.010 = 75.27 °C. |
| Interpret the result | A code represents a voltage interval, so this is an estimate; quantisation, reference error and sensor error limit precision. |
| Follow the data path | Sensor → ADC input → digital reading in RAM → program comparison → output command. |
Check your method
For an actual ADC, use its specified transfer function: some calculations use a 2¹⁰ = 1024 step size rather than mapping the highest code to the endpoint. Check supply and reference limits, analogue pin configuration and the sensor’s offset. Do not connect a high-voltage load directly to a processor pin.
Try it yourself
Using the same ideal endpoint scale, estimate the voltage for ADC code 512. Which stored information should survive a normal loss of power: temporary sample data in RAM or the program in nonvolatile memory?
Show the answer and method
V = 512 × 5/1023 ≈ 2.502 V. The program in nonvolatile memory survives; ordinary RAM sample data does not.
This written practice example was prepared for Jemshah revision. It is additional practice, not an official examination question or a transcript of the video.