Home > other >  STM32 RS485 communication receives the first two bytes of data error or overwritten
STM32 RS485 communication receives the first two bytes of data error or overwritten

Time:09-18

I do STM32 RS485 communication test found that when using a serial debugging assistants to send data STM32 to accept less than the first two bytes of data, for example, I use serial debugging assistant send STM32 00 00 03 01 00 02, STM32 is 00 00 03 02 received the first two Numbers!!
If I send 11 11 00 00 03 02 is acceptable for the STM32 buffer in 03 00 02
I'm dizzy! This is what happened? The warrior can help answer?

Void USART3_IRQHandler (void)//serial port interrupt service routine 2
{
U8 res;
U8 err;
If (USART_GetITStatus (USART3, USART_IT_RXNE)!=RESET)
{
If (USART_GetFlagStatus (USART3, USART_FLAG_NE | USART_FLAG_FE | USART_FLAG_PE))
Err=1;//noise is detected, the frame or calibration errors
The else
Err=0;
Res=USART_ReceiveData (USART3);
If (err==0)
{
RS485_RX_BUFF [RS485_RX_CNT]=res;
RS485_RX_CNT + +;
}
}
}

CodePudding user response:

STM32 serial interface chip connected with an oscilloscope waveform at the tube feet first

CodePudding user response:

Rs232 chip may have a problem, I tried the batch production of boards often have a lot of can't normal communication, a lot of fakes, 232 chip debug a circuit board, sometimes life is not normal, is don't doubt that chip is bad, as soon as the results in the chip is normal,

CodePudding user response:

Sometimes errors on hardware, especially the RS485 chips, from a treasure to sell development board, 485 chips may be inferior products, I have my own experience, debugging a day and a half, finally determine the RS485 chip, bought a new, still go up, problems to be resolved immediately,

Solve the in the mind a little excited, report back to you immediately, so as not to have the same problem of the bobbin to walk again my Lou,

CodePudding user response:

Could be the send function

CodePudding user response:

Change a serial assistants!

Did you use the special MODBUS serial assistants, your front when the address, participate in the resolution, but not when data show!!!!!!


Ha ha ha, I also sent this mistake, didn't pay attention to, the whole 3 genius,

CodePudding user response:

Check the HSPi agreement, esp when it needs CMD and add in the first few bytes, send and receive public his buff
  • Related