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.

[Fault ISR] Tiva Controller

Other Parts Discussed in Thread: TM4C123GH6PZ

Hi,

I'm using TM4C123GH6PZ Controller in CCS 6.0.

When i run my code it is going to fault isr.

i have enabled peripherals as follows

SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOH);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOK);

GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE,GPIO_PIN_0 | GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_4);
GPIOPinTypeGPIOInput(GPIO_PORTA_BASE,GPIO_PIN_1| GPIO_PIN_6);

 in a common.c file and included this file in my main file.

when i run my code its going into fault isr.

i followed      http://www.ti.com/lit/an/spma043/spma043.pdf document and found that i'm getting "Hard Fault" for GPIO Port.

When i reinitialize port in main file the statement is passing  in debug mode, otherwise it is going to faultisr.

please let me know where i'm going wrong. 

Thank You.

  • Hi,

       Attach your CCS project files here, for review.

    - kel

  • Hi Markel,

                   Thank you for the reply.Its a company project i'm unable to attach the project. i'm giving the information of problem where i'm facing.

                  In common.c file i'm enabling the ports.

    #include "common_header_h.h"
    
    void BoardConfig(void)
    {
    //	//Enable Clock ,Use PLL
    
    	SysCtlClockSet(SYSCTL_SYSDIV_2_5 | SYSCTL_USE_OSC | SYSCTL_USE_PLL  | SYSCTL_OSC_MAIN |SYSCTL_XTAL_8MHZ);
    
    	// Enable PORTA,PORTB,PORTC,PORTD,PORTE,PORTF,PORTG,PORTH & PORTK
    	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
    	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
    	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
    	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
    	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
    	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
    	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG);
    	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOH);
    	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOJ);
    	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOK);
    
    	
    	GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE,GPIO_PIN_0  | GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_4);
    
    	GPIOPinTypeGPIOInput(GPIO_PORTA_BASE,GPIO_PIN_1| GPIO_PIN_6);
    
    	GPIOPinTypeGPIOOutput(GPIO_PORTB_BASE, GPIO_PIN_2 | GPIO_PIN_4 | GPIO_PIN_5 );
    
    	GPIOPinTypeGPIOOutput(GPIO_PORTC_BASE,GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 );
    	GPIOPinTypeGPIOInput(GPIO_PORTC_BASE,GPIO_PIN_7);
    }

    In  common_header_h.h file i have included as follows

    #include <assert.h>
    #include "inc/tm4c123gh6pz.h"
    #include "stdbool.h"
    #include "stdint.h"
    
    #include "inc/hw_types.h"
    #include "driverlib/timer.h"
    #include "inc/hw_memmap.h"
    #include "driverlib/pin_map.h"
    #include "driverlib/rom.h"
    #include "inc/hw_types.h"
    #include "driverlib/debug.h"
    #include "driverlib/gpio.h"
    #include "driverlib/interrupt.h"
    #include "driverlib/sysctl.h"
    #include "driverlib/uart.h"
    #include "driverlib/can.h"
    #include "utils/uartstdio.h"
    #include "string.h"
    #include "inc/hw_i2c.h"
    #include "driverlib/i2c.h"
    #include "driverlib/adc.h"
    #include "inc\hw_gpio.h"
    #include "commons.h"
    #include "crc8.h"

    in commons.h 

    extern void BoardConfig(void);

    and in Main.c

    #include "common_header_h.h"
    
    unsigned long TempCountVar = 0;
    
    void MKM_Initialitation(unsigned char ucNumberOfCells)
    {
    	//Initialize all GPIO
        BoardConfig();
    
    
        // Get number of cells
        ucNumberOfCells = 10;
    
    
    
    void MKM_code_Initial_setting(unsigned char ucNumberOfCells)
    {
    	    GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_5, 0X20);
                GPIOPinWrite(GPIO_PORTE_BASE, GPIO_PIN_3, 0X08); 
    	    chTimer = getTimeStamp();
    	    sleepTimer = getSeconds();
    }
    
    
    int main(void)
    {
    
    	unsigned char ucNumberOfCells = 10;
    
    
        MKM_Initialitation(ucNumberOfCells);
        MKM_code_Initial_setting(ucNumberOfCells);
    
    
        while(1)
    	{
            TempCountVar++; // Dummy Count
    
    
    }
    
    	}
    }
    
    
    

    In when i run above code its going into fault isr in 

    void MKM_code_Initial_setting(unsigned char ucNumberOfCells)
    {
    	    GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_5, 0X20);
                GPIOPinWrite(GPIO_PORTE_BASE, GPIO_PIN_3, 0X08); 
    	    chTimer = getTimeStamp();
    	    sleepTimer = getSeconds();
    }

    if i comment 

    GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_5, 0X20);

    its passing below line in debug mode

          GPIOPinWrite(GPIO_PORTE_BASE, GPIO_PIN_3, 0X08); 

    My question is both are same functions why it is working with PORT E whynot with port B.

    if i add 

    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
    GPIOPinTypeGPIOOutput(GPIO_PORTB_BASE, GPIO_PIN_2 | GPIO_PIN_4 | GPIO_PIN_5 );

    lines above 

    GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_5, 0X20);

    its not going to fault isr.

    Why i have to initialize again even i initialized before.

    Thank You

  • Hello Ramesh

    Which version of TIVAWare are you using?

    Regards

    Amit

  • Hi Amit,

    I'm using TivaWare_C_Series-2.0.1.11577

     

  • @Ramesh.

        I noticed that at your main function, there is an extra curly brace.

    - kel

  • Hi Markel,

                    Its my mistake while pasting the code in the forum,that brace is not present in the code. 

  • @Ramesh,

        As you said it goes to FaultISR when the code runs into "MKM_code_Initial_setting". Put a breakpoint inside MKM_code_Initial_setting then step through the code, see which line it goes into a Fault.

       Also regarding TempCountVar++; at your while loop, is there any part of your code that resets the value to 0?

    - kel

  • Hi Markel,

     I keep breakpoint in the code 

    at the below line its going into fault isr

    GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_5, 0X20);

    if i add below lines
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
    GPIOPinTypeGPIOOutput(GPIO_PORTB_BASE, GPIO_PIN_2 | GPIO_PIN_4 | GPIO_PIN_5 );

    its working fine.

    but i already initialized that port in common.c

    in MKM_code_Initial_setting  function   

    GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_5, 0X20);
            GPIOPinWrite(GPIO_PORTE_BASE, GPIO_PIN_3, 0X08);
    

    fault isr  occurs with first line but not with second line and both are same function ( GPIOPinWrite ();)

    Thank You

  • Hi, 

    RAMESH CHAND said:
    GPIOPinWrite(GPIO_PORTE_BASE, GPIO_PIN_3, 0X08);

    Where in your code that sets PORTE as output?

    - kel

  • Hello Ramesh,

    I took the code that you had posted and ran it on my EK-TM4C123 LaunchPad. It works without any issues. I have attached the CCS Project for your reference.

    http://e2e.ti.com/cfs-file.ashx/__key/communityserver-discussions-components-files/908/5808.TM4C123_5F00_GPIOFaultISR.7z

    Please do note that some functions I have commented as I do not have the proto define for them and some of the coding mistakes that Kel has highlighted have also been accounted for in the package.

    First run this code w/o any modifications.

    Regards

    Amit

  • Hello Amit,

    I am facuing the similar issue with the code.

    On looking ate faultISR Detail, I am getting HARD FAult.

    While I am running the code it goes to faultISR(), but while debugging if I try and run step by step using step info code works perfectly fine.

    Could you pllease help me out with it?

    Regards,

    Mitesh

  • Hi Mitesh,

    Much better to create a new post about your faultISR() problem and provide all details, including code snippets.

    - kel
  • Hello Mitesh

    Check the FAULTSTATand FAULTADDR registers. More details on simple Fault debug in the following post

    e2e.ti.com/.../374640