ADC, help me

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

ADC, help me

1,684 次查看
KingJames
Contributor I

Hi all

 

I'm starting with Freescale Beekit Tool kit. I'm using IAR Embedded Workbench with MC1322x Sensor Node.

Someone can tell me how to use ADC or where I can find some example where I can understand...

 

Thanks...

标签 (1)
0 项奖励
回复
2 回复数

819 次查看
Iko
Contributor II

Hi kingJames.

 

First, you must know the ADC channel where you want to make a convert.

After, you must define you're parameters:

-8,10,12.. bits results

-single or continus conversion

-whit or whitout interruption...

-ADC frequency (source clock and diviser/prescaler)

 

Next, you write on the various ADC register...

 

See the data sheet of you're µC for more details for ADC device...

 

0 项奖励
回复

819 次查看
KingJames
Contributor I

Hi Iko,

Thanks for the reply...

 

this is my c code:

 

1) set of gpio

 

    Gpio_SetPinFunction(gGpioPin31_c, gGpioAlternate1Mode_c);
    Gpio_EnPinPuKeeper(gGpioPin31_c,      FALSE);

 

 

2) ADC Setup

 

  #include "ADC_Interface.h"

 

  ...

  ...

 

  AdcConfig_t sAdc_Config;
  AdcConvCtrl_t adcConvCtrl;
  Adc_Init();
  Adc_Reset();
  (void)Adc_SetFifoCtrl(FIFO_DEEP);
  Adc_DefaultConfig(sAdc_Config, 24000); // (1Mhz prescale clock, 300KHz ADC analog clock,
                                         //   10 us on time, 40 us conversion time,
                                         //   auto working mode, compare interrupt disabled,
                                         //   FIFO interrupt disabled)
 
  (void)Adc_SetConfig(&sAdc_Config);
  Adc_TurnOn();
 
  adcConvCtrl.adcTmrOn = TRUE;
  adcConvCtrl.adcChannels = 0;
  adcConvCtrl.adcChannels |= (1 << gAdcChan1_c);
  adcConvCtrl.adcTmBtwSamples = gTimeBetweenSamples_c; // 1s between samples
  adcConvCtrl.adcSeqMode = gAdcSeqOnTmrEv_c; //Timer mode
  adcConvCtrl.adcRefVoltage = gAdcBatteryRefVoltage_c;
  (void)Adc_SetConvCtrl(gAdcPrimary_c, &adcConvCtrl);

 

3) problem :  I'm tring to sample 1.5V of battery (AA) on channel 1, but the sampled value that I read from FIFO is greater ,for example 2130  ....

Where is the problem on my code?

Have you some example about it?

 

Thank you in advance...

 

 

0 项奖励
回复