http://wiki.ros.org/rosserial_tivac/Tutorials/TivaWare%20Setup
http://www.ti.com/tool/SW-TM4C
http://www.ti.com/tool/SW-TM4C#technicaldocuments
Inside Energia, choose “Board Manager” and install components for Tiva:
Creating the simplest hello-world program:
/*
Blink
The basic Energia example.
Turns on an LED on for one second, then off for one second, repeatedly.
Change the LED define to blink other LEDs.
Hardware Required:
* LaunchPad with an LED
This example code is in the public domain.
*/
// most launchpads have a red LED
#define LED RED_LED
//see pins_energia.h for more LED definitions
//#define LED GREEN_LED
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(LED, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
digitalWrite(LED, HIGH); // turn the LED on (HIGH is the voltage level)
delay(50); // wait for a second
digitalWrite(LED, LOW); // turn the LED off by making the voltage LOW
delay(500); // wait for a second
}
Looking at the command line executed via “ps -ef”:
The gcc commands spewed out:
/home/tthtlc/.energia15/packages/energia/tools/arm-none-eabi-gcc/6.3.1-20170620/bin/../lib/gcc/arm-none-eabi/6.3.1/cc1plus -quiet -I /home/tthtlc/.energia15/packages/energia/hardware/tivac/1.0.3/variants/EK-TM4C1294XL -I /home/tthtlc/.energia15/packages/energia/hardware/tivac/1.0.3/system/driverlib -I /home/tthtlc/.energia15/packages/energia/hardware/tivac/1.0.3/system/inc -I /home/tthtlc/.energia15/packages/energia/hardware/tivac/1.0.3/system -I /home/tthtlc/.energia15/packages/energia/hardware/tivac/1.0.3/cores/tivac -I /home/tthtlc/.energia15/packages/energia/hardware/tivac/1.0.3/variants/EK-TM4C1294XL -imultilib thumb/v7e-m/fpv4-sp/hard -iprefix /home/tthtlc/.energia15/packages/energia/tools/arm-none-eabi-gcc/6.3.1-20170620/bin/../lib/gcc/arm-none-eabi/6.3.1/ -isysroot /home/tthtlc/.energia15/packages/energia/tools/arm-none-eabi-gcc/6.3.1-20170620/bin/../arm-none-eabi -MMD /tmp/arduino_build_5357/sketch/Blink.ino.cpp.d -MQ /tmp/arduino_build_5357/sketch/Blink.ino.cpp.o -D__USES_INITFINI__ -D printf=iprintf -D F_CPU=120000000L -D ARDUINO=10807 -D ENERGIA=10807 -D ENERGIA_EK_TM4C1294XL -D ENERGIA_ARCH_TIVAC /tmp/arduino_build_5357/sketch/Blink.ino.cpp -quiet -dumpbase Blink.ino.cpp -mcpu=cortex-m4 -mthumb -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mabi=aapcs -auxbase-strip /tmp/arduino_build_5357/sketch/Blink.ino.cpp.o -g -Os -w -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -fno-rtti -fno-exceptions –param max-inline-insns-single=500 -o /tmp/ccxPVy15.s
We can see that it is using arm-none-eabi-gcc to compile before being flashed, and the output are also “thumb” formatted:
cd /home/tthtlc/.energia15/packages/energia/tools/arm-none-eabi-gcc/6.3.1-20170620/bin
and you can see the tools:
And going to the /tmp/ directory, there is a temporary directory created for processing all the ELF processing:
Using objdump to disassemble the ELF:
export PATH=/home/tthtlc/.energia15/packages/energia/tools/arm-none-eabi-gcc/6.3.1-20170620/bin:$PATH
arm-none-eabi-objdump -d Blink.ino.elf
And the full details are pasted here:
https://pastebin.com/z2h88Bqs
But essentially the following are found:
The g_pfnVectors can be found from “$HOME/.energia15/packages/energia/hardware/tivac/1.0.3/cores/tivac/startup_gcc.c“. Within the g_pfnVectors are all the dynamic function pointers for interrupt handling:
These hardware vector offset are determined by hardware, and therefore are also declared as “constant”, and cannot be changed.
From the “libraries/core.a” found in the arduino_build_5357 directory, are listed all the core libraries components – which will include all the functions declared in the above header file:
00000000 <UARTIntHandler>:
00000000 <UARTIntHandler1>:
00000000 <UARTIntHandler2>:
00000000 <UARTIntHandler3>: ……etc
Only some of these will be compiled into the .text section of the ELF.
If we had used “Export compiled binary” and generated a binary in the export library directory, we can identify that binary as identical to the “.text” section of the ELF file above – which is exactly the portion only needed to be flashed to the evaluation kit.
To understand fully the different hardware handler of the binary will require the full datasheet of the microcontroller:
http://www.ti.com/lit/ds/symlink/tm4c1294ncpdt.pdf
To understand how the blinking happens, we shall go into the digitalWrite() implementation (inside $HOME/.energia15/packages/energia/hardware/tivac/1.0.3/cores/tivac/wiring_digital.c):
85 void digitalWrite(uint8_t pin, uint8_t val)
86 {
87 uint8_t bit = digitalPinToBitMask(pin);
88 uint8_t mask = val ? bit : 0;
89 uint8_t port = digitalPinToPort(pin);
90 uint32_t portBase = (uint32_t) portBASERegister(port);
91
92 if (port == NOT_A_PORT) return;
93
94 ROM_GPIOPinWrite(portBase, bit, mask);
95 }
These are programming the 4 LEDs.
Four user LEDs are provided on the board. D1 and D2 are connected to GPIOs PN1 and PN0. D3 and D4 are connected to GPIOs PF4 and PF0.
For details (on other GPIOs, timers etc) please lookup datasheet for the board:
http://www.ti.com/tool/EK-TM4C1294XL
http://www.ti.com/lit/ug/spmu365c/spmu365c.pdf
And other document:
http://www.ti.com/product/TM4C1294NCPDT/technicaldocuments
https://www.ti.com/product/TM4C1290NCPDT
Other relevant links:
https://github.com/Lauszus/TM4C-MSC-bootloader
https://github.com/shawn-dsilva/tm4c-linux-template
https://github.com/energia/Energia
https://github.com/YashBansod/ARM-TM4C-CCS
You must be logged in to post a comment.