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.

EK-TM4C123GXL: Input port clock is off (PORT A) need help turning it on

Part Number: EK-TM4C123GXL
Other Parts Discussed in Thread: TM4C123GH6PM,

Hello, I am currently exploring some blinking LED code and am having trouble with error message Abort:Input port clock is off. I am confused as to why it will run on the simulator and on the real board but will not execute when debugging. Any tips or suggestions are appreciated. Thank you. 

// ***** 1. Pre-processor Directives Section *****

#define PA2 (*((volatile unsigned long *)0x40004010))
#define PA3 (*((volatile unsigned long *)0x40004020))
#define PA32 (*((volatile unsigned long *)0x40004030))
#define GPIO_PORTA_DATA_R (*((volatile unsigned long *)0x400043FC))
#define GPIO_PORTA_DIR_R (*((volatile unsigned long *)0x40004400))
#define GPIO_PORTA_AFSEL_R (*((volatile unsigned long *)0x40004420))
#define GPIO_PORTA_DEN_R (*((volatile unsigned long *)0x4000451C))
#define GPIO_PORTA_AMSEL_R (*((volatile unsigned long *)0x40004528))
#define GPIO_PORTA_PCTL_R (*((volatile unsigned long *)0x4000452C))
#define SYSCTL_RCGC2_R (*((volatile unsigned long *)0x400FE108))
//#define SYSCTL_RCGC2_GPIO_R (*((volatile unsigned long *)0x00000001)) // port A Clock Gating Control
#include "TExaS.h"
#include "tm4c123gh6pm.h"

void LED_On(void);
void LED_Off(void);
void LED_Init(void);
void EnableInterrupts(void);
void delay(unsigned long halfsecs);
unsigned long SW1;
unsigned long out;

int main(void){
TExaS_Init(SW_PIN_PE0, LED_PIN_PE1, ScopeOn); // activate grader and set system clock to 80 MHz
EnableInterrupts(); // enable interrupts for the grader
LED_Init();// initialize PA2 and make it output
while(1){
LED_On(); // c) LED signal goes low
do {
PA2 = GPIO_PORTA_DATA_R&0x10;
}while(PA2 == 0x00); // b) wait for switch to be pressed (zero means SW1 is pressed
LED_Off();
delay(1);
LED_On();
delay(1);
//LED_Off();
//delay(1);
if (PA2 == 0x10)
{LED_On();
}
}
}
// Subroutine to delay in units of half seconds
void delay(unsigned long halfsecs){
unsigned long count;

while(halfsecs > 0 ) { // repeat while there are still halfsecs to delay
count = 1600000; // 400000*0.5/0.13 that it takes 0.13 sec to count down to zero (1638400)
while (count > 0) {
count--;
} // This while loop takes approximately 3 cycles
halfsecs--;
}
}

