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 support@ccsinfo.com

pic16f877 I want to change port of Keypad to portA or C

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



Joined: 08 Sep 2010
Posts: 2

View user's profile Send private message

pic16f877 I want to change port of Keypad to portA or C
PostPosted: Wed Sep 08, 2010 6:49 pm     Reply with quote

Hi All,
From below code.
I use ccs compiler.
Keypad is port B, LCD is portD.
I want to change port of Keypad is portA or C.
Please suggest to me too.
Thank you.
Code:

#include <16F877A.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)

#include <lcd.c>
#define use_portb_kbd
#include <kbd.c>

int i=0;
char doc_id[8],pat_id[8];

void doctor();
void patiant();
void showid();

void kbd_pullup_init()
{
   port_b_pullups(true);
}

void main()
{
   char k;
   int a=1;
   
   kbd_pullup_init();
   lcd_init();
   doctor();
   
   while (true)
   { 
      lcd_putc("\fHELLO\n");   
   }

}

void doctor()
{
   char k=0;
   lcd_putc("\fID  DOCTOR\n");
   i=0;
   
   while(i<4)
   {
      k=kbd_getc();
      if(k!=0)
      {
      doc_id[i]=k;
      lcd_putc(doc_id[i]);
      i++;
      }
   }
   patiant();
}

void patiant()
{
   char k=0;
   lcd_putc("\fPATIANT  ID\n");
   i=0;
   while(i<4)
   {
      k=kbd_getc();
      if(k!=0)
      {
         pat_id[i]=k;
         lcd_putc(pat_id[i]);
         i++;
      }
   }
   showid();   
}

void showid()
{
   int j;
   lcd_putc("\fDOC ID:");
   for(j=0;j<4;j++)
   {
      lcd_putc(doc_id[j]);
   }
   lcd_putc("\n");
         
   lcd_putc("PAT ID:");
   for(j=0;j<4;j++)
   {
      lcd_putc(pat_id[j]);
   }
   delay_ms(2000);
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Sep 08, 2010 9:35 pm     Reply with quote

Use the flex keypad driver. Change the #define statements at the top
of the file, to be the same as your new connections on Port A.
http://www.ccsinfo.com/forum/viewtopic.php?t=26333

Make sure the keypad Row pins have pull-up resistors on them.
Use 10K ohm resistors.
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