Home > other >  Stm32 serial port to send sending error occurs
Stm32 serial port to send sending error occurs

Time:10-11

Int main (void)
{
My_USART_Config ();
Uint8_t buffer [6].
Buffer [0]=0 x31;
Buffer [1]=0 x32;
Buffer [2]=0 x32;
Buffer [3]=0 x30;
Buffer [4]=0 x63;//high
Buffer [5]=0 xba;
While (1)
{
For (uint8_t I=0; i<6; I++)
{
COM_Sendchar (buffer [I]);
}
Delay_ms (1000);

}
}
Was going to do the modbus crc16 inspection, but every time when the buffer [0] ~ buffer [5] by cyclic repeating hexadecimal 0 x3f, serial debugging assistant always appear when I thought didn't exceed 0 xba uint8_t (0 ~ 255), then go to step to send, found that a single to send data when the results are normal, wrong feeling is at this point in the 0 xba,
This is to send a single character function definition:
Void COM_Sendchar uint8_t (ch)
{
USART_SendData (USART1, ch);
While (USART_GetFlagStatus (USART1, USART_FLAG_TC)==RESET);
}
No no bosses to solve the...

CodePudding user response:

USART_FLAG_TC USART_FLAG_TXE try instead

CodePudding user response:

while (! (USART1 - & gt; The SR & amp; USART_FLAG_TXE));

CodePudding user response:

Send out, whether to send the correct

CodePudding user response:

Should be a sign of your query is wrong, look at the corresponding series of library function or routine
  • Related