Question

Princess Sumaya University for Technology Computer Engineering Department Embedded Systems Lab Quiz #3 2 1 2 2 3 For the keyp

    answers are wrong want the right answers

void main (0 Lcd_Init): Lcd Cmd LLCD CURSOR OFF) do portc : Ocece//..* if(!(portc8.Oke21 )// Lcd_Out (1,1,1):// write the c

Princess Sumaya University for Technology Computer Engineering Department Embedded Systems Lab Quiz #3 2 1 2 2 3 For the keypad shown in figure 1, consider that coll,col2, col3 are connected to portc (0,1,2) and rowl, row2, row3 and row4 are connected to portc(4,5,6,7). Complete the following cod so if we press any button in the first (most left ) column, it will be displayed on an LCD. means that there is some code missing in this line; you should write it
void main (0 Lcd_Init): Lcd Cmd LLCD CURSOR OFF) do portc : Ocece//..* if(!(portc8.Oke21 )// Lcd_Out (1,1,"1"):// write the charecter to be displayed delay_ms (1000); Lcd_Out (1,1,"4"); delay_ms (1000) if (I(portc& f Lcd_Out (1,1,"7"); delay_ms (1000) f (lporte& OXO (Lcd Out (1,1," delay ms (1000)
0 0
Add a comment Improve this question Transcribed image text
Answer #1

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!

Add a comment
Know the answer?
Add Answer to:
Princess Sumaya University for Technology Computer Engineering Department Embedded Systems Lab Qu...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT