📄 main.c
字号:
#include <windows.h>
#include <stdio.h>
#include <conio.h>
#include "types.h"
#include "tool.h"
#include "jtag.h"
#include "xjerr.h"
#include "tapctrl.h"
#include "./arm7tdmi/arm7tdmi.h"
//extern void paral_output1(u8 data);
#define BYPASS_TEST 0x55555555
#define IDCODE_LEN 0x32
//static unsigned short LP1_ADR = 0x378;
/*
* This array is a bin file of an executable program. The source code
* comes with this program. Please check the source code under directory
* ADS Example.
* The RO_BASE = 0x00200000
*/
u8 ads[100]=
{68,0,159,229,255,16,160,227,0,16,128,229,60,0,159,229,
126,16,160,227,125,32,160,227,123,48,160,227,119,64,160,227,
238,80,160,227,222,96,160,227,190,112,160,227,0,16,128,229,
0,32,128,229,0,48,128,229,0,64,128,229,0,80,128,229,
0,96,128,229,0,112,128,229,254,255,255,234,0,80,255,3,
8,80,255,3};
u8 bds[100];
int main()
{
int status;
int i;
u32 pc;
u32 addrs;
//Init ...
jtag_init();
tapctrl_init();
arm7tdmi_init();
// FILE *lp1recode;
// lp1recode = ("c:\\lp1","ab") ;
/**************************TESTING****************************/
arm7tdmi_readid(32);
status = arm7tdmi_enter_dbgstat(&pc);
if(status != XJ_OK)
printf("Failed to enter DEBUG state\n");
printf("Enter DEBUG state....OK ");
if(arm7tdmi_status.from = ARM7TDMI_FROM_ARM)
printf("[from ARM]\n");
printf("[from THUMB]\n");
printf("Core reg:\n");
status = arm7tdmi_core_rd_all();
addrs = 0x40000000;
//Write the program to memory location 0x200000
status = arm7tdmi_mem_wri32(addrs, (u32*)ads, 25);
if(status != XJ_OK)
printf("Failed to download program\n");
printf("Download program....OK\n");
arm7tdmi_mem_rd32(addrs, (u32*)bds, 25);
printf("Content of memory form :0x%x\n",addrs);
for( i=0; i<100; i++){
printf("ads[%d]=%d\tbds[%d]=%d\n",i,ads[i],i,bds[i]);
}
//Before start, set a breakpt @ 0x200000
status = arm7tdmi_set_breakpt(0x200000);
if(status != XJ_OK)
printf("Failed to set breakpt\n");
printf("Set breakpt....OK\n");
// status = arm7tdmi_clr_breakpt(0x200000);
// if(status != XJ_OK)
// printf("Failed to remove breakpt\n");
// printf("Remove breakpt....OK\n");
//Exit from DEBUG state and and start the program at 0x200000
status = arm7tdmi_exit_dbgstat(0x200000);
if(status != XJ_OK)
printf("Failed to resume the program\n");
printf("Resume the program....OK\n");
//Single step debug...
for(i = 0; i < 5; ){
Sleep(500);
//Enter DEBUG state?
status = arm7tdmi_check_dbgstat(&pc);
if(status == XJ_OK){ //Enter DEBUG state by breakpt
i++;
arm7tdmi_clr_breakpt(pc); //Clear the breakpt first
if(i != 5)
arm7tdmi_set_breakpt(pc + 4); //Set a new breakpt
arm7tdmi_exit_dbgstat(pc); //Resume the program
}
}
return 0;
}
/*static void paral_output1(u8 data)
{
_outp(LP1_ADR, data);
}*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -