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.

TIVA TM4C123GH6PM Hard Fault

Hi all,

I have a fault with my code, i find the line that got program into hard fault.

Here is my program, could u guy pls help me fix the problem. THANKS

void Timer1IntHandler(void) //1s calculate rpm, output pwm
{
	TimerIntClear(TIMER1_BASE, TIMER_TIMA_TIMEOUT );
	PWMGenDisable(PWM0_BASE, PWM_GEN_3);               // IN DEBUG I FIND OUT THIS LINE CAUSE FAULT ISR
	pulse_count = TimerLoadGet(WTIMER0_BASE, TIMER_B)-TimerValueGet(WTIMER0_BASE, TIMER_B);
	rpm = 60*pulse_count/(334);
	TimerLoadSet(WTIMER0_BASE, TIMER_B,10000000);
	UpdatePID();
	PWMPulseWidthSet(PWM0_BASE, PWM_OUT_6,Output);
	PWMGenEnable(PWM0_BASE, PWM_GEN_3);
}

  • Hello Nvadugx

    The peripheral corresponding to the address 0x40028000 has not been enabled. That is why you are getting the bus fault.

    Regards
    Amit
  • Hi Amit
    i look up the hw_memmap and find out the address 0x40028000 = PWM_BASE0, so i think i config pwm wrong.
    here my config pwm code, i try to run it on an other project and i run fine, can u pls point out where i do wrong:

    void COnfigPWM()
    {
    SysCtlPWMClockSet(SYSCTL_PWMDIV_1);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM0); // module 0, PC4 PWM6
    PWM_Period = SysCtlClockGet()/1000; //50MHz/1000 =50000 pwmclock.(max = 65535) 1000hz

    //Configure PF1 pins as PWM
    GPIOPinTypePWM(GPIO_PORTC_BASE, GPIO_PIN_4);
    GPIOPinConfigure(GPIO_PC4_M0PWM6);

    //Configure PWM Options
    PWMGenConfigure(PWM0_BASE, PWM_GEN_3, PWM_GEN_MODE_DOWN | PWM_GEN_MODE_NO_SYNC);
    PWMGenPeriodSet(PWM0_BASE, PWM_GEN_3, PWM_Period);
    //Turn on the Output pins
    PWMPulseWidthSet(PWM0_BASE, PWM_OUT_6,50);
    PWMOutputState(PWM0_BASE, PWM_OUT_6_BIT, true);
    PWMGenEnable(PWM0_BASE, PWM_GEN_3);
    }
  • Hello Nvadugx,

    I think the Timer Interrupt Handler is getting asserted before the PWM module is enabled, which is causing the issue.

    Regards
    Amit
  • Thank for your suggestion Amit, i think that was problem.
    Best regards
  • Hello Nvadugx,

    One simple way of avoiding it is to ensure that instead of CPU reset a System Reset is done in CCS.

    Regards
    Amit