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.

keypad on PORTF - ATMEGA128

Status
Not open for further replies.

_SquiD_

Advanced Member level 4
Joined
Jul 30, 2008
Messages
114
Helped
3
Reputation
6
Reaction score
2
Trophy points
1,298
Activity points
2,035
Hi there,
I have this board with an ATMEGA128. The board has only one available connector that goes to PORTF (ADC port). The problem is that I have to connect a 4x3 keypad.
I simulated in Proteus connecting the keypad to PORTC and it works but when I try connecting it to PORTF it doesn't work. Does anybody know how can I make this work ? I use MikroC for AVR.

Thanks in advance.

- SQD -
 

nobody has a clue ?
 

This is the code:
Code:
unsigned short kp, cnt, oldstate = 0;
char txt[6];
int k=1;

// Keypad module connections
char  keypadPort at PORTF;
char  keypadPort_Direction at DDRF;
// End Keypad module connections

// LCD module connections
sbit LCD_RS at PORTG1_bit;
sbit LCD_EN at PORTG2_bit;
sbit LCD_D4 at PORTA4_bit;
sbit LCD_D5 at PORTA5_bit;
sbit LCD_D6 at PORTA6_bit;
sbit LCD_D7 at PORTA7_bit;

sbit LCD_RS_Direction at DDG1_bit;
sbit LCD_EN_Direction at DDG2_bit;
sbit LCD_D4_Direction at DDA4_bit;
sbit LCD_D5_Direction at DDA5_bit;
sbit LCD_D6_Direction at DDA6_bit;
sbit LCD_D7_Direction at DDA7_bit;

void main()
{
  cnt = 0;
  Keypad_Init();
  Lcd_Init();
  Lcd_Cmd(_LCD_CLEAR);
  Lcd_Cmd(_LCD_CURSOR_OFF);
  Lcd_Out(1, 1, "Keys  :");
  do {
    kp = 0;
    do
      kp = Keypad_Key_Click();
    while (!kp);

    switch (kp) {
      case  1: kp = 49; break; // 1
      case  2: kp = 50; break; // 2
      case  3: kp = 51; break; // 3
      case  4: kp = 65; break; // A
      case  5: kp = 52; break; // 4
      case  6: kp = 53; break; // 5
      case  7: kp = 54; break; // 6
      case  8: kp = 66; break; // B
      case  9: kp = 55; break; // 7
      case 10: kp = 56; break; // 8
      case 11: kp = 57; break; // 9
      case 12: kp = 67; break; // C
      case 13: kp = 42; break; // *
      case 14: kp = 48; break; // 0
      case 15: kp = 35; break; // #
      case 16: kp = 68; break; // D
      default: kp += 48;
    }
if (kp != oldstate)
{
      cnt = 1;
      oldstate = kp;
}
   Lcd_Chr(2, k, kp);
   k++;
  } while (1);
}

This is the hardware that I used:
**broken link removed**

what is wrong with it?
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top