+ Post New Thread
Results 1 to 5 of 5
  1. #1
    Advanced Member level 2
    Points: 2,573, Level: 11
    baileychic's Avatar
    Join Date
    Aug 2017
    Posts
    501
    Helped
    46 / 46
    Points
    2,573
    Level
    11

    TM4C123G code problem

    I am using TI Tiva launchpad and my Blinky code is not working.

    This is th elaunchpad I am using.

    https://www.anandtronics.com/EK-TM4C...chpad-eval-kit

    Oscillator and other project settings are fine because I copied them from mikroe MINI-M4-Tiva example Blink project.

    https://www.mikroe.com/mini-tiva

    I also tried to blink the onboard RGB Leds but none of the Leds light up. If I flash some other example projects written in Keil, they work and so the hardware setup is fine.

    What is the issue?

    Find my mikroC PRO ARM project attached.

    Here is my mikroC PRO ARM code.

    Code:
    void main() {
        GPIO_Digital_Output(&GPIO_PORTE_DATA, _GPIO_PINMASK_ALL);
        GPIO_PORTE_DATA = 0;
        
        while (1) {
            GPIO_PORTE_DATA = ~GPIO_PORTE_DATA;           // Toggle LEDs
            Delay_ms(500);                                // 500ms pause
        }
    }

    •   AltAdvertisment

        
       

  2. #2
    Advanced Member level 3
    Points: 6,894, Level: 19
    Achievements:
    7 years registered

    Join Date
    Jul 2010
    Location
    Sweden
    Posts
    898
    Helped
    357 / 357
    Points
    6,894
    Level
    19

    Re: TM4C123G code problem

    Enable port E before doing anything else.

    Maybe like this (not sure about the argument):
    Code:
    GPIO_Clk_Enable(&GPIO_PORTE_DATA);



    •   AltAdvertisment

        
       

  3. #3
    Advanced Member level 2
    Points: 2,573, Level: 11
    baileychic's Avatar
    Join Date
    Aug 2017
    Posts
    501
    Helped
    46 / 46
    Points
    2,573
    Level
    11

    Re: TM4C123G code problem

    Okay, thanks. I tried that. It still doesn't work.

    The hardware setup is okay because it works with sample code for Keil.

    Here is my latest code. The oscillator settings remain as previous (Internal Oscillator with PLL) 80 MHz.

    I made this latest code looking at the help file of mikroC PRO ARM.

    Code C - [expand]
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    
    /*
     * Project name:
         Led_Blinking (The simplest simple example)
     * Test configuration:
         MCU:             TM4C123GH6PM
                          [url]http://www.ti.com/lit/ds/symlink/tm4c123gh6pm.pdf[/url]
         Oscillator:      IOSC-PLL, 80.000MHz
         SW:              mikroC PRO for ARM
                          [url]http://www.mikroe.com/mikroc/arm/[/url]
     */
     
    void main() {
        GPIO_Config(&GPIO_PORTB, _GPIO_PINMASK_0 |
                                 _GPIO_PINMASK_1 |
                                 _GPIO_PINMASK_2 |
                                 _GPIO_PINMASK_3, 
                                 _GPIO_DIR_INPUT, 
                                 _GPIO_CFG_DIGITAL_ENABLE,
                                 _GPIO_PINCODE_NONE);
        GPIO_Digital_Input(&GPIO_PORTB, 
                                        _GPIO_PINMASK_0 | 
                                        _GPIO_PINMASK_1 | 
                                        _GPIO_PINMASK_2 | 
                                        _GPIO_PINMASK_3
                                        );
     
        GPIO_PORTB_DATA = 0;
     
        GPIO_Config(&GPIO_PORTE, _GPIO_PINMASK_0 |
                                 _GPIO_PINMASK_1 |
                                 _GPIO_PINMASK_2 |
                                 _GPIO_PINMASK_3,
                                 _GPIO_DIR_OUTPUT,
                                 _GPIO_CFG_DIGITAL_ENABLE |
                                 _GPIO_CFG_DRIVE_8mA,
                                 _GPIO_PINCODE_NONE);
        GPIO_Digital_Output(&GPIO_PORTE_DATA, _GPIO_PINMASK_0 |
                                              _GPIO_PINMASK_1 |
                                              _GPIO_PINMASK_2 |
                                              _GPIO_PINMASK_3
                                              );
        GPIO_Clk_Enable(&GPIO_PORTE);
                                              
        GPIO_PORTE_DATA = 0;
        
        while (1) {
            GPIO_PORTE_DATA = ~GPIO_PORTE_DATA;           // Toggle LEDs
            Delay_ms(500);                                // 500ms pause
        }
    }

    - - - Updated - - -

    I forgot to mention that with the latest post (post #3) I am trying to blink 4x LEDs connected to lower 4 bits of PORTE that is PE0,1,2,3. I also have 4x tact switches wired to PB0,1,2,3.



    •   AltAdvertisment

        
       

  4. #4
    Advanced Member level 2
    Points: 2,573, Level: 11
    baileychic's Avatar
    Join Date
    Aug 2017
    Posts
    501
    Helped
    46 / 46
    Points
    2,573
    Level
    11

    Re: TM4C123G code problem

    Did the required changes but still not working on the launchpad.

    Changes: Moved the GPIO_Clk_Enable() calls to beginning but still not result on hardware.

    I am using "LM Flash Ultility" to download the .hex file to the launchpad.

    Code C - [expand]
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    
    /*
     * Project name:
         Led_Blinking (The simplest simple example)
     * Test configuration:
         MCU:             TM4C123GH6PM
                          [url]http://www.ti.com/lit/ds/symlink/tm4c123gh6pm.pdf[/url]
         Oscillator:      IOSC-PLL, 80.000MHz
         SW:              mikroC PRO for ARM
                          [url]http://www.mikroe.com/mikroc/arm/[/url]
     */
     
    void main() {
        GPIO_Clk_Enable(&GPIO_PORTB);
        GPIO_Config(&GPIO_PORTB, _GPIO_PINMASK_0 |
                                 _GPIO_PINMASK_1 |
                                 _GPIO_PINMASK_2 |
                                 _GPIO_PINMASK_3,
                                 _GPIO_DIR_INPUT,
                                 _GPIO_CFG_DIGITAL_ENABLE,
                                 _GPIO_PINCODE_NONE);
        GPIO_Digital_Input(&GPIO_PORTB,
                                        _GPIO_PINMASK_0 |
                                        _GPIO_PINMASK_1 |
                                        _GPIO_PINMASK_2 |
                                        _GPIO_PINMASK_3
                                        );
     
        GPIO_PORTB_DATA = 0;
        
        GPIO_Clk_Enable(&GPIO_PORTE);
        GPIO_Config(&GPIO_PORTE, _GPIO_PINMASK_0 |
                                 _GPIO_PINMASK_1 |
                                 _GPIO_PINMASK_2 |
                                 _GPIO_PINMASK_3,
                                 _GPIO_DIR_OUTPUT,
                                 _GPIO_CFG_DIGITAL_ENABLE |
                                 _GPIO_CFG_DRIVE_8mA,
                                 _GPIO_PINCODE_NONE);
        GPIO_Digital_Output(&GPIO_PORTE_DATA, _GPIO_PINMASK_0 |
                                              _GPIO_PINMASK_1 |
                                              _GPIO_PINMASK_2 |
                                              _GPIO_PINMASK_3
                                              );
                                              
        GPIO_PORTE_DATA = 0;
       
        while (1) {
            
            GPIO_PORTE_DATA = ~GPIO_PORTE_DATA;                
        }
    }
    Last edited by baileychic; 19th April 2019 at 19:21.



  5. #5
    Advanced Member level 5
    Points: 9,012, Level: 22
    Achievements:
    7 years registered
    Easyrider83's Avatar
    Join Date
    Oct 2011
    Location
    Tallinn, Estonia
    Posts
    1,588
    Helped
    362 / 362
    Points
    9,012
    Level
    22
    Love me or hate me. All infractions will be ignored.


    1 members found this post helpful.

--[[ ]]--