Chapter
11 has more about PIC18F4520 programming.
In PCs, .NET??™s SerialPort class includes the BytesToWrite property, which
returns the number of bytes in the transmit buffer. However, BytesToWrite
returns zero when the UART??™s hardware buffer still contains bytes to transmit
and when the final byte is transmitting. If you use BytesToWrite to find out if
the data has transmitted, you??™ll need to add a delay after BytresToWrite = 0 to
allow the UART??™s buffer to empty. Chapter 9 and Chapter 10 have more about
.NET programming.
A transmitting computer can ensure that all data has transmitted by reading the
data back after it transmits. This method also detects problems such as a disconnected
transceiver or multiple drivers enabled at the same time. To enable
reading back the data, the RS-485 receiver must be enabled when transmitting.
To use this method, the program code sends the data and read back the data
just transmitted. To verify a match, the transmitting computer can just count
the received bytes or compare the received data with the bytes transmitted. On
receiving the expected data or number of bytes, the transmitting computer can
disable its driver. If the data doesn??™t appear or the values don??™t match, the transmitting
computer can retry or give up.
A calculated delay is another approach to determining when to disable the drivers.
Pages:
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133