May 04, 2021
05:26 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
May 04, 2021
05:26 AM
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
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
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
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
#include
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;
}
Solved! Go to Solution.
- Tags:
- IFX
1 Solution
May 06, 2021
06:14 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
May 06, 2021
06:14 AM
Hi Emanuele,
I have modified your code. Kindly check whether this works.
Modified Code:
Best Regards,
Vasanth
I have modified your code. Kindly check whether this works.
Modified Code:
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)
{
sprintf(TxBuffer,"\n\rResult=%d",result_Isignal);
for(int i=0;TxBuffer != '\0';i++)
{
USBD_VCOM_SendByte(TxBuffer);
CDC_Device_USBTask(&USBD_VCOM_0);
}
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_Channel_A_handle);
Isignalstatus = 1;
}
Best Regards,
Vasanth
2 Replies
May 06, 2021
06:14 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
May 06, 2021
06:14 AM
Hi Emanuele,
I have modified your code. Kindly check whether this works.
Modified Code:
Best Regards,
Vasanth
I have modified your code. Kindly check whether this works.
Modified Code:
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)
{
sprintf(TxBuffer,"\n\rResult=%d",result_Isignal);
for(int i=0;TxBuffer != '\0';i++)
{
USBD_VCOM_SendByte(TxBuffer);
CDC_Device_USBTask(&USBD_VCOM_0);
}
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_Channel_A_handle);
Isignalstatus = 1;
}
Best Regards,
Vasanth
May 06, 2021
06:47 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
May 06, 2021
06:47 AM
Hi Vasanth,
yes, it works, thank you for your help!
yes, it works, thank you for your help!