Ttelmah
Joined: 11 Mar 2010 Posts: 19504
|
|
Posted: Mon Jun 13, 2011 9:36 am |
|
|
1) Learn to use the 'code' button. Makes reading your code 100* easier......
2) Of course it does. You are buffering the data to send, then dropping the RS485_DRIVER line in the main, as sooon as you have stored the data, while the TX interrupt is still sending. You need to drop this line _at the same point where you disable the TX interrupt - where the buffer is empty_. Or, don't use TXREG directly, use the CCS putc function, and add the enable line to the #USE RS232 setup.
3) Don't bother disabling the RS232 receive. You are presumably doing this because your RS485 hardware will receive the bytes being sent?. Turning off the interrupt will still leave a couple of characters in the hardware receive buffer. Have the RS232 receive routine, read characters and throw them away (rather than storing them), if RS485_DRIVER is low. Leave the interrupt enabled, and the characters transmitted will then automatically be read and the buffer will remain clear.
Best Wishes |
|