2010-06-15 02:07 AM
Timer1 Triggered and Scan Mode ADC1
2011-05-17 06:09 AM
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.2011-05-17 06:09 AM
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);
}
2011-05-17 06:09 AM
Ok thanks for all,
I think tomorrow, I'll try your code in my project. Thanks yet, regards.2011-05-17 06:09 AM
Hi,
Good job, this code run very well.
Thanks.
2011-05-17 06:09 AM
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 ADC1The 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,2011-05-17 06:09 AM
2011-05-17 06:09 AM
Hi moussa,
''CXSTM8_16K'' means that he is using cosmic compiler with limited code size to 16K. regards, MCU Lüfter