三星4510B处理器,ADS版本1.2。在调试一段PDIUSBD12程序时总是卡在一个地方,过不去。出错程序如下(带中括号的行都是翻译程序后对应的汇编语句): #include "4510.h"
#define alloff 0x3ffff #define allon 0x0
void delay(unsigned int x) { unsigned int i; unsigned int j; for(i=0;i<x;i++) [0xe3a02000] mov r2,#0 [0xea000004] b 0x4001d0 ; (delay + 0x1c) ...... [0xe2822001] add r2,r2,#1 [0xe1520000] cmp r2,r0 [0x3afffff8] bcc 0x4001bc ; (delay + 0x8) for(j=0;j<230;j++); [0xe3a01000] mov r1,#0 [0xe2811001] add r1,r1,#1 [0xe35100e6] cmp r1,#0xe6 [0x3afffffc] bcc 0x4001c0 ; (delay + 0xc) } [0xe1a0f00e] mov pc,r14
void write_usb_command(unsigned char usb_command) { command_usb=usb_command;//写入命令 [0xe59f1084] ldr r1,0x00400268 ; = #0x03fd4000 [0xe5c10001] strb r0,[r1,#1] //每次程序都是卡在这一条语句了,但是看不出来有什么错误啊。 } [0xe1a0f00e] mov pc,r14
void write_a_usb_data(unsigned char usb_data) //写一字节USB数据 { data_usb=usb_data; [0xe59f1078] ldr r1,0x00400268 ; = #0x03fd4000 [0xe5c10000] strb r0,[r1,#0] } [0xe1a0f00e] mov pc,r14
int main(void) { [0xe52de004] * str r14,[r13,#-4]! IOPCON=0x0000; [0xe59f206c] ldr r2,0x0040026c ; = #0x03ff5000 [0xe3a03000] mov r3,#0 [0xe5823004] str r3,[r2,#4] IOPMOD=0x3ffff; [0xe59f0064] ldr r0,0x00400270 ; = #0x0003ffff [0xe5820000] str r0,[r2,#0] write_usb_command(0xD0); [0xe3a000d0] mov r0,#0xd0 [0xebfffff1] bl write_usb_command write_a_usb_data(0xf0); [0xe3a000f0] mov r0,#0xf0 [0xebfffff2] bl write_a_usb_data IOPDATA=allon; [0xe5823008] str r3,[r2,#8] delay(100); [0xe3a00064] mov r0,#0x64 [0xebffffe2] bl delay write_usb_command(0xd8); [0xe3a000d8] mov r0,#0xd8 [0xebffffea] bl write_usb_command write_a_usb_data(0x01); [0xe3a00001] mov r0,#1 [0xebffffeb] bl write_a_usb_data delay(100); [0xe3a00064] mov r0,#0x64 [0xebffffdc] bl delay write_usb_command(0xf3); [0xe3a000f3] mov r0,#0xf3 [0xebffffe4] bl write_usb_command write_a_usb_data(0xDA); [0xe3a000da] mov r0,#0xda [0xebffffe5] bl write_a_usb_data write_a_usb_data(0xCB); [0xe3a000cb] mov r0,#0xcb [0xebffffe3] bl write_a_usb_data }
中括号所对应的行都是通过AXD的反汇编功能查看的。程序总是卡在我写注释的地方,在点击“停止”后AXD提示“error:read,mode=255,id=ff0010”或者id为其他一些值。在4510.h中关于PD12我是这样定义: #define VPchar *(volatile unsigned char *) #define command_usb (VPchar(0x3FD4001)) //PD12命令 #define data_usb (VPchar(0x3FD4000)) //PD12数据 请高手指点!!!谢谢了。 |