I am struggling to figure out this practice problem and using an HCS12 Microcont
ID: 2085337 • Letter: I
Question
I
am struggling to figure out this practice problem and using an HCS12 Microcontrollers and Embedded Systems, 1st Edition. Reviewing the chapters was a bit challenging to find an accurate answer. I need help to solve this practice problem and it is due today. Thank you
BRCLR Branch if Bits Cleared-This performs a logical AND on the content of a mask byte and the content of a memory location, bit by bit, then branches if and only if all bits with a value of 1 in the mask byte correspond to bits with a value of 0 in the tested byte
Data Direction Register DDRB is used to configure PORTB as either an input or output port. Clear the bits in DDRB will make PORTB an input port, set the bits in DDRA will make it an output port
this exercise relates to the HCS12 Microcontrollers and Embedded Systems but does not say what the microcontroller type. just ask what is the results after BSET DDRB,%10000001.
Does this answer your question?
After BCLR DDRB,%00010001
PORTB pin4 and pin0 are configured as output pins
PORTB pin4 and pin0 are configured as input pins
PORTB pin7, 6, 5, 3, 2, 1 are configured as output pins
PORTB pin7, 6, 5, 3, 2, 1 are configured as input pins
Explanation / Answer
Answer:- BSET DDRB %10000001 will make pin 7 and pin 0 of PORTB as output pin, rest pins function is same as earlier i.e no change for rest pins whether they were input or output, they will work same.
BCLR DDRB, %00010001 This will make PORTB pin 0 and pin 4 as input port. Rest pin functions are not changed whether they were input or output they will do as defined earlier.
Note:- If earlier not defined then default operation of pin will be perfomed by port pin.
so for BSET and BCLR only the bit of given address is affected for which the mask bit is set, rest bits are unaffected. The syntax for these two instruction is-
BSET MemAddr MaskBits
BCLR MemAddr MaskBits
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.