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.

AHB gpio are not working in tm4c129encpdt

Other Parts Discussed in Thread: TM4C129ENCPDT, TM4C123GH6PM

Hi all,

    I am using tm4c129encpdt controller: -> crystal used 16Mhz

 my gpio configuration is as bellow:

case A)

SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
SysCtlGPIOAHBEnable(SYSCTL_PERIPH_GPIOD); GPIOPinTypeGPIOOutput(GPIO_PORTD_AHB_BASE, GPIO_PIN_0);

while(1)
{

  HWREG(GPIO_PORTD_AHB_BASE + GPIO_O_DATA + (GPIO_PIN_0 << 2)) = GPIO_PIN_0;                       

         HWREG(GPIO_PORTD_AHB_BASE + GPIO_O_DATA + (GPIO_PIN_0 << 2)) = 0;  

}

case B)

SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
GPIOPinTypeGPIOOutput(GPIO_PORTD_BASE, GPIO_PIN_0);

while(1)
{

  HWREG(GPIO_PORTD_BASE + GPIO_O_DATA + (GPIO_PIN_0 << 2)) = GPIO_PIN_0;                       

         HWREG(GPIO_PORTD_BASE + GPIO_O_DATA + (GPIO_PIN_0 << 2)) = 0;  

}

In case A and B i  am getting the same frequency as 3.54MHz i have observed it on DSO(digital storage osc) . Why AHB bus is not working. Is there any mistake in pin configuration?

  • Is it not likely that the DRM code presented fails to fully/properly initialize the AHB bus?

    Many find the use of DRM (after) they've teased success (via the far quicker, easier, better illustrated API) a more successful path.   Usually you must "break the hold" of the standard bus prior to enabling the AHB bus.

  • Hello Sagar,

    As cb1 has noted, it is hard to follow and debug code written in DRMs (Direct Register access Memory). I would suggest using TivaWare APIs instead.

    TIP#2 in this forum sticky explains the reasons as to why using DRMs is not a good idea.

    Thanks,

    Sai

  • Might it (instead) prove more productive for the forum to (embrace) KISS - not shun it?

    I would bet that, "Not too many" will click upon that "tip #2" and then those long sentences - not being, "Compact, Easy, and Memorable" - are (surely) quickly forgotten.

    KISS proves hard to forget - is compact & simple - and does NOT have to be viewed w/"negative connotation."   (i.e. KISS = Keep It Simple, Students)

    May I note that you/I agree in "resisting complexity" - yet (any) replacement for the (long) tried/true KISS - adds (such) complexity!

  • Anyone has example of AHB gpio please shaire?
  • I am use like this for accessing GPIO's for TM4c123gh6pm controller. if its's suitable for u, you can use this


    #include <stdbool.h>
    #include <stdint.h>
    #include "inc/tm4c123gh6pm.h"

    #include "inc/hw_memmap.h"
    #include "driverlib/gpio.h"
    #include "driverlib/interrupt.h"
    #include "driverlib/pin_map.h"
    #include "driverlib/sysctl.h"
    #include "driverlib/timer.h"
    #include "driverlib/uart.h"
    #include "utils/uartstdio.h"


    volatile uint32_t g_ui32Counter = 0;
    volatile unsigned long delay;
    unsigned long test_time1, test_time;

    void Timer0BIntHandler(void);

    #define LEDS (*((volatile unsigned long *)0x4002503C))//0x4000703C)) 0x400253FC

    //*****************************************************************************
    //
    // Configure Timer0B as a 16-bit periodic counter with an interrupt every 1ms.
    //
    //*****************************************************************************
    int main(void)
    {
    SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);

    test_time1 = 0;

    SYSCTL_RCGC2_R |= SYSCTL_RCGC2_GPIOF; // activate port F
    delay = SYSCTL_RCGC2_R; // allow time for clock to stabilize
    GPIO_PORTF_DIR_R |= 0x0F; // make PD3-0 out
    GPIO_PORTF_AFSEL_R &= ~0x0F; // regular port function
    GPIO_PORTF_DEN_R |= 0x0F; // enable digital I/O on PD3-0

    while(1)
    {
    // If the interrupt count changed, print the new value

    if(++ test_time > 3000000)
    test_time1++;

    if(test_time1 == 1)
    LEDS = 10; // 1010, LED is 0101
    else if(test_time1 == 2)
    LEDS = 9; // 1001, LED is 0110
    else if(test_time1 == 3)
    LEDS = 5; // 0101, LED is 1010
    else if(test_time1 == 4)
    {
    LEDS = 6; // 0110, LED is 1001
    test_time1 = 0;
    }
    }
    }
  • Would not your code be (even) more suitable for general forum use "if" comments matched the code?

    Yuva raj said:

    GPIO_PORTF_DIR_R |= 0x0F; // make PD3-0 out
    GPIO_PORTF_AFSEL_R &= ~0x0F; // regular port function
    GPIO_PORTF_DEN_R |= 0x0F; // enable digital I/O on PD3-0

    Poster specifically asked about "AHB" bus - which is not well noted w/in your response...