This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

rfreader

#include<reg51.h>
void boud_rate()
{
        SCON = 0x50;
        TMOD = 0x20;                /* timer 1, mode 2, 8-bit reload */
        TH1  = 0xFD;                /* reload value for 2400 baud */
        TR1  = 1;
        TI   = 1;
}
char serial_receive()
{
    char chr;        /* variable to hold the new character */
        while (RI != 1) {;}
        chr = SBUF;
        RI = 0;
        return(chr);
}

void main(void)
{

        boud_rate();
  unsigned char rx_data;

  for(;;)
  {
    rx_data = serial_receive();

    switch(rx_data)
    {
//      case '1': open_door();
          case 0067892341 : open_door();
        break;
//      case '9': open_door();
       case 0045780034 : open_door();
        break;

      default: dont_open();
    }

    proper_delay();
  }
}

errors

'rx_data':undefined identifier
 illigal octal digit

please tell me how to overcum these errors

Parents
  • ya your right, but what to do, I need to submit this program as fast as possible. . only 2 days remaining. I have studied the comparing of arrays and that part is completed. The only problem is in receiving char using interrupt and displaying it.

    Now I have corrected all the mistakes still it is displaying 255 on the display.

    once i am able to receive the char then I will finish off this program and take a break to study.

    even I am feeling very bad.

Reply
  • ya your right, but what to do, I need to submit this program as fast as possible. . only 2 days remaining. I have studied the comparing of arrays and that part is completed. The only problem is in receiving char using interrupt and displaying it.

    Now I have corrected all the mistakes still it is displaying 255 on the display.

    once i am able to receive the char then I will finish off this program and take a break to study.

    even I am feeling very bad.

Children
  • Now I have corrected all the mistakes still it is displaying 255 on the display.
    HUH? if it is "displaying 255 on the display" it is not possible that you have "corrected all the mistakes"

    once i am able to receive the char then I will finish off this program and take a break to study
    AKA sequencing error

    while(1==1)
            {
    
                   /* read the next character from the serial port */
                            input[input_pos++] = getCharacter ();
    
                            for(i=0;i<=input_pos;i++)
                            {
                                lcd_print_b(input[i]);
                            }
            }
    }
    char getCharacter (void)
    {
          char chr[INPUT_LENGTH];           /* variable to hold the new character */
            while (RI != 1) {;}
            chr[input_pos++] = SBUF;
            RI = 0;
            return(chr);
    }
    

    since the above read and display characters one by one why are you using arrays?
    what happens if you do this

    lcd_print_b ('U');
    


    you are making the mistake of writing code instead of growing code. get one thing to work at a time.

    Erik

  • #include <reg51.h>
    #include "_LCD_R8C.c"
    
    #define INPUT_LENGTH 11
    
    
    int main()
    {
      char input[INPUT_LENGTH];  /* The input from the serial port */
      int  input_pos  = 0;       /* Current position to write in the input buffer */
    
      lcd_init();
      lcd_clear();
    
      SCON = 0x50;
      TMOD = 0x20;                /* timer 1, mode 2, 8-bit reload */
      TH1  = 0xFD;                /* reload value for 2400 baud */
      TR1  = 1;
      TI   = 1;
      RI   = 1;
    
      while(1)
      {
        /* read the next character from the serial port */
        if(input_pos < INPUT_LENGTH)    /* check for buffer overflow */
        {
          input[input_pos] = getCharacter();
          lcd_print_b(input[input_post]);  /* only makes sense to print each character once */
          input_pos++;
        }
     }
    
    
     char getCharacter (void)
     {
       char chr          /* variable to hold the new character */
    
       while (RI != 1)
         ;
    
       chr = SBUF;
       RI = 0;
    
       return(chr);
     }
    

    i am getting display as 255... help me out...