|
|
View previous topic :: View next topic |
Author |
Message |
tavioman
Joined: 22 Feb 2006 Posts: 65
|
#int_AD |
Posted: Wed Feb 22, 2006 1:06 pm |
|
|
How can I read A/D during A/D conversion complete interrupt, and how do I start the conversion before main loop.
Thank You! |
|
|
Ttelmah Guest
|
|
Posted: Wed Feb 22, 2006 3:37 pm |
|
|
The 'read_adc' function, has an optional variable, that allows it to be 'split' into components. The default 'read_adc()', functions the same as 'read_adc(ADC_START_AND_READ)'. Read_ADC(ADC_READ_ONLY), returns the current ADC reading, if one is ready, without starting the conversion. Read_adc(ADC_START_ONLY), starts the conversion, and does not return a reading.
However I'd suggest 'rethinking' using the ADC interrupt. The problem is that calling an interrupt handler, inserts typically about 30 instruction times overhead, before the handler is reached, and the same again, returning from the handler. Then perhaps another ten instruction times to take the reading itself. So if you trigger an ADC conversion, you get perhaps 20uSec pass, before the interrupt triggers, and then you have a total overhead of perhaps 70 instruction times to actually 'get' the reading. Now assuming a 40Mhz processor clock, you 'save' potentially 200 instruction times where you can be doing other things while the reading occurs, but then lose back some 70 of these in the overhead associated with the interrupt handler. On slower processors, the overhead becomes greater than any saving....
In another thread, I suggested that instead, if you are using a timer interrupt, you can use this to read the value from the last conversion, and then trigger a new conversion, and not have to wait for either part.
Best Wishes |
|
|
tavioman
Joined: 22 Feb 2006 Posts: 65
|
|
Posted: Wed Feb 22, 2006 3:44 pm |
|
|
Thank You! |
|
|
tavioman
Joined: 22 Feb 2006 Posts: 65
|
|
Posted: Wed Feb 22, 2006 3:44 pm |
|
|
Thank You! |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|