Part Number: TM4C123GH6PM
Tool/software: Code Composer Studio
I'm currently using the Launchpad Tiva C Series TM4C123G Evaluation Kit. I'm trying to connect a NC-SR04 Ultrasonic device. I have found some code on the Line and I'm getting linking errors I have Cleaned up some other errors that were in the program If anyone can help that would be great. see Program below..
It looks like when the functions are not being linked I'm using Version: 7.4.0.00015 of ccs I have removed the all functions from the program to see if it would and it will compile with out them..
Program:
#include <stdint.h>
#include <stdbool.h>
#include "stdlib.h"
#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "inc/hw_timer.h"
#include "inc/hw_uart.h"
#include "inc/hw_gpio.h"
#include "inc/hw_pwm.h"
#include "inc/hw_types.h"
#include "driverlib/pin_map.h"
#include "driverlib/timer.h"
#include "driverlib/gpio.h"
#include "driverlib/interrupt.h"
#include "driverlib/rom.h"
#include "driverlib/rom_map.h"
#include "driverlib/sysctl.h"
#include "driverlib/uart.h"
#include "driverlib/udma.h"
#include "driverlib/pwm.h"
#include "driverlib/ssi.h"
#include "driverlib/systick.h"
//#include "EK_TM4C123GXL.h"
#include "utils/uartstdio.h"
#include <string.h>
//*****************************************************************************
//
// The error routine that is called if the driver library encounters an error.
//
//*****************************************************************************
#ifdef DEBUG
void
__error__(char *pcFilename, uint32_t ui32Line)
{
}
#endif
void inputInt(void);
void Captureinit(void);
void InitConsole(void);
//This is to avoid doing the math everytime you do a reading
const double temp = 1.0/80.0;
//Stores the pulse length
volatile uint32_t pulse=0;
//Tells the main code if the a pulse is being read at the moment
volatile uint8_t echowait=0;
int
main()
{
//Set system clock to 80Mhz
SysCtlClockSet(SYSCTL_SYSDIV_2_5|SYSCTL_USE_PLL|SYSCTL_OSC_MAIN|SYSCTL_XTAL_16MHZ);
//Configures the UART
InitConsole();
//Configures the timer
Captureinit();
//Configure Trigger pin
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
SysCtlDelay(3);
GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, GPIO_PIN_3);
//Configure Echo pin
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
SysCtlDelay(3);
GPIOPinTypeGPIOInput(GPIO_PORTA_BASE, GPIO_PIN_2);
GPIOIntEnable(GPIO_PORTA_BASE, GPIO_PIN_2);
GPIOIntTypeSet(GPIO_PORTA_BASE, GPIO_PIN_2,GPIO_BOTH_EDGES);
GPIOIntRegister(GPIO_PORTA_BASE,inputInt);
while(1)
{
//Checks if a pulse read is in progress
if(echowait != 1){
//Does the required pulse of 10uS
GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_3, GPIO_PIN_3);
SysCtlDelay(266);
GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_3, ~GPIO_PIN_3);
/*
This makes the code wait for a reading to finish
You can omit this part if you want the code to be non-blocking but
reading is only ready when echowait=0.
*/
while(echowait != 0);
//Converts the counter value to cm.
pulse =(uint32_t)(temp * pulse);
pulse = pulse / 58;
//Prints out the distance measured.
UARTprintf("distance = %2dcm \n" , pulse);
}
//wait about 10ms until the next reading.
SysCtlDelay(400000);
}
}
void
inputInt(void)
{
//Clear interrupt flag. Since we only enabled on this is enough
GPIOIntClear(GPIO_PORTA_BASE, GPIO_PIN_2);
/*
If it's a rising edge then set he timer to 0
It's in periodic mode so it was in some random value
*/
if ( GPIOPinRead(GPIO_PORTA_BASE, GPIO_PIN_2) == GPIO_PIN_2){
HWREG(TIMER2_BASE + TIMER_O_TAV) = 0; //Loads value 0 into the timer.
TimerEnable(TIMER2_BASE,TIMER_A);
echowait=1;
}
/*
If it's a falling edge that was detected, then get the value of the counter
*/
else{
pulse = TimerValueGet(TIMER2_BASE,TIMER_A); //record value
TimerDisable(TIMER2_BASE,TIMER_A);
echowait=0;
}
}
void
Captureinit(void)
{
/*
Set the timer to be periodic.
*/
SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER2);
SysCtlDelay(3);
TimerConfigure(TIMER2_BASE, TIMER_CFG_PERIODIC_UP);
TimerEnable(TIMER2_BASE,TIMER_A);
}
void
InitConsole(void)
{
//
// Enable GPIO port A which is used for UART0 pins.
// TODO: change this to whichever GPIO port you are using.
//
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
SysCtlDelay(3);
//
// Configure the pin muxing for UART0 functions on port A0 and A1.
// This step is not necessary if your part does not support pin muxing.
// TODO: change this to select the port/pin you are using.
//
GPIOPinConfigure(GPIO_PA0_U0RX);
GPIOPinConfigure(GPIO_PA1_U0TX);
//
// Enable UART0 so that we can configure the clock.
//
SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
//
// Use the internal 16MHz oscillator as the UART clock source.
//
UARTClockSourceSet(UART0_BASE, UART_CLOCK_PIOSC);
//
// Select the alternate (UART) function for these pins.
// TODO: change this to select the port/pin you are using.
//
GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
//
// Initialize the UART for console I/O.
//
UARTStdioConfig(0, 115200, 16000000);
}
LINK ERROR
**** Build of configuration Debug for project HC-SR04-UltraSonic ****
"C:\\ti\\ccsv7\\utils\\bin\\gmake" -k -j 4 all -O
'Building file: "../HC-SR04.c"'
'Invoking: ARM Compiler'
"C:/ti/ccsv7/tools/compiler/ti-cgt-arm_16.9.6.LTS/bin/armcl" -mv7M4 --code_state=16 --float_support=FPv4SPD16 -me -O2 --fp_mode=relaxed --include_path="E:/TiArm/HC-SR04-UltraSonic" --include_path="C:/ti/TivaWare_C_Series-2.1.4.178" --include_path="C:/ti/TivaWare_C_Series-2.1.4.178/utils" --include_path="C:/ti/ccsv7/tools/compiler/ti-cgt-arm_16.9.6.LTS/include" --define=ccs="ccs" --define=PART_TM4C123GH6PM -g --gcc --diag_warning=225 --diag_wrap=off --display_error_number --abi=eabi --preproc_with_compile --preproc_dependency="HC-SR04.d_raw" "../HC-SR04.c"
'Finished building: "../HC-SR04.c"'
'Building target: "HC-SR04-UltraSonic.out"'
'Invoking: ARM Linker'
"C:/ti/ccsv7/tools/compiler/ti-cgt-arm_16.9.6.LTS/bin/armcl" -mv7M4 --code_state=16 --float_support=FPv4SPD16 -me -O2 --fp_mode=relaxed --define=ccs="ccs" --define=PART_TM4C123GH6PM -g --gcc --diag_warning=225 --diag_wrap=off --display_error_number --abi=eabi -z -m"HC-SR04-UltraSonic.map" --heap_size=128 --stack_size=512 -i"C:/ti/ccsv7/tools/compiler/ti-cgt-arm_16.9.6.LTS/lib" -i"C:/ti/ccsv7/tools/compiler/ti-cgt-arm_16.9.6.LTS/include" --reread_libs --diag_wrap=off --display_error_number --warn_sections --xml_link_info="HC-SR04-UltraSonic_linkInfo.xml" --rom_model -o "HC-SR04-UltraSonic.out" "./HC-SR04.obj" "./tm4c123gh6pm_startup_ccs.obj" "./uartstdio.obj" "../tm4c123gh6pm.cmd" -llibc.a
<Linking>
undefined first referenced
symbol in file
--------- ----------------
GPIOIntClear ./HC-SR04.obj
GPIOIntEnable ./HC-SR04.obj
GPIOIntRegister ./HC-SR04.obj
GPIOIntTypeSet ./HC-SR04.obj
GPIOPinConfigure ./HC-SR04.obj
GPIOPinRead ./HC-SR04.obj
GPIOPinTypeGPIOInput ./HC-SR04.obj
GPIOPinTypeGPIOOutput ./HC-SR04.obj
GPIOPinTypeUART ./HC-SR04.obj
GPIOPinWrite ./HC-SR04.obj
SysCtlClockSet ./HC-SR04.obj
SysCtlDelay ./HC-SR04.obj
SysCtlPeripheralEnable ./HC-SR04.obj
SysCtlPeripheralPresent ./uartstdio.obj
TimerConfigure ./HC-SR04.obj
TimerDisable ./HC-SR04.obj
TimerEnable ./HC-SR04.obj
TimerValueGet ./HC-SR04.obj
UARTCharGet ./uartstdio.obj
UARTCharPut ./uartstdio.obj
UARTClockSourceSet ./HC-SR04.obj
UARTConfigSetExpClk ./uartstdio.obj
UARTEnable ./uartstdio.obj
error #10234-D: unresolved symbols remain
error #10010: errors encountered during linking; "HC-SR04-UltraSonic.out" not built
>> Compilation failure
makefile:143: recipe for target 'HC-SR04-UltraSonic.out' failed
gmake[1]: *** [HC-SR04-UltraSonic.out] Error 1
gmake: *** [all] Error 2
makefile:139: recipe for target 'all' failed
**** Build Finished ****
PROBLEMS
Description Resource Path Location Type
#10010 null: errors encountered during linking; "HC-SR04-UltraSonic.out" not built HC-SR04-UltraSonic C/C++ Problem
<a href="processors.wiki.ti.com/.../10234"> null: unresolved symbols remain HC-SR04-UltraSonic C/C++ Problem
gmake: *** [all] Error 2 HC-SR04-UltraSonic C/C++ Problem
gmake[1]: *** [HC-SR04-UltraSonic.out] Error 1 HC-SR04-UltraSonic C/C++ Problem
unresolved symbol GPIOIntClear, first referenced in ./HC-SR04.obj HC-SR04-UltraSonic C/C++ Problem
unresolved symbol GPIOIntEnable, first referenced in ./HC-SR04.obj HC-SR04-UltraSonic C/C++ Problem
unresolved symbol GPIOIntRegister, first referenced in ./HC-SR04.obj HC-SR04-UltraSonic C/C++ Problem
unresolved symbol GPIOIntTypeSet, first referenced in ./HC-SR04.obj HC-SR04-UltraSonic C/C++ Problem
unresolved symbol GPIOPinConfigure, first referenced in ./HC-SR04.obj HC-SR04-UltraSonic C/C++ Problem
unresolved symbol GPIOPinRead, first referenced in ./HC-SR04.obj HC-SR04-UltraSonic C/C++ Problem
unresolved symbol GPIOPinTypeGPIOInput, first referenced in ./HC-SR04.obj HC-SR04-UltraSonic C/C++ Problem
unresolved symbol GPIOPinTypeGPIOOutput, first referenced in ./HC-SR04.obj HC-SR04-UltraSonic C/C++ Problem
unresolved symbol GPIOPinTypeUART, first referenced in ./HC-SR04.obj HC-SR04-UltraSonic C/C++ Problem
unresolved symbol GPIOPinWrite, first referenced in ./HC-SR04.obj HC-SR04-UltraSonic C/C++ Problem
unresolved symbol SysCtlClockSet, first referenced in ./HC-SR04.obj HC-SR04-UltraSonic C/C++ Problem
unresolved symbol SysCtlDelay, first referenced in ./HC-SR04.obj HC-SR04-UltraSonic C/C++ Problem
unresolved symbol SysCtlPeripheralEnable, first referenced in ./HC-SR04.obj HC-SR04-UltraSonic C/C++ Problem
unresolved symbol SysCtlPeripheralPresent, first referenced in ./uartstdio.obj HC-SR04-UltraSonic C/C++ Problem
unresolved symbol TimerConfigure, first referenced in ./HC-SR04.obj HC-SR04-UltraSonic C/C++ Problem
unresolved symbol TimerDisable, first referenced in ./HC-SR04.obj HC-SR04-UltraSonic C/C++ Problem
unresolved symbol TimerEnable, first referenced in ./HC-SR04.obj HC-SR04-UltraSonic C/C++ Problem
unresolved symbol TimerValueGet, first referenced in ./HC-SR04.obj HC-SR04-UltraSonic C/C++ Problem
unresolved symbol UARTCharGet, first referenced in ./uartstdio.obj HC-SR04-UltraSonic C/C++ Problem
unresolved symbol UARTCharPut, first referenced in ./uartstdio.obj HC-SR04-UltraSonic C/C++ Problem
unresolved symbol UARTClockSourceSet, first referenced in ./HC-SR04.obj HC-SR04-UltraSonic C/C++ Problem
unresolved symbol UARTConfigSetExpClk, first referenced in ./uartstdio.obj HC-SR04-UltraSonic C/C++ Problem
unresolved symbol UARTEnable, first referenced in ./uartstdio.obj HC-SR04-UltraSonic C/C++ Problem
I