Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
05/29/10 11:04
Read: times


 
#176283 - Useful ideas - but I don't want to change the hardware
Responding to: ???'s previous message
Michael,

Thanks for these useful guidelines. I can see the benefit of the "receive always on" approach that you suggest - however I don't want to change the hardware if I can avoid it because there are hundreds of these systems out in the field. So I'd like to come up with the most reliable, bullet-proof way of driving the bus with /RE and DE connected together and to my port pin. Here's what I've got at present (this just echoes all characters received):
  • At the beginning of the loop I can't be sure what state everything is in, and other code may have been using the RS485 bus.
  • turn driver off and receiver on, because I'm not sure what state it's been left in
  • wait a moment for bus settling etc.
  • do I need to read SBUF to make sure the chip is ready to receive the next byte?
  • do I need to clear RI here in case something has been received when I switched the receiver off and on again or by "other code"?
  • jnb RI,$
  • clr RI
  • mov a,SBUF
  • wait half a bit-time plus a moment for settling
  • turn driver on and receiver off
  • wait a moment for settling
  • do I need to clear TI here, just to be sure?
  • mov SBUF,a
  • jnb TI,$
  • clr TI
  • wait 1 bit-time plus a moment more for bus settling etc.
  • turn driver off and receiver on
  • wait a moment for bus settling etc.
  • "other code" which may receive and/or transmit via the RS485 port
  • repeat the above in a loop
Can you suggest any improvements to this?

Yes, I know that the best way to do it is with interrupts! I will move on to that when I've got this working perfectly...

Thanks - Rowan





List of 21 messages in thread
TopicAuthorDate
Receiving serial bytes on 80C320 UART            01/01/70 00:00      
   here            01/01/70 00:00      
      Thanks - excellent FAQ            01/01/70 00:00      
         "bible time"            01/01/70 00:00      
            Truly biblical!            01/01/70 00:00      
   My recommendation...            01/01/70 00:00      
      Useful ideas - but I don't want to change the hardware            01/01/70 00:00      
         You are absolutotally unconditionally confused            01/01/70 00:00      
            !RI or /RE            01/01/70 00:00      
               I'll re-answer the post above            01/01/70 00:00      
                  Use previous advice and keep receiver enabled            01/01/70 00:00      
                     This can't be right...            01/01/70 00:00      
                        How to get it working            01/01/70 00:00      
                        sometimes right, sometimes wrong            01/01/70 00:00      
                           e-mailed to Steve, Craig --- forum FYI            01/01/70 00:00      
                           We're getting there...            01/01/70 00:00      
                              I believe you are corect....            01/01/70 00:00      
                                 join the club            01/01/70 00:00      
                                    "No other way??"            01/01/70 00:00      
                                       in my (personal) opinion            01/01/70 00:00      
         what is "other code" ?            01/01/70 00:00      

Back to Subject List