(v) Explain the function of the ‘trisb’ Special Function Register(SFR). Where is
ID: 2268362 • Letter: #
Question
(v) Explain the function of the ‘trisb’ Special Function Register(SFR). Where is it located in the PIC. Say what effect the following statement has:-
trisb = 0x03;
(vi) In a C program for a microcontroller, portb has been setup as all outputs and is assigned the hexadecimal value 0xD3. Determine the voltage levels on the pins of portb.
(vii) In the context of explaining the difference between the logical NOT operator(!) and the bitwise NOT operator(~) say what value portb will end up with in each of the following cases:-
a) portb = ~ (0x55);
b) portb = !(0x55);
(viii) Determine the value on the portb pins after the following C code statement is executed, if portb had an initial value of 0x40:-
portb = portb >> 2;
Explanation / Answer
Ans a.) FUNCTION: To define the type of an I/O pin, we use TRIS registers. These are 8-bit registers. The Least significant bit corresponds to 0 and Most significant bit corresponds to 1. When one bit of this register is set to ‘1’, the corresponding port pin becomes input and when it is set to ‘0’, it corresponds to output. TRIS registers are of two types:
TRISA corresponds to 8 pins of port set A while TRISB corresponds to 8 pins of port set B.
TRIS registers are located in the bank 1.
TRISB = 0*03; will set bits 0 and 1 to inputs, the rest outputs. 1 means input, 0 means output.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.