AnsweredAssumed Answered

How to send data via UART

Question asked by VanTechniek on Jul 15, 2015
Latest reply on Jul 28, 2015 by emoloney

I am having trouble using the drivers for UART communication. I followed the examples provided in the SDK, but I do not get results from any of them.

 

The API defines the adi_UART_BufTx function as what to use to transmit data over UART and both the examples use this as well. I can not use the UARTCharTest example though because of a missing definition for adi_GPIO_ConfigurePinMuxing which I can not find in any of the source files. The second example UARTTest appears to be sending data over UART however my oscilloscope doesn't read any signals on the TX line, which my only guess to as why is because the loopback is enabled and the program gets stuck in an infinite loop without it. So with the examples not working for me in this way I tried to do a simple transmission of my own using the following code:

 

int main()

{

  ADI_UART_RESULT_TYPE uartResult;

  ADI_UART_INIT_DATA initData;

  ADI_UART_GENERIC_SETTINGS_TYPE Settings;

  int16_t rxSize = 1;

  int16_t txSize = 2;

 

  //Initialize clock

  //SystemInit();

  //Initialize NVIC

  NVIC_SetPriorityGrouping(12);

 

  /* Change HCLK clock divider to 1 for a 16MHz clock */

  if (ADI_SYS_SUCCESS != SetSystemClockDivider(ADI_SYS_CLOCK_CORE, 1))

  {

      printf("SetSystemClockDivider() failed");

  }

  /* Change PCLK clock divider to 1 for a 16MHz clock */

  if (ADI_SYS_SUCCESS != SetSystemClockDivider (ADI_SYS_CLOCK_UART, 1))

  {

      printf("SetSystemClockDivider() failed");

  }

 

  initData.pRxBufferData = RxBuffer;

  initData.RxBufferSize = BUFFER_SIZE;

  initData.pTxBufferData = TxBuffer;

  initData.TxBufferSize = BUFFER_SIZE;

 

  //Initialize UART

  uartResult = adi_UART_Init(ADI_UART_DEVID_0, &hDevice, &initData);

 

  Settings.BaudRate = ADI_UART_BAUD_9600;

  Settings.bInterruptMode = true;

  Settings.Parity = ADI_UART_PARITY_NONE;

  Settings.WordLength = ADI_UART_WLS_8;

  Settings.bDmaMode = false;

 

  //Configure UART settigns

  uartResult = adi_UART_SetGenericSettings(hDevice, &Settings);

  if(ADI_UART_SUCCESS != uartResult)

  {

    printf("generic settigns failed");

  }

  uartResult = adi_UART_Enable(hDevice, true);

  if(ADI_UART_SUCCESS != uartResult)

  {

    printf("enable failed");

  }

 

  while(1){

  TxBuffer[0] = 0x09;

 

  uartResult = adi_UART_BufTx(hDevice, TxBuffer, &txSize);

  }  

  return 0;

}

 

Now this is not my own code, this was an attempt to pull pieces of the two examples into something really simple that works, but it doesn't work . No signals appear on the oscilloscope.

 

I am using an Eval-ADuCM350EBZ board for evaluation. Please help me with what I am doing wrong. Also if anyone has good resources for learning how to program the 350, that would be great as well. Thank you!

Outcomes