??? 05/29/10 13:38 Read: times |
#176297 - How to get it working Responding to: ???'s previous message |
Rowan Sylvester-bradley said:
Per Westermark said: This surely can't be right? If TI was set when starting to transmit, it would surely serve no useful purpose? From Erik's FAQ, I understood that TI was set at the beginning of the stop bit, which would mean that have to wait at least one bit-time before turning off the driver.
If not being able to hear your own outgoing data, you will get an interrupt when the UART starts to send the last character Thanks - Rowan Rowan: The transmit section is double buffered. This means that when sending out several bytes this happens: 1) You load SBUF 2) SBUF gets loaded output shifter 3) TI becomes set because SBUF is "empty" (note this happens because the shifter was idle [which is similar to stop bit state] ) 4) You load SBUF again with second byte 5) Passage of time while shifter works at baud rate 6) Shifter gets done with previous byte (i.e. at stop bit) 7) SBUF again gets loaded into output shifter for next byte 8) TI becomes set because SBUF is "empty" (note this happening in conjunction with stop bit time of previous byte). 9) If more bytes going out loop back to step 4 else continue ahead 10) Delay one bit time 11) Disable transmitter Do use interrupts. For RS485 stop thinking about single byte transfers which are next to useless. Concentrate 100% on the concept of a packetized communucations system where a whole command goes out and a response comes back. For a master the ISR can become a relatively simple state machine process a transmit buffer, turn the line around and receive the response. For a slave the state machine works the opposite way. The slave ISR looks continually for bytes coming in and assembles them into a buffer when it looks like a packet has started. Once the packet has received the slave turns the line around and sends back its reply. Always devise a "protocol". This should include in the "packet" a start leader byte, a command opcode, a packet length, an optional payload, and a check code such as CRC. If operating master to multiple slaves have the packet also include the address of the intended slave. Michael Karas |
Topic | Author | Date |
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 |