各位老师,我最近打算学习ARM处理器,使用JZ2440开发板熟悉硬件逻辑,一边看着韦东山老师的视频和书,一边将其中的代码用ADS1.2 + JLink调试
当看到SRAM这一章节的时候,调试程序在SRAM中运行。但是每当执行汇编跳转到SRAM指令后运行不久,调试器便报错,苦思不知原因何在,特请教各位前辈,网不吝赐教
错误信息见附件
跳转后的地址也不对,链接地址是0x30000000, 但是跳转之后的地址为0x33f80400, 韦东山老师讲解的地址应该是0x30000010
代码如下:
2440init.s
IMPORT main
IMPORT Key_Led_Init
IMPORT SRAM_Init
IMPORT CopyProgrameToSRAM
CODE32
AREA Init,CODE,READONLY
ENTRY
ldr r0, =0x53000000
mov r1, #0x0
str r1, [r0]
ldr sp, =1024 * 4
bl SRAM_Init
bl CopyProgrameToSRAM
ldr pc, =on_sdram
on_sdram
bl main
main_loop
b main_loop
END
*****************************************************
main.c
int main()
{
#if 1
Key_Led_Init();
while(1)
{
Key_Led_Proc();
}
return 0;
#endif
return 0;
}
****************************************************
SRAM.c
static int MemoryInitData[] =
{
0x22011110, // BWSCON
0x00000700, // BANKCON0
0x00000700, // BANKCON1
0x00000700, // BANKCON2
0x00000700, // BANKCON3
0x00000700, // BANKCON4
0x00000700, // BANKCON5
0x00018005, // BANKCON6
0x00018005, // BANKCON7
0x008C07A3, // REFRESH
0x000000B1, // BANKSIZE
0x00000030, // MRSRB6
0x00000030, // MRSRB7
};
/**********************************************
SRAM初始化
**********************************************/
void SRAM_Init(void)
{
long i = 0;
for(i = 0; i < 13; i++)
{
*(volatile long *)(MemoryBase + 4 * i) = MemoryInitData[i];
}
}
/**********************************************
复制程序到SRAM中
**********************************************/
void CopyProgrameToSRAM(void)
{
long i;
for(i = 0; i < StepingStoneSize; i++)
*(volatile long *)(SRAM_Base + 4 * i) = *(volatile long *)(StepingStoneBase + 4 * i);
}
******************************************************************
Key_Led.c
int Key_Led_Status_Now = KEY_SCAN;
/****************************************************
按键初始化
****************************************************/
void Key_Led_Init()
{
GPFCON = 0;
GPFDAT = 0;
GPFUP = 0xFFFF;
GPGCON = 0;
GPGDAT = 0;
GPGUP = 0xFFFF;
GPFCON = LED1_Out | LED2_Out | LED4_Out;
GPFUP &= ~((1 << 0) | (1<<2));
GPGUP &= ~(1 << 3);
LED1_Off();
LED2_Off();
LED4_Off();
Key_Led_Status_Now = KEY_SCAN;
}
/****************************************************
按键扫描处理
****************************************************/
void Key_Led_Proc()
{
static int KeyFilter = 0;
static uint8 S2Enable = 0;
static uint8 S3Enable = 0;
static uint8 S4Enable = 0;
switch(Key_Led_Status_Now)
{
case KEY_SCAN:
if((GPFDAT & S2_DAT) == 0 || (GPFDAT & S3_DAT) == 0 || (GPGDAT & S4_DAT) == 0)
{
KeyFilter = 0;
Key_Led_Status_Now = KEY_FILTER;
}
else
{
LED1_Off();
LED2_Off();
LED4_Off();
S2Enable = 0;
S3Enable = 0;
S4Enable = 0;
}
break;
case KEY_FILTER:
if((GPFDAT & S2_DAT) == 0 || (GPFDAT & S3_DAT) == 0 || (GPGDAT & S4_DAT) == 0)
{
KeyFilter ++;
if(KeyFilter >= 1000)
{
KeyFilter = 0;
Key_Led_Status_Now = KEY_ENSURE;
}
}
else
Key_Led_Status_Now = KEY_SCAN;
break;
case KEY_ENSURE:
if((GPFDAT & S2_DAT) == 0 || (GPFDAT & S3_DAT) == 0 || (GPGDAT & S4_DAT) == 0)
{
if((GPFDAT & S2_DAT) == 0)
S2Enable = 1;
if((GPFDAT & S3_DAT) == 0)
S3Enable = 1;
if((GPGDAT & S4_DAT) == 0)
S4Enable = 1;
Key_Led_Status_Now = KEY_PROC;
}
else
Key_Led_Status_Now = KEY_SCAN;
break;
case KEY_PROC:
if(S2Enable)
LED1_On();
if(S3Enable)
LED2_On();
if(S4Enable)
LED4_On();
Key_Led_Status_Now = KEY_SCAN;
break;
}
}
多谢各位老师驻足观看指点,谢谢!
|