📄 bwmeter.lst
字号:
+1 499 jb acc.b,des
+1 500 ENDM
+1 501
+1 502 JBL MACRO ad,b,des ; jump on bit low
+1 503 mov dptr,#ad
+1 504 movx a,@dptr
A51 MACRO ASSEMBLER BWMETER 06/05/2002 14:07:37 PAGE 9
+1 505 jnb acc.b,des
+1 506 ENDM
+1 507 ;
+1 508 L1_ON MACRO
+1 509 mov dptr,#0B000h
+1 510 movx a,@dptr
+1 511 ENDM
+1 512 L2_ON MACRO
+1 513 mov dptr,#0A000h
+1 514 movx a,@dptr
+1 515 ENDM
+1 516 L3_ON MACRO
+1 517 mov dptr,#09000h
+1 518 movx a,@dptr
+1 519 ENDM
+1 520 L4_ON MACRO
+1 521 mov dptr,#08000h
+1 522 movx a,@dptr
+1 523 ENDM
+1 524 L1_OFF MACRO
+1 525 mov dptr,#0B100h
+1 526 movx a,@dptr
+1 527 ENDM
+1 528 L2_OFF MACRO
+1 529 mov dptr,#0A100h
+1 530 movx a,@dptr
+1 531 ENDM
+1 532 L3_OFF MACRO
+1 533 mov dptr,#09100h
+1 534 movx a,@dptr
+1 535 ENDM
+1 536 L4_OFF MACRO
+1 537 mov dptr,#08100h
+1 538 movx a,@dptr
+1 539 ENDM
540 $list
541 NAME BWmeter
0007 542 bHSM equ 7 ; in USBCS--High Speed Mode
0001 543 bSOF equ 1 ; in USBIRQ register--an SOF has arrived
544
---- 545 ISEG AT 90H ; stack
0090 546 stack: ds 40
547 ;
---- 548 DSEG at 20H ; bit-addressable registers
0020 549 flags: ds 1 ; NOTE: all flags in this byte initialze to 0
0000 550 PKTbuf_full equ flags.0
0001 551 F_LEDtog equ flags.1 ; alternate L2-L3 every SOF
0002 552 blankflag equ flags.2 ; blank LED if 1
0003 553 F_found_HS equ flags.3 ; found the high speed mode
0004 554 F_gotPacket equ flags.4 ; got an IN or an OUT packet
0005 555 did_once equ flags.5 ; to do stuff only once when PKTbuf just filled
556 ;
---- 557 DSEG at 30H ; gp registers
0030 558 ppf: ds 1 ; packets per frame
0031 559 InCnt: ds 1 ; number of IN-8 transfers
0032 560 displaydigit: ds 1 ; hex digit to display
0033 561 maxppf: ds 1 ; max packets in a microframe
0034 562 PKTbuf: ds 64 ; 64-byte ppf-history buffer
563 ;
---- 564 CSEG AT 0
0000 020090 565 LJMP start ; jump over the interrupt vectors
566 ; -------------------------------------------------
0080 567 org 0080h
568 ; -------------------------------------------------
0080 C0F9A4B0 569 digit_table: db 0C0h,0F9h,0A4h,0B0h,99h,92h,82h,0F8h,80h,98h,88h,83h,0C6h,0A1h,86h,
08Eh
A51 MACRO ASSEMBLER BWMETER 06/05/2002 14:07:37 PAGE 10
0084 999282F8
0088 80988883
008C C6A1868E
0090 75818F 570 start: mov SP,#stack-1 ; set stack
575 ;
576 ; Comment out two of the following three statements to set 8051 clock speed
577 ;
578 ; LDREG CPUCS,#02h ; 12 MHz, CKOUT enabled (default)
579 ; LDREG CPUCS,#0Ah ; 24 MHz, CKOUT enabled
584 ;
585 ; initialize variables, buffers & pointers
586 ;
009F 515E 587 init: call lites_out
00A1 31B9 588 call reset_FIFOS
00A3 5145 589 call arm_EP24 ; arm the OUT endpoints
00A5 31D4 590 call fill_and_arm_EP8_buffers ; with 00's and 01's
00A7 5107 591 call fill_and_arm_EP6_buffers ; with EF's and FF's
00A9 753102 592 mov InCnt,#2 ; two packets are already posted-for-delivery
00AC 7834 593 mov r0,#PKTbuf ; initialize packet buffer pointer
00AE 753000 594 mov ppf,#0 ; IN packets per frame counter
00B1 753300 595 mov maxppf,#0 ; max over long haul
00B4 752000 596 mov flags,#0 ; all flags in this byte init to zero
00B7 D202 597 setb blankflag ; blank the display
00B9 516F 598 call display_hex
599 ;********************************************************************************
600 ; Main Loop. Poll flags
601 ;********************************************************************************
00BB E5AA 602 mainloop: mov a,EP2468STAT ; *** Check for EP8 full flag
00BD 20E704 603 jb acc.7,m0 ; EP8 is full--don't need to update
00C0 3149 604 call Update_EP8 ; got a free buffer--fill and arm it
00C2 8005 605 sjmp m1 ; skip EP6 test
00C4 20E502 606 m0: jb acc.5,m1 ; EP6 is full--don't need to update
00C7 315C 607 call Update_EP6 ; got a free buffer--fill and arm it
608 ;
00C9 E5AA 609 m1: mov a,EP2468STAT ; *** Check for EP4OUT-EMPTY
00CB 20E204 610 jb acc.2,m10 ; EP4OUT is empty--move on
00CE 316F 611 call Update_EP4 ; it has OUT data--re-arm it
00D0 8005 612 sjmp m2
00D2 20E002 613 m10: jb acc.0,m2 ; *** Check for EP2OUT empty
00D5 317A 614 call Update_EP2 ; EP2OUT has OUT data--re-arm it
615 ;
00DB 30E107 619 jnb acc.1,m3 ; USBIRQ.1=SOF: no SOF yet
00DE 7402 620 mov a,#00000010b ; b1 is SOF IRQ flag
00E0 F0 621 movx @dptr,a ; clear the request bit
00E1 3185 622 call got_SOF
00E3 80D6 623 sjmp mainloop
624 ;
00E9 30E507 628 jnb acc.5,m3a ; IBNIRQ.5 is EP8-NAK
00EC 7420 629 mov a,#00100000b ; EP4-IBN IRQ bit is bit 5
00EE F0 630 movx @dptr,a ; clear the bit
634 ;
00F7 30E507 638 jnb acc.5,m4 ; bit 5 is EP4
00FA 7420 639 mov a,#00100000b
00FC F0 640 movx @dptr,a ; clear the bit
644 ;
0105 20E108 648 jb acc.1,m4a ; bit 1 is BUSY bit
010E 808F 653 jmp init ; *** START OVER
654 ;
0114 20E104 658 jb acc.1,m5 ; busy--waiting for USB data
0117 90E68D 659 mov dptr,#EP1OUTBC ; any value in acc will do
011A F0 660 movx @dptr,a ; Re-arm it so we don't hang the control panel
661 ;
662 ; *** Check for high-speed operation
663 ;
011B 20030D 664 m5: jb F_found_HS,m6 ; don't need to check for HS mode any more
0129 D203 672 setb F_found_HS ; set flag so won't continue checking
A51 MACRO ASSEMBLER BWMETER 06/05/2002 14:07:37 PAGE 11
673 ;
674 ; Do the following operations only once when the PKTbuffer fills (to 64).
675 ;
012B 20058D 676 m6: jb did_once,mainloop ; already displayed the max ppf & updated
EP1-IN buffer
012E 30008A 677 jnb PKTbuf_full,mainloop ; history buffer not full yet
0131 D205 678 setb did_once ; Do the stuff below only once
679 ;
680 ; *** Load EP1-IN with 64 bytes of ppf history
681 ;
0133 7F40 682 mov r7,#64 ; loop counter
0135 7834 683 mov r0,#PKTbuf ; r0 points to 64-byte ppf history buffer
0137 90E7C0 684 mov dptr,#EP1INBUF ; dptr points to destination (endpoint FIFO
)
013A E6 685 xfr: mov a,@r0 ; get byte from PKTbuf
013B 08 686 inc r0 ; bump source pointer
013C F0 687 movx @dptr,a ; store byte in EP1INBUF
013D A3 688 inc dptr ; bump dest pointer
013E DFFA 689 djnz r7,xfr ; do it 64 times
690 ;
0140 C202 691 clr blankflag ; (don't blank the display in 'display_hex'
call)
0142 853332 692 mov displaydigit,maxppf ; display max packets per frame
0145 516F 693 call display_hex
0147 01BB 694 jmp mainloop ; go again
695 ; -----------------------------------------------------------------------------------------
------
696 ; An EP8 buffer is available. Update last byte in buffer, and dispatch another packet
697 ; -----------------------------------------------------------------------------------------
------
0149 0531 698 Update_EP8: inc InCnt ; total number of IN packets
014B D204 699 setb F_gotPacket ; tell SOF service routine we're in busines
s
0153 0530 704 inc ppf ; bump the packets-per-frame count
015B 22 709 ret ; back to loop
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -