我正在使用UART3进行RS-485
通信(我在PC和
威廉希尔官方网站
板之间连接了B& B RS-232到RS-485转换器)。麻烦的是UART3不会“发送”数据,除非我在通过UART3发送数据后不久放置调试断点。然后数据发送正常。如果没有断点,PC就不会收到数据。这是我发送数据的功能:
void send_485(uint8_t * ptr,uint8_t length)
{
uint8_t i = 0;
uint8_t count = _1s_counter;
GPIO_WriteHigh(GPIOE,GPIO_PIN_4);
while(_1s_counter< count + 5){}
而(长度 - > 0)
{
/ *等待UART3 TXE = 0 * /
while(UART3_GetFlagStatus(UART1_FLAG_TXE)== RESET)
{
}
UART3_SendData8((PTR [I ++]));
}
count = _1s_counter;
while(UART3_GetFlagStatus(UART1_FLAG_TXE)== RESET)
{
}
while(_1s_counter< count + 1000){}
GPIO_WriteLow(GPIOE,GPIO_PIN_4); //在这一行放置断点。
}
关于调试器做什么使得通信工作的任何想法?添加该断点,可以完美地接收字节。
谢谢,
万斯
#uart3#rs485#stm8
以上来自于谷歌翻译
以下为原文
I'm using UART3 for RS-485 communica
tions (I have a B&B RS-232 to RS-485 converter connected between the PC and the board). The trouble is that the UART3 won't ''send'' the data unless I put a debug break-point shortly after sending data via UART3. The data then sends fine. Without the break-point, the PC doesn't receive the data. Here is my function for sending data:
void send_485(uint8_t *ptr, uint8_t length)
{
uint8_t i = 0;
uint8_t count = _1s_counter;
GPIO_WriteHigh(GPIOE, GPIO_PIN_4);
while(_1s_counter < count+5){}
while (length-- > 0)
{
/* Wait while UART3 TXE = 0 */
while (UART3_GetFlagStatus(UART1_FLAG_TXE) == RESET)
{
}
UART3_SendData8((ptr[i++]));
}
count = _1s_counter;
while (UART3_GetFlagStatus(UART1_FLAG_TXE) == RESET)
{
}
while(_1s_counter < count + 1000){}
GPIO_WriteLow(GPIOE, GPIO_PIN_4); // Put break-point on this line.
}
Any ideas as to what the debugger does that makes the communication work? Adding that break-point, the bytes are received flawlessly.
Thanks,
Vance
#uart3 #rs485 #stm8