Adding a "frame start" byte at the beginning of a DMA w/ ADC transfer | Cypress Semiconductor
Adding a "frame start" byte at the beginning of a DMA w/ ADC transfer
Using PSOC5LP, I am attempting to send a stream of ADC data to the USB over USBUART w/ DMA. Currently, I have the following:
USBUART_LoadInEP(USBUART_cdc_data_in_ep, ADC_sample, 62); //DMA Endpoint for transmitting ADC Data from PSOC-->PC
USBUART_ReadOutEP(USBUART_cdc_data_out_ep, rdBuffer, RDBUFFERSIZE); //DMA endpoint for reading USBUART data from PC-->PSOC
The user sends a command from the PC to the PSOC5LP USBUART via the
ReadOutEP function to start sampling. The PC then automatically streams ADC data to the PC via the
LoadInEp function. Sampling will continue indefinitely.
I am sampling, as an example, a linear voltage sweep with digital values from 0->100. Every time I trigger the command from the PC, we will sample the linear sweep. We can call each sweep a "frame".
Right now, I am transferring data to the PC, but I dont really know when the "frame" started. This results in misaligned data. So, I believe I need to pack the ADC data into a simple communication protocol that labels "start frame" and "end frame" with a byte string.
The problem is, I do not really know the correct way to add data to the ADC DMA since it all happens automatically.
I have 2 ideas right now, but I am not sure if this is the correct way to go about it.
- Run this function whenever I receive the start command from the PC:
USBUART_PutString(StartFrameBytes). Then, start DMA.
- Create a new endpoint that links to the string StartFrameBytes and then swap back to the original ADC DMA endpoint once the StartFrameBytes have been successfully sent.
Any help would be greatly appreciated.