2012-07-25 11:37 AM
Hello I want to change the USART baudrate in some conditions but i couldn't do this.
switch( bdstate)
{ case 0 : DownloadUsartConfig(9600); break; case 1 : DownloadUsartConfig(19200); break; case 2 : DownloadUsartConfig(38400); break; case 3 : DownloadUsartConfig(57600); break; case 4 : DownloadUsartConfig(115200); break; default: break ; }the function is :void DownloadUsartConfig(uint32_t baudrate)
{ USART_InitStructure.USART_BaudRate = baudrate; USART_InitStructure.USART_WordLength = USART_WordLength_8b; USART_InitStructure.USART_StopBits = USART_StopBits_1; USART_InitStructure.USART_Parity = USART_Parity_No; USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; /* Configure USART2 */ USART_Init(DL_USART, &USART_InitStructure); USART_ITConfig(DL_USART, USART_IT_RXNE, ENABLE); /* Enable the USART2 */ USART_Cmd(DL_USART, ENABLE);}it doesn't work How can do about the this problem ? Where doing i make mistake ?2012-07-25 11:52 AM
I would think just doing the USART_Init() portion would be sufficient, I swear I've done this before when downshifting the CORE/APB clocks.
What you'd want to be sure of is that you aren't actively transmitting, ie wait for TC and TXE, so you don't change mid symbol.2012-07-25 12:20 PM
I understood that
case 0 :USART_InitStructure.USART_BaudRate = 9600;USART_Init(DL_USART, &USART_InitStructure);break;case 1:USART_InitStructure.USART_BaudRate = 19200;USART_Init(DL_USART, &USART_InitStructure);break;......Like it ?2012-07-26 11:14 AM
''it doesn't work''
That is not a useful description of the problem! Do you mean it sets the wrong baud rate? Or sets it, but won't change it? Or the UART doesn't work at all? Or what?? What debugging have you done to locate the problem? Have you started with a basic, working example on DevKit or Discovery Board or similar?2012-07-26 11:54 AM
Everything is ok
At the first the baudrate must be 9600 and than it will be change in some conditions.when i changed the bd on the source code i saw the signals like noise ?Scope can't decode this signals ..2012-07-26 03:40 PM
''Everything is ok''
You mean the problem is now solved?2012-07-26 06:08 PM
No I'm trying still
Only problem is changing baudrate. usart is working