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

Saving cellphone numbers on PIC16f877a using keypad and lcd

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



Joined: 06 Aug 2010
Posts: 15

View user's profile Send private message

Saving cellphone numbers on PIC16f877a using keypad and lcd
PostPosted: Fri Aug 13, 2010 11:32 pm     Reply with quote

Could that be possible?

I have here codes for inputting number from keypad that will be outputted on LCD but I have no idea on how to save the numbers into PIC that I inputted on my keypad.

And after that, all cellphone numbers on PIC16F877A should be called by GSM to be able to transmit messages to recipients.

Do you have codes for this or threads? Please help me.
theasus



Joined: 31 May 2009
Posts: 79

View user's profile Send private message

PostPosted: Sat Aug 14, 2010 12:19 am     Reply with quote

You can use external EEPROM like 2408 to save the numbers. You can find its library form PICC/Drivers. And it is very easy to use. Here are the codes which is enough for your program:
Code:

#include <input.c> //
#include <2408.c>  // necessary libraries
#use i2c(master,sda=pin_c4,scl=pin_c3,slow=100000)// sets I2C communication parameters

write_ext_eeprom(long int address, BYTE data);\\Write data to address
variable=read_ext_eeprom(long int address);\\Read the adress and assign its value to variable.

And also you can use these codes for keypad driving:
http://www.ccsinfo.com/forum/viewtopic.php?t=28022&start=14
zephyr2009



Joined: 06 Aug 2010
Posts: 15

View user's profile Send private message

PostPosted: Sat Aug 14, 2010 9:15 am     Reply with quote

I have here my driver for 3x4 keypad...

Code:
///////////////////////////////////////////////////////////////////////////
////                             Flex_KBD.C                            ////
////                  Generic keypad scan driver                       ////
////                                                                   ////
////  kbd_init()   Must be called before any other function.           ////
////                                                                   ////
////  c = kbd_getc(c)  Will return a key value if pressed or /0 if not ////
////                   This function should be called frequently so as ////
////                   not to miss a key press.                        ////
////                                                                   ////
///////////////////////////////////////////////////////////////////////////



//Keypad connection:

#define col0 PIN_B5
#define col1 PIN_B6
#define col2 PIN_B7
#define row0 PIN_B1
#define row1 PIN_B2
#define row2 PIN_B3
#define row3 PIN_B4

// Keypad layout:
char const KEYS[4][3] = {{'1','2','3'},
                         {'4','5','6'},
                         {'7','8','9'},
                         {'*','0','#'}};

#define KBD_DEBOUNCE_FACTOR 33    // Set this number to apx n/333 where
                                  // n is the number of times you expect
                                  // to call kbd_getc each second



void kbd_init() {
}


short int ALL_ROWS (void)
{
   if (input (row0) & input (row1) & input (row2) & input (row3))
      return (0);
   else
      return (1);
}



char kbd_getc( ) {
   static byte kbd_call_count;
   static short int kbd_down;
   static char last_key;
   static byte col;

   byte kchar;
   byte row;

   kchar='\0';
   if(++kbd_call_count>KBD_DEBOUNCE_FACTOR) {
       switch (col) {
         case 0   : output_low(col0);
               output_high(col1);
               output_high(col2);
                    break;
         case 1   : output_high(col0);
               output_low(col1);
               output_high(col2);
                    break;
         case 2   : output_high(col0);
               output_high(col1);
               output_low(col2);
                    break;
       }

       if(kbd_down) {
         if(!ALL_ROWS()) {
           kbd_down=false;
           kchar=last_key;
           last_key='\0';
         }
       } else {
          if(ALL_ROWS()) {
             if(!input (row0))
               row=0;
             else if(!input (row1))
               row=1;
             else if(!input (row2))
               row=2;
             else if(!input (row3))
               row=3;
             last_key =KEYS[row][col];
             kbd_down = true;
          } else {
             ++col;
             if(col==3)
               col=0;
          }
       }
      kbd_call_count=0;
   }
  return(kchar);
}


Is there anything else that i will change on your code?
and is it possible to embed your code with this keypad driver?
bkamen



Joined: 07 Jan 2004
Posts: 1615
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Sat Aug 14, 2010 10:18 am     Reply with quote

If the PIC you're using (which you didn't mention) has EEPROM (and some do!) built in, you can use that.

If the PIC doesn't have EEPROM, but is one of the devices with internally reprogrammable flash (like I think most if not all of the PIC18F series), you can actually use a block of flash memory to save your defaults.

Last, if none of the previous two are options, you can use an SPI, I2C or even Dallas 1-wire NVRAM/EEPROM/FLASH device.


-Ben
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
zephyr2009



Joined: 06 Aug 2010
Posts: 15

View user's profile Send private message

PostPosted: Sat Aug 14, 2010 10:02 pm     Reply with quote

Quote:
If the PIC you're using (which you didn't mention) has EEPROM (and some do!) built in, you can use that.

If the PIC doesn't have EEPROM, but is one of the devices with internally reprogrammable flash (like I think most if not all of the PIC18F series), you can actually use a block of flash memory to save your defaults.

I think that my PIC16F877A has an EEPROM because you can put codes into it. But I don't know on how to declare the numbers seen on LCD to be saved on PIC when I pressed the asterisk button (*) on KEYPAD 3X4 or something else.
bkamen



Joined: 07 Jan 2004
Posts: 1615
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Sun Aug 15, 2010 11:40 am     Reply with quote

zephyr2009 wrote:

I think that my PIC16F877A has an EEPROM because you can put codes into it. But I don't know on how to declare the numbers seen on LCD to be saved on PIC when I pressed the asterisk button (*) on KEYPAD 3X4 or something else.


To quote an old friend's measurement product line's mantra, "Don't Think, Know."

The 16F877 has 256bytes of EEPROM.

You could define an array of X number of phone numbers and then use the CCS functions write_eeprom and read_eeprom to save the data to the internal EEPROM.

-Ben
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
zephyr2009



Joined: 06 Aug 2010
Posts: 15

View user's profile Send private message

PostPosted: Tue Aug 17, 2010 7:54 am     Reply with quote

mr. bkamen, I know that it is possible to save number on PIC16f877a,

im just a complete newbie with write_eeprom

do you threads for saving numbers what I declared on keypad and appeared on LCD.. I want to declare (*) on keypad when im done with my number and i want to save those numbers on PIC Smile
bkamen



Joined: 07 Jan 2004
Posts: 1615
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Tue Aug 17, 2010 1:01 pm     Reply with quote

zephyr2009 wrote:
mr. bkamen, I know that it is possible to save number on PIC16f877a,

im just a complete newbie with write_eeprom

do you threads for saving numbers what I declared on keypad and appeared on LCD.. I want to declare (*) on keypad when im done with my number and i want to save those numbers on PIC Smile


I usually make a config structure and then save that whole structure to EEPROM.

Do you have a book on 'C' yet?
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
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