AnsweredAssumed Answered

multichannel ADC

Question asked by fischer.daniel on Jul 1, 2010
Latest reply on Apr 12, 2011 by piovan.stefano
Hello all,

The analog to digital example provided, ADC, uses 1 analog channel (channel 9) only.  I am working on an application and need to convert 2 voltage channels.

1) is there a way to set up the A/D to cause an interrupt when 2 channels have been converted.  If yes, could someone provide the setup C sequence and the interrupt service routine C sequency (ADC example has the setup in main.c and interrupt service routine in stm8s_it.c).  I have found a SCAN bit in ADC_CR2 (Ref. Manual), presumably channel can be scanned; no info on which/the order of the scanned analog channels; how do I select say, ch 8 and ch 9 for scanning?

2) if the above cannot be done automatically, do I have to select the next channel in the interrupt service routine of the timer, and read the A/D in its interrupt handler; if you could provide the C sequence, that would be great.

3) There are a number of data buffer registers located in the memory range 53E0 to 53F3 (according to the Reference manual 14587.pdf).  I looked with the debugger and all these registers seem to be stuck on 0 (zero).  According to the ADC example, the value to be read for the conversion is in the data register high and low ADC_DRH and DRL.  I found a bit DBUF, in conf register 3 of the AD1, which presubably would enable the buffers.  My question is, why would one NOT want the buffer registers ALWAYS enabled; I would like to get the result of channel conversion in the appropriate buffer registers (0-9), rather than in one single register, and having to figure out which channel value is in this register; just wondering...