0
0
Embedded Cprogramming~5 mins

Direction register vs data register in Embedded C - Quick Revision & Key Differences

Choose your learning style9 modes available
Recall & Review
beginner
What is a Direction Register in embedded C?
A Direction Register controls whether a pin on a microcontroller is set as an input or an output. Setting a bit to 1 usually means output, and 0 means input.
Click to reveal answer
beginner
What is a Data Register in embedded C?
A Data Register holds the actual value sent to or read from a pin. For output pins, it sets the voltage level (high or low). For input pins, it reads the current voltage level.
Click to reveal answer
intermediate
How do Direction and Data Registers work together?
First, the Direction Register sets if a pin is input or output. Then, the Data Register either sends a signal out (if output) or reads a signal in (if input).
Click to reveal answer
beginner
Example: If you want to turn on an LED connected to a pin, which registers do you use and how?
Set the pin as output by writing 1 to the Direction Register bit. Then write 1 to the Data Register bit to turn the LED on (assuming active high).
Click to reveal answer
intermediate
Why can't you write to the Data Register if the pin is set as input?
Because the pin is configured to receive signals, not send them. Writing to the Data Register has no effect when the pin is input.
Click to reveal answer
What does setting a bit to 1 in the Direction Register usually mean?
APin is set as output
BPin is set as input
CPin is disabled
DPin is set to high impedance
Which register do you write to in order to send a high signal on an output pin?
ADirection Register
BControl Register
CStatus Register
DData Register
If a pin is set as input, what does reading the Data Register give you?
AThe current voltage level on the pin
BThe output value you set
CThe direction of the pin
DThe pin's configuration mode
What happens if you write to the Data Register when the pin is set as input?
AThe pin outputs the value
BThe pin changes direction
CNothing happens to the pin output
DThe microcontroller resets
Which register do you configure first to use a pin as output?
AData Register
BDirection Register
CStatus Register
DInterrupt Register
Explain the roles of the Direction Register and Data Register in controlling a microcontroller pin.
Think about how you tell a pin what to do and then what value it should have.
You got /4 concepts.
    Describe a simple example of turning on an LED using Direction and Data Registers.
    Remember: direction first, then data.
    You got /3 concepts.