This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

SK-TDA4VM: 在mcu3_0中使用UART4发送数据,出现只发送一次数据问题,后面就不发送。

Part Number: SK-TDA4VM


1.帮忙看一下这个代码,用UART4发送数据时,为什么数据只发送一次,就发送不了了,

eg:如下代码执行,只收得到UART HELLO WORD,收不到字符串sssaannnh

char testIdPrompt[24] = "UART HELLO WORD\r\n";
char crPrompt[16] = "sssaannnh\r\n";
UART_write(uart, (void *)(uintptr_t)testIdPrompt, sizeof(testIdPrompt));
//Osal_delay(100);
UART_write(uart, (void *)(uintptr_t)crPrompt, sizeof(crPrompt));

#if 1
/* Define the UART test interface */
typedef struct UART_Tests_s
{
    bool     (*testFunc)(bool);
    bool     dmaMode;
    int16_t  testId;
    char     testDesc[80];

} UART_Tests;

UART_PAR uartParity = UART_PAR_NONE;
uint32_t verifyLoopback = FALSE;

UART_Tests Uart_tests[] =
{
    {NULL, false, 1, "\r\n UART non-DMA read write test in block mode"},
    {NULL, }
};

static void UART_initConfig_test(bool dmaMode)
{
    UART_HwAttrs uart_cfg;
    /* Get the default UART init configurations */
    UART_socGetInitCfg(4, &uart_cfg);

    uart_cfg.edmaHandle = NULL;
    uart_cfg.dmaMode    = FALSE;
    uart_cfg.loopback   = verifyLoopback;

    /* Set the DMA enabled UART init configurations */
    UART_socSetInitCfg(4, &uart_cfg);
}



int UART_mcutest_print_test_desc22(UART_Tests *test)
{
    linData_t      linMasterData;
    UART_Handle uart = NULL;
    UART_Params uartParams;
    char        testIdPrompt[24] = "UART HELLO WORD\r\n";
	char        crPrompt[16] = "sssaannnh\r\n";
    char        testId[16] = {0, };
    int8_t         status        = 0;
    uint8_t     protectId   = 0;

    UART_init();
    appLogPrintf("APP: Init  mcu2_1 print_test000 H0  EZHU... !!!\n");
  
    /* UART SoC init configuration */
    UART_initConfig_test(false);//关闭DMA
    appLogPrintf("APP: Init  mcu2_1 print_test111 HEZHU... !!!\n");
  
    /* Initialize the default configuration params. */
    UART_Params_init(&uartParams);   
    uartParams.parityType = uartParity;

    appLogPrintf("APP: Init  mcu2_1 print_test222 HEZHU... !!!\n");
    uart = UART_open(4, &uartParams);
    if(uart == NULL)
    {
        appLogPrintf("\nFailed to get the UART handle\n");
        return -1;
    }
    appLogPrintf("APP: Init  mcu2_1 print_test333 HEZHU... !!!\n");
    /* Print unit test ID */
    sprintf(testId, "%d", test->testId);
    
    UART_write(uart, (void *)(uintptr_t)testIdPrompt, sizeof(testIdPrompt));

    //Osal_delay(100);
    UART_write(uart, (void *)(uintptr_t)crPrompt, sizeof(crPrompt));

    UART_write(uart, (void *)(uintptr_t)testId, sizeof(testId));
    //UART_write(uart, (void *)(uintptr_t)crPrompt, sizeof(crPrompt));


    UART_close(uart);

    return 0;
}
#endif 

static void appMain(void* arg0, void* arg1)
{

    appUtilsTaskInit();
    appInit();
    appRun();

    appLogPrintf("APP: Init  mcu3_0 test_sta HEZHU... !!!\n");

    UART_mcutest_print_test_desc22(&Uart_tests[0]);

    appLogPrintf("APP: Init  mcu3_0 test_end HEZHU... !!!\n");
    
    
    #if 1
    while(1)
    {
        appLogWaitMsecs(100u);
    }
    #else
    appDeInit();
    #endif
}

void StartupEmulatorWaitFxn (void)
{
    volatile uint32_t enableDebug = 0;
    do
    {
    }while (enableDebug);
}

static uint8_t gTskStackMain[8*1024]
__attribute__ ((section(".bss:taskStackSection")))
__attribute__ ((aligned(8192)))
    ;

int main(void)
{
    TaskP_Params tskParams;
    TaskP_Handle task;
    Board_initCfg boardCfg;
 
    /* This is for debug purpose - see the description of function header */
    StartupEmulatorWaitFxn();

    boardCfg = BOARD_INIT_PINMUX_CONFIG |
        BOARD_INIT_MODULE_CLOCK;

    if (BOARD_SOK !=  Board_init(boardCfg))
    {
        appLogPrintf("Board_init failed!... \n");
        return (false);
    }

    OS_init();

    TaskP_Params_init(&tskParams);
    tskParams.priority = 8u;
    tskParams.stack = gTskStackMain;
    tskParams.stacksize = sizeof (gTskStackMain);
    task = TaskP_create(appMain, &tskParams);
    if(NULL == task)
    {
        OS_stop();
    }
    OS_start();

    return 0;
}

uint32_t appGetDdrSharedHeapSize()
{
    return DDR_SHARED_MEM_SIZE;

}