DAVE - C++ project

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Not applicable
Hi all,

I try to setup a C++ project in DAVE. The reason is, that the XMC is part of a bigger project with C/C++-classes which I need. Because of code reusability we don't want to program the functionability of these classes again in C. So I made a normal XMC project with a main.cpp. Almost everything seems to work, except one thing:
The startup code located in the Startup directory (system_XMC1100.c and system_XMC1100.s) make problems, but I don't know really why. I attached the output message of the compile process below. There the compilier complains about uint32_t for example. These kind of data types (uint8_t ...) are almost used everywhere and all other files compilied without problems


Building file: ../Startup/system_XMC1100.c
Invoking: ARM-GCC C Compiler
"C:\DAVE-3.1.10\ARM-GCC/bin/arm-none-eabi-gcc" -DDAVE_CE -DUC_ID=1101009 -D__cplusplus -I"C:\DAVE-3.1.10\eclipse\/../CMSIS/Include" -I"C:\DAVE-3.1.10\eclipse\/../CMSIS/Infineon/Include" -I"C:\DAVE-3.1.10\ARM-GCC/arm-none-eabi/include" -I"C:\DAVE-3.1.10\eclipse\/../emWin/Start/GUI/inc" -I"C:\DAVE-3.1.10\eclipse\/../CMSIS/Infineon/XMC1100_series/Include" -I"C:\home\I2C003_Slave\Dave\Generated\inc\LIBS" -I"C:\home\I2C003_Slave\Dave\Generated\inc\DAVESupport" -O0 -ffunction-sections -Wall -std=gnu99 -mfloat-abi=soft -Wa,-adhlns="Startup/system_XMC1100.o.lst" -c -fmessage-length=0 -MMD -MP -MF"Startup/system_XMC1100.d" -MT"Startup/system_XMC1100.d Startup/system_XMC1100.o" -mcpu=cortex-m0 -mthumb -g3 -gdwarf-2 -o "Startup/system_XMC1100.o" "../Startup/system_XMC1100.c"
In file included from ../Startup/system_XMC1100.c:37:0:
C:\DAVE-3.1.10\eclipse\/../CMSIS/Infineon/XMC1100_series/Include/system_XMC1100.h:38:8: error: expected identifier or '(' before string constant
In file included from ../Startup/system_XMC1100.c:38:0:
C:\DAVE-3.1.10\eclipse\/../CMSIS/Infineon/XMC1100_series/Include/XMC1100.h:48:8: error: expected identifier or '(' before string constant
../Startup/system_XMC1100.c:50:1: error: unknown type name 'uint32_t'
../Startup/system_XMC1100.c: In function 'SystemInit':
../Startup/system_XMC1100.c:82:3: warning: implicit declaration of function 'SystemCoreClockUpdate' [-Wimplicit-function-declaration]
../Startup/system_XMC1100.c: At top level:
../Startup/system_XMC1100.c:91:6: warning: conflicting types for 'SystemCoreClockUpdate' [enabled by default]
../Startup/system_XMC1100.c:82:3: note: previous implicit declaration of 'SystemCoreClockUpdate' was here
../Startup/system_XMC1100.c: In function 'SystemCoreClockUpdate':
../Startup/system_XMC1100.c:93:3: error: unknown type name 'uint32_t'
../Startup/system_XMC1100.c:95:12: error: 'SCU_CLK_TypeDef' undeclared (first use in this function)
../Startup/system_XMC1100.c:95:12: note: each undeclared identifier is reported only once for each function it appears in
../Startup/system_XMC1100.c:95:12: error: expected expression before ')' token
../Startup/system_XMC1100.c:96:12: error: expected expression before ')' token
make: *** [Startup/system_XMC1100.o] Error 1

**** Build Finished ****


I hope someone can help! I had a look into the files mentioned in the output message but I didn't find any suspicious.

Kind regards
Sebastian
0 Likes
5 Replies
Not applicable
I tried with defining the symbol __cplusplus in the C-Preprocessor settings, but unfortunately without success.
0 Likes
Not applicable
HI,

Did you update your DAVE v3.1.10 with a CMSIS patch published last year.

If not, could you please update the CMSIS folder as explained at http://www.infineonforums.com/threads/115-Information-about-Updates?p=5048&viewfull=1#post5048

Regards,
Daryl
0 Likes
Not applicable
Hi Daryl,

thank you very much for your answer. I made very good progress with your help. The C++ executable compiles now and is even running on my XMC1100. Now another (hopefully small) problem occured:

I have three interrupt handlers, formerly defined in my main.c, now defined in my new main.cpp. They are responsible for my I2C communication. My XMC is a slave. I have the following behaviour: as long as I don't send anything from the master, my main-loop is running without problems, I can step forward withoupt problems.
The problem occurs when I initiate a write request from the master. In my C-project, I see, that my custom interrupt routine is callec. But in my new C++-project, after the interrupt the XMC is trapped in Insert_ExceptionHandler USIC0_0_IRQHandler in the startup_XMC1100.s. It seems to me, that my custom interrupt routine is not found anymore.

I am wondering about this, because my NVIC002_Conf.h contains the following code:


#ifndef _NVIC002_CONF_H_
#define _NVIC002_CONF_H_

#ifdef __cplusplus
extern "C" {
#endif

/****************************************************************************
@Defines
****************************************************************************/
#define DEBUG_APP false

/* User defined function mapped to IRQ_Hdlr_9 */
#define slave_Rx_handler IRQ_Hdlr_9

/* User defined function mapped to IRQ_Hdlr_10 */
#define slave_Read_Req_handler IRQ_Hdlr_10

/* User defined function mapped to IRQ_Hdlr_11 */
#define slave_TxD_Buffer_handler IRQ_Hdlr_11

// .....




My slave_Rx_handler, for example (located now in main.cpp) is this


void slave_Rx_handler(void)
{
// ein Byte empfangen
I2C003_ReadData(&I2C003_Handle0, &I2C_ReadBuffer[WritePtr++]);
// Empfangs-FIFO loeschen
USIC_FlushRxFIFO(I2C003_Handle0.I2CRegs);

// ...


Thanks for helping!!!

Kind regards
Sebastian
0 Likes
Not applicable
Hi all,

I have a solution for the "problem". In fact it seems NOT to be a problem. 🙂 I remembered that I have seen a lot of interrupt routines in curly brackets with the extern "C"-keyword due to the different signatures for C and C++ functions. Compiled once again and it worked. Just for completeness I provide here a little code snippet:


extern "C"
{
// Receive Interrupt routine
void slave_Rx_handler(void)
{
// do custom staff here
}

// more interrupt routines here
// ...
} // extern "C"


Perhaps for someone of you the information is also interesting and time-saving!

Kind regards
Sebastian
0 Likes
Not applicable
Thanks for the update, Sebastian! 🙂
0 Likes