Quantcast
Channel: MCS Electronics Forum
Viewing all articles
Browse latest Browse all 20637

BASCOM-AVR : Fast ADC in free mode : REPLY

$
0
0
[quote:bef8a09911="Ruprecht"]But I cannot reach this :([/quote:bef8a09911] Because you lack basic understanding how free-run works. Also in free-run there's a conversion time, the same as in single mode, so after changing the channel one still has to wait till the conversion is ready. So this [code:1:bef8a09911] Admux = 5 Adclow = Adcl Adchigh = Adch [/code:1:bef8a09911] is complete nonsense. As more as it kills partly this line: [code:1:bef8a09911]Config Adc = Free , Prescaler = Auto , Reference = Avcc[/code:1:bef8a09911] by clearing REFS0 and setting Reference to external. To do free-run mode without ISR is much more complex, if more than one channel is involved. If you would consult the data sheet [quote:bef8a09911]In Free Running mode, always select the channel before starting the first conversion. The chan- nel selection may be changed one ADC clock cycle after writing one to ADSC. However, the simplest method is to wait for the first conversion to complete, and then change the channel selection. Since the next conversion has already started automatically, the next result will reflect the previous channel selection. Subsequent conversions will reflect the new channel selection.[/quote:bef8a09911] you'd learn that it depends on when the main-loop is able to read ADC. The problem is asynchronous handling of the result in the main loop, it's difficult to say to what MUX-setting the result belongs to. If the time between setting MUX and reading ADC is longer than two ADC-conversions, the result always belongs to the actual MUX-setting, otherwise it may belong to the previous setting. That is also the reason, you'll find little information for your approach [quote:bef8a09911]What I need is ADC in free mode without interrupts and without waiting for end of conversion.[/quote:bef8a09911] as it's unsuitable, if you need to switch channels. In an ISR the MUX-switching can be done in a controlled way, considered the ADC-ISR is not blocked by other ISR for too long. Then simply the actual result belongs to the previous MUX-setting. However, if free run is done with only one channel (like in the link you've posted), the problem doesn't occur, one simply reads ADC and always gets the last valid result. With repeatedly changing MUX, it's much different. Better describe what you want to achieve and why without ISR, than describing an unsuitable approach.

Viewing all articles
Browse latest Browse all 20637


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>