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.

MSP432P4111: Hard Fault interrupt invoked when starting real time clock

Part Number: MSP432P4111

I'm getting a Hard Fault Interrupt when I invoke the following code:

Note that this is a port from a large MSP430-based legacy system, so I'm not sure if the cause has anything to do with the real time clock or if it's because I'm enabling global interrupts.

I see the UNALIGNED bit is set in CFSR and the STKALIGN bit is set in CCR after the Hard Fault is invoked:

Any ideas?

Thx

  • Sorry, nothing showed up when I pasted it in, and this interface is definitely not WSYWIG.  None of the icons for inserting content are working for me right now.  I can't show you my register window capture, but I can show you the code:

    RTC_C_initCalendar(&currentTime,RTC_C_FORMAT_BCD);

    //Enable interrupt for RTC Ready Status, which asserts when the RTC

    //Calendar registers are ready to read.

    RTC_C_clearInterruptFlag(RTC_C_CLOCK_READ_READY_INTERRUPT); // | RTC_C_OSCILLATOR_FAULT_INTERRUPT); //clear flag before enabling interrupt

    RTC_C_enableInterrupt(RTC_C_CLOCK_READ_READY_INTERRUPT); // | RTC_C_OSCILLATOR_FAULT_INTERRUPT); //enable ready interrupt and fault interrupt

    Interrupt_enableInterrupt(INT_RTC_C);

    Interrupt_enableMaster();

    for (i= 0; i< 50000; i++)

    __no_operation();

    RTC_C_startClock(); //start clock

     

  • Are you fairly certain this is a Hard Fault, not just a call to Default_Handler?

    An easy way to obtain the latter is to misspell the ISR name. The name matters in the MSP432, but not in the MSP430.

  • I created a separate HardFault_Handler() function to be sure I was invoking it, so yes, I'm sure.

    I seem to have found the cause of the problem, which was a data assignment within the interrupt itself.  If I understand correctly a Hard Fault can be caused by a data alignment issue with addressing, as might happen when porting MSP430 code, which is 16-bit, to an MSP432 platform, which is 32-bit.  There are numerous data structures which may not port properly, so I'm trying to get an idea of what to look out for if and when I have this problem again.

    Thanks.

  • I would actually like to show you guys the code that caused the Hard Fault, in case there's some insight someone can share regarding the cause.  The workaround is fine, but it's odd that reading the return value of the real time clock value to a field of a global struct variable causes a Hard Fault, while reading it to a local variable, then to the struct variable does not:

    RTC_C_Calendar rtc_time;

    //TODO: sysRamData.rtcV = RTC_C_getCalendarTime(); //causes Hard Fault(?)

    rtc_time= RTC_C_getCalendarTime();

    sysRamData.rtcV= rtc_time;

  • OK, I found the source of the issue in the definition of the struct.  When I commented out the pragma directive below the problem went away, trading memory for more robust performance.

    //#pragma pack(1)

    typedef struct

    {

    __RAM_PT__ pt;

    __CAL__ cali;

    RTC_C_Calendar rtcV;

**Attention** This is a public forum