Hi,
I am currently trying to put the UART multi-drop parity address match mode into operation on the M4F core of the AM243x.
I have written the following code for this:
// 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(); */ }
(In the main.c just a one-time task is created, which calls the empty_main() function, and the scheduler is started)
With the commented multi-drop enable routine, the programme works and sends the appropriate bytes via the UART interface. However, when I activate the multi-drop mode (uncomment the code), the microcontroller gets stuck there and does not process anything else. What could be the reason for this? And is the multi-drop match mode supported from the M4F Core at all?
Thanks for your help!