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.

RTOS/TM4C123GH6PM: RTOS/TM4C123GH6PM:

Part Number: TM4C123GH6PM

Tool/software: TI-RTOS

I am working on TIRTOS platform using TM4c123GH6PM.. I want to create LED Toggling using C++ using concept of Classes and Objects . Below is my code where I have used one idle function and tried to toggle LED. My code is on .cpp extension. Empty.c file I have excluded from build because it was not supporting classes and object.. 

#include <xdc/std.h> //mandatory - have to include first, for BIOS types
#include <ti/sysbios/BIOS.h> //mandatory - if you call APIs like BIOS_start()
#include <xdc/runtime/Log.h> //needed for any Log_info() call
#include <xdc/cfg/global.h>//header file for statically defined objects/handles
#include <stdint.h>
#include <stdbool.h>

#include "inc/hw_types.h"
#include "inc/hw_memmap.h"
#include "driverlib/sysctl.h"
#include "driverlib/gpio.h"
#include "inc/hw_ints.h"
#include "driverlib/interrupt.h"
#include "driverlib/timer.h"
#include <time.h>
void hardware_init(void);
void ledToggle1(void);
void main(void)
{
   hardware_init();             // init hardware via Xware
   BIOS_start();                // Start BIOS Scheduler (never returns)
   class LED_Status
  {

  public:
  	 int ON;
  	 int OFF;
  };
   LED_Status status;
   status.ON=8;
   status.OFF=0;

}

void hardware_init(void)
{
//Set CPU Clock to 40MHz. 400MHz PLL/2 = 200 DIV 5 = 40MHz
 SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN);
// ADD Tiva-C GPIO setup - enables port, sets pins 1-3 (RGB) pins for output
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3);

}
void ledToggle1(void)
{
	GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_3, status.ON);	// LED ON
	SysCtlDelay(2000000);				// DELAY
	GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_3, status.OFF);	// LED OFF
	SysCtlDelay(2000000);
 }

I am getting the following errors when I compile .cpp file.

Description Resource Path Location Type
#10010 errors encountered during linking; "rtos1.out" not built rtos1 C/C++ Problem
<a href="file:/c:/ti/ccsv6/tools/compiler/dmed/HTML/10234.html">#10234-D</a> unresolved symbols remain rtos1 C/C++ Problem
unresolved symbol ledToggle1, first referenced in E:\dg\rtos1\Debug\configPkg\package\cfg\empty_pem4f.oem4f rtos1 C/C++ Problem
unresolved symbol main, first referenced in C:\ti\ccsv6\tools\compiler\ti-cgt-arm_5.2.5\lib\rtsv7M4_T_le_v4SPD16_eabi.lib<args_main.obj> rtos1 C/C++ Problem

How could this problem be solved. I have to use C++ concepts like Classes and Objects. 

This code runs fine on NON RTOS .cpp files but its not working here

  • Your compiler, which you haven't mentioned, is telling you what is wrong.

    Madhusudan Kumar said:
    unresolved symbol ledToggle1, first referenced in E:\dg\rtos1\Debug\configPkg\package\cfg\empty_pem4f.oem4f rtos1

    So your program cannot find ledToggle, but you don't show us the file it is referenced from. There are several possibilities, function type mismatcn, C/C++ mismatch, or you are not including the file in your link.

    Madhusudan Kumar said:
    unresolved symbol main, first referenced in C:\ti\ccsv6\tools\compiler\ti-cgt-arm_5.2.5\lib\rtsv7M4_T_le_v4SPD16_eabi.lib

    This one is a little more subtle. You have not declared main properly for C++. See for instance https://stackoverflow.com/questions/4207134/what-is-the-proper-declaration-of-main

    It's also possible you do not have you link set up correctly.

    Finally your compiler should have complained about there being no definition for status in ledToggle1. The fact that it doesn't leads me to think that you are not compiling your C++ file

    Robert

  • Thanks Robert. I went through your suggestions and rectified it. I also used extern "C" and defined the functions in side it . Thank you so much.