CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

LCD Menu integration with 4x4 keypad (c programming)

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
unexpert



Joined: 05 Feb 2010
Posts: 2

View user's profile Send private message Send e-mail

LCD Menu integration with 4x4 keypad (c programming)
PostPosted: Fri Feb 05, 2010 2:00 pm     Reply with quote

Hi,

I've been working on a project using MPLAB IDE v8.36.
I'm trying to make a menu using the keypad for eg,

1 pressed - measure heart rate
2 pressed - exit

We can't get the output when we press the allocated key.
Here is our program code below:
Code:

#include <p18f4520.h>
#include <delays.h>

unsigned int LCD(void);
unsigned int EXIT(void);

void Init_LCD(void);
void w_ctr_8bit(char);
void w_data_8bit(char);
void Delay_1kcyc(void);

#define LCD_DATA PORTD
#define LCD_RS PORTBbits.RB1
#define LCD_E PORTBbits.RB2

unsigned char LCD_TEMP, i,j,k,m;
char MESS[16]=" WELCOME TO ECG ";
char MESS2[16]="1.MEASURE 2.EXIT";

void main()

{
unsigned int x, y, value;
ADCON1=0x0F;
TRISA=0xFF;
TRISB=0;
TRISD=0;
y=value;
PORTD=1;
Init_LCD();
w_ctr_8bit(0b10000000);
for (i=0; i<16; i++)
w_data_8bit(MESS[i]);

w_ctr_8bit(0b11000000);
for (i=0; i<16; i++)
w_data_8bit(MESS2[i]);

LCD();

while(1)
{ if (value==0b00000001)
for(i=0;i<16;i++)
{

unsigned int EXIT();
}
}


}


unsigned int LCD(void)
{
char value, keyInputs;

while(PORTAbits.RA4==0);

keyInputs = PORTA & 0x0F;

switch(keyInputs)
{
case 0: value='1';w_data_8bit(value);break;
case 1: value='2';w_data_8bit(value);break;
case 2: value='3';w_data_8bit(value);break;
case 3: value='F';w_data_8bit(value);break;
case 4: value='4';w_data_8bit(value);break;
case 5: value='5';w_data_8bit(value);break;
case 6: value='6';w_data_8bit(value);break;
case 7: value='E';w_data_8bit(value);break;
case 8: value='7';w_data_8bit(value);break;
case 9: value='8';w_data_8bit(value);break;
case 10: value='9';w_data_8bit(value);break;
case 11: value='D';w_data_8bit(value);break;
case 12: value='A';w_data_8bit(value);break;
case 13: value='0';w_data_8bit(value);break;
case 14: value='B';w_data_8bit(value);break;
case 15: value='C';w_data_8bit(value);break;
}

Delay10KTCYx(50);

return(value);
}

void Init_LCD()
{
w_ctr_8bit(0b00111000);
w_ctr_8bit(0b00001100);
w_ctr_8bit(0b00000110);
w_ctr_8bit(0b00000001);
w_ctr_8bit(0b00000010);
w_ctr_8bit(0b10000010);
}

void w_ctr_8bit(char w)
{
LCD_RS = 0;
LCD_E = 1;
LCD_DATA = w;
LCD_E = 0;
Delay10TCYx(50);
}

void w_data_8bit(char w)
{
LCD_RS = 1;
LCD_E = 1;
LCD_DATA = w;
LCD_E = 0;
Delay10TCYx(50);
}

unsigned int EXIT(void)
{
char MESS3[16]="THANK YOU FOR";
char MESS4[16]="USING ECG, BYE!";

w_ctr_8bit(0b10000000);
for (i=0; i<16; i++)
w_data_8bit(MESS3[i]);

w_ctr_8bit(0b11000000);
for (i=0; i<16; i++)
w_data_8bit(MESS4[i]);
}


We would appreciate help. Thanks Smile..
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Feb 05, 2010 2:50 pm     Reply with quote

You're using the Microchip C18 compiler. This forum is for the CCS
compiler. You should ask your questions on the Microchip forum:
http://www.microchip.com/forums/Default.aspx?
unexpert



Joined: 05 Feb 2010
Posts: 2

View user's profile Send private message Send e-mail

PostPosted: Fri Feb 05, 2010 3:36 pm     Reply with quote

Thanks Smile..
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group