Forum: ARM programming with GCC/GNU tools problem with startup

Author: michael (Guest)
Posted on:

Rate this post
0 useful
not useful
Dear all
I am a beginner with ARM. I use mini2440 board with s3c2440 
microcontroller. My problem is that I can't find fitting startup for 
this ARM, which configure all devices.
I would like use timer with interrupt but it doesn't work.
I found somewhere this startup:
.global vectors
    b   start
    b   undef_instr_handler
    b   software_int_handler
    b   prefetch_abort_handler
    b   data_abort_handler
    b   reserved_handler
    b   irq_handler
    b   fiq_handler

    /* enter supervisor mode, disable IRQ */
        msr     cpsr, #0xd3

             /* Disable the watchdog */
        ldr     r2, =0x00000000
        mov     r1, #0x53000000
       str     r2, [r1]

    /* Mask all Interupts to be safe */
        ldr     r2, =0xFFFFFFFF
        mov     r1, #0x4A000000
        str     r2, [r1, #0x08]

       /* Set up stack for IRQ mode */
        msr     cpsr_c, #0xd2
        ldr     sp, =irq_stack
                /* Set up stack for FIQ mode */
       msr     cpsr_c, #0xd1
        ldr     sp, =fiq_stack

        /* Let abort and undefined modes use IRQ stack */
        msr     cpsr_c, #0xd7
        ldr     sp, =irq_stack
        msr     cpsr_c, #0xdb
        ldr     sp, =irq_stack

                /* Switch to supervisor mode */
                msr     cpsr_c, #0xd3
                ldr     sp, =stackend

    /* Start the main function */
    adr     lr, vectors
    ldr     pc, =main

    mov    r0, lr
    mov    r1, #0
    b      UIE

    movs   pc, lr

    sub    r0, lr, #4
    mov    r1, #1
    b      UIE

    sub    r0, lr, #8
    mov    r1, #2
    b      UIE

    bl UIE

    b UIE

    b UIE

.word  0x0badc0de

.word 0x0badc0de

My C code:
 * timer.c
 * chip: s3c2440
 * compiler: arm-none-eabi-gcc 4.3.3
 *  Created on: 2010-02-04
 *      Author: michal grzybek
 *      This code shows how use timers to count time with interrupts.
 *      There is used timer no. 2
 *      to count one second. After this time is enable binary counter on LED's

#include "2440addr.h"
#include "Def.h"

void init_timer (void);
void binary_leds (void);

void timer_handler (void) __attribute__ ((interrupt("IRQ")));
void timer_handler (void)



U16 i=0,tmp=0;  /* temporary needed to binary counter*/

int main (void)


while (1);

return 0;

void init_timer (void)
  pISR_TIMER2  = (unsigned)timer_handler;  /* address of interrupt service routine*/
  pISR_IRQ = (unsigned)timer_handler;
  ClearPending(BIT_TIMER2);  /* interrupt timer2 requested*/
  EnableIrq(BIT_TIMER2);  /* */

  rGPBCON &= 0xffffcc;  /* mask GPBCON and clear 5th and 4th bits and buzzer off*/
  rGPBCON |= 0x000020;  /* set 5th and  4th bits at 2 binary value,
              //it's mean that GPB2 is configured as TOUT2*/

  rGPBCON&=0xfc03ff; /*Port GPB is configured for leds (GPB5,GPB6,GPB7,GPB8-output)*/

  rGPBDAT|=0x1e0;    /*LEDs are cleared*/

  rTCFG0 |= 0x0ff00;    /* prescaler configured as 255 value*/
  rTCFG1 |= 0x00300;    /* divider configured as 16 value */

  /******************* timer on ***************************/
  rTCMPB2 = 0;    /* set comparator at 0*/
  rTCNTB2 = 65000;    /* set counter to count 1 sec */
  rTCON = 0x00a000;  /* Auto-reload is on, manual update bit is set*/
  rTCON = 0x009000;  /* manual update bit is cleared, start bit is set */


void binary_leds (void)

      i = (~i)<<5;

      rGPBDAT &= i;

Author: Clifford Slocombe (clifford)
Posted on:

Rate this post
0 useful
not useful
Your start-up looks rather too minimal for an ARM9; you have no set-up 
for PLL, MMU, Cache, or SDRAM controller; or do you have a bootloader 
that is doing all that for you?

The http://www.friendlyarm.net/downloads page has a uCOS-II port 
download that includes start-up code that is probably closer to your 
requirements, even if you do not actually need the uCOS-II stuff.

Author: michael (Guest)
Posted on:

Rate this post
0 useful
not useful
Ok, I downloaded uCOS-II but there is startup for ADS. I use gcc and 
this file doesn't fit.
Any idea?

Author: Andreas (Guest)
Posted on:

Rate this post
0 useful
not useful
port the files to GCC or have a look at the RT-Thread project:

Author: Clifford Slocombe (clifford)
Posted on:

Rate this post
0 useful
not useful
This was discussed a while ago here: http://embdev.net/topic/146188

The Micrium site has generic ARM ports for GCC; they just don't make it 
too obvious where!  The thread I mentioned tells you how.


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.