AnsweredAssumed Answered

MCF51EM256 - how to use >2 channels of an ADC device

Question asked by Steve Leatherland on Jun 2, 2011
Latest reply on Jun 7, 2011 by Steve Leatherland

Hello,

 

I'm struggling to try and make sense of the ADC driver, specifically for the MCF51EM256 microcontroller.  I am trying to understand how to use more than two channels on a given ADC device.  For example, if I open the "adc1" device and then open channels on that device the first two are opened successfully but anything after that fails.

 

Digging down through the call to fopen() I can see that in the function _adc_open() of module "adc.c" that the channels are always bundled in groups of 2 channels.  Once both of those channels have been assigned, any attempt to open another channel will fail because there is no free channel available.  Presumably the channels are bundled in pairs so that they can be triggered via the two outputs of the Programmable Delay Block (PDB).

 

However, I feel like I must be missing something here.  For the MCF51EM256 microcontroller the ADC1 there should be 6 channels that can be used to read external voltages.  Surely it should be possible to use more than just two of those at a time?

 

In general, this is what I am trying to do:

 

fpADC = fopen("adc1:", (const char *)&adcInit);  // Open file pointer to ADC

.

.

.

// Open individual ADC channels

 

// ADC_SOURCE_ADC1_ADPM1

fpADCChTempr = fopen("adc1:temperature", (const char *)&adcChTemprInit);

 

// ADC_SOURCE_ADC1_AD5

fpADCChVoltage = fopen("adc1:voltage", (const char *)&adcChVoltageInit);

 

// ADC_SOURCE_ADC1_AD10

fpADCChCurrent = fopen("adc1:current", (const char *)&adcChCurrentInit);


// ADC_SOURCE_ADC1_AD11

fpADCChLux = fopen("adc1:lux", (const char *)&adcChLuxInit);


 

Any suggestions would be greatly appreciated.

 

Thank you.

 

 

 

Outcomes