Post Go back to editing

Transmit data to serial emulator with UART ADUCM3029

Hello.

I have code snippet below that uses ADC to sample the input signal at channel 0 and write the acquired samples to a serial emulator(Realterm). It uses UART device driver for autobaud rate detection that is it waits to transmit the samples to serial emulator when I enter a key character(carriage return). I just want that my samples would be transmitted to serial emulator without waiting to enter any key character, something it would transmit the samples automatically. I've been reading documentations for a while now but nothing seems to work with my code. I'm newbie when it comes to UART and appreciate any assistance you can provide. Thanks

do {

	  adi_pwr_Init();
	  adi_pwr_SetClockDivider(ADI_CLOCK_HCLK, 1u);
      adi_pwr_SetClockDivider(ADI_CLOCK_PCLK, 1u);
	  /* Open the UART device. */
	  if(ADI_UART_SUCCESS != adi_uart_Open(UART_DEVICE_NUM, ADI_UART_DIR_BIDIRECTION, UartDeviceMem, ADI_UART_MEMORY_SIZE, &h1Device))
	  {
		  DEBUG_MESSAGE("Failed to open the UART device.");
		  bFailure = true;
		  break;
	  }

	  /* Register a callback to test callback mode. */
	  if(adi_uart_RegisterCallback(h1Device, UARTCallback, h1Device) != ADI_UART_SUCCESS)
	  {
		  DEBUG_MESSAGE("Call back registration failed");
		  bFailure = true;
		  break;
	  }

	  /* Enable autobaud using the callback. */
	  if(adi_uart_EnableAutobaud(h1Device, true, bAutobaudCallback) != ADI_UART_SUCCESS)
	  {
		  DEBUG_MESSAGE("Failed to enable autobaud");
		  bFailure = true;
		  break;
	  }


	#ifndef __CC_ARM
		  DEBUG_MESSAGE("Press enter to start!\n");
	#endif


	   /* Wait until the baudrate has been detected. */
	  do
	  {
		  adi_uart_GetBaudRate(h1Device, &nBaudrate, &nAutobaudError);
		  nAutobaudCounter++;

	  }while((nBaudrate == 0) && (nAutobaudCounter < UART_AUTOBAUD_TIMEOUT));


	  /* Disable autobaud. */
	  if(adi_uart_EnableAutobaud(h1Device, false, false) != ADI_UART_SUCCESS)
	  {
		  DEBUG_MESSAGE("Failed to disable autobaud");
		  bFailure = true;
		  break;
	  }

	  /* Sample the ADC Channel 0 */
	  ADC_SampleData();
	  
	  double Value[ADC_NUM_SAMPLES];
	  for (int x = 0; x < ADC_NUM_SAMPLES; x++) {
		  Value[x]= ADC_DataBuffer[x];
		  sprintf(InfoBuffer," %0.3f ", ((Value[x]	)/4096) * 2.5 );
		  if (adi_uart_Write(h1Device,&InfoBuffer[0],strlen(InfoBuffer), 0, &nHardwareError) != ADI_UART_SUCCESS)
		  {
			  DEBUG_MESSAGE("Failed to write  the specified data to UART device");
			  bFailure = true;
			  break;
		  }
	  }

	  /* Wait until Tx buffer is completly empty before closing the device */
	  while(bTxComplete == false)
	  {
		  if(adi_uart_IsTxComplete(h1Device, &bTxComplete) != ADI_UART_SUCCESS)
		  {
			  DEBUG_MESSAGE("Failed to query Tx Complete");
			  bFailure = true;
			  break;
		  }
	  }

	  /* Close the device. */
	  if(adi_uart_Close(h1Device)!= ADI_UART_SUCCESS)
	  {
		  DEBUG_MESSAGE("Failed to close the device");
		  bFailure = true;
	  }
	  
  }while(0);