www.pudn.com > jtagsrc.rar > main.c
#include#include #include "types.h" #include "tool.h" #include "jtag.h" #include "xjerr.h" #include "tapctrl.h" #include "./arm7tdmi/arm7tdmi.h" /* * 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}; int main() { int status; int i; u32 pc; //Init ... jtag_init(); tapctrl_init(); arm7tdmi_init(); /**************************TESTING****************************/ /* * Enter DEBUG state by force to download debug program */ status = arm7tdmi_enter_dbgstat(&pc); if(status != XJ_OK) printf("Failed to enter DEBUG state\n"); //Write the program to memory location 0x200000 status = arm7tdmi_mem_wri32(0x200000, (u32*)ads, 25); if(status != XJ_OK) printf("Failed to download program\n"); //Before start, set a breakpt @ 0x200000 status = arm7tdmi_set_breakpt(0x200000); if(status != XJ_OK) printf("Failed to set breakpt\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"); //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; }