m_a_d_i_s wrote on Wednesday, October 24, 2007:
Hi!
I have an interesting problem here related to ISR-s. ISR-s are started as in case of FreeRTOS demos etc.:
void vUSB_ISR( void ) __attribute__ ((naked));
/*-----------------------------------------------------------*/
void vUSB_ISR( void )
{
/* This ISR can cause a context switch. Therefore a call to the
portENTER_SWITCHING_ISR() macro is made. This must come BEFORE any
stack variable declarations. */
portENTER_SWITCHING_ISR();
/* Now variables can be declared. */
Which is followed by local variable declarations. But I noticed that when I declare too many local variables, funny things will happen. So I started to debug the entering to ISR-s. IRQ stack pointer is located at 0xfff0 as expected (part is SAM7X256 with 64K RAM and I debug in RAM). Stack sizes are declared like:
/* Stack Sizes */
.set UND_STACK_SIZE, 0x00000004
.set ABT_STACK_SIZE, 0x00000004
.set FIQ_STACK_SIZE, 0x00000004
.set IRQ_STACK_SIZE, 0X00002000
.set SVC_STACK_SIZE, 0x00000800
So IRQ stack is empty. But do to the naked attribute stack pointer is not modified while entering to the ISR. I think thats the expected action, as there is asm macro included, that enter_isr? But now the local variables are situated above the stack pointer…? So in case I declare enough local variables in ISR, it overwrites my vector table. I verified it with debugger. while declaring the local variables and initialising them, asm code generated is:
portCHAR cTaskWokenByPost = pdFALSE;
0x00001454 <vAudio_ISR+96>: mov r3, #0 ; 0x0
0x00001458 <vAudio_ISR+100>: strb r3, [sp, #11]
while stack pointer stays at the beginning of IRQ stack 0xfff0.
C flags are:
CPFLAGS = $(MCFLAGS) -mthumb-interwork $(OPT) -ggdb -fomit-frame-pointer -ffunction-sections -fdata-sections -Wall -Wextra -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wno-strict-aliasing -fverbose-asm -Wa,-ahlms=$(<:.c=.lst) $(DEFS)
CPFLAGS += -MD -MP -MF .dep/$(@F).d
arm-elf-gcc version is 4.1.1 which was included with yagarto toolchain.
Can anybody point me whats wrong with my code, cflags or something else?
Thank you,
Madis