2012-02-20 05:52 AM
2012-02-20 07:23 AM
Change ScanConvMode from DISABLE to ENABLE for all 3 ADCs to get the second and third channel converted. The library example you may have started from converted only one channel.
Depending on your tension (pressure?) signal impedance, you may want to increase the sample time for better accuracy, but that is not related to the problem of converting only one channel. Minor nit: PAO is ADC123_IN0, not _IN12. Cheers, Hal2012-02-20 08:45 AM
Thanks for your response.
Now, I do the three conversions ! It is great :) I will set the sample time depending on the sensors (anemometer, clinometer...) But I still have a problem. A flashing led at every interrupt (of DMA2_stream0) and I test the new example :int main(void)
{
uint16_t i;
// Initialisation Hardware
HwInit();
for (i=0;i<9;i++)
{
ADCTripleConvertedValue[i]=i;
}
/* Infinite loop */
while (1)
{
/* Analog to digital converter */
DelayMS(100);
ADC_SoftwareStartConv(ADC1); // Start ADC
}
}
/**
* @brief This function handles DMAx global interrupt request.
* @param None
* @retval None
*/
/* Private define ------------------------------------------------------------*/
#define DMA2_IRQHANDLER DMA2_Stream0_IRQHandler
uint16_t AN0, AN1, AN2, AN3, AN4, AN5, AN6, AN7, AN8;
void DMA2_IRQHANDLER(void)
{
if(DMA_GetITStatus(DMA2_Stream0, DMA_IT_TCIF0) != RESET)
{
DMA_ClearITPendingBit(DMA2_Stream0, DMA_IT_TCIF0); // Reset du Flag
GPIO_ToggleBits(GPIOD, GPIO_Pin_12);
AN0 = DMA_GetADC(0) & 0x0FFF;
AN1 = DMA_GetADC(1) & 0x0FFF;
AN2 = DMA_GetADC(2) & 0x0FFF;
AN3 = DMA_GetADC(3) & 0x0FFF;
AN4 = DMA_GetADC(4) & 0x0FFF;
AN5 = DMA_GetADC(5) & 0x0FFF;
AN6 = DMA_GetADC(6) & 0x0FFF;
AN7 = DMA_GetADC(7) & 0x0FFF;
AN8 = DMA_GetADC(8) & 0x0FFF;
}
else
{
USART_SendString(USART3,''error
'');
}
}
Normaly the frequence of flashing led must be 5 Hz (1/2*100ms) but the led :
turn on : 100 ms
turn off : 100 ms
tunr on : 200 ms
turn off : 100 ms
...
I don't see where does the error.
Thank again,
Ronan.
2012-02-20 01:02 PM
I will set the sample time depending on the sensors (anemometer, clinometer...)
Remember, the sampling times for each simultaneous conversion have to be equal.But I still have a problem. A flashing led at every interrupt (of DMA2_stream0) and I test the new example : The problem is not clear to me. LED Pin D12 is also USART3 RTS. If that is not the problem, please describe the problem differently. Cheers, Hal2012-02-21 12:48 AM
Sorry for my first explanation which is not clear.
To verify that there is an interrupt (DMA) every 100 ms, I use a Led. Every DMA interrupt, I make a flashing led. Normally the led must flash at 20 Hz (if there is a conversion every 100ms). But when I tested my program the led don't flash regulary and i don't see where does the problem ? Regards, Ronan.2012-02-23 10:28 AM
If you toggle the LED every 100 msec, the LED will flash 5 times per second. That is probably visible, but to be sure, slow it down with a 500 msec delay.
I can't find anything wrong. Put a count variable on each ADC conversion command and each DMA interrupt, run for a few seconds, then inspect the count variables in Debug mode. This may isolate the problem to main or the DMA handler, or the LED init. Cheers, Hal2012-02-29 08:31 AM
Hi Hal,
I observe
signals
with
a scope so
not need to change
interrupt timer (every 100ms). I verified the differents interrupts : -> ADC interrupt : every 100 ms -> DMA interrupt : the cycle is 100 ms, 100ms, 200 ms, 200ms So the problem comes DMA Handler but I don't see where ? Maybe the FIFOMode or MemoryBurst ??? Thanks, Ronan.2012-02-29 08:48 AM
I enclose
my code : main.c, utils.c, utils.h, stm32f4xx_it.c
________________ Attachments : main.c : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HzaP&d=%2Fa%2F0X0000000bNz%2FY4fgKpXudKIIhOKRhflDX_UYDdDe2RKv_9BjqKrlKwo&asPdf=falsestm32f4xx_it.c : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HzKn&d=%2Fa%2F0X0000000bO0%2FAy3skQ7e4OuQIg1ekrC6v9y6nFjYkzCAkauwHXFSinM&asPdf=falseutils.c : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006Hz9v&d=%2Fa%2F0X0000000bNx%2F1KCASYTjtLagu2Z6aLfG7213b6NJXg71SfHi9H0ZH10&asPdf=falseutils.h : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HzaF&d=%2Fa%2F0X0000000bNy%2FUkB.iO8wKypCf2tbEY3WIwmW2WbWJKzyZAw3PTF4DMI&asPdf=false2012-03-01 09:27 AM
See my post STOne-32 ADC Lib Examples Problem dated Feb 24 in the STM32 forum for one fix you need. It may not fix your current problem, but it will avoid other problems.
I am otherwise busy, but I will take a better look at your code in a few days if a fix has not been found by then. Cheers, Hal2012-03-04 09:43 AM
There are two problems in utils.c:
The PA4 pin can be either ADC123_IN4 or DAC1_OUT, but not both. Change _IN4 to an available free _INx pin. There are three channels set up for conversion per ADC, and a 9 word DMA buffer size, but the ADC init NumberOfConversions is only 2 per ADC. Change it to 3. Cheers, Hal