
answers are wrong want the right
answers

Answer:
In the problem statement (or in the circuit diagram) it is not explicitly mentioned as to which portc lines are the scan lines (i.e. the output lines from the microcontroller) and which are the return lines (i.e. the input lines into the microcontroller). As the answers indicated are wrong, therefore there is only one possibility. This is as follows:
PORTC lines 0,1, and 2 are the output lines, and
PORTC lines 4,5,6 and 7 are the input lines
therefore trisc should contain 1 1 1 1 0 0 0 0 Binary, i.e. 0Xf0
Recall that 1 in tris register means that that particular pin is being configured as input, and 0 in trisc register means that that pin is being configured as an output line. So we have configured upper 4 lines as input and lower four lines as output.
In this circuit portc pin 3 is not used and therefore it can be either 1 or 0. I am setting it as 0 in trisc.
Next the program needs to read port C to figure out which key in the leftmost column has been pressed.
Some explanation first:
In a standard scanned keypad (which this circuit seems to be), the input lines are pulled-up by pull up resistances. So if no key is pressed, all input lines would read 1.
The reading of this keypad happens in the following fashion:
1. The output lines are made 0 one by one at a rapid rate. This is called keypad scanning.
2. When a key is pressed the corresponding input line also becomes zero. For example When col1 line is 0 and key #4 is pressed, then row2 will also become zero.
3. The input lines (in this case line 5-7 of portc) are read by the program
4. The program checks if any input line is 0. This would happen only if any key was pressed. In the given program is being done by the statement if(!portc & ……) statement. Recall that & operator means logical ANDing and ! operator implies complement operation. So the program is looking if the argument of if statement has become 0.
For the blanks spaces in of the code should be:
first blank space portc = input_c() //read portc
second blank space 0x10 // retain only bit 4 of the port C input and check if it is zero. If it is zero then key "1" is pressed
third blank space 0x20
fourth blank space 0x40
fifth blank space 0x80
Hope this helps!
Princess Sumaya University for Technology Computer Engineering Department Embedded Systems Lab Qu...