Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | Last revisionBoth sides next revision | ||
pinouts [2021/08/29 21:37] – [V.Smile cartridges] pulkomandy | pinouts [2021/09/23 22:56] – [Flow control] Document it a bit more clearly pulkomandy | ||
---|---|---|---|
Line 80: | Line 80: | ||
===== Flow control ===== | ===== Flow control ===== | ||
- | When the console sends a byte, first CTS goes high, then the console sends the bits on the Tx line. When done, CTS goes low again. | + | The CPU has a single UART that is used to communicate with both controllers. This requires flow control to make sure the two controllers don't try to communicate at the same time. |
- | When the controller | + | A controller |
- | If there are multiple bytes to send, RTS remains down until the start of the last byte. | + | The general way to handle this is as follows, starting from an idle state with all CTS low and no pending data transfers |
+ | |||
+ | * If a controller has its RTS pin low, select it by setting | ||
+ | * The controller will start transmitting data, receive that from the Rx register until "Rx ready" is cleared | ||
+ | * If needed, send a reply to the controller | ||
+ | * Make sure the reply is completely sent ("Tx buffer empty" in status register) | ||
+ | * Wait until RTS goes high (the controller has nothing to send anymore) | ||
+ | * Put CTS low again | ||
+ | * Wait a little (in case the controller was sending something just as you set CTS low) and read a possible | ||
+ | * You are back to idle state | ||
+ | |||
+ | It is possible to send something to a controller even if it was not requesting RTS: | ||
+ | |||
+ | * Select the controller by setting the corresponding CTS high | ||
+ | * Send data to the controller | ||
+ | * Make sure the reply is completely sent ("Tx buffer empty" in status register) | ||
+ | * Check that RTS did not become low | ||
+ | * Put CTS high again | ||
+ | * Back to idle state | ||
+ | |||
+ | The controller keeps RTS down as long as it has more bytes to send. | ||
===== Messages from the controller ===== | ===== Messages from the controller ===== | ||