cancel
Showing results for 
Search instead for 
Did you mean: 

EOC interrupt for ADC

orn
Associate II
Posted on October 22, 2012 at 16:42

 

 

The original post was too long to process during our migration. Please click on the attachment to read the original post.
14 REPLIES 14
Posted on October 22, 2012 at 17:06

You'd need an interrupt service routine to handle this?

Wouldn't it make more sense to use the DMA TC interrupt to catch the capture of all three measurements, or to extend the DMA to capture 100 or 3x 100 samples and then interrupt?
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
orn
Associate II
Posted on October 22, 2012 at 17:18

I need to build three vectors containing the samples of the three channels, if I do it directly put more than once the same sample in the vector! okay any solution, I decided to do it as you saw in the previous code, but it does not work ....

Posted on October 22, 2012 at 17:25

a) ADC EOC is probably not the appropriate interrupt to be working from.

b) Without an interrupt service routine, the system will malfunction once one is signalled.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
orn
Associate II
Posted on October 22, 2012 at 18:45

In your opinion what is the most appropriate interrupt?

how do I create a routine for the ADC interrupt or DMA?

Posted on October 22, 2012 at 19:06

In your opinion what is the most appropriate interrupt? how do I create a routine for the ADC interrupt or DMA?

You're drowning here. Have you done anything like this before, or work with someone who has?

// ...
/* Enable the ADC DMA Interrupt */
NVIC_InitStructure.NVIC_IRQChannel = DMA2_Stream0_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
// ...
/* Enable DMA Stream Half Transfer and Transfer Complete interrupt */
DMA_ITConfig(DMA2_Stream0, DMA_IT_TC, ENABLE);
DMA_ITConfig(DMA2_Stream0, DMA_IT_HT, ENABLE);
/* Enable the DMA Stream */
DMA_Cmd(DMA2_Stream0, ENABLE);
// ...
void DMA2_Stream0_IRQHandler(void)
{
/* Test on DMA Stream Transfer Complete interrupt */
if (DMA_GetITStatus(DMA2_Stream0, DMA_IT_TCIF0))
{
/* Clear DMA Stream Transfer Complete interrupt pending bit */
DMA_ClearITPendingBit(DMA2_Stream0, DMA_IT_TCIF0);
// Process second half of sample buffer
}
/* Test on DMA Stream Half Transfer interrupt */
if (DMA_GetITStatus(DMA2_Stream0, DMA_IT_HTIF0))
{
/* Clear DMA Stream Half Transfer interrupt pending bit */
DMA_ClearITPendingBit(DMA2_Stream0, DMA_IT_HTIF0);
// Process first half of sample buffer
}
}

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
orn
Associate II
Posted on October 22, 2012 at 22:48

as always you are very kind! unfortunately an electrical blackout prevented me to try your suggestions.

I tried to do something like this before, usually start with an example and try to change it, but I can not always understand everything, because it is only recently that I work with microcontrollers. thank you very much for your help :D

orn
Associate II
Posted on October 23, 2012 at 10:39

The original post was too long to process during our migration. Please click on the provided URL to read the original post. https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I6lw&d=%2Fa%2F0X0000000bv1%2FyD5UCb82IPunTgafbzcK.0Kek0nmHPjp50NjbjybzaM&asPdf=false
orn
Associate II
Posted on October 23, 2012 at 13:09

I solved this way! I hope I did the right reason!

I did a check on the interrupt, increasing the index in the interrupt routin rather than in the main.

//interrupt routine
void DMA2_Stream0_IRQHandler(void)
{
/* Test on DMA Stream Transfer Complete interrupt */
if (DMA_GetITStatus(DMA2_Stream0, DMA_IT_TCIF0))
{
VetVin[i]=ADC3ConvertedValue[0]*K_adc/0xFFF; //recupero i valori dei segnali acquisiti per poi elaborarli
VetIin[i]=ADC3ConvertedValue[1]*K_adc/0xFFF; //K_adc è la costante di conversione che porta i valori dell'adc
VetVout[i]=ADC3ConvertedValue[2]*K_adc/0xFFF;
i=i+1;
if(i==100) {i=0; ok=1;}
/* Clear DMA Stream Transfer Complete interrupt pending bit */ 
DMA_ClearITPendingBit(DMA2_Stream0, DMA_IT_TCIF0);
}

Main:

while (1)
{ 
if(ok==1){
ok=0;
DMA_ITConfig(DMA2_Stream0, DMA_IT_TC, DISABLE); 
for(j=0;j<100;j++){
printf(''Vin=%d
 - '',VetVin[j]); 
printf(''Iin=%d
 - '',VetIin[j]);
printf(''Vout=%d
 - '',VetVout[j]);
STM_EVAL_LEDOn(LED6);
}
DMA_ITConfig(DMA2_Stream0, DMA_IT_TC, ENABLE);
}
}
}

:)
Posted on October 23, 2012 at 15:28

I'm not sure why you wouldn't capture a much larger sample, and then interrupt. The HT/TC method won't work with 3 samples, 3 x 100 x 2 would be a more optimum course.

There is also the problem of sampling too quickly, and too often. I'm really not sure you're going to get accurate results at 3 cycles, and you should perhaps be pacing the sampling so you get X sample per seconds, rather than just saturating the ADC, and the system with interrupts.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..