ВходНаше всё Теги codebook 无线电组件 Поиск Опросы Закон Четверг
7 ноября
852565 Топик полностью
Bill (03.07.2018 11:17, просмотров: 433) ответил sladkoejka на Ваш контроллер использует autovector? Это когда в LJMP инструкции расположенной в таблице векторов стоит адрес новой таблицы векторов, а процессор подменяет младший байт под соответствующий суб-вектор. Т.е. когда приходит прерывание от USB, в LJMP
Вообще-то, примеры примеры были сделаны для вашего контроллера. Исходный код#include <ioCY7C68013A.h> #include <intrinsics.h> typedef unsigned int uint16_t; typedef signed int int16_t; volatile char Flags; #pragma vector = USB_int __interrupt void USB_Handler(void) { Flags = 0; } #pragma vector = TF0_int __interrupt void Tim0_Handler(void) { Flags = 1; } void delay(uint16_t n) { for (uint16_t i=0; i < n; i++) __no_operation(); } void main(void) { for (;;) { delay(1000U); delay(10000U); } } Сгенерированный код F:\MCS51prj\Test\test.c 1 #include <ioCY7C68013A.h> 2 #include <intrinsics.h> 3 4 typedef unsigned int uint16_t; 5 typedef signed int int16_t; 6 \ In segment IDATA_Z, align 1, keep-with-next 7 volatile char Flags; \ Flags: \ 000000 DS 1 \ 000001 REQUIRE __INIT_IDATA_Z 8 9 #pragma vector = USB_int \ In segment NEAR_CODE, align 1, keep-with-next 10 __interrupt void USB_Handler(void) \ USB_Handler: 11 { \ 000000 C0E0 PUSH A \ 000002 E8 MOV A,R0 \ 000003 ; Saved register size: 4 \ 000003 ; Auto size: 0 12 Flags = 0; \ 000003 78.. MOV R0,#Flags \ 000005 7600 MOV @R0,#0x0 13 } \ 000007 F8 MOV R0,A \ 000008 D0E0 POP A \ 00000A 32 RETI 14 15 #pragma vector = TF0_int \ In segment NEAR_CODE, align 1, keep-with-next 16 __interrupt void Tim0_Handler(void) \ Tim0_Handler: 17 { \ 000000 C0E0 PUSH A \ 000002 E8 MOV A,R0 \ 000003 ; Saved register size: 4 \ 000003 ; Auto size: 0 18 Flags = 1; \ 000003 78.. MOV R0,#Flags \ 000005 7601 MOV @R0,#0x1 19 } \ 000007 F8 MOV R0,A \ 000008 D0E0 POP A \ 00000A 32 RETI \ In segment NEAR_CODE, align 1, keep-with-next 20 void delay(uint16_t n) \ delay: 21 { \ 000000 ; Saved register size: 0 \ 000000 ; Auto size: 0 22 for (uint16_t i=0; i < n; i++) \ 000000 EA MOV A,R2 \ 000001 4B ORL A,R3 \ 000002 6011 JZ ??delay_0 \ 000004 EA MOV A,R2 \ 000005 F8 MOV R0,A \ 000006 EB MOV A,R3 \ 000007 F9 MOV R1,A 23 __no_operation(); \ ??delay_1: \ 000008 00 NOP \ 000009 E8 MOV A,R0 \ 00000A 24FF ADD A,#-0x1 \ 00000C 18 DEC R0 \ 00000D E9 MOV A,R1 \ 00000E 34FF ADDC A,#-0x1 \ 000010 F9 MOV R1,A \ 000011 E8 MOV A,R0 \ 000012 49 ORL A,R1 \ 000013 70F3 JNZ ??delay_1 24 } \ ??delay_0: \ 000015 53..FE ANL ?DPS,#0xfe \ 000018 22 RET 25 \ In segment NEAR_CODE, align 1, keep-with-next 26 void main(void) \ main: 27 { \ 000000 ; Auto size: 0 28 for (;;) 29 { 30 delay(1000U); \ ??main_0: \ 000000 ; Setup parameters for call to function delay \ 000000 7AE8 MOV R2,#-0x18 \ 000002 7B03 MOV R3,#0x3 \ 000004 12.... LCALL delay 31 delay(10000U); \ 000007 ; Setup parameters for call to function delay \ 000007 7A10 MOV R2,#0x10 \ 000009 7B27 MOV R3,#0x27 \ 00000B 12.... LCALL delay \ 00000E 80F0 SJMP ??main_0 32 } 33 } \ In segment INTVEC, offset 0xb, root \ `??Tim0_Handler::??INTVEC 11`: \ 00000B 02.... LJMP (Tim0_Handler) \ In segment INTVEC, offset 0x43, root \ `??USB_Handler::??INTVEC 67`: \ 000043 02.... LJMP (USB_Handler) Maximum stack usage in bytes: ISTACK Function ------ -------- 4 Tim0_Handler 4 USB_Handler 0 delay 0 main 0 -> delay Segment part sizes: Bytes Function/Label ----- -------------- 1 Flags 11 Tim0_Handler 3 Tim0_Handler::??INTVEC 11 11 USB_Handler 3 USB_Handler::??INTVEC 67 25 delay 16 main 1 byte in segment IDATA_Z 6 bytes in segment INTVEC 63 bytes in segment NEAR_CODE 63 bytes of CODE memory (+ 6 bytes shared) 1 byte of IDATA memory Errors: none Warnings: none Карта памяти
################################################################################
#                                                                              #
#      IAR Universal Linker V6.4.2.83                                          #
#                                                                              #
#           Link time     =  03/Jul/2018  13:13:31                             #
#           Target CPU    =  x51                                               #
#           List file     =  F:\MCS51prj\Test\Release\List\test.map            #
#           Output file 1 =  F:\MCS51prj\Test\Release\Exe\test.a51             #
#                            Format: intel-standard                            #
#           Command line  =  "-IC:\Program Files\IAR Systems\Embedded Workbenc #
#                            h 7.3\8051\CONFIG\"                               #
#                            -D_NR_OF_BANKS=0 -D_CODEBANK_END=0                #
#                            -D_CODEBANK_START=0                               #
#                            F:\MCS51prj\Test\Release\Obj\test.r51 -o          #
#                            F:\MCS51prj\Test\Release\Exe\test.a51             #
#                            -Fintel-standard -l                               #
#                            F:\MCS51prj\Test\Release\List\test.map -xms       #
#                            "-IC:\Program Files\IAR Systems\Embedded Workbenc #
#                            h 7.3\8051\LIB\"                                  #
#                            -f                                                #
#                            "C:\Program Files\IAR Systems\Embedded Workbench  #
#                            7.3\8051\config\devices\Cypress\lnk51ew_CY7C68013 #
#                            A.xcl"                                            #
#                            (-D_IDATA0_START=0x00 -D_IDATA0_END=0xFF          #
#                            -D_PDATA0_START=0x0000 -D_PDATA0_END=0x00FF       #
#                            -D_IXDATA0_START=0xE000 -D_IXDATA0_END=0xE1FF     #
#                            -D_XDATA0_START=0xE000 -D_XDATA0_END=0xE1FF       #
#                            -D_CODE0_START=0x000000 -D_CODE0_END=0x3FFF       #
#                            -D?REGISTER_BANK=0x0 -D_REGISTER_BANK_START=0x0   #
#                            -D_BREG_START=0x00 -D?VB=0x20                     #
#                            -Z(BIT)BREG=_BREG_START -Z(BIT)BIT_N=0-7F         #
#                            -Z(DATA)REGISTERS+8=_REGISTER_BANK_START          #
#                            -Z(DATA)BDATA_Z,BDATA_N,BDATA_I=20-2F             #
#                            -Z(DATA)VREG=08-7F -Z(DATA)PSP,XSP=08-7F          #
#                            -Z(DATA)DOVERLAY=08-7F                            #
#                            -Z(DATA)DATA_I,DATA_Z,DATA_N=08-7F                #
#                            -U(IDATA)0-7F=(DATA)0-7F                          #
#                            -Z(IDATA)IDATA_I,IDATA_Z,IDATA_N=08-_IDATA0_END   #
#                            -Z(IDATA)ISTACK+_IDATA_STACK_SIZE#08-_IDATA0_END  #
#                            -Z(IDATA)IOVERLAY=08-FF -Z(CODE)INTVEC=0          #
#                            -Z(CODE)CSTART=_CODE0_START-_CODE0_END            #
#                            -Z(CODE)BIT_ID,BDATA_ID,DATA_ID,IDATA_ID,IXDATA_I #
#                            D,PDATA_ID,XDATA_ID=_CODE0_START-_CODE0_END       #
#                            -Z(CODE)HUGE_ID=_CODE0_START-_CODE0_END           #
#                            -Z(CODE)RCODE,DIFUNCT=_CODE0_START-_CODE0_END     #
#                            -P(CODE)CODE_C,CODE_N,NEAR_CODE=_CODE0_START-_COD #
#                            E0_END                                            #
#                            -Z(CODE)CHECKSUM#_CODE0_END                       #
#                            -Z(XDATA)PDATA_Z,PDATA_I=_PDATA0_START-_PDATA0_EN #
#                            D                                                 #
#                            -P(XDATA)PDATA_N=_PDATA0_START-_PDATA0_END        #
#                            -Z(XDATA)PSTACK+_PDATA_STACK_SIZE=_PDATA0_START-_ #
#                            PDATA0_END                                        #
#                            -Z(XDATA)EXT_STACK+_EXTENDED_STACK_SIZE=_EXTENDED #
#                            _STACK_START                                      #
#                            -Z(XDATA)XSTACK+_XDATA_STACK_SIZE=_XDATA0_START-_ #
#                            XDATA0_END                                        #
#                            -Z(XDATA)IXDATA_I,IXDATA_Z=_IXDATA0_START-_IXDATA #
#                            0_END                                             #
#                            -P(XDATA)IXDATA_N=_IXDATA0_START-_IXDATA0_END     #
#                            -Z(XDATA)XDATA_I,XDATA_Z=_XDATA0_START-_XDATA0_EN #
#                            D                                                 #
#                            -P(XDATA)XDATA_N=_XDATA0_START-_XDATA0_END        #
#                            -Z(XDATA)XDATA_HEAP+_XDATA_HEAP_SIZE=_XDATA0_STAR #
#                            T-_XDATA0_END                                     #
#                            -Z(CONST)XDATA_ROM_C=_XDATA0_START-_XDATA0_END    #
#                            -Z(CODE)FAR22_ID=[_CODE0_START-_CODE0_END]/10000  #
#                            -Z(CODE)FAR_ID=[_CODE0_START-_CODE0_END]/10000    #
#                            -cx51) -D?DPMASK=0x01                             #
#                            -D_NR_OF_VIRTUAL_REGISTERS=8 -D?DPS=0x86          #
#                            -D?PBANK=0x92 -D?DPL1=0x84 -D?DPH1=0x85 -s        #
#                            __program_start                                   #
#                            "C:\Program Files\IAR Systems\Embedded Workbench  #
#                            7.3\8051\LIB\CLIB\cl-pli-nsid-2e16inc.r51"        #
#                            -D_IDATA_STACK_SIZE=0x40 -D?ESP=0 -D?ESP_MASK=0   #
#                            -D_EXTENDED_STACK_START=0                         #
#                            -D_EXTENDED_STACK_SIZE=0                          #
#                            -D_PDATA_STACK_SIZE=0x80                          #
#                            -D_XDATA_STACK_SIZE=0xEFF                         #
#                            -D_XDATA_HEAP_SIZE=0xFF -D_FAR_HEAP_SIZE=0xFFF    #
#                            -D_HUGE_HEAP_SIZE=0xFFF                           #
#                            -D_FAR22_HEAP_SIZE=0xFFF                          #
#                                                                              #
#                           Copyright (C) 1987-2015 IAR Systems AB.            #
################################################################################





                ****************************************
                *                                      *
                *           CROSS REFERENCE            *
                *                                      *
                ****************************************

       Program entry at : CODE      0000005F  Relocatable, from module : CSTARTUP




                ****************************************
                *                                      *
                *            RUNTIME MODEL             *
                *                                      *
                ****************************************

  __SystemLibrary          = CLib
  __calling_convention     = idata_reentrant
  __code_model             = near
  __core                   = plain
  __data_model             = small
  __dptr_size              = 16
  __dptr_visibility        = separate
  __extended_stack         = disabled
  __location_for_constants = data
  __number_of_dptrs        = 2
  __rt_version             = 1

                ****************************************
                *                                      *
                *    AUTOMATIC SYMBOL REDIRECTIONS     *
                *                                      *
                ****************************************

                  There are no automatic symbol redirections.



                ****************************************
                *                                      *
                *              MODULE MAP              *
                *                                      *
                ****************************************


  DEFINED ABSOLUTE ENTRIES
    *************************************************************************

  DEFINED ABSOLUTE ENTRIES
  PROGRAM MODULE, NAME : ?ABS_ENTRY_MOD

