??? 04/02/09 01:41 Modified: 04/02/09 01:54 Read: times |
#164199 - I wouldn't use serial transmission interrupts Responding to: ???'s previous message |
As the send baud rate (DMX-512) is so much higher than the receive baud rate (Midi) I would check the RI flag by polling after each sent DMX-512 data byte (frame):
Poll RI before sending the string, if RI=0 set TXD=0 for 88µsec, set TXD=1 for 8µsec, poll RI, if RI=0 move start byte into SBUF, poll TI until TI=1, afterwards clear TI and poll RI, if RI=0 move first DMX-512 data byte into SBUF, poll TI until TI=1, afterwards clear TI and poll RI, if RI=0 move second DMX-512 data byte into SBUF, and so on... By this scheme there's no chance that a received Midi byte gets lost, because a Midi data byte needs 320µsec, while a DMX-512 data byte only needs 44µsec. Even the reset pulse only lasts 88µsec. If in the scheme above once RI=1 is found, clear RI, move the received Midi data byte waiting in the SBUF register to a free location in the RAM and send the next DMX-512 data byte. At the end of transmission of string (all 512 DMX-512 data bytes) you have some Midi data bytes in the RAM waiting for being analyzed and processed. By the way, I would choose UART Mode 1 operation, where 10 bits are transmitted, 1 start bit, 8 data bits and 1 stop bit. This is directly Midi compatible. For the DMX-512 transmission add a delay of 4µsec after each sent DMX-512 data byte (directly after TI was set high by the UART). By this you add the needed second stop bit of DMX-512 transmission protocol. Kai |