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

Inerrupt for begin if any key press

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



Joined: 24 Mar 2004
Posts: 53
Location: Portugal

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

Inerrupt for begin if any key press
PostPosted: Wed Apr 07, 2004 5:42 am     Reply with quote

Hello

I do a program to read IO and save in the Eeprom the value and this program need a 4 digit code to acces. I can change the code press *
Use LCD. C and Keyboard 4x4.

I need help to configure Inteerupt IF no key press in 5 seconds return to Begin, like a normal access code.

Thank you
Carlos

Code:


#include <16F877.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=4000000)
#USE RS232 (baud = 9600, xmit = PIN_C6, rcv = PIN_C7 )

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

#rom 0x2100={1,2,3,4}   


////.....////

void grava()
   {
   int ncod =0;
   
   printf("programacao %c\r\n",k);
   lcd_putc("\fNovo Codigo\n");
   for (ncod = 0; (ncod < nmax);)
      {
      k=kbd_getc();
      if(k!=0)
         {
         lcd_putc("*");
         ncod++;
         write_eeprom ((ncod - 1),(k - 0x30));
         }
      }
      
   printf("Codigo gravado %c\r\n",k);
   lcd_putc("\fCodigo gravado\n");
   }

/// .... ///

void main()
{

// .. //

   while (TRUE)
         {
         k=kbd_getc();
         if(k!=0)
        if(k=='*')
           grava();
          //lcd_putc('\f');
        else
           {   
                lcd_putc("*");
                 EE=read_eeprom(Ponta);
                rel = EE + 0x30;
                printf( "%2x ", k );
                printf( "%2x ", rel );
                n++;
                Ponta++;
                if ( (rel==k) && (correcto==(Ponta -1) ))   
                  {
                  correcto++;
                      if ( n == nmax )
                     {
                     output_high(pin_b0);
                     printf("ligado %c\r\n",k);
                     lcd_putc("\fCodigo Correcto\n");
/// .... //   
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Apr 07, 2004 12:03 pm     Reply with quote

Quote:
I need help to configure Inteerupt IF no key press in 5 seconds return to Begin, like a normal access code.

So you need the code to timeout if there is no keypress after
a specified time. Look at my answer in this thread below.
Also look at the link at the end of the thread.
http://www.ccsinfo.com/forum/viewtopic.php?t=18034
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