How to send int values efficiently through CDC USB
Hello ST community, I am trying to send values from ADC through USB using "CDC_Transmit_FS()"
The code works well but my goal is to transmit ADC values faster!
(I have no option to use High Speed USB transmission mode.)
The ADC values in the adcbuff are 4 digits integer and "\n" is appended to distinguish each value at the receiving side.
e.g) txbuff[] = {'1', '1', '1', '1','\n','2', '2', '2', '2','\n' ... '9', '9', '9', '9','\n'};
Is there any better or direct method to send ADC values through USB instead of converting int values to string?
Thanks in advance!
uint32_t adcbuff[sample];
char txbuff[sample*5];
char tempbuff[10];
while(1)
{
HAL_ADC_Start_DMA(&hadc2,(uint32_t*)adcbuff, sample);
for(i = 0; i < sample; i++)
{
sprintf (tempbuff, "%d\n", ((adcbuff[i] * 5000) / 0xFFFF)-2000);
strcat( txbuff,tempbuff);
}
CDC_Transmit_FS( (uint8_t*)txbuff, strlen(txbuff));
strcpy(txtbuff,"");
}
