您好!
我当前正在尝试在 AM243x 的 M4F 内核上运行 UART 多点奇偶校验地址匹配模式。
我已经为此编写了以下代码:
// Included Files
#include "serial_communication.h" // Contains all necessary headers
#define SERIAL_TASK_PRI (3u)
#define SERIAL_TASK_SIZE (1024u)
#define APP_UART_BUFSIZE (200U)
#define APP_UART_RECEIVE_BUFSIZE (8U)
StackType_t serialTaskStack[SERIAL_TASK_SIZE] __attribute__((aligned(32)));
StaticTask_t gSerialTaskObj;
TaskHandle_t serialTask;
uint8_t gUartBuffer[APP_UART_BUFSIZE] = {0x01, 0x02, 0x03};
uint8_t gUartReceiveBuffer[APP_UART_RECEIVE_BUFSIZE];
UART_Transaction trans;
void serial_main(void *args)
{
TickType_t xLastWakeTime;
xLastWakeTime = xTaskGetTickCount();
for(;;)
{
int32_t transferOK;
UART_Transaction_init(&trans);
/* Send data */
// HW_WR_REG32(((uint32_t)gUartHandle[COMM_UART1] + UART_ECR), (HW_RD_REG32((uint32_t)gUartHandle[COMM_UART1] + UART_ECR) | 0x01)); // Next byte is written as an address byte
trans.buf = &gUartBuffer[0U];
trans.count = 3;
transferOK = UART_write(gUartHandle[COMM_UART1], &trans);
DebugP_log("Message sent!\r\n");
//TODO: xTaskDelayUntil()
vTaskDelay(1000 / portTICK_PERIOD_MS); // Set the overall task period to 1ms
}
}
void empty_main(void *args)
{
/* Open drivers to open the UART driver for console */
Drivers_open();
Board_driversOpen();
// // Enable Multi-drop Parity Address Match Mode
// HW_WR_REG32(((uint32_t)gUartHandle[COMM_UART1] + UART_ECR), (HW_RD_REG32((uint32_t)gUartHandle[COMM_UART1] + UART_ECR) & 0xFFFFFFF7)); // Disable Receive Mode
// HW_WR_REG32(((uint32_t)gUartHandle[COMM_UART1] + UART_EFR2), (HW_RD_REG32((uint32_t)gUartHandle[COMM_UART1] + UART_EFR2) | 0x00000004)); // Enable Multi-drop address match mode
// HW_WR_REG32(((uint32_t)gUartHandle[COMM_UART1] + UART_MAR), (uint32_t)0x10); // Set matching device address
// HW_WR_REG32(((uint32_t)gUartHandle[COMM_UART1] + UART_MMR), (uint32_t)0xFF); // Set address match masking
// HW_WR_REG32(((uint32_t)gUartHandle[COMM_UART1] + UART_MBR), (uint32_t)0xFF); // Set broadcast address match
// HW_WR_REG32(((uint32_t)gUartHandle[COMM_UART1] + UART_EFR2), (HW_RD_REG32((uint32_t)gUartHandle[COMM_UART1] + UART_EFR2) | 0x00000080)); // Enable broadcast address matching (if needed)
// HW_WR_REG32(((uint32_t)gUartHandle[COMM_UART1] + UART_ECR), (HW_RD_REG32((uint32_t)gUartHandle[COMM_UART1] + UART_ECR) | 0x08)); // Enable RX
/* create the tasks, order of task creation does not matter for this example */
serialTask = xTaskCreateStatic( serial_main, /* Pointer to the function that implements the task. */
"Serial_polling", /* Text name for the task. This is to facilitate debugging only. */
SERIAL_TASK_SIZE, /* Stack depth in units of StackType_t typically uint32_t on 32b CPUs */
NULL, /* We are not using the task parameter. */
SERIAL_TASK_PRI, /* task priority, 0 is lowest priority, configMAX_PRIORITIES-1 is highest */
serialTaskStack, /* pointer to stack base */
&gSerialTaskObj ); /* pointer to statically allocated task object memory */
configASSERT(serialTask != NULL);
DebugP_log("The task is created!\r\n");
Board_driversClose();
/* Don't close drivers to keep the UART driver open for console */
/* Drivers_close(); */
}
(在 main.c 中只会创建一个一次性任务,该任务会调用 empty_maine()函数,并启动调度程序)
使用注释的多点使能例程、程序通过 UART 接口工作并发送相应的字节。 但是、当我激活多点模式(取消代码注释)时、微控制器会卡在那里、不处理任何其他内容。 这样做的原因是什么? 而且 M4F 内核完全支持多点匹配模式吗?
感谢您的帮助!
