Forum: ARM programming with GCC/GNU tools FIQ interrupt using asmfunc.S or startup.S

Author: Andre (Guest)
Posted on:
Attached files:

Rate this post
0 useful
not useful
I'm using the interrupt.h and asmfunc.S included in SD card project from 
Martin THOMAS website.

To use a IRQ interrupt i can use:
RegisterVector(EINT0_INT, EINT0_Routine, PRI_HIGHEST, CLASS_IRQ);

but for FIQ i don't know how can i doo that.
I've tried RegisterVector(EINT0_INT, EINT0_Routine, PRI_HIGHEST, 

but don't work.

Reading the interrupcao.h i find two procedures:
void LoadFiqRegs (long int *regs);
void StoreFiqRegs (long *regs);

I don't know how can i use this two procedures.
Anyone knows how can I use the FIQ interruption with this asmfunc.S?

Author: A. K. (prx)
Posted on:

Rate this post
0 useful
not useful
The startup code in asmfunc.S does not support FIQ. The FIQ vector runs 
into an infinite loop (Trap) and there is no stack assigned.

BTW: You did not mention the controller type.

Author: Andre (Guest)
Posted on:

Rate this post
0 useful
not useful
I changed the asmfunc.S and use a FIQ interruption, but only enter the 
procedure one time. I clean the flags of interruption but still don't 

I changed in the code:

.section .VECTOR, "ax"

  LDR  PC, [PC, #24]  @ Reset entry, jump to reset handler
  LDR  PC, [PC, #24]  @ Undef entry, trap
  LDR  PC, [PC, #24]  @ SWI entry, jump to SWI handler
  LDR  PC, [PC, #24]  @ PAbt entry, trap
  LDR  PC, [PC, #24]  @ DAbt entry, trap
  .word  0    @ Check sum (set by flash programmer)
  LDR  PC, [PC, #20]  @ IRQ entry, jump to IRQ handler
  LDR     PC, [PC, #20]  @ FIQ entry, trap

  .word  Reset_Handler  @ Reset handler
  .word  Trap    @ Undefined Instruction handler
  .word  SWI_Handler  @ Software Interrupt handler
  .word  Trap    @ Prefetch Abort handler
  .word  Trap    @ Data Abort handler
  .word  IRQ_Handler  @ IRQ handler
FIQ_Addr:  .word  FIQ_Routine


  ORR  R0, R0, #B_Fiq
  MSR  SPSR_c, R0

  BIC  R0, R0, #B_Fiq
  MSR  SPSR_c, R0

In my main function I set the Fiq interruption using:

  VICIntSelect |= 0x00004000;
  VICIntEnable = 0x00004000;

and start the while(1) loop that runs infinitaly.

When I press the button enter in the Interruptio routine:

void FIQ_Routine() {
  int k;
  //Força limpeza da interrupção (Caso de travamento)
  if ((EXTINT==1)&&(T0TC>=tempo+1000)) {
  //Pega o endereço da fonte de interrupção.
  //Verifica se foi Ext0 que interrompeu
  if(test_bit(k,0)) {
    LCD_escreveMsgLC(2,1,"Botao apertado.");

The execution back to main while(1) loop but when I pressed the button 
again the Interruption doesnt work anymore.
Anyone can help me to solve this?

Author: A. K. (prx)
Posted on:

Rate this post
0 useful
not useful
An interrupt handler as defined by the machine is called in a different 
way as normal C functions are. FIQ handlers too. Normal IRQs are wrapped 
by the handler code in the asm file, so normal C functions can be used 
as final IRQ handlers. Your FIQs however are called directly. When a C 
function is called directly by hardware, the C function must be declared 
 void FIQ_Routine () __attribute__ ((interrupt ("FIQ")));

You should also allocate some bytes for the FIQ stack. There is a 
definition for the FIQ stack size in the asm file, which was set to 0 in 
the version shown above.

Note that interrupts are intended to be fast and short, so slow LCD 
functions should not be placed withing handlers. Especially if they can 
interrupt some other LCD output sequence in main program, disturbing 
state and pin control as well as timing. A simple LED as event indicator 
for debugging (e.g. toggling) is much safer.


Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]

Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.