Other Parts Discussed in Thread: TM4C123GH6PM
Tool/software: Linux
Hi
I am trying to blink LEDs on the Tiva launchpad.
Here is my source code for blinking LEDs
1 #include <stdbool.h>
2 #include <stdint.h>
3
4 #include "inc/hw_types.h"
5 #include "inc/hw_gpio.h"
6 #include "inc/hw_memmap.h"
7 #include "inc/hw_sysctl.h"
8 #include "driverlib/gpio.h"
9 #include "driverlib/rom.h"
10 #include "driverlib/sysctl.h"
11 #include "driverlib/pin_map.h"
12 #include "driverlib/can.h"
13
14 #define LED_RED GPIO_PIN_1
15 #define LED_BLUE GPIO_PIN_2
16 #define LED_GREEN GPIO_PIN_3
17 #define SW2 GPIO_PIN_0
18 #define SW1 GPIO_PIN_4
19
20 int main()
21 {
22 ROM_SysCtlClockSet(SYSCTL_SYSDIV_4|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN);
23 ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
24 ROM_GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, LED_RED|LED_BLUE|LED_GREEN);
25 ROM_GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, SW2);
26
27 for (;;) {
28
29 if (GPIOPinRead(GPIO_PORTF_BASE,SW2)) {
30 GPIOPinWrite(GPIO_PORTF_BASE, LED_GREEN, LED_GREEN);
31 } else {
32 GPIOPinWrite(GPIO_PORTF_BASE, LED_GREEN, 0);
33 }
34 }
35 }
36
when I compiled the above code using make, I got the following errors
sudha@VCHN172:~/tmc4123/Embedded/led-project$ make
arm-none-eabi-gcc -o build/main.o src/main.c -g -mthumb -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=softfp -Os -ffunction-sections -fdata-sections -MD -std=c99 -Wall -pedantic -DPART_TM4C123GH6PM -c -I/home/sudha/tmc4123/Embedded/tivaware -DTARGET_IS_BLIZZARD_RA1
arm-none-eabi-ld -o build/a.out build/main.o build/startup_gcc.o -T TM4C123GH6PM.ld --entry ResetISR --gc-sections
build/main.o: In function `main':
/home/sudha/tmc4123/Embedded/led-project/src/main.c:29: undefined reference to `GPIOPinRead'
/home/sudha/tmc4123/Embedded/led-project/src/main.c:32: undefined reference to `GPIOPinWrite'
Makefile:57: recipe for target 'build/a.out' failed
make: *** [build/a.out] Error 1
but when I use ROM_GPIOPinWrite or ROM_GPIOPinRead, the code is compiled successfully.
Please help me what is the issue when using GPIOPinWrite/GPIOPinRead, and how to solve the issue.