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;
}
}