Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

TM4C123G code problem

Status
Not open for further replies.

baileychic

Advanced Member level 3
Joined
Aug 2, 2017
Messages
728
Helped
56
Reputation
112
Reaction score
57
Trophy points
28
Activity points
7,033
I am using TI Tiva launchpad and my Blinky code is not working.

This is th elaunchpad I am using.

**broken link removed**

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

Attachments

  • Led Blinking.rar
    207.5 KB · Views: 64

Enable port E before doing anything else.

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

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]https://www.ti.com/lit/ds/symlink/tm4c123gh6pm.pdf[/url]
     Oscillator:      IOSC-PLL, 80.000MHz
     SW:              mikroC PRO for ARM
                      [url]https://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.
 

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]https://www.ti.com/lit/ds/symlink/tm4c123gh6pm.pdf[/url]
     Oscillator:      IOSC-PLL, 80.000MHz
     SW:              mikroC PRO for ARM
                      [url]https://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:

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top