ADC Data to PC via USBUART

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
kpolacha
Level 1
Level 1
5 sign-ins First reply posted First question asked

Hello,

I am using PSoC-5 board CY8CKIT-059. I am sending ADC data to PC via USBUART. I use bridge control panel to view the ADC reading. I see that with the code below, I get only get readings at 6Samples/Second. I am looking for sending ADC data to PC at 1MSPS. 

Bridge Control Panel Commands to Read Data:

RX8 [H = 0D 0A] +
@1rc @0rc +
[T = 00 FF]

Code Snippet: (Please also see the project attached):

#include <project.h>
int main()
{
CyGlobalIntEnable; /* Enable all interrupts by the processor. */
PGA_1_Start();
ADC_SAR_1_Start();
USBUART_1_Start(0, USBUART_1_5V_OPERATION);
uint16 adcReading = 0;

while(1)
{

ADC_SAR_1_StartConvert();
ADC_SAR_1_IsEndConversion(ADC_SAR_1_WAIT_FOR_RESULT);
adcReading = ADC_SAR_1_GetResult16();
//USBUART_1_PutString("20");
//USBUART_1_PutCRLF();

USBUART_1_PutChar(0x0D);
USBUART_1_PutChar(0x0A);
USBUART_1_PutChar((adcReading >> 😎 & 0x00FF);
USBUART_1_PutChar(adcReading & 0x00FF);
USBUART_1_PutChar(0x00);
USBUART_1_PutChar(0xFF);

}

}

0 Likes
1 Solution
BiBi_1928986
Level 7
Level 7
First comment on blog 500 replies posted 250 replies posted

Hello.

I can't answer why you observe 6sps.
But, you may need to lower your expectations.

KIT-059 USB is only Full Speed at 12meg-bit/second.  By the time ADC packet is sent (along with USB overhead bytes), <150k sps is possible.

You might also be interested in an excellent project created by Odissey1:
https://community.infineon.com/t5/Code-Examples/SerialPlot-interface-to-real-time-data-charts/td-p/2...

If you can get that project working, then go back and re-work your project to use USBUART.  Make sure the bottleneck isn't the s/w running on PC.

You might also want to check out the USBUART example project.

Good luck with your project.

View solution in original post

0 Likes
4 Replies
BiBi_1928986
Level 7
Level 7
First comment on blog 500 replies posted 250 replies posted

Hello.

I can't answer why you observe 6sps.
But, you may need to lower your expectations.

KIT-059 USB is only Full Speed at 12meg-bit/second.  By the time ADC packet is sent (along with USB overhead bytes), <150k sps is possible.

You might also be interested in an excellent project created by Odissey1:
https://community.infineon.com/t5/Code-Examples/SerialPlot-interface-to-real-time-data-charts/td-p/2...

If you can get that project working, then go back and re-work your project to use USBUART.  Make sure the bottleneck isn't the s/w running on PC.

You might also want to check out the USBUART example project.

Good luck with your project.

0 Likes

Is there any ready to use example project for CY8CKIT-059 which streams data from the kit to PC ? It will be helpful even if the datarate is of lower side e.g., 100Kbps. I do not see any ready to use codes for this.

0 Likes

Hello.

The simplest code example is called USBFS_UART.  You'll find it near the bottom of the list when you choose Find Code Example from Creator in Start Page window.  This basically echos any data sent from PC back to it.  You could insert your ADC samples here.

There's also a USBFS_AUDIO_PSoC3_5LP example that will stream audio to the 5LP DAC.  It might give you clues how to stream the ADC data in the opposite direction.

You should also look at the links provided by Odissey1.  Tons of info there.

0 Likes
odissey1
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted

kpolacha,

Getting continuous 1Ms/sec from PSoC5 to PC is rather challenging, and USBUART will not handle that. There are many discussions on this forum about USBFS bulk transfer mode, please check them.

USB Isochronous Transfer ,

 

USB UART data transfer speed Cortex-M3

 

getting 1 MSPS samples off of the PSoC

 

Sample projects for fast DMA USB streaming

 

Question of USB and Streaming Data

 

If you only need only occasional 1MSPS bursts ("oscilloscope mode"), there are another demo projects:

Basic oscilloscope demo using ADC_SAR and KIT-059

0 Likes