Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
06/20/09 11:52
Read: times


 
#166284 - Why dont you define correct id in "code" space
Responding to: ???'s previous message
Dear Popa,

Why dont you define the valid id in code space instead of data space.

// #include <REGX52.h>   //program care stocheaza si compara(bun)
#include <89lpc932.h>

#define Baud_rate 0xF4

#define LED_P   P2_0

#define LED_OF  1
#define LED_ON  0

code unsigned char valid_id[10] = {0x30, 0x34, 0x31, 0x35, 0x44, 0x38, 0x41, 0x31, 0x46, 0x31};

//rx_on, & chk_id can also be defined as bit(if compiler permits it)
unsigned char offset, rx_on, chk_id;
unsigned char com_rx_buf[11];

void serial_IT(void) interrupt 4 using 1
{
unsigned char ch;

if(RI)
{
    if(rx_on)
    {
        if(SBUF == 0x0D)
        {
            chk_id = 1;
            rx_on = 0;
        }
        else
        {
            if(offset < 10)
            {
                com_rx_buf[offset] = SBUF;
                offset++;
            }
            else
                rx_on = 0;
        }
    }
    else
    {
        if(SBUF == 0x0A)
        {
            rx_on = 1;

            for(ch = 0; ch < 11; ch++)
                com_rx_buf[ch] = 0x00;

            offset = 0;
        }
    }
}
else
{
    if(TI)
        TI = 0;
}
}

void init_var(void)
{
unsigned char ch;

    for(ch = 0; ch < 11; ch++)
        com_rx_buf[ch] = 0x00;

    offset = 0;
    rx_on = 0;
    chk_id = 0;
}

void init(void)
{
    TMOD = 0x20;
    SCON = 0x50;
    TH1 = Baud_rate;
    TL1 = Baud_rate;
//     EA = 1;
    ES = 1;
    TR1 = 1;

    init_var();

    LED_P = LED_OF;
}

void compare_id(void)
{
unsigned char ch;

if(offset == 10)
{
    for(ch = 0; ch < 10; ch++)
    {
        if(com_rx_buf[ch] != valid_id[ch])
            break;

        if(ch == 9)
            LED_P = LED_ON;
    }
}
}

void main(void)
{
    EA = 0;
    init();
    EA = 1;

while(1)
{
    if(chk_id)
    {
        compare_id();
        init_var();
    }
}
}

 


Regards,
Mahesh



List of 54 messages in thread
TopicAuthorDate
Project using 89s52            01/01/70 00:00      
   RET (Where?)            01/01/70 00:00      
      Loops?            01/01/70 00:00      
         Loops?            01/01/70 00:00      
            with a quick glance            01/01/70 00:00      
               with a quick glance            01/01/70 00:00      
                  search for ...            01/01/70 00:00      
            Loops Something like this            01/01/70 00:00      
               School work?            01/01/70 00:00      
                  Nope            01/01/70 00:00      
               Loops Something like this            01/01/70 00:00      
                  ?...Doesnot Work...?            01/01/70 00:00      
                     ?...Doesnot Work...?            01/01/70 00:00      
                        Correct            01/01/70 00:00      
                        You sure you get a line feed before RFID?            01/01/70 00:00      
                            You sure you get a line feed before RFID?            01/01/70 00:00      
                              Try This            01/01/70 00:00      
                                 Try This            01/01/70 00:00      
                                 error            01/01/70 00:00      
                                    it's bible time            01/01/70 00:00      
                                       it's bible time            01/01/70 00:00      
                                    Is it ERROR or DOUBT???            01/01/70 00:00      
                                       Is it ERROR or DOUBT???            01/01/70 00:00      
                                 Compare            01/01/70 00:00      
                                    Simulate your function.            01/01/70 00:00      
                                       Simulate your function.            01/01/70 00:00      
                                          Use the free Keil C compiler Evaluation            01/01/70 00:00      
                                    COMPARE            01/01/70 00:00      
                                       compare            01/01/70 00:00      
                                          Still not out of time for C            01/01/70 00:00      
                                             Still not out of time for C            01/01/70 00:00      
                                                Read up on pointer            01/01/70 00:00      
                                                   Read up on pointer            01/01/70 00:00      
                                                      Me or you?            01/01/70 00:00      
                                                   Or do not use a pointer            01/01/70 00:00      
                                                      working code            01/01/70 00:00      
                                                         Describe your work process            01/01/70 00:00      
                                                            v            01/01/70 00:00      
                                                               Did you read? Did you debug?            01/01/70 00:00      
                                                         Why dont you define correct id in "code" space            01/01/70 00:00      
                                                            Hoping to get someone relegated?            01/01/70 00:00      
   Reading or Transmitting Data            01/01/70 00:00      
      Reading or Transmitting Data            01/01/70 00:00      
   a trip to the wild blue younder            01/01/70 00:00      
      This is where it gets lost            01/01/70 00:00      
   The fundamental problem is...            01/01/70 00:00      
      Same as its always been,            01/01/70 00:00      
         Yep I cannot think            01/01/70 00:00      
            Yep I cannot think            01/01/70 00:00      
               Why too late?            01/01/70 00:00      
            for a simple task ...            01/01/70 00:00      
               More than one way to skin a cat            01/01/70 00:00      
                  my $0.02            01/01/70 00:00      
                     If you can not code it in ASM ...            01/01/70 00:00      

Back to Subject List