Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

4x4 keyboard need help to to convert a pseudocode into c

Status
Not open for further replies.

althealxy

Newbie level 2
Joined
Jun 25, 2009
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
singapore
Activity points
1,299
4x4 keyboard

can any help me with this? to convert a pseudocode into c program code?
{
set port C and port D to input(appropriate TRIS registers)
loop until port D pin 0 goes high
read port C pin0-pin3
perform look-up for the corresponding value
}


can i have a reply quick? i need it urgently
 

4x4 keyboard

well, althealxy

I don't understand what do you mean by (Pseudo code) in here? please be more specified. where is the pseudo code?
 

Re: 4x4 keyboard

The pseudocode is words representing the actual programming keywords. Pseudocode tells you what the program needs to do. In this case, it is the stuff between the "{" and the "}".
 

Re: 4x4 keyboard

althealxy said:
can any help me with this? to convert a pseudocode into c program code?
{
set port C and port D to input(appropriate TRIS registers)
loop until port D pin 0 goes high
read port C pin0-pin3
perform look-up for the corresponding value
}


can i have a reply quick? i need it urgently
and the MCU your using? anyway, just follow that pseudocode then read some sample code, its just a basic routine.
 

Re: 4x4 keyboard

im using pic18f4520 and mm74c992 16 key encoder
 

I have same problem as althealxy what is the C programming code?
 

If you loop until PORTD.0 becomes 1 then MCU will not be able to do any other thing during that time.


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
char kp = 0;
 
void main() {
 
TRISC = 0xFF;
TRISD = 0xFF;
 
    while(1) {
 
        while(RD0_bit == 0);
 
        kp = (PORTC & 0x0F);
 
        switch(kp) {
 
            case 0:
                //do what you want here
                break;
            case 1:
                //do what you want here
                break;
            case 2:
                //do what you want here
                break;
            //...
 
            default:
        };
    }
}

 

So this is the coded for
{
set port C and port D to input(appropriate TRIS registers)
loop until port D pin 0 goes high
read port C pin0-pin3
perform look-up for the corresponding value
}

If you loop until PORTD.0 becomes 1 then MCU will not be able to do any other thing during that time.


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
char kp = 0;
 
void main() {
 
TRISC = 0xFF;
TRISD = 0xFF;
 
    while(1) {
 
        while(RD0_bit == 0);
 
        kp = (PORTC & 0x0F);
 
        switch(kp) {
 
            case 0:
                //do what you want here
                break;
            case 1:
                //do what you want here
                break;
            case 2:
                //do what you want here
                break;
            //...
 
            default:
        };
    }
}

 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top