<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.arm.com/utility/feedstylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Stm32f4 Adc problem</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/31480/stm32f4-adc-problem</link><description> 


HI…I am using adc and then usart to send data to pc at timer interrupts.My code was working properly. checked it by sampling a signal from signal generator and displaying it on matlab GUI.But suddenly it stopped working.now it correctly samples DC</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: Stm32f4 Adc problem</title><link>https://community.arm.com/thread/93202?ContentTypeID=1</link><pubDate>Sat, 31 May 2014 05:12:43 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:5623c423-af70-4a10-8260-455e0206b118</guid><dc:creator>ImPer Westermark</dc:creator><description>&lt;p&gt;&lt;p&gt;
Programs seldom magically stops working.&lt;/p&gt;

&lt;p&gt;
That is a reason why it is important to try to use some form of
version control. Even if that version control is regularly making a
copy of the source files to directories bu1/, bu2/, bu3/, ...&lt;/p&gt;

&lt;p&gt;
Being able to compare what has changed between working/non-working
is often the fastest way to spot errors that has managed to work
themselves into the code or project settings.&lt;/p&gt;

&lt;p&gt;
Anyway - back to debugging. Get the ADC module to function as an
independent box&amp;quot; of functionality.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Stm32f4 Adc problem</title><link>https://community.arm.com/thread/62864?ContentTypeID=1</link><pubDate>Sat, 31 May 2014 03:26:13 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:a3af5e47-c79c-4308-ba64-16a81db7b8ef</guid><dc:creator>Amna Tehreem</dc:creator><description>&lt;p&gt;&lt;p&gt;
I am using adc and then usart to send data to pc at timer
interrupts.My code was working properly. checked it by sampling a
signal from signal generator and displaying it on matlab GUI.But
suddenly it stopped working.now it correctly samples DC signal but
any varying signal is sampled by just continuous 0&amp;#39;s and 1&amp;#39;s.I
checked everything independently. Timer and usart are working
accurately. The problem is with ADC. can anyone help me to resolve
this&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Stm32f4 Adc problem</title><link>https://community.arm.com/thread/62861?ContentTypeID=1</link><pubDate>Sat, 31 May 2014 03:25:18 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:26a6463b-156c-4c80-b56f-d8d953dd9a9d</guid><dc:creator>Amna Tehreem</dc:creator><description>&lt;p&gt;&lt;p&gt;
void TIM2_IRQHandler(void) //Timer Interupt for sending data&lt;br /&gt;
{ if (TIM_GetITStatus(TIM2, TIM_IT_Update) != RESET) {
TIM_ClearITPendingBit(TIM2, TIM_IT_Update);
GPIO_ToggleBits(GPIOA,GPIO_Pin_0); sample_data = (uint8_t)
(ConvertedValue&amp;gt;&amp;gt;4); //convert 12 bit data to 8 bits
USART_puts(USART1,sample_data );&lt;/p&gt;

&lt;p&gt;
}&lt;br /&gt;
}&lt;/p&gt;

&lt;p&gt;
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);
RCC_AHB1PeriphClockCmd(RCC_AHB1ENR_GPIOCEN,ENABLE); //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&amp;#39;t need any
pull up or pull down
GPIO_Init(GPIOC,&amp;amp;GPIO_initStructre);//Affecting the port with the
initialization structure configuration //ADC structure configuration
ADC_DeInit(); ADC_init_structure.ADC_DataAlign = ADC_DataAlign_Right;
ADC_init_structure.ADC_Resolution = ADC_Resolution_12b;
ADC_init_structure.ADC_ContinuousConvMode = ENABLE;
ADC_init_structure.ADC_ExternalTrigConv =
ADC_ExternalTrigConv_T1_CC1;
ADC_init_structure.ADC_ExternalTrigConvEdge =
ADC_ExternalTrigConvEdge_None; ADC_init_structure.ADC_NbrOfConversion
= 1;//I think this one is clear :p
ADC_init_structure.ADC_ScanConvMode = DISABLE;//The scan is
configured in one channel ADC_Init(ADC1,&amp;amp;ADC_init_structure);
ADC_Cmd(ADC1,ENABLE); //Select the channel to be read from
ADC_RegularChannelConfig(ADC1,ADC_Channel_10,1,ADC_SampleTime_144Cycles);&lt;br /&gt;

} 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&lt;br /&gt;
}&lt;/p&gt;

&lt;p&gt;
int main(void){&lt;/p&gt;

&lt;p&gt;
init_USART1(19200); INTTIM_Config(); adc_configure();&lt;/p&gt;

&lt;p&gt;
while(1){ ConvertedValue = adc_convert();//Read the ADC converted
value }&lt;br /&gt;
}&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>