hi sir, i am trying to plot adc data register value in logic analyser , but while giving sine wave input to board stm32f103, i am unable to get sine wave in high frequency .it working fine at around 10hz .what might be the problem can u clarify?
i am unable to get sine wave in high frequency
So, what are you able to get? Are you sure the input frequency isn't too high for the sampling frequencey of your ADC setup, and/or the logic analyzer?
Yes sir, I am able to get sine wave when i am plotting the value of adc data register in logic analyser .But when i am taking certain size of array for extra processing at each time i am not getting exact sine wave, its coming like square wave.SO i think their might be problem in timing of taking samples.
You're going to have to get a lot better at presenting your problems if you expect others to diagnose them.
The code and sample data would describe a lot of the issues you are failing to convey.
What rate are you sampling at now, have you quantified that? Do the samples hit the rails? What is the swing of the square wave? Does it have a DC offset?
thanks, i am setting adc at 9mhz, and no of cycles 55.5, while giving signal through function generator i am giving .5v around offset. problem:
here the while loop is working only once ,but if i am removing 'systick' intrrupt then it is working continuously. what is the better option to store(update) particular size of array regularly in real time implimentation ?? since i am taking 512 amount so the perticular sine wave is not coming ,what i suppose to do with it?
void main() { RCC->APB2ENR |= ( 1UL << 4); GPIOC->CRL &= ~0x000F0000; #ifndef __ADC_IRQ RCC->AHBENR |= ( 1UL << 0); DMA1_Channel1->CMAR = (uint32_t)&ADC_last; DMA1_Channel1->CPAR = (uint32_t)&(ADC1->DR); DMA1_Channel1->CNDTR = 1; DMA1_Channel1->CCR = 0x00002522; NVIC_EnableIRQ(DMA1_Channel1_IRQn); DMA1_Channel1->CCR |= (1 << 0); #endif RCC->CFGR |= ( 3UL << 14); RCC->APB2ENR |= ( 1UL << 9); ADC1->SQR1 = 0; ADC1->SQR2 = 0; ADC1->SQR3 = (14UL << 0); ADC1->SMPR1 = ( 5UL << 12); ADC1->CR1 = ( 1UL << 8); ADC1->CR2 = ( 7UL << 17)| ( 1UL << 20) ; #ifndef __ADC_IRQ ADC1->CR2 |= ( 1UL << 8); #else ADC1->CR1 |= ( 1UL << 5); NVIC_EnableIRQ(ADC1_2_IRQn); #endif ADC1->CR2 |= ( 1UL << 0); ADC1->CR2 |= 1 << 3; while (ADC1->CR2 & (1 << 3)); ADC1->CR2 |= 1 << 2; while (ADC1->CR2 & (1 << 2)); while(1) { i=0; while(i<512) { ADC1->CR2 |= (1UL << 22); SysTick_Config(SystemCoreClock / 100); ADC_last = ADC1->DR; voltage1[i] = (double)(3.00 * ADC_last)/4096.0; i++; ADC1->SR &= ~(1 << 1); } ADC1->CR2 &= ~(1UL << 22); }
Please read the posting notes and use PRE tags when posting code.
I can barely decipher this. There is a whole mess of DMA, IRQ, and then you read the ADC1->DR with no attention to if the conversion is complete. Pick ONE method and apply it consistently.
You need to get this out of your loop, it has no purpose being there SysTick_Config(SystemCoreClock / 100);