2013-06-08 03:15 AM
2013-06-08 03:35 AM
Looks to be a tool problem with the code generation, suggest you take it to the CooCox forum or GNU/GCC devs.
You could try a different optimization level, ie not -O02013-06-09 09:49 PM
2013-06-10 10:26 AM
You'll need to review the forum posts, and firmware examples. I don't distribute a package of examples.
I can't fix issues with your tools, you will need to find a different tool chain if the one you have doesn't compile/link code properly. Support for CooCox will need to be sought from them, perhaps via their forum, they do not participate here.2013-06-11 02:55 AM
hey ..i am facing a problem in this code .i attached two potentiometer on pc0 and pc5.i am getting same value when i rotate one potentiometer and another is fixed.so plz guide me how could i get value of 2 potentiometer on different channel..here is my code
#include ''stm32f4xx_adc.h'' #include ''stm32f4xx_gpio.h'' #include ''stm32f4xx_rcc.h'' int ConvertedValue = 0; int ConvertedValue1=0; //Converted value readed from ADC void adc_configure(){ ADC_InitTypeDef ADC_init_structure; //Structure for adc confguration GPIO_InitTypeDef GPIO_initStructre; //Structure for analog input pin //Clock configuration RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1,ENABLE);//The ADC1 is connected the APB2 peripheral bus thus we will use its clock source RCC_AHB1PeriphClockCmd(RCC_AHB1ENR_GPIOCEN,ENABLE);//Clock for the ADC port!! Do not forget about this one ;) //Analog pin configuration GPIO_initStructre.GPIO_Pin = GPIO_Pin_0;//The channel 10 is connected to PC0 GPIO_initStructre.GPIO_Mode = GPIO_Mode_AN; //The PC0 pin is configured in analog mode GPIO_initStructre.GPIO_PuPd = GPIO_PuPd_NOPULL; //We don't need any pull up or pull down GPIO_Init(GPIOC,&GPIO_initStructre);//Affecting the port with the initialization structure configuration //ADC structure configuration GPIO_initStructre.GPIO_Pin = GPIO_Pin_5;//The channel 15 is connected to PC5 GPIO_initStructre.GPIO_Mode = GPIO_Mode_AN; //The PC0 pin is configured in analog mode GPIO_initStructre.GPIO_PuPd = GPIO_PuPd_NOPULL; //We don't need any pull up or pull down GPIO_Init(GPIOC,&GPIO_initStructre);//Affecting the port with the initialization structure configuration //ADC structure configuration ADC_DeInit(); ADC_init_structure.ADC_DataAlign = ADC_DataAlign_Right;//data converted will be shifted to right ADC_init_structure.ADC_Resolution = ADC_Resolution_12b;//Input voltage is converted into a 12bit number giving a maximum value of 4096 ADC_init_structure.ADC_ContinuousConvMode = ENABLE; //the conversion is continuous, the input data is converted more than once ADC_init_structure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_T1_CC1;// conversion is synchronous with TIM1 and CC1 (actually I'm not sure about this one :/) ADC_init_structure.ADC_ExternalTrigConvEdge = ADC_ExternalTrigConvEdge_None;//no trigger for conversion ADC_init_structure.ADC_NbrOfConversion = 2;//I think this one is clear :p ADC_init_structure.ADC_ScanConvMode = ENABLE;//The scan is configured in one channel ADC_Init(ADC1,&ADC_init_structure);//Initialize ADC with the previous configuration //Enable ADC conversion ADC_Cmd(ADC1,ENABLE); //Select the channel to be read from ADC_RegularChannelConfig(ADC1,ADC_Channel_10,1,ADC_SampleTime_144Cycles); ADC_RegularChannelConfig(ADC1,ADC_Channel_15,2,ADC_SampleTime_144Cycles); } int adc_convert(){ ADC_SoftwareStartConv(ADC1);//Start the conversion while(!ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC));//Processing the conversion return ADC_GetConversionValue(ADC1); //Return the converted data } int adc_convert1(){ ADC_SoftwareStartConv(ADC1);//Start the conversion while(!ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC));//Processing the conversion return ADC_GetConversionValue(ADC1); //Return the converted data } int main(void){ adc_configure();//Start configuration while(1){//loop while the board is working ConvertedValue = adc_convert();//Read the ADC converted value ConvertedValue1 = adc_convert1();//Read the ADC converted value } }2013-06-11 05:14 AM
You can't do it like that, you must use DMA for multiple channels on a single ADCx unit.
See example 4/5 down the page. [DEAD LINK /public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/3%20channels%20on%20ADC1%20and%20DMA&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B¤tviews=123]https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=%2Fpublic%2FSTe2ecommunities%2Fmcu%2FLists%2Fcortex_mx_stm32%2F3%20channels%20on%20ADC1%20and%20DMA&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B¤tviews=1232013-06-11 05:35 AM
...
[cc] C:\Users\AKG\AppData\Local\Temp\cciWMwmp.s: Assembler messages:
[cc] C:\Users\AKG\AppData\Local\Temp\cciWMwmp.s:180: Error: offset out of range
[cc] C:\Users\AKG\AppData\Local\Temp\cciWMwmp.s:181: Error: offset out of range
[cc] c:/program files (x86)/gnu tools arm embedded/4.7 2013q1/bin/../lib/gcc/arm-none-eabi/4.7.3/../../../../arm-none-eabi/bin/ld.exe: lto-wrapper failed
[cc] lto-wrapper: C:\Program Files (x86)\GNU Tools ARM Embedded\4.7 2013q1\bin\arm-none-eabi-gcc returned 1 exit status
[cc] collect2.exe: error: ld returned 1 exit status
Your toolchain, i.e. the compiler in this case, might have been build without LTO support. Try removing the ''-flto'' flag.
2013-06-11 09:32 AM
2013-06-11 09:34 AM
which tool chain should i use to assemble the programe ?
2013-06-11 10:00 AM
which tool chain should i use to assemble the programe ?
I'm using Keil, but have reasonably good experiences with Rowley, and IAR. If you're proficient with GNU/GCC something like Yagarto might be workable for you, I've built some flat projects with it. In terms of supported tools, ST has provided a Template Project, you'd want to be comfortable manipulating that into a new project, and copying in the code I've supplied. The code is sufficiently complete to drop into an existing project, building a project from scratch requires some experience/familiarity with the chosen tools.