cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F3 Discovery USART1 Problem

SoHaeng.Lee
Associate II
Posted on January 10, 2016 at 12:29

The original post was too long to process during our migration. Please click on the attachment to read the original post.
4 REPLIES 4
Posted on January 10, 2016 at 16:17

When sending characters to the USART you need to check TXE is asserted before each byte, your string output functions completely ignore that.

Sending dozens of characters in the IRQ Handler is a poor plan, the buffer depth is a single character, you need to buffer the data on the software side, and output at each TXE assertion.

Your use of include files suggests you aren't passing the right defines into the compiler. Check again the project options in the templates for your tool chain.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
SoHaeng.Lee
Associate II
Posted on January 10, 2016 at 17:32

Thanks clive1.

I just checked my source, and edit some code.

--------------------------------------------

void SerialPutString(char *c)

{

 while(*c)

 {

  USART_SendData(USART1, (uint16_t)*c++);

  while(USART_GetFlagStatus(USART1, USART_FLAG_TXE)==RESET);

 }

}

// USART1_IRQHandler

// GetChar interrupt Call

// USART1 입력설정 í�?Œëž˜ê·¸ê°€ 세트ë�˜ë©´ 호출ë�¨.

void USART1_IRQHandler(void)

{

 uint16_t C;

 char      s[20];

 if(USART_GetITStatus(USART1,USART_IT_RXNE) != RESET)

 {

   C = USART_ReceiveData(USART1);

   sprintf(s,''Data : %c : %#x\r\n'',C,C);

   SerialPutString(s);

   SerialPutString(''\r\n'');

 }

}

--------------------------------------------

But, the problem was not fixed.

See my youtube : https://www.youtube.com/watch?v=awV40t2MGto

Posted on January 10, 2016 at 17:56

void SerialPutString(char *c)
{
while(*c)
{
while(USART_GetFlagStatus(USART1, USART_FLAG_TXE)==RESET); // **BEFORE** - IS REGISTER EMPTY TO RECEIVE NEXT CHAR
USART_SendData(USART1, (uint16_t)*c++);
}
}

Make sure the setting of HSE_VALUE matches the 8 MHz clock source used. You serial header has three pins, looks to use just two, do the two boards share a common ground? I'd suggest outputting a stream of 'U' characters and checking the baud rate settings on a scope. The output from the STM32 is at CMOS levels, not RS232 levels
Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
SoHaeng.Lee
Associate II
Posted on January 11, 2016 at 05:33

Thanks clive1.

I just fixed my problem.

The problem was cable problem.

and i respect your advice and change my code.

thank you.