Quantcast
Channel: Infineon Forums
Viewing all articles
Browse latest Browse all 9892

XMC4500 sending values from ADC to USB

$
0
0
Hello everyone,
I am trying to acquire a voltage with my XMC4500 Relax Kit and then transmit the value through USB.

I am using the ADC_MEASUREMENT app activated every 1s by a TIMER app and it works fine. Then I have problems with the USB transmission.
I am using the USBD_VCOM app and I understand that the problem is the type of the value to be sent.
For example, if I try to send the character 'a' by writing
Code:

TxBuffer[0] = 'a'
I properly see the character 'a' on my Putty terminal.
On the contrary I did non understand how to send numbers up to 4096. Although I think that only few lines of code are missing, I tried different already posted solution with no success.
Can you help me?
Emanuele

Code:


#include <DAVE.h>

 uint32_t event_count;
 uint32_t result_Isignal;
 uint32_t i = 0;
 bool Isignalstatus = 0;
 int8_t TxBuffer[64];


 int main(void)
 {
  DAVE_STATUS_t status;

  status = DAVE_Init();
  if (status == DAVE_STATUS_FAILURE)
  {
    XMC_DEBUG(("DAVE Apps initialization failed with status %d\n", status));
    while (1U)
    {
    }
  }

  if(USBD_VCOM_Connect() != USBD_VCOM_STATUS_SUCCESS)
  {
      return -1;
  }

  while(!USBD_VCOM_IsEnumDone());

  ADC_MEASUREMENT_StartConversion(&ADC_MEASUREMENT_0);

  while (1U)
  {
          if (Isignalstatus==1)
          {
                  TxBuffer[0] = result_Isignal;
                  USBD_VCOM_SendByte(TxBuffer[0]);
                  CDC_Device_USBTask(&USBD_VCOM_cdc_interface);
                  Isignalstatus = 0;
          }
  }

  return 1;
 }


 void Time_Interval_Event(void)
 {
        /* Acknowledge Period Match interrupt generated on TIMER_CCU_1 */
        TIMER_ClearEvent(&TIMER_0);
        ADC_MEASUREMENT_StartConversion(&ADC_MEASUREMENT_0);
 }

 /*End of measurements interrupt*/
 void Adc_Measurement_Handler(void)
 {
        /*Read out conversion results*/
        result_Isignal = ADC_MEASUREMENT_GetResult(&ADC_MEASUREMENT_Isignal_handle);
        Isignalstatus = 1;

 }


Viewing all articles
Browse latest Browse all 9892

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>