Posted on:
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
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
start:
/* 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
undef_instr_handler:
mov r0, lr
mov r1, #0
b UIE
software_int_handler:
reserved_handler:
movs pc, lr
prefetch_abort_handler:
sub r0, lr, #4
mov r1, #1
b UIE
data_abort_handler:
sub r0, lr, #8
mov r1, #2
b UIE
irq_handler:
bl UIE
fiq_handler:
b UIE
UIE:
b UIE
irq_stack:
.word 0x0badc0de
fiq_stack:
.word 0x0badc0de
end: |
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) { ClearPending(BIT_TIMER2); binary_leds(); } U16 i=0,tmp=0; /* temporary needed to binary counter*/ int main (void) { init_timer(); 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)*/ rGPBCON|=0x0015400; 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) { tmp++; i=tmp; i = (~i)<<5; rGPBDAT|=0x1e0; rGPBDAT &= i; } |
Posted on:
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.
Posted on:
Ok, I downloaded uCOS-II but there is startup for ADS. I use gcc and this file doesn't fit. Any idea?
Posted on:
port the files to GCC or have a look at the RT-Thread project: http://code.google.com/p/rt-thread/
Posted on:
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.