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.

CCS/TM4C123GH6PM: Fault Interrupt

Part Number: TM4C123GH6PM
Other Parts Discussed in Thread: SW-TM4C

Tool/software: Code Composer Studio

Hello

My problem is when I resume the program it stucks in this infinite loop shown in the photo below 

Here is the program 

#define led (*((volatile unsigned long *)0x40025008)) // BF1 RED LED
#define sw1sw2 (*((volatile unsigned long *)0x40025044)) // PF4 SW1 & PFO SW2
#define GPIO_PORTF_DIR_R (*((volatile unsigned long *)0x40025400))
#define GPIO_PORTF_AFSEL_R (*((volatile unsigned long *)0x40025420))
#define GPIO_PORTF_PUR_R (*((volatile unsigned long *)0x40025510))
#define GPIO_PORTF_DEN_R (*((volatile unsigned long *)0x4002551C))
#define GPIO_PORTF_LOCK_R (*((volatile unsigned long *)0x40025520))
#define GPIO_PORTF_CR_R (*((volatile unsigned long *)0x40025524))
#define GPIO_PORTF_AMSEL_R (*((volatile unsigned long *)0x40025528))
#define GPIO_PORTF_PCTL_R (*((volatile unsigned long *)0x4002552C))
#define SYSCTL_RCGC2_R (*((volatile unsigned long *)0x400FE108))
//SysTick Timer
#define NVIC_ST_CTRL_R (*((volatile unsigned long *)0XE000E010))
#define NVIC_ST_RELOAD_R (*((volatile unsigned long *)0XE000E014))
#define NVIC_ST_CURRENT_R (*((volatile unsigned long *)0XE000E018))

void INIT(void){
volatile unsigned long delay;
SYSCTL_RCGC2_R |= 0x00000020; // 1) activate clock for Port F
delay = SYSCTL_RCGC2_R; // allow time for clock to start
GPIO_PORTF_LOCK_R = 0x4C4F434B; // 2) unlock GPIO Port F
GPIO_PORTF_CR_R |= 0x13; // allow changes to PF1 AND PF4 AND PF0
GPIO_PORTF_AMSEL_R &= ~0x13; // 3) disable analog on PF1 AND PF4 AND PF0
GPIO_PORTF_PCTL_R &= ~0x000F00FF; // 4) PCTL GPIO on PF1 AND PF4AND PF0
GPIO_PORTF_DIR_R |= 0x02; // 5) PF4,PF0 in(switches), PF3-1 out ->0x 0000 1110(leds)
GPIO_PORTF_DIR_R &= ~0x11;
GPIO_PORTF_PUR_R |= 0x11;
GPIO_PORTF_AFSEL_R &= ~0x13; // 6) disable alt funct on PF7-0
GPIO_PORTF_DEN_R |= 0x13; // 7) enable digital I/O on PF1
}
void SYSTICK(void){
NVIC_ST_CTRL_R &= ~0x01;//disable systick timer
NVIC_ST_RELOAD_R= 0x00FFFFFF ;// initialize reload reg value
NVIC_ST_CURRENT_R= 0xAA;//put any value in current reg to reset it
NVIC_ST_CTRL_R = 0x05; //choose system clock (16MHZ)//disable interrupt//enable the counter so it starts ticks
}
void delay(void){
unsigned long count;
count = 79999; //Oscillates at 10 HZ

while (count) {
count--;
}
}
void main(void) {
INIT();
SYSTICK();
led=0X02;
unsigned long start,end;
unsigned long i=0;
float time[50];
unsigned long state[50];
unsigned long switches[50];
unsigned long accurate =799105;
unsigned int error=0;

while(1){
if (sw1sw2 !=0x11 )
{
led =led ^ 0X02;
start =NVIC_ST_CURRENT_R;
delay();
end=NVIC_ST_CURRENT_R;


if (i<50)
{
time[i]=(start - end )*0.0000000625 ;
state[i]=led&0x02;
switches[i]= sw1sw2 & 0x11;
if ((start - end )<879015 || (start - end )>719194)
{error ++;}
i++;
}
}
else
led=0;
}


}

  • Chaymae Harfoush said:
    My problem is when I resume the program it stucks in this infinite loop shown in the photo below

    That means the program has generated a hard fault. See Diagnosing Software Faults in Stellaris for how to determine the cause of a hard fault.

    Also, what is reason for coding using #defines for peripheral registers in the program rather than using TivaWare?

  • Hello Chaymae,

    Since you are using register level calls and not TivaWare it's not really easy to say. With TivaWare, a common issue is that an ISR isn't correctly directed in the startup_ccs.c file, but I am not sure if you are even using that.

    Please get the latest TivaWare and use that for your application: www.ti.com/tool/sw-tm4c
  • Hello
    I have just started learning from EDX course "Embedded Systems - Shape the World" and they are using #defines for peripheral registers not TivaWare. If you have other resource to learn from as a beginner I'd appreciate that.

    thank you for your help,
    Chaymae

  • Hello Chaymae,

    I see, that's a pity that they are doing the course that way. I have heard of it but wasn't aware they aren't using TivaWare. We don't really have much documentation for register level calls. What Chester posted is probably the best point to work from as far as error discovery. All beginners with the device are referred to TivaWare and it is very rare that even experts use such register level changes and even then only do so for very specific application purposes that TivaWare does not cover.

    The course may have some sort of support system built in though so you may want to investigate if there is any way to submit questions in there.

    Anyways, in general a fault ISR occurs when:

    1) Your ISR has not been linked to the interrupt vector table properly

    2) An interrupt has been enabled that shouldn't be (as there is no ISR for it) and is going the fault ISR.

    That's about all the guidance I can offer on the matter, so good look with that.

  • Chaymae,

    Despite the course teaching direct registry programming, don't give that part too much attention. You can still follow the course, and at the same time download Tivaware from TI's site, and read the DRL-UG (driverlib user guide) which is inside the /docs folder.

    You will note that there is a probably a function for every low level driver configuration that you need during the course. Simple "ignore all that bunch of binary configuration" and replace them by Tivaware calls. Certainly, the important part of the course is the "programming structure", the logic behind the loops, the timing control, etc...

    Also, you will find simple examples that come with Tivaware that will teach you to blink a led. Looking at those codes and getting familiar with them is quite useful. After you get the led to blink the way you want, sending a rocket to Mars is just a few steps further...

    Bruno