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.

SW-TM4C: I tried to create the configuration of the clock circuit

Part Number: SW-TM4C
Other Parts Discussed in Thread: TM4C123GH6PM

I tried creating the source code for the clock code.
Can you move here too?

Sample Code

--------------------------------------------------------------------------------
/*Probably We should use header files below*/
#include <sysctl.h>
#include <rom_map.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>

/*main function*/
int main(void){
/* Configure the PLL */
SysCtlClockFreqSet(SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL, 120000000);
MAP_SysCtlClockFreqSet(SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL, 120000000);

return 0;
}

--------------------------------------------------------------------------------

By the way, the PLL configuration and UART configuration were made with the following code.

What do you think?

Sample Code

--------------------------------------------------------------------------------

/*Probably We should use header files below*/
#include <stdint.h>
#include <stdbool.h>
#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "driverlib/debug.h"
#include "driverlib/gpio.h"
#include "driverlib/interrupt.h"
#include "driverlib/pin_map.h"
#include "driverlib/rom.h"
#include "driverlib/rom_map.h"
#include "driverlib/sysctl.h"
#include "driverlib/uart.h"

/*System clock rate in Hz*/
uint32_t g_ui32SysClock;

/*main function*/
int main(void){
// Setting the PLL
g_ui32SysClock = SysCtlClockFreqSet(SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL, 120000000);

// Enable UART Pin
SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);

// Configure UART
UARTConfigSetExpClk(UART0_BASE, g_ui32SysClock, 115200,(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE));

return 0;
}

--------------------------------------------------------------------------------

  • Hello Kanematu-san,

    SysCtlClockFreqSet(SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL, 120000000);
    MAP_SysCtlClockFreqSet(SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL, 120000000);

    For both of these, you are missing the input for the VCO. To run at 120MHz, you should use SYSCTL_CFG_VCO_240.

    See below:

    MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
                            SYSCTL_OSC_MAIN |
                            SYSCTL_USE_PLL |
                            SYSCTL_CFG_VCO_240), 120000000);

    // Configure UART
    UARTConfigSetExpClk(UART0_BASE, g_ui32SysClock, 115200,(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE));

    The clock configuration is fine here for the UART peripheral.

    Best Regards,

    Ralph Jacobi

  • By the way, regarding the header file, I have not yet found out the meaning of include in the header file in the SW-TM4C file when creating my own SourceCode, so please let me know.

    Example): #include "driverlib/uart.h"
    For example, in the case of the above content, I think it is the recognition of uart.h in driverlib in SW-TM4C.
    That's why I created the sample code, but does that mean that uart.h is not necessary if the header file is placed in the same hierarchy as this code?

    (P.S.)
    I actually tried compiling my code with CCS.

    The project has the following hierarchy, but the following error message was displayed.


    "..\sysctl.h", line 600: error #20: identifier "uint32_t" is undefined
    "..\sysctl.h", line 601: error #20: identifier "bool" is undefined

    What should I do?
    I don't really understand how to deal with errors in the Header file.

  • Hello Kanematu-san,

    You do not need to include these files in your CCS project like you have displayed where you have directly added them. They should be linked by using the TivaWare driverlib library file and just using the #include definition in your .c files.

    Please follow Section 5 of our Getting Started Guide: https://www.ti.com/lit/ug/spmu373a/spmu373a.pdf

    That will walk you through how to properly add driverlib to your project. At that point you can remove the associations for TivaWare library files.

    The only time you need to add files from TivaWare SDK into your project is if there is not a library associated with them. That can be the case with utils like uartstdio. Section 3.1 of the same Getting Started Guide has details on how to do that.

    Best Regards,

    Ralph Jacobi

  • Hi, thanks for your reply.

    So you're saying that different types of header files don't have to be in the same directory?
    If you want to know more, you should look at chapters 3 and 5 of the material you provided!

    By the way, how should I deal with the following questions I asked?

    "..\sysctl.h", line 600: error #20: identifier "uint32_t" is undefined
    "..\sysctl.h", line 601: error #20: identifier "bool" is undefined

    What should I do?
    I don't really understand how to deal with errors in the Header file.

  • The errors occur because you have incorrectly added the files to your project. Remove them and follow the guidance of the Getting Started Guide.

  • Thank you for teaching.

    I got it. I'll take a quick look at the materials.
    Does that mean that it is also written in chapters 3 and 5?

    (P.S.)

    I followed the steps in Chapter 3.

    However, when building, I got the following error:
    Why did this occur?
    teach me please.

    "C:/ti/ccs1220/ccs/tools/compiler/ti-cgt-arm_20.2.7.LTS/bin/armcl" -mv7M4 --code_state=16 --float_support=FPv4SPD16 -me -O2 --define=ccs="ccs" --define=PART_TM4C123GH6PM --define=TARGET_IS_TM4C123_RB1 -g --gcc --diag_warning=225 --diag_wrap=off --display_error_number --gen_func_subsections=on --abi=eabi --ual -z -m"project0_ccs.map" --heap_size=0 --stack_size=256 -i"C:/ti/ccs1220/ccs/tools/compiler/ti-cgt-arm_20.2.7.LTS/lib" -i"C:/ti/ccs1220/ccs/tools/compiler/ti-cgt-arm_20.2.7.LTS/include" --reread_libs --diag_wrap=off --display_error_number --warn_sections --xml_link_info="Single_Ended_linkInfo.xml" --rom_model -o "Single_Ended.out" "./project0.obj" "./startup_ccs.obj" "./tm4c123gh6pm_startup_ccs.obj" "./uartstdio.obj" "../project0_ccs.cmd" -l"C:/ti/TivaWare_C_Series-2.2.0.295/driverlib/ccs/Debug/driverlib.lib" -l"C:/ti/TivaWare_C_Series-2.2.0.295/usblib/ccs/Debug/usblib.lib" -llibc.a
    <Linking>
    error #10056: symbol "ResetISR" redefined: first defined in "./startup_ccs.obj"; redefined in "./tm4c123gh6pm_startup_ccs.obj"
    error #10056: symbol "g_pfnVectors" redefined: first defined in "./startup_ccs.obj"; redefined in "./tm4c123gh6pm_startup_ccs.obj"
    error #10010: errors encountered during linking; "Single_Ended.out" not built

    >> Compilation failure
    makefile:140: recipe for target 'Single_Ended.out' failed
    gmake[1]: *** [Single_Ended.out] Error 1
    makefile:136: recipe for target 'all' failed
    gmake: *** [all] Error 2

    **** Build Finished ****

  • Hello Kanematu-san,

    It sounds like you may have multiple startup files in your project. I can't determine more than that, but it's not a driverlib related issue or anything to do with the material covered in Sections 3 or 5.

    You may want to start from a fresh project and follow those sections instead of trying to salvage an existing project with build errors - without CCS expertise it's a pain to solve build errors and will be quicker to re-start from scratch and then re-add your project-specific files once you have the libraries configured properly.

    Best Regards,

    Ralph Jacobi