Atmel website | ARM Community | AVR freaks | Technical Support
Banner
 FAQ •  Search •  Register •  Login 

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Prefetch abort & spurious interrupt
PostPosted: Wed Jun 24, 2009 8:03 am 
Offline

Joined: Wed Feb 25, 2009 8:33 am
Posts: 6
Hi all,

I am working with AT91SAM7SE32 arm7tdmi core. I am frequently getting the prefetch abort and spurious interrupt problem. The description of the problem is as below.
It would be great if you can give some suggestions over it too.

1) Prefetch Abort - I am getting it when working with flash writing and unlocking. (especially when executing the below code in function EFC_PerformCommand in EFC.c)

pEfc->EFC_FCR = (0x5A << 24) | (argument << 8) | command;

When I am step debugging this command, there is no problem in writing to flash, but when I give a breakpoint just after this, and give it a run, the execution will be stuck in prefetch abort vector.

2) Spurious Interrupt - When getting too many interrupts in IRQ0 and SPI as well. Basically, its repeating when multiple interrupts are interrupting at a very fast rate.

Please suggest me if you have any ways to handle these 2 critical problems.

Regards
Pradeep


Top
 Profile  
 
 Post subject: Re: Prefetch abort & spurious interrupt
PostPosted: Wed Jun 24, 2009 3:24 pm 
Offline

Joined: Wed Jun 07, 2006 10:52 pm
Posts: 60
When you write to flash, are you executing that function out of ram or flash? If it's in flash, it's going to get hung up.

As for the spurious interrupts, in the low level init file (sets up the processor clock speed, wait cycles for flash etc etc) there should be a part where it defines the default handlers for interrupts:

Quote:
AT91C_BASE_AIC->AIC_SVR[0] = (int) AT91F_Default_FIQ_handler ;
for (i=1;i < 31; i++)
{
AT91C_BASE_AIC->AIC_SVR[i] = (int) AT91F_Default_IRQ_handler ;
}


add in this line to the end:
Code:
AT91C_BASE_AIC->AIC_SPU  = (int) AT91F_Spurious_handler ;


You then have to write a handler for the spurious interrupts:
Code:
void AT91F_Spurious_handler(void)
{
   // Acknowledge the broken interrupt
   AT91F_AIC_AcknowledgeIt(AT91C_BASE_AIC);

   // Return nothing so we move on with life
   return;
}


That will catch all the spurious interrupts and stop them from mucking up your system.


Top
 Profile  
 
 Post subject: Re: Prefetch abort & spurious interrupt
PostPosted: Thu Jun 25, 2009 7:36 am 
Offline

Joined: Wed Feb 25, 2009 8:33 am
Posts: 6
Hi ancaritha,
Thanks for the reply.

1) I am running the code from flash. That might be a problem, which I had not thought about. Is there any way to overcome this. Because I have a limited RAM size of 8K, where in I am not able to put the whole code in RAM and test.

2) I handled the spurious vector as you had shown. Its working fine. Thank you very much.


Regards
Pradeep


Top
 Profile  
 
 Post subject: Re: Prefetch abort & spurious interrupt
PostPosted: Thu Jun 25, 2009 8:31 pm 
Offline

Joined: Wed Jun 07, 2006 10:52 pm
Posts: 60
There is a way to define just specific functions in RAM, which is what I do. I got these instructions from Martin Thomas over at http://embdev.net/forum/arm-gcc, so all credit goes to him. Now let me just find what I had to change... I know it required a couple of changes in different places... Been a long time since I looked at this code :P

OK, so here are the two functions that I have in RAM

Code:
RAMFUNC int AT91F_Flash_Status (unsigned int Mask)
{
    unsigned int status;
    status = 0;

    //* Wait the end of command
   while ((status & Mask) != Mask )
   {
      status = AT91C_BASE_MC->MC_FSR;
   }
   return status;
}

