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!
Quick Update:
The updated SWI handler is not working.
Xiao
It is really frustrating problem.
I use the RTOS when I first started this project and RTOS stops randomly. I was told by some posts on this forum that Keil has a fix for the "RTOS stop" (related to interrupt detection).
I stopped using RTOS and have the same problem again. I think there something wrong in this compiler dealing with the interrupt. Actually RTOS does the pretty much same thing as I do. Both use SWI very offen.
Regards, Xiao