AnsweredAssumed Answered

How to write UART ON BF609

Question asked by Alice on Feb 24, 2014
Latest reply on Sep 12, 2017 by WillMoore

Hi,everyone

        Using CrossCore Embedded Studio write a serial program,Using CrossCore Embedded Studio packaging good function, but debugging failure when set the baud rate,在adi_uart_bf60x.h()文件中定义了read、open、write等函数

如:

1.PNG

2.PNG

  3.PNG  

Excuse me: how do I use the above packaging good function? Use what function? What baud rate setting failure?

串口程序如下:

void SetUart(void)

{

          ADI_UART_RESULT Result;

 

 

          *pREG_PORTB_FER |= 0x0000e000;

          *pREG_PORTB_MUX = 0x0;

 

 

          *pREG_PORTC_FER |= 0x000002ff;

          *pREG_PORTC_MUX = 0x0;

 

 

          *pREG_PORTD_MUX = 0x0;

          *pREG_PORTD_FER |= 0x00000040;

 

 

          /* 打开UART */

          Result = adi_uart_Open(UARTDevice, ADI_UART_DIR_BIDIRECTION,

                              uart_deviceMemory, ADI_UART_BIDIR_DMA_MEMORY_SIZE, &PDevice);

          if(Result == ADI_UART_SUCCESS)

          {

                    printf("uart open succes\n");

          }

          else {

                    printf("uart open fail\n");

          }

          /* 设置模式   */

          Result = adi_uart_SetMode(PDevice, ADI_UART_MODE_UART);

          if(Result == ADI_UART_SUCCESS)

                    {

                              printf("uart setmode succes\n");

                    }

                    else {

                              printf("uart setmode fail\n");

                    }

          /* 设置 BAUD*/

          Result = adi_uart_SetBaudRate(PDevice, UART_BaudRate);

          if(Result == ADI_UART_SUCCESS)

                    {

                              printf("uart setbaudrate succes\n");

                    }

                    else {

                              printf("uart setbaudrate fail\n");

                    }

          /* 数据位  */

          Result = adi_uart_SetWordLen(PDevice, ADI_UART_WORDLEN_8BITS);

          if(Result == ADI_UART_SUCCESS)

                    {

                              printf("uart setwordlen succes\n");

                    }

                    else {

                              printf("uart setwordlen fail\n");

                    }

          /* 校验位  */

          Result = adi_uart_SetParity(PDevice, ADI_UART_NO_PARITY);

          if(Result == ADI_UART_SUCCESS)

                    {

                              printf("uart setparity succes\n");

                    }

                    else {

                              printf("uart setparity fail\n");

                    }

          /* 停止位   */

          Result = adi_uart_SetNumStopBits(PDevice, ADI_UART_ONE_STOPBIT);

          if(Result == ADI_UART_SUCCESS)

                    {

                              printf("uart setnumstopbits succes\n");

                    }

                    else {

                              printf("uart setnumstopbits fail\n");

                    }

          /* 流控   */

          Result = adi_uart_Write(PDevice, uart_buffer, sizeof(uart_buffer));

          if(Result ==  ADI_UART_SUCCESS)

          {

                    printf("uart write succes\n");

          }

          else {

                    printf("uart write fail\n");

          }

 

 

          Result = adi_uart_Close(PDevice);

}

result:

1.PNG


Outcomes