STM32 and DMX
Posted: Sat Mar 28, 2015 9:46 pm
Hello,
I'm migrating some stuff I have from AVR to STM32, they're DMX dongles and/or converters, so I've been trying to investigate a little bit more about implementing the DMX protocol in STM32 and I've been having some problems with it by itself, and, I have a few doubts related to ChibiOS about it as well.
What is a common practice to generate the break signal, used to signal the start of the DMX stream, is to change baudrate to 100000 (and change the format to 8 bit + parity + 1 stop bit = 10 bit ~ 100usec break) and send a 0 byte, then switch back to the regular DMX baudrate which is 250k, by changing baud, we generate the MAB (Mark after break), then proceed to send the start byte which for DMX is 0 and then send 512 bytes which correspond to the 512 DMX channels.
The most efficient way by implementing this in AVR's was(is) :
- Set baud to 100k
- write byte 0
- set baud to 250k, enable tx enable int
- txc int triggers and send startbit disable tx complete int, enable udre int
- udre int triggers and send 512 bytes of data
- repeat
Now, I'm attempting to do the exact same thing in a STM32 (more specifically an STM32f103C8T6 the one sold in ebay from LC-Tech board) while using ChibiOS, the purpose is to have 3 DMX streams (for each usart) + 1 SPI (ENC28J60), yes, for those guessing, an ArtNet node with 3 DMX output ports, where each DMX stream is a thread, SPI (ENC28J60) another thread, and the main thread the one handling the USB connectivity, with a usb serial cdc mostly for debugging purposes, and this led me to the following questions I'd hope you guys could help me with (oh btw, it's open source, or better yet, will be as soon as I have an alpha working):
- First and most important, is the AVR method of generating a DMX stream the best one to do in a Cortex M3 such as this STM32F1 ?
- If it is, how do I change baudrate after I initialize the UART ? If not, how do you guys in your experience think it would be the best method to achieve the most stable stream ?
- Is my way of thinking regarding the plan for implementing the project with ChibiOS the right one ? (3 threads per USART + 1 thread for SPI + main thread for USB) ?
- What is the highest SPI speed that a STM32F1 (running ar 72Mhz) can achieve ? (72/2?)
Thank you very much for all the help.
I'm migrating some stuff I have from AVR to STM32, they're DMX dongles and/or converters, so I've been trying to investigate a little bit more about implementing the DMX protocol in STM32 and I've been having some problems with it by itself, and, I have a few doubts related to ChibiOS about it as well.
What is a common practice to generate the break signal, used to signal the start of the DMX stream, is to change baudrate to 100000 (and change the format to 8 bit + parity + 1 stop bit = 10 bit ~ 100usec break) and send a 0 byte, then switch back to the regular DMX baudrate which is 250k, by changing baud, we generate the MAB (Mark after break), then proceed to send the start byte which for DMX is 0 and then send 512 bytes which correspond to the 512 DMX channels.
The most efficient way by implementing this in AVR's was(is) :
- Set baud to 100k
- write byte 0
- set baud to 250k, enable tx enable int
- txc int triggers and send startbit disable tx complete int, enable udre int
- udre int triggers and send 512 bytes of data
- repeat
Now, I'm attempting to do the exact same thing in a STM32 (more specifically an STM32f103C8T6 the one sold in ebay from LC-Tech board) while using ChibiOS, the purpose is to have 3 DMX streams (for each usart) + 1 SPI (ENC28J60), yes, for those guessing, an ArtNet node with 3 DMX output ports, where each DMX stream is a thread, SPI (ENC28J60) another thread, and the main thread the one handling the USB connectivity, with a usb serial cdc mostly for debugging purposes, and this led me to the following questions I'd hope you guys could help me with (oh btw, it's open source, or better yet, will be as soon as I have an alpha working):
- First and most important, is the AVR method of generating a DMX stream the best one to do in a Cortex M3 such as this STM32F1 ?
- If it is, how do I change baudrate after I initialize the UART ? If not, how do you guys in your experience think it would be the best method to achieve the most stable stream ?
- Is my way of thinking regarding the plan for implementing the project with ChibiOS the right one ? (3 threads per USART + 1 thread for SPI + main thread for USB) ?
- What is the highest SPI speed that a STM32F1 (running ar 72Mhz) can achieve ? (72/2?)
Thank you very much for all the help.