cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F3 Discovery next steps?

don23
Associate II
Posted on December 13, 2012 at 04:35

Hi,

I successfully setup IAR 6.5 and got the F3 Discovery Bd. demo working along with modifying the code to change the LED timing. I read through UM5170 User Manual. I'm looking for more examples to learn about the peripherals. So, I downloaded the AN4157 firmware examples. This includes brief descriptions of each peripheral but not the tutorials to work them.

I also found examples with, ''This example has been tested with STMicroelectronics STM32303C-EVAL (STM32F30x)  evaluation board and can be easily tailored to any other supported device and development board.'' However, it doesn't explain How to do this.

Since I'm new to ARM and 32F3, I would appreciate what next steps to learn this platform.

Thanks!

#stm32f3-iar #adc #discovery-board #:-discovery-board-stm32f3
53 REPLIES 53
Posted on September 23, 2013 at 15:56

It would suggest you are not getting any ADC/DMA requests. Would suggest you check the DMA peripheral state and see if it's indicating some fault condition.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
hilwan
Associate II
Posted on September 23, 2013 at 17:40

It checked TEIF1 and TEIF5 for channel 1 and channel 5 but they don't  change.

I insert a breakpoint  point at   void DMA1_Channel1_IRQHandler(void) and voidDMA2_Channel5_IRQHandler(void). it seems to jump the second one. that's mean  DMA2 channel5 IRQ Channel isn't enabled ?

Which DMA registers can i check to verify that i have errors ? 

hilwan
Associate II
Posted on September 25, 2013 at 11:07

Hi again,

1) I want to know if when you put

(ADC_InitStructure.ADC_ContinuousConvMode=ADC_ContinuousConvMode_Disable; */// Triggered

) we can acquire a sine wave in continuous mode on ADC1 for example?

2) How can i evaluate the sampling rate of my ADC practically?

3) In the while loop i write :

while(1)

{

/* ADC12 samples */

for (j=0;i<SAMPLES;j++)

{

ADC1ConvertedValue = (ADC12DualConvertedValue[i]& 0xFFFF);

ADC1ConvertedVoltage = ADC1ConvertedValue *2960/0xFFF;

ADC2ConvertedValue =((ADC12DualConvertedValue[i] & 0xFFFF0000) >>16);

ADC2ConvertedVoltage= ADC2ConvertedValue *2960/0xFFF;

/* ADC34 samples */

ADC3ConvertedValue = (ADC34DualConvertedValue[i]& 0xFFFF);

ADC3ConvertedVoltage = ADC3ConvertedValue *2960/0xFFF;

ADC4ConvertedValue =((ADC34DualConvertedValue[i]& 0xFFFF0000) >>16);

ADC4ConvertedVoltage= ADC4ConvertedValue *2960/0xFFF;

}

if (i < 256)

{

buffer1[i] = ADC1ConvertedVoltage ;

buffer2[i] = ADC2ConvertedVoltage ;

buffer3[i] = ADC3ConvertedVoltage ;

buffer4[i] = ADC4ConvertedVoltage ;

i++;

}

}

Do you have an idea how can I verify that conversion of 4 analogs inputs are done in synchronization with the 4 ADCs?

These answers are important for my project, i'll be very grateful for your help.

Thank you in advance

Posted on September 25, 2013 at 14:26

1) Don't know, how would free running the conversions be more useful than doing it at a known pace, with synchronization? What frequency is required?

2) Use a signal of known frequency and determine the zero-crossing point in the sample buffer. Toggle a GPIO at DMA TC interrupt measuring sample window period?

3) Provide signals of known frequency and phase relationship to the four inputs. Step 1 would be to use a signal generator to feed all four channels.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
hilwan
Associate II
Posted on September 25, 2013 at 17:05

1) I tough that when

ADC_ContinuousConvMode_Disable

est set means that i can have only my input in single mode and not in repeated mode . But i saw in RM0316 that when an hardware trigger is used, conversion can be continuous until ADSTART=1. i use a signal generator to drive inputs variating between [0-3V] and reaching a FreqMax=100KHz. 2) Honestly, i don't know how to use the zero-crossing. But basing on your code the GPIO is toggled at DMA TC interrupt every 1s knowing that we have 25 samples occurring every 500 ms, the trigger is produced every 20 ms . Theoretically, we have t-adc= 3.6 Msamlpe/s. 3) the 4 inputs are diven with the same input from a signal generator but in debug mode the conversion is so fast that i can't see the similarity between them.
Posted on September 25, 2013 at 17:30

You'd want to record and off-load the samples in enough volume that you could perform a proper analysis of the data. ie stick in a spreadsheet, plot it, whatever.

