This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Interrupt stops randomly

Hi,

Mocroprocessor: AT91SAM7s128
Toolchain: RealView MDK-ARM Version: 3.20

I have the following ADC code need to be run while interrupts disabled to eliminate 60hz noise. So I put it inside SWI (all interrupts are disabled in SWI).

int __swi(1) GetRawCountsFromExternalADC2DataBuffer(unsigned short * P);
int __SWI_1 (unsigned short * P)
{
    unsigned int Index;
    unsigned int Sum;

    // Start the ADC
    StartPWMC();

    do    // Eliminate first reading
    {
        // Check if the ADC ready for the data
        Sum = CheckADCReady();
    }while(Sum == 0);
    SelectSpiPort(SPI_ADC);
    GetDataFromSpi();

    // Start get 1024 readins
    for(Index = 0; Index < TOTAL_SAMPLE; Index ++)
    {
        do
        {
            // Check if the ADC ready for the data
            Sum = CheckADCReady();
        }while(Sum == 0);

        SelectSpiPort(SPI_ADC);
        *(P + Index) = (unsigned short)GetDataFromSpi();
    }

    // Stop the ADC
    StopPWMC();
    return(1);
}

The problem is that all interrupts (Timer and UART) will be stopped after it runs for random time. I also
use the spuriouse interrupt handler to fix the problem, but it is not working.

The following code is used to catch the spurious interrupts.


// STORE SPURIOUS INTERRUPT HANDLER TO AIC_SPU
    AT91C_BASE_AIC->AIC_SPU = (unsigned long) SpuriousInterruptHandler;

static void SpuriousInterruptHandler(void)
{
    // END OF INTERRUPT
    AT91C_BASE_AIC->AIC_EOICR = 0; }

If I am not using disable/enable interrupts for ADC code (data with 60hz will not right), the code runs without any problem.

Any comments are appreciated!