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.

MSP432E411Y: How to trace code location before entering handler HardFault

Guru 12065 points
Part Number: MSP432E411Y

Hi, 

I would like to know what code was executed before entering Default_handler. Is there a register where the address of the last executed code is stored? If not, I would like to know how to check with CCS.

Here is the sample code I am currently running.
・simplelink_msp432e4_sdk_4_20_00_12\examples\nortos\MSP432E411Y_BGAEVM\demos\outofbox_msp432e411y

Thanks,
Astro

  • Hello Astro,

    Yes, the PSR register can be checked and the lower 8-bits will indicate what the exception number was. It will be in hexadecimal format by default but you will want the decimal equivalent.

    Once you have that, refer to table 6.3.3 Nested Vectored Interrupt Controller (NVIC) of the Device Datasheet and match the exception number to the vector number on the table to find out which peripheral interrupt was triggered.

    Best Regards,

    Ralph Jacobi

  • Hi, Ralph 

    Thank you for your answer.

    [Question 1]
    I checked the PSR value and the exception number was 0x03. As far as the data sheet is concerned, it is thought that it was caused by an interrupt of GPIO Port D. is my perception correct?

    [Question 2]
    If my understanding of question 1 is correct, then we need to consider why the interrupt occurs.
    Currently, I am checking the operation of the Ethernet function.
    I found a sample using the Iwip protocol stack with Ethernet in the SDK, so I made some changes and confirmed the operation.
    After exchanging the DHCP Ack message with the DHCP server, the assigned IP address is not output and a hard fault occurs and the Default_Handler() function goes into an infinite loop.

    Is it possible to get any comments?

    Thanks,
    Astro

  • Hello Astro,

    If the value in the PSR handler is 0x03 then you didn't hit a Default Handler but rather the system Fault Handler. That's a different kind of fault.

    The Fault Handler is most commonly hit when you try and access a peripheral that hasn't been enabled yet.

    What you will want to look for is both the NVIC_FAULT_STAT and potentially the NVIC_FAULT_ADDR values.

    The NVIC_FAULT_STAT values are all provided in the Technical Reference Manual under Table 2-37. FAULTSTAT Register Field Descriptions. So check what kind of error you have.

    If the NVIC_FAULT_STAT indicates that a Precise Bus Fault occurred, then you can check NVIC_FAULT_ADDR to see what part of the device triggered the fault. If it's a peripheral, you likely tried to access it before it was enabled.

    If you have something different from that, report back what the fault value is and I can provide further guidance.

    Best Regards,

    Ralph Jacobi

  • Hi, Ralph 

    Thank you for your reply.

    The MCU has a Precise Bus Fault and NVIC_FAULT_ADDR is 0x00B00953. Is it possible to get any comments?

    Thanks,

    Astro

  • Hello Astro,

    The address that triggered the fault is outside of the typical code execution regions so I suspect a Stack Overflow occurred. Please increase the size of your system stack and see if the fault continues to happen.

    Best Regards,

    Ralph Jacobi

  • Hi, Ralph 

    Please increase the size of your system stack and see if the fault continues to happen.

    I'm trying to verify increasing the capacity of the stack to avoid stack overflow.
    I increased the stack size from the CCS basic options and clicked the build button, but the stack size in the linker command file does not change. Are the above steps correct?

    Thanks,

    Astro

  • Hello Astro,

    Please see the following about how to adjust stack size. It is for a different MCU but applies to SimpleLink SDK for the MSP432E4 as well. It also has details about application stack in case you need that in the future as well:

    https://e2e.ti.com/support/tools/code-composer-studio-group/ccs/f/code-composer-studio-forum/874238/ccs-msp432p401r-how-to-increase-stack-size-of-the-rtos-application/3234707#3234707

    Best Regards,

    Ralph Jacobi

  • Hi, Ralph 

    This time, we are developing with nonRTOS (bare metal). As far as the URL is concerned, it looks like a stack adjustment method for TI-RTOS. Does the same procedure apply for nonRTOS?

    Thanks,

    Astro

  • Hello Astro,

    For non-RTOS / bare metal, the way you were trying to do it should work by changing it under --stack_size in Basic Options. I don't believe that setting would change the hard coded value in the Linker Command file automatically, but if you provide a setting there it should be used over the value in the hard coded Linker file.

    Best Regards,

    Ralph Jacobi