Author Topic: Utasker interrupt handle  (Read 4238 times)

Offline Kuroro

  • Newbie
  • *
  • Posts: 38
    • View Profile
Utasker interrupt handle
« on: July 23, 2008, 08:39:32 AM »
Hi mark

The idea is to sample a data every 10µs, when it's done in the scan complete interupt i would like to store the data and drive an output.

So my question is :

- Where is the interupt handle called when a scan is complet ?
I think's is _ADC_convertA_interrupt bu I'm not certain.

Code: [Select]
adc_setup.int_type = ADC_INTERRUPT;                                  // identifier when configuring
    adc_setup.int_adc_bit = 7;                                        // ADC channel 7
    adc_setup.int_adc_mode = (ADC_CONFIGURE_ADC | ADC_CONFIGURE_CHANNEL | ADC_SEQUENTIAL_MODE | ADC_SINGLE_ENDED | ADC_LOOP_MODE | ADC_START_OPERATION); // single ended configuration in loop mode
    adc_setup.int_adc_speed = (unsigned char)(BUS_CLOCK/100000);         // 100KHz sampling (must be between 100kHz and 5MHz)
    adc_setup.int_priority = CAN15_INTERRUPT_PRIORITY; // Priorité de l'interuption généré
    adc_setup.int_adc_int_type = ADC_END_OF_SCAN_INT;                    // Interuption a la fin de chaque echantillonage
    fnConfigureInterrupt((void *)&adc_setup);                            // configure and start operation
 

I do it but i'm no certain to go in the right way

Thank's mark

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3191
    • View Profile
    • uTasker
Re: Utasker interrupt handle
« Reply #1 on: July 23, 2008, 02:01:42 PM »
Hi

In your code the interrupt handler is missing (this would mean that the interrupt actually does nothing).
You can add a handler with a parameter like the following_

    adc_setup.int_handler = adc_conversion_interrupt;                       // handling function

static void adc_conversion_interrupt(ADC_INTERRUPT_RESULT *adc_result)
{
    // IRQ handling code here (note that this is a callback so doesn't need to be declared as interrupt routine)
}

However I am not sure that this method is the best for 10us sampling since this is quite high speed and the routines are designed for general purpose, flexibility and ease of use. This means that you may do best when you set up the ADC in free running mode (ensure that its conversion speed is configured to be faster than your sampling rate) and then use a timer (PIT or DMA) to generate a free-running 10us interrupt. The interrupt can then directly read the ADC sample - this probably reduces overhead quite a lot.

Although more complicated and possibly not exactly what you need, it is interesting to note that a DMA timer can be configured to save sample values at a high speed to a RAM buffer without any CPU intervention. It can for example sample 10'000 values to a buffer in 1s which can then be treated by the CPU while the next 10'000 are being stored. Although not that useful fro real time sample processing it can be a nice method in some circumstances to avoid interrupt handling of each sample. The coding is however a bit trickier...

Regards

Mark

Offline Kuroro

  • Newbie
  • *
  • Posts: 38
    • View Profile
Re: Utasker interrupt handle
« Reply #2 on: July 23, 2008, 02:17:54 PM »
Thank's mark

the idea to use a timer to generate an interupt, and in this interupt store the data was good but i could be sur that an other utasker interupt was not allready activate when the timer interupt occured.
The priority of this application is to do a sample every 10µs so i need to be sur that the timer interupt would be take in care by the system a soon as they apear.
The solution of the dma see better, I will look on it.