v-usb adc

Go To Last Post
5 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello

im doing v-usb adc logger project and have some weird problem. My pc side program is lagging when adc communication is included, even if i use very short delay times.
with

void static adc_read(void){
	
	ADCSRA |= (1 << ADSC);
	
	while(ADCSRA & (1<<ADSC));
	
	replyBuf[1]=ADCL;
	replyBuf[0]=ADCH;
	replyBuf[2]=0;
	
	_delay_ms(1);
	
}

it is lagging visibly already and if i use delay of 100ms, program is almost not working. Without adc it works well. My watchdog resets every 1s. Any ideas?

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It could be possible that the AVR is running on a factory-default system clock of 1MHz. This would happen if the AVR internal fuses were not set to use an external 16MHz source as the clock.

What do you mean by "PC side is lagging?"

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

And what does the documentation say about the usbPoll() function? I'll give you a hint, if it is not called at least every 50ms, there could be trouble... including the device not being recognized. That type of trouble means that just about any symptoms might result, it's hard to know what might happen -- including the system almost not working.

Martin Jay McKee

As with most things in engineering, the answer is an unabashed, "It depends."

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Simonetta

Sorry for not mentioning, i use mega16 with 12MHz speed. By lagging i mean that it takes maybe half of second to start working instead of right away when i don't use adc.

mckeemj

thanks for pointing this out, i wont use long waits anymore but i still dont understand why adc communication and a delay of few ms matters.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

This was probably a false alarm, i tried everything again and it takes aproximately the same amount of time to load with and without adc and that small loading lag is probably for usb communication:) anyway thanks