Absolute parts
           ENTRY                   ADDRESS         REF BY
           =====                   =======         ======
           _FAR22_HEAP_SIZE        00000FFF 
           _HUGE_HEAP_SIZE         00000FFF 
           _FAR_HEAP_SIZE          00000FFF 
           _XDATA_HEAP_SIZE        000000FF 
           _XDATA_STACK_SIZE       00000EFF 
           _PDATA_STACK_SIZE       00000080 
           _EXTENDED_STACK_SIZE    00000000 
           _EXTENDED_STACK_START   00000000 
           ?ESP_MASK               00000000 
           ?ESP                    00000000 
           _IDATA_STACK_SIZE       00000040 
           ?DPH1                   00000085 
           ?DPL1                   00000084 
           ?PBANK                  00000092 
           ?DPS                    00000086        ?RESET_DPS (CSTARTUP)
                                                   delay (test)
           _NR_OF_VIRTUAL_REGISTERS
                                   00000008 
           ?DPMASK                 00000001        ?RESET_DPS (CSTARTUP)
           ?VB                     00000020 
           _BREG_START             00000000 
           _REGISTER_BANK_START    00000000 
           ?REGISTER_BANK          00000000        Segment part 6 (CSTARTUP)
           _CODE0_END              00003FFF 
           _CODE0_START            00000000 
           _XDATA0_END             0000E1FF 
           _XDATA0_START           0000E000 
           _IXDATA0_END            0000E1FF 
           _IXDATA0_START          0000E000 
           _PDATA0_END             000000FF 
           _PDATA0_START           00000000 
           _IDATA0_END             000000FF 
           _IDATA0_START           00000000 
           _CODEBANK_START         00000000 
           _CODEBANK_END           00000000 
           _NR_OF_BANKS            00000000 
    *************************************************************************

  FILE NAME : F:\MCS51prj\Test\Release\Obj\test.r51
  PROGRAM MODULE, NAME : test

  SEGMENTS IN THE MODULE
  ======================
IDATA_Z
  Relative segment, address: IDATA 00000008 - 00000008 (0x1 bytes), align: 0
  Segment part 8.             Intra module refs:   Tim0_Handler
                                                   USB_Handler
           ENTRY                   ADDRESS         REF BY
           =====                   =======         ======
           Flags                   00000008 
    -------------------------------------------------------------------------
<NEAR_CODE> 1 (was NEAR_CODE)
  Relative segment, address: CODE 0000006B - 00000075 (0xb bytes), align: 0
  Segment part 9.             Intra module refs:   USB_Handler::??INTVEC 67
           ENTRY                   ADDRESS         REF BY
           =====                   =======         ======
           USB_Handler             0000006B 
               interrupt function
               ISTACK = 00000000 ( 00000004 )
    -------------------------------------------------------------------------
<NEAR_CODE> 1 (was NEAR_CODE)
  Relative segment, address: CODE 00000076 - 00000080 (0xb bytes), align: 0
  Segment part 10.            Intra module refs:   Tim0_Handler::??INTVEC 11
           ENTRY                   ADDRESS         REF BY
           =====                   =======         ======
           Tim0_Handler            00000076 
               interrupt function
               ISTACK = 00000000 ( 00000004 )
    -------------------------------------------------------------------------
<NEAR_CODE> 1 (was NEAR_CODE)
  Relative segment, address: CODE 00000081 - 00000099 (0x19 bytes), align: 0
  Segment part 11.            Intra module refs:   main
           ENTRY                   ADDRESS         REF BY
           =====                   =======         ======
           delay                   00000081 
    -------------------------------------------------------------------------
