ADC Crashes after 20 Open and Close Cycles

, , , ,

Use the pre-version of the ‘TdxAllLibraries’ library and probably found a bug: when I open and close the ADC several times (with a lot of time in between) the whole WinCE system crashes after exactly 20 cycles.

Regardless multiple open and close cycles is in most applications not the case, I report this bug.

Following an example (see the long sleeps):

HANDLE adcHandle1 = TegAdc_Init(L"ADC1");

	bool success = false;

	success = TegAdc_SetConfigInt(adcHandle1, L"BitResolution", 12, StoreVolatile);
	success = TegAdc_SetConfigInt(adcHandle1, L"AvgSamples", 1, StoreVolatile);
		
	int counter = 0;
	while (counter < 100)
	{

		DWORD adcValue1 = 0;

		success = TegAdc_Open(adcHandle1);		

		success = TegAdc_Read(adcHandle1, &adcValue1, sizeof(adcValue1));
		
		Sleep(1000);

		success = TegAdc_Close(adcHandle1);

		double mVAdc1 = static_cast<double>(adcValue1) / 1000.0;

		std::cout << std::setprecision(3) << "\r ADC1: " << mVAdc1 << " / counter: "  << counter;

		Sleep(1000);
		counter++;
	}	

	TegAdc_Deinit(adcHandle1);

Btw: this pre-release version still outputs “size 512” to the console when I call Adc_Init(…). As reported under C#