我正在使用恩智浦LH79524 ARM7TDMI SOC處理器在嵌入式設備上工作。
我的任務是通過UART0將工作數據傳輸轉換爲使用DMA。如何通過DMA將數據傳輸至UART0恩智浦LH79524?
我們有一個格式化的ASCII數據的2k緩衝區,我希望DMA將這些數據傳輸到UART0。我們將分析系統,看看它是否比現有系統更快,以及是否可以釋放執行時間。
我在網上搜索了一些例子,恩智浦LH79524處理器沒有任何功能。
用戶手冊在傳輸數據所需的步驟上含糊不清。
這裏是我的代碼,假設UART0已設置爲字符傳輸:
typedef struct DMA_Data_Stream_Register_struct
{
uint32_t Source_Low;
uint32_t Source_High;
uint32_t Dest_Low;
uint32_t Dest_High;
uint32_t Maximum_Count;
uint32_t Control;
uint32_t Current_Srce_Addr_High;
uint32_t Current_Srce_Addr_Low;
uint32_t Current_Dest_Addr_High;
uint32_t Current_Dest_Addr_Low;
uint32_t Terminal_Count;
uint32_t reserved[4];
} DMA_Data_Stream_Register_t;
// ...
//----------------------------------------------------------------------
// Initialize the DMA controller to use the UART.
// This is an experiment.
//----------------------------------------------------------------------
DMA_Data_Stream_Register_t volatile * const p_dma_uart_tx = (DMA_Data_Stream_Register_t *) 0xFFFE10C0U;
uint32_t volatile * const p_dma_intr_mask_register = (uint32_t *) 0xFFFE10F0U;
uint32_t volatile * const p_dma_intr_clear_register = (uint32_t *) 0xFFFE10F4U;
uint32_t volatile * const p_dma_status_register = (uint32_t *) 0xFFFE10F8U;
uint32_t volatile * const p_uart0_dma_control_register = (uint32_t *) 0xFFFC0048U;
static const char dma_test_text[] = "\r\n\r\n*** Written by DMA ***\r\n\r\n";
//----------------------------------------------------------------------
// Set up UART0 for DMA transfers
//----------------------------------------------------------------------
*p_uart0_dma_control_register = 0x02U; // Enable transmit DMA, a.k.a. TXDMAEN
//----------------------------------------------------------------------
// Set up the source addresses for stream 0.
//----------------------------------------------------------------------
uint32_t source_address = (uint32_t) &dma_test_text[0U];
uint32_t source_high = source_address >> 16;
uint32_t source_low = source_address & 0xFFFFU;
p_dma_uart_tx->Source_Low = source_low;
p_dma_uart_tx->Source_High = source_high;
p_dma_uart_tx->Current_Srce_Addr_High = source_high;
p_dma_uart_tx->Current_Srce_Addr_Low = source_low;
p_dma_uart_tx->Maximum_Count = sizeof(dma_test_text) - 1U;
const uint32_t dma_config =
0x2000U /* Peripheral is destination */
| 0x0000U /* DMA to Destination Data width, 0x00 == 1 byte */
| 0x0000U /* Peripheral Burst Size, single == 0x00 */
| 0x0002U /* Current Source Register increments */
;
p_dma_uart_tx->Control = dma_config;
//----------------------------------------------------------------------
// Start the DMA transfer.
//----------------------------------------------------------------------
p_dma_uart_tx->Control = dma_config | 0x01U;
*p_uart0_dma_control_register = 0x02U; // Enable transmit DMA, a.k.a. TXDMAEN
我使用的IAR Embedded Workbench編譯器/ IDE。
通過監視窗口查看DMA寄存器時,源地址被複制到「當前源」寄存器。在等待一秒之後,「當前源」寄存器不會遞增,並且終端計數仍然是原始傳輸大小。
我不確定啓用DMA和UART0的順序。我嘗試啓用DMA首先,然後UART0 TXDMAEN,並沒有字符出來我試圖啓用UART0 TXDMAEN然後啓用DMA,並沒有字符出來
我正在尋找一個工作的C語言的示例傳輸數據到UART0使用DMA恩智浦LH79524處理器,任何指針都會有幫助