Part Number: TM4C129ENCPDT
Tool/software: Code Composer Studio
I am trying my first code in embedded C++. I have some requirement to use Exceptions and Classes. So I have to shift from embedded C to C++
I wrote the following c++ code in ccs7. It is just to blink the on board led on the TI Evaluation board. The program compiled with no error. But when upleaded into the board, it gets uploaded and starts running automatically.
Usually when written in embedded C and when I upload the code in ccs, it gets uploaded into the board and waits for the resume button to be pressed. Only when I press the resume button the code starts running.
But in this c++ code, as soon I upload the code, it shows that the code is running. But no output is seen in the board. I doubt that the code itself is not uploaded or not getting started.
Do I need to change any settings in the file properties to run the c++ code specifically?
I created an empty project in from File-->New-->CCSProject.
Then added a Souce file in the project. Choosed the template as "Default C++ Source template". This is the only place where I mentioned that the code I am going to write is going to be in c++.
Then I started with including the the header file "iostream" just to verify whether the c++ template is working or not.
I have some my own driver files written in embedded C for some ICs. If I switch to embedded C++ and start working with Classes and Objects, Will I still be able to use those driver files?
Thank You for your time.
#include <iostream> #include <stdbool.h> #include <stdint.h> #include <stdlib.h> #include "inc/hw_ints.h" #include "inc/hw_memmap.h" #include "driverlib/flash.h" #include "driverlib/interrupt.h" #include "driverlib/gpio.h" #include "driverlib/rom_map.h" #include "driverlib/sysctl.h" #include "driverlib/systick.h" #include "drivers/pinout.h" #include "driverlib/debug.h" #include "driverlib/pin_map.h" #include "driverlib/rom.h" #include "driverlib/ssi.h" #include "driverlib/eeprom.h" #include "driverlib/uart.h" #include "string.h" #include "utils/ustdlib.h" #include "utils/uartstdio.h" using namespace std; int g_ui32SysClock; void main() { // Run from the PLL at 120 MHz. g_ui32SysClock = SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), 120000000); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPION); SysCtlPeripheralReset(SYSCTL_PERIPH_GPION); while(!SysCtlPeripheralReady(SYSCTL_PERIPH_GPION)) {} GPIOPinTypeGPIOOutput(GPIO_PORTN_BASE, GPIO_PIN_1); SysCtlDelay(40000*10); while(1) { GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_1, GPIO_PIN_1); SysCtlDelay(40000*500); GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_1, 0x00); SysCtlDelay(40000*500); } }