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

in my arm program,why the program can't execute the instruction ldr pc,=main ,my program can't go into the main function,but goback to execue bl init_sdram

//head.S


.global _start
.text

_start:

ldr sp,=4095
bl  init_sdram      
bl  read_nand_to_sdram
ldr sp,=0x34000000
ldr lr,=loop
ldr pc,=main

loop:

b loop

//init.c

#include "lcd.h"

void init_sdram(void)

{

volatile unsigned int *p = BWSCON;

LOCKTIME = 0xffffffff;

MPLLCON = 0x000ad022;

CLKSLOW = 0x4;

CLKDIVN = 0x2;

CAMDIVN = 0x00;

GPHCON |= ((2 << 4) | (2 << 6));

ULCON0 = 0x03;

UCON0  = 0x0005;

UBRDIV0 = 0x49;

GPFCON = 0x5555;

GPFDAT =0x00;

p[0] = 0x22011110;     //BWSCON

    p[1] = 0x00000700;     //BANKCON0

    p[2] = 0x00000700;     //BANKCON1

    p[3] = 0x00000700;     //BANKCON2

    p[4] = 0x00000700;     //BANKCON3 

    p[5] = 0x00000700;     //BANKCON4

    p[6] = 0x00000700;     //BANKCON5

    p[7] = 0x00018005;     //BANKCON6

    p[8] = 0x00018005;     //BANKCON7

    p[9]  = 0x008C03C3;

    p[10] = 0x000000B1;     //BANKSIZE

    p[11] = 0x00000030;     //MRSRB6

    p[12] = 0x00000030;     //MRSRB7

    int i = 0;

    while(i<100000)i++;

   while(i>0)i--;

while(   !(  (1<<2) & UTRSTAT )   ) ;

UTXH0 = 'a';

}

void nand_reset()

{

 

NFCONT &= (~(1<<1));

 

NFCMMD |= 0xff;

 

while(1)

{

if(NFSTAT & 1)

{

break;

}

}

 

NFCONT |=(1<<1);

}

void init_nand()

{

/* 设置时序 */

        NFCONF |= ((0<<12)|(3<<8)|(0<<4));

        /* 使能NAND Flash控制器, 初始化ECC, 禁止片选 */

        NFCONT |= ((1<<4)|(1<<1)|(1<<0));

nand_reset();

}

void read_nand_to_sdram(void)

{     

    int i = 0;

    while(i<100000)i++;

   while(i>0)i--;

while(   !(  (1<<2) & UTRSTAT )   ) ;

UTXH0 = 'b';

init_nand();

volatile unsigned char *p = (volatile unsigned char *)0x30000000;

 

NFCONT &= (~(1<<1));

 

NFCMMD = 0x00;

 

NFADDR =0x00 ;

for(i = 0;i<10;i++);

NFADDR = 0x20;

for(i = 0;i<10;i++);

NFADDR = 0x00;

for(i = 0;i<10;i++);

NFADDR = 0x00;

for(i = 0;i<10;i++);

NFADDR = 0X00;

for(i = 0;i<10;i++);

NFCMMD = 0X30;

 

while(1)

{

if(NFSTAT & 1)

{

break;

}

}

 

 

for(i = 0;i<(16*1024);i++)

{

       p[i] = (0xff & NFDATA);

}

i = 0;

NFCONT |=(1<<1);

    while(i<100000)i++;

   while(i>0)i--;

while(   !(  (1<<2) & UTRSTAT )   ) ;

UTXH0 = 'c';

}

//lcd.lds

SECTIONS{

first 0x0000 : AT(0){ head.o init.o }

second 0x30000000 : AT(4095){ main.o }

}