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.

CCS/EK-TM4C1294XL: EK-TM4C1294XL

Part Number: EK-TM4C1294XL
Other Parts Discussed in Thread: TM4C1294NCPDT,

Tool/software: Code Composer Studio

HELLO this is my code to turn on led using switch it has some errors n still dono if it works after that or not please help me out

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include<hw_gpio.h>

#include <TM4C1294NCPDT.h>
#include <Mydefines.h>
void Delay(int s); // Software Delay Function
void Setup_GPIO(void);

int main(void)
{
unsigned long sw1;
void PORTN_INIT();
void PORTJ_INIT();
while(1)
{
GPIO_PORTN_DATA_R &=~0X02;
do{
sw1=GPIO_PORTJ_AHB_DATA_R & 0X02;
}while(sw1);
do{
GPIO_PORTN_DATA_R^=0X02;
Delay(1);
sw1=GPIO_PORTJ_AHB_DATA_R & 0X02;
}while(!sw1);

}
}
//initialize PORTJ and PORTN (pj1=input, pn1= output)
void PORTJ_Int(void);
void PORTN_Int(void);
{
volatile unsigned long delay;
SYSCTL_RCGCGPIO_R= SYSCTL_RCGCGPIO_R12|SYSCTL_RCGCGPIO_R8;
//delay=SYSCTL_RCGCGPIO_R12|SYSCTL_RCGCGPIO_R8;
GPIO_PORTJ_LOCK_R |=Ox4C4F434B;
GPIO_PORTJ_CR_R |=0x01;
GPIO_PORTJ_AMSEL_R &=~(0x01);
GPIO_PORTN_AMSEL_R &=0x00;
GPIO_PORTJ_PCTL_R &=0x00000000;
GPIO_PORTN_PCTL_R &=0x00000000;
GPIO_PORTJ_AHB_DIR_R &=~0x02;
GPIO_PORTN_DIR_R |= 0x02;
GPIO_PORTJ_AHB_PUR_R |= 0x01;
GPIO_PORTJ_AHB_DEN_R |=0x01;
GPIO_PORTN_DEN_R |=0X01;
}
void Delay(int s)
{
volatile int i, j;
for(i=0;i<s;i++)
for(j=0;j<3180;j++)
{}
}

AND THIS IS THE ERROR


**** Build of configuration Debug for project switch ****

"C:\\ti\\ccsv8\\utils\\bin\\gmake" -k -j 4 all -O

Building file: "../main.c"
Invoking: ARM Compiler
"C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.3.LTS/bin/armcl" -mv7M4 --code_state=16 --float_support=FPv4SPD16 -me --include_path="C:/ti/switch" --include_path="C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.3.LTS/include" --define=ccs="ccs" --define=PART_TM4C1294NCPDT -g --gcc --diag_warning=225 --diag_wrap=off --display_error_number --abi=eabi --preproc_with_compile --preproc_dependency="main.d_raw" "../main.c"

>> Compilation failure
subdir_rules.mk:9: recipe for target 'main.obj' failed
"../main.c", line 34: error #171: expected a declaration
1 error detected in the compilation of "../main.c".
gmake: *** [main.obj] Error 1
gmake: Target 'all' not remade because of errors.

