阅读:1087回复:0
ezusb的汇编程序改c程序出错,请赐教!
下面是cypress提供的EZBULK.A51
$NOMOD51 ; disable predefined 8051 registers $nolist $include (..\..\..\target\inc\ezregs.inc) ; EZ-USB register assignments $list ; NAME ezbulk ; ISEG AT 60H ; stack (this app doesn't use it) stack: ds 20 ; CSEG AT 0 ljmp start ; ------------------------------------------------- org 200h ; ------------------------------------------------- start: mov SP,#STACK-1 ; set stack mov dptr,#IN2BUF mov r7,#64 ; fill EP2IN buffer with 64 bytes fill: mov a,r7 movx @dptr,a inc dptr djnz r7,fill ; load decrementing counter starting w. 64 ; mov r1,#0 ; count the IN transfers mov r2,#0 ; count the OUT transfers mov dptr,#IN2BC ; load the IN2 Byte Count register mov a,#64 ; 64 bytes movx @dptr,a ; arm the IN transfer ; loop: mov dptr,#IN2CS ; EP2IN Control & Status register movx a,@dptr jnb acc.1,service_IN2 ; check the busy bit, service if LOW mov dptr,#OUT2CS ; EP2OUT Control & Status reg movx a,@dptr jb acc.1,loop ; busy-keep checking ; service_OUT2: inc r2 ; OUT packet counter mov dptr,#IN2BUF+1 ; load OUT packet count into second IN2BUF byte mov a,r2 movx @dptr,a mov dptr,#OUT2BC ; load anything to byte count to re-arm mov a,#1 ; any value movx @dptr,a sjmp loop ; service_IN2: inc r1 ; IN packet countr mov dptr,#IN2BUF mov a,r1 ; load IN packet count into first IN2BUF byte movx @dptr,a mov dptr,#IN2BC ; load the EP2IN byte count to re-arm IN transfer mov a,#64 ; 64 byte payload movx @dptr,a sjmp loop ; END 自己修改成c之后,编译没有问题,但是运行就是不对 #include <ezusb.h> #include <ezregs.h> #include <absacc.h> main() { int r1=0,r2=0,i; for(i=64;i>0;i--) IN2BUF[64-i]=i; IN2BC=64; while(1) { if(!(EPIO[IN2BUF_ID].cntrl & bmEPBUSY)) { r1++; IN2BUF[0]=r1; EPIO[IN2BUF_ID].bytes=64; } else if(!(EPIO[OUT2BUF_ID].cntrl & bmEPBUSY)) { r2++; IN2BUF[1]=r2; EPIO[OUT2BUF_ID].bytes=1; } } } 大家帮我看看可能是什么原因?多谢了 |
|