你好:
目前想做一個專案,需透過RS 232串口連結HC-05將訊息打印出來,手邊使用的是AWR1642 boost EVM
有參考UART傳輸初步先進行程式撰寫,但一直無法將信息打印出來,
以下是我編寫的程式,麻煩協助確認是否有哪裡設置錯誤,感謝。
void MmwDemo_mssInitTask(UArg arg0, UArg arg1)
{
int32_t errCode;
int32_t magic_size;
MMWave_InitCfg initCfg;
UART_Params uartParams;
Task_Params taskParams;
Semaphore_Params semParams;
UART_Handle uartHandle;
Mailbox_Config mboxCfg;
DMA_Params dmaParams;
DMA_Handle dmaHandle;
Error_Block eb;
/* Debug Message: */
System_printf("Debug: MMWDemoMSS Launched the Initialization Task\n");
MmwDemo_printHeapStats();
/*****************************************************************************
* Initialize the mmWave SDK components:
*****************************************************************************/
/* Pinmux setting */
/* Set Up GPIO to toggle up at start frame output and down at end frame output */
Pinmux_Set_OverrideCtrl(SOC_XWR16XX_PINP5_PADBG, PINMUX_OUTEN_RETAIN_HW_CTRL, PINMUX_INPEN_RETAIN_HW_CTRL);
Pinmux_Set_FuncSel(SOC_XWR16XX_PINP5_PADBG, SOC_XWR16XX_PINP5_PADBG_GPIO_32);
/* Setup the PINMUX to bring out the UART-1 */
Pinmux_Set_OverrideCtrl(SOC_XWR16XX_PINN5_PADBE, PINMUX_OUTEN_RETAIN_HW_CTRL, PINMUX_INPEN_RETAIN_HW_CTRL);
Pinmux_Set_FuncSel(SOC_XWR16XX_PINN5_PADBE, SOC_XWR16XX_PINN5_PADBE_RS232_TX);
Pinmux_Set_OverrideCtrl(SOC_XWR16XX_PINN4_PADBD, PINMUX_OUTEN_RETAIN_HW_CTRL, PINMUX_INPEN_RETAIN_HW_CTRL);
Pinmux_Set_FuncSel(SOC_XWR16XX_PINN4_PADBD, SOC_XWR16XX_PINN4_PADBD_RS232_RX);
/* Setup the PINMUX to bring out the UART-3 */
/*UART3串口發送接收*/
Pinmux_Set_OverrideCtrl(SOC_XWR16XX_PINF14_PADAJ, PINMUX_OUTEN_RETAIN_HW_CTRL, PINMUX_INPEN_RETAIN_HW_CTRL);
Pinmux_Set_FuncSel(SOC_XWR16XX_PINF14_PADAJ, SOC_XWR16XX_PINF14_PADAJ_MSS_UARTB_TX);
/* Setup the PINMUX to bring out the DSS UART */
Pinmux_Set_OverrideCtrl(SOC_XWR16XX_PINP8_PADBM, PINMUX_OUTEN_RETAIN_HW_CTRL, PINMUX_INPEN_RETAIN_HW_CTRL);
Pinmux_Set_FuncSel(SOC_XWR16XX_PINP8_PADBM, SOC_XWR16XX_PINP8_PADBM_DSS_UART_TX);
/* Initialize the GPIO */
GPIO_init();
//GPIO_setConfig(SOC_XWR16XX_PINP5_PADBG, GPIO_CFG_OUTPUT);
/* Initialize the UART */
UART_init();
/* Initialize the DMA */
DMA_init ();
/* Open the DMA Instance */
DMA_Params_init(&dmaParams);
dmaHandle = DMA_open(0, &dmaParams, &errCode);
if (dmaHandle == NULL)
{
printf ("Error: Unable to open the DMA Instance [Error code %d]\n", errCode);
return;
}
/*****************************************************************************
* Open & configure the drivers:
*****************************************************************************/
/* Setup the default UART Parameters(command) */
UART_Params_init(&uartParams);
uartParams.clockFrequency = gMmwMssMCB.cfg.sysClockFrequency;
uartParams.baudRate = gMmwMssMCB.cfg.commandBaudRate;
uartParams.isPinMuxDone = 1U;
/* Open the UART Instance */
gMmwMssMCB.commandUartHandle = UART_open(0, &uartParams);
if (gMmwMssMCB.commandUartHandle == NULL)
{
System_printf("Error: MMWDemoMSS Unable to open the Command UART Instance\n");
return;
}
/* Setup the default UART Parameters (logging)*/
UART_Params_init(&uartParams);
uartParams.writeDataMode = UART_DATA_BINARY;
uartParams.readDataMode = UART_DATA_BINARY;
uartParams.clockFrequency = gMmwMssMCB.cfg.sysClockFrequency;
uartParams.baudRate = gMmwMssMCB.cfg.loggingBaudRate;
uartParams.isPinMuxDone = 1U;
uartParams.dmaHandle = dmaHandle;
uartParams.txDMAChannel = 1U;
uartParams.rxDMAChannel = 2U;
/* Open the Logging UART Instance: */
gMmwMssMCB.loggingUartHandle = UART_open(1, &uartParams);
if (gMmwMssMCB.loggingUartHandle == NULL)
{
System_printf("Error: MMWDemoMSS Unable to open the Logging UART Instance\n");
return;
}
while (1)
{
int32_t syncStatus;
magic_size = 100;
UART_writePolling (uartHandle, (uint8_t*) magic_size, sizeof(magic_size));
Task_sleep(10);
}
return;
}
/*****************************************************************************
* 主程式
*****************************************************************************/
int main (void)
{
Task_Params taskParams;
int32_t errCode;
SOC_Cfg socCfg;
/* Initialize the ESM: */
ESM_init(0U);
/* Initialize and populate the demo MCB */
memset ((void*)&gMmwMssMCB, 0, sizeof(MmwDemo_MCB));
/* Initialize the SOC confiugration: */
memset ((void *)&socCfg, 0, sizeof(SOC_Cfg));
/* Populate the SOC configuration: */
socCfg.clockCfg = SOC_SysClock_INIT;
/* Initialize the SOC Module: This is done as soon as the application is started
* to ensure that the MPU is correctly configured. */
gMmwMssMCB.socHandle = SOC_init (&socCfg, &errCode);
if (gMmwMssMCB.socHandle == NULL)
{
System_printf ("Error: SOC Module Initialization failed [Error code %d]\n", errCode);
return -1;
}
/* Initialize the DEMO configuration: */
gMmwMssMCB.cfg.sysClockFrequency = MSS_SYS_VCLK;
gMmwMssMCB.cfg.loggingBaudRate = 9600;
gMmwMssMCB.cfg.commandBaudRate = 115200;
gMmwMssMCB.pcEnable = 1;
Cycleprofiler_init();
/* Initialize the Task Parameters. */
Task_Params_init(&taskParams);
taskParams.priority = 3;
Task_create(MmwDemo_mssInitTask, &taskParams, NULL);
/* Start BIOS */
BIOS_start();
return 0;
}