This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS: 12 button keypad

Other Parts Discussed in Thread: MSP430G2553

Tool/software: Code Composer Studio

hello ,

Im having trouble with my code. I need to have the msp430 display the value of the 12 button keypad on the lcd. Any way you can look at my code and give me some insight.

#include <msp430g2553.h>
#include "keypad12.h"
#include "flashmem.h"
#include "lcdLib.h"
#include "common.h"

char standardDecode(char keycode2Decode);
char one[5] = {0};
char two[5] = {0};
char three[5] = {0};
char gotkey = 0;
char getKey = 0;
char key = 0;

int main(void){
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
lcdInit(); //Initialize LCD. integer


keypad12Config(BIT3 + BIT4 + BIT5 + BIT6, BIT0 + BIT1 + BIT2, Port1, Port1, 10); //All of Port 1 except P1.7

volatile char gotkey = 0, key = 0; //Watch these variables in the 'Expressions' tab.

while(1){

int h = 0;
int i = 0;

if (h == 0)
{
gotkey = 0;
key = 0;
key = standardDecode(getKey12(1));

if (key == '#')
{

gotkey = 0;
key = 0;

while (i < 4 ){

delay_ms(500);

key = standardDecode(getKey12(1));
one[i] = key;

lcdSetText(one,0,0);

delay_ms(500);
i++;

}

h++;
flashErase(0x1080);
flashWrite(one,SegmentB, block, 3);
key = 0;
}
//segment B
//flashMove(0xE800, 0xE600, block, 3);
if(key == '*')
{
flashErase(0x1080);
//lcdInit();
lcdClear();
lcdSetText ("XXXX", 0, 0);
}
}
if (h == 1)
{
lcdClear();
gotkey = 0;
key = 0;
key = standardDecode(getKey12(1));

if (key == '#')
{

gotkey = 0;
key = 0;
i=0;

while (i < 4){

delay_ms(500);
key = standardDecode(getKey12(1));
two[i] = key;

lcdSetText(&two,12,1);

delay_ms(500);
i++;
}
h++;

flashErase(0x1040);
flashWrite(two, SegmentC, block, 3);
//flashMove(0xE800, 0xE600, block, 3);
if (key == '*')
{
flashErase(0x1040);
//lcdInit();
lcdClear();
lcdSetText ("XXXX", 12, 1);
}
}
}
if (h == 2)
{
lcdClear();
gotkey = 0;
key = 0;
key = standardDecode(getKey12(1));

if (key == '#')
{
gotkey = 0;
key = 0;
i=0;
while (i < 4){

delay_ms(500);
key = standardDecode(getKey12(1));
three[i] = key;

lcdSetText(&three,0,1);

delay_ms(500);
i++;

}

flashErase(0x1000);
flashWrite(three, SegmentD, block, 3);
//flashMove(0xE800, 0xE600, block, 3);

if (key == '*')
{
flashErase(0x1000);
//lcdInit();
lcdClear();
lcdSetText ("XXXX", 0, 1);
}
else{
lcdClear();
}

}
}
}
}

**Attention** This is a public forum