// Make PA2 high
void LED_On(void){
GPIO_PORTA_DATA_R |= 0x08;
}
// Make PA2 low
void LED_Off(void){
GPIO_PORTA_DATA_R &= ~0x08;
}
// Make PA2 an output, enable digital I/O, ensure alt. functions off
void LED_Init(void){ volatile unsigned long delay;
SYSCTL_RCGC2_R |= 0x00000001; // 1) activate clock for Port A
delay = SYSCTL_RCGC2_R; // allow time for clock to start
// 2) no need to unlock PA2
GPIO_PORTA_PCTL_R &= ~0x00000F00; // 3) regular GPIO
GPIO_PORTA_AMSEL_R &= ~0x04; // 4) disable analog function on PA2
GPIO_PORTA_DIR_R |= ~0x04; // 5) set direction to output
GPIO_PORTA_AFSEL_R &= ~0x04; // 6) regular port function
GPIO_PORTA_DEN_R |= 0x8C; // 7) enable digital port
}

  • First of all, please refer to guideline #4 in this FAQ https://e2e.ti.com/support/microcontrollers/other/f/908/t/695568. Basically, we don't support DRM (direct register maninpulation) style of coding. We provide TivaWare library that allows you to very efficiently develop your project. DRM style of coding is very prone to mistakes. 

    With that said, I can give some comments. 

      You code is confusing and I'm not sure what you are trying to do. You wrote:

    // Make PA2 high
    void LED_On(void){
    GPIO_PORTA_DATA_R |= 0x08;
    }
    // Make PA2 low
    void LED_Off(void){
    GPIO_PORTA_DATA_R &= ~0x08;
    }

    The above code looks more like PA3 rather than PA2 to me. For example 0x1 could have control PA0, 0x2 will control PA1. 0x4 will control PA2 and 0x8 will control PA3. So check what you want to do. 

    You also wrote:

    LED_On(); // c) LED signal goes low
    do {
    PA2 = GPIO_PORTA_DATA_R&0x10;
    }while(PA2 == 0x00); // b) wait for switch to be pressed (zero means SW1 is pressed

    I also have some doubt with the above PA2 assignment. To me, this is not PA2 but rather PA4 to me. You use the UT material. So it is best that you consult with your professor or TA. 

    Just one more comment on your above code, you are trying to blink LED on PA2 and use the same PA2 as a SW1? This is again very confusing. What are you trying to do? This will not work. 

    Finally, if you are using the EK-TM4C123GXL launchPad board then the the SW1 on the board is connected to PF4, not PA2. The LED are mapped to the PF port, not PA port. 

  •  Hello Charles! Thank you for the quick response! Good eye!!! Yes I am trying to use PA3 for an external red LED controlled by PA2 external bounce switch. When the switch is not pressed the Red LED is on, and when the external bounce switch is pressed and held the LED blinks until upon release the Red LED will light solid. The debugger wants the input clock on (and crashes),-this is where I am confused.

    Thank you again for your help (I do not have access to a TA for I am trying to learn this content solo out of an old Valvano ARM textbook).

  • Hello Charles! 

    Take a look at this wire setup (hopefully it showcases how I am using PA2 for external bounce switch on the protoboard and PA3 for the LED). 

    Specifically I do not understand if this is correct address/code to turn on the clock for PORT A 

    //#define SYSCTL_RCGC2_GPIO_R (*((volatile unsigned long *)0x00000001)) // port A Clock Gating Control

    or if I need to fix something on this line

    //SYSCTL_RCGC2_R |= 0x00000001; // 1) activate clock for Port  A

  • Thank you Charles! The problem has been resolved. It seems the TeXas grader (function) was looking for the system on PORTE...and I was trying to test it while built on PORTA (just needed to rebuild it around the clock on PORTE (not PORTA).  I turned on the clock for port E with (SYSCTL_RCGC2_R |= 0x00000010) and it seemed to work after adjusting the necessary pins for the system. Thanks again for the help (any suggestions on tightening up the code?)! Please find below. PS (Is this considered DRM style coding)? for I would like a less complicated way if available (I will check out TivaWare). 

    // ***** 1. Pre-processor Directives Section *****

    #define PE0 (*((volatile unsigned long *)0x40024004))
    #define PE1 (*((volatile unsigned long *)0x40024008))
    #define PE10 (*((volatile unsigned long *)0x40024012))
    #define GPIO_PORTE_DATA_R (*((volatile unsigned long *)0x400243FC))
    #define GPIO_PORTE_DIR_R (*((volatile unsigned long *)0x40024400))
    #define GPIO_PORTE_AFSEL_R (*((volatile unsigned long *)0x40024420))
    #define GPIO_PORTE_DEN_R (*((volatile unsigned long *)0x4002451C))
    #define GPIO_PORTE_AMSEL_R (*((volatile unsigned long *)0x40024528))
    #define GPIO_PORTE_PCTL_R (*((volatile unsigned long *)0x4002452C))
    //#define SYSCTL_RCGC2_R (*((volatile unsigned long *)0x400FE108))
    #define SYSCTL_RCGC2_GPIO_R (*((volatile unsigned long *)0x400FE608)) // port A Clock Gating Control
    #include "TExaS.h"
    #include "tm4c123gh6pm.h"

    void LED_On(void);
    void LED_Off(void);
    void LED_Init(void);
    void EnableInterrupts(void);
    void delay(unsigned long halfsecs);

    int main(void){
    TExaS_Init(SW_PIN_PE0, LED_PIN_PE1, ScopeOn); // activate grader and set system clock to 80 MHz
    EnableInterrupts(); // enable interrupts for the grader
    LED_Init();// initialize PE1 and make it output
    while(1){
    LED_On(); // c) LED signal goes low
    do {
    out = GPIO_PORTA_DATA_R&0x02;
    }while(PE0 == 0x00); // b) wait for switch to be pressed (zero means switch is pressed
    LED_Off();
    delay(1);
    LED_On();
    delay(1);
    if (PE0 == 0x10)
    {LED_On();
    }
    }
    }
    // Subroutine to delay in units of half seconds
    void delay(unsigned long halfsecs){
    unsigned long count;

    while(halfsecs > 0 ) { // repeat while there are still halfsecs to delay
    count = 1600000; // 400000*0.5/0.13 that it takes 0.13 sec to count down to zero (1638400)
    while (count > 0) {
    count--;
    } // This while loop takes approximately 3 cycles
    halfsecs--;
    }
    }

    // Make PE1 high
    void LED_On(void){
    GPIO_PORTE_DATA_R |= 0x02;
    }
    // Make PE1 low
    void LED_Off(void){
    GPIO_PORTE_DATA_R &= ~0x02;
    }
    // Make PE1 an output, enable digital I/O, ensure alt. functions off
    void LED_Init(void){ volatile unsigned long delay;
    SYSCTL_RCGC2_R |= 0x00000010; // 1) activate clock for Port E
    delay = SYSCTL_RCGC2_R; // allow time for clock to start
    //GPIO_PORTE_LOCK_R = 0x4C4F434B; // 2) unlock GPIO Port unlocking is needed only for pins PC3-0, PD7, PF0 // 2) no need to unlock PE0
    GPIO_PORTE_PCTL_R &= ~0x00000F00; // 3) regular GPIO
    GPIO_PORTE_AMSEL_R &= ~0x00; // 4) disable analog function on PE1
    GPIO_PORTE_DIR_R |= ~0x01; // 5) set direction to output
    GPIO_PORTE_AFSEL_R &= ~0x08; // 6) regular port function
    GPIO_PORTE_DEN_R |= 0x03; // 7) enable digital port
    }

  • Hi,

      You wrote in your first post:

    #define SYSCTL_RCGC2_R (*((volatile unsigned long *)0x400FE108))
    //#define SYSCTL_RCGC2_GPIO_R (*((volatile unsigned long *)0x00000001)) // port A Clock Gating Control

    Your SYSCTL_RCGC2_R is mapped to address 0x400FE108 which is correct. You should write a 0x1 to this register to enable the clock to the GPIO PortA. 

     What is the SYSCTL_RCGC2_GPIO_R? You are mapping it to address 0x00000001. This is the second byte of the flash memory. This is incorrect.

  • Hello Charles; This was my initial attempt to be "pin specific" by trying to specify for PortA focusing on Bit 2. I put had that line of comment code there (//#define SYSCTL_RCGC2_GPIO_R (*((volatile unsigned long *)0x00000001)) // port A Clock Gating Control.) to highlight my confusion for the clock on PortA. 

    When initializing the LED (setting PA2 as an output, enable digital I/O, ensure alt. functions off) I was confused about the activation of the clock and was not sure if that was something that needed to be defined in pre-possessor directive and in LED_Init() as SYSCTL_RCGC2_R |= 0x00000001; // 1) activate clock for Port A

    I find the the definition of the ports to be confusing at times and this exercise and communication has helped with clarification (on what is needed and what is not needed).

    #define GPIO_PORTA_DATA_R (*((volatile unsigned long *)0x400043FC))
    #define GPIO_PORTA_DIR_R (*((volatile unsigned long *)0x40004400))
    #define GPIO_PORTA_AFSEL_R (*((volatile unsigned long *)0x40004420))
    #define GPIO_PORTA_DEN_R (*((volatile unsigned long *)0x4000451C))
    #define GPIO_PORTA_AMSEL_R (*((volatile unsigned long *)0x40004528))
    #define GPIO_PORTA_PCTL_R (*((volatile unsigned long *)0x4000452C))
    #define SYSCTL_RCGC2_R (*((volatile unsigned long *)0x400FE108)) 

  • Hi Dustin,

      As I mentioned in the original reply, there will be more learning curve to use the DRM style of coding and the DRM is prone to mistake and this is the reason we provide the TivaWare for efficient software development. I will encourage you to use the TivaWare. Below is a example program that blinks the LED. As you can see it is easy to read and understand. 

    #define RED_LED   GPIO_PIN_1
    #define BLUE_LED  GPIO_PIN_2
    #define GREEN_LED GPIO_PIN_3
    
    
    //*****************************************************************************
    //
    // Main 'C' Language entry point.  Toggle an LED using TivaWare.
    //
    //*****************************************************************************
    int
    main(void)
    {
        //
        // Setup the system clock to run at 50 Mhz from PLL with crystal reference
        //
        SysCtlClockSet(SYSCTL_SYSDIV_4|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|
                        SYSCTL_OSC_MAIN);
    
        //
        // Enable and wait for the port to be ready for access
        //
        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
        while(!SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOF))
        {
        }
        
        //
        // Configure the GPIO port for the LED operation.
        //
        GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, RED_LED|BLUE_LED|GREEN_LED);
    
    
        printf("test\n");
    
        //
        // Loop Forever
        //
        while(1)
        {
            //
            // Turn on the LED
            //
            GPIOPinWrite(GPIO_PORTF_BASE, RED_LED|BLUE_LED|GREEN_LED, RED_LED);
    
            //
            // Delay for a bit
            //
            SysCtlDelay(2000000);
    
            //
            // Turn on the LED
            //
            GPIOPinWrite(GPIO_PORTF_BASE, RED_LED|BLUE_LED|GREEN_LED, BLUE_LED);
    
            //
            // Delay for a bit
            //
            SysCtlDelay(2000000);
        }
    }