refactor: Modbus 默认波特率 115200 + 资源分析重评估
分析结论 (115200 vs 9600): - TX 阻塞: 4.3ms (曾 44.8ms) → 活动态 CPU 仅 +2.9% - 主循环延迟 < 半个测量窗, 不影响线圈检测/光耦/BLE - 从"临界可用"变为"完全充裕" 固件修复: - rs485_init: 硬编码 RS485_BAUD → 使用 g_storage_uart_baud (flash 可配) - 协议文档: Modbus 默认 115200 - DLD154Tool: 串口默认 115200
This commit is contained in:
@@ -50,7 +50,7 @@ void rs485_init(void)
|
||||
GPIOA_ModeCfg(GPIO_Pin_13, GPIO_ModeOut_PP_5mA);
|
||||
|
||||
/* UART0 外设: 9600 8N1 */
|
||||
UART0_BaudRateCfg(RS485_BAUD);
|
||||
UART0_BaudRateCfg(g_storage_uart_baud); /* 使用 flash 存储的波特率 (700BS=9600, Modbus=115200) */
|
||||
R8_UART0_LCR = 0x03; // 8 数据位, 1 停止位, 无校验
|
||||
R8_UART0_MCR = 0x04; // RE=0 进入接收模式
|
||||
|
||||
|
||||
@@ -779,7 +779,8 @@ void modbus_init(void)
|
||||
|
||||
void modbus_poll(void)
|
||||
{
|
||||
/*=== 帧接收 ===*/\n if (_rx_len > 0) {
|
||||
/*=== 帧接收 ===*/
|
||||
if (_rx_len > 0) {
|
||||
uint32_t now = mstick();
|
||||
if (now - _rx_last_tick >= MB_FRAME_TIMEOUT_TICK) {
|
||||
/* 帧超时 → 处理完整帧 */
|
||||
@@ -814,5 +815,6 @@ void modbus_poll(void)
|
||||
}
|
||||
}
|
||||
|
||||
/*=== 主动上报调度 ===*/\n modbus_report_schedule();
|
||||
/*=== 主动上报调度 ===*/
|
||||
modbus_report_schedule();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user