Triggered mode uses the timer for pacing, want a faster sample rate, then drop the prescaler/period of the timer to reflect the rate desired. I picked the buffer size, and sample rate for illustration.

At 3 MSps you're going to be generating A LOT of data, you'll be hard pressed to process or store information at those rates. What are you trying to sample, and what rate is appropriate for that task?

While it might be of academic interest to know just how fast the ADC may theoretically run, practical realities will likely be much lower.

If you're trying to make a 4 channel scope, you don't specify, the memory size and bandwidth are going to be the limiting/constraining factors.

3 MSps equates to 24 MBps, you have 40 KB for samples, so figure about 5K samples.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
hilwan
Associate II
Posted on September 25, 2013 at 18:52

I want to sample 4 analogs inputs coming from an interferometer sensor.

So i have sine waves 0/3 V to sample. The aim is to have a sample rate of 100 KHz minimum this is way i chooses Discovery 3 (4 ADCs). so i try to have a sample rate between 100KHz until 1MHz for each ADC at 12 bits, it'll be nice

''If you're trying to make a 4 channel scope, you don't specify, the memory size and bandwidth are going to be the limiting/constraining factors'', do you mean with DMA ?

Posted on September 25, 2013 at 19:03

No, you're going to have to use DMA, I'm saying that the system resources are going to more limiting than the maximal speed of the ADCs. You presumably want to do something with, or process, the incoming data. You'll have to figure out what the saturation point is.

I don't see a problem running 4 channels at 100 KHz

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
hilwan
Associate II
Posted on September 26, 2013 at 15:48

Well, i tried to set my ADCs frequency sampling at 100KHz.

1) first off all, i use RCC_ADC12PLLCLK_Div4 to get 18MHz of the ADC clock, then 18Mhz/100KHz= 180. So i calculated the Tadc using the relation Tadc=Tsmp+Tsar=[x cycles +12.5(12bits) cycles ]*Tadc-clk. In this case x=167.5, so i take ADC_SampleTime_181Cycles5.

Tadc=10.77µs 

2) based on the Tadc,  i  Configure Timer/Counter 3 to Generate interrupt every 100µs @ 72 MHZ Timer clock.

3) to have all sample data, i need to configure the DMA buffer to 100K samples!!! so the limitation is 65535. But when i put the buffer size at 4000 samples i get this error Error: L6406E: No space in execution regions with .ANY selector matching main.o(.bss).as you said i will have resources limitation knowing that i need to do my algorithm with this samples.

So i reduced the buffer size to 2048 to avoid this problem for the moment. And i think to add a flash memory, i don't know if it will be a easy stuff.

4) another thing, in debug session, i have noticed that when doing this code below 

       for (j=0;i<SAMPLES;j++)

{

           ADC1ConvertedValue = (ADC12DualConvertedValue[i]& 0xFFFF);

            ADC1ConvertedVoltage = ADC1ConvertedValue *2960/0xFFF; 

   ADC2ConvertedValue =((ADC12DualConvertedValue[i] & 0xFFFF0000) >>16);

   ADC2ConvertedVoltage= ADC2ConvertedValue *2960/0xFFF;

  /* ADC34 samples */

     ADC3ConvertedValue = (ADC34DualConvertedValue[i]& 0xFFFF);

     ADC3ConvertedVoltage = ADC3ConvertedValue *2960/0xFFF;  

     ADC4ConvertedValue =((ADC34DualConvertedValue[i]& 0xFFFF0000) >>16);

   ADC4ConvertedVoltage= ADC4ConvertedValue *2960/0xFFF;

buffer1[j] = ADC1ConvertedVoltage ;

buffer2[j] = ADC2ConvertedVoltage ;

buffer3[j] = ADC3ConvertedVoltage ;

buffer4[j] = ADC4ConvertedVoltage ;

i++;

}

ADC12DualConvertedValue[i] changed its 2048 values every step in debug mode and so the  ADC1ConvertedVoltage,ADC2ConvertedVoltage,ADC3ConvertedVoltage,ADC4ConvertedVoltage    are not given at t instant but t+n instant.

 

5) if my way to process isn't clear, please correct me.

Without you help,it will be very difficult for me to understand some notions.

Thank you very much 

Posted on September 26, 2013 at 17:32

You likely ran out of space as you only have 40K of SRAM to play with, and by processing the data into your buffer[] array you have halved your sample space, assuming that array uses 16-bit integers.

You could process the data in place if you are capturing and stopping, or you could upload the data and post-process it.

Using a 16-bit array to capture the values you'd need to do less work manipulating the 32-bit values.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..