您的位置: OpenADSP社区论坛 -> Blackfin专区 -> 新手上路 -> BF609开发板串口程序没有打印数据
本帖共有1320个阅读者
发表帖子 发表投票 回复主题
BF609开发板串口程序没有打印数据
kladsp(论坛新手)
kladsp
头衔:社区公民
帮派:无帮无派
帖数:66
金钱:634
积分:88
注册时间:2015/1/26
楼主信息 | 留言 | Email | 主页 | 编辑 | 管理 | 离线
BF609开发板串口程序没有打印数据
BF609开发板自带的一个串口DOMO是采用寄存器操作的方式可以打印数据出来。
就像STM32开发一样,有寄存器跟库函数两种方式,库函数编程的方式更简单可读性更好。
于是我仿照官方DEMO板的串口程序,实现串口接收数据然后发送接收到的数据的ECHO功能,在BF609开发板上运行,但是没有打印出结果。帮忙看看为什么?

原来怀疑 adi_uart_Open 函数的第一个参数不对,于是从0修改为1还是不行。
代码如下:
int main(void)
{
/* UART return code */
ADI_UART_RESULT    eResult;
/* SEC return code */
ADI_SEC_RESULT     eSECResult;
/* Tx size */
uint32_t           nTxSize = 1;
/* Flag which indicates whether to stop the program */
    _Bool bStopFlag = false;
/**
* Initialize managed drivers and/or services that have been added to
* the project.
* @return zero on success
*/
adi_initComponents();
/**
* The default startup code does not include any functionality to allow
* core 0 to enable core 1. A convenient way to enable core 1 is to use the
* 'adi_core_1_enable' function.
*/
// adi_core_1_enable();

/* Begin adding your custom code here */


    printf("UART Char echo blocking mode example \n");

//    /* Set the Software controlled switches to default values */
//    ConfigSoftSwitches();
//
//    /* Initialize Power service */
    if(adi_pwr_Init(CLKIN, CORE_MAX, SYSCLK_MAX, VCO_MIN) != ADI_PWR_SUCCESS)
    {
        REPORT_ERROR("Failed to initialize power service \n");
        return FAILED;
    }
//    /*
//     * Initialize UART
//     */
//    /* Open UART driver */
    if((eResult = adi_uart_Open(UART_DEVICE_NUM,
                                 ADI_UART_DIR_BIDIRECTION,
                                 gUARTMemory,
                                 ADI_UART_BIDIR_DMA_MEMORY_SIZE,
                                 &ghUART)) != ADI_UART_SUCCESS)
    {
     REPORT_ERROR("Could not open UART Device 0x%08X \n", eResult);
     return FAILED;
    }
//    /* Set the UART Mode */
    if((eResult = adi_uart_SetMode(ghUART,
                                    ADI_UART_MODE_UART
                                   )) != ADI_UART_SUCCESS)
    {
     REPORT_ERROR("Could not set the Mode 0x%08X \n", eResult);
     return FAILED;
    }
//
//
//    /* Set UART Baud Rate */
    if((eResult = adi_uart_SetBaudRate(ghUART,
     BAUD_RATE
                                        )) != ADI_UART_SUCCESS)
    {
     REPORT_ERROR("Could not set the Baud Rate 0x%08X \n", eResult);
     return FAILED;
    }
//
//    /* Set number of stop bits */
    if((eResult = adi_uart_SetNumStopBits(ghUART,
                                            ADI_UART_ONE_STOPBIT
                                         )) != ADI_UART_SUCCESS)
    {
     REPORT_ERROR("Could not set the stop bits 0x%08X \n", eResult);
     return FAILED;
    }
//
//    /* Set number of stop bits */
    if((eResult = adi_uart_SetWordLen(ghUART,
                                          ADI_UART_WORDLEN_8BITS
                                         )) != ADI_UART_SUCCESS)
    {
     REPORT_ERROR("Could not set word length 0x%08X \n", eResult);
     return FAILED;
    }
//
    printf("Setup Hyperterminal as described in Readme file. \n");
    printf("Press any key on the key board and notice the character  being echoed to Hyperterminal. \n");
    printf("\n Press return key to stop the program.\n");
//
    char szs[16] = "start..";
    memcpy(RxBuffer,szs,strlen(szs));
    /* Write back the character */
    if((eResult = adi_uart_Write(ghUART,
            &RxBuffer[0],
            strlen(szs)
    )) != ADI_UART_SUCCESS)
    {
        REPORT_ERROR("Could not do a write 0x%08X \n", eResult);
        return FAILED;
    }
//    /* UART processing loop */
    while(bStopFlag == false)
    {
//        /* Read a character */
        if((eResult = adi_uart_Read(ghUART,
                &RxBuffer[0],
                1
        )) != ADI_UART_SUCCESS)
        {
            REPORT_ERROR("Could not do a read 0x%08X \n", eResult);
            return FAILED;
        }

        /* If return character is pressed, write back \n character along with \r */
        if(RxBuffer[0] == '\r')
        {
            RxBuffer[1] = '\n';

            /* Transmit two characters in this case */
            nTxSize     = 2u;

            /* Stop the program upon receiving carriage return */
            bStopFlag = true;
        }

        /* Write back the character */
        if((eResult = adi_uart_Write(ghUART,
                &RxBuffer[0],
                nTxSize
        )) != ADI_UART_SUCCESS)
        {
            REPORT_ERROR("Could not do a write 0x%08X \n", eResult);
            return FAILED;
        }
     }

    /* Close the UART */
    if((eResult = adi_uart_Close(ghUART)) != ADI_UART_SUCCESS)
    {
        REPORT_ERROR("Could not close UART driver 0x%08X \n", eResult);
        return FAILED;
    }

//    return PASSED;

return 0;
}


这家伙很懒,什么也没有留下!
等级:论坛新手 参考IP地址:*.*.*.*
2015/1/30 16:25:35
kladsp(论坛新手)
kladsp
头衔:社区公民
帮派:无帮无派
帖数:66
金钱:634
积分:88
注册时间:2015/1/26
1信息 | 留言 | Email | 主页 | 编辑 | 管理 | 离线
发现把  \ADSP-BF609_Evaluation_Board-Rel1.0.3\BF609_EZ-Board\Blackfin\Examples\drivers\uart\BF609_char_echo
里面的工程拿到BF609板子上运行都可以,但是我的代码跟那个一样,怎么不行?

这家伙很懒,什么也没有留下!
等级:论坛新手 参考IP地址:*.*.*.*
2015/1/30 16:42:21
kladsp(论坛新手)
kladsp
头衔:社区公民
帮派:无帮无派
帖数:66
金钱:634
积分:88
注册时间:2015/1/26
2信息 | 留言 | Email | 主页 | 编辑 | 管理 | 离线
原因找到了,没有配置串口复用,在system.svc图形化界面里面配置一下就好了,不写代码不看芯片手册鼠标点点就把事情给搞定了,这种感觉真好。。

这家伙很懒,什么也没有留下!
等级:论坛新手 参考IP地址:*.*.*.*
2015/1/30 16:51:17
Powered by OpenADSP Copyright © 2010 www.Openadsp.com. All rights reserved.154189 Call, 1 Queries, Processed in 0.015625 second(s),