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.

Compiler/TM4C1230H6PM: Fault ISR calling a TiVa ware API

Part Number: TM4C1230H6PM

Tool/software: TI C/C++ Compiler

All,

I am struggling with the code below - it jumps to the fault ISR while(1) once I reach the first TiVa API (here: SysCtlClockFreqSet)

I guess it could be something wrong with the startup_ccs.c?

#include <stdint.h>
#include <stdbool.h>
#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/debug.h"
#include "driverlib/gpio.h"
#include "driverlib/interrupt.h"
#include "driverlib/pin_map.h"
#include "driverlib/sysctl.h"
#include "driverlib/timer.h"

void init ();


uint32_t g_ui32Flags; // Flags that contain the current value of the interrupt indicator as displayed on the UART.


int main(void)
{

//init ();

uint32_t g_ui32SysClock; // System clock rate in Hz.

g_ui32SysClock = SysCtlClockFreqSet((SYSCTL_XTAL_16MHZ |
SYSCTL_OSC_MAIN |
SYSCTL_USE_PLL |
SYSCTL_CFG_VCO_480), 120000000); // Set the clocking to run directly from the crystal at 120MHz.

SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG); // Enable the GPIO ports
GPIOPinTypeGPIOOutput(GPIO_PORTG_BASE, GPIO_PIN_0 | GPIO_PIN_1); // Enable the GPIO pins for the LEDs (PN0 & PN1)

IntMasterEnable(); // Enable processor interrupts

SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0); // Enable Timer0
TimerConfigure(TIMER0_BASE, TIMER_CFG_PERIODIC); // Configure the Timer0 32-bit periodic timers
TimerLoadSet(TIMER0_BASE, TIMER_A, g_ui32SysClock);
IntEnable(INT_TIMER0A); // Setup the interrupts for the timer timeouts
TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
TimerEnable(TIMER0_BASE, TIMER_A); // Enable the timer

while(1)
{
}
}


void Timer0IntHandler(void) // The interrupt handler for the timer interrupt.
{
TimerIntClear(TIMER0_BASE, TIMER_TIMA_TIMEOUT);

HWREGBITW(&g_ui32Flags, 0) ^= 1; // Toggle the flag for the first timer

GPIOPinWrite(GPIO_PORTG_BASE, GPIO_PIN_0, g_ui32Flags); // Use the flags to Toggle the LED for this timer
}

complete project attached.Notstrom.zip

Thanks for your help,