RAMFUNC void flushPage(U32 nPageAddr)
{
   U32 nPage = nPageAddr >> 8;

    //  Set number of Flash Waite sate
    //  SAM7A3 features Single Cycle Access at Up to 30 MHz
    //  if MCK = 47923200, 72 Cycles for 1.5 µseconde (field MC_FMR->FMCN)
    AT91C_BASE_MC->MC_FMR = ((AT91C_MC_FMCN) & (72 <<16)) | AT91C_MC_FWS_1FWS;

    // Write the write page command
    AT91C_BASE_MC->MC_FCR = AT91C_MC_CORRECT_KEY | AT91C_MC_FCMD_START_PROG | (AT91C_MC_PAGEN & (nPage << 8));

   // OPTIONAL WRITE COMMAND--- THIS ONE WON'T ERASE MEMORY FIRST!
    //AT91C_BASE_MC->MC_FCR = AT91C_MC_CORRECT_KEY | AT91C_MC_FCMD_START_PROG | (AT91C_MC_PAGEN & (nPage << 8) | AT91C_MC_NEBP);

    // Wait the end of command
    AT91F_Flash_Status(AT91C_MC_EOP);
}


RAMFUNC is defined as:
Code:
#define RAMFUNC __attribute__ ((long_call, section (".fastrun")))


Now we get to modify the linker file! For me, that file is: AT91SAM7A3-ROM.ld

Head down to where it creates the .data section, and add in .fastrun at the end of it:

Code:
/* .data section which is used for initialized data */
  .data : AT (_etext)
  {
    _data = .;
    PROVIDE (__os_data_start = .);       
    *(.osData)
    PROVIDE (__os_data_end = .);
    *(.data)
   *(.data.*)
   *(.gnu.linkonce.d*)   
   SORT(CONSTRUCTORS) /* mt 4/2005 */
   . = ALIGN(4);
   *(.fastrun)         /* "RAM-Functions" */ /* added by mthomas */
  } > RAM


Your linker script likely will not have an .osData section, that's something else I added. It may or may not have the SORT(CONSTRUCTORS) either, as that is for getting C++ to work.

I believe those are the only two changes you have to make. Hopefully it'll work for you!


Top
 Profile  
 
 Post subject: Re: Prefetch abort & spurious interrupt
PostPosted: Wed Jul 21, 2010 11:00 am 
Offline

Joined: Wed Jul 21, 2010 10:53 am
Posts: 1
Regarding the handler, does it need the __irq and __arm specifiers? (I am using the IAR toolset). Is there a way to test this handler in practice?
Regards

Quote:
You then have to write a handler for the spurious interrupts:
Code:
void AT91F_Spurious_handler(void)
{
   // Acknowledge the broken interrupt
   AT91F_AIC_AcknowledgeIt(AT91C_BASE_AIC);

   // Return nothing so we move on with life
   return;
}


That will catch all the spurious interrupts and stop them from mucking up your system.


Top
 Profile  
 
 Post subject: Re: Prefetch abort & spurious interrupt
PostPosted: Tue Aug 31, 2010 4:53 pm 
Offline

Joined: Sun Jan 20, 2008 8:14 pm
Posts: 2
Hi,

i have the same problem as pradeepit now.

My program gets stuck after executing:
pEfc->EFC_FCR = (0x5A << 24) | (argument << 8) | command;
in efc.c, in the function EFC_PerformCommand().

I have checked, that the Function runs in the RAM.

For testing purpose, i wrote a small testprogram, to ensure the functionalitiy of the FLASHD_xxx functions. There i worte a 256 Byte buffer successfully to the flash.
But in my main-project the processor get stuck and halts in abort-mode after executing the write-command to EFC_FCR.

What could be the source of the error?
I also already tried to disable all Interrupts in the AIC, with no effect.

kind regards

PS: i'm using WinARM with the Atmel Library V1.5


Top
 Profile  
 
 Post subject: Re: Prefetch abort & spurious interrupt
PostPosted: Wed Sep 01, 2010 8:35 pm 
Offline

Joined: Thu Dec 02, 2004 2:28 pm
Posts: 454
zeilhofer wrote:
Hi,

i have the same problem as pradeepit now.

My program gets stuck after executing:
pEfc->EFC_FCR = (0x5A << 24) | (argument << 8) | command;
in efc.c, in the function EFC_PerformCommand().

I have checked, that the Function runs in the RAM.

For testing purpose, i wrote a small testprogram, to ensure the functionalitiy of the FLASHD_xxx functions. There i worte a 256 Byte buffer successfully to the flash.
But in my main-project the processor get stuck and halts in abort-mode after executing the write-command to EFC_FCR.

What could be the source of the error?
I also already tried to disable all Interrupts in the AIC, with no effect.

kind regards

PS: i'm using WinARM with the Atmel Library V1.5

hello
posting your code would make things easier.

regards
gerhard


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 26 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: