This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP430F5419A PC GETTING LOST

Other Parts Discussed in Thread: MSP430F5419A

Hello,


We are working on a project with MSP430F5419A for GPS tracking application. Our project development is over and installation of units in the field is half way. We are facing one issue in some units, that the controller stops sometimes. It will get recover only when we REST the board, and continues to run for some duration and stops again.


OBSERVATIONS:

  1. Issue persists only in some units.
  2. Sometimes the Interrupt routines continues to run (Tested with LED ON/OFF in timer interrupt) and only main code fails. Sometimes both fails.
  3. If we run the failed unit in debug mode, and we BREAK the code when it fails (During GSM response +CGREG: 1) we see that the current execution line shows somewhere in the memory not the code. Below image FYR.

Details FYI:

IAR: V5.10.1

Clock: Internal 16MHZ.


Kindly help us to resolve the issue.


Thanks,

Manoj Srinivasan.

  • Apparently, your code jumps to a wrong address.

    It's not possible to say more without knowing the code.
  • Take a look at the stack trace and see if it looks valid. Check the SP register. You could be running into a stack overrun issue. If the stack grows into the space where variables are stored, then a write to the variable corrupts the stack and you could have a function returning to a faulty location.

    1. Use the static stack tool in IAR to verify call depth.
    2. Make sure that max stack usage + max call chain for worst-case ISR doesn't grow stack beyond boundaries.
    3. Make sure you aren't passing large data structures on the stack
    etc.
  • Brian Boorman said:
    Take a look at the stack trace and see if it looks valid. Check the SP register. You could be running into a stack overrun issue. If the stack grows into the space where variables are stored, then a write to the variable corrupts the stack and you could have a function returning to a faulty location.

    1. Use the static stack tool in IAR to verify call depth.
    2. Make sure that max stack usage + max call chain for worst-case ISR doesn't grow stack beyond boundaries.
    3. Make sure you aren't passing large data structures on the stack
    etc.

    Hi Brian,


    Thanks for your reply. I have generated the map of my code with Static Stack Tool in IAR. Please find the attachment.

    I'm not able to verify the "max stack usage + max call chain for worst-case". Kindly advise me how to verify that using the IAR tool.

    Thanks

    Manoj.


    Stack usage
    
    Call graph (*** = already visited):
    
      interrupt:
      0 USCI_B1_ISR [38]
        20 Tx_UART_A0_Char [2]
          22 - [0]
        20 GPSReceiveFrameAnalyzer [18]
          38 - [0]
    
      interrupt:
      0 Timer_A0 [12]
        12 - [0]
    
      interrupt:
      0 USCI_A2_ISR [114]
        20 DownloadHexFile [2]
          22 - [0]
        20 GSMReceiveFrameAnalyzer [94]
          26 memset [10]
            36 - [0]
          26 strtol [88]
            26 __iar_Stolx [88]
              56 __iar_Stoulx [58]
                100 ?Mul32Hw32 [4]
                  104 - [0]
                100 __iar_Memchr [6]
                  106 - [0]
                100 ?DivMod32u [14]
                  114 - [0]
                104 - [0]
            28 - [0]
          26 strcpy [2]
            28 - [0]
    
      interrupt:
      0 USCI_A1_ISR [4]
        4 - [0]
    
      interrupt:
      0 scan [4]
        4 - [0]
    
      interrupt:
      0 Ignition [4]
        4 - [0]
    
      Program entry:
      0 __program_start [316]
        0 __data20_memzero [6]
          6 - [0]
        0 __data20_memcpy [10]
          0 memcpy [10]
            10 - [0]
          2 - [0]
        0 main [316]
          2 Init_MSP [4]
            4 Init_WDT [2]
              6 - [0]
            4 Init_CLK [2]
              6 - [0]
            4 Init_Port [2]
              6 - [0]
            4 I2C_Init [2]
              6 - [0]
            4 InitGSM_UART_A2 [2]
              6 - [0]
            4 Init_ADC [2]
              6 - [0]
            4 Init_TIMER_A [2]
              6 - [0]
            4 Init_UART_A0 [2]
              6 - [0]
            2 Init_SPI_USCI_B2 [2]
              4 - [0]
          2 Buzzer_ON_4_0 [2]
            4 - [0]
          2 PowerONModem [2]
            4 - [0]
          2 Init_Variables [2]
            4 - [0]
          2 Buzzer_OFF_4_0 [2]
            4 - [0]
          2 GSMModemReset [20]
            4 Tx_UART_A0_String [4]
              6 Tx_UART_A0_Char [2] ***
            2 GSMResetPinToggle [2]
              4 - [0]
            4 GSMSendCommand [18]
              10 Tx_UART_A2_String [12]
                20 Tx_UART_A2_Char [2]
                  22 - [0]
              10 Tx_UART_A2_Char [2] ***
          2 ReadStoredPacketsCount [18]
            12 SST_Read_Status_Register [8]
              14 CS_LOW [2]
                16 - [0]
              14 M25P80_SPI_TXRX [6]
                16 halMcuWaitMs [4]
                  18 halMcuWaitUs [2]
                    20 - [0]
              14 CS_HIGH [2]
                16 - [0]
            12 CS_LOW [2] ***
            12 M25P80_SPI_TXRX [6] ***
            12 CS_HIGH [2] ***
            14 - [0]
          2 InitFG [4]
            4 strcpy [2] ***
            2 strcpy [2] ***
          2 GSMInit [190]
            4 GSMSendCommand [18] ***
            4 GSMFlashCommandParser [188]
              182 memset [10] ***
            2 GSMWaitForResponse [4]
              4 GSMReadyForNextCommand [2]
                6 - [0]
              4 GSMErrorHandler [2]
                6 - [0]
            4 GSMWaitForResponse [4] ***
            4 FrameGprsCommand [102]
              106 - [0]
            4 SendATCommand [36]
              22 GSMSendCommand [18] ***
            2 GSMModemReset [20] ***
            4 GSMErrorHandler [2] ***
          2 GSMGetSignalStrength [20]
            4 GSMSendCommand [18] ***
          2 GSMSwitchToData [38]
            4 GSMSendCommand [18] ***
            4 GSMReconnectTCP [20]
              6 GSMSendCommand [18] ***
            4 GSMSwitchToCommand [4]
              6 Tx_UART_A2_Char [2] ***
            4 ReadStoredPackets [36]
              30 memset [10] ***
              30 SST_Read_Status_Register [8] ***
              30 CS_LOW [2] ***
              30 M25P80_SPI_TXRX [6] ***
              32 - [0]
            4 GSMSendPacket [12]
              14 Tx_UART_A2_Char [2] ***
            2 GSMResponseHandler [2]
              4 - [0]
          2 BatteryStatus [290]
            4 memset [10] ***
            6 sprintf [286]
              20 _PrintfFull [272]
                150 _PutcharFull [8]
                  156 _SProut [2]
                    158 - [0]
                150 __iar_Strchr [2]
                  152 - [0]
                150 strlen [6]
                  156 - [0]
                150 __iar_Memchr [6] ***
                150 _LdtobFull [142]
                  234 __iar_Dunscale [2]
                    236 - [0]
                  234 memcpy [10] ***
                  234 _CmpGe32f [8]
                    236 ?FLT_GE [6]
                      242 - [0]
                  234 __iar_Dscale [10]
                    244 - [0]
                  234 _Cast32fto32s [12]
                    236 ?FLT_Extract [10]
                      246 - [0]
                  234 _Cast32sto32f [10]
                    234 _Cast32uto32f [10]
                      244 - [0]
                  234 ?ShiftRight32s_4 [2]
                    234 ?ShiftRight32s_3 [2]
                      234 ?ShiftRight32s_2 [2]
                        236 - [0]
                  234 ?Mul16to32sHw [4]
                    238 - [0]
                  234 ?DivMod32s [20]
                    240 ?DivMod32u [14] ***
                  234 scale [38]
                    260 ?Mul32fHw32 [12]
                      272 - [0]
                  234 _Div32f [18]
                    252 - [0]
                  234 _Cast32uto32f [10] ***
                  234 ?Mul32fHw32 [12] ***
                  236 _GenldFull [56]
                    278 memcpy [10] ***
                    278 div [14]
                      284 ?DivMod16s [8]
                        290 ?DivMod16u [2]
                          292 - [0]
                    284 - [0]
                  234 _Cast32fto32u [12]
                    236 ?FLT_Extract [10] ***
                  234 _Sub32f [18]
                    234 _Add32f [18]
                      252 - [0]
                  236 _CmpLt32f [8]
                    238 ?FLT_LT [6]
                      244 - [0]
                  234 ?DivMod32u [14] ***
                  238 - [0]
                150 LoadInt [4]
                  154 - [0]
                150 _LitobFull [98]
                  206 _Mod64u [34]
                    240 - [0]
                  206 _Div64u [42]
                    248 - [0]
                  208 - [0]
                152 _PutcharsFull [26]
                  170 _PutcharFull [8] ***
                152 pad [46]
                  172 _PutcharsFull [26] ***
                154 - [0]
          2 VMUPowerStatus [2]
            4 - [0]
          2 Ignition_ON_OFF [30]
            4 SendAlertPacket [28]
              22 strlen [6] ***
              22 memset [10] ***
              22 ?DivMod16u [2] ***
            2 Tx_UART_A0_String [4] ***
            4 Tx_UART_A0_String [4] ***
          2 StorePacket [50]
            4 SST_Read_Status_Register [8] ***
            4 strcat [2]
              6 - [0]
            4 strlen [6] ***
            6 M25P80_FLASH_WRITE [46]
              44 M25P80_WriteEnable [8]
                46 CS_LOW [2] ***
                46 M25P80_SPI_TXRX [6] ***
                44 CS_HIGH [2] ***
              44 CS_LOW [2] ***
              44 M25P80_SPI_TXRX [6] ***
              44 M25P80_SPI_WRITE [2]
                46 - [0]
              44 CS_HIGH [2] ***
              48 - [0]
          2 FuelSensor [292]
            8 sprintf [286] ***
          2 EraseStoredData [16]
            4 SST_Read_Status_Register [8] ***
            4 M25P80_ERASE_BULK [14]
              10 M25P80_WriteEnable [8] ***
              10 CS_LOW [2] ***
              10 M25P80_SPI_TXRX [6] ***
              10 CS_HIGH [2] ***
          2 GPSPreparePacket [314]
            20 strlen [6] ***
            20 memset [10] ***
            22 snprintf [294]
              44 _PrintfFull [272]
                174 _PutcharFull [8]
                  180 _SNProut [2]
                    182 - [0]
                174 __iar_Strchr [2] ***
                174 strlen [6] ***
                174 __iar_Memchr [6] ***
                174 _LdtobFull [142] ***
                174 LoadInt [4] ***
                174 _LitobFull [98] ***
                176 _PutcharsFull [26]
                  194 _PutcharFull [8] ***
                176 pad [46]
                  196 _PutcharsFull [26] ***
                178 - [0]
            20 ?DivMod16u [2] ***
          2 GSMResponseHandler [2] ***
          2 GSMMessageHandler [298]
            12 memset [10] ***
            12 strtol [88] ***
            12 strcat [2] ***
            12 strlen [6] ***
            14 sprintf [286] ***
            12 PrepareSMS [36]
              38 strlen [6] ***
              38 memset [10] ***
              38 strcat [2] ***
            12 SendATCommand [36] ***
          2 SendATCommand [36] ***
          2 ScanKey [2]
            4 - [0]
          2 SendSMSFunction [20]
            4 GSMSendCommand [18] ***
            4 Tx_UART_A2_String [12] ***
            4 Tx_UART_A2_Char [2] ***
          2 GSMFlashRW [190]
            4 GSMFlashCommandParser [188] ***
            4 GSMSendCommand [18] ***
            4 Tx_UART_A2_String [12] ***
            4 Tx_UART_A0_String [4] ***
            4 SendATCommand [36] ***
            4 GSMModemReset [20] ***
          2 GSMSwitchToCommand [4] ***
          2 OTA_update [216]
            4 Erase_Flash [32]
              10 Tx_UART_A0_String [4] ***
              10 init_M25p80_Flash_OTA [26]
                20 Init_SPI_USCI_B2 [2] ***
                20 halMcuWaitMs [4] ***
                20 powerOnFlash [16]
                  30 halMcuWaitUs [2] ***
                  30 M25P80_SPI_TXRX [6] ***
                20 M25P80_Read_ID [8]
                  22 M25P80_SPI_TXRX [6] ***
                20 M25P80_ERASE_BULK [14] ***
              10 Flash_m25p80_Sector_Erase [18]
                20 M25P80_BLOCK_WIP [8]
                  22 M25P80_SPI_TXRX [6] ***
                  22 halMcuWaitUs [2] ***
                20 M25P80_WriteEnable [8] ***
                20 M25P80_SPI_TXRX [6] ***
                20 halMcuWaitUs [2] ***
                20 halMcuWaitMs [4] ***
            4 SST_Read_Status_Register [8] ***
            4 SendATCommand [36] ***
            4 InitGSM_UART_A2_9600 [2]
              6 - [0]
            4 Tx_UART_A0_String [4] ***
            4 FTPConnect [214]
              200 memset [10] ***
              200 GSMSendCommand [18] ***
            4 InitGSM_UART_A2 [2] ***
            4 OtaAckSms [28]
              22 memset [10] ***
            4 SendOtaSms [28]
              14 GSMSendCommand [18] ***
              14 Tx_UART_A2_String [12] ***
            6 M25P80_FLASH_WRITE [46] ***
            4 Validate_CRC_Hex_File_Rxd [50]
              38 Tx_UART_A0_String [4] ***
              38 M25P80_START_CONTINOUS_FLASH_READ [16]
                48 M25P80_SPI_TXRX [6] ***
                50 - [0]
              38 M25P80_STOP_CONTINOUS_FLASH_READ [2]
                40 - [0]
            4 Program_MSP_Flash [10]
              14 - [0]
        0 exit [8]
          0 _exit [8]
            2 __exit [6]
              6 __DebugBreak [2]
                8 - [0]
          2 - [0]
    
    
    
    

  • Clemens Ladisch said:
    Apparently, your code jumps to a wrong address.

    It's not possible to say more without knowing the code.

    Hi Clemens,


    Thanks for your response. I cannot share the code in a public forum, since i'm working in a company.

    Please share your personal email to the below mail id, so that i can share my code.

    manoj.r@trinitymobility.com


    Thanks,

    Manoj.

  • >I'm not able to verify the "max stack usage + max call chain for worst-case". Kindly advise me how to verify that using the IAR tool.

    Easiest & quickest way to check stack - init code shall fill whole stack with signature words like 0xDEAD or 0xBEEF or both. After code runs you can attach debugger to see how much of the "signed stack" is overwritten. This will show max stack usage.

  • Manoj Srinivasan said:
    I'm not able to verify the "max stack usage + max call chain for worst-case". Kindly advise me how to verify that using the IAR tool.

    You do it manually. Find the longest call chain stack usage. Find the longest IRQ chain stack usage. Add the two. Make sure your reserved stack space in your linker settings/file is more than that worst case number.

    Now.... the version of IAR I am currently using doesn't seem to have the static stack usage analysis in the project options. Hmmm, I know I've seen it and used it before.

    Regardless, llmars just gave you another option to check it empirically (memset the stack in __low_level_init() function). Caution should be noted that unless your test exercises every code path and IRQ possibility then this is just a guidance number - your stack should have some additional cushion space.

    All of this assumes a monolithic application. Once you add an RTOS with context-switching and thread-specific stacks then the analysis becomes much harder. This is probably not your scenario but I mention it for completeness.

  • One more possible reason for your problem is something else is trashing your stack. Like perhaps an errant or uninitialized pointer.

**Attention** This is a public forum