**** Build Finished ****

  • #include <stdio.h>
    #include <stdlib.h>
    #include <stdint.h>
    #include <stdbool.h>
    #include<hw_gpio.h>

    #include <TM4C1294NCPDT.h>
    #include <Mydefines.h>
    void Delay(int s); // Software Delay Function
    void Setup_GPIO(void);

    int main(void)
    {
    unsigned long sw1;
    void PORTN_INIT();
    void PORTJ_INIT();
    while(1)
    {
    GPIO_PORTN_DATA_R &=~0X02;
    do{
    sw1=GPIO_PORTJ_AHB_DATA_R & 0X02;
    }while(sw1);
    do{
    GPIO_PORTN_DATA_R^=0X02;
    Delay(1);
    sw1=GPIO_PORTJ_AHB_DATA_R & 0X02;
    }while(!sw1);

    }
    }
    //initialize PORTJ and PORTN (pj1=input, pn1= output)
    void PORTJ_AHB_Int(void)
    void PORTN_Int (void)
    {
    volatile unsigned long delay;
    SYSCTL_RCGCGPIO_R= SYSCTL_RCGCGPIO_R12|SYSCTL_RCGCGPIO_R8;
    delay=SYSCTL_RCGCGPIO_R12|SYSCTL_RCGCGPIO_R8;
    //GPIO_PORTJ_AHB_LOCK_R |=Ox4C4F434B;
    GPIO_PORTJ_AHB_CR_R |=0x01;
    GPIO_PORTJ_AHB_AMSEL_R &=~(0x01);
    GPIO_PORTN_AMSEL_R &=0x00;
    GPIO_PORTJ_AHB_PCTL_R &=0x00000000;
    GPIO_PORTN_PCTL_R &=0x00000000;
    GPIO_PORTJ_AHB_DIR_R &=~0x02;
    GPIO_PORTN_DIR_R |= 0x02;
    GPIO_PORTJ_AHB_PUR_R |= 0x01;
    GPIO_PORTJ_AHB_DEN_R |=0x01;
    GPIO_PORTN_DEN_R |=0X01;

    }
    void Delay(int s)
    {
    volatile int i, j;
    for(i=0;i<s;i++)
    for(j=0;j<3180;j++)
    {}
    }


    changed somethings now got different error



    **** Build of configuration Debug for project switch ****

    "C:\\ti\\ccsv8\\utils\\bin\\gmake" -k -j 4 all -O

    Building file: "../main.c"
    Invoking: ARM Compiler
    "C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.3.LTS/bin/armcl" -mv7M4 --code_state=16 --float_support=FPv4SPD16 -me --include_path="C:/ti/switch" --include_path="C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.3.LTS/include" --define=ccs="ccs" --define=PART_TM4C1294NCPDT -g --gcc --diag_warning=225 --diag_wrap=off --display_error_number --abi=eabi --preproc_with_compile --preproc_dependency="main.d_raw" "../main.c"

    >> Compilation failure
    subdir_rules.mk:9: recipe for target 'main.obj' failed
    "../main.c", line 33: error #131: expected a "{"
    1 error detected in the compilation of "../main.c".
    gmake: *** [main.obj] Error 1
    gmake: Target 'all' not remade because of errors.

    **** Build Finished ****
  • #include <stdio.h>
    #include <stdlib.h>
    #include <stdint.h>
    #include <stdbool.h>
    #include<hw_gpio.h>

    #include <TM4C1294NCPDT.h>
    #include <Mydefines.h>

    void Delay(int s); // Software Delay Function
    void Setup_GPIO(void);

    int main(void)
    {
    unsigned long sw1;
    void PORTN_INIT();
    void PORTJ_INIT();
    while(1)
    {
    GPIO_PORTN_DATA_R &=~0X02;
    do{
    sw1=GPIO_PORTJ_AHB_DATA_R & 0X02;
    }while(sw1);
    do{
    GPIO_PORTN_DATA_R^=0X02;
    Delay(1);
    sw1=GPIO_PORTJ_AHB_DATA_R & 0X02;
    }while(!sw1);

    }
    }
    //initialize PORTJ and PORTN (pj1=input, pn1= output)
    void PORTJ_AHB_Int(void)
    //void PORTN_Int (void)
    {
    volatile unsigned long delay;
    SYSCTL_RCGCGPIO_R= SYSCTL_RCGCGPIO_R12|SYSCTL_RCGCGPIO_R8;
    delay=SYSCTL_RCGCGPIO_R12|SYSCTL_RCGCGPIO_R8;
    GPIO_PORTJ_AHB_LOCK_R |=0x4C4F434B;
    GPIO_PORTJ_AHB_CR_R |=0x01;
    GPIO_PORTJ_AHB_AMSEL_R &=~(0x01);
    GPIO_PORTN_AMSEL_R &=0x00;
    GPIO_PORTJ_AHB_PCTL_R &=0x00000000;
    GPIO_PORTN_PCTL_R &=0x00000000;
    GPIO_PORTJ_AHB_DIR_R &=~0x02;
    GPIO_PORTN_DIR_R |= 0x02;
    GPIO_PORTJ_AHB_PUR_R |= 0x01;
    GPIO_PORTJ_AHB_DEN_R |=0x01;
    GPIO_PORTN_DEN_R |=0X01;

    }
    void Delay(int s)
    {
    volatile int i, j;
    for(i=0;i<s;i++)
    for(j=0;j<3180;j++)
    {}
    }


    this has no errors bt still no response led is nt blinking please help me out asap
  • Hello Chethan,

    We have already informed you that you must use TivaWare to get support on these forums: e2e.ti.com/.../2702537
  • yes sir i know bt i need a code atleast in tivaware

    best regards,

    chethan
  • Hello Chethan,

    In CCS go to the Project menu and select the 'Import CCS Projects...' option. Then browse on your PC to your TivaWare installation and find the following folder path: [Install Path]\TivaWare_C_Series-2.1.4.178\examples\boards\ek-tm4c1294xl\blinky

    Select the blinky example project folder and then click Finish.

    This will load the blinky example for flashing an LED on the EK-TM4C1294XL LaunchPad which you can compile and download to your LaunchPad as well as review the code to learn how it works.
  • Hello Ralph Jacobi,

    I Got the blinky project in both the way

    Now i'm looking for code to turn on and off led using switch , didn't find any example so thought of asking help from you.


    Best Regards,

    Chethan
  • Hello Chethan,

    If you got Blinky working, then you should try and add the switch functionality on with TivaWare API's. Then we can help you.

    To see a fairly simple example project where a switch was used in TivaWare, you can check out the Watchdog example.
  • HELLO Ralph Jacobi,

    I hve tried using tivaware there is something wrong help me out
    This is my code

    #include <stdint.h>
    #include <stdbool.h>
    #include "hw_ints.h"
    #include "hw_memmap.h"
    #include "hw_types.h"
    #include <gpio.h>
    #include <buttons.h>
    #include <sysctl.h>

    #define USER_LED1 GPIO_PIN_0
    #define USER_LED2 GPIO_PIN_1
    #define USR_sw1 GPIO_PIN_0
    #define USR_sw2 GPIO_PIN_1

    // error routine

    #ifdef DEBUG
    void
    __error__(char *pcFilename, uint32_t ui32Line)
    {
    }
    #endif

    // ..................
    int main(void)
    {
    uint32_t ui32SysClock;
    //
    // Run from the PLL at 120 MHz.
    //
    ui32SysClock = SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
    SYSCTL_OSC_MAIN |
    SYSCTL_USE_PLL |
    SYSCTL_CFG_VCO_480), 120000000);


    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPION);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOJ);
    while(!SysCtlPeripheralReady(SYSCTL_PERIPH_GPION))
    while(!SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOJ))
    {
    }
    ButtonsInit();


    GPIOPinTypeGPIOOutput(GPIO_PORTN_BASE, (USER_LED1|USER_LED2));
    GPIOPinTypeGPIOOutput(GPIO_PORTJ_BASE, (USR_sw1|USR_sw2));


    while(1)
    {
    uint8_t ui8Buttons = ButtonsPoll(0, 0);

    if(ui8Buttons & USR_sw1);
    {
    GPIOPinWrite(GPIO_PORTN_BASE,(USER_LED1|USER_LED2),USER_LED1);
    }
    if
    (ui8Buttons & USR_sw2);
    {
    GPIOPinWrite(GPIO_PORTN_BASE,(USER_LED1|USER_LED2),USER_LED2);

    }

    }
    }

    THIS IS THE ERROR



    **** Build of configuration Debug for project sw ****

    "C:\\ti\\ccsv8\\utils\\bin\\gmake" -k -j 4 all -O

    Building file: "../main.c"
    Invoking: ARM Compiler
    "C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.3.LTS/bin/armcl" -mv7M4 --code_state=16 --float_support=FPv4SPD16 -me --include_path="C:/ti/sw" --include_path="C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.3.LTS/include" --define=ccs="ccs" --define=PART_TM4C1294NCPDT -g --gcc --diag_warning=225 --diag_wrap=off --display_error_number --abi=eabi --preproc_with_compile --preproc_dependency="main.d_raw" "../main.c"
    "../main.c", line 27: warning #552-D: variable "ui32SysClock" was set but never used
    Finished building: "../main.c"

    Building target: "sw.out"
    Invoking: ARM Linker
    "C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.3.LTS/bin/armcl" -mv7M4 --code_state=16 --float_support=FPv4SPD16 -me --define=ccs="ccs" --define=PART_TM4C1294NCPDT -g --gcc --diag_warning=225 --diag_wrap=off --display_error_number --abi=eabi -z -m"sw.map" --heap_size=0 --stack_size=512 -i"C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.3.LTS/lib" -i"C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.3.LTS/include" --reread_libs --diag_wrap=off --display_error_number --warn_sections --xml_link_info="sw_linkInfo.xml" --rom_model -o "sw.out" "./main.obj" "./tm4c1294ncpdt_startup_ccs.obj" "../tm4c1294ncpdt.cmd" -llibc.a
    <Linking>

    undefined first referenced
    symbol in file
    --------- ----------------
    ButtonsInit ./main.obj
    ButtonsPoll ./main.obj
    GPIOPinTypeGPIOOutput ./main.obj
    GPIOPinWrite ./main.obj
    SysCtlClockFreqSet ./main.obj
    SysCtlPeripheralEnable ./main.obj
    SysCtlPeripheralReady ./main.obj

    error #10234-D: unresolved symbols remain
    error #10010: errors encountered during linking; "sw.out" not built

    >> Compilation failure
    makefile:142: recipe for target 'sw.out' failed
    gmake[1]: *** [sw.out] Error 1
    makefile:138: recipe for target 'all' failed
    gmake: *** [all] Error 2

    **** Build Finished ****
  • Hello Chethan,

    Your includes are not being pathed correctly. Once TivaWare is linked right, you still need to direct CCS to go through the TivaWare folders to find certain files.

    For example from the blinky.c project, you can see these includes for TivaWare specifically:

    #include "inc/hw_memmap.h"
    #include "inc/hw_ints.h"
    #include "driverlib/debug.h"
    #include "driverlib/gpio.h"
    #include "driverlib/interrupt.h"
    #include "driverlib/sysctl.h"
    #include "driverlib/timer.h"

    You need the driverlib/ and inc/ folders as part of your #include based on where each file is located.

  • Hello
    Thank you for tht can u please go throught the code once or run tht code once so tht there are no errors or it needs some other changes
  • Please reply soon
  • Hello Chethan,

    What other errors are you running into?
  • Its nt working on board so
  • Hello Chethan,

    Is it compiling fine, or are you having compilation errors still?

    Have you tried using breakpoints to see if your code enters the correct conditional statements when buttons are pressed?
  • hello after invluding also still same errors this is my code

    #include <stdint.h>
    #include <stdbool.h>
    #include "hw_ints.h"
    #include "hw_memmap.h"
    #include "hw_types.h"
    #include <driverlib/gpio.h>
    #include <buttons.h>
    #include <driverlib/sysctl.h>
    #include <rom.h>

    #define USER_LED1 GPIO_PIN_0
    #define USER_LED2 GPIO_PIN_1
    #define USR_sw1 GPIO_PIN_0
    #define USR_sw2 GPIO_PIN_1

    // error routine

    #ifdef DEBUG
    void
    __error__(char *pcFilename, uint32_t ui32Line)
    {
    }
    #endif

    // ..................
    int main(void)
    {
    uint32_t ui32SysClock;
    //
    // Run from the PLL at 120 MHz.
    //
    ui32SysClock = SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
    SYSCTL_OSC_MAIN |
    SYSCTL_USE_PLL |
    SYSCTL_CFG_VCO_480), 120000000);


    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPION);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOJ);
    while(!SysCtlPeripheralReady(SYSCTL_PERIPH_GPION))
    while(!SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOJ))
    {
    }
    ButtonsInit();


    GPIOPinTypeGPIOOutput(GPIO_PORTN_BASE, (USER_LED1|USER_LED2));
    GPIOPinTypeGPIOOutput(GPIO_PORTJ_BASE, (USR_sw1|USR_sw2));

    while(1)
    {
    uint8_t ui8Buttons = ButtonsPoll(0, 0);

    if(ui8Buttons & USR_sw1);
    {
    GPIOPinWrite(GPIO_PORTN_BASE,(USER_LED1|USER_LED2),USER_LED1);
    }
    if
    (ui8Buttons & USR_sw2);
    {
    GPIOPinWrite(GPIO_PORTN_BASE,(USER_LED1|USER_LED2),USER_LED2);

    }

    }
    }

    THIS IS THE ERROR


    **** Build of configuration Debug for project sw3 ****

    "C:\\ti\\ccsv8\\utils\\bin\\gmake" -k -j 4 all -O

    Building target: "sw3.out"
    Invoking: ARM Linker
    "C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.3.LTS/bin/armcl" -mv7M4 --code_state=16 --float_support=FPv4SPD16 -me --define=ccs="ccs" --define=PART_TM4C1294NCPDT -g --gcc --diag_warning=225 --diag_wrap=off --display_error_number --abi=eabi -z -m"sw3.map" --heap_size=0 --stack_size=512 -i"C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.3.LTS/lib" -i"C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.3.LTS/include" --reread_libs --diag_wrap=off --display_error_number --warn_sections --xml_link_info="sw3_linkInfo.xml" --rom_model -o "sw3.out" "./main.obj" "./tm4c1294ncpdt_startup_ccs.obj" "../tm4c1294ncpdt.cmd" -llibc.a -l"C:/ti/TivaWare_C_Series-2.1.4.178/driverlib/ccs/Debug/driverlib.lib"
    <Linking>

    undefined first referenced
    symbol in file
    --------- ----------------
    ButtonsInit ./main.obj
    ButtonsPoll ./main.obj

    error #10234-D: unresolved symbols remain
    error #10010: errors encountered during linking; "sw3.out" not built

    >> Compilation failure
    makefile:143: recipe for target 'sw3.out' failed
    gmake[1]: *** [sw3.out] Error 1
    makefile:139: recipe for target 'all' failed
    gmake: *** [all] Error 2

    **** Build Finished ****

  • And now this error the problem is in the "header" file only


    **** Build of configuration Debug for project sw3 ****

    "C:\\ti\\ccsv8\\utils\\bin\\gmake" -k -j 4 all -O

    Building file: "../main.c"
    Invoking: ARM Compiler
    "C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.3.LTS/bin/armcl" -mv7M4 --code_state=16 --float_support=FPv4SPD16 -me --include_path="C:/ti/sw3" --include_path="C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.3.LTS/TivaWare_C_Series-2.1.4.178" --include_path="C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.3.LTS/include" --include_path="C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.3.LTS/include" --define=ccs="ccs" --define=PART_TM4C1294NCPDT -g --gcc --diag_warning=225 --diag_wrap=off --display_error_number --abi=eabi --preproc_with_compile --preproc_dependency="main.d_raw" "../main.c"

    >> Compilation failure
    subdir_rules.mk:9: recipe for target 'main.obj' failed
    "C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.3.LTS/include/buttons.h", line 27: fatal error #1965: cannot open source file "inc/hw_types.h"
    1 catastrophic error detected in the compilation of "../main.c".
    Compilation terminated.
    gmake: *** [main.obj] Error 1
    gmake: Target 'all' not remade because of errors.

    **** Build Finished ****