??? 11/05/11 04:03 Read: times |
#184553 - The Example is for one UART Responding to: ???'s previous message |
You would need to duplicate it for the second UART.
Example: static xdata unsigned char tbuf1 [TBUF_SIZE]; static xdata unsigned char rbuf1 [RBUF_SIZE]; static xdata unsigned char t_in1 = 0; static xdata unsigned char t_out1 = 0; static xdata unsigned char t_disabled1 = 0; static xdata unsigned char r_in1 = 0; static xdata unsigned char r_out1 = 0; static xdata unsigned char tbuf2 [TBUF_SIZE]; static xdata unsigned char rbuf2 [RBUF_SIZE]; static xdata unsigned char t_in2 = 0; static xdata unsigned char t_out2 = 0; static xdata unsigned char t_disabled2 = 0; static xdata unsigned char r_in2 = 0; static xdata unsigned char r_out2 = 0; /*------------------------------------------------------------------------------ ------------------------------------------------------------------------------*/ unsigned char com_rbuflen1 (void) { return (r_in1 - r_out1); } /*------------------------------------------------------------------------------ ------------------------------------------------------------------------------*/ unsigned char com_rbuflen2 (void) { return (r_in2 - r_out2); } or maybe: /*------------------------------------------------------------------------------ ------------------------------------------------------------------------------*/ unsigned char com_rbuflen2 (unsigned char port) { if(port == 0) { return (r_in1 - r_out1); } else { return (r_in1 - r_out1); } } Note: #define TBUF_SIZE 256 /* DO NOT CHANGE */ Is Not 100% True. It does to be a power of 2, And you will need to make other changes to make it work. Same if you want to move it out of XDATA. The optimal values for you, have to be determined by you. This assumes that you need to send and receive on both UARTs simultaneously with out having the main loop stalling. It may be overkill for you depending on your needs. If you are using printf you will need to make a single putch() function. |
Topic | Author | Date |
Both UARTs simultaneous works | 01/01/70 00:00 | |
yes | 01/01/70 00:00 | |
Both with Queues | 01/01/70 00:00 | |
C code | 01/01/70 00:00 | |
Or C | 01/01/70 00:00 | |
No simultaneous work | 01/01/70 00:00 | |
The Example is for one UART | 01/01/70 00:00 | |
Duplicate or Generalise | 01/01/70 00:00 | |
at89c51RE2 | 01/01/70 00:00 | |
Start a new thread | 01/01/70 00:00 | |
The same | 01/01/70 00:00 | |
but not same problem | 01/01/70 00:00 |