This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

TCP fast transmission

I use the STM32F4 discovery, middleware 7.0.0 and CMSIS 4.5.0. I wonna sample data with a sampling frequency of 192kHz (24bit) using an external ADC which sends the data via I2S to my uC. By using a TCP socket the data shall be sent to Matlab. To simulate this I use the DAC+timer+DMA+lookup to generate a 2kHz sinus which is than sampled by the internal ADC of the uC with (at first) a smaple rate of approx 20kHz. The data is than transfered by DMA to ADCbuffer (500*unint32). This buffer looks like: 0x00000xxx.

I use the callbacks

void HAL_ADC_ConvHalfCpltCallback(ADC_HandleTypeDef* hadc)
{ osSignalSet(tid_Thread_TCP, 2U);
} void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc)
{ osSignalSet(tid_Thread_TCP, 3U);
}

To send the first 1000 bytes of ADCbuffer and than the second 1000 bytes.This is doen by the TCP_thread

#define TCP_LENGTH 1000 uint8_t *sendbuf1; uint8_t *sendbuf2;

int Init_Thread_TCP (void) {

tid_Thread_TCP = osThreadCreate(osThread(Thread_TCP), NULL); if (!tid_Thread_TCP) return(-1);

return(0);
}

void Thread_TCP (void const *argument) {

while (1) {

osSignalWait(2U, osWaitForever); // Wait for signal while (!netTCP_SendReady (tcp_sock)) {}

sendbuf1 = netTCP_GetBuffer (TCP_LENGTH); memcpy (sendbuf1, &ADCBuffer[0], TCP_LENGTH); netTCP_Send(tcp_sock,sendbuf1,TCP_LENGTH*sizeof(uint8_t));

osSignalWait(3U, osWaitForever); // Wait for signal

while (!netTCP_SendReady (tcp_sock)) {} sendbuf2 = netTCP_GetBuffer (TCP_LENGTH); memcpy (sendbuf2, &ADCBuffer[TCP_LENGTH/4], TCP_LENGTH); netTCP_Send (tcp_sock, sendbuf2, TCP_LENGTH*sizeof(uint8_t)); }

In Matlab I dont use the zeros and obtain a sin wave with irregular phasejumps (attachement)
I m sure that the reason for that is needs to much time to be ready again which results in an overflow of the buffer.

My questions:
Is it possible that the TCP connection is to slow? I just sample with 20kHz. Later I want to be more than 10 times faster. Is it possible to get that fast? Do I need some kind of extra buffer? Is it possible that this buffer wont overflow

Please help me. I ve no clue what to do!

Thanks a lot in advance

Andreas