Gunter

  • Gunter Heuer said:
    g_ui32SysClock = SysCtlClockFreqSet((SYSCTL_XTAL_16MHZ |
    SYSCTL_OSC_MAIN |
    SYSCTL_USE_PLL |
    SYSCTL_CFG_VCO_480), 120000000); // Set the clocking to run directly from the crystal at 120MHz.

    The SysCtlClockFreqSet() function is only for use on TM4C129 devices. For use with TM4C123 devices such as the TM4C1230H6PM in your project the SysCtlClockSet() function should be used.

    Also, for TM4C123 devices the maximum CPU frequency is 80MHz. Therefore, to set the maximum CPU frequency for a TM4C1230H6PM try using the following:

            /* Set the system clock to run at 80 MHz off the PLL with external crystal as reference. */
            SysCtlClockSet (SYSCTL_SYSDIV_2_5 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN);
            g_ui32SysClock = SysCtlClockGet ();

  • Thanks for the quick response.
    Unfortunately, I does not solve the issue. It still ends with ISR fault routine...
  • Poster Chester's advice was, "Spot On!"

    That you (still) land w/in dreaded "Fault ISR" indicates (other sources of error) w/in your code.

    Would it not prove wise to use a, "Known GOOD, Vendor Supplied, Small Program" and confirm that it works?    

    There are MANY IDE Settings which you must "get right" - and use of the "vendor supplied programs" has, "Done ALL of the "heavy lifting" for you!"

    Such warrants your consideration - does it not?     After that vendor program runs (and avoids Fault ISR) you may gradually add "bits/pieces" of your own code - (now) confident that (at least) the IDE has been properly "Set-Up."     (improper IDE Set-Up is a major cause of, "Fault ISR Visitation!")

  • This comment does not help, sorry.
    In fact, my source Code is nearly 100% the code from the example "Timers".
    Nevertheless, there are some Challenges left.
    Perhaps someone more experienced could invest 3 minutes - I am sure it is a minor issue, but too hidden for me.

    Thanks in Advance.
  • Hello Gunter,

    Once you updated the SysClk API as Chester instructed, are you entering the Fault_ISR at a point later than the SysClk API?

    If so then

    Gunter Heuer said:
    I guess it could be something wrong with the startup_ccs.c?

    This is probably true. Looking at your startup_ccs.c file, you have correctly extern'd your Timer0IntHandler, but it isn't added to the vector table in place of IntDefaultHandler.

  • Gunter Heuer said:
    This comment does not help, sorry.

    You may note that such comment, "Employ known good, unchanged, vendor example code" has been voiced by this vendor - many times.     Thus - your comment, "Does not help" appears subject to debate.   You admit to having made (some) changes (i.e. "nearly 100%") - thus you've "invited uncertainty & mistakes" (proven by your entry w/in Fault ISR) have you not?

    Gunter Heuer said:
    Perhaps someone more experienced could invest 3 minutes - I am sure it is a minor issue

    You know "nothing" of my experience - nor do you attempt to justify the investment of "3 minutes" - yet you are "sure" of your failure - proving "minor."    From where do such "proclamations" spring - and how have you achieved such "sureness?"     As to experience - that can be gleaned from my forum profile - it is doubtful that the experience of (many) here exceeds my own.    (having past co-founded - then taking tech firm PUBLIC - and long reaching top US tax bracket...)

    A clear attempt was made to "applaud the effort of another" AND to guide you - which resulted (only) in your "unkind & ill investigated" remarks...    (No thanks sought nor required...)

  • All,

    @ Ralph: Thanks for your input - but it doesn´t solve the problem.
    I have entered the interrupt vector.
    It seems, that calling the sysctlclockset function or ANY further TiVa ware function lead to the interrupt fault loop.
    Any other functions (for example for---while loops) are working fine .
    Is there anything I have forgotten to use the Tiva ware APIs?

    @ cb1_mobile:
    Sorry for the misunderstanding - the statement "somebody more ecperienced" was in comparison to MY experience.
    I never would judge on your experience, sorry. How coudl I??!!


    best regards Gunter
  • Gunter Heuer said:
    Is there anything I have forgotten to use the Tiva ware APIs?

    From the description of the problem can't see what is causing the hard fault.

    Diagnosing Software Faults in Stellaris® Microcontrollers has guidance on how to determine the cause of the fault ISR (the document was written for the previous Stellaris devices but it still applicable to Tiva devices).

    Also, can you you clarify if you are using a TI evaluation board or a custom board?

  • Have you added your interrupt handler to the vector table in the Startup module?

    You need to add it to the correct line of the vector table for it to be linked into your system.

    See the partial table from one of mine below:

       (void (*)(void))((uint32_t)&__STACK_TOP),
                                                // The initial stack pointer
        ResetISR,                               // The reset handler
        NmiSR,                                  // The NMI handler
        FaultISR,                               // The hard fault handler
        IntDefaultHandler,                      // The MPU fault handler
        IntDefaultHandler,                      // The bus fault handler
        IntDefaultHandler,                      // The usage fault handler
        0,                                      // Reserved
        0,                                      // Reserved
        0,                                      // Reserved
        0,                                      // Reserved
        IntDefaultHandler,                      // SVCall handler
        IntDefaultHandler,                      // Debug monitor handler
        0,                                      // Reserved
        IntDefaultHandler,                      // The PendSV handler
        SysTickHandler,                         // The SysTick handler
        IntDefaultHandler,                      // GPIO Port A
        IntDefaultHandler,                      // GPIO Port B

  • Guys,

    sorry, I was out for some days because of a business trip.

    In the meantime, I have found the problem: Interrupt vector was entered at WIDEtimer 0 and not at timer0.

    Thanks for your help,

    Gunter