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?

  • Hi Erwin!

    Did you find something yet? I have been trying to find something in vain. I already have a library that doesn't utilize the send and receive FIFO (it actually uses 16550 ind the 16450 mode). Yesterday I have decided to implement the fifos myself (well, that's how I usually solve problems). The receive FIFO works fine and it tested and I had already an idea how make use of the transmit fifo. I guess, I will finish that work in a few hours from now.

    What did you do? Do you use the FIFOs?

    Take care
    Sven

  • It is frustrating that UART library would be so difficult to find considering it is so common. Since we need it immediately, so one of my team making it now (he doesnt know C51 so write in assembler). At first not using FIFO, maybe we add it later. Initial tests yesterday problem with the transmit interrupt not triggered.


  • Hi Erwin!

    Well, my code is running now. Probably I need to do some cosmetics with it. Seems that there is not much about programming a 16550 on the net. I was searching for that in vain. I was testing my code yesterday and it seems to work fine. If you want the raw code, let me know... my e-mail address is s dot petersen at amotec dot de. Send me e-mail and please replace the 'dot' and the 'at' (just want to prevent spam mail this way).

    Take caer
    Sven

  • 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