芯片:STM32F429ZGT6
线程信息:
cmd_tx_thread = rt_thread_create("cmd_tx_thread", cmd_tx_thread_entry, &cmd_tx_thread, 1024, 6, 30);
cmd_rx_thread = rt_thread_create("cmd_rx_thread", cmd_rx_thread_entry, &cmd_rx_thread, 1024, 6, 50);
TQ_thread = rt_thread_create("TQ_thread", TQ_thread_entry, RT_NULL, 4096, 6, 30);
YY_thread = rt_thread_create("YY_thread", YY_thread_entry, RT_NULL, 4096, 6, 30);
YY_X_thread = rt_thread_create("YY_X_thread", YY_X_thread_entry, RT_NULL, 4096, 6, 30);
YY_Z_thread = rt_thread_create("YY_Z_thread", YY_Z_thread_entry, RT_NULL, 4096, 6, 30);
YY_Y_thread = rt_thread_create("YY_Y_thread", YY_Y_thread_entry, RT_NULL, 4096, 6, 30);
YY_P_thread = rt_thread_create("YY_P_thread", YY_P_thread_entry, RT_NULL, 4096, 6, 30);
TQ_X_thread = rt_thread_create("TQ_X_thread", TQ_X_thread_entry, RT_NULL, 4096, 6, 30);
TQ_Z_thread = rt_thread_create("TQ_Z_thread", TQ_Z_thread_entry, RT_NULL, 4096, 6, 30);
TQ_Y_thread = rt_thread_create("TQ_Y_thread", TQ_Y_thread_entry, RT_NULL, 4096, 6, 30);
heat_timer = rt_thread_create("heat_timer", heat_timer_entry, RT_NULL, 512, 6, 30);
heat_thread = rt_thread_create("heat_thread", heat_thread_entry, RT_NULL, 1024, 6, 30);
内核堆栈信息
#define RT_HEAP_SIZE 1024 *32
static uint32_t rt_heap[RT_HEAP_SIZE] /* __at(0x10000000)*/; // heap default size: 4K(1024 * 4)
还有一些其他的线程,就在详细列出:
指令数据都是定长16位;
所有线程优先级相同;
线程将指令处理完以后,通过
void send_ack(uint8_t data_buf[16])
{
data_buf[14] = XorVerify(data_buf, 1, 13);
//HAL_UART_Transmit(&cmd_com, data_buf, CMD_LENGTH,100);
rt_mq_send(cmd_tx_mq, data_buf, CMD_LENGTH);
}
唤醒指令返回线程,发送返回数据给上位机
void cmd_tx_thread_entry(void *parameter)
{
rt_err_t uwRet;
//rt_uint32_t recved;
uint8_t cmd_tx[16];
while (1)
{
/* 从消息队列中接收要返回的数据信息 */
uwRet = rt_mq_recv(cmd_tx_mq, cmd_tx, CMD_LENGTH, RT_WAITING_FOREVER);
if (uwRet == RT_EOK)
{
//rt_enter_critical();
HAL_UART_Transmit(&cmd_com, cmd_tx, CMD_LENGTH, 200);
//rt_exit_critical();
rt_thread_mdelay(5);
}
}
}
现在遇到的问题是: 设备运行一段时间后,通过串口监控发现,通过cmd_tx_thread线程返回的数据出现断帧现象;并且此时,上位机再发送指令给主控板,下位机不再响应;
MDK仿真,给指令串口打断点,发现也没有响应串口接收中断。thread.org/ask/question/215d47c484a7eae2.html