If you're the DMX transmitter then there's a lot of leeway in the timing. As long as you send a 512-byte packet once a second you're in spec. The time between bytes isn't really an issue either as long as you meet that. You'll probably want it faster than that, but there's usually plenty of time in your main loop to do stuff.
Here's how I've done this in the past:
- use two 512 byte packets... one for the main loop to fill (#1) and one for the ISR to transmit (#2).
- in the main loop do whatever you need to create the DMX packet in buffer #1
- copy the packet in buffer #1 to the second buffer #2 for the ISR to use to transmit
- start the packet transmitting. after generating the BREAK/START timing, the ISR pulls bytes from the DMX transmit buffer #2 until done using the UART TXIF.
The main loop can continue on generating the next packet since it uses buffer #1. Usually, things are so fast that the main loop ends up waiting for the DMX TX ISR to finish sending the previous packet before sending the new one since it takes at least 22ms for the ISR to send the 512 bytes.
Bookmarks