Systick interrupt function not getting called on stm32F103RB nucleo board
<p>I am trying to implement a very simple program to call a function from systick interrupt on stm32f103rb board. The program runs fine but it never calls the interrupt function. I have gone through many fourms and experimented with different register values but I am not sure what I am missing here. My startup program and test program are below:</p>

<p>startup.s ::</p>

<pre><code>         .data 
arr:    .4byte 0x20001000        @ Read-only array of bytes
        .4byte start+1     
        .4byte reset1
        .4byte reset2
        .4byte reset3
        .4byte reset4
        .4byte reset5
        .4byte reset6
        .4byte reset7
        .4byte reset8
        .4byte reset9
        .4byte reset10
        .4byte reset11
        .4byte reset12
        .4byte reset13
        .4byte reset14
        .4byte reset15
        .4byte reset16
eoa: 
        .text
reset1: b reset1
reset2: b reset2
reset3: b reset3
reset4: b reset4
reset5: b reset5
reset6: b reset6
reset7: b reset7
reset8: b reset8
reset9: b reset9
reset10: b reset10
reset11: b sysTickFunc
reset12: b sysTickFunc
reset13: b sysTickFunc
reset14: b sysTickFunc
reset15: b sysTickFunc
reset16: b sysTickFunc
start:                           @ Label, not really required
        mov   r4, #4             @ Load register r0 with the value 5
        mov   r5, #5             @ Load register r1 with the value 4
        add   r6, r4, r5         @ Add r0 and r1 and store in r2
        ldr   r4, =0x40021000
        str   r1, [r4]
        cpsie i
        b test_func
stop:   b stop                   @ Infinite loop to stop execution
</code></pre>

<p>Test.c - test function and systick function implementation::</p>

<pre><code>#define SYSTICK_CTRL     (volatile unsigned int *)( 0xE000E010 )
#define SYSTICK_LOAD     (volatile unsigned int *)( 0xE000E014 )
#define SYSTICK_VAL      (volatile unsigned int *)( 0xE000E018 )

#define PORT_C_CRL   (volatile unsigned int *)( 0x40011000 )
#define PORT_C_CRH   (volatile unsigned int *)( 0x40011004 )
#define PORT_C_ODR   (volatile unsigned int *)( 0x4001100C )
#define APB2         (volatile unsigned int *)( 0x40021018 )
#define AHB          (volatile unsigned int *)( 0x40021014 )

void sysTickFunc(void);
void test_func(void)
{
    volatile unsigned int * p;
    unsigned int x;
    p = SYSTICK_CTRL;
    *p = 7;   /*CLKSRC to processor clock, TICK INT is 1, COUNTER ENABLE is 1  */
    p = SYSTICK_LOAD;
    *p = 20;
    p = (volatile unsigned int *)( 0xE000E01C );
    *p = 0x00002328;
    x = 0;
    /* loop in while and check if systick function is called */
    while(1)
    {

       x++;
    }       
}


void sysTickFunc(void)
{
    while(1)
    {
        asm("mov r0,0xCCCCCCCC;");
        asm("mov r1,0xDDDDDDDD;");
        asm("mov r2,0xBBBBBBBB;");
        asm("mov r3,0x11111111;");
        asm("mov r4,0x22222222;");
        asm("mov r5,0x33333333;");
        asm("mov r6,0x44444444;");
    }
}
</code></pre>

<p>Linker file:</p>

<pre><code>SECTIONS {
   . = 0x08000000;
   .data : { * (.data)}
   . = 0x08003000;
   .text : {* (.text)} 
}
</code></pre>

<p>build script:</p>

<pre><code>arm-none-eabi-gcc -nostdlib -mcpu=cortex-m3 -mthumb -g -o add.elf -T stm.ld test.c startup.s
arm-none-eabi-objcopy -O binary add.elf add.bin
dd if=/dev/zero of=flash.bin bs=4096 count=4096
dd if=add.bin of=flash.bin bs=4096 conv=notrunc
</code></pre>

<p>Can someone help me what is wrong in my code? When I run it with arm gdb on ubuntu, I never get my systick function called. ( I know I have put systick function in many places in the vector table. It was an attempt to check the possibility of sysTickFunction not being at right location in the vector table. )</p>

<p>Thanks
Ravi</p>