2012-12-12 07:35 PM
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-stm32f32013-09-17 09:18 AM
I spent a lot of time to debug but no success, can you please help me on this. I m working with STM32f3 discovery.
I'm not using F3 parts, and can't afford to spend any time on them.2013-09-17 09:21 AM
Ok understand. I hope that someone else would have the answer.
Any case thank you and I'll continue to resolve the problem.2013-09-18 07:37 AM
There is an ''ADC_DualMode'' example in the STM32F30x_DSP_StdPeriph_Lib, as found on the ST website, which employs the ADC with DMA.
I think you can take this example as template for your code.2013-09-18 09:05 PM
2013-09-20 03:46 AM
Thanks clive1, your code is similar to what i'm looking for.
But i still have some remarks and questions. First off all, to configure the ADC clocks you put : 1) RCC_ADCCLKConfig(RCC_ADC12PLLCLK_Div1); that's mean that the ADC is clocked is derived from the PLL Clock (72Mhz in this case). In the same time ADC_CommonInitStructure.ADC_Clock = ADC_Clock_AsynClkMode; So based on the data sheet, with this configuration has the advantage to reach the maximum of the ADC clock but it's not synchronized with the AHB clock. but we should use the AHB clock to drive the ADC in order to use timers to trigger the ADC. This is way i make some modification, but i don't know if is correct; /* Configures the AHB clock (HCLK) ***/ RCC_HCLKConfig(RCC_SYSCLK_Div1); // RCC_AHB_Clock_Source( 72MHz in this case ). then : ADC_CommonInitStructure.ADC_Clock = ADC_Clock_SynClkModeDiv4; // this gives us 18 MHz. I have a question about how to read from ADC12DualConvertedValue [SAMPLES * 2]?i put : ADC1ConvertedVoltage= ADC12DualConvertedValue[0] *2960/0xFFF; ADC2ConvertedVoltage= ADC12DualConvertedValue[1] *2960/0xFFF; 2) Timer : Timer 2 uses the ABP1 clock,so its clock is 36 MHz if TIM_Prescaler=0.TIM_TimeBaseStructure.TIM_Period = (SystemCoreClock / 50) - 1; // 25Hz Sample Rate and not 50, because SystemCoreClock =72Mhz.
3) void DMA1_Channel1_IRQHandler(void)// 2 Hz
: i Don't understand how you compute 2Hz. Thanks in advance2013-09-20 07:21 AM
1) I'll have to look at that some more, I suspect it just adds some additional delay while resynchronizing the already synchronous signals.
The low 16-bit word is for ADC1, the high 16-bit word is for ADC2, the secondary buffer has ADC3 and ADC4. 2) No, I really think it will be clocking at 72 MHz, you should review the ''Clock Tree'' in the reference manual, and observe the routing of the TIMCLK. These can be, are typically are, APBCLK * 2 on the slower buses. 3) 25 Samples at 20 ms (50 Hz) will occur every 500 ms (2 Hz)2013-09-20 08:48 AM
response to 1) So in this case
volatile uint16_t ADC12DualConvertedValue[SAMPLES * 2] be
shouldvolatile uint32_t ADC12DualConvertedValue[SAMPLES * 2] no? And my variables become: ADC1ConvertedValue = (ADC12DualConvertedValue[0] & 0xFFFF); ADC1ConvertedVoltage = ADC1ConvertedValue *2960/0xFFF; ADC2ConvertedVoltage= ((ADC12DualConvertedValue[0] & 0xFFFF0000) >>16); ADC2ConvertedVoltage = ADC2ConvertedValue *2960/0xFFF;
what would happen if we put ADC_InitStructure.ADC_ContinuousConvMode = ADC_ContinuousConvMode_Enable; ? instead of ADC_InitStructure.ADC_ContinuousConvMode=ADC_ContinuousConvMode_Disable; */// Triggered
2013-09-20 10:11 AM
No, I want to access them as 16-bit values, the DMA is filling them in pairs (32-bit), and why the 16-bit array is twice the number of samples. The compiler doesn't have to treat them as 32-bit, it's just memory. It fills 100 bytes in 500 ms, be that 25x 32-bit or 50x 16-bit.
ADC12DualConvertedValue[0] ADC1 Sample 1 ADC12DualConvertedValue[1] ADC2 Sample 1 ADC12DualConvertedValue[2] ADC1 Sample 2 ADC12DualConvertedValue[3] ADC2 Sample 2 .. ADC34DualConvertedValue[0] ADC3 Sample 1 ADC34DualConvertedValue[1] ADC4 Sample 1 ADC34DualConvertedValue[2] ADC3 Sample 2 ADC34DualConvertedValue[3] ADC4 Sample 2 .. Well if you have it in continuous mode it's just going to jam results as quickly as it can. Usually I'm more concerned about the time domain, and getting the sample at a specific time/rate.2013-09-23 01:42 AM
Ok, thank you very much clive1,I'll take in considerations all your helpful suggestions and remarks; I'll give you i feedback when the code will be tested.
2013-09-23 06:17 AM
when I put ADC_InitStructure.ADC_ContinuousConvMode = ADC_ContinuousConvMode_Enable; LED3 stays on (but don't blink) and LED4 stays off. do you have an idea why ?
In other hand, in debug mode, the CDR registers contain value even if the analog inputs are disconnected, so we always have converted value! this is because the CMOS level ?