<NEAR_CODE> 1 (was NEAR_CODE)
  Relative segment, address: CODE 0000009A - 000000A9 (0x10 bytes), align: 0
  Segment part 12.
           ENTRY                   ADDRESS         REF BY
           =====                   =======         ======
           main                    0000009A        ?call_main (?cmain)
               calls direct
    -------------------------------------------------------------------------
INTVEC
  Common segment, address: CODE 00000000 - 0000000D (0xe bytes), align: 0
  Segment part 1. ROOT 
           ENTRY                   ADDRESS         REF BY
           =====                   =======         ======
           Tim0_Handler::??INTVEC 11
                                   0000000B 
    -------------------------------------------------------------------------
INTVEC
  Common segment, address: CODE 00000000 - 00000045 (0x46 bytes), align: 0
  Segment part 2. ROOT 
           ENTRY                   ADDRESS         REF BY
           =====                   =======         ======
           USB_Handler::??INTVEC 67
                                   00000043 

    *************************************************************************

  FILE NAME : C:\Program Files\IAR Systems\Embedded Workbench 7.3\8051\LIB\CLIB\cl-pli-nsid-2e16inc.r51
  LIBRARY MODULE, NAME : ?cexit

  SEGMENTS IN THE MODULE
  ======================
CSTART
  Relative segment, address: CODE 00000046 - 0000004A (0x5 bytes), align: 0
  Segment part 0.
           ENTRY                   ADDRESS         REF BY
           =====                   =======         ======
           exit                    00000046        ?call_main (?cmain)
           ?C_EXIT                 00000046 
           ?ROM_MONITOR_NOPS       00000046 

    -------------------------------------------------------------------------
  LIBRARY MODULE, NAME : ?cmain

  SEGMENTS IN THE MODULE
  ======================
CSTART
  Relative segment, address: CODE 0000004B, align: 0
  Segment part 5.
           ENTRY                   ADDRESS         REF BY
           =====                   =======         ======
           ?cmain                  0000004B        Segment part 14 (CSTARTUP)
               calls direct
    -------------------------------------------------------------------------
CSTART
  Relative segment, address: CODE 0000004B - 00000058 (0xe bytes), align: 0
  Segment part 12.
           ENTRY                   ADDRESS         REF BY
           =====                   =======         ======
           __INIT_IDATA_Z          0000004B        Flags (test)
    -------------------------------------------------------------------------
CSTART
  Relative segment, address: CODE 00000059 - 0000005E (0x6 bytes), align: 0
  Segment part 38.            Intra module refs:   ?cmain
           ENTRY                   ADDRESS         REF BY
           =====                   =======         ======
           ?call_main              00000059 

    -------------------------------------------------------------------------
  LIBRARY MODULE, NAME : CSTARTUP

  SEGMENTS IN THE MODULE
  ======================
REGISTERS
  Relative segment, address: DATA 00000000, align: 0
  Segment part 0.             Intra module refs:   Segment part 6
           ENTRY                   ADDRESS         REF BY
           =====                   =======         ======
           ?REGISTERS              00000000 
    -------------------------------------------------------------------------
ISTACK
  Relative segment, address: IDATA 000000C0, align: 0
  Segment part 1.             Intra module refs:   Segment part 6
           ENTRY                   ADDRESS         REF BY
           =====                   =======         ======
           ?ISTACK_START           000000C0 
    -------------------------------------------------------------------------
INTVEC
  Common segment, address: CODE 00000000 - 00000002 (0x3 bytes), align: 0
  Segment part 5. ROOT        Intra module refs:   Segment part 6
    -------------------------------------------------------------------------
CSTART
  Relative segment, address: CODE 0000005F - 00000064 (0x6 bytes), align: 0
  Segment part 6. ROOT        Intra module refs:   Segment part 5
           ENTRY                   ADDRESS         REF BY
           =====                   =======         ======
           __program_start         0000005F        Absolute parts (?ABS_ENTRY_MOD)
           ?RESET_SP               00000062 
    -------------------------------------------------------------------------
CSTART
  Relative segment, address: CODE 00000065 - 00000067 (0x3 bytes), align: 0
  Segment part 12.            Intra module refs:   Absolute parts
           ENTRY                   ADDRESS         REF BY
           =====                   =======         ======
           ?RESET_DPS              00000065 
    -------------------------------------------------------------------------
CSTART
  Relative segment, address: CODE 00000068 - 0000006A (0x3 bytes), align: 0
  Segment part 14.            Intra module refs:   Absolute parts

    -------------------------------------------------------------------------
  LIBRARY MODULE, NAME : VIRTUAL_REGISTERS

  SEGMENTS IN THE MODULE
  ======================
BREG
  Relative segment, address: BIT 00000020.0 - 00000020.7 (0x8 bits), align: 0
  Segment part 0.
           ENTRY                   ADDRESS         REF BY
           =====                   =======         ======
           ?B0                     00000020.0      Absolute parts (CSTARTUP)




                ****************************************
                *                                      *
                *      SEGMENTS IN ADDRESS ORDER       *
                *                                      *
                ****************************************


SEGMENT              SPACE    START ADDRESS   END ADDRESS     SIZE  TYPE  ALIGN
=======              =====    =============   ===========     ====  ====  =====
INTVEC               CODE          00000000 - 00000045          46   com    0
CSTART               CODE          00000046 - 0000006A          25   rel    0
<NEAR_CODE> 1        CODE          0000006B - 000000A9          3F   rel    0
REGISTERS            DATA          00000000 - 00000007           8   rel    0
BREG                 BIT        00000020.0  -  00000020.7        8   rel    0
IDATA_I              IDATA              00000008                     dse    0
IDATA_Z              IDATA         00000008 - 00000008           1   rel    0
ISTACK               IDATA         000000C0 - 000000FF          40   rel    0

                ****************************************
                *                                      *
                *        END OF CROSS REFERENCE        *
                *                                      *
                ****************************************

 170 bytes of CODE  memory
   8 bytes of DATA  memory
  65 bytes of IDATA memory
   8 bits  of BIT   memory

Errors: none
Warnings: none