This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

compiler issue

hello all,
i have one arm7 kit of lpc2148. and one IDE is provided with it, its name is SCARM,
i have written one simple program of led on-off in SCARM and downloaded it and it is working fine.
When i wrote the same program in keil, and i included its header file and startup file. compilation is successful.but when i downloaded the file in same board it is not responding.
i want to solve this problem. is it because of startup file or something else?
and i want to use keil as SCARM code size is restricted to only 2Kbyte.
pls help me
thank you

  • hello sir,
    thanks for the reply.
    how to solve the problem of startupt file. what all changes should i do for keil startup file.
    i directly included the startup file of SCARM but it is not working. and the assembly language of it is different. so how to go about it?
    pls guide me
    thank you

  • It would be more helpful if you would provide a link to it!

    Do you mean this: www.spjsystems.com/scarm.htm ?

  • The problem may not be the startup file - it may be "something else".

    You have given absolutely no details whatsoever about the startup file that you've used, and absolutely no details whatsoever about the rest of your application - so how on earth do you expect anyone to be able to say what might be wrong, or where?!

    It's like saying, "my car won't work; what's wrong with it?" - when we don't even know what car you have!

    But, if your code looks like this www.spjsystems.com/scarm.htm then it's highly likely to be an Optimisation issue - search the forum about using software delay loops in High-Level Languages (HLLs)...

    See: www.8052.com/.../175943

    See also: www.8052.com/.../162556

    etc, etc,...

  • hello again,
    thanks for reply. yes the site is same.
    here is startup file for LPC2148 in keil:

    and another startup.asm for SCARM

    /*
            startup.asm
            Revison 1.1, dated 9 August 2005.
    */
    
    .section .text
    .code 32
    @.globl vectors
    
    vectors:
            b reset                 @ Reset
            b .                     @ Undefined instruction
            b .                     @ SWI
            b .                     @ Prefetch abort
            b .                     @ Data abort
            b .                     @ reserved vector
    @ The following instruction should transfer control to
    @ the vector corresponding to ISR of IRQ
    @ Most ARM micro-controllers include a built-in
    @ Interrupt Controller. One example is the LPC2138.
    @ It includes the VIC interrupt controller.
    @ It will automatically put appropriate jump address
    @ into the register "VICVectAddr" - provided the VIC
    @ is configured appropriately by the user.
    @ So the following instruction simply copies the contents
    @ of "VICVectAddr" into PC.
    @ This instruction is appropriate, if you are using
    @ LPC2138 micro-controller (or it's cousins)
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @ NOTE: You may need to change the following instruction
    @ to make it work correctly for other ARM micro-controllers.
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
            ldr     pc,[pc,#-0xFF0] @ irqs (to VICVectAddr)
            b .                     @ fast irqs
    
    
    reset:
    @ clear .bss section
            ldr r1, bss_start
            ldr r2, bss_end
            ldr r3, =0
    
    clear_bss:
            cmp r1,r2
            strne r3,[r1],#+4
            bne clear_bss
    
    do_init:
            ldr     r1,initdata_start       @ start address of init table
            ldr     r2,initdata_end         @ end address of init table
    do1init:cmp     r1,r2
            bhs     init_done
            ldr     r0,[r1],#4      @ destination address
            ldr     r3,[r1],#4      @ number of bytes to copy
    copy_loop:
            ldrb    r4,[r1],#1      @ read 1 byte from source
            strb    r4,[r0],#1      @ write 1 byte to destination
            subs    r3,r3,#1
            bne     copy_loop
    @ now align the address in R1 to 4 bytes boundry
            add     r1,r1,#3
            and     r1,r1,#~3
            b       do1init
    init_done:
    @ init sp for supervisor (default) mode
            ldr     r13,stack_pointer
    
    @ init sp for IRQ mode
            mrs     r0,cpsr
            bic     r1,r0,#0x1F
            orr     r1,r1,#0x012    @ IRQ mode= 0x12
            msr     cpsr_c,r1
            ldr     r13,irq_stack
    
    @  enable IRQs & return to supervisor mode
            bic     r0,r0,#0x80     @ cpsr[7]=IRQ disable flag
            msr     cpsr_c,r0
    
    @ run C program
    
            bl main
    
    here:   b here
    
    stack_pointer:  .word   _stack_top
    irq_stack:      .word   _irq_stack_top
    bss_start:      .word   __bss_start__
    bss_end:        .word   __bss_end__
    initdata_start: .word   __initdata_start__
    initdata_end:   .word   __initdata_end__
            .end
    
    
    


    pls help.
    and my c code is:

    #include <stdio.h>
    #include "LPC2148.h"
    #include "mainhdr.h"
    
    
    
    int main(void) { // init_pll(); // init_mam(); // init_vpb(); init_port();
    while(1) { IO0SET = 0xffffffff; // delay(5000);
    // IO0CLR = 0xffffffff; // delay(5000);
    }
    } /* void init_pll(void) { //system clock //PLLCFG = 0x00100100; //p=2 (PSEL=01) and m=5-1 (MSEL=00100) PLL0CFG = 0x22; //48Mhz m = 4-1 = 3 i.e 00010 // PLLCFG = 0x23; //60Mhz m=5-1=4 i.e 00011 PLL0CON = 0x01;
    PLL0FEED = 0xaa; PLL0FEED = 0x55;
    while((PLL0STAT & 0x400) == 0);
    PLL0CON = 0x03;
    PLL0FEED = 0xaa; PLL0FEED = 0x55;
    //usb clock //PLL48CFG = 0x00100011; //p=2 (PSEL=01) and m=4-1 (MSEL=00011) PLL1CFG = 0x23; PLL1CON = 0x01;
    PLL1FEED = 0xaa; PLL1FEED = 0x55;
    while((PLL1STAT & 0x400) == 0);
    PLL1CON = 0x03;
    PLL1FEED = 0xaa; PLL1FEED = 0x55; } */ void init_mam(void) { MAMTIM = 0x00000001; MAMCR = 0x02; }
    void init_vpb(void) { VPBDIV = 0x01; }
    void init_port(void) { SCS = 0x00000000; PINSEL0 = 0x00000000; //all gpio IO0DIR = 0xffffffff; //p0.15 as output IO0CLR = 0xffffffff; //p0.15 = 1 }
    void delay(uint a) { uint i,j; for(i=0;i<a;i++) { j = 0; } }

  • hello again,
    and arm startupt file is already present in keil4 folder which we get after installation
    thank you

  • hello andrew neil
    are you there?

  • hello all,
    pls help me in startup file
    thank you

  • Why do you insist that it's the startup file?

    Have you actually read anyhing that I've said to you so far?
    Have you read the articles that I linked?

    Have you spent any time debugging your code?

    Keil provide plenty of "blinky" examples - have you looked at any of those?

  • hello sir,
    thanx for your reply. and problem was in startup file only. and i am using board of other company and developing code on keil. so i disabled the PLL,MAM,VPBDIV functions in startup file.
    i added target.c file to my project and now simple program of led blinking is working.
    thanks for your help and i saw the links mentioned by you. but my problem was not related to these links.
    thanks for your help and support.
    regards

  • How do you know that?

    What, exactly, was the problem?

  • Maybe not this time - but do you now understand the issues?

    Do you now understand how compiler optimisation could break such code?
    (in fact, compiler optimisation is likely to break such code!)

    Do you now understand how to write code that will not be broken by compiler optimisation?