This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS570LS3137: ADC conversion, missing samples every 256 samples

Part Number: TMS570LS3137
Other Parts Discussed in Thread: HALCOGEN

I am using TMS570 Hercules Dev Kit.

I am fighting with ADC (one channel), data acquisition frequency is determined by RT (e.g. 1-50kHz) and FATfs library for data acquisition (SD card slot). Everything looked fine but than I started tests with sinewaves from generator.... and .... wait where are my samples? ;/

The problem is, every 256 samples (it is constant value and it is independent from acquisition frequency) some samples are missing. I do not have any other interrupts. I checked time of code inside my interrupt and the max value is 7,0us. (rtiGetCurrentTick = 70, with closk 10M).

Here is my example data:

and my code:

   if (notification == rtiNOTIFICATION_COMPARE0)
    {
		/* ADC conversion */
		adcStartConversion(adcREG1, adcGROUP1);
		while(!adcIsConversionComplete(adcREG1, adcGROUP1));

		adcGetData(adcREG1, adcGROUP1, adc_data_ptr); //Store conversion into ADC pointer
		value = (uint16_t)((*adc_data_ptr).value);

		// Convert uint16_t data into 2x BYTE
		dataBufferPtr[0] = (value >> 8) & 0xFF;
		dataBufferPtr[1] = value & 0xFF;

		/* Write file */
		f_write(&fsrc, &dataBuffer, bufferSize, &bw);
		bufferFIlledCount = bufferFIlledCount + 1;
		dataBufferPtr = &dataBuffer;


		/* Check if number of conversion reached number required */
		if (bufferFIlledCount == buffersToBeSaved)
		{
			/* Close the file */
			res = f_close(&fsrc);
		}         
    }

Where could be a problem? If it can help I can also add screenshots from my HalCoGen project.

  • I ve just found a solution.
    The problem was that I use f_write() (from FATfs library) inside the same interrupt I use for get data from ADC. I should bring f_write outside this interrupt, so I will use some kind of ring buffer in this case.
    second summary: rtiGetCurrentTick does not always show the actual execution time of the code. I was convinced that my code time inside interrupt is below 7us, but after entering the f_write(), where write to the disk occurs, the time measurement was not correct (other interrupts? spi?).
  • Thanks for update!

    Best regards,
    MIro