This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to verify the Cortex-M0 thumb instructions ? I found one chip( RAM &FLASH is OK) when it run LDR relative instructions,the program is in Hardfault。But others run the same code is OK

Could you help me to solve the problem.Do  you have the code  to verify the thumb instruction ? If have,the code can check any  corner the functions of thumb instructions

Parents
  • #pragma location = 0x0001bf0

    __root const int16_t  TAB_SoftVer[21] ={0,-1,-2,3,4,5,6,7,8,9,10,1,2,3,4,5,6};        

    //const INT16U  TAB_SoftVer[14] @"romdata"  ={0x0000,0x1111,0x22222,0x3333,0x4444,0x5555,0x6666,0x77777,0x8888,0x9999,0xaaaa,0xbbbb,0xcccc};                                       //软件版本(内部用) 

    __no_init  INT8S Ram_Dat[5]@ 0x20000100;

        Ram_Dat[0]=-2;

        Ram_Dat[1]=-1;

       Ram_Dat[2]=0X69;

        Ram_Dat[3]=-5;

         Ram_Dat[4]=0X66;

        __asm(       

             "NOP\n"

              // "NOP\n"

            "LDR  R4,RAMDAT_ADDR\n"   

            "LDR  R0,ROMDAT_ADDR\n"

               "NOP\n"

               "NOP\n"

            "LDRSB   R2 ,[R4,R2]\n"

              "NOP\n"

            "MOVS   R3 ,#3\n"

               "NOP\n"

            "LDRSB   R4 ,[R4,R3]\n"

                 "NOP\n"

                   "NOP\n"

                     "NOP\n"

            "SUBS R2,R2,R4\n"

            "LSLS  R2,#24\n"

            "ASRS  R2,#23\n"

            "LDRH  R2,[R0,R2]\n"         

             "RAMDAT_ADDR: DC32    0x20000100\n"

             "ROMDAT_ADDR: DC32    0x0001bf0\n"

     );

    the RAMDAT_ADDR is the address of Ram_Dat[5],the ROMDAT_ADDR is the address of  TAB_SoftVer.

    when it run at   "SUBS R2,R2,R4\n" , R2 is wrong , when R2 is 0xFFFFFFF8,R4 is 0xFFFFFFF0, the result of  R2 is 0x40800008.

    The frequency of core is 11Mhz.

Reply
  • #pragma location = 0x0001bf0

    __root const int16_t  TAB_SoftVer[21] ={0,-1,-2,3,4,5,6,7,8,9,10,1,2,3,4,5,6};        

    //const INT16U  TAB_SoftVer[14] @"romdata"  ={0x0000,0x1111,0x22222,0x3333,0x4444,0x5555,0x6666,0x77777,0x8888,0x9999,0xaaaa,0xbbbb,0xcccc};                                       //软件版本(内部用) 

    __no_init  INT8S Ram_Dat[5]@ 0x20000100;

        Ram_Dat[0]=-2;

        Ram_Dat[1]=-1;

       Ram_Dat[2]=0X69;

        Ram_Dat[3]=-5;

         Ram_Dat[4]=0X66;

        __asm(       

             "NOP\n"

              // "NOP\n"

            "LDR  R4,RAMDAT_ADDR\n"   

            "LDR  R0,ROMDAT_ADDR\n"

               "NOP\n"

               "NOP\n"

            "LDRSB   R2 ,[R4,R2]\n"

              "NOP\n"

            "MOVS   R3 ,#3\n"

               "NOP\n"

            "LDRSB   R4 ,[R4,R3]\n"

                 "NOP\n"

                   "NOP\n"

                     "NOP\n"

            "SUBS R2,R2,R4\n"

            "LSLS  R2,#24\n"

            "ASRS  R2,#23\n"

            "LDRH  R2,[R0,R2]\n"         

             "RAMDAT_ADDR: DC32    0x20000100\n"

             "ROMDAT_ADDR: DC32    0x0001bf0\n"

     );

    the RAMDAT_ADDR is the address of Ram_Dat[5],the ROMDAT_ADDR is the address of  TAB_SoftVer.

    when it run at   "SUBS R2,R2,R4\n" , R2 is wrong , when R2 is 0xFFFFFFF8,R4 is 0xFFFFFFF0, the result of  R2 is 0x40800008.

    The frequency of core is 11Mhz.

Children