This code was developped to show how you can send DMX packages without using any assembler code. It works because the ATmega chips of the Arduino support the 250.000 baud rate used by the DMX protocol.
You can find a Arduino compatible library and 2 sample applications at http://www.mathertel.de/Arduino/DMXSerial.aspx .
This library does not use the built-in Serial object but modifies the hardware registers directly.
Well, there are 3 stumbling blocks arround:
First, there is a problem with the standard Arduino library to access the hardware base serial interface because the serial kind of parity and stop bit handling is not set at all and the standard values are used. The trick is to patch the hardware register after initializing everything else to no parity and 2 stop bits.
The other problem is the starting break block that have to be sent before the channel data bytes. This 88 usec low signal cannot be sent by using the 250.000 baut rate so for sending the break a slower baud rate is initialized, a 0-byte is sent and the baud rate is reset to the correct 250.000 baud.
When trying to receive DMX packages you will have to implement a function for handling the receive interrupt. This will conflict with the built-in Serial library object that also implements this interrupt. The workaround that was used by several libraries is to patch the HardwareSerial.cpp implementation. I discovered that when not using the standard Serial library at all this conflict disapears because the standard Serial code is not included in the sketch. Therefore the library handles all hardware registers by itself.
You can find a more detailed documentation about that topic at http://www.mathertel.de/Arduino/DMXSerial.aspx.
This Sketch is just for analysis and demo purpose here.