2017-07-24 04:22 AM
Hello
I useing stm32f103c8(72mhz) and i want create DMX512 transmitter for led lighing.
I have some problem.I config usart like this.
USART_InitStructure.USART_BaudRate = 250000;
USART_InitStructure.USART_WordLength = USART_WordLength_8b; USART_InitStructure.USART_StopBits = USART_StopBits_2; USART_InitStructure.USART_Parity = USART_Parity_No; USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; USART_InitStructure.USART_Mode = USART_Mode_Tx; USART_Init(USART2, &USART_InitStructure);when i make reset sequence and data with this code.
_delayus(20);///MarkBeforeBreak
USART_SendBreak(USART2);//Break_delayus
(12);//MarkAfterBreak; USART_SendData(USART2,0);///start codefor(int i=0;i<512;i++)
{
USART_SendData(USART2,255);//R
USART_SendData(USART2,255);//G
USART_SendData(USART2,255);//B
_delayus
(12);//MTBP
}
I have some problem with this code.
1-Break time is 44us but dmx need 92us at least how can solve this problem?
2-Is structure right for dmx led light?
Thanks
2017-07-24 05:30 AM
Hi!!
for the first part:
by sending more (at least 3) consecutive breaks. Is it permited from protocol?
2017-07-24 08:24 AM
Hi again
for the second part. .I am nnot familiar with this protocol but you have some UART issuesBefore you send a character or every character by USART_SendData(USARTX,y);must check before if DR txbuffer is empty by// SendByte sequencewhile( USART_GetFlagStatus(USART2, USART_FLAG_TXE)==RESET);USART_SendData(USART2,data);to send two or more consecutive breaks must check before ' Break Character' flag //check before the CR1 SBK flagwhile(USART2->CR1 & CR1_SBK_Set);USART_SendBreak(USART2);//Breakwhile(USART2->CR1 & CR1_SBK_Set);USART_SendBreak(USART2);//Break2017-07-25 06:06 AM
hello thanks.
but when i use this code
while(USART2->CR1 & CR1_SBK_Set);
USART_SendBreak(USART2);//Break
break doesn't send at all
2017-07-25 09:18 AM
Hello again
mahmoud
!What you mean
doesn't send at all
?You mean stucks to ''while loop''?
To observe if Uart tranmitts clear manualy TC flag (transmit completed) just before transmit.
and observe it after send a break .
I took a look at dmx512 protocol.
It don't says ''send a break '' but describes Break condition as LO state of line. (means keep IO pin low for xxx microsec)
So i think you need a different approximation for your project..
For Break and MAB and MTBFs states you may use your TX pin as normal output and keep it low or hi for some time. .
When you need to transmit serial data Change it to Uart tx pin and transmit the data!
Regards
2024-06-26 11:58 PM
The USART module available on STM32
microcontrollers has the ability to automatically generate a 12-bit long break signal,
corresponding to 48 µsec at 250 k baud. Unfortunately, this is too short for use in a DMX512
application as the protocol requires a minimum length of 92 µsec.
Figure 6 shows the alternative hardware method chosen to generate the longer break
signal. A 100 Ω resistor is connected in series with the microcontroller's USART transmit pin
and the other end of the resistor to an I/O pin. With this solution, the break time can be
varied, from 92 µsec to 176 µsec to meet the DMX protocol break time specification, when
sending a break signal, the I/O pin is driven low. Later, the I/O pin is tri-stated to allow
transmission from the USART to resume.