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