📄 1620temp.lst
字号:
02B2 FF =1 545 MOV R7, A ; Save counter
02B3 F5F0 =1 546 MOV B, A
02B5 7800 =1 547 MOV R0, #LOW(EP0InBuffer) ; PageReg = 7FH = HIGH(EP0InBuffer)
02B7 F2 =1 548 CopySD: MOVX @R0, A
02B8 08 =1 549 INC R0
02B9 A3 =1 550 INC DPTR
02BA E0 =1 551 MOVX A, @DPTR
02BB DFFA =1 552 DJNZ R7, CopySD
=1 553 ; Fixup complete, get back to the program flow
02BD D0E0 =1 554 POP ACC ; Get rid of the return address
02BF D0E0 =1 555 POP ACC
02C1 E5F0 =1 556 MOV A, B ; Retrieve byte count
02C3 21A9 =1 557 JMP SendEP0InBuffer
558 $INCLUDE(DTables.A51)
=1 559 ; This module declares the descriptors
=1 560 ;
=1 561 ; This example has one Device Descriptor with:
=1 562 ; One Configuration - single IN port and single OUT port
=1 563 ; One Interface - there is only one method of accessing the ports
=1 564 ; One HID Descriptor - to make PC host software simpler
=1 565 ; One Endpoint Descriptor - for HID Input Reports
=1 566 ; One Report Descriptor - one 7 byte IN and one 12 byte OUT report
=1 567 ; Multiple Sting Descriptors - to aid the user
=1 568 ;
---- =1 569 CSEG
02C5 =1 570 DeviceDescriptor:
02C5 1201 =1 571 DB 18, 1 ; Length, Type
02C7 0101 =1 572 DW 101H ; USB Rev 1.1
02C9 000000 =1 573 DB 0, 0, 0 ; Class, Subclass and Protocol
02CC 40 =1 574 DB 64 ; EP0 size
02CD 4242 =1 575 DW 4242H, 1, 1 ; Vendor ID, Product ID and Version
02CF 0001
02D1 0001
02D3 010200 =1 576 DB 1, 2, 0 ; Manufacturer, Product & Serial# Names
02D6 01 =1 577 DB 1 ; #Configs
02D7 =1 578 ConfigurationDescriptor:
02D7 0902 =1 579 DB 9, 2 ; Length, Type
02D9 2200 =1 580 DB LOW(ConfigLength), HIGH(ConfigLength)
A51 MACRO ASSEMBLER 1620TEMP 22/07/99 11:19:38 PAGE 10
02DB 010100 =1 581 DB 1, 1, 0 ; #Interfaces, Configuration#, Config. Name
02DE 80 =1 582 DB 10000000b ; Attributes = Bus Powered
02DF 32 =1 583 DB 50 ; Max. Power is 50x2 = 100mA
02E0 =1 584 InterfaceDescriptor:
02E0 0904 =1 585 DB 9, 4 ; Length, Type
02E2 000001 =1 586 DB 0, 0, 1 ; No alternate setting, HID uses EP1
02E5 03 =1 587 DB 3 ; Class = Human Interface Device
02E6 0000 =1 588 DB 0, 0 ; Subclass and Protocol
02E8 00 =1 589 DB 0 ; Interface Name
02E9 =1 590 HIDDescriptor:
02E9 0921 =1 591 DB 9, 21H ; Length, Type
02EB 0001 =1 592 DB 0, 1 ; HID Class Specification compliance
02ED 00 =1 593 DB 0 ; Country localization (=none)
02EE 01 =1 594 DB 1 ; Number of descriptors to follow
02EF 22 =1 595 DB 22H ; And it's a Report descriptor
02F0 1F00 =1 596 DB LOW(ReportLength), HIGH(ReportLength)
02F2 =1 597 EndpointDescriptor:
02F2 0705 =1 598 DB 7, 5 ; Length, Type
02F4 81 =1 599 DB 10000001b ; Address = IN 1
02F5 03 =1 600 DB 00000011b ; Interrupt
02F6 4000 =1 601 DB 64, 0 ; Maximum packet size
02F8 C8 =1 602 DB 200 ; Poll every 0.2 seconds
0022 =1 603 ConfigLength EQU $ - ConfigurationDescriptor
=1 604
02F9 =1 605 ReportDescriptor: ; Generated with HID Tool, copied to here
02F9 0600FF =1 606 DB 6, 0, 0FFH ; Usage_Page (Vendor Defined)
02FC 0901 =1 607 DB 9, 1 ; Usage (I/O Device)
02FE A101 =1 608 DB 0A1H, 1 ; Collection (Application)
0300 1901 =1 609 DB 19H, 1 ; Usage_Minimum
0302 2902 =1 610 DB 29H, 2 ; Usage_Maximum
0304 1500 =1 611 DB 15H, 0 ; Logical_Minimum (0)
0306 26FF00 =1 612 DB 26H, 255, 0 ; Logical_Maximum (255)
0309 7508 =1 613 DB 75H, 8 ; Report_Size (8)
030B 9507 =1 614 DB 95H, 7 ; Report_Count (7)
030D 8102 =1 615 DB 81H, 2 ; Input (Data,Var,Abs)
030F 1901 =1 616 DB 19H, 1 ; Usage_Minimum
0311 2902 =1 617 DB 29H, 2 ; Usage_Maximum
0313 950C =1 618 DB 95H, 12 ; Report_Count (12)
0315 9102 =1 619 DB 91H, 2 ; Output (Data,Var,Abs)
0317 C0 =1 620 DB 0C0H ; End_Collection
001F =1 621 ReportLength EQU $-ReportDescriptor
=1 622
0318 =1 623 String0: ; Declare the UNICODE strings
0318 04030904 =1 624 DB 4, 3, 9, 4 ; Only English language strings supported
031C =1 625 String1: ; Manufacturer
031C 2C03 =1 626 DB (String2-String1),3 ; Length, Type
031E 55005300 =1 627 DB "U",0,"S",0,"B",0," ",0,"D",0,"e",0,"s",0,"i",0,"g",0,"n",0," ", 0
0322 42002000
0326 44006500
032A 73006900
032E 67006E00
0332 2000
0334 42007900 =1 628 DB "B",0,"y",0," ",0,"E",0,"x",0,"a",0,"m",0,"p",0,"l",0,"e",0
0338 20004500
033C 78006100
0340 6D007000
0344 6C006500
0348 =1 629 String2: ; Product Name
0348 1A03 =1 630 DB (EndOfDescriptors-String2),3
034A 54006500 =1 631 DB "T",0,"e",0,"m",0,"p",0,"e",0,"r",0
034E 6D007000
0352 65007200
0356 61007400 =1 632 DB "a",0,"t",0,"u",0,"r",0,"e",0,"s",0
035A 75007200
035E 65007300
0362 =1 633 EndOfDescriptors:
A51 MACRO ASSEMBLER 1620TEMP 22/07/99 11:19:38 PAGE 11
0362 0000 =1 634 DW 0 ; Backstop for String Descriptors
=1 635
=1 636
=1 637
638 $INCLUDE(1620Main.A51)
=1 639 ; This module initializes the microcontroller then executes MAIN forever
=1 640 ;
---- =1 641 CSEG
0364 =1 642 Reset:
0364 7581EB =1 643 MOV SP, #235 ; Initialize the Stack
0367 75927F =1 644 MOV PageReg, #7FH ; Allows MOVX Ri to access EZ-USB memory
=1 645
036A 78D6 =1 646 MOV R0, #Low(USBControl) ; Simulate a disconnect
036C E2 =1 647 MOVX A, @R0
036D 54F3 =1 648 ANL A, #11110011b ; Clear DISCON, DISCOE
036F F2 =1 649 MOVX @R0, A
0370 1203DA =1 650 CALL Wait100msec ; Give the host time to react
0373 E2 =1 651 MOVX A, @R0 ; Reconnect with this new identity
0374 4406 =1 652 ORL A, #00000110b ; Set DISCOE to enable pullup resistor
0376 F2 =1 653 MOVX @R0, A ; Set RENUM so that 8051 handles USB requests
0377 E4 =1 654 CLR A
0378 F520 =1 655 MOV FLAGS, A ; Start in Default state
037A =1 656 InitializeMsecCounter:
037A 04 =1 657 INC A ; = 1
037B F542 =1 658 MOV Expired_Time, A
037D F549 =1 659 MOV Msec_counter, A
037F =1 660 InitializeIOSystem: ; Work around the dScope monitor I/O needs
=1 661 ; Setup Port A as 8-bit OUTPUT port (no alternate functions)
=1 662 ; Setup an 8-bit INPUT port using PortB_Bits [7:4] and PortC_Bits[3:0]
=1 663 ; Assume a pre-existing configuration (ie dScope)
037F 7893 =1 664 MOV R0, #LOW(PortA_Config) ; PageReg = 7F = HIGH(PortA_Config)
0381 E4 =1 665 CLR A
0382 F2 =1 666 MOVX @R0, A ; No alternate functions
0383 799C =1 667 MOV R1, #LOW(PortA_OE)
0385 F4 =1 668 CPL A ; = 0FFH
0386 F3 =1 669 MOVX @R1, A ; Enable PortA for Output
0387 08 =1 670 INC R0 ; Point to PortB_Config
0388 09 =1 671 INC R1 ; Point to PortB_OE
0389 E2 =1 672 MOVX A, @R0 ; Get current configuration
038A 540F =1 673 ANL A, #0FH
038C F2 =1 674 MOVX @R0, A ; No alternate functions on upper nibble
038D E3 =1 675 MOVX A, @R1 ; Get current configuration
038E 44F0 =1 676 ORL A, #0F0H
0390 F3 =1 677 MOVX @R1, A ; Enable PortB_Bits[7:4] for Output
0391 08 =1 678 INC R0 ; Point to PortC_Config
0392 09 =1 679 INC R1 ; Point to PortC_OE
0393 E2 =1 680 MOVX A, @R0 ; Get current configuration
0394 54F0 =1 681 ANL A, #0F0H
0396 F2 =1 682 MOVX @R0, A ; No alternate functions on lower nibble
0397 E3 =1 683 MOVX A, @R1 ; Get current configuration
0398 440F =1 684 ORL A, #0FH
039A F3 =1 685 MOVX @R1, A ; Enable PortC_Bits[3:0] for Output
039B =1 686 InitializeThermometers:
039B 7896 =1 687 MOV R0, #Low(PortA_Out) ; Do all six at the same time
039D 7404 =1 688 MOV A, #00000100b ; Select pattern
039F FE =1 689 ILoop: MOV R6, A
03A0 7401 =1 690 MOV A, #00000001b ; Port A idle state
03A2 4E =1 691 ORL A, R6
03A3 F2 =1 692 MOVX @R0, A ; Select one of the thermometers
03A4 7D0C =1 693 MOV R5, #0CH ; Configure command
03A6 120448 =1 694 CALL SendByte
03A9 7D0A =1 695 MOV R5, #00001010b ; Set CPU mode and continuous conversion
03AB 120448 =1 696 CALL SendByte
03AE FA =1 697 MOV R2, A ; Save A
03AF 7401 =1 698 MOV A, #00000001b ; Port A idle state
03B1 F2 =1 699 MOVX @R0, A
A51 MACRO ASSEMBLER 1620TEMP 22/07/99 11:19:38 PAGE 12
03B2 754014 =1 700 MOV Temp, #20
03B5 1203DD =1 701 CALL Wait1msec ; Wait for write to complete
03B8 EA =1 702 MOV A, R2 ; Restore A
03B9 7DEE =1 703 MOV R5, #0EEH ; Start temperature conversion command
03BB 120448 =1 704 CALL SendByte
03BE CE =1 705 XCH A, R6
03BF C3 =1 706 CLR C ; Need to zero fill
03C0 33 =1 707 RLC A
03C1 70DC =1 708 JNZ ILoop
=1 709
03C3 =1 710 InitializeInterruptSystem: ; First initialize the USB level
03C3 E4 =1 711 CLR A
03C4 78AC =1 712 MOV R0, #LOW(IN07IEN)
03C6 F2 =1 713 MOVX @R0, A ; Disable interrupts from IN Endpoints 0-7
03C7 08 =1 714 INC R0
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -