主题中讨论的其他器件:SysConfig
工具与软件:
您好!
我将使用 McASP 驱动程序来编写一个应用程序。
我成功地配置了 McASP0驱动器实例、以通过单个串行器(AXR0或 AXR1)以48kHz 的速率传输8槽/16位 TDM 帧:
- AXR0:
- AXR1:
问题是、当我启用2个串行器(即 AXR0和 AXR1)并运行非常相同的应用 时、我无法在相应的串行数据引脚上看到任何数据-我只能看到串行位时钟信号:
我想知道如何启用2个串行器、以便它们可以同时为两个引脚上的数据提供服务。
在 SysConfig 中添加第二个串行器是否足够?
我是否需要发送更多数据?
是否有任何实现 TDM 多槽多串行器案例的示例应用可用?
下面是应用代码和 SysConfig 设置示例:
-应用程序:
#include "mcasp_util.h" #include "ti_drivers_config.h" #include <FreeRTOS.h> #include <drivers/mcasp.h> #include <kernel/dpl/CacheP.h> #include <kernel/dpl/DebugP.h> #include <task.h> #include <stdint.h> #include <string.h> #define SLOT_COUNT (8u) #define SLOT_SIZE_IN_B (4u) #define FRAME_COUNT (2u) #define FRAME_SIZE_IN_B (SLOT_COUNT * SLOT_SIZE_IN_B) #define DATA_SIZE_IN_B (FRAME_COUNT * FRAME_SIZE_IN_B) #define LOOPJOB_BUFFER_SIZE_IN_B (FRAME_SIZE_IN_B) uint8_t txBuffers[FRAME_COUNT][FRAME_SIZE_IN_B] __attribute__((aligned(256))); MCASP_Transaction txTransactions[FRAME_COUNT] = {}; uint32_t volatile txCallbackCallCount = 0u; extern uint8_t txLoopjobBuffer[]; static void fillTxBuffers(uint8_t (* const buffer)[FRAME_COUNT][FRAME_SIZE_IN_B]) { for (uint32_t i = 0u; i < FRAME_COUNT; ++i) { for (uint32_t j = 0u; j < FRAME_SIZE_IN_B; ++j) { (*buffer)[i][j] = (FRAME_SIZE_IN_B * i + j) % 256u; } } } static void fillLoopjobBuffer( uint8_t (* const buffer)[LOOPJOB_BUFFER_SIZE_IN_B], uint32_t const value) { for (uint32_t i = 0u; i < LOOPJOB_BUFFER_SIZE_IN_B; i += 4u) { *((uint32_t*)(&((*buffer)[i]))) = value; } } static void submitBuffers( MCASP_Handle const handle, MCASP_Transaction (* const transactions)[FRAME_COUNT], uint8_t (* const buffers)[FRAME_COUNT][FRAME_SIZE_IN_B], int32_t (* const callback)(MCASP_Handle, MCASP_Transaction*)) { for (uint32_t i = 0u; i < FRAME_COUNT; ++i) { (*transactions)[i].buf = &(*buffers)[i]; (*transactions)[i].count = FRAME_SIZE_IN_B / SLOT_SIZE_IN_B; (*transactions)[i].timeout = 0xFFFFFFFFu; callback(handle, &(*transactions)[i]); } } static void awaitTransferCompletion(void) { vTaskDelay(pdMS_TO_TICKS(100u)); } static void withdrawBuffers( MCASP_Handle const handle, MCASP_Transaction* (* const callback)(MCASP_Handle)) { while (callback(handle) != NULL) { } } void mcaspMain(void* args) { MCASP_Handle handle; fillTxBuffers(&txBuffers); CacheP_wb(&txBuffers, DATA_SIZE_IN_B, CacheP_TYPE_ALL); fillLoopjobBuffer(&txLoopjobBuffer, 0xFFFFFFFFu); CacheP_wb(&txLoopjobBuffer, LOOPJOB_BUFFER_SIZE_IN_B, CacheP_TYPE_ALL); handle = MCASP_getHandle(CONFIG_MCASP0); DebugP_assert(handle != NULL); submitBuffers( handle, &txTransactions, &txBuffers, &MCASP_submitTx ); DebugP_assert(MCASP_startTransferTx(handle) == SystemP_SUCCESS); awaitTransferCompletion(); MCASP_stopTransferTx(handle); withdrawBuffers(handle, &MCASP_withdrawTx); } void runOnTransmittingData( MCASP_Handle handle, MCASP_Transaction* const transaction) { ++txCallbackCallCount; }
- SysConfig 设置:
/** * These arguments were used when this file was generated. They will be automatically applied on subsequent loads * via the GUI or CLI. Run CLI with '--help' for additional information on how to override these arguments. * @cliArgs --device "AM62x" --package "AMC" --part "Default" --context "a53ss0-0" --product "MCU_PLUS_SDK_AM62x@09.02.01" * @versions {"tool":"1.20.0+3587"} */ /** * Import the modules used in this configuration. */ const mcasp = scripting.addModule("/drivers/mcasp/mcasp", {}, false); const mcasp1 = mcasp.addInstance(); const debug_log = scripting.addModule("/kernel/dpl/debug_log"); const mmu_armv8 = scripting.addModule("/kernel/dpl/mmu_armv8", {}, false); const mmu_armv81 = mmu_armv8.addInstance(); const mmu_armv82 = mmu_armv8.addInstance(); /** * Write custom configuration values to the imported modules. */ mcasp1.$name = "CONFIG_MCASP0"; mcasp1.txHclkSourceMux = 2; mcasp1.rxHclkSourceMux = 2; mcasp1.txCallbackFxn = "runOnTransmittingData"; mcasp1.rxCallbackFxn = "runOnReceivingData"; mcasp1.txLoopjobBuf = "txLoopjobBuffer"; mcasp1.rxLoopjobBuf = "rxLoopjobBuffer"; mcasp1.rxActiveSlotMask = 0x3; mcasp1.rxDataMask = 0xFFFFFFFF; mcasp1.enableLoopback = false; mcasp1.clkSyncMode = "ASYNC"; mcasp1.enableMcaspRx = false; mcasp1.TxMode = "TDM"; mcasp1.NumTxSlots = 8; mcasp1.txAfifoEnable = false; mcasp1.txActiveSlotMask = 0xFF; mcasp1.txFsPolarity = 0; mcasp1.txBitClkPolarity = 0; mcasp1.txDataDelay = 0; mcasp1.TxSlotSize = 16; mcasp1.txDataMask = 0xFF000000; mcasp1.txLoopjobBufLength = 16; mcasp1.MCASP.$assignAllowConflicts = "MCASP0"; mcasp1.mcaspSer.create(2); mcasp1.mcaspSer[0].$name = "CONFIG_MCASP_SER0"; mcasp1.mcaspSer[0].MCASP.$assignAllowConflicts = "MCASP0"; mcasp1.mcaspSer[1].$name = "CONFIG_MCASP_SER1"; mcasp1.mcaspSer[1].serNum = 1; mcasp1.mcaspSer[1].MCASP.$assignAllowConflicts = "MCASP0"; scripting.suppress("Resource conflict,MCASP0 is also in use by @@@.+?@@@, @@@.+?@@@", mcasp1.MCASP, "$assign"); scripting.suppress("Resource conflict,MCASP0 is also in use by @@@.+?@@@, @@@.+?@@@", mcasp1.mcaspSer[0].MCASP, "$assign"); scripting.suppress("Resource conflict,MCASP0 is also in use by @@@.+?@@@, @@@.+?@@@", mcasp1.mcaspSer[1].MCASP, "$assign"); const udma = scripting.addModule("/drivers/udma/udma", {}, false); const udma1 = udma.addInstance({}, false); udma1.$name = "CONFIG_UDMA0"; mcasp1.bcDmaDriver = udma1; const udma2 = udma.addInstance({}, false); udma2.$name = "CONFIG_UDMA1"; mcasp1.pktDmaDriver = udma2; debug_log.enableUartLog = true; debug_log.uartLog.$name = "CONFIG_UART_CONSOLE"; debug_log.uartLog.UART.$assign = "USART0"; mmu_armv81.size = 0x80000000; mmu_armv81.$name = "SOC_MEM_REGION"; mmu_armv82.vAddr = 0x80000000; mmu_armv82.pAddr = 0x80000000; mmu_armv82.size = 0x80000000; mmu_armv82.attribute = "MAIR7"; mmu_armv82.$name = "DDR_REGION"; /** * Pinmux solution for unlocked pins/peripherals. This ensures that minor changes to the automatic solver in a future * version of the tool will not impact the pinmux you originally saw. These lines can be completely deleted in order to * re-solve from scratch. */ mcasp1.MCASP.AFSX.$suggestSolution = "MCASP0_AFSX"; mcasp1.MCASP.ACLKX.$suggestSolution = "MCASP0_ACLKX"; mcasp1.SYSTEM.$suggestSolution = "SYSTEM0"; mcasp1.mcaspSer[0].MCASP.AXR0.$suggestSolution = "MCASP0_AXR0"; mcasp1.mcaspSer[1].MCASP.AXR1.$suggestSolution = "MCASP0_AXR1"; debug_log.uartLog.UART.RXD.$suggestSolution = "UART0_RXD"; debug_log.uartLog.UART.TXD.$suggestSolution = "UART0_TXD";
BR、
Maciek