cancel
Showing results for 
Search instead for 
Did you mean: 

Timer1 Triggered and Scan Mode ADC1

vcelik
Associate II
Posted on June 15, 2010 at 11:07

Timer1 Triggered and Scan Mode ADC1

7 REPLIES 7
sylvain_laurent
Associate II
Posted on May 17, 2011 at 15:09

Hi volkan,

Yesterday, I tested your code with my demo board because I would like to use the same purpose in my project.

First of all, without use interrupt and timer1 trigger so i'm in pulling mode, the conversions are good on all ADC inputs.

But after, with interrupt on EOC, I have the same problem.

Only the first [0] get values.

Do you resolved your problem ?

Thanks.

vcelik
Associate II
Posted on May 17, 2011 at 15:09

Yes. 

ADC1_ConversionConfig() function must come after the ADC1_Cmd(ENABLE),

ADC1_ScanModeCmd(ENABLE) and 

ADC1_ITConfig(ADC1_IT_EOCIE, ENABLE) functions.

Because these functions reset the channel definition of the

ADC1->CSR register.

So the right initiation function is like this:

void MyInitFunc(void)

{

      

ADC1_Cmd(ENABLE);    

ADC1_ScanModeCmd(ENABLE);  

ADC1_ITConfig(ADC1_IT_EOCIE, ENABLE);

ADC1_ConversionConfig(ADC1_CONVERSIONMODE_SINGLE, ADC1_CHANNEL_8, ADC1_ALIGN_RIGHT);

ADC1_PrescalerConfig(ADC1_PRESSEL_FCPU_D2);

    

ADC1_SchmittTriggerConfig(ADC1_SCHMITTTRIG_CHANNEL0, DISABLE);

ADC1_SchmittTriggerConfig(ADC1_SCHMITTTRIG_CHANNEL1, DISABLE);

ADC1_SchmittTriggerConfig(ADC1_SCHMITTTRIG_CHANNEL2, DISABLE);

ADC1_SchmittTriggerConfig(ADC1_SCHMITTTRIG_CHANNEL3, DISABLE);

ADC1_SchmittTriggerConfig(ADC1_SCHMITTTRIG_CHANNEL4, DISABLE);

ADC1_SchmittTriggerConfig(ADC1_SCHMITTTRIG_CHANNEL5, DISABLE);

ADC1_SchmittTriggerConfig(ADC1_SCHMITTTRIG_CHANNEL6, DISABLE);

ADC1_SchmittTriggerConfig(ADC1_SCHMITTTRIG_CHANNEL7, DISABLE);

ADC1_SchmittTriggerConfig(ADC1_SCHMITTTRIG_CHANNEL8, DISABLE);

  

    TIM1_SelectMasterSlaveMode(ENABLE);   

    ADC1_ExternalTriggerConfig(ADC1_EXTTRIG_TIM, ENABLE); 

    

TIM1_TimeBaseInit(3999, TIM1_COUNTERMODE_UP, 4000, 0);        

    

TIM1_SelectOutputTrigger(TIM1_TRGOSOURCE_UPDATE); 

    

TIM1_Cmd(ENABLE);

}

sylvain_laurent
Associate II
Posted on May 17, 2011 at 15:09

Ok thanks for all,

I think tomorrow, I'll try your code in my project.

Thanks yet, regards.

sylvain_laurent
Associate II
Posted on May 17, 2011 at 15:09

Hi,

Good job, this code run very well.

Thanks.

mchnani
Associate II
Posted on May 17, 2011 at 15:09

Hi Volkan,

I use STMS105K4 (COSMIC) and i would like to use seven channels with scan mode. When i tested your final code i have errors with ADC1

The command: ''clnk -l''C:\Program Files\COSMIC\CXSTM8_16K\Lib''

What's the library are you used in your project, 

Thank you in advance

Best regards,

eos1d3
Associate II
Posted on May 17, 2011 at 15:09

I believe you need the following before enabling ADC1:

ADC1_DataBufferCMD(ENABLE);

https://my.st.com/public/STe2ecommunities/mcu/Lists/STM8/group__ADC1__Public__Functions.html#ge1604ac905b2237098c53046e100f679

lowpowermcu
Associate II
Posted on May 17, 2011 at 15:09

Hi moussa,

''CXSTM8_16K'' means that he is using cosmic compiler with limited code size to 16K.

regards,

MCU Lüfter