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

16550 library

WHere can I find a portable 16550 library for use with C51?

Parents
  • Hi Erwin!

    I have lost your e-mail address, but I want to notify you about a problem in the code that I have sent you.

    uchar uart_getc( void ) {
      uchar return_byte;
      if (rxcount) {                        // if bytes in rx buffer
         EA = 0;                            // disable all interrupt
         return_byte = rxbuf[rxo++];        // get byte from buffer and advance output pointer
         --rxcount;                         // decrement number of bytes in buffer
         if (rxcount < TRLOW) {             // if number of bytes in rx buffer lower than threshold
            uart_mcr = 0x03;                // set RTS bit of UART
            rts = 1;                        // and flag too.
         }
         EA = 1;                            // enable interrupt
         return return_byte;
      }
      else {
        return 0;                           // nothing to receive
      }
    }
    

    The interrupt should be disabled in the uart_getc() routine, like sown above. Otherwise - in some rare cases - the rxcount variable could be currupted.

    Take care
    Sven

Reply
  • Hi Erwin!

    I have lost your e-mail address, but I want to notify you about a problem in the code that I have sent you.

    uchar uart_getc( void ) {
      uchar return_byte;
      if (rxcount) {                        // if bytes in rx buffer
         EA = 0;                            // disable all interrupt
         return_byte = rxbuf[rxo++];        // get byte from buffer and advance output pointer
         --rxcount;                         // decrement number of bytes in buffer
         if (rxcount < TRLOW) {             // if number of bytes in rx buffer lower than threshold
            uart_mcr = 0x03;                // set RTS bit of UART
            rts = 1;                        // and flag too.
         }
         EA = 1;                            // enable interrupt
         return return_byte;
      }
      else {
        return 0;                           // nothing to receive
      }
    }
    

    The interrupt should be disabled in the uart_getc() routine, like sown above. Otherwise - in some rare cases - the rxcount variable could be currupted.

    Take care
    Sven